From 00d346d51d459d10fa6ca7aa9768ed5012a743df Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 18 May 2022 08:30:39 +0000 Subject: [PATCH 01/63] more --- include/common/tdataformat.h | 2 +- source/common/src/tdataformat.c | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h index e13705d403..d9220c461d 100644 --- a/include/common/tdataformat.h +++ b/include/common/tdataformat.h @@ -62,7 +62,7 @@ int32_t tTSRowBuilderGetRow(STSRowBuilder *pBuilder, const STSRow2 **ppRow); int32_t tTagNew(STagVal *pTagVals, int16_t nTag, STag **ppTag); void tTagFree(STag *pTag); void tTagGet(STag *pTag, int16_t cid, int8_t type, uint8_t **ppData, int32_t *nData); -int32_t tEncodeTag(SEncoder *pEncoder, STag *pTag); +int32_t tEncodeTag(SEncoder *pEncoder, const STag *pTag); int32_t tDecodeTag(SDecoder *pDecoder, const STag **ppTag); // STRUCT ================= diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c index 8aa8ed2f14..4bc01cba70 100644 --- a/source/common/src/tdataformat.c +++ b/source/common/src/tdataformat.c @@ -597,17 +597,12 @@ void tTagGet(STag *pTag, int16_t cid, int8_t type, uint8_t **ppData, int32_t *nD } } -int32_t tEncodeTag(SEncoder *pEncoder, STag *pTag) { - // return tEncodeBinary(pEncoder, (uint8_t *)pTag, pTag->len); - ASSERT(0); - return 0; +int32_t tEncodeTag(SEncoder *pEncoder, const STag *pTag) { + return tEncodeBinary(pEncoder, (const uint8_t *)pTag, pTag->len); } int32_t tDecodeTag(SDecoder *pDecoder, const STag **ppTag) { - // uint32_t n; - // return tDecodeBinary(pDecoder, (const uint8_t **)ppTag, &n); - ASSERT(0); - return 0; + return tDecodeBinary(pDecoder, (const uint8_t **)ppTag, NULL); } #if 1 // =================================================================================================================== From 70042a918c01210061999569d0fd76af76b20fe6 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 18 May 2022 09:17:38 +0000 Subject: [PATCH 02/63] more data format --- include/common/tdataformat.h | 3 ++- source/common/src/tdataformat.c | 47 ++++++++++++++++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h index d9220c461d..29e9695e3e 100644 --- a/include/common/tdataformat.h +++ b/include/common/tdataformat.h @@ -61,7 +61,8 @@ int32_t tTSRowBuilderGetRow(STSRowBuilder *pBuilder, const STSRow2 **ppRow); // STag int32_t tTagNew(STagVal *pTagVals, int16_t nTag, STag **ppTag); void tTagFree(STag *pTag); -void tTagGet(STag *pTag, int16_t cid, int8_t type, uint8_t **ppData, int32_t *nData); +int32_t tTagSet(STag *pTag, SSchema *pSchema, int32_t nCols, int iCol, uint8_t *pData, uint32_t nData, STag **ppTag); +void tTagGet(STag *pTag, int16_t cid, int8_t type, uint8_t **ppData, uint32_t *nData); int32_t tEncodeTag(SEncoder *pEncoder, const STag *pTag); int32_t tDecodeTag(SDecoder *pDecoder, const STag **ppTag); diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c index 4bc01cba70..f4b8f00e3b 100644 --- a/source/common/src/tdataformat.c +++ b/source/common/src/tdataformat.c @@ -581,7 +581,52 @@ void tTagFree(STag *pTag) { if (pTag) taosMemoryFree(pTag); } -void tTagGet(STag *pTag, int16_t cid, int8_t type, uint8_t **ppData, int32_t *nData) { +int32_t tTagSet(STag *pTag, SSchema *pSchema, int32_t nCols, int iCol, uint8_t *pData, uint32_t nData, STag **ppTag) { + STagVal *pTagVals; + int16_t nTags = 0; + SSchema *pColumn; + uint8_t *p; + uint32_t n; + + pTagVals = (STagVal *)taosMemoryMalloc(sizeof(*pTagVals) * nCols); + if (pTagVals == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + for (int32_t i = 0; i < nCols; i++) { + pColumn = &pSchema[i]; + + if (i == iCol) { + p = pData; + n = nData; + } else { + tTagGet(pTag, pColumn->colId, pColumn->type, &p, &n); + } + + if (p == NULL) continue; + + ASSERT(IS_VAR_DATA_TYPE(pColumn->type) || n == pColumn->bytes); + + pTagVals[nTags].cid = pColumn->colId; + pTagVals[nTags].type = pColumn->type; + pTagVals[nTags].nData = n; + pTagVals[nTags].pData = p; + + nTags++; + } + + // create new tag + if (tTagNew(pTagVals, nTags, ppTag) < 0) { + taosMemoryFree(pTagVals); + return -1; + } + + taosMemoryFree(pTagVals); + return 0; +} + +void tTagGet(STag *pTag, int16_t cid, int8_t type, uint8_t **ppData, uint32_t *nData) { STagIdx *pTagIdx = bsearch(&((STagIdx){.cid = cid}), pTag->idx, pTag->nTag, sizeof(STagIdx), tTagIdxCmprFn); if (pTagIdx == NULL) { *ppData = NULL; From 0584acf505a1c3562d8646a8c513acccf85ec3e3 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Sun, 22 May 2022 22:30:46 +0800 Subject: [PATCH 03/63] trigger CI From e95647970e89473952970c1217dc00d7007f77bf Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Mon, 23 May 2022 22:35:45 +0800 Subject: [PATCH 04/63] scheduler async api --- include/libs/scheduler/scheduler.h | 3 ++ source/libs/scheduler/inc/schedulerInt.h | 20 ++++++---- source/libs/scheduler/src/schJob.c | 48 ++++++++++++++++++----- source/libs/scheduler/src/schRemote.c | 42 ++++++++++---------- source/libs/scheduler/src/scheduler.c | 50 ++++++------------------ 5 files changed, 88 insertions(+), 75 deletions(-) diff --git a/include/libs/scheduler/scheduler.h b/include/libs/scheduler/scheduler.h index dcd058a293..62a97d1be0 100644 --- a/include/libs/scheduler/scheduler.h +++ b/include/libs/scheduler/scheduler.h @@ -64,6 +64,9 @@ typedef struct STaskInfo { SSubQueryMsg *msg; } STaskInfo; +typedef void (*schedulerCallback)(SQueryResult* pResult, void* param, int32_t code); + + int32_t schedulerInit(SSchedulerCfg *cfg); /** diff --git a/source/libs/scheduler/inc/schedulerInt.h b/source/libs/scheduler/inc/schedulerInt.h index ffac0f856d..d2ddd8b695 100644 --- a/source/libs/scheduler/inc/schedulerInt.h +++ b/source/libs/scheduler/inc/schedulerInt.h @@ -40,8 +40,8 @@ enum { }; typedef struct SSchTrans { - void *transInst; - void *transHandle; + void *pTrans; + void *pHandle; } SSchTrans; typedef struct SSchHbTrans { @@ -74,12 +74,17 @@ typedef struct SSchJobStat { } SSchJobStat; -typedef struct SSchedulerStat { +typedef struct SSchStat { SSchApiStat api; SSchRuntimeStat runtime; SSchJobStat job; -} SSchedulerStat; +} SSchStat; +typedef struct SSchResInfo { + SQueryResult queryRes; + schedulerCallback userFp; + void* userParam; +} SSchResInfo; typedef struct SSchedulerMgmt { uint64_t taskId; // sequential taksId @@ -89,7 +94,7 @@ typedef struct SSchedulerMgmt { bool exit; int32_t jobRef; int32_t jobNum; - SSchedulerStat stat; + SSchStat stat; SHashObj *hbConnections; } SSchedulerMgmt; @@ -170,7 +175,7 @@ typedef struct SSchJob { SSchJobAttr attr; int32_t levelNum; int32_t taskNum; - void *transport; + void *pTrans; SArray *nodeList; // qnode/vnode list, SArray SArray *levels; // starting from 0. SArray SNodeList *subPlans; // subplan pointer copied from DAG, no need to free it in scheduler @@ -196,6 +201,7 @@ typedef struct SSchJob { void *queryRes; void *resData; //TODO free it or not int32_t resNumOfRows; + SSchResInfo userRes; const char *sql; SQueryProfileSummary summary; } SSchJob; @@ -292,7 +298,7 @@ int32_t schUpdateTaskExecNodeHandle(SSchTask *pTask, void *handle, int32_t rspCo void schFreeRpcCtxVal(const void *arg); int32_t schMakeBrokenLinkVal(SSchJob *pJob, SSchTask *pTask, SRpcBrokenlinkVal *brokenVal, bool isHb); int32_t schRecordTaskExecNode(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, void *handle); -int32_t schExecStaticExplain(void *transport, SArray *pNodeList, SQueryPlan *pDag, int64_t *job, const char *sql, +int32_t schExecStaticExplainJob(void *transport, SArray *pNodeList, SQueryPlan *pDag, int64_t *job, const char *sql, bool syncSchedule); int32_t schExecJobImpl(void *transport, SArray *pNodeList, SQueryPlan *pDag, int64_t *job, const char *sql, int64_t startTs, bool sync); diff --git a/source/libs/scheduler/src/schJob.c b/source/libs/scheduler/src/schJob.c index 14f4646397..a211d90a37 100644 --- a/source/libs/scheduler/src/schJob.c +++ b/source/libs/scheduler/src/schJob.c @@ -39,8 +39,8 @@ int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel * return TSDB_CODE_SUCCESS; } -int32_t schInitJob(SSchJob **pSchJob, SQueryPlan *pDag, void *transport, SArray *pNodeList, const char *sql, - int64_t startTs, bool syncSchedule) { +int32_t schInitJob(SSchJob **pSchJob, SQueryPlan *pDag, void *pTrans, SArray *pNodeList, const char *sql, + SSchResInfo *pRes, int64_t startTs, bool syncSchedule) { int32_t code = 0; int64_t refId = -1; SSchJob *pJob = taosMemoryCalloc(1, sizeof(SSchJob)); @@ -51,8 +51,9 @@ int32_t schInitJob(SSchJob **pSchJob, SQueryPlan *pDag, void *transport, SArray pJob->attr.explainMode = pDag->explainInfo.mode; pJob->attr.syncSchedule = syncSchedule; - pJob->transport = transport; + pJob->pTrans = pTrans; pJob->sql = sql; + pJob->userRes = pRes; if (pNodeList != NULL) { pJob->nodeList = taosArrayDup(pNodeList); @@ -1228,8 +1229,8 @@ void schFreeJobImpl(void *job) { schCloseJobRef(); } -int32_t schExecJobImpl(void *transport, SArray *pNodeList, SQueryPlan *pDag, int64_t *job, const char *sql, - int64_t startTs, bool sync) { +int32_t schExecJobImpl(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int64_t *job, const char *sql, + SSchResInfo *pRes, int64_t startTs, bool sync) { qDebug("QID:0x%" PRIx64 " job started", pDag->queryId); if (pNodeList == NULL || taosArrayGetSize(pNodeList) <= 0) { @@ -1238,7 +1239,7 @@ int32_t schExecJobImpl(void *transport, SArray *pNodeList, SQueryPlan *pDag, int int32_t code = 0; SSchJob *pJob = NULL; - SCH_ERR_JRET(schInitJob(&pJob, pDag, transport, pNodeList, sql, startTs, sync)); + SCH_ERR_JRET(schInitJob(&pJob, pDag, pTrans, pNodeList, sql, pRes, startTs, sync)); SCH_ERR_JRET(schLaunchJob(pJob)); @@ -1261,8 +1262,36 @@ _return: SCH_RET(code); } -int32_t schExecStaticExplain(void *transport, SArray *pNodeList, SQueryPlan *pDag, int64_t *job, const char *sql, - bool syncSchedule) { +int32_t schExecJob(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int64_t *pJob, const char *sql, + int64_t startTs, SSchResInfo *pRes, bool sync) { + int32_t code = 0; + + *pJob = 0; + + if (EXPLAIN_MODE_STATIC == pDag->explainInfo.mode) { + SCH_ERR_RET(schExecStaticExplainJob(pTrans, pNodeList, pDag, pJob, sql, pRes, sync)); + } else { + SCH_ERR_JRET(schExecJobImpl(pTrans, pNodeList, pDag, pJob, sql, pRes, startTs, sync)); + } + +_return: + + if (*pJob) { + SSchJob *job = schAcquireJob(*pJob); + + pRes->code = atomic_load_32(&job->errCode); + pRes->numOfRows = job->resNumOfRows; + pRes->res = job->queryRes; + job->queryRes = NULL; + + schReleaseJob(*pJob); + } + + return code; +} + +int32_t schExecStaticExplainJob(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int64_t *job, const char *sql, + SSchResInfo *pRes, bool sync) { qDebug("QID:0x%" PRIx64 " job started", pDag->queryId); int32_t code = 0; @@ -1277,7 +1306,8 @@ int32_t schExecStaticExplain(void *transport, SArray *pNodeList, SQueryPlan *pDa pJob->attr.explainMode = pDag->explainInfo.mode; pJob->queryId = pDag->queryId; pJob->subPlans = pDag->pSubplans; - + pJob->userRes = pRes; + SCH_ERR_JRET(qExecStaticExplain(pDag, (SRetrieveTableRsp **)&pJob->resData)); int64_t refId = taosAddRef(schMgmt.jobRef, pJob); diff --git a/source/libs/scheduler/src/schRemote.c b/source/libs/scheduler/src/schRemote.c index 6d9f6b435f..247358af8f 100644 --- a/source/libs/scheduler/src/schRemote.c +++ b/source/libs/scheduler/src/schRemote.c @@ -481,7 +481,7 @@ int32_t schGenerateCallBackInfo(SSchJob *pJob, SSchTask *pTask, int32_t msgType, param->queryId = pJob->queryId; param->refId = pJob->refId; param->taskId = SCH_TASK_ID(pTask); - param->transport = pJob->transport; + param->transport = pJob->pTrans; msgSendInfo->param = param; msgSendInfo->fp = fp; @@ -556,7 +556,7 @@ int32_t schMakeHbCallbackParam(SSchJob *pJob, SSchTask *pTask, void **pParam) { param->nodeEpId.nodeId = addr->nodeId; memcpy(¶m->nodeEpId.ep, SCH_GET_CUR_EP(addr), sizeof(SEp)); - param->transport = pJob->transport; + param->transport = pJob->pTrans; *pParam = param; @@ -638,7 +638,7 @@ int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { SCH_ERR_JRET(schGetCallbackFp(TDMT_VND_QUERY_HEARTBEAT, &fp)); param->nodeEpId = epId; - param->transport = pJob->transport; + param->transport = pJob->pTrans; pMsgSendInfo->param = param; pMsgSendInfo->fp = fp; @@ -666,7 +666,7 @@ int32_t schRegisterHbConnection(SSchJob *pJob, SSchTask *pTask, SQueryNodeEpId * int32_t code = 0; SSchHbTrans hb = {0}; - hb.trans.transInst = pJob->transport; + hb.trans.pTrans = pJob->pTrans; SCH_ERR_RET(schMakeHbRpcCtx(pJob, pTask, &hb.rpcCtx)); @@ -743,12 +743,12 @@ int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId) { __async_send_cb_fn_t fp = NULL; SCH_ERR_JRET(schGetCallbackFp(msgType, &fp)); - param->transport = trans.transInst; + param->transport = trans.pTrans; pMsgSendInfo->param = param; pMsgSendInfo->msgInfo.pData = msg; pMsgSendInfo->msgInfo.len = msgSize; - pMsgSendInfo->msgInfo.handle = trans.transHandle; + pMsgSendInfo->msgInfo.handle = trans.pHandle; pMsgSendInfo->msgType = msgType; pMsgSendInfo->fp = fp; @@ -756,13 +756,13 @@ int32_t schBuildAndSendHbMsg(SQueryNodeEpId *nodeEpId) { SEpSet epSet = {.inUse = 0, .numOfEps = 1}; memcpy(&epSet.eps[0], &nodeEpId->ep, sizeof(nodeEpId->ep)); - qDebug("start to send hb msg, instance:%p, handle:%p, fqdn:%s, port:%d", trans.transInst, trans.transHandle, + qDebug("start to send hb msg, pTrans:%p, pHandle:%p, fqdn:%s, port:%d", trans.pTrans, trans.pHandle, nodeEpId->ep.fqdn, nodeEpId->ep.port); - code = asyncSendMsgToServerExt(trans.transInst, &epSet, &transporterId, pMsgSendInfo, true, &rpcCtx); + code = asyncSendMsgToServerExt(trans.pTrans, &epSet, &transporterId, pMsgSendInfo, true, &rpcCtx); if (code) { - qError("fail to send hb msg, instance:%p, handle:%p, fqdn:%s, port:%d, error:%x - %s", trans.transInst, - trans.transHandle, nodeEpId->ep.fqdn, nodeEpId->ep.port, code, tstrerror(code)); + qError("fail to send hb msg, pTrans:%p, pHandle:%p, fqdn:%s, port:%d, error:%x - %s", trans.pTrans, + trans.pHandle, nodeEpId->ep.fqdn, nodeEpId->ep.port, code, tstrerror(code)); SCH_ERR_JRET(code); } @@ -812,8 +812,8 @@ int32_t schUpdateHbConnection(SQueryNodeEpId *epId, SSchTrans *trans) { memcpy(&hb->trans, trans, sizeof(*trans)); SCH_UNLOCK(SCH_WRITE, &hb->lock); - qDebug("hb connection updated, sId:%" PRIx64 ", nodeId:%d, fqdn:%s, port:%d, instance:%p, handle:%p", schMgmt.sId, - epId->nodeId, epId->ep.fqdn, epId->ep.port, trans->transInst, trans->transHandle); + qDebug("hb connection updated, sId:%" PRIx64 ", nodeId:%d, fqdn:%s, port:%d, pTrans:%p, pHandle:%p", schMgmt.sId, + epId->nodeId, epId->ep.fqdn, epId->ep.port, trans->pTrans, trans->pHandle); return TSDB_CODE_SUCCESS; } @@ -833,8 +833,8 @@ int32_t schHandleHbCallback(void *param, const SDataBuf *pMsg, int32_t code) { } SSchTrans trans = {0}; - trans.transInst = pParam->transport; - trans.transHandle = pMsg->handle; + trans.pTrans = pParam->transport; + trans.pHandle = pMsg->handle; SCH_ERR_JRET(schUpdateHbConnection(&rsp.epId, &trans)); @@ -879,7 +879,7 @@ int32_t schMakeCallbackParam(SSchJob *pJob, SSchTask *pTask, void **pParam) { param->queryId = pJob->queryId; param->refId = pJob->refId; param->taskId = SCH_TASK_ID(pTask); - param->transport = pJob->transport; + param->transport = pJob->pTrans; *pParam = param; @@ -1034,15 +1034,15 @@ int32_t schAsyncSendMsg(SSchJob *pJob, SSchTask *pTask, void *transport, SEpSet pMsgSendInfo->msgInfo.pData = msg; pMsgSendInfo->msgInfo.len = msgSize; - pMsgSendInfo->msgInfo.handle = trans->transHandle; + pMsgSendInfo->msgInfo.handle = trans->pHandle; pMsgSendInfo->msgType = msgType; - qDebug("start to send %s msg to node[%d,%s,%d], refId:%" PRIx64 "instance:%p, handle:%p", TMSG_INFO(msgType), + qDebug("start to send %s msg to node[%d,%s,%d], refId:%" PRIx64 "pTrans:%p, pHandle:%p", TMSG_INFO(msgType), ntohl(((SMsgHead *)msg)->vgId), epSet->eps[epSet->inUse].fqdn, epSet->eps[epSet->inUse].port, pJob->refId, - trans->transInst, trans->transHandle); + trans->pTrans, trans->pHandle); int64_t transporterId = 0; - code = asyncSendMsgToServerExt(trans->transInst, epSet, &transporterId, pMsgSendInfo, persistHandle, ctx); + code = asyncSendMsgToServerExt(trans->pTrans, epSet, &transporterId, pMsgSendInfo, persistHandle, ctx); if (code) { SCH_ERR_JRET(code); } @@ -1208,12 +1208,12 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, SCH_SET_TASK_LASTMSG_TYPE(pTask, msgType); - SSchTrans trans = {.transInst = pJob->transport, .transHandle = SCH_GET_TASK_HANDLE(pTask)}; + SSchTrans trans = {.transInst = pJob->pTrans, .transHandle = SCH_GET_TASK_HANDLE(pTask)}; SCH_ERR_JRET(schAsyncSendMsg(pJob, pTask, &trans, &epSet, msgType, msg, msgSize, persistHandle, (rpcCtx.args ? &rpcCtx : NULL))); if (msgType == TDMT_VND_QUERY) { - SCH_ERR_RET(schRecordTaskExecNode(pJob, pTask, addr, trans.transHandle)); + SCH_ERR_RET(schRecordTaskExecNode(pJob, pTask, addr, trans.pHandle)); } return TSDB_CODE_SUCCESS; diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index bd2c7e5b49..de802465c2 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -67,50 +67,24 @@ int32_t schedulerInit(SSchedulerCfg *cfg) { return TSDB_CODE_SUCCESS; } -int32_t schedulerExecJob(void *transport, SArray *nodeList, SQueryPlan *pDag, int64_t *pJob, const char *sql, +int32_t schedulerExecJob(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int64_t *pJob, const char *sql, int64_t startTs, SQueryResult *pRes) { - if (NULL == transport || NULL == pDag || NULL == pDag->pSubplans || NULL == pJob || NULL == pRes) { + if (NULL == pTrans || NULL == pDag || NULL == pDag->pSubplans || NULL == pJob || NULL == pRes) { SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } - int32_t code = 0; - - *pJob = 0; - - if (EXPLAIN_MODE_STATIC == pDag->explainInfo.mode) { - SCH_ERR_RET(schExecStaticExplain(transport, nodeList, pDag, pJob, sql, true)); - } else { - SCH_ERR_JRET(schExecJobImpl(transport, nodeList, pDag, pJob, sql, startTs, true)); - } - -_return: - - if (*pJob) { - SSchJob *job = schAcquireJob(*pJob); - - pRes->code = atomic_load_32(&job->errCode); - pRes->numOfRows = job->resNumOfRows; - pRes->res = job->queryRes; - job->queryRes = NULL; - - schReleaseJob(*pJob); - } - - return code; + SSchResInfo resInfo = {.queryRes = *pRes}; + SCH_RET(schExecJob(pTrans, pNodeList, pDag, pJob, sql, startTs, &resInfo, true)); } -int32_t schedulerAsyncExecJob(void *transport, SArray *pNodeList, SQueryPlan *pDag, const char *sql, int64_t *pJob) { - if (NULL == transport || NULL == pDag || NULL == pDag->pSubplans || NULL == pJob) { - SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); - } - - if (EXPLAIN_MODE_STATIC == pDag->explainInfo.mode) { - SCH_ERR_RET(schExecStaticExplain(transport, pNodeList, pDag, pJob, sql, false)); - } else { - SCH_ERR_RET(schExecJobImpl(transport, pNodeList, pDag, pJob, sql, 0, false)); - } - - return TSDB_CODE_SUCCESS; +int32_t schedulerAsyncExecJob(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int64_t *pJob, const char *sql, + int64_t startTs, SQueryResult *pRes, schedulerCallback fp, void* param) { + if (NULL == pTrans || NULL == pDag || NULL == pDag->pSubplans || NULL == pJob || NULL == pRes || NULL == fp || NULL == param) { + SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); + } + + SSchResInfo resInfo = {.queryRes = *pRes, .userFp = fp, .userParam = param}; + SCH_RET(schExecJob(pTrans, pNodeList, pDag, pJob, sql, startTs, &resInfo, false)); } int32_t schedulerFetchRows(int64_t job, void **pData) { From 067af9d0bea04fad5bdbe00260dcabe2b2ce408c Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 24 May 2022 06:50:47 +0000 Subject: [PATCH 05/63] feat: vnode snapshot 1 --- include/common/tdataformat.h | 2 +- include/util/taoserror.h | 1 + source/common/src/tdataformat.c | 6 +- source/dnode/vnode/CMakeLists.txt | 3 + source/dnode/vnode/inc/vnode.h | 12 +-- source/dnode/vnode/src/inc/vnodeInt.h | 26 ++++-- source/dnode/vnode/src/meta/metaSnapshot.c | 35 ++++++++ source/dnode/vnode/src/tsdb/tsdbSnapshot.c | 35 ++++++++ source/dnode/vnode/src/vnd/vnodeSnapshot.c | 97 ++++++++++++++++++++++ source/util/src/terror.c | 1 + 10 files changed, 199 insertions(+), 19 deletions(-) create mode 100644 source/dnode/vnode/src/meta/metaSnapshot.c create mode 100644 source/dnode/vnode/src/tsdb/tsdbSnapshot.c create mode 100644 source/dnode/vnode/src/vnd/vnodeSnapshot.c diff --git a/include/common/tdataformat.h b/include/common/tdataformat.h index bbe7d22cfb..ef931ed3b1 100644 --- a/include/common/tdataformat.h +++ b/include/common/tdataformat.h @@ -64,7 +64,7 @@ void tTagFree(STag *pTag); int32_t tTagSet(STag *pTag, SSchema *pSchema, int32_t nCols, int iCol, uint8_t *pData, uint32_t nData, STag **ppTag); void tTagGet(STag *pTag, int16_t cid, int8_t type, uint8_t **ppData, uint32_t *nData); int32_t tEncodeTag(SEncoder *pEncoder, const STag *pTag); -int32_t tDecodeTag(SDecoder *pDecoder, const STag **ppTag); +int32_t tDecodeTag(SDecoder *pDecoder, STag **ppTag); // STRUCT ================= struct STColumn { diff --git a/include/util/taoserror.h b/include/util/taoserror.h index e318978339..0ba1d0c0f2 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -313,6 +313,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_VND_INVALID_TABLE_ACTION TAOS_DEF_ERROR_CODE(0, 0x0519) #define TSDB_CODE_VND_COL_ALREADY_EXISTS TAOS_DEF_ERROR_CODE(0, 0x051a) #define TSDB_CODE_VND_TABLE_COL_NOT_EXISTS TAOS_DEF_ERROR_CODE(0, 0x051b) +#define TSDB_CODE_VND_READ_END TAOS_DEF_ERROR_CODE(0, 0x051c) // tsdb #define TSDB_CODE_TDB_INVALID_TABLE_ID TAOS_DEF_ERROR_CODE(0, 0x0600) diff --git a/source/common/src/tdataformat.c b/source/common/src/tdataformat.c index 65c044a29b..e8d7e3ac09 100644 --- a/source/common/src/tdataformat.c +++ b/source/common/src/tdataformat.c @@ -646,9 +646,7 @@ int32_t tEncodeTag(SEncoder *pEncoder, const STag *pTag) { return tEncodeBinary(pEncoder, (const uint8_t *)pTag, pTag->len); } -int32_t tDecodeTag(SDecoder *pDecoder, const STag **ppTag) { - return tDecodeBinary(pDecoder, (const uint8_t **)ppTag, NULL); -} +int32_t tDecodeTag(SDecoder *pDecoder, STag **ppTag) { return tDecodeBinary(pDecoder, (uint8_t **)ppTag, NULL); } #if 1 // =================================================================================================================== static void dataColSetNEleNull(SDataCol *pCol, int nEle); @@ -1127,7 +1125,7 @@ SKVRow tdGetKVRowFromBuilder(SKVRowBuilder *pBuilder) { kvRowSetNCols(row, pBuilder->nCols); kvRowSetLen(row, tlen); - if(pBuilder->nCols > 0){ + if (pBuilder->nCols > 0) { memcpy(kvRowColIdx(row), pBuilder->pColIdx, sizeof(SColIdx) * pBuilder->nCols); memcpy(kvRowValues(row), pBuilder->buf, pBuilder->size); } diff --git a/source/dnode/vnode/CMakeLists.txt b/source/dnode/vnode/CMakeLists.txt index 4141485d28..cb73f5462b 100644 --- a/source/dnode/vnode/CMakeLists.txt +++ b/source/dnode/vnode/CMakeLists.txt @@ -13,6 +13,7 @@ target_sources( "src/vnd/vnodeModule.c" "src/vnd/vnodeSvr.c" "src/vnd/vnodeSync.c" + "src/vnd/vnodeSnapshot.c" # meta "src/meta/metaOpen.c" @@ -22,6 +23,7 @@ target_sources( "src/meta/metaQuery.c" "src/meta/metaCommit.c" "src/meta/metaEntry.c" + "src/meta/metaSnapshot.c" # sma "src/sma/sma.c" @@ -44,6 +46,7 @@ target_sources( "src/tsdb/tsdbReadImpl.c" # "src/tsdb/tsdbSma.c" "src/tsdb/tsdbWrite.c" + "src/tsdb/tsdbSnapshot.c" # tq "src/tq/tq.c" diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 9e33973c05..1b8fe71fb8 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -39,9 +39,10 @@ extern "C" { #endif // vnode -typedef struct SVnode SVnode; -typedef struct STsdbCfg STsdbCfg; // todo: remove -typedef struct SVnodeCfg SVnodeCfg; +typedef struct SVnode SVnode; +typedef struct STsdbCfg STsdbCfg; // todo: remove +typedef struct SVnodeCfg SVnodeCfg; +typedef struct SVSnapshotReader SVSnapshotReader; extern const SVnodeCfg vnodeCfgDefault; @@ -59,13 +60,14 @@ int32_t vnodeProcessQueryMsg(SVnode *pVnode, SRpcMsg *pMsg); int32_t vnodeProcessFetchMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo); int32_t vnodeGetLoad(SVnode *pVnode, SVnodeLoad *pLoad); int32_t vnodeValidateTableHash(SVnode *pVnode, char *tableFName); - int32_t vnodeStart(SVnode *pVnode); void vnodeStop(SVnode *pVnode); - int64_t vnodeGetSyncHandle(SVnode *pVnode); void vnodeGetSnapshot(SVnode *pVnode, SSnapshot *pSnapshot); void vnodeGetInfo(SVnode *pVnode, const char **dbname, int32_t *vgId); +int32_t vnodeSnapshotReaderOpen(SVnode *pVnode, SVSnapshotReader **ppReader, int64_t sver, int64_t ever); +int32_t vnodeSnapshotReaderClose(SVSnapshotReader *pReader); +int32_t vnodeSnapshotRead(SVSnapshotReader *pReader, void **ppData, uint32_t *nData); // meta typedef struct SMeta SMeta; // todo: remove diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 24b3f458b1..380b1fc518 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -47,15 +47,17 @@ extern "C" { #endif -typedef struct SVnodeInfo SVnodeInfo; -typedef struct SMeta SMeta; -typedef struct SSma SSma; -typedef struct STsdb STsdb; -typedef struct STQ STQ; -typedef struct SVState SVState; -typedef struct SVBufPool SVBufPool; -typedef struct SQWorker SQHandle; -typedef struct STsdbKeepCfg STsdbKeepCfg; +typedef struct SVnodeInfo SVnodeInfo; +typedef struct SMeta SMeta; +typedef struct SSma SSma; +typedef struct STsdb STsdb; +typedef struct STQ STQ; +typedef struct SVState SVState; +typedef struct SVBufPool SVBufPool; +typedef struct SQWorker SQHandle; +typedef struct STsdbKeepCfg STsdbKeepCfg; +typedef struct SMetaSnapshotReader SMetaSnapshotReader; +typedef struct STsdbSnapshotReader STsdbSnapshotReader; #define VNODE_META_DIR "meta" #define VNODE_TSDB_DIR "tsdb" @@ -95,6 +97,9 @@ STSma* metaGetSmaInfoByIndex(SMeta* pMeta, int64_t indexUid); STSmaWrapper* metaGetSmaInfoByTable(SMeta* pMeta, tb_uid_t uid, bool deepCopy); SArray* metaGetSmaIdsByTable(SMeta* pMeta, tb_uid_t uid); SArray* metaGetSmaTbUids(SMeta* pMeta); +int32_t metaSnapshotReaderOpen(SMeta* pMeta, SMetaSnapshotReader** ppReader, int64_t sver, int64_t ever); +int32_t metaSnapshotReaderClose(SMetaSnapshotReader* pReader); +int32_t metaSnapshotRead(SMetaSnapshotReader* pReader, void** ppData, uint32_t* nData); int32_t metaCreateTSma(SMeta* pMeta, int64_t version, SSmaCfg* pCfg); int32_t metaDropTSma(SMeta* pMeta, int64_t indexUid); @@ -112,6 +117,9 @@ tsdbReaderT* tsdbQueryTables(SVnode* pVnode, SQueryTableDataCond* pCond, STableG tsdbReaderT tsdbQueryCacheLastT(STsdb* tsdb, SQueryTableDataCond* pCond, STableGroupInfo* groupList, uint64_t qId, void* pMemRef); int32_t tsdbGetTableGroupFromIdListT(STsdb* tsdb, SArray* pTableIdList, STableGroupInfo* pGroupInfo); +int32_t tsdbSnapshotReaderOpen(STsdb* pTsdb, STsdbSnapshotReader** ppReader, int64_t sver, int64_t ever); +int32_t tsdbSnapshotReaderClose(STsdbSnapshotReader* pReader); +int32_t tsdbSnapshotRead(STsdbSnapshotReader* pReader, void** ppData, uint32_t* nData); // tq STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal); diff --git a/source/dnode/vnode/src/meta/metaSnapshot.c b/source/dnode/vnode/src/meta/metaSnapshot.c new file mode 100644 index 0000000000..9a9d8dd641 --- /dev/null +++ b/source/dnode/vnode/src/meta/metaSnapshot.c @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "meta.h" + +struct SMetaSnapshotReader { + // TODO +}; + +int32_t metaSnapshotReaderOpen(SMeta* pMeta, SMetaSnapshotReader** ppReader, int64_t sver, int64_t ever) { + // TODO + return 0; +} + +int32_t metaSnapshotReaderClose(SMetaSnapshotReader* pReader) { + // TODO + return 0; +} + +int32_t metaSnapshotRead(SMetaSnapshotReader* pReader, void** ppData, uint32_t* nData) { + // TODO + return 0; +} \ No newline at end of file diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c new file mode 100644 index 0000000000..f40cab600f --- /dev/null +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "tsdb.h" + +struct STsdbSnapshotReader { + // TODO +}; + +int32_t tsdbSnapshotReaderOpen(STsdb* pTsdb, STsdbSnapshotReader** ppReader, int64_t sver, int64_t ever) { + // TODO + return 0; +} + +int32_t tsdbSnapshotReaderClose(STsdbSnapshotReader* pReader) { + // TODO + return 0; +} + +int32_t tsdbSnapshotRead(STsdbSnapshotReader* pReader, void** ppData, uint32_t* nData) { + // TODO + return 0; +} diff --git a/source/dnode/vnode/src/vnd/vnodeSnapshot.c b/source/dnode/vnode/src/vnd/vnodeSnapshot.c new file mode 100644 index 0000000000..67d9c120db --- /dev/null +++ b/source/dnode/vnode/src/vnd/vnodeSnapshot.c @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "vnodeInt.h" + +struct SVSnapshotReader { + SVnode *pVnode; + int64_t sver; + int64_t ever; + int8_t isMetaEnd; + int8_t isTsdbEnd; + SMetaSnapshotReader *pMetaReader; + STsdbSnapshotReader *pTsdbReader; +}; + +int32_t vnodeSnapshotReaderOpen(SVnode *pVnode, SVSnapshotReader **ppReader, int64_t sver, int64_t ever) { + SVSnapshotReader *pReader = NULL; + + pReader = (SVSnapshotReader *)taosMemoryCalloc(1, sizeof(*pReader)); + if (pReader == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + pReader->pVnode = pVnode; + pReader->sver = sver; + pReader->ever = ever; + pReader->isMetaEnd = 0; + pReader->isTsdbEnd = 0; + + if (metaSnapshotReaderOpen(pVnode->pMeta, &pReader->pMetaReader, sver, ever) < 0) { + taosMemoryFree(pReader); + goto _err; + } + + if (tsdbSnapshotReaderOpen(pVnode->pTsdb, &pReader->pTsdbReader, sver, ever) < 0) { + metaSnapshotReaderClose(pReader->pMetaReader); + taosMemoryFree(pReader); + goto _err; + } + +_exit: + *ppReader = pReader; + return 0; + +_err: + *ppReader = NULL; + return -1; +} + +int32_t vnodeSnapshotReaderClose(SVSnapshotReader *pReader) { + if (pReader) { + tsdbSnapshotReaderClose(pReader->pTsdbReader); + metaSnapshotReaderClose(pReader->pMetaReader); + taosMemoryFree(pReader); + } + return 0; +} + +int32_t vnodeSnapshotRead(SVSnapshotReader *pReader, void **ppData, uint32_t *nData) { + int32_t code = 0; + + if (!pReader->isMetaEnd) { + code = metaSnapshotRead(pReader->pMetaReader, ppData, nData); + if (code) { + if (code == TSDB_CODE_VND_READ_END) { + pReader->isMetaEnd = 1; + } else { + return code; + } + } else { + return code; + } + } + + if (!pReader->isTsdbEnd) { + code = tsdbSnapshotRead(pReader->pTsdbReader, ppData, nData); + if (code) { + } else { + return code; + } + } + + code = TSDB_CODE_VND_READ_END; + return code; +} \ No newline at end of file diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 7c4f0fa2dd..0b37a71c60 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -311,6 +311,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_VND_TABLE_NOT_EXIST, "Table does not exists TAOS_DEFINE_ERROR(TSDB_CODE_VND_INVALID_TABLE_ACTION, "Invalid table action") TAOS_DEFINE_ERROR(TSDB_CODE_VND_COL_ALREADY_EXISTS, "Table column already exists") TAOS_DEFINE_ERROR(TSDB_CODE_VND_TABLE_COL_NOT_EXISTS, "Table column not exists") +TAOS_DEFINE_ERROR(TSDB_CODE_VND_READ_END, "Read end") // tsdb From c81ff9cbab82c807ea7db07b1fc6d05f67a40974 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 24 May 2022 09:12:14 +0000 Subject: [PATCH 06/63] vnode snapshot 2 --- source/dnode/vnode/CMakeLists.txt | 1 + source/dnode/vnode/src/inc/vnodeInt.h | 6 +- source/dnode/vnode/src/meta/metaSnapshot.c | 72 +++++++++++++++++++--- source/dnode/vnode/src/vnd/vnodeUtil.c | 45 ++++++++++++++ 4 files changed, 115 insertions(+), 9 deletions(-) create mode 100644 source/dnode/vnode/src/vnd/vnodeUtil.c diff --git a/source/dnode/vnode/CMakeLists.txt b/source/dnode/vnode/CMakeLists.txt index cb73f5462b..d988f97188 100644 --- a/source/dnode/vnode/CMakeLists.txt +++ b/source/dnode/vnode/CMakeLists.txt @@ -14,6 +14,7 @@ target_sources( "src/vnd/vnodeSvr.c" "src/vnd/vnodeSync.c" "src/vnd/vnodeSnapshot.c" + "src/vnd/vnodeUtil.c" # meta "src/meta/metaOpen.c" diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 380b1fc518..faf0ddcd4a 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -69,8 +69,10 @@ typedef struct STsdbSnapshotReader STsdbSnapshotReader; #define VNODE_RSMA2_DIR "rsma2" // vnd.h -void* vnodeBufPoolMalloc(SVBufPool* pPool, int size); -void vnodeBufPoolFree(SVBufPool* pPool, void* p); +void* vnodeBufPoolMalloc(SVBufPool* pPool, int size); +void vnodeBufPoolFree(SVBufPool* pPool, void* p); +int32_t vnodeRealloc(void** pp, int32_t size); +void vnodeFree(void* p); // meta typedef struct SMCtbCursor SMCtbCursor; diff --git a/source/dnode/vnode/src/meta/metaSnapshot.c b/source/dnode/vnode/src/meta/metaSnapshot.c index 9a9d8dd641..5757039d55 100644 --- a/source/dnode/vnode/src/meta/metaSnapshot.c +++ b/source/dnode/vnode/src/meta/metaSnapshot.c @@ -16,20 +16,78 @@ #include "meta.h" struct SMetaSnapshotReader { - // TODO + SMeta* pMeta; + TBC* pTbc; + int64_t sver; + int64_t ever; }; int32_t metaSnapshotReaderOpen(SMeta* pMeta, SMetaSnapshotReader** ppReader, int64_t sver, int64_t ever) { - // TODO - return 0; + int32_t code = 0; + int32_t c = 0; + SMetaSnapshotReader* pMetaReader = NULL; + + pMetaReader = (SMetaSnapshotReader*)taosMemoryCalloc(1, sizeof(*pMetaReader)); + if (pMetaReader == NULL) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _err; + } + pMetaReader->pMeta = pMeta; + pMetaReader->sver = sver; + pMetaReader->ever = ever; + code = tdbTbcOpen(pMeta->pTbDb, &pMetaReader->pTbc, NULL); + if (code) { + goto _err; + } + + code = tdbTbcMoveTo(pMetaReader->pTbc, &(STbDbKey){.version = sver, .uid = INT64_MIN}, sizeof(STbDbKey), &c); + if (code) { + goto _err; + } + + *ppReader = pMetaReader; + return code; + +_err: + *ppReader = NULL; + return code; } int32_t metaSnapshotReaderClose(SMetaSnapshotReader* pReader) { - // TODO + if (pReader) { + tdbTbcClose(pReader->pTbc); + taosMemoryFree(pReader); + } return 0; } -int32_t metaSnapshotRead(SMetaSnapshotReader* pReader, void** ppData, uint32_t* nData) { - // TODO - return 0; +int32_t metaSnapshotRead(SMetaSnapshotReader* pReader, void** ppData, uint32_t* nDatap) { + const void* pKey = NULL; + const void* pData = NULL; + int32_t nKey = 0; + int32_t nData = 0; + int32_t code = 0; + + for (;;) { + code = tdbTbcGet(pReader->pTbc, &pKey, &nKey, &pData, &nData); + if (code || ((STbDbKey*)pData)->version > pReader->ever) { + return TSDB_CODE_VND_READ_END; + } + + if (((STbDbKey*)pData)->version < pReader->sver) { + continue; + } + + break; + } + + // copy the data + if (vnodeRealloc(ppData, nData) < 0) { + code = TSDB_CODE_OUT_OF_MEMORY; + return code; + } + + memcpy(*ppData, pData, nData); + *nDatap = nData; + return code; } \ No newline at end of file diff --git a/source/dnode/vnode/src/vnd/vnodeUtil.c b/source/dnode/vnode/src/vnd/vnodeUtil.c new file mode 100644 index 0000000000..cd942099bc --- /dev/null +++ b/source/dnode/vnode/src/vnd/vnodeUtil.c @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "vnd.h" + +int32_t vnodeRealloc(void** pp, int32_t size) { + uint8_t* p = NULL; + int32_t csize = 0; + + if (*pp) { + p = (uint8_t*)(*pp) - sizeof(int32_t); + csize = *(int32_t*)p; + } + + if (csize >= size) { + return 0; + } + + p = (uint8_t*)taosMemoryRealloc(p, size); + if (p == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } + *(int32_t*)p = size; + *pp = p + sizeof(int32_t); + + return 0; +} + +void vnodeFree(void* p) { + if (p) { + taosMemoryFree(((uint8_t*)p) - sizeof(int32_t)); + } +} \ No newline at end of file From 9fbbb25aea2f79bf2d2c05775dad400616c47ae2 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Tue, 24 May 2022 09:21:14 +0000 Subject: [PATCH 07/63] feat: vnode snapshot --- source/dnode/vnode/inc/vnode.h | 2 +- source/dnode/vnode/src/vnd/vnodeSnapshot.c | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/source/dnode/vnode/inc/vnode.h b/source/dnode/vnode/inc/vnode.h index 1b8fe71fb8..6026245174 100644 --- a/source/dnode/vnode/inc/vnode.h +++ b/source/dnode/vnode/inc/vnode.h @@ -67,7 +67,7 @@ void vnodeGetSnapshot(SVnode *pVnode, SSnapshot *pSnapshot); void vnodeGetInfo(SVnode *pVnode, const char **dbname, int32_t *vgId); int32_t vnodeSnapshotReaderOpen(SVnode *pVnode, SVSnapshotReader **ppReader, int64_t sver, int64_t ever); int32_t vnodeSnapshotReaderClose(SVSnapshotReader *pReader); -int32_t vnodeSnapshotRead(SVSnapshotReader *pReader, void **ppData, uint32_t *nData); +int32_t vnodeSnapshotRead(SVSnapshotReader *pReader, const void **ppData, uint32_t *nData); // meta typedef struct SMeta SMeta; // todo: remove diff --git a/source/dnode/vnode/src/vnd/vnodeSnapshot.c b/source/dnode/vnode/src/vnd/vnodeSnapshot.c index 67d9c120db..5e451e4142 100644 --- a/source/dnode/vnode/src/vnd/vnodeSnapshot.c +++ b/source/dnode/vnode/src/vnd/vnodeSnapshot.c @@ -23,6 +23,8 @@ struct SVSnapshotReader { int8_t isTsdbEnd; SMetaSnapshotReader *pMetaReader; STsdbSnapshotReader *pTsdbReader; + void *pData; + int32_t nData; }; int32_t vnodeSnapshotReaderOpen(SVnode *pVnode, SVSnapshotReader **ppReader, int64_t sver, int64_t ever) { @@ -61,6 +63,7 @@ _err: int32_t vnodeSnapshotReaderClose(SVSnapshotReader *pReader) { if (pReader) { + vnodeFree(pReader->pData); tsdbSnapshotReaderClose(pReader->pTsdbReader); metaSnapshotReaderClose(pReader->pMetaReader); taosMemoryFree(pReader); @@ -68,11 +71,11 @@ int32_t vnodeSnapshotReaderClose(SVSnapshotReader *pReader) { return 0; } -int32_t vnodeSnapshotRead(SVSnapshotReader *pReader, void **ppData, uint32_t *nData) { +int32_t vnodeSnapshotRead(SVSnapshotReader *pReader, const void **ppData, uint32_t *nData) { int32_t code = 0; if (!pReader->isMetaEnd) { - code = metaSnapshotRead(pReader->pMetaReader, ppData, nData); + code = metaSnapshotRead(pReader->pMetaReader, &pReader->pData, &pReader->pData); if (code) { if (code == TSDB_CODE_VND_READ_END) { pReader->isMetaEnd = 1; @@ -80,14 +83,23 @@ int32_t vnodeSnapshotRead(SVSnapshotReader *pReader, void **ppData, uint32_t *nD return code; } } else { + *ppData = pReader->pData; + *nData = pReader->nData; return code; } } if (!pReader->isTsdbEnd) { - code = tsdbSnapshotRead(pReader->pTsdbReader, ppData, nData); + code = tsdbSnapshotRead(pReader->pTsdbReader, &pReader->pData, pReader->nData); if (code) { + if (code == TSDB_CODE_VND_READ_END) { + pReader->isTsdbEnd = 1; + } else { + return code; + } } else { + *ppData = pReader->pData; + *nData = pReader->nData; return code; } } From efa071c9f68eff3e1d068b1b1dbc271a9139a237 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Tue, 24 May 2022 17:49:22 +0800 Subject: [PATCH 08/63] scheduler async api --- include/libs/scheduler/scheduler.h | 10 +- source/client/src/clientImpl.c | 2 +- source/libs/scheduler/inc/schedulerInt.h | 31 ++- source/libs/scheduler/src/schJob.c | 233 ++++++++++++++++-- source/libs/scheduler/src/schRemote.c | 8 +- source/libs/scheduler/src/scheduler.c | 102 +++----- source/libs/scheduler/test/schedulerTests.cpp | 60 ++++- 7 files changed, 324 insertions(+), 122 deletions(-) diff --git a/include/libs/scheduler/scheduler.h b/include/libs/scheduler/scheduler.h index 62a97d1be0..a72489f338 100644 --- a/include/libs/scheduler/scheduler.h +++ b/include/libs/scheduler/scheduler.h @@ -54,8 +54,6 @@ typedef struct SQueryProfileSummary { typedef struct SQueryResult { int32_t code; uint64_t numOfRows; - int32_t msgSize; - char *msg; void *res; } SQueryResult; @@ -64,7 +62,8 @@ typedef struct STaskInfo { SSubQueryMsg *msg; } STaskInfo; -typedef void (*schedulerCallback)(SQueryResult* pResult, void* param, int32_t code); +typedef void (*schedulerExecCallback)(SQueryResult* pResult, void* param, int32_t code); +typedef void (*schedulerFetchCallback)(void* pResult, void* param, int32_t code); int32_t schedulerInit(SSchedulerCfg *cfg); @@ -83,7 +82,8 @@ int32_t schedulerExecJob(void *transport, SArray *nodeList, SQueryPlan *pDag, in * @param pNodeList Qnode/Vnode address list, element is SQueryNodeAddr * @return */ -int32_t schedulerAsyncExecJob(void *transport, SArray *pNodeList, SQueryPlan* pDag, const char* sql, int64_t *pJob); + int32_t schedulerAsyncExecJob(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int64_t *pJob, const char *sql, + int64_t startTs, schedulerExecCallback fp, void* param); /** * Fetch query result from the remote query executor @@ -93,6 +93,8 @@ int32_t schedulerAsyncExecJob(void *transport, SArray *pNodeList, SQueryPlan* pD */ int32_t schedulerFetchRows(int64_t job, void **data); +int32_t schedulerAsyncFetchRows(int64_t job, schedulerFetchCallback fp, void* param); + int32_t schedulerGetTasksStatus(int64_t job, SArray *pSub); diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index b142885841..131a3d5770 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -292,7 +292,7 @@ void setResPrecision(SReqResultInfo* pResInfo, int32_t precision) { int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList, void** pRes) { void* pTransporter = pRequest->pTscObj->pAppInfo->pTransporter; - SQueryResult res = {.code = 0, .numOfRows = 0, .msgSize = ERROR_MSG_BUF_DEFAULT_SIZE, .msg = pRequest->msgBuf}; + SQueryResult res = {.code = 0, .numOfRows = 0}; int32_t code = schedulerExecJob(pTransporter, pNodeList, pDag, &pRequest->body.queryJob, pRequest->sqlstr, pRequest->metric.start, &res); if (code != TSDB_CODE_SUCCESS) { diff --git a/source/libs/scheduler/inc/schedulerInt.h b/source/libs/scheduler/inc/schedulerInt.h index d2ddd8b695..6599d00f58 100644 --- a/source/libs/scheduler/inc/schedulerInt.h +++ b/source/libs/scheduler/inc/schedulerInt.h @@ -39,6 +39,11 @@ enum { SCH_WRITE, }; +enum { + SCH_EXEC_CB = 1, + SCH_FETCH_CB, +}; + typedef struct SSchTrans { void *pTrans; void *pHandle; @@ -81,9 +86,11 @@ typedef struct SSchStat { } SSchStat; typedef struct SSchResInfo { - SQueryResult queryRes; - schedulerCallback userFp; - void* userParam; + SQueryResult* queryRes; + void** fetchRes; + schedulerExecCallback execFp; + schedulerFetchCallback fetchFp; + void* userParam; } SSchResInfo; typedef struct SSchedulerMgmt { @@ -113,7 +120,7 @@ typedef struct SSchTaskCallbackParam { typedef struct SSchHbCallbackParam { SSchCallbackParamHeader head; SQueryNodeEpId nodeEpId; - void *transport; + void *pTrans; } SSchHbCallbackParam; typedef struct SSchFlowControl { @@ -196,13 +203,13 @@ typedef struct SSchJob { int32_t remoteFetch; SSchTask *fetchTask; int32_t errCode; - SArray *errList; // SArray SRWLatch resLock; void *queryRes; void *resData; //TODO free it or not int32_t resNumOfRows; SSchResInfo userRes; const char *sql; + int32_t userCb; SQueryProfileSummary summary; } SSchJob; @@ -298,15 +305,21 @@ int32_t schUpdateTaskExecNodeHandle(SSchTask *pTask, void *handle, int32_t rspCo void schFreeRpcCtxVal(const void *arg); int32_t schMakeBrokenLinkVal(SSchJob *pJob, SSchTask *pTask, SRpcBrokenlinkVal *brokenVal, bool isHb); int32_t schRecordTaskExecNode(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, void *handle); -int32_t schExecStaticExplainJob(void *transport, SArray *pNodeList, SQueryPlan *pDag, int64_t *job, const char *sql, - bool syncSchedule); -int32_t schExecJobImpl(void *transport, SArray *pNodeList, SQueryPlan *pDag, int64_t *job, const char *sql, - int64_t startTs, bool sync); +int32_t schExecStaticExplainJob(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int64_t *job, const char *sql, + SSchResInfo *pRes, bool sync); +int32_t schExecJobImpl(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int64_t *job, const char *sql, + SSchResInfo *pRes, int64_t startTs, bool sync); int32_t schChkUpdateJobStatus(SSchJob *pJob, int8_t newStatus); int32_t schCancelJob(SSchJob *pJob); int32_t schProcessOnJobDropped(SSchJob *pJob, int32_t errCode); uint64_t schGenTaskId(void); void schCloseJobRef(void); +int32_t schExecJob(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int64_t *pJob, const char *sql, + int64_t startTs, SSchResInfo *pRes); +int32_t schAsyncExecJob(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int64_t *pJob, const char *sql, + int64_t startTs, SSchResInfo *pRes); +int32_t schFetchRows(SSchJob *pJob); +int32_t schAsyncFetchRows(SSchJob *pJob); #ifdef __cplusplus diff --git a/source/libs/scheduler/src/schJob.c b/source/libs/scheduler/src/schJob.c index a211d90a37..52722d819f 100644 --- a/source/libs/scheduler/src/schJob.c +++ b/source/libs/scheduler/src/schJob.c @@ -53,7 +53,7 @@ int32_t schInitJob(SSchJob **pSchJob, SQueryPlan *pDag, void *pTrans, SArray *pN pJob->attr.syncSchedule = syncSchedule; pJob->pTrans = pTrans; pJob->sql = sql; - pJob->userRes = pRes; + pJob->userRes = *pRes; if (pNodeList != NULL) { pJob->nodeList = taosArrayDup(pNodeList); @@ -459,6 +459,7 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { SCH_ERR_JRET(schBuildTaskRalation(pJob, planToTask)); _return: + if (planToTask) { taosHashCleanup(planToTask); } @@ -728,6 +729,69 @@ _return: SCH_JOB_DLOG("job errCode updated to %x - %s", errCode, tstrerror(errCode)); } + +int32_t schSetJobQueryRes(SSchJob* pJob, SQueryResult* pRes) { + pRes->code = atomic_load_32(&pJob->errCode); + pRes->numOfRows = pJob->resNumOfRows; + pRes->res = pJob->queryRes; + pJob->queryRes = NULL; + + return TSDB_CODE_SUCCESS; +} + +int32_t schSetJobFetchRes(SSchJob* pJob, void** pData) { + int32_t code = 0; + if (pJob->resData && ((SRetrieveTableRsp *)pJob->resData)->completed) { + SCH_ERR_RET(schChkUpdateJobStatus(pJob, JOB_TASK_STATUS_SUCCEED)); + } + + while (true) { + *pData = atomic_load_ptr(&pJob->resData); + if (*pData != atomic_val_compare_exchange_ptr(&pJob->resData, *pData, NULL)) { + continue; + } + + break; + } + + if (NULL == *pData) { + SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)taosMemoryCalloc(1, sizeof(SRetrieveTableRsp)); + if (rsp) { + rsp->completed = 1; + } + + *pData = rsp; + SCH_JOB_DLOG("empty res and set query complete, code:%x", code); + } + + SCH_JOB_DLOG("fetch done, totalRows:%d", pJob->resNumOfRows); + + return TSDB_CODE_SUCCESS; +} + +int32_t schNotifyUserQueryRes(SSchJob* pJob) { + pJob->userRes.queryRes = taosMemoryCalloc(1, sizeof(*pJob->userRes.queryRes)); + if (pJob->userRes.queryRes) { + schSetJobQueryRes(pJob, pJob->userRes.queryRes); + } + + (*pJob->userRes.execFp)(pJob->userRes.queryRes, pJob->userRes.userParam, atomic_load_32(&pJob->errCode)); + + pJob->userRes.queryRes = NULL; + + return TSDB_CODE_SUCCESS; +} + +int32_t schNotifyUserFetchRes(SSchJob* pJob) { + void* pRes = NULL; + + SCH_ERR_RET(schSetJobFetchRes(pJob, &pRes)); + + (*pJob->userRes.fetchFp)(pRes, pJob->userRes.userParam, atomic_load_32(&pJob->errCode)); + + return TSDB_CODE_SUCCESS; +} + int32_t schProcessOnJobFailureImpl(SSchJob *pJob, int32_t status, int32_t errCode) { // if already FAILED, no more processing SCH_ERR_RET(schChkUpdateJobStatus(pJob, status)); @@ -742,6 +806,14 @@ int32_t schProcessOnJobFailureImpl(SSchJob *pJob, int32_t status, int32_t errCod SCH_JOB_DLOG("job failed with error: %s", tstrerror(code)); + if (!pJob->attr.syncSchedule) { + if (SCH_EXEC_CB == atomic_val_compare_exchange_32(&pJob->userCb, SCH_EXEC_CB, 0)) { + schNotifyUserQueryRes(pJob); + } else if (SCH_FETCH_CB == atomic_val_compare_exchange_32(&pJob->userCb, SCH_FETCH_CB, 0)) { + schNotifyUserFetchRes(pJob); + } + } + SCH_RET(code); } @@ -763,6 +835,10 @@ int32_t schProcessOnJobPartialSuccess(SSchJob *pJob) { if (pJob->attr.syncSchedule) { tsem_post(&pJob->rspSem); + } else if (SCH_EXEC_CB == atomic_val_compare_exchange_32(&pJob->userCb, SCH_EXEC_CB, 0)) { + schNotifyUserQueryRes(pJob); + } else if (SCH_FETCH_CB == atomic_val_compare_exchange_32(&pJob->userCb, SCH_FETCH_CB, 0)) { + schNotifyUserFetchRes(pJob); } if (atomic_load_8(&pJob->userFetch)) { @@ -1219,6 +1295,7 @@ void schFreeJobImpl(void *job) { tFreeSSubmitRsp((SSubmitRsp*)pJob->queryRes); } + taosMemoryFreeClear(pJob->userRes.queryRes); taosMemoryFreeClear(pJob->resData); taosMemoryFreeClear(pJob); @@ -1239,57 +1316,66 @@ int32_t schExecJobImpl(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int64_ int32_t code = 0; SSchJob *pJob = NULL; - SCH_ERR_JRET(schInitJob(&pJob, pDag, pTrans, pNodeList, sql, pRes, startTs, sync)); - - SCH_ERR_JRET(schLaunchJob(pJob)); + SCH_ERR_RET(schInitJob(&pJob, pDag, pTrans, pNodeList, sql, pRes, startTs, sync)); *job = pJob->refId; + SCH_ERR_JRET(schLaunchJob(pJob)); + if (sync) { SCH_JOB_DLOG("will wait for rsp now, job status:%s", SCH_GET_JOB_STATUS_STR(pJob)); tsem_wait(&pJob->rspSem); + } else { + pJob->userCb = SCH_EXEC_CB; } SCH_JOB_DLOG("job exec done, job status:%s", SCH_GET_JOB_STATUS_STR(pJob)); - schReleaseJob(pJob->refId); - - return TSDB_CODE_SUCCESS; - _return: - schFreeJobImpl(pJob); + schReleaseJob(pJob->refId); + SCH_RET(code); } int32_t schExecJob(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int64_t *pJob, const char *sql, - int64_t startTs, SSchResInfo *pRes, bool sync) { + int64_t startTs, SSchResInfo *pRes) { int32_t code = 0; *pJob = 0; if (EXPLAIN_MODE_STATIC == pDag->explainInfo.mode) { - SCH_ERR_RET(schExecStaticExplainJob(pTrans, pNodeList, pDag, pJob, sql, pRes, sync)); + SCH_ERR_JRET(schExecStaticExplainJob(pTrans, pNodeList, pDag, pJob, sql, NULL, true)); } else { - SCH_ERR_JRET(schExecJobImpl(pTrans, pNodeList, pDag, pJob, sql, pRes, startTs, sync)); + SCH_ERR_JRET(schExecJobImpl(pTrans, pNodeList, pDag, pJob, sql, NULL, startTs, true)); } _return: if (*pJob) { SSchJob *job = schAcquireJob(*pJob); - - pRes->code = atomic_load_32(&job->errCode); - pRes->numOfRows = job->resNumOfRows; - pRes->res = job->queryRes; - job->queryRes = NULL; - + schSetJobQueryRes(job, pRes->queryRes); schReleaseJob(*pJob); } return code; } +int32_t schAsyncExecJob(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int64_t *pJob, const char *sql, + int64_t startTs, SSchResInfo *pRes) { + int32_t code = 0; + + *pJob = 0; + + if (EXPLAIN_MODE_STATIC == pDag->explainInfo.mode) { + SCH_ERR_RET(schExecStaticExplainJob(pTrans, pNodeList, pDag, pJob, sql, pRes, false)); + } else { + SCH_ERR_RET(schExecJobImpl(pTrans, pNodeList, pDag, pJob, sql, pRes, startTs, false)); + } + + return code; +} + int32_t schExecStaticExplainJob(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int64_t *job, const char *sql, SSchResInfo *pRes, bool sync) { qDebug("QID:0x%" PRIx64 " job started", pDag->queryId); @@ -1303,10 +1389,11 @@ int32_t schExecStaticExplainJob(void *pTrans, SArray *pNodeList, SQueryPlan *pDa pJob->sql = sql; pJob->attr.queryJob = true; + pJob->attr.syncSchedule = sync; pJob->attr.explainMode = pDag->explainInfo.mode; pJob->queryId = pDag->queryId; pJob->subPlans = pDag->pSubplans; - pJob->userRes = pRes; + pJob->userRes = *pRes; SCH_ERR_JRET(qExecStaticExplain(pDag, (SRetrieveTableRsp **)&pJob->resData)); @@ -1318,7 +1405,7 @@ int32_t schExecStaticExplainJob(void *pTrans, SArray *pNodeList, SQueryPlan *pDa if (NULL == schAcquireJob(refId)) { SCH_JOB_ELOG("schAcquireJob job failed, refId:%" PRIx64, refId); - SCH_RET(TSDB_CODE_SCH_STATUS_ERROR); + SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } pJob->refId = refId; @@ -1326,12 +1413,17 @@ int32_t schExecStaticExplainJob(void *pTrans, SArray *pNodeList, SQueryPlan *pDa SCH_JOB_DLOG("job refId:%" PRIx64, pJob->refId); pJob->status = JOB_TASK_STATUS_PARTIAL_SUCCEED; + *job = pJob->refId; SCH_JOB_DLOG("job exec done, job status:%s", SCH_GET_JOB_STATUS_STR(pJob)); + if (!pJob->attr.syncSchedule) { + code = schNotifyUserQueryRes(pJob); + } + schReleaseJob(pJob->refId); - return TSDB_CODE_SUCCESS; + SCH_RET(code); _return: @@ -1339,4 +1431,103 @@ _return: SCH_RET(code); } +int32_t schFetchRows(SSchJob *pJob) { + int32_t code = 0; + + int8_t status = SCH_GET_JOB_STATUS(pJob); + if (status == JOB_TASK_STATUS_DROPPING) { + SCH_JOB_ELOG("job is dropping, status:%s", jobTaskStatusStr(status)); + SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); + } + + if (!SCH_JOB_NEED_FETCH(pJob)) { + SCH_JOB_ELOG("no need to fetch data, status:%s", SCH_GET_JOB_STATUS_STR(pJob)); + SCH_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + } + + if (atomic_val_compare_exchange_8(&pJob->userFetch, 0, 1) != 0) { + SCH_JOB_ELOG("prior fetching not finished, userFetch:%d", atomic_load_8(&pJob->userFetch)); + SCH_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + } + + if (JOB_TASK_STATUS_FAILED == status || JOB_TASK_STATUS_DROPPING == status) { + SCH_JOB_ELOG("job failed or dropping, status:%s", jobTaskStatusStr(status)); + SCH_ERR_JRET(atomic_load_32(&pJob->errCode)); + } else if (status == JOB_TASK_STATUS_SUCCEED) { + SCH_JOB_DLOG("job already succeed, status:%s", jobTaskStatusStr(status)); + goto _return; + } else if (status != JOB_TASK_STATUS_PARTIAL_SUCCEED) { + SCH_JOB_ELOG("job status error for fetch, status:%s", jobTaskStatusStr(status)); + SCH_ERR_JRET(TSDB_CODE_SCH_STATUS_ERROR); + } + + if (!(pJob->attr.explainMode == EXPLAIN_MODE_STATIC)) { + SCH_ERR_JRET(schFetchFromRemote(pJob)); + tsem_wait(&pJob->rspSem); + + status = SCH_GET_JOB_STATUS(pJob); + if (JOB_TASK_STATUS_FAILED == status || JOB_TASK_STATUS_DROPPING == status) { + SCH_JOB_ELOG("job failed or dropping, status:%s", jobTaskStatusStr(status)); + SCH_ERR_JRET(atomic_load_32(&pJob->errCode)); + } + } + + SCH_ERR_JRET(schSetJobFetchRes(pJob, pJob->userRes.fetchRes)); + +_return: + + atomic_val_compare_exchange_8(&pJob->userFetch, 1, 0); + + SCH_RET(code); +} + +int32_t schAsyncFetchRows(SSchJob *pJob) { + int32_t code = 0; + + int8_t status = SCH_GET_JOB_STATUS(pJob); + if (status == JOB_TASK_STATUS_DROPPING) { + SCH_JOB_ELOG("job is dropping, status:%s", jobTaskStatusStr(status)); + SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); + } + + if (!SCH_JOB_NEED_FETCH(pJob)) { + SCH_JOB_ELOG("no need to fetch data, status:%s", SCH_GET_JOB_STATUS_STR(pJob)); + SCH_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + } + + if (atomic_val_compare_exchange_8(&pJob->userFetch, 0, 1) != 0) { + SCH_JOB_ELOG("prior fetching not finished, userFetch:%d", atomic_load_8(&pJob->userFetch)); + SCH_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + } + + if (JOB_TASK_STATUS_FAILED == status || JOB_TASK_STATUS_DROPPING == status) { + SCH_JOB_ELOG("job failed or dropping, status:%s", jobTaskStatusStr(status)); + SCH_ERR_JRET(atomic_load_32(&pJob->errCode)); + } else if (status == JOB_TASK_STATUS_SUCCEED) { + SCH_JOB_DLOG("job already succeed, status:%s", jobTaskStatusStr(status)); + goto _return; + } else if (status != JOB_TASK_STATUS_PARTIAL_SUCCEED) { + SCH_JOB_ELOG("job status error for fetch, status:%s", jobTaskStatusStr(status)); + SCH_ERR_JRET(TSDB_CODE_SCH_STATUS_ERROR); + } + + if (pJob->attr.explainMode == EXPLAIN_MODE_STATIC) { + SCH_ERR_JRET(schNotifyUserFetchRes(pJob)); + + atomic_val_compare_exchange_8(&pJob->userFetch, 1, 0); + } else { + pJob->userCb = SCH_FETCH_CB; + + SCH_ERR_JRET(schFetchFromRemote(pJob)); + } + + return TSDB_CODE_SUCCESS; + +_return: + + atomic_val_compare_exchange_8(&pJob->userFetch, 1, 0); + + SCH_RET(code); +} + diff --git a/source/libs/scheduler/src/schRemote.c b/source/libs/scheduler/src/schRemote.c index 247358af8f..33c04318cf 100644 --- a/source/libs/scheduler/src/schRemote.c +++ b/source/libs/scheduler/src/schRemote.c @@ -450,7 +450,7 @@ int32_t schHandleLinkBrokenCallback(void *param, const SDataBuf *pMsg, int32_t c if (head->isHbParam) { SSchHbCallbackParam *hbParam = (SSchHbCallbackParam *)param; - SSchTrans trans = {.transInst = hbParam->transport, .transHandle = NULL}; + SSchTrans trans = {.pTrans = hbParam->pTrans, .pHandle = NULL}; SCH_ERR_RET(schUpdateHbConnection(&hbParam->nodeEpId, &trans)); SCH_ERR_RET(schBuildAndSendHbMsg(&hbParam->nodeEpId)); @@ -556,7 +556,7 @@ int32_t schMakeHbCallbackParam(SSchJob *pJob, SSchTask *pTask, void **pParam) { param->nodeEpId.nodeId = addr->nodeId; memcpy(¶m->nodeEpId.ep, SCH_GET_CUR_EP(addr), sizeof(SEp)); - param->transport = pJob->pTrans; + param->pTrans = pJob->pTrans; *pParam = param; @@ -638,7 +638,7 @@ int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { SCH_ERR_JRET(schGetCallbackFp(TDMT_VND_QUERY_HEARTBEAT, &fp)); param->nodeEpId = epId; - param->transport = pJob->pTrans; + param->pTrans = pJob->pTrans; pMsgSendInfo->param = param; pMsgSendInfo->fp = fp; @@ -1208,7 +1208,7 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, SCH_SET_TASK_LASTMSG_TYPE(pTask, msgType); - SSchTrans trans = {.transInst = pJob->pTrans, .transHandle = SCH_GET_TASK_HANDLE(pTask)}; + SSchTrans trans = {.pTrans = pJob->pTrans, .pHandle = SCH_GET_TASK_HANDLE(pTask)}; SCH_ERR_JRET(schAsyncSendMsg(pJob, pTask, &trans, &epSet, msgType, msg, msgSize, persistHandle, (rpcCtx.args ? &rpcCtx : NULL))); diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index de802465c2..8d802980ea 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -73,18 +73,18 @@ int32_t schedulerExecJob(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int6 SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } - SSchResInfo resInfo = {.queryRes = *pRes}; - SCH_RET(schExecJob(pTrans, pNodeList, pDag, pJob, sql, startTs, &resInfo, true)); + SSchResInfo resInfo = {.queryRes = pRes}; + SCH_RET(schExecJob(pTrans, pNodeList, pDag, pJob, sql, startTs, &resInfo)); } int32_t schedulerAsyncExecJob(void *pTrans, SArray *pNodeList, SQueryPlan *pDag, int64_t *pJob, const char *sql, - int64_t startTs, SQueryResult *pRes, schedulerCallback fp, void* param) { - if (NULL == pTrans || NULL == pDag || NULL == pDag->pSubplans || NULL == pJob || NULL == pRes || NULL == fp || NULL == param) { + int64_t startTs, schedulerExecCallback fp, void* param) { + if (NULL == pTrans || NULL == pDag || NULL == pDag->pSubplans || NULL == pJob || NULL == fp || NULL == param) { SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } - SSchResInfo resInfo = {.queryRes = *pRes, .userFp = fp, .userParam = param}; - SCH_RET(schExecJob(pTrans, pNodeList, pDag, pJob, sql, startTs, &resInfo, false)); + SSchResInfo resInfo = {.execFp = fp, .userParam = param}; + SCH_RET(schAsyncExecJob(pTrans, pNodeList, pDag, pJob, sql, startTs, &resInfo)); } int32_t schedulerFetchRows(int64_t job, void **pData) { @@ -99,76 +99,32 @@ int32_t schedulerFetchRows(int64_t job, void **pData) { SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } - int8_t status = SCH_GET_JOB_STATUS(pJob); - if (status == JOB_TASK_STATUS_DROPPING) { - SCH_JOB_ELOG("job is dropping, status:%s", jobTaskStatusStr(status)); - schReleaseJob(job); + pJob->attr.syncSchedule = true; + pJob->userRes.fetchRes = pData; + code = schFetchRows(pJob); + + schReleaseJob(job); + + SCH_RET(code); +} + +int32_t schedulerAsyncFetchRows(int64_t job, schedulerFetchCallback fp, void* param) { + if (NULL == fp || NULL == param) { + SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); + } + + int32_t code = 0; + SSchJob *pJob = schAcquireJob(job); + if (NULL == pJob) { + qError("acquire job from jobRef list failed, may be dropped, refId:%" PRIx64, job); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } - if (!SCH_JOB_NEED_FETCH(pJob)) { - SCH_JOB_ELOG("no need to fetch data, status:%s", SCH_GET_JOB_STATUS_STR(pJob)); - schReleaseJob(job); - SCH_ERR_RET(TSDB_CODE_QRY_APP_ERROR); - } - - if (atomic_val_compare_exchange_8(&pJob->userFetch, 0, 1) != 0) { - SCH_JOB_ELOG("prior fetching not finished, userFetch:%d", atomic_load_8(&pJob->userFetch)); - schReleaseJob(job); - SCH_ERR_RET(TSDB_CODE_QRY_APP_ERROR); - } - - if (JOB_TASK_STATUS_FAILED == status || JOB_TASK_STATUS_DROPPING == status) { - SCH_JOB_ELOG("job failed or dropping, status:%s", jobTaskStatusStr(status)); - SCH_ERR_JRET(atomic_load_32(&pJob->errCode)); - } else if (status == JOB_TASK_STATUS_SUCCEED) { - SCH_JOB_DLOG("job already succeed, status:%s", jobTaskStatusStr(status)); - goto _return; - } else if (status == JOB_TASK_STATUS_PARTIAL_SUCCEED) { - if (!(pJob->attr.explainMode == EXPLAIN_MODE_STATIC)) { - SCH_ERR_JRET(schFetchFromRemote(pJob)); - tsem_wait(&pJob->rspSem); - } - } else { - SCH_JOB_ELOG("job status error for fetch, status:%s", jobTaskStatusStr(status)); - SCH_ERR_JRET(TSDB_CODE_SCH_STATUS_ERROR); - } - - status = SCH_GET_JOB_STATUS(pJob); - - if (JOB_TASK_STATUS_FAILED == status || JOB_TASK_STATUS_DROPPING == status) { - SCH_JOB_ELOG("job failed or dropping, status:%s", jobTaskStatusStr(status)); - SCH_ERR_JRET(atomic_load_32(&pJob->errCode)); - } - - if (pJob->resData && ((SRetrieveTableRsp *)pJob->resData)->completed) { - SCH_ERR_JRET(schChkUpdateJobStatus(pJob, JOB_TASK_STATUS_SUCCEED)); - } - - while (true) { - *pData = atomic_load_ptr(&pJob->resData); - if (*pData != atomic_val_compare_exchange_ptr(&pJob->resData, *pData, NULL)) { - continue; - } - - break; - } - - if (NULL == *pData) { - SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)taosMemoryCalloc(1, sizeof(SRetrieveTableRsp)); - if (rsp) { - rsp->completed = 1; - } - - *pData = rsp; - SCH_JOB_DLOG("empty res and set query complete, code:%x", code); - } - - SCH_JOB_DLOG("fetch done, totalRows:%d, code:%s", pJob->resNumOfRows, tstrerror(code)); - -_return: - - atomic_val_compare_exchange_8(&pJob->userFetch, 1, 0); + pJob->attr.syncSchedule = false; + pJob->userRes.fetchFp = fp; + pJob->userRes.userParam = param; + + code = schFetchRows(pJob); schReleaseJob(job); diff --git a/source/libs/scheduler/test/schedulerTests.cpp b/source/libs/scheduler/test/schedulerTests.cpp index fc0e05aaf1..ec5d74372d 100644 --- a/source/libs/scheduler/test/schedulerTests.cpp +++ b/source/libs/scheduler/test/schedulerTests.cpp @@ -87,6 +87,11 @@ void schtInitLogFile() { } +void schtQueryCb(SQueryResult* pResult, void* param, int32_t code) { + assert(TSDB_CODE_SUCCESS == code); + *(int32_t*)param = 1; +} + void schtBuildQueryDag(SQueryPlan *dag) { uint64_t qId = schtQueryId; @@ -485,6 +490,7 @@ void* schtRunJobThread(void *aa) { SHashObj *execTasks = NULL; SDataBuf dataBuf = {0}; uint32_t jobFinished = 0; + int32_t queryDone = 0; while (!schtTestStop) { schtBuildQueryDag(&dag); @@ -496,7 +502,8 @@ void* schtRunJobThread(void *aa) { qnodeAddr.port = 6031; taosArrayPush(qnodeList, &qnodeAddr); - code = schedulerAsyncExecJob(mockPointer, qnodeList, &dag, "select * from tb", &queryJobRefId); + queryDone = 0; + code = schedulerAsyncExecJob(mockPointer, qnodeList, &dag, &queryJobRefId, "select * from tb", 0, schtQueryCb, &queryDone); assert(code == 0); pJob = schAcquireJob(queryJobRefId); @@ -595,6 +602,14 @@ void* schtRunJobThread(void *aa) { pIter = taosHashIterate(execTasks, pIter); } + while (true) { + if (queryDone) { + break; + } + + taosUsleep(10000); + } + atomic_store_32(&schtStartFetch, 1); void *data = NULL; @@ -667,8 +682,9 @@ TEST(queryTest, normalCase) { schtSetPlanToString(); schtSetExecNode(); schtSetAsyncSendMsgToServer(); - - code = schedulerAsyncExecJob(mockPointer, qnodeList, &dag, "select * from tb", &job); + + int32_t queryDone = 0; + code = schedulerAsyncExecJob(mockPointer, qnodeList, &dag, &job, "select * from tb", 0, schtQueryCb, &queryDone); ASSERT_EQ(code, 0); @@ -718,6 +734,14 @@ TEST(queryTest, normalCase) { pIter = taosHashIterate(pJob->execTasks, pIter); } + while (true) { + if (queryDone) { + break; + } + + taosUsleep(10000); + } + TdThreadAttr thattr; taosThreadAttrInit(&thattr); @@ -773,8 +797,9 @@ TEST(queryTest, readyFirstCase) { schtSetPlanToString(); schtSetExecNode(); schtSetAsyncSendMsgToServer(); - - code = schedulerAsyncExecJob(mockPointer, qnodeList, &dag, "select * from tb", &job); + + int32_t queryDone = 0; + code = schedulerAsyncExecJob(mockPointer, qnodeList, &dag, &job, "select * from tb", 0, schtQueryCb, &queryDone); ASSERT_EQ(code, 0); @@ -824,6 +849,13 @@ TEST(queryTest, readyFirstCase) { pIter = taosHashIterate(pJob->execTasks, pIter); } + while (true) { + if (queryDone) { + break; + } + + taosUsleep(10000); + } TdThreadAttr thattr; @@ -885,16 +917,17 @@ TEST(queryTest, flowCtrlCase) { schtSetPlanToString(); schtSetExecNode(); schtSetAsyncSendMsgToServer(); - - code = schedulerAsyncExecJob(mockPointer, qnodeList, &dag, "select * from tb", &job); + + int32_t queryDone = 0; + code = schedulerAsyncExecJob(mockPointer, qnodeList, &dag, &job, "select * from tb", 0, schtQueryCb, &queryDone); ASSERT_EQ(code, 0); SSchJob *pJob = schAcquireJob(job); - bool queryDone = false; + bool qDone = false; - while (!queryDone) { + while (!qDone) { void *pIter = taosHashIterate(pJob->execTasks, NULL); if (NULL == pIter) { break; @@ -915,7 +948,7 @@ TEST(queryTest, flowCtrlCase) { code = schHandleResponseMsg(pJob, task, TDMT_VND_RES_READY_RSP, (char *)&rsp, sizeof(rsp), 0); ASSERT_EQ(code, 0); } else { - queryDone = true; + qDone = true; break; } @@ -923,6 +956,13 @@ TEST(queryTest, flowCtrlCase) { } } + while (true) { + if (queryDone) { + break; + } + + taosUsleep(10000); + } TdThreadAttr thattr; taosThreadAttrInit(&thattr); From 04238b8ff15464d625b7ac77cf74b68b4c85d393 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Tue, 24 May 2022 19:22:06 +0800 Subject: [PATCH 09/63] fix crash issue --- source/libs/scheduler/src/schJob.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source/libs/scheduler/src/schJob.c b/source/libs/scheduler/src/schJob.c index 52722d819f..d64c944994 100644 --- a/source/libs/scheduler/src/schJob.c +++ b/source/libs/scheduler/src/schJob.c @@ -53,8 +53,10 @@ int32_t schInitJob(SSchJob **pSchJob, SQueryPlan *pDag, void *pTrans, SArray *pN pJob->attr.syncSchedule = syncSchedule; pJob->pTrans = pTrans; pJob->sql = sql; - pJob->userRes = *pRes; - + if (pRes) { + pJob->userRes = *pRes; + } + if (pNodeList != NULL) { pJob->nodeList = taosArrayDup(pNodeList); } @@ -1393,7 +1395,9 @@ int32_t schExecStaticExplainJob(void *pTrans, SArray *pNodeList, SQueryPlan *pDa pJob->attr.explainMode = pDag->explainInfo.mode; pJob->queryId = pDag->queryId; pJob->subPlans = pDag->pSubplans; - pJob->userRes = *pRes; + if (pRes) { + pJob->userRes = *pRes; + } SCH_ERR_JRET(qExecStaticExplain(pDag, (SRetrieveTableRsp **)&pJob->resData)); From 54b7e1b29424dbac72d192e2a66bc192584d558f Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Tue, 24 May 2022 21:34:18 +0800 Subject: [PATCH 10/63] fix hb epset issue --- source/client/src/clientHb.c | 6 ++++-- source/dnode/mnode/impl/src/mndProfile.c | 2 +- source/libs/parser/src/parInsertData.c | 2 +- source/libs/scheduler/src/schRemote.c | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index d01ec501ba..193d64bf6c 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -140,8 +140,10 @@ static int32_t hbQueryHbRspHandle(SAppHbMgr *pAppHbMgr, SClientHbRsp *pRsp) { STscObj *pTscObj = (STscObj *)acquireTscObj(pRsp->connKey.tscRid); if (NULL == pTscObj) { tscDebug("tscObj rid %" PRIx64 " not exist", pRsp->connKey.tscRid); - } else { - updateEpSet_s(&pTscObj->pAppInfo->mgmtEp, &pRsp->query->epSet); + } else { + if (pRsp->query->totalDnodes > 1 && !isEpsetEqual(&pTscObj->pAppInfo->mgmtEp.epSet, &pRsp->query->epSet)) { + updateEpSet_s(&pTscObj->pAppInfo->mgmtEp, &pRsp->query->epSet); + } pTscObj->connId = pRsp->query->connId; if (pRsp->query->killRid) { diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index b9ac82d890..c9c52af0fe 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -379,7 +379,7 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb } rspBasic->connId = pConn->id; - rspBasic->totalDnodes = 1; // TODO + rspBasic->totalDnodes = mndGetDnodeSize(pMnode); rspBasic->onlineDnodes = 1; // TODO mndGetMnodeEpSet(pMnode, &rspBasic->epSet); mndReleaseConn(pMnode, pConn); diff --git a/source/libs/parser/src/parInsertData.c b/source/libs/parser/src/parInsertData.c index f82c792c96..6a42109d55 100644 --- a/source/libs/parser/src/parInsertData.c +++ b/source/libs/parser/src/parInsertData.c @@ -137,7 +137,7 @@ static int32_t createDataBlock(size_t defaultSize, int32_t rowSize, int32_t star } memset(dataBuf->pData, 0, sizeof(SSubmitBlk)); - dataBuf->pTableMeta = tableMetaDup(pTableMeta); + dataBuf->pTableMeta = pTableMeta; SParsedDataColInfo* pColInfo = &dataBuf->boundColumnInfo; SSchema* pSchema = getTableColumnSchema(dataBuf->pTableMeta); diff --git a/source/libs/scheduler/src/schRemote.c b/source/libs/scheduler/src/schRemote.c index 33c04318cf..8704f0e339 100644 --- a/source/libs/scheduler/src/schRemote.c +++ b/source/libs/scheduler/src/schRemote.c @@ -396,6 +396,7 @@ int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t msgType, in SCH_ERR_JRET(schHandleResponseMsg(pJob, pTask, msgType, pMsg->pData, pMsg->len, rspCode)); _return: + if (pJob) { schReleaseJob(pParam->refId); } From 7259a35620fbb86479583ffb724efabce356e429 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Tue, 24 May 2022 22:17:52 +0800 Subject: [PATCH 11/63] enh: refactor trans free ctx --- include/libs/transport/trpc.h | 3 +- source/libs/transport/inc/transComm.h | 4 +- source/libs/transport/src/transCli.c | 16 +- source/libs/transport/src/transComm.c | 4 +- source/libs/transport/test/transportTests.cpp | 152 +++++++++--------- source/os/src/osSocket.c | 20 ++- 6 files changed, 105 insertions(+), 94 deletions(-) diff --git a/include/libs/transport/trpc.h b/include/libs/transport/trpc.h index 754a203471..70977bba87 100644 --- a/include/libs/transport/trpc.h +++ b/include/libs/transport/trpc.h @@ -89,19 +89,18 @@ typedef struct SRpcInit { typedef struct { void *val; int32_t (*clone)(void *src, void **dst); - void (*freeFunc)(const void *arg); } SRpcCtxVal; typedef struct { int32_t msgType; void * val; int32_t (*clone)(void *src, void **dst); - void (*freeFunc)(const void *arg); } SRpcBrokenlinkVal; typedef struct { SHashObj * args; SRpcBrokenlinkVal brokenVal; + void (*freeFunc)(const void *arg); } SRpcCtx; int32_t rpcInit(); diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index 30f799f39e..683f6c88c6 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -95,8 +95,8 @@ typedef void* queue[2]; #define QUEUE_DATA(e, type, field) ((type*)((void*)((char*)(e)-offsetof(type, field)))) #define TRANS_RETRY_COUNT_LIMIT 100 // retry count limit -#define TRANS_RETRY_INTERVAL 15 // ms retry interval -#define TRANS_CONN_TIMEOUT 3 // connect timeout +#define TRANS_RETRY_INTERVAL 15 // ms retry interval +#define TRANS_CONN_TIMEOUT 3 // connect timeout typedef SRpcMsg STransMsg; typedef SRpcCtx STransCtx; diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 92c5e9faf7..159b0cdd07 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -131,6 +131,19 @@ static void destroyThrdObj(SCliThrdObj* pThrd); static void cliWalkCb(uv_handle_t* handle, void* arg); +static void cliReleaseUnfinishedMsg(SCliConn* conn) { + SCliMsg* pMsg = NULL; + for (int i = 0; i < transQueueSize(&conn->cliMsgs); i++) { + pMsg = transQueueGet(&conn->cliMsgs, i); + if (pMsg != NULL && pMsg->ctx != NULL) { + if (conn->ctx.freeFunc != NULL) { + conn->ctx.freeFunc(pMsg->ctx->ahandle); + } + } + destroyCmsg(pMsg); + } +} + #define CLI_RELEASE_UV(loop) \ do { \ uv_walk(loop, cliWalkCb, NULL); \ @@ -161,6 +174,7 @@ static void cliWalkCb(uv_handle_t* handle, void* arg); transUnrefCliHandle(conn); \ } \ destroyCmsg(pMsg); \ + cliReleaseUnfinishedMsg(conn); \ addConnToPool(((SCliThrdObj*)conn->hostThrd)->pool, conn); \ return; \ } \ @@ -465,8 +479,8 @@ static void addConnToPool(void* pool, SCliConn* conn) { STrans* pTransInst = ((SCliThrdObj*)conn->hostThrd)->pTransInst; conn->expireTime = taosGetTimestampMs() + CONN_PERSIST_TIME(pTransInst->idleTime); - transCtxCleanup(&conn->ctx); transQueueClear(&conn->cliMsgs); + transCtxCleanup(&conn->ctx); conn->status = ConnInPool; char key[128] = {0}; diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index 7014cc481f..53f86ba0e9 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -233,7 +233,7 @@ void transCtxCleanup(STransCtx* ctx) { STransCtxVal* iter = taosHashIterate(ctx->args, NULL); while (iter) { - iter->freeFunc(iter->val); + ctx->freeFunc(iter->val); iter = taosHashIterate(ctx->args, iter); } @@ -257,7 +257,7 @@ void transCtxMerge(STransCtx* dst, STransCtx* src) { STransCtxVal* dVal = taosHashGet(dst->args, key, klen); if (dVal) { - dVal->freeFunc(dVal->val); + dst->freeFunc(dVal->val); } taosHashPut(dst->args, key, klen, sVal, sizeof(*sVal)); iter = taosHashIterate(src->args, iter); diff --git a/source/libs/transport/test/transportTests.cpp b/source/libs/transport/test/transportTests.cpp index a84bd94a00..6c8b30b6e4 100644 --- a/source/libs/transport/test/transportTests.cpp +++ b/source/libs/transport/test/transportTests.cpp @@ -156,80 +156,80 @@ int32_t cloneVal(void *src, void **dst) { memcpy(*dst, src, sz); return 0; } -TEST_F(TransCtxEnv, mergeTest) { - int key = 1; - { - STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx)); - transCtxInit(src); - { - STransCtxVal val1 = {NULL, NULL, (void (*)(const void *))taosMemoryFree}; - val1.val = taosMemoryMalloc(12); - - taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); - key++; - } - { - STransCtxVal val1 = {NULL, NULL, (void (*)(const void *))taosMemoryFree}; - val1.val = taosMemoryMalloc(12); - taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); - key++; - } - transCtxMerge(ctx, src); - taosMemoryFree(src); - } - EXPECT_EQ(2, taosHashGetSize(ctx->args)); - { - STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx)); - transCtxInit(src); - { - STransCtxVal val1 = {NULL, NULL, (void (*)(const void *))taosMemoryFree}; - val1.val = taosMemoryMalloc(12); - - taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); - key++; - } - { - STransCtxVal val1 = {NULL, NULL, (void (*)(const void *))taosMemoryFree}; - val1.val = taosMemoryMalloc(12); - taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); - key++; - } - transCtxMerge(ctx, src); - taosMemoryFree(src); - } - std::string val("Hello"); - EXPECT_EQ(4, taosHashGetSize(ctx->args)); - { - key = 1; - STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx)); - transCtxInit(src); - { - STransCtxVal val1 = {NULL, NULL, (void (*)(const void *))taosMemoryFree}; - val1.val = taosMemoryCalloc(1, 11); - val1.clone = cloneVal; - memcpy(val1.val, val.c_str(), val.size()); - - taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); - key++; - } - { - STransCtxVal val1 = {NULL, NULL, (void (*)(const void *))taosMemoryFree}; - val1.val = taosMemoryCalloc(1, 11); - val1.clone = cloneVal; - memcpy(val1.val, val.c_str(), val.size()); - taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); - key++; - } - transCtxMerge(ctx, src); - taosMemoryFree(src); - } - EXPECT_EQ(4, taosHashGetSize(ctx->args)); - - char *skey = (char *)transCtxDumpVal(ctx, 1); - EXPECT_EQ(0, strcmp(skey, val.c_str())); - taosMemoryFree(skey); - - skey = (char *)transCtxDumpVal(ctx, 2); - EXPECT_EQ(0, strcmp(skey, val.c_str())); -} +// TEST_F(TransCtxEnv, mergeTest) { +// int key = 1; +// { +// STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx)); +// transCtxInit(src); +// { +// STransCtxVal val1 = {NULL, NULL, (void (*)(const void *))taosMemoryFree}; +// val1.val = taosMemoryMalloc(12); +// +// taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); +// key++; +// } +// { +// STransCtxVal val1 = {NULL, NULL, (void (*)(const void *))taosMemoryFree}; +// val1.val = taosMemoryMalloc(12); +// taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); +// key++; +// } +// transCtxMerge(ctx, src); +// taosMemoryFree(src); +// } +// EXPECT_EQ(2, taosHashGetSize(ctx->args)); +// { +// STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx)); +// transCtxInit(src); +// { +// STransCtxVal val1 = {NULL, NULL, (void (*)(const void *))taosMemoryFree}; +// val1.val = taosMemoryMalloc(12); +// +// taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); +// key++; +// } +// { +// STransCtxVal val1 = {NULL, NULL, (void (*)(const void *))taosMemoryFree}; +// val1.val = taosMemoryMalloc(12); +// taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); +// key++; +// } +// transCtxMerge(ctx, src); +// taosMemoryFree(src); +// } +// std::string val("Hello"); +// EXPECT_EQ(4, taosHashGetSize(ctx->args)); +// { +// key = 1; +// STransCtx *src = (STransCtx *)taosMemoryCalloc(1, sizeof(STransCtx)); +// transCtxInit(src); +// { +// STransCtxVal val1 = {NULL, NULL, (void (*)(const void *))taosMemoryFree}; +// val1.val = taosMemoryCalloc(1, 11); +// val1.clone = cloneVal; +// memcpy(val1.val, val.c_str(), val.size()); +// +// taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); +// key++; +// } +// { +// STransCtxVal val1 = {NULL, NULL, (void (*)(const void *))taosMemoryFree}; +// val1.val = taosMemoryCalloc(1, 11); +// val1.clone = cloneVal; +// memcpy(val1.val, val.c_str(), val.size()); +// taosHashPut(src->args, &key, sizeof(key), &val1, sizeof(val1)); +// key++; +// } +// transCtxMerge(ctx, src); +// taosMemoryFree(src); +// } +// EXPECT_EQ(4, taosHashGetSize(ctx->args)); +// +// char *skey = (char *)transCtxDumpVal(ctx, 1); +// EXPECT_EQ(0, strcmp(skey, val.c_str())); +// taosMemoryFree(skey); +// +// skey = (char *)transCtxDumpVal(ctx, 2); +// EXPECT_EQ(0, strcmp(skey, val.c_str())); +//} #endif diff --git a/source/os/src/osSocket.c b/source/os/src/osSocket.c index 572e2db6fd..4a0d9e2866 100644 --- a/source/os/src/osSocket.c +++ b/source/os/src/osSocket.c @@ -889,11 +889,11 @@ uint32_t taosGetIpv4FromFqdn(const char *fqdn) { #ifdef WINDOWS // Initialize Winsock WSADATA wsaData; - int iResult; + int iResult; iResult = WSAStartup(MAKEWORD(2, 2), &wsaData); if (iResult != 0) { - printf("WSAStartup failed: %d\n", iResult); - return 1; + // printf("WSAStartup failed: %d\n", iResult); + return 1; } #endif struct addrinfo hints = {0}; @@ -913,12 +913,12 @@ uint32_t taosGetIpv4FromFqdn(const char *fqdn) { } else { #ifdef EAI_SYSTEM if (ret == EAI_SYSTEM) { - printf("failed to get the ip address, fqdn:%s, errno:%d, since:%s", fqdn, errno, strerror(errno)); + // printf("failed to get the ip address, fqdn:%s, errno:%d, since:%s", fqdn, errno, strerror(errno)); } else { - printf("failed to get the ip address, fqdn:%s, ret:%d, since:%s", fqdn, ret, gai_strerror(ret)); + // printf("failed to get the ip address, fqdn:%s, ret:%d, since:%s", fqdn, ret, gai_strerror(ret)); } #else - printf("failed to get the ip address, fqdn:%s, ret:%d, since:%s", fqdn, ret, gai_strerror(ret)); + // printf("failed to get the ip address, fqdn:%s, ret:%d, since:%s", fqdn, ret, gai_strerror(ret)); #endif return 0xFFFFFFFF; } @@ -928,7 +928,7 @@ int32_t taosGetFqdn(char *fqdn) { char hostname[1024]; hostname[1023] = '\0'; if (gethostname(hostname, 1023) == -1) { - printf("failed to get hostname, reason:%s", strerror(errno)); + // printf("failed to get hostname, reason:%s", strerror(errno)); assert(0); return -1; } @@ -946,7 +946,7 @@ int32_t taosGetFqdn(char *fqdn) { #endif // __APPLE__ int32_t ret = getaddrinfo(hostname, NULL, &hints, &result); if (!result) { - printf("failed to get fqdn, code:%d, reason:%s", ret, gai_strerror(ret)); + // printf("failed to get fqdn, code:%d, reason:%s", ret, gai_strerror(ret)); assert(0); return -1; } @@ -993,9 +993,7 @@ void tinet_ntoa(char *ipstr, uint32_t ip) { sprintf(ipstr, "%d.%d.%d.%d", ip & 0xFF, (ip >> 8) & 0xFF, (ip >> 16) & 0xFF, ip >> 24); } -void taosIgnSIGPIPE() { - signal(SIGPIPE, SIG_IGN); -} +void taosIgnSIGPIPE() { signal(SIGPIPE, SIG_IGN); } void taosSetMaskSIGPIPE() { #ifdef WINDOWS From 3ac134adbe129c9d4ce8301a3155fb78d6b6ac90 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 24 May 2022 23:10:51 +0800 Subject: [PATCH 12/63] enh: free cursor if it is not a null pointer. --- include/common/tmsg.h | 3 +-- source/libs/executor/src/scanoperator.c | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 32cb739535..88fa385f9c 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -660,8 +660,7 @@ typedef struct { int32_t tz; // query client timezone char intervalUnit; char slidingUnit; - char - offsetUnit; // TODO Remove it, the offset is the number of precision tickle, and it must be a immutable duration. + char offsetUnit; int8_t precision; int64_t interval; int64_t sliding; diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index f77b80c533..2215d0035d 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -1031,8 +1031,9 @@ static void destroySysScanOperator(void* param, int32_t numOfOutput) { blockDataDestroy(pInfo->pRes); const char* name = tNameGetTableName(&pInfo->name); - if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, TSDB_TABLE_FNAME_LEN) == 0) { + if (strncasecmp(name, TSDB_INS_TABLE_USER_TABLES, TSDB_TABLE_FNAME_LEN) == 0 || pInfo->pCur != NULL) { metaCloseTbCursor(pInfo->pCur); + pInfo->pCur = NULL; } taosArrayDestroy(pInfo->scanCols); From 52e05bbfe60c53a472dce83441fa06b580b1e6c4 Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Wed, 25 May 2022 09:25:39 +0800 Subject: [PATCH 13/63] fix mem leak --- source/libs/catalog/src/catalog.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index 4afebf9951..bbb8983713 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -540,12 +540,6 @@ int32_t catalogGetHandle(uint64_t clusterId, SCatalog** catalogHandle) { CTG_ERR_JRET(TSDB_CODE_CTG_MEM_ERROR); } - SHashObj *metaCache = taosHashInit(gCtgMgmt.cfg.maxTblCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_ENTRY_LOCK); - if (NULL == metaCache) { - qError("taosHashInit failed, num:%d", gCtgMgmt.cfg.maxTblCacheNum); - CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR); - } - code = taosHashPut(gCtgMgmt.pCluster, &clusterId, sizeof(clusterId), &clusterCtg, POINTER_BYTES); if (code) { if (HASH_NODE_EXIST(code)) { From c867c6812a448eb53edf284061e2c32d78442dc9 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Wed, 25 May 2022 11:09:14 +0800 Subject: [PATCH 14/63] change rpc ctx api --- source/libs/scheduler/src/schRemote.c | 6 ++++-- source/libs/scheduler/src/schUtil.c | 6 ++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source/libs/scheduler/src/schRemote.c b/source/libs/scheduler/src/schRemote.c index 6d9f6b435f..15847114b5 100644 --- a/source/libs/scheduler/src/schRemote.c +++ b/source/libs/scheduler/src/schRemote.c @@ -643,13 +643,14 @@ int32_t schMakeHbRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { pMsgSendInfo->param = param; pMsgSendInfo->fp = fp; - SRpcCtxVal ctxVal = {.val = pMsgSendInfo, .clone = schCloneSMsgSendInfo, .freeFunc = schFreeRpcCtxVal}; + SRpcCtxVal ctxVal = {.val = pMsgSendInfo, .clone = schCloneSMsgSendInfo}; if (taosHashPut(pCtx->args, &msgType, sizeof(msgType), &ctxVal, sizeof(ctxVal))) { SCH_TASK_ELOG("taosHashPut msg %d to rpcCtx failed", msgType); SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } SCH_ERR_JRET(schMakeBrokenLinkVal(pJob, pTask, &pCtx->brokenVal, true)); + pCtx->freeFunc = schFreeRpcCtxVal; return TSDB_CODE_SUCCESS; @@ -938,7 +939,7 @@ int32_t schMakeQueryRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { SCH_ERR_JRET(schGenerateCallBackInfo(pJob, pTask, TDMT_VND_EXPLAIN, &pExplainMsgSendInfo)); int32_t msgType = TDMT_VND_RES_READY_RSP; - SRpcCtxVal ctxVal = {.val = pReadyMsgSendInfo, .clone = schCloneSMsgSendInfo, .freeFunc = schFreeRpcCtxVal}; + SRpcCtxVal ctxVal = {.val = pReadyMsgSendInfo, .clone = schCloneSMsgSendInfo}; if (taosHashPut(pCtx->args, &msgType, sizeof(msgType), &ctxVal, sizeof(ctxVal))) { SCH_TASK_ELOG("taosHashPut msg %d to rpcCtx failed", msgType); SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); @@ -952,6 +953,7 @@ int32_t schMakeQueryRpcCtx(SSchJob *pJob, SSchTask *pTask, SRpcCtx *pCtx) { } SCH_ERR_JRET(schMakeBrokenLinkVal(pJob, pTask, &pCtx->brokenVal, false)); + pCtx->freeFunc = schFreeRpcCtxVal; return TSDB_CODE_SUCCESS; diff --git a/source/libs/scheduler/src/schUtil.c b/source/libs/scheduler/src/schUtil.c index 57a86ba125..3862ba76f6 100644 --- a/source/libs/scheduler/src/schUtil.c +++ b/source/libs/scheduler/src/schUtil.c @@ -77,16 +77,14 @@ void schFreeRpcCtx(SRpcCtx *pCtx) { while (pIter) { SRpcCtxVal *ctxVal = (SRpcCtxVal *)pIter; - (*ctxVal->freeFunc)(ctxVal->val); + (*pCtx->freeFunc)(ctxVal->val); pIter = taosHashIterate(pCtx->args, pIter); } taosHashCleanup(pCtx->args); - if (pCtx->brokenVal.freeFunc) { - (*pCtx->brokenVal.freeFunc)(pCtx->brokenVal.val); - } + (*pCtx->freeFunc)(pCtx->brokenVal.val); } From 6c6237abe5bb6944a4c0c207c4730b27551edb3e Mon Sep 17 00:00:00 2001 From: dapan1121 <89396746@qq.com> Date: Wed, 25 May 2022 13:27:36 +0800 Subject: [PATCH 15/63] fix mem double free issue --- source/libs/parser/src/parInsert.c | 7 ++----- source/libs/parser/src/parInsertData.c | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 11324e3f49..76dddcf192 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -1073,7 +1073,6 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) { int32_t tbNum = 0; char tbFName[TSDB_TABLE_FNAME_LEN]; bool autoCreateTbl = false; - STableMeta* pMeta = NULL; // for each table while (1) { @@ -1136,12 +1135,10 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) { CHECK_CODE(getDataBlockFromList(pCxt->pTableBlockHashObj, tbFName, strlen(tbFName), TSDB_DEFAULT_PAYLOAD_SIZE, sizeof(SSubmitBlk), getTableInfo(pCxt->pTableMeta).rowSize, pCxt->pTableMeta, &dataBuf, NULL, &pCxt->createTblReq)); - pMeta = pCxt->pTableMeta; - pCxt->pTableMeta = NULL; if (TK_NK_LP == sToken.type) { // pSql -> field1_name, ...) - CHECK_CODE(parseBoundColumns(pCxt, &dataBuf->boundColumnInfo, getTableColumnSchema(pMeta))); + CHECK_CODE(parseBoundColumns(pCxt, &dataBuf->boundColumnInfo, getTableColumnSchema(pCxt->pTableMeta))); NEXT_TOKEN(pCxt->pSql, sToken); } @@ -1177,7 +1174,7 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) { return TSDB_CODE_TSC_OUT_OF_MEMORY; } memcpy(tags, &pCxt->tags, sizeof(pCxt->tags)); - (*pCxt->pStmtCb->setInfoFn)(pCxt->pStmtCb->pStmt, pMeta, tags, tbFName, autoCreateTbl, pCxt->pVgroupsHashObj, + (*pCxt->pStmtCb->setInfoFn)(pCxt->pStmtCb->pStmt, pCxt->pTableMeta, tags, tbFName, autoCreateTbl, pCxt->pVgroupsHashObj, pCxt->pTableBlockHashObj); memset(&pCxt->tags, 0, sizeof(pCxt->tags)); diff --git a/source/libs/parser/src/parInsertData.c b/source/libs/parser/src/parInsertData.c index 6a42109d55..f82c792c96 100644 --- a/source/libs/parser/src/parInsertData.c +++ b/source/libs/parser/src/parInsertData.c @@ -137,7 +137,7 @@ static int32_t createDataBlock(size_t defaultSize, int32_t rowSize, int32_t star } memset(dataBuf->pData, 0, sizeof(SSubmitBlk)); - dataBuf->pTableMeta = pTableMeta; + dataBuf->pTableMeta = tableMetaDup(pTableMeta); SParsedDataColInfo* pColInfo = &dataBuf->boundColumnInfo; SSchema* pSchema = getTableColumnSchema(dataBuf->pTableMeta); From e256a0dbe3bd650fd4b74d4b94ce314f61b5c07e Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Wed, 25 May 2022 14:23:09 +0800 Subject: [PATCH 16/63] change ctx api --- source/libs/scheduler/src/schRemote.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/libs/scheduler/src/schRemote.c b/source/libs/scheduler/src/schRemote.c index 15847114b5..3996771443 100644 --- a/source/libs/scheduler/src/schRemote.c +++ b/source/libs/scheduler/src/schRemote.c @@ -565,8 +565,9 @@ int32_t schMakeHbCallbackParam(SSchJob *pJob, SSchTask *pTask, void **pParam) { int32_t schCloneHbRpcCtx(SRpcCtx *pSrc, SRpcCtx *pDst) { int32_t code = 0; - memcpy(&pDst->brokenVal, &pSrc->brokenVal, sizeof(pSrc->brokenVal)); + memcpy(pDst, pSrc, sizeof(SRpcCtx)); pDst->brokenVal.val = NULL; + pDst->args = NULL; SCH_ERR_RET(schCloneSMsgSendInfo(pSrc->brokenVal.val, &pDst->brokenVal.val)); @@ -589,7 +590,7 @@ int32_t schCloneHbRpcCtx(SRpcCtx *pSrc, SRpcCtx *pDst) { if (taosHashPut(pDst->args, msgType, sizeof(*msgType), &dst, sizeof(dst))) { qError("taosHashPut msg %d to rpcCtx failed", *msgType); - (*dst.freeFunc)(dst.val); + (*pSrc->freeFunc)(dst.val); SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } @@ -912,7 +913,6 @@ int32_t schMakeBrokenLinkVal(SSchJob *pJob, SSchTask *pTask, SRpcBrokenlinkVal * brokenVal->msgType = msgType; brokenVal->val = pMsgSendInfo; brokenVal->clone = schCloneSMsgSendInfo; - brokenVal->freeFunc = schFreeRpcCtxVal; return TSDB_CODE_SUCCESS; From a38fcf4e1f2fd0c6146646c5df7a8fc75160ba5b Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Wed, 25 May 2022 14:24:56 +0800 Subject: [PATCH 17/63] catalog async test --- source/libs/catalog/src/ctgDbg.c | 123 +++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) diff --git a/source/libs/catalog/src/ctgDbg.c b/source/libs/catalog/src/ctgDbg.c index 1d4ad0082c..9897370f2d 100644 --- a/source/libs/catalog/src/ctgDbg.c +++ b/source/libs/catalog/src/ctgDbg.c @@ -21,6 +21,129 @@ extern SCatalogMgmt gCtgMgmt; SCtgDebug gCTGDebug = {0}; +void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) { + ASSERT(*(int32_t*)param == 1); + taosMemoryFree(param); + + ctgDebug("async call result: %s", tstrerror(code)); + if (NULL == pResult) { + ctgDebug("empty meta result"); + return; + } + + int32_t num = 0; + + if (pResult->pTableMeta && taosArrayGetSize(pResult->pTableMeta) > 0) { + num = taosArrayGetSize(pResult->pTableMeta); + for (int32_t i = 0; i < num; ++i) { + STableMeta *p = taosArrayGet(pResult->pTableMeta, i); + STableComInfo *c = &p->tableInfo; + + if (TSDB_CHILD_TABLE == p->tableType) { + ctgDebug("table meta: type:%d, vgId:%d, uid:%" PRIx64 ",suid:%" PRIx64, p->tableType, p->vgId, p->uid, p->suid); + return; + } else { + ctgDebug("table meta: type:%d, vgId:%d, uid:%" PRIx64 ",suid:%" PRIx64 ",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d", + p->tableType, p->vgId, p->uid, p->suid, p->sversion, p->tversion, c->numOfTags, c->precision, c->numOfColumns, c->rowSize); + } + + int32_t colNum = c->numOfColumns + c->numOfTags; + for (int32_t j = 0; j < colNum; ++j) { + SSchema *s = &p->schema[j]; + ctgDebug("[%d] name:%s, type:%d, colId:%d, bytes:%d", j, s->name, s->type, s->colId, s->bytes); + } + } + } else { + ctgDebug("empty table meta"); + } + + if (pResult->pDbVgroup && taosArrayGetSize(pResult->pDbVgroup) > 0) { + num = taosArrayGetSize(pResult->pDbVgroup); + for (int32_t i = 0; i < num; ++i) { + SArray *pDb = *(SArray**)taosArrayGet(pResult->pDbVgroup, i); + int32_t vgNum = taosArrayGetSize(pDb); + for (int32_t j = 0; j < vgNum; ++j) { + SVgroupInfo* pInfo = taosArrayGet(pDb, j); + ctgDebug(param, ...); + } + } + } else { + ctgDebug("empty db vgroup"); + } +} + +int32_t ctgdLaunchAsyncCall(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, uint64_t reqId) { + int32_t code = 0; + SCatalogReq req = {0}; + req.pTableMeta = taosArrayInit(2, sizeof(SName)); + req.pDbVgroup = taosArrayInit(2, TSDB_DB_FNAME_LEN); + req.pTableHash = taosArrayInit(2, sizeof(SName)); + req.pUdf = taosArrayInit(2, TSDB_FUNC_NAME_LEN); + req.pDbCfg = taosArrayInit(2, TSDB_DB_FNAME_LEN); + req.pIndex = NULL;//taosArrayInit(2, TSDB_INDEX_FNAME_LEN); + req.pUser = taosArrayInit(2, sizeof(SUserAuthInfo)); + req.qNodeRequired = true; + + SName name = {0}; + char dbFName[TSDB_DB_FNAME_LEN] = {0}; + char funcName[TSDB_FUNC_NAME_LEN] = {0}; + SUserAuthInfo user = {0}; + + tNameFromString(&name, "1.db1.tb1", T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + taosArrayPush(req.pTableMeta, &name); + taosArrayPush(req.pTableHash, &name); + tNameFromString(&name, "1.db1.st1", T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + taosArrayPush(req.pTableMeta, &name); + taosArrayPush(req.pTableHash, &name); + + strcpy(dbFName, "1.db1"); + taosArrayPush(req.pDbVgroup, dbFName); + taosArrayPush(req.pDbCfg, dbFName); + strcpy(dbFName, "1.db2"); + taosArrayPush(req.pDbVgroup, dbFName); + taosArrayPush(req.pDbCfg, dbFName); + + strcpy(funcName, "udf1"); + taosArrayPush(req.pUdf, funcName); + strcpy(funcName, "udf2"); + taosArrayPush(req.pUdf, funcName); + + strcpy(user.user, "root"); + strcpy(user.dbFName, "1.db1"); + user.type = AUTH_TYPE_READ; + taosArrayPush(req.pUser, &user); + user.type = AUTH_TYPE_WRITE; + taosArrayPush(req.pUser, &user); + user.type = AUTH_TYPE_OTHER; + taosArrayPush(req.pUser, &user); + + strcpy(user.user, "user1"); + strcpy(user.dbFName, "1.db2"); + user.type = AUTH_TYPE_READ; + taosArrayPush(req.pUser, &user); + user.type = AUTH_TYPE_WRITE; + taosArrayPush(req.pUser, &user); + user.type = AUTH_TYPE_OTHER; + taosArrayPush(req.pUser, &user); + + int32_t *param = taosMemoryCalloc(1, sizeof(int32_t)); + *param = 1; + + int64_t jobId = 0; + CTG_ERR_JRET(catalogAsyncGetAllMeta(pCtg, pTrans, pMgmtEps, reqId, &req, ctgdUserCallback, param, &jobId)); + +_return: + + taosArrayDestroy(req.pTableMeta); + taosArrayDestroy(req.pDbVgroup); + taosArrayDestroy(req.pTableHash); + taosArrayDestroy(req.pUdf); + taosArrayDestroy(req.pDbCfg); + taosArrayDestroy(req.pUser); + + CTG_RET(code); +} + int32_t ctgdEnableDebug(char *option) { if (0 == strcasecmp(option, "lock")) { gCTGDebug.lockEnable = true; From aa7a1a77505f338abd61eed9809e108a4946d50b Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 25 May 2022 06:38:13 +0000 Subject: [PATCH 18/63] make compile --- source/dnode/vnode/src/vnd/vnodeSnapshot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/dnode/vnode/src/vnd/vnodeSnapshot.c b/source/dnode/vnode/src/vnd/vnodeSnapshot.c index 5e451e4142..baa8422307 100644 --- a/source/dnode/vnode/src/vnd/vnodeSnapshot.c +++ b/source/dnode/vnode/src/vnd/vnodeSnapshot.c @@ -75,7 +75,7 @@ int32_t vnodeSnapshotRead(SVSnapshotReader *pReader, const void **ppData, uint32 int32_t code = 0; if (!pReader->isMetaEnd) { - code = metaSnapshotRead(pReader->pMetaReader, &pReader->pData, &pReader->pData); + code = metaSnapshotRead(pReader->pMetaReader, &pReader->pData, &pReader->nData); if (code) { if (code == TSDB_CODE_VND_READ_END) { pReader->isMetaEnd = 1; @@ -90,7 +90,7 @@ int32_t vnodeSnapshotRead(SVSnapshotReader *pReader, const void **ppData, uint32 } if (!pReader->isTsdbEnd) { - code = tsdbSnapshotRead(pReader->pTsdbReader, &pReader->pData, pReader->nData); + code = tsdbSnapshotRead(pReader->pTsdbReader, &pReader->pData, &pReader->nData); if (code) { if (code == TSDB_CODE_VND_READ_END) { pReader->isTsdbEnd = 1; From 823d47672d0c545e1965e55c2b0bb7f29fe068c5 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Wed, 25 May 2022 14:50:20 +0800 Subject: [PATCH 19/63] enh: asan option --- cmake/cmake.define | 4 ++-- source/util/src/thash.c | 4 ++-- tests/script/jenkins/basic.txt | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmake/cmake.define b/cmake/cmake.define index 0ae4f56f71..a8bab17aba 100644 --- a/cmake/cmake.define +++ b/cmake/cmake.define @@ -71,8 +71,8 @@ ELSE () ENDIF () IF (${SANITIZER} MATCHES "true") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -g3") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=null -fno-sanitize=alignment -g3") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=shift-base -fno-sanitize=alignment -g3") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-literal-suffix -Werror=return-type -fPIC -gdwarf-2 -fsanitize=address -fsanitize=undefined -fsanitize-recover=all -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fno-sanitize=shift-base -fno-sanitize=alignment -g3") MESSAGE(STATUS "Will compile with Address Sanitizer!") ELSE () SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Werror=return-type -fPIC -gdwarf-2 -g3") diff --git a/source/util/src/thash.c b/source/util/src/thash.c index 551c3b67c8..f564ae45b6 100644 --- a/source/util/src/thash.c +++ b/source/util/src/thash.c @@ -708,7 +708,7 @@ SHashNode *doCreateHashNode(const void *key, size_t keyLen, const void *pData, s pNewNode->removed = 0; pNewNode->next = NULL; - memcpy(GET_HASH_NODE_DATA(pNewNode), pData, dsize); + if (pData) memcpy(GET_HASH_NODE_DATA(pNewNode), pData, dsize); memcpy(GET_HASH_NODE_KEY(pNewNode), key, keyLen); return pNewNode; @@ -774,7 +774,7 @@ static void *taosHashReleaseNode(SHashObj *pHashObj, void *p, int *slot) { ASSERT(prevNode->next != prevNode); } else { pe->next = pOld->next; - SHashNode* x = pe->next; + SHashNode *x = pe->next; if (x != NULL) { ASSERT(x->next != x); } diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index f9c6cbf42a..a30b470256 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -67,6 +67,7 @@ # ---- stream ./test.sh -f tsim/stream/basic0.sim ./test.sh -f tsim/stream/basic1.sim +./test.sh -f tsim/stream/basic2.sim ./test.sh -f tsim/stream/session0.sim ./test.sh -f tsim/stream/session1.sim From baccc3040877be3e830f4e2be4f6c3d9a0cb5add Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Wed, 25 May 2022 15:10:56 +0800 Subject: [PATCH 20/63] fix: use real schema version of row --- source/dnode/vnode/src/vnd/vnodeSvr.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 5e50a1b796..ae7ec5a950 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -617,16 +617,18 @@ static int vnodeDebugPrintSingleSubmitMsg(SMeta *pMeta, SSubmitBlk *pBlock, SSub STSchema *pSchema = NULL; tb_uid_t suid = 0; STSRow *row = NULL; + int32_t rv = -1; tInitSubmitBlkIter(msgIter, pBlock, &blkIter); if (blkIter.row == NULL) return 0; - if (!pSchema || (suid != msgIter->suid)) { + if (!pSchema || (suid != msgIter->suid) || rv != TD_ROW_SVER(blkIter.row)) { if (pSchema) { taosMemoryFreeClear(pSchema); } - pSchema = metaGetTbTSchema(pMeta, msgIter->suid, 1); // TODO: use the real schema + pSchema = metaGetTbTSchema(pMeta, msgIter->suid, TD_ROW_SVER(blkIter.row)); // TODO: use the real schema if (pSchema) { suid = msgIter->suid; + rv = TD_ROW_SVER(blkIter.row); } } if (!pSchema) { From 74f2746677df861c6090088c84eae7258eca159e Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 25 May 2022 07:14:36 +0000 Subject: [PATCH 21/63] drop super table --- source/dnode/vnode/src/meta/metaTable.c | 101 +++++++++++++----------- 1 file changed, 54 insertions(+), 47 deletions(-) diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index a792343380..208d6f9fca 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -71,64 +71,71 @@ _err: } int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq) { - TBC *pNameIdxc = NULL; - TBC *pUidIdxc = NULL; - TBC *pCtbIdxc = NULL; - SCtbIdxKey *pCtbIdxKey; - const void *pKey = NULL; - int nKey; - const void *pData = NULL; - int nData; - int c, ret; + void *pKey = NULL; + int nKey = 0; + void *pData = NULL; + int nData = 0; + int c = 0; + int rc = 0; - // prepare uid idx cursor - tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, &pMeta->txn); - ret = tdbTbcMoveTo(pUidIdxc, &pReq->suid, sizeof(tb_uid_t), &c); - if (ret < 0 || c != 0) { - terrno = TSDB_CODE_VND_TB_NOT_EXIST; - tdbTbcClose(pUidIdxc); - goto _err; + // check if super table exists + rc = tdbTbGet(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, &pData, &nData); + if (rc < 0 || *(tb_uid_t *)pData != pReq->suid) { + terrno = TSDB_CODE_VND_TABLE_NOT_EXIST; + return -1; } - // prepare name idx cursor - tdbTbcOpen(pMeta->pNameIdx, &pNameIdxc, &pMeta->txn); - ret = tdbTbcMoveTo(pNameIdxc, pReq->name, strlen(pReq->name) + 1, &c); - if (ret < 0 || c != 0) { - ASSERT(0); - } + // drop all child tables + TBC *pCtbIdxc = NULL; + SArray *pArray = taosArrayInit(8, sizeof(tb_uid_t)); - tdbTbcDelete(pUidIdxc); - tdbTbcDelete(pNameIdxc); - tdbTbcClose(pUidIdxc); - tdbTbcClose(pNameIdxc); - - // loop to drop each child table tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, &pMeta->txn); - ret = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = pReq->suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c); - if (ret < 0 || (c < 0 && tdbTbcMoveToNext(pCtbIdxc) < 0)) { + rc = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = pReq->suid, .uid = INT64_MIN}, sizeof(SCtbIdxKey), &c); + if (rc < 0) { tdbTbcClose(pCtbIdxc); - goto _exit; + metaWLock(pMeta); + goto _drop_super_table; } for (;;) { - tdbTbcGet(pCtbIdxc, &pKey, &nKey, NULL, NULL); - pCtbIdxKey = (SCtbIdxKey *)pKey; + rc = tdbTbcNext(pCtbIdxc, &pKey, &nKey, NULL, NULL); + if (rc < 0) break; - if (pCtbIdxKey->suid > pReq->suid) break; + if (((SCtbIdxKey *)pKey)->suid < pReq->suid) { + continue; + } else if (((SCtbIdxKey *)pKey)->suid > pReq->suid) { + break; + } - // drop the child table (TODO) - - if (tdbTbcMoveToNext(pCtbIdxc) < 0) break; + taosArrayPush(pArray, &(((SCtbIdxKey *)pKey)->uid)); } + tdbTbcClose(pCtbIdxc); + + metaWLock(pMeta); + + for (int32_t iChild = 0; iChild < taosArrayGetSize(pArray); iChild++) { + tb_uid_t uid = *(tb_uid_t *)taosArrayGet(pArray, iChild); + metaDropTableByUid(pMeta, uid); + } + + taosArrayDestroy(pArray); + + // drop super table +_drop_super_table: + tdbTbGet(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), &pData, &nData); + tdbTbDelete(pMeta->pTbDb, &(STbDbKey){.version = *(int64_t *)pData, .uid = pReq->suid}, sizeof(STbDbKey), + &pMeta->txn); + tdbTbDelete(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, &pMeta->txn); + tdbTbDelete(pMeta->pUidIdx, &pReq->suid, sizeof(tb_uid_t), &pMeta->txn); + + metaULock(pMeta); + _exit: + tdbFree(pKey); + tdbFree(pData); metaDebug("vgId:%d super table %s uid:%" PRId64 " is dropped", TD_VID(pMeta->pVnode), pReq->name, pReq->suid); return 0; - -_err: - metaError("vgId:%d failed to drop super table %s uid:%" PRId64 " since %s", TD_VID(pMeta->pVnode), pReq->name, - pReq->suid, tstrerror(terrno)); - return -1; } int metaAlterSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { @@ -608,14 +615,14 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA // TODO : need to update tag index } ctbEntry.version = version; - if(pTagSchema->nCols == 1 && pTagSchema->pSchema[0].type == TSDB_DATA_TYPE_JSON){ + if (pTagSchema->nCols == 1 && pTagSchema->pSchema[0].type == TSDB_DATA_TYPE_JSON) { ctbEntry.ctbEntry.pTags = taosMemoryMalloc(pAlterTbReq->nTagVal); - if(ctbEntry.ctbEntry.pTags == NULL){ + if (ctbEntry.ctbEntry.pTags == NULL) { terrno = TSDB_CODE_OUT_OF_MEMORY; goto _err; } - memcpy((void*)ctbEntry.ctbEntry.pTags, pAlterTbReq->pTagVal, pAlterTbReq->nTagVal); - }else{ + memcpy((void *)ctbEntry.ctbEntry.pTags, pAlterTbReq->pTagVal, pAlterTbReq->nTagVal); + } else { SKVRowBuilder kvrb = {0}; const SKVRow pOldTag = (const SKVRow)ctbEntry.ctbEntry.pTags; SKVRow pNewTag = NULL; @@ -649,7 +656,7 @@ static int metaUpdateTableTagVal(SMeta *pMeta, int64_t version, SVAlterTbReq *pA tDecoderClear(&dc1); tDecoderClear(&dc2); - if (ctbEntry.ctbEntry.pTags) taosMemoryFree((void*)ctbEntry.ctbEntry.pTags); + if (ctbEntry.ctbEntry.pTags) taosMemoryFree((void *)ctbEntry.ctbEntry.pTags); if (ctbEntry.pBuf) taosMemoryFree(ctbEntry.pBuf); if (stbEntry.pBuf) tdbFree(stbEntry.pBuf); tdbTbcClose(pTbDbc); From 84f6898fcd5863767a7694d268f7d729e9c27b3e Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 25 May 2022 15:22:34 +0800 Subject: [PATCH 22/63] enh(query): add detailed sort exec information in analysis of operator. --- include/common/tcommon.h | 10 ++++ include/common/tdatablock.h | 2 +- source/common/src/tdatablock.c | 10 +--- source/libs/command/src/explain.c | 47 ++++++++++++++---- source/libs/executor/inc/executorimpl.h | 10 ++-- source/libs/executor/inc/tsort.h | 8 ++++ source/libs/executor/src/scanoperator.c | 2 +- source/libs/executor/src/sortoperator.c | 63 ++++++++++++++++++++----- source/libs/executor/src/tsort.c | 45 +++++++++++++----- source/util/src/tpagedbuf.c | 15 ++++-- 10 files changed, 158 insertions(+), 54 deletions(-) diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 9e3ad42a82..0ff13963c0 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -219,6 +219,16 @@ typedef struct { #define GET_FORWARD_DIRECTION_FACTOR(ord) (((ord) == TSDB_ORDER_ASC) ? QUERY_ASC_FORWARD_STEP : QUERY_DESC_FORWARD_STEP) +#define SORT_QSORT_T 0x1 +#define SORT_SPILLED_MERGE_SORT_T 0x2 +typedef struct SSortExecInfo { + int32_t sortMethod; + int32_t sortBuffer; + int32_t loops; // loop count + int32_t writeBytes; // write io bytes + int32_t readBytes; // read io bytes +} SSortExecInfo; + #ifdef __cplusplus } #endif diff --git a/include/common/tdatablock.h b/include/common/tdatablock.h index db8644ecfe..e8fe47a462 100644 --- a/include/common/tdatablock.h +++ b/include/common/tdatablock.h @@ -198,7 +198,7 @@ void colDataTrim(SColumnInfoData* pColumnInfoData); size_t blockDataGetNumOfCols(const SSDataBlock* pBlock); size_t blockDataGetNumOfRows(const SSDataBlock* pBlock); -int32_t blockDataMerge(SSDataBlock* pDest, const SSDataBlock* pSrc, SArray* pIndexMap); +int32_t blockDataMerge(SSDataBlock* pDest, const SSDataBlock* pSrc); int32_t blockDataSplitRows(SSDataBlock* pBlock, bool hasVarCol, int32_t startIndex, int32_t* stopIndex, int32_t pageSize); int32_t blockDataToBuf(char* buf, const SSDataBlock* pBlock); diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 51bcd05ea1..816fdab3d2 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -361,19 +361,13 @@ int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock, int32_t tsColumnIndex) return 0; } -// if pIndexMap = NULL, merger one column by on column -int32_t blockDataMerge(SSDataBlock* pDest, const SSDataBlock* pSrc, SArray* pIndexMap) { +int32_t blockDataMerge(SSDataBlock* pDest, const SSDataBlock* pSrc) { assert(pSrc != NULL && pDest != NULL); int32_t capacity = pDest->info.capacity; for (int32_t i = 0; i < pDest->info.numOfCols; ++i) { - int32_t mapIndex = i; - // if (pIndexMap) { - // mapIndex = *(int32_t*)taosArrayGet(pIndexMap, i); - // } - SColumnInfoData* pCol2 = taosArrayGet(pDest->pDataBlock, i); - SColumnInfoData* pCol1 = taosArrayGet(pSrc->pDataBlock, mapIndex); + SColumnInfoData* pCol1 = taosArrayGet(pSrc->pDataBlock, i); capacity = pDest->info.capacity; colDataMergeCol(pCol2, pDest->info.rows, &capacity, pCol1, pSrc->info.rows); diff --git a/source/libs/command/src/explain.c b/source/libs/command/src/explain.c index 1acc9368c8..26a0f3bf6c 100644 --- a/source/libs/command/src/explain.c +++ b/source/libs/command/src/explain.c @@ -16,6 +16,7 @@ #include "commandInt.h" #include "plannodes.h" #include "query.h" +#include "tcommon.h" int32_t qExplainGenerateResNode(SPhysiNode *pNode, SExplainGroup *group, SExplainResNode **pRes); int32_t qExplainAppendGroupResRows(void *pCtx, int32_t groupId, int32_t level); @@ -637,13 +638,48 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); } - EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT, pSortNode->pSortKeys->length); + + SDataBlockDescNode* pDescNode = pSortNode->node.pOutputDataBlockDesc; + EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT, nodesGetOutputNumFromSlotList(pDescNode->pSlots)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); - EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pSortNode->node.pOutputDataBlockDesc->totalRowSize); + EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pDescNode->totalRowSize); EXPLAIN_ROW_APPEND(EXPLAIN_RIGHT_PARENTHESIS_FORMAT); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + if (EXPLAIN_MODE_ANALYZE == ctx->mode) { + // sort key + EXPLAIN_ROW_NEW(level, "Sort Key: "); + if (pResNode->pExecInfo) { + for (int32_t i = 0; i < LIST_LENGTH(pSortNode->pSortKeys); ++i) { + SOrderByExprNode *ptn = nodesListGetNode(pSortNode->pSortKeys, i); + EXPLAIN_ROW_APPEND("%s ", nodesGetNameFromColumnNode(ptn->pExpr)); + } + } + + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + // sort method + EXPLAIN_ROW_NEW(level, "Sort Method: "); + + int32_t nodeNum = taosArrayGetSize(pResNode->pExecInfo); + SExplainExecInfo *execInfo = taosArrayGet(pResNode->pExecInfo, 0); + SSortExecInfo * pExecInfo = (SSortExecInfo *)execInfo->verboseInfo; + EXPLAIN_ROW_APPEND("%s", pExecInfo->sortMethod == SORT_QSORT_T ? "quicksort" : "merge sort"); + if (pExecInfo->sortBuffer > 1024 * 1024) { + EXPLAIN_ROW_APPEND(" Buffers:%.2f Mb", pExecInfo->sortBuffer / (1024 * 1024.0)); + } else if (pExecInfo->sortBuffer > 1024) { + EXPLAIN_ROW_APPEND(" Buffers:%.2f Kb", pExecInfo->sortBuffer / (1024.0)); + } else { + EXPLAIN_ROW_APPEND(" Buffers:%d b", pExecInfo->sortBuffer); + } + + EXPLAIN_ROW_APPEND(" loops:%d", pExecInfo->loops); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + } + if (verbose) { EXPLAIN_ROW_NEW(level + 1, EXPLAIN_OUTPUT_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_COLUMNS_FORMAT, @@ -792,13 +828,8 @@ int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, i QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); } -// EXPLAIN_ROW_APPEND(EXPLAIN_FUNCTIONS_FORMAT, pPartNode->length); -// EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pPartNode->node.pOutputDataBlockDesc->totalRowSize); -// if (pPartNode->pGroupKeys) { -// EXPLAIN_ROW_APPEND(EXPLAIN_BLANK_FORMAT); -// EXPLAIN_ROW_APPEND(EXPLAIN_GROUPS_FORMAT, pPartNode->pGroupKeys->length); -// } + EXPLAIN_ROW_APPEND(EXPLAIN_RIGHT_PARENTHESIS_FORMAT); EXPLAIN_ROW_END(); QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 8ac320b9aa..2dfbaaa4aa 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -588,18 +588,14 @@ typedef struct SSortedMergeOperatorInfo { typedef struct SSortOperatorInfo { SOptrBasicInfo binfo; - uint32_t sortBufSize; // max buffer size for in-memory sort + uint32_t sortBufSize; // max buffer size for in-memory sort SArray* pSortInfo; SSortHandle* pSortHandle; SArray* pColMatchInfo; // for index map from table scan output int32_t bufPageSize; - // TODO extact struct - int64_t startTs; // sort start time - uint64_t sortElapsed; // sort elapsed time, time to flush to disk not included. - uint64_t totalSize; // total load bytes from remote - uint64_t totalRows; // total number of rows - uint64_t totalElapsed; // total elapsed time + int64_t startTs; // sort start time + uint64_t sortElapsed; // sort elapsed time, time to flush to disk not included. } SSortOperatorInfo; typedef struct STagFilterOperatorInfo { diff --git a/source/libs/executor/inc/tsort.h b/source/libs/executor/inc/tsort.h index d74628a72f..c8b1b3ee51 100644 --- a/source/libs/executor/inc/tsort.h +++ b/source/libs/executor/inc/tsort.h @@ -137,6 +137,14 @@ void* tsortGetValue(STupleHandle* pVHandle, int32_t colId); */ SSDataBlock* tsortGetSortedDataBlock(const SSortHandle* pSortHandle); +/** + * return the sort execution information. + * + * @param pHandle + * @return + */ +SSortExecInfo tsortGetSortExecInfo(SSortHandle* pHandle); + #ifdef __cplusplus } #endif diff --git a/source/libs/executor/src/scanoperator.c b/source/libs/executor/src/scanoperator.c index 2215d0035d..ccd4b7c4cf 100644 --- a/source/libs/executor/src/scanoperator.c +++ b/source/libs/executor/src/scanoperator.c @@ -790,7 +790,7 @@ static SSDataBlock* getDataFromCatch(SStreamBlockScanInfo* pInfo) { SSDataBlock* pDB = createOneDataBlock(pInfo->pRes, false); blockDataFromBuf(pDB, buf); SSDataBlock* pSub = blockDataExtractBlock(pDB, pos->rowId, 1); - blockDataMerge(pInfo->pRes, pSub, NULL); + blockDataMerge(pInfo->pRes, pSub); blockDataDestroy(pDB); blockDataDestroy(pSub); } diff --git a/source/libs/executor/src/sortoperator.c b/source/libs/executor/src/sortoperator.c index 990dc0f200..8f5fa88070 100644 --- a/source/libs/executor/src/sortoperator.c +++ b/source/libs/executor/src/sortoperator.c @@ -2,6 +2,9 @@ #include "executorimpl.h" static SSDataBlock* doSort(SOperatorInfo* pOperator); +static int32_t doOpenSortOperator(SOperatorInfo* pOperator); +static int32_t getExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* len); + static void destroyOrderOperatorInfo(void* param, int32_t numOfOutput); SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSDataBlock* pResBlock, SArray* pSortInfo, SExprInfo* pExprInfo, int32_t numOfCols, @@ -35,7 +38,7 @@ SOperatorInfo* createSortOperatorInfo(SOperatorInfo* downstream, SSDataBlock* pR pOperator->pTaskInfo = pTaskInfo; pOperator->fpSet = - createOperatorFpSet(operatorDummyOpenFn, doSort, NULL, NULL, destroyOrderOperatorInfo, NULL, NULL, NULL); + createOperatorFpSet(doOpenSortOperator, doSort, NULL, NULL, destroyOrderOperatorInfo, NULL, NULL, getExplainExecInfo); int32_t code = appendDownstream(pOperator, &downstream, 1); return pOperator; @@ -121,20 +124,17 @@ void applyScalarFunction(SSDataBlock* pBlock, void* param) { } } -SSDataBlock* doSort(SOperatorInfo* pOperator) { - if (pOperator->status == OP_EXEC_DONE) { - return NULL; - } - - SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; +int32_t doOpenSortOperator(SOperatorInfo* pOperator) { SSortOperatorInfo* pInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; - if (pOperator->status == OP_RES_TO_RETURN) { - return getSortedBlockData(pInfo->pSortHandle, pInfo->binfo.pRes, pOperator->resultInfo.capacity, pInfo->pColMatchInfo); + if (OPTR_IS_OPENED(pOperator)) { + return TSDB_CODE_SUCCESS; } -// pInfo->binfo.pRes is not equalled to the input datablock. -// int32_t numOfBufPage = pInfo->sortBufSize / pInfo->bufPageSize; + pInfo->startTs = taosGetTimestampUs(); + + // pInfo->binfo.pRes is not equalled to the input datablock. pInfo->pSortHandle = tsortCreateSortHandle(pInfo->pSortInfo, pInfo->pColMatchInfo, SORT_SINGLESOURCE_SORT, -1, -1, NULL, pTaskInfo->id.str); @@ -146,12 +146,39 @@ SSDataBlock* doSort(SOperatorInfo* pOperator) { int32_t code = tsortOpen(pInfo->pSortHandle); taosMemoryFreeClear(ps); + if (code != TSDB_CODE_SUCCESS) { longjmp(pTaskInfo->env, terrno); } + pOperator->cost.openCost = (taosGetTimestampUs() - pInfo->startTs)/1000.0; pOperator->status = OP_RES_TO_RETURN; - return getSortedBlockData(pInfo->pSortHandle, pInfo->binfo.pRes, pOperator->resultInfo.capacity, pInfo->pColMatchInfo); + + OPTR_SET_OPENED(pOperator); + return TSDB_CODE_SUCCESS; +} + +SSDataBlock* doSort(SOperatorInfo* pOperator) { + if (pOperator->status == OP_EXEC_DONE) { + return NULL; + } + + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + SSortOperatorInfo* pInfo = pOperator->info; + + int32_t code = pOperator->fpSet._openFn(pOperator); + if (code != TSDB_CODE_SUCCESS) { + longjmp(pTaskInfo->env, code); + } + + SSDataBlock* pBlock = getSortedBlockData(pInfo->pSortHandle, pInfo->binfo.pRes, pOperator->resultInfo.capacity, pInfo->pColMatchInfo); + + if (pBlock != NULL) { + pOperator->resultInfo.totalRows += pBlock->info.rows; + } else { + doSetOperatorCompleted(pOperator); + } + return pBlock; } void destroyOrderOperatorInfo(void* param, int32_t numOfOutput) { @@ -161,3 +188,15 @@ void destroyOrderOperatorInfo(void* param, int32_t numOfOutput) { taosArrayDestroy(pInfo->pSortInfo); taosArrayDestroy(pInfo->pColMatchInfo); } + +int32_t getExplainExecInfo(SOperatorInfo* pOptr, void** pOptrExplain, uint32_t* len) { + ASSERT(pOptr != NULL); + SSortExecInfo* pInfo = taosMemoryCalloc(1, sizeof(SSortExecInfo)); + + SSortOperatorInfo *pOperatorInfo = (SSortOperatorInfo*)pOptr->info; + + *pInfo = tsortGetSortExecInfo(pOperatorInfo->pSortHandle); + *pOptrExplain = pInfo; + *len = sizeof(SSortExecInfo); + return TSDB_CODE_SUCCESS; +} diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index c826cb68bf..7581836d59 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -31,20 +31,16 @@ struct STupleHandle { struct SSortHandle { int32_t type; - int32_t pageSize; int32_t numOfPages; SDiskbasedBuf *pBuf; SArray *pSortInfo; - SArray *pIndexMap; SArray *pOrderedSource; - _sort_fetch_block_fn_t fetchfp; - _sort_merge_compar_fn_t comparFn; - SMultiwayMergeTreeInfo *pMergeTree; - int64_t startTs; + int32_t loops; uint64_t sortElapsed; + int64_t startTs; uint64_t totalElapsed; int32_t sourceId; @@ -53,13 +49,15 @@ struct SSortHandle { int32_t numOfCompletedSources; bool opened; const char *idStr; - bool inMemSort; bool needAdjust; STupleHandle tupleHandle; - void *param; void (*beforeFp)(SSDataBlock* pBlock, void* param); + + _sort_fetch_block_fn_t fetchfp; + _sort_merge_compar_fn_t comparFn; + SMultiwayMergeTreeInfo *pMergeTree; }; static int32_t msortComparFn(const void *pLeft, const void *pRight, void *param); @@ -80,7 +78,7 @@ SSortHandle* tsortCreateSortHandle(SArray* pSortInfo, SArray* pIndexMap, int32_t pSortHandle->pageSize = pageSize; pSortHandle->numOfPages = numOfPages; pSortHandle->pSortInfo = pSortInfo; - pSortHandle->pIndexMap = pIndexMap; + pSortHandle->loops = 0; if (pBlock != NULL) { pSortHandle->pDataBlock = createOneDataBlock(pBlock, false); @@ -415,6 +413,9 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) { int32_t numOfRows = blockDataGetCapacityInRow(pHandle->pDataBlock, pHandle->pageSize); blockDataEnsureCapacity(pHandle->pDataBlock, numOfRows); + // the initial pass + sortPass + final mergePass + pHandle->loops = sortPass + 2; + size_t numOfSorted = taosArrayGetSize(pHandle->pOrderedSource); for(int32_t t = 0; t < sortPass; ++t) { int64_t st = taosGetTimestampUs(); @@ -502,12 +503,13 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) { return 0; } -static int32_t createInitialSortedMultiSources(SSortHandle* pHandle) { +static int32_t createInitialSources(SSortHandle* pHandle) { size_t sortBufSize = pHandle->numOfPages * pHandle->pageSize; if (pHandle->type == SORT_SINGLESOURCE_SORT) { SSortSource* source = taosArrayGetP(pHandle->pOrderedSource, 0); taosArrayClear(pHandle->pOrderedSource); + while (1) { SSDataBlock* pBlock = pHandle->fetchfp(source->param); if (pBlock == NULL) { @@ -524,6 +526,7 @@ static int32_t createInitialSortedMultiSources(SSortHandle* pHandle) { } else { pHandle->pageSize = 4096; } + // todo!! pHandle->numOfPages = 1024; sortBufSize = pHandle->numOfPages * pHandle->pageSize; @@ -535,7 +538,7 @@ static int32_t createInitialSortedMultiSources(SSortHandle* pHandle) { } // todo relocate the columns - int32_t code = blockDataMerge(pHandle->pDataBlock, pBlock, pHandle->pIndexMap); + int32_t code = blockDataMerge(pHandle->pDataBlock, pBlock); if (code != 0) { return code; } @@ -569,6 +572,7 @@ static int32_t createInitialSortedMultiSources(SSortHandle* pHandle) { pHandle->cmpParam.numOfSources = 1; pHandle->inMemSort = true; + pHandle->loops = 1; pHandle->tupleHandle.rowIndex = -1; pHandle->tupleHandle.pBlock = pHandle->pDataBlock; return 0; @@ -592,7 +596,7 @@ int32_t tsortOpen(SSortHandle* pHandle) { pHandle->opened = true; - int32_t code = createInitialSortedMultiSources(pHandle); + int32_t code = createInitialSources(pHandle); if (code != TSDB_CODE_SUCCESS) { return code; } @@ -692,3 +696,20 @@ void* tsortGetValue(STupleHandle* pVHandle, int32_t colIndex) { SColumnInfoData* pColInfo = TARRAY_GET_ELEM(pVHandle->pBlock->pDataBlock, colIndex); return colDataGetData(pColInfo, pVHandle->rowIndex); } + +SSortExecInfo tsortGetSortExecInfo(SSortHandle* pHandle) { + SSortExecInfo info = {0}; + + info.sortBuffer = pHandle->pageSize * pHandle->numOfPages; + info.sortMethod = pHandle->inMemSort? SORT_QSORT_T:SORT_SPILLED_MERGE_SORT_T; + info.loops = pHandle->loops; + + if (pHandle->pBuf != NULL) { + SDiskbasedBufStatis st = getDBufStatis(pHandle->pBuf); + info.writeBytes = st.flushBytes; + info.readBytes = st.loadBytes; + } + + return info; +} + diff --git a/source/util/src/tpagedbuf.c b/source/util/src/tpagedbuf.c index 00f1233707..101ac78e18 100644 --- a/source/util/src/tpagedbuf.c +++ b/source/util/src/tpagedbuf.c @@ -549,11 +549,16 @@ void destroyDiskbasedBuf(SDiskbasedBuf* pBuf) { // print the statistics information { SDiskbasedBufStatis* ps = &pBuf->statis; - uDebug( - "Get/Release pages:%d/%d, flushToDisk:%.2f Kb (%d Pages), loadFromDisk:%.2f Kb (%d Pages), avgPageSize:%.2f " - "Kb\n", - ps->getPages, ps->releasePages, ps->flushBytes / 1024.0f, ps->flushPages, ps->loadBytes / 1024.0f, - ps->loadPages, ps->loadBytes / (1024.0 * ps->loadPages)); + if (ps->loadPages == 0) { + uDebug( + "Get/Release pages:%d/%d, flushToDisk:%.2f Kb (%d Pages), loadFromDisk:%.2f Kb (%d Pages)", + ps->getPages, ps->releasePages, ps->flushBytes / 1024.0f, ps->flushPages, ps->loadBytes / 1024.0f, ps->loadPages); + } else { + uDebug( + "Get/Release pages:%d/%d, flushToDisk:%.2f Kb (%d Pages), loadFromDisk:%.2f Kb (%d Pages), avgPageSize:%.2f Kb", + ps->getPages, ps->releasePages, ps->flushBytes / 1024.0f, ps->flushPages, ps->loadBytes / 1024.0f, + ps->loadPages, ps->loadBytes / (1024.0 * ps->loadPages)); + } } taosRemoveFile(pBuf->path); From d5d0bd2b191279873228f814bcbc2307430dd217 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 25 May 2022 15:36:57 +0800 Subject: [PATCH 23/63] fix(query): add check for invalid tablename. --- source/libs/parser/src/parInsert.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 239bd21abc..8b3ee20545 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -189,6 +189,7 @@ static int32_t createSName(SName* pName, SToken* pTableName, int32_t acctId, con const char* msg1 = "name too long"; const char* msg2 = "invalid database name"; const char* msg3 = "db is not specified"; + const char* msg4 = "invalid table name"; int32_t code = TSDB_CODE_SUCCESS; char* p = strnchr(pTableName->z, TS_PATH_DELIMITER[0], pTableName->n, true); @@ -207,6 +208,10 @@ static int32_t createSName(SName* pName, SToken* pTableName, int32_t acctId, con } int32_t tbLen = pTableName->n - dbLen - 1; + if (tbLen <= 0) { + return buildInvalidOperationMsg(pMsgBuf, msg4); + } + char tbname[TSDB_TABLE_FNAME_LEN] = {0}; strncpy(tbname, p + 1, tbLen); /*tbLen = */ strdequote(tbname); From 55411d07c6d495b5beac7b3d8e935a55392e2c9a Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Wed, 25 May 2022 15:45:13 +0800 Subject: [PATCH 24/63] feat: support delete function --- source/dnode/vnode/src/tsdb/tsdbDelete.c | 61 ++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 source/dnode/vnode/src/tsdb/tsdbDelete.c diff --git a/source/dnode/vnode/src/tsdb/tsdbDelete.c b/source/dnode/vnode/src/tsdb/tsdbDelete.c new file mode 100644 index 0000000000..ef18b8ff66 --- /dev/null +++ b/source/dnode/vnode/src/tsdb/tsdbDelete.c @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "tsdb.h" + +typedef struct STombStoneItem STombStoneItem; +typedef struct STombStones STombStones; + +struct STombStones { + TdThreadRwlock lock; + SHashObj* pTmStones; // key: uid, value: tombstone items sorted by version + T_REF_DECLARE() +}; + +struct STombStoneItem { + int64_t tbUid; // child/normal table + int64_t version; + int64_t gversion; // global unique version assigned by mnode + SArray* tsFilters; +}; + +// SBlock 中除了原有的 keyFirst/keyLast,应该不再需要记录 versionMin 和 versionMax +// 因为在查询时,新到的 query 的 version,一定大于原有写入的数据 version。 + +// mem [ts1:v200, ts1:v201, ts2:v300,ts2:v310,ts2:320, ts5:400,ts5:v500,ts6:v600, ts7:v700, ts8:v800] + +// imem [ts2:80,ts2:v90,ts2:v100] + +// file [blk1: ts1:v10,ts1:v11,ts2:v20,ts2:v21 + [blk2: ts2:v30,ts2:v31,ts2:v35 + [blk3: ts2:v40,ts2:v45,ts2:v50,ts3:v60,ts4:v70 + +// delete [ctb1, ts2-ts5:v315] +// [ctb1, ts5:v450] +// [ctb1, ts6:v550] +// 根据 delete version, 逆序过滤。 + +// sql: select * from ctb1 where ts < ts8 and ts > ts1; // query version = 460; + +int32_t tsdbLoadBlockDataMV(SFileBlockIter *pBlockIter, SMemIter *pMemIter, SDataCols *pTarget, SArray *pTmStoneArray, int64_t queryVersion){ + + // 首先,query executor 根据 查询的 ts 范围,找到最后一条记录的位置。 + // 1) 有可能只在 mem/imem + // 2) 有可能只在 某一个文件 + // 3) 有可能 mem/imem 和 文件中均包含。 + + + +} From d1a4e2d232c35264621503b9905be1f19ebd7469 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 25 May 2022 08:03:05 +0000 Subject: [PATCH 25/63] feat: drop stable --- source/dnode/vnode/src/meta/metaTable.c | 154 ++++++++---------------- 1 file changed, 48 insertions(+), 106 deletions(-) diff --git a/source/dnode/vnode/src/meta/metaTable.c b/source/dnode/vnode/src/meta/metaTable.c index 208d6f9fca..462d461a8a 100644 --- a/source/dnode/vnode/src/meta/metaTable.c +++ b/source/dnode/vnode/src/meta/metaTable.c @@ -23,6 +23,7 @@ static int metaUpdateTtlIdx(SMeta *pMeta, const SMetaEntry *pME); static int metaSaveToSkmDb(SMeta *pMeta, const SMetaEntry *pME); static int metaUpdateCtbIdx(SMeta *pMeta, const SMetaEntry *pME); static int metaUpdateTagIdx(SMeta *pMeta, const SMetaEntry *pCtbEntry); +static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type); int metaCreateSTable(SMeta *pMeta, int64_t version, SVCreateStbReq *pReq) { SMetaEntry me = {0}; @@ -116,7 +117,7 @@ int metaDropSTable(SMeta *pMeta, int64_t verison, SVDropStbReq *pReq) { for (int32_t iChild = 0; iChild < taosArrayGetSize(pArray); iChild++) { tb_uid_t uid = *(tb_uid_t *)taosArrayGet(pArray, iChild); - metaDropTableByUid(pMeta, uid); + metaDropTableByUid(pMeta, uid, NULL); } taosArrayDestroy(pArray); @@ -263,122 +264,63 @@ _err: } int metaDropTable(SMeta *pMeta, int64_t version, SVDropTbReq *pReq, SArray *tbUids) { - TBC *pTbDbc = NULL; - TBC *pUidIdxc = NULL; - TBC *pNameIdxc = NULL; - const void *pData; - int nData; - tb_uid_t uid; - int64_t tver; - SMetaEntry me = {0}; - SDecoder coder = {0}; - int8_t type; - int64_t ctime; - tb_uid_t suid; - int c = 0, ret; + void *pData = NULL; + int nData = 0; + int rc = 0; + tb_uid_t uid; + int type; - // search & delete the name idx - tdbTbcOpen(pMeta->pNameIdx, &pNameIdxc, &pMeta->txn); - ret = tdbTbcMoveTo(pNameIdxc, pReq->name, strlen(pReq->name) + 1, &c); - if (ret < 0 || !tdbTbcIsValid(pNameIdxc) || c) { - tdbTbcClose(pNameIdxc); + rc = tdbTbGet(pMeta->pNameIdx, pReq->name, strlen(pReq->name) + 1, &pData, &nData); + if (rc < 0) { terrno = TSDB_CODE_VND_TABLE_NOT_EXIST; return -1; } - - ret = tdbTbcGet(pNameIdxc, NULL, NULL, &pData, &nData); - if (ret < 0) { - ASSERT(0); - return -1; - } - uid = *(tb_uid_t *)pData; - tdbTbcDelete(pNameIdxc); - tdbTbcClose(pNameIdxc); + metaWLock(pMeta); + metaDropTableByUid(pMeta, uid, &type); + metaULock(pMeta); - // search & delete uid idx - tdbTbcOpen(pMeta->pUidIdx, &pUidIdxc, &pMeta->txn); - ret = tdbTbcMoveTo(pUidIdxc, &uid, sizeof(uid), &c); - if (ret < 0 || c != 0) { - ASSERT(0); - return -1; + if (type == TSDB_CHILD_TABLE && tbUids) { + taosArrayPush(tbUids, &uid); } - ret = tdbTbcGet(pUidIdxc, NULL, NULL, &pData, &nData); - if (ret < 0) { - ASSERT(0); - return -1; + tdbFree(pData); + return 0; +} + +static int metaDropTableByUid(SMeta *pMeta, tb_uid_t uid, int *type) { + void *pData = NULL; + int nData = 0; + int rc = 0; + int64_t version; + SMetaEntry e = {0}; + SDecoder dc = {0}; + + rc = tdbTbGet(pMeta->pUidIdx, &uid, sizeof(uid), &pData, &nData); + version = *(int64_t *)pData; + + tdbTbGet(pMeta->pTbDb, &(STbDbKey){.version = version, .uid = uid}, sizeof(STbDbKey), &pData, &nData); + + tDecoderInit(&dc, pData, nData); + metaDecodeEntry(&dc, &e); + + if (type) *type = e.type; + + tdbTbDelete(pMeta->pTbDb, &(STbDbKey){.version = version, .uid = uid}, sizeof(STbDbKey), &pMeta->txn); + tdbTbDelete(pMeta->pNameIdx, e.name, strlen(e.name) + 1, &pMeta->txn); + tdbTbDelete(pMeta->pUidIdx, &uid, sizeof(uid), &pMeta->txn); + if (e.type == TSDB_CHILD_TABLE) { + tdbTbDelete(pMeta->pCtbIdx, &(SCtbIdxKey){.suid = e.ctbEntry.suid, .uid = uid}, sizeof(SCtbIdxKey), &pMeta->txn); + } else if (e.type == TSDB_NORMAL_TABLE) { + // drop schema.db (todo) + // drop ttl.idx (todo) + } else if (e.type == TSDB_SUPER_TABLE) { + // drop schema.db (todo) } - tver = *(int64_t *)pData; - tdbTbcDelete(pUidIdxc); - tdbTbcClose(pUidIdxc); - - // search and get meta entry - tdbTbcOpen(pMeta->pTbDb, &pTbDbc, &pMeta->txn); - ret = tdbTbcMoveTo(pTbDbc, &(STbDbKey){.uid = uid, .version = tver}, sizeof(STbDbKey), &c); - if (ret < 0 || c != 0) { - ASSERT(0); - return -1; - } - - ret = tdbTbcGet(pTbDbc, NULL, NULL, &pData, &nData); - if (ret < 0) { - ASSERT(0); - return -1; - } - - // decode entry - void *pDataCopy = taosMemoryMalloc(nData); // remove the copy (todo) - memcpy(pDataCopy, pData, nData); - tDecoderInit(&coder, pDataCopy, nData); - ret = metaDecodeEntry(&coder, &me); - if (ret < 0) { - ASSERT(0); - return -1; - } - - type = me.type; - if (type == TSDB_CHILD_TABLE) { - ctime = me.ctbEntry.ctime; - suid = me.ctbEntry.suid; - taosArrayPush(tbUids, &me.uid); - } else if (type == TSDB_NORMAL_TABLE) { - ctime = me.ntbEntry.ctime; - suid = 0; - } else { - ASSERT(0); - } - - taosMemoryFree(pDataCopy); - tDecoderClear(&coder); - tdbTbcClose(pTbDbc); - - if (type == TSDB_CHILD_TABLE) { - // remove the pCtbIdx - TBC *pCtbIdxc = NULL; - tdbTbcOpen(pMeta->pCtbIdx, &pCtbIdxc, &pMeta->txn); - - ret = tdbTbcMoveTo(pCtbIdxc, &(SCtbIdxKey){.suid = suid, .uid = uid}, sizeof(SCtbIdxKey), &c); - if (ret < 0 || c != 0) { - ASSERT(0); - return -1; - } - - tdbTbcDelete(pCtbIdxc); - tdbTbcClose(pCtbIdxc); - - // remove tags from pTagIdx (todo) - } else if (type == TSDB_NORMAL_TABLE) { - // remove from pSkmDb - } else { - ASSERT(0); - } - - // remove from ttl (todo) - if (ctime > 0) { - } + tDecoderClear(&dc); + tdbFree(pData); return 0; } From 3a0efe72550981de3e48a5a27af71fd01e217a9c Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Wed, 25 May 2022 16:30:26 +0800 Subject: [PATCH 26/63] fix(os): run case on win --- source/client/src/clientHb.c | 5 + source/libs/catalog/src/ctgCache.c | 5 +- source/os/src/osDir.c | 5 +- source/os/src/osFile.c | 1 - source/os/src/osSemaphore.c | 9 +- source/util/src/tlog.c | 2 +- tests/pytest/fulltest.bat | 2 + tests/pytest/test-all.bat | 25 +++++ tests/pytest/test.py | 160 ++++++++++++++++++----------- tests/pytest/util/cases.py | 10 +- tests/pytest/util/dnodes.py | 109 +++++++++++++++++--- 11 files changed, 248 insertions(+), 85 deletions(-) create mode 100644 tests/pytest/fulltest.bat create mode 100644 tests/pytest/test-all.bat diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index 1ae6fa405f..eca9102bf0 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -582,8 +582,13 @@ void hbClearReqInfo(SAppHbMgr *pAppHbMgr) { } } +void hbThreadFuncUnexpectedStopped(void) { + atomic_store_8(&clientHbMgr.threadStop, 2); +} + static void *hbThreadFunc(void *param) { setThreadName("hb"); + atexit(hbThreadFuncUnexpectedStopped); while (1) { int8_t threadStop = atomic_val_compare_exchange_8(&clientHbMgr.threadStop, 1, 2); if (1 == threadStop) { diff --git a/source/libs/catalog/src/ctgCache.c b/source/libs/catalog/src/ctgCache.c index 6335a056b9..425a0bf926 100644 --- a/source/libs/catalog/src/ctgCache.c +++ b/source/libs/catalog/src/ctgCache.c @@ -1457,10 +1457,13 @@ _return: CTG_RET(code); } +void ctgUpdateThreadFuncUnexpectedStopped(void) { + CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock); +} void* ctgUpdateThreadFunc(void* param) { setThreadName("catalog"); - + atexit(ctgUpdateThreadFuncUnexpectedStopped); qInfo("catalog update thread started"); CTG_LOCK(CTG_READ, &gCtgMgmt.lock); diff --git a/source/os/src/osDir.c b/source/os/src/osDir.c index c4b7c9386e..75797048ca 100644 --- a/source/os/src/osDir.c +++ b/source/os/src/osDir.c @@ -107,13 +107,14 @@ int32_t taosMkDir(const char *dirname) { int32_t taosMulMkDir(const char *dirname) { if (dirname == NULL) return -1; char temp[1024]; + char * pos = temp; + int32_t code = 0; #ifdef WINDOWS taosRealPath(dirname, temp, sizeof(temp)); + if (temp[1] == ':') pos += 3; #else strcpy(temp, dirname); #endif - char * pos = temp; - int32_t code = 0; if (taosDirExist(temp)) return code; diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c index e08b668163..c75cca79f6 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -69,7 +69,6 @@ void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, cha } strcpy(tmpPath + len, tdengineTmpFileNamePrefix); - strcat(tmpPath, tdengineTmpFileNamePrefix); if (strlen(tmpPath) + strlen(fileNamePrefix) + strlen("-%d-%s") < PATH_MAX) { strcat(tmpPath, fileNamePrefix); strcat(tmpPath, "-%d-%s"); diff --git a/source/os/src/osSemaphore.c b/source/os/src/osSemaphore.c index d4cfe4fc39..3b68073c7e 100644 --- a/source/os/src/osSemaphore.c +++ b/source/os/src/osSemaphore.c @@ -50,10 +50,15 @@ int32_t taosGetAppName(char* name, int32_t* len) { if (sub != NULL) { *sub = '\0'; } - strcpy(name, filepath); + char* end = strrchr(filepath, TD_DIRSEP[0]); + if (end == NULL) { + end = filepath; + } + + strcpy(name, end); if (len != NULL) { - *len = (int32_t)strlen(filepath); + *len = (int32_t)strlen(end); } return 0; diff --git a/source/util/src/tlog.c b/source/util/src/tlog.c index c1fc2c48c0..e8a1ceb18b 100644 --- a/source/util/src/tlog.c +++ b/source/util/src/tlog.c @@ -226,7 +226,7 @@ static void *taosThreadToOpenNewFile(void *param) { tsLogObj.logHandle->pFile = pFile; tsLogObj.lines = 0; tsLogObj.openInProgress = 0; - taosSsleep(10); + taosSsleep(20); taosCloseLogByFd(pOldFile); uInfo(" new log file:%d is opened", tsLogObj.flag); diff --git a/tests/pytest/fulltest.bat b/tests/pytest/fulltest.bat new file mode 100644 index 0000000000..5758691c88 --- /dev/null +++ b/tests/pytest/fulltest.bat @@ -0,0 +1,2 @@ + +python .\test.py -f insert\basic.py \ No newline at end of file diff --git a/tests/pytest/test-all.bat b/tests/pytest/test-all.bat new file mode 100644 index 0000000000..437472f7b8 --- /dev/null +++ b/tests/pytest/test-all.bat @@ -0,0 +1,25 @@ +@echo off +SETLOCAL EnableDelayedExpansion +for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do ( set "DEL=%%a") +set /a a=0 +@REM echo Windows Taosd Test +@REM for /F "usebackq tokens=*" %%i in (fulltest.bat) do ( +@REM echo Processing %%i +@REM set /a a+=1 +@REM call %%i ARG1 -w -m localhost > result_!a!.txt 2>error_!a!.txt +@REM if errorlevel 1 ( call :colorEcho 0c "failed" &echo. && exit 8 ) else ( call :colorEcho 0a "Success" &echo. ) +@REM ) +echo Linux Taosd Test +for /F "usebackq tokens=*" %%i in (fulltest.bat) do ( + echo Processing %%i + set /a a+=1 + call %%i ARG1 -w 1 -m %1 > result_!a!.txt 2>error_!a!.txt + if errorlevel 1 ( call :colorEcho 0c "failed" &echo. && exit 8 ) else ( call :colorEcho 0a "Success" &echo. ) +) +exit + +:colorEcho +echo off + "%~2" +findstr /v /a:%1 /R "^$" "%~2" nul +del "%~2" > nul 2>&1i \ No newline at end of file diff --git a/tests/pytest/test.py b/tests/pytest/test.py index 97dca6be18..5c9dae688f 100644 --- a/tests/pytest/test.py +++ b/tests/pytest/test.py @@ -35,8 +35,9 @@ if __name__ == "__main__": logSql = True stop = 0 restart = False - opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghr', [ - 'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help']) + windows = 0 + opts, args = getopt.gnu_getopt(sys.argv[1:], 'f:p:m:l:scghrw', [ + 'file=', 'path=', 'master', 'logSql', 'stop', 'cluster', 'valgrind', 'help', 'windows']) for key, value in opts: if key in ['-h', '--help']: tdLog.printNoPrefix( @@ -61,7 +62,10 @@ if __name__ == "__main__": deployPath = value if key in ['-m', '--master']: - masterIp = value + masterIp = value + + if key in ['-w', '--windows']: + windows = 1 if key in ['-l', '--logSql']: if (value.upper() == "TRUE"): @@ -110,67 +114,107 @@ if __name__ == "__main__": time.sleep(2) tdLog.info('stop All dnodes') - - tdDnodes.init(deployPath) - tdDnodes.setTestCluster(testCluster) - tdDnodes.setValgrind(valgrind) - tdDnodes.stopAll() - is_test_framework = 0 - key_word = 'tdCases.addLinux' - try: - if key_word in open(fileName).read(): - is_test_framework = 1 - except: - pass - if is_test_framework: - moduleName = fileName.replace(".py", "").replace("/", ".") - uModule = importlib.import_module(moduleName) - try: - ucase = uModule.TDTestCase() - tdDnodes.deploy(1,ucase.updatecfgDict) - except : - tdDnodes.deploy(1,{}) - else: - tdDnodes.deploy(1,{}) - tdDnodes.start(1) if masterIp == "": host = '127.0.0.1' else: host = masterIp - tdLog.info("Procedures for tdengine deployed in %s" % (host)) - - tdCases.logSql(logSql) - - if testCluster: - tdLog.info("Procedures for testing cluster") - if fileName == "all": - tdCases.runAllCluster() - else: - tdCases.runOneCluster(fileName) - else: + if (windows): + tdCases.logSql(logSql) tdLog.info("Procedures for testing self-deployment") - conn = taos.connect( - host, - config=tdDnodes.getSimCfgPath()) - if fileName == "all": - tdCases.runAllLinux(conn) - else: - tdCases.runOneLinux(conn, fileName) - if restart: - if fileName == "all": - tdLog.info("not need to query ") - else: - sp = fileName.rsplit(".", 1) - if len(sp) == 2 and sp[1] == "py": - tdDnodes.stopAll() - tdDnodes.start(1) - time.sleep(1) - conn = taos.connect( host, config=tdDnodes.getSimCfgPath()) - tdLog.info("Procedures for tdengine deployed in %s" % (host)) - tdLog.info("query test after taosd restart") - tdCases.runOneLinux(conn, sp[0] + "_" + "restart.py") + if masterIp == "" or masterIp == "localhost": + tdDnodes.init(deployPath) + tdDnodes.setTestCluster(testCluster) + tdDnodes.setValgrind(valgrind) + tdDnodes.stopAll() + is_test_framework = 0 + key_word = 'tdCases.addWindows' + try: + if key_word in open(fileName).read(): + is_test_framework = 1 + except: + pass + if is_test_framework: + moduleName = fileName.replace(".py", "").replace(os.sep, ".") + uModule = importlib.import_module(moduleName) + try: + ucase = uModule.TDTestCase() + tdDnodes.deploy(1,ucase.updatecfgDict) + except : + tdDnodes.deploy(1,{}) else: - tdLog.info("not need to query") + pass + tdDnodes.deploy(1,{}) + tdDnodes.startWin(1) + else: + remote_conn = Connection("root@%s"%host) + with remote_conn.cd('/var/lib/jenkins/workspace/TDinternal/community/tests/pytest'): + remote_conn.run("python3 ./test.py") + tdDnodes.init(deployPath) + conn = taos.connect( + host="%s" % (host), + config=tdDnodes.sim.getCfgDir()) + print(host) + print(tdDnodes.sim.getCfgDir()) + tdCases.runOneWindows(conn, fileName) + tdCases.logSql(logSql) + else: + tdDnodes.init(deployPath) + tdDnodes.setTestCluster(testCluster) + tdDnodes.setValgrind(valgrind) + tdDnodes.stopAll() + is_test_framework = 0 + key_word = 'tdCases.addLinux' + try: + if key_word in open(fileName).read(): + is_test_framework = 1 + except: + pass + if is_test_framework: + moduleName = fileName.replace(".py", "").replace("/", ".") + uModule = importlib.import_module(moduleName) + try: + ucase = uModule.TDTestCase() + tdDnodes.deploy(1,ucase.updatecfgDict) + except : + tdDnodes.deploy(1,{}) + else: + tdDnodes.deploy(1,{}) + tdDnodes.start(1) + + tdLog.info("Procedures for tdengine deployed in %s" % (host)) + + tdCases.logSql(logSql) + + if testCluster: + tdLog.info("Procedures for testing cluster") + if fileName == "all": + tdCases.runAllCluster() + else: + tdCases.runOneCluster(fileName) + else: + tdLog.info("Procedures for testing self-deployment") + conn = taos.connect( + host, + config=tdDnodes.getSimCfgPath()) + if fileName == "all": + tdCases.runAllLinux(conn) + else: + tdCases.runOneLinux(conn, fileName) + if restart: + if fileName == "all": + tdLog.info("not need to query ") + else: + sp = fileName.rsplit(".", 1) + if len(sp) == 2 and sp[1] == "py": + tdDnodes.stopAll() + tdDnodes.start(1) + time.sleep(1) + conn = taos.connect( host, config=tdDnodes.getSimCfgPath()) + tdLog.info("Procedures for tdengine deployed in %s" % (host)) + tdLog.info("query test after taosd restart") + tdCases.runOneLinux(conn, sp[0] + "_" + "restart.py") + else: + tdLog.info("not need to query") conn.close() diff --git a/tests/pytest/util/cases.py b/tests/pytest/util/cases.py index 2fc1ac8515..2bfd8efdcd 100644 --- a/tests/pytest/util/cases.py +++ b/tests/pytest/util/cases.py @@ -34,7 +34,7 @@ class TDCases: self.clusterCases = [] def __dynamicLoadModule(self, fileName): - moduleName = fileName.replace(".py", "").replace("/", ".") + moduleName = fileName.replace(".py", "").replace(os.sep, ".") return importlib.import_module(moduleName, package='..') def logSql(self, logSql): @@ -101,8 +101,12 @@ class TDCases: for tmp in self.windowsCases: if tmp.name.find(fileName) != -1: case = testModule.TDTestCase() - case.init(conn) - case.run() + case.init(conn, self._logSql) + try: + case.run() + except Exception as e: + tdLog.notice(repr(e)) + tdLog.exit("%s failed" % (fileName)) case.stop() runNum += 1 continue diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index 9190943dfd..cc02703c4f 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -67,17 +67,19 @@ class TDSimClient: if os.system(cmd) != 0: tdLog.exit(cmd) - cmd = "mkdir -p " + self.logDir - if os.system(cmd) != 0: - tdLog.exit(cmd) + # cmd = "mkdir -p " + self.logDir + # if os.system(cmd) != 0: + # tdLog.exit(cmd) + os.makedirs(self.logDir) cmd = "rm -rf " + self.cfgDir if os.system(cmd) != 0: tdLog.exit(cmd) - cmd = "mkdir -p " + self.cfgDir - if os.system(cmd) != 0: - tdLog.exit(cmd) + # cmd = "mkdir -p " + self.cfgDir + # if os.system(cmd) != 0: + # tdLog.exit(cmd) + os.makedirs(self.cfgDir) cmd = "touch " + self.cfgPath if os.system(cmd) != 0: @@ -179,17 +181,20 @@ class TDDnode: if os.system(cmd) != 0: tdLog.exit(cmd) - cmd = "mkdir -p " + self.dataDir - if os.system(cmd) != 0: - tdLog.exit(cmd) + # cmd = "mkdir -p " + self.dataDir + # if os.system(cmd) != 0: + # tdLog.exit(cmd) + os.makedirs(self.dataDir) - cmd = "mkdir -p " + self.logDir - if os.system(cmd) != 0: - tdLog.exit(cmd) + # cmd = "mkdir -p " + self.logDir + # if os.system(cmd) != 0: + # tdLog.exit(cmd) + os.makedirs(self.logDir) - cmd = "mkdir -p " + self.cfgDir - if os.system(cmd) != 0: - tdLog.exit(cmd) + # cmd = "mkdir -p " + self.cfgDir + # if os.system(cmd) != 0: + # tdLog.exit(cmd) + os.makedirs(self.cfgDir) cmd = "touch " + self.cfgPath if os.system(cmd) != 0: @@ -247,6 +252,8 @@ class TDDnode: if ("packaging" not in rootRealPath): paths.append(os.path.join(root, tool)) break + if (len(paths) == 0): + return "" return paths[0] def start(self): @@ -309,6 +316,69 @@ class TDDnode: time.sleep(10) # time.sleep(5) + def startWin(self): + binPath = self.getPath("taosd.exe") + + if (binPath == ""): + tdLog.exit("taosd.exe not found!") + else: + tdLog.info("taosd.exe found: %s" % binPath) + + taosadapterBinPath = self.getPath("taosadapter.exe") + if (taosadapterBinPath == ""): + tdLog.info("taosAdapter.exe not found!") + else: + tdLog.info("taosAdapter.exe found in %s" % taosadapterBuildPath) + + if self.deployed == 0: + tdLog.exit("dnode:%d is not deployed" % (self.index)) + + cmd = "mintty -h never %s -c %s" % ( + binPath, self.cfgDir) + + if (taosadapterBinPath != ""): + taosadapterCmd = "mintty -h never -w hide %s --monitor.writeToTD=false " % ( + taosadapterBinPath) + if os.system(taosadapterCmd) != 0: + tdLog.exit(taosadapterCmd) + + if os.system(cmd) != 0: + tdLog.exit(cmd) + + self.running = 1 + tdLog.debug("dnode:%d is running with %s " % (self.index, cmd)) + if self.valgrind == 0: + time.sleep(0.1) + key = 'from offline to online' + bkey = bytes(key, encoding="utf8") + logFile = self.logDir + "/taosdlog.0" + i = 0 + while not os.path.exists(logFile): + sleep(0.1) + i += 1 + if i > 50: + break + popen = subprocess.Popen( + 'tail -n +0 -f ' + logFile, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + shell=True) + pid = popen.pid + # print('Popen.pid:' + str(pid)) + timeout = time.time() + 60 * 2 + while True: + line = popen.stdout.readline().strip() + if bkey in line: + popen.kill() + break + if time.time() > timeout: + tdLog.exit('wait too long for taosd start') + tdLog.debug("the dnode:%d has been started." % (self.index)) + else: + tdLog.debug( + "wait 10 seconds for the dnode:%d to start." % + (self.index)) + time.sleep(10) def startWithoutSleep(self): binPath = self.getPath() @@ -448,7 +518,8 @@ class TDDnodes: processID = subprocess.check_output( psCmd, shell=True).decode("utf-8") - binPath = self.dnodes[0].getPath() + "/../../../" + binPath = os.path.dirname(os.path.realpath(__file__)) + binPath = binPath + "/../../../debug/" tdLog.debug("binPath %s" % (binPath)) binPath = os.path.realpath(binPath) tdLog.debug("binPath real path %s" % (binPath)) @@ -475,7 +546,7 @@ class TDDnodes: for i in range(len(self.dnodes)): self.dnodes[i].init(self.path) - + print(self.path) self.sim = TDSimClient(self.path) def setTestCluster(self, value): @@ -504,6 +575,10 @@ class TDDnodes: self.check(index) self.dnodes[index - 1].start() + def startWin(self, index): + self.check(index) + self.dnodes[index - 1].startWin() + def startWithoutSleep(self, index): self.check(index) self.dnodes[index - 1].startWithoutSleep() From b0b533e002a61607484b0bde6ae6b593d03c2d96 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 25 May 2022 16:42:29 +0800 Subject: [PATCH 27/63] fix query ctx crash --- source/libs/transport/src/transComm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index 53f86ba0e9..1ea03083b2 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -245,6 +245,7 @@ void transCtxMerge(STransCtx* dst, STransCtx* src) { if (dst->args == NULL) { dst->args = src->args; dst->brokenVal = src->brokenVal; + dst->freeFunc = src->freeFunc; src->args = NULL; return; } From 8011ea777ff6eac86cbaf080ea5d841298da7937 Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Wed, 25 May 2022 09:16:16 +0000 Subject: [PATCH 28/63] make compile --- source/dnode/vnode/src/tsdb/tsdbSnapshot.c | 1 + 1 file changed, 1 insertion(+) diff --git a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c index f40cab600f..79989a5560 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSnapshot.c +++ b/source/dnode/vnode/src/tsdb/tsdbSnapshot.c @@ -16,6 +16,7 @@ #include "tsdb.h" struct STsdbSnapshotReader { + STsdb* pTsdb; // TODO }; From a9c54ae70155a6fc3ac5e7b1bc9ee7a1e4c63b45 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Wed, 25 May 2022 15:54:49 +0800 Subject: [PATCH 29/63] enh(tmq): support restart --- source/dnode/vnode/src/tq/tq.c | 123 ++++++++++++++++++++------------- 1 file changed, 75 insertions(+), 48 deletions(-) diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index 979db9169e..0e8835357a 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -51,6 +51,47 @@ int tqExecKeyCompare(const void* pKey1, int32_t kLen1, const void* pKey2, int32_ return strcmp(pKey1, pKey2); } +int32_t tqStoreExec(STQ* pTq, const char* key, const STqExec* pExec) { + int32_t code; + int32_t vlen; + tEncodeSize(tEncodeSTqExec, pExec, vlen, code); + ASSERT(code == 0); + + void* buf = taosMemoryCalloc(1, vlen); + if (buf == NULL) { + ASSERT(0); + } + + SEncoder encoder; + tEncoderInit(&encoder, buf, vlen); + + if (tEncodeSTqExec(&encoder, pExec) < 0) { + ASSERT(0); + } + + TXN txn; + + if (tdbTxnOpen(&txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) { + ASSERT(0); + } + + if (tdbBegin(pTq->pMetaStore, &txn) < 0) { + ASSERT(0); + } + + if (tdbTbUpsert(pTq->pExecStore, key, (int)strlen(key), buf, vlen, &txn) < 0) { + ASSERT(0); + } + + if (tdbCommit(pTq->pMetaStore, &txn) < 0) { + ASSERT(0); + } + + tEncoderClear(&encoder); + taosMemoryFree(buf); + return 0; +} + STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal) { STQ* pTq = taosMemoryMalloc(sizeof(STQ)); if (pTq == NULL) { @@ -96,8 +137,31 @@ STQ* tqOpen(const char* path, SVnode* pVnode, SWal* pWal) { int vLen; tdbTbcMoveToFirst(pCur); + SDecoder decoder; while (tdbTbcNext(pCur, &pKey, &kLen, &pVal, &vLen) == 0) { - // create, put into execsj + STqExec exec; + tDecoderInit(&decoder, (uint8_t*)pVal, vLen); + tDecodeSTqExec(&decoder, &exec); + exec.pWalReader = walOpenReadHandle(pTq->pVnode->pWal); + if (exec.subType == TOPIC_SUB_TYPE__TABLE) { + for (int32_t i = 0; i < 5; i++) { + exec.pExecReader[i] = tqInitSubmitMsgScanner(pTq->pVnode->pMeta); + + SReadHandle handle = { + .reader = exec.pExecReader[i], + .meta = pTq->pVnode->pMeta, + .pMsgCb = &pTq->pVnode->msgCb, + }; + exec.task[i] = qCreateStreamExecTaskInfo(exec.qmsg, &handle); + ASSERT(exec.task[i]); + } + } else { + for (int32_t i = 0; i < 5; i++) { + exec.pExecReader[i] = tqInitSubmitMsgScanner(pTq->pVnode->pMeta); + } + exec.pDropTbUid = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK); + } + taosHashPut(pTq->execs, pKey, kLen, &exec, sizeof(STqExec)); } if (tdbTxnClose(&txn) < 0) { @@ -604,7 +668,9 @@ int32_t tqProcessVgDeleteReq(STQ* pTq, char* msg, int32_t msgLen) { ASSERT(0); } - tdbTbDelete(pTq->pExecStore, pReq->subKey, (int)strlen(pReq->subKey), &txn); + if (tdbTbDelete(pTq->pExecStore, pReq->subKey, (int)strlen(pReq->subKey), &txn) < 0) { + /*ASSERT(0);*/ + } if (tdbCommit(pTq->pMetaStore, &txn) < 0) { ASSERT(0); @@ -659,60 +725,21 @@ int32_t tqProcessVgChangeReq(STQ* pTq, char* msg, int32_t msgLen) { } taosHashPut(pTq->execs, req.subKey, strlen(req.subKey), pExec, sizeof(STqExec)); - int32_t code; - int32_t vlen; - tEncodeSize(tEncodeSTqExec, pExec, vlen, code); - ASSERT(code == 0); - - void* buf = taosMemoryCalloc(1, vlen); - if (buf == NULL) { - ASSERT(0); + if (tqStoreExec(pTq, req.subKey, pExec) < 0) { + // TODO } - - SEncoder encoder; - tEncoderInit(&encoder, buf, vlen); - - if (tEncodeSTqExec(&encoder, pExec) < 0) { - ASSERT(0); - } - - TXN txn; - - if (tdbTxnOpen(&txn, 0, tdbDefaultMalloc, tdbDefaultFree, NULL, TDB_TXN_WRITE | TDB_TXN_READ_UNCOMMITTED) < 0) { - ASSERT(0); - } - - if (tdbBegin(pTq->pMetaStore, &txn) < 0) { - ASSERT(0); - } - - if (tdbTbUpsert(pTq->pExecStore, req.subKey, (int)strlen(req.subKey), buf, vlen, &txn) < 0) { - ASSERT(0); - } - - if (tdbCommit(pTq->pMetaStore, &txn) < 0) { - ASSERT(0); - } - - tEncoderClear(&encoder); - taosMemoryFree(buf); - return 0; } else { - /*if (req.newConsumerId != -1) {*/ - /*taosWLockLatch(&pExec->lock);*/ - ASSERT(pExec->consumerId == req.oldConsumerId); + /*ASSERT(pExec->consumerId == req.oldConsumerId);*/ // TODO handle qmsg and exec modification atomic_store_32(&pExec->epoch, -1); atomic_store_64(&pExec->consumerId, req.newConsumerId); atomic_add_fetch_32(&pExec->epoch, 1); - /*taosWUnLockLatch(&pExec->lock);*/ + + if (tqStoreExec(pTq, req.subKey, pExec) < 0) { + // TODO + } return 0; - /*} else {*/ - // TODO - /*taosHashRemove(pTq->tqMetaNew, req.subKey, strlen(req.subKey));*/ - /*return 0;*/ - /*}*/ } } From 356c9e90569dbc395bc53f8787f60906b19bad94 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Wed, 25 May 2022 17:55:34 +0800 Subject: [PATCH 30/63] fix(query): set correct expression number in project operator. --- source/libs/executor/src/executorimpl.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index e16b60e58b..232333ffb7 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -1748,8 +1748,7 @@ void setFunctionResultOutput(SOptrBasicInfo* pInfo, SAggSupporter* pSup, int32_t SResultRow* pRow = doSetResultOutBufByKey(pSup->pResultBuf, pResultRowInfo, (char*)&tid, sizeof(tid), true, groupId, pTaskInfo, false, pSup); - ASSERT(pDataBlock->info.numOfCols == numOfExprs); - for (int32_t i = 0; i < pDataBlock->info.numOfCols; ++i) { + for (int32_t i = 0; i < numOfExprs; ++i) { struct SResultRowEntryInfo* pEntry = getResultCell(pRow, i, rowCellInfoOffset); cleanupResultRowEntry(pEntry); @@ -1757,7 +1756,7 @@ void setFunctionResultOutput(SOptrBasicInfo* pInfo, SAggSupporter* pSup, int32_t pCtx[i].scanFlag = stage; } - initCtxOutputBuffer(pCtx, pDataBlock->info.numOfCols); + initCtxOutputBuffer(pCtx, numOfExprs); } void updateOutputBuf(SOptrBasicInfo* pBInfo, int32_t* bufCapacity, int32_t numOfInputRows) { From 84cf8ff273bd9ab74b3ec8711c0e163648342b98 Mon Sep 17 00:00:00 2001 From: jiajingbin Date: Wed, 25 May 2022 18:00:58 +0800 Subject: [PATCH 31/63] test: add debug cases --- tests/pytest/stream/test1.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 tests/pytest/stream/test1.py diff --git a/tests/pytest/stream/test1.py b/tests/pytest/stream/test1.py new file mode 100644 index 0000000000..d3439a7bdb --- /dev/null +++ b/tests/pytest/stream/test1.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- + +import sys +from util.log import * +from util.cases import * +from util.sql import * +class TDTestCase: + def init(self, conn, logSql): + tdLog.debug("start to execute %s" % __file__) + tdSql.init(conn.cursor(), logSql) + + def run(self): + tdSql.prepare() + tdSql.execute('drop database if exists slmfvojuxt;') + tdSql.execute('create database if not exists slmfvojuxt vgroups 1;') + tdSql.execute('use slmfvojuxt;') + tdSql.execute('create table if not exists downsampling_stb (ts timestamp, c1 int, c2 double, c3 varchar(100), c4 bool) tags (t1 int, t2 double, t3 varchar(100), t4 bool);') + tdSql.execute('create table ownsampling_ct1 using downsampling_stb tags(10, 10.1, "beijing", True);') + tdSql.execute('create table if not exists scalar_stb (ts timestamp, c1 int, c2 double, c3 binary(20)) tags (t1 int);') + tdSql.execute('create table scalar_ct1 using scalar_stb tags(10);') + tdSql.execute('create stream downsampling_stream into output_downsampling_stb as select _wstartts AS start, min(c1), max(c2), sum(c1) from downsampling_stb interval(10m);') + tdSql.execute('create stream scalar_stream into output_scalar_stb as select ts, abs(c1) a1 , abs(c2) a2 from scalar_stb;') + tdSql.execute('insert into scalar_ct1 values (1653471881952, 100, 100.1, "beijing");') + tdSql.execute('insert into scalar_ct1 values (1653471881952+1s, -50, -50.1, "tianjin");') + def stop(self): + tdSql.close() + tdLog.success("%s successfully executed" % __file__) + + +tdCases.addWindows(__file__, TDTestCase()) +tdCases.addLinux(__file__, TDTestCase()) From 21bc9335def37677ebb5e9b139440e27ee74f36c Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Wed, 25 May 2022 18:28:57 +0800 Subject: [PATCH 32/63] fix(os): run case on win --- source/libs/catalog/src/ctgCache.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/libs/catalog/src/ctgCache.c b/source/libs/catalog/src/ctgCache.c index 425a0bf926..9aec2588e9 100644 --- a/source/libs/catalog/src/ctgCache.c +++ b/source/libs/catalog/src/ctgCache.c @@ -1458,7 +1458,7 @@ _return: } void ctgUpdateThreadFuncUnexpectedStopped(void) { - CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock); + if (CTG_IS_LOCKED(&gCtgMgmt.lock)) CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock); } void* ctgUpdateThreadFunc(void* param) { @@ -1497,7 +1497,7 @@ void* ctgUpdateThreadFunc(void* param) { ctgdShowClusterCache(pCtg); } - CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock); + if (CTG_IS_LOCKED(&gCtgMgmt.lock)) CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock); qInfo("catalog update thread stopped"); From ae9c03e7f51043a85f1ba21f49edf054f5957382 Mon Sep 17 00:00:00 2001 From: 54liuyao <54liuyao@163.com> Date: Wed, 25 May 2022 14:41:18 +0800 Subject: [PATCH 33/63] ci(stream): close session test --- tests/script/jenkins/basic.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 03744768c9..a8f96cccf1 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -68,8 +68,8 @@ ./test.sh -f tsim/stream/basic0.sim ./test.sh -f tsim/stream/basic1.sim ./test.sh -f tsim/stream/basic2.sim -./test.sh -f tsim/stream/session0.sim -./test.sh -f tsim/stream/session1.sim +# ./test.sh -f tsim/stream/session0.sim +# ./test.sh -f tsim/stream/session1.sim # ---- transaction ./test.sh -f tsim/trans/lossdata1.sim From 79e97271ca0997853beaeca251a6a2c3140b0bd5 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Wed, 25 May 2022 18:43:25 +0800 Subject: [PATCH 34/63] fix(stream): memory error --- include/libs/stream/tstream.h | 2 +- source/libs/stream/src/tstream.c | 7 +- tests/pytest/stream/cqSupportBefore1970.py | 93 --------- tests/pytest/stream/history.py | 67 ------- tests/pytest/stream/metric_1.py | 104 ---------- tests/pytest/stream/metric_n.py | 123 ------------ tests/pytest/stream/new.py | 79 -------- tests/pytest/stream/parser.py | 182 ------------------ .../pytest/stream/showStreamExecTimeisNull.py | 98 ---------- tests/pytest/stream/stream1.py | 142 -------------- tests/pytest/stream/stream2.py | 164 ---------------- tests/pytest/stream/stream3.py | 108 ----------- tests/pytest/stream/sys.py | 62 ------ tests/pytest/stream/table_1.py | 89 --------- tests/pytest/stream/table_n.py | 143 -------------- 15 files changed, 5 insertions(+), 1458 deletions(-) delete mode 100644 tests/pytest/stream/cqSupportBefore1970.py delete mode 100644 tests/pytest/stream/history.py delete mode 100644 tests/pytest/stream/metric_1.py delete mode 100644 tests/pytest/stream/metric_n.py delete mode 100644 tests/pytest/stream/new.py delete mode 100644 tests/pytest/stream/parser.py delete mode 100644 tests/pytest/stream/showStreamExecTimeisNull.py delete mode 100644 tests/pytest/stream/stream1.py delete mode 100644 tests/pytest/stream/stream2.py delete mode 100644 tests/pytest/stream/stream3.py delete mode 100644 tests/pytest/stream/sys.py delete mode 100644 tests/pytest/stream/table_1.py delete mode 100644 tests/pytest/stream/table_n.py diff --git a/include/libs/stream/tstream.h b/include/libs/stream/tstream.h index d18f609d54..55e8cf0050 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -107,7 +107,7 @@ static FORCE_INLINE void streamDataSubmitRefDec(SStreamDataSubmit* pDataSubmit) if (ref == 0) { taosMemoryFree(pDataSubmit->data); taosMemoryFree(pDataSubmit->dataRef); - // taosFreeQitem(pDataSubmit); + taosFreeQitem(pDataSubmit); } } diff --git a/source/libs/stream/src/tstream.c b/source/libs/stream/src/tstream.c index 0acec0e4e6..dd7e38a458 100644 --- a/source/libs/stream/src/tstream.c +++ b/source/libs/stream/src/tstream.c @@ -166,6 +166,7 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, void* data, SArray* pRes) streamDataSubmitRefDec((SStreamDataSubmit*)data); } else { taosArrayDestroyEx(((SStreamDataBlock*)data)->blocks, (FDelete)tDeleteSSDataBlock); + taosFreeQitem(data); } return 0; } @@ -186,7 +187,7 @@ int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) { streamTaskExecImpl(pTask, data, pRes); - taosFreeQitem(data); + /*taosFreeQitem(data);*/ if (taosArrayGetSize(pRes) != 0) { SStreamDataBlock* resQ = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM); @@ -206,7 +207,7 @@ int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) { streamTaskExecImpl(pTask, data, pRes); - taosFreeQitem(data); + /*taosFreeQitem(data);*/ if (taosArrayGetSize(pRes) != 0) { SStreamDataBlock* resQ = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM); @@ -228,7 +229,7 @@ int32_t streamExec(SStreamTask* pTask, SMsgCb* pMsgCb) { streamTaskExecImpl(pTask, data, pRes); - taosFreeQitem(data); + /*taosFreeQitem(data);*/ if (taosArrayGetSize(pRes) != 0) { SStreamDataBlock* resQ = taosAllocateQitem(sizeof(SStreamDataBlock), DEF_QITEM); diff --git a/tests/pytest/stream/cqSupportBefore1970.py b/tests/pytest/stream/cqSupportBefore1970.py deleted file mode 100644 index 01ba5234fc..0000000000 --- a/tests/pytest/stream/cqSupportBefore1970.py +++ /dev/null @@ -1,93 +0,0 @@ -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -from util.log import * -from util.cases import * -from util.sql import * -from util.dnodes import * - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug(f"start to execute {__file__}") - tdSql.init(conn.cursor(), logSql) - - def insertnow(self): - - # timestamp list: - # 0 -> "1970-01-01 08:00:00" | -28800000 -> "1970-01-01 00:00:00" | -946800000000 -> "1940-01-01 00:00:00" - # -631180800000 -> "1950-01-01 00:00:00" - - tsp1 = 0 - tsp2 = -28800000 - tsp3 = -946800000000 - tsp4 = "1969-01-01 00:00:00.000" - - tdSql.execute("insert into tcq1 values (now-11d, 5)") - tdSql.execute(f"insert into tcq1 values ({tsp1}, 4)") - tdSql.execute(f"insert into tcq1 values ({tsp2}, 3)") - tdSql.execute(f"insert into tcq1 values ('{tsp4}', 2)") - tdSql.execute(f"insert into tcq1 values ({tsp3}, 1)") - - def waitedQuery(self, sql, expectRows, timeout): - tdLog.info(f"sql: {sql}, try to retrieve {expectRows} rows in {timeout} seconds") - try: - for i in range(timeout): - tdSql.cursor.execute(sql) - self.queryResult = tdSql.cursor.fetchall() - self.queryRows = len(self.queryResult) - self.queryCols = len(tdSql.cursor.description) - # tdLog.info("sql: %s, try to retrieve %d rows,get %d rows" % (sql, expectRows, self.queryRows)) - if self.queryRows >= expectRows: - return (self.queryRows, i) - time.sleep(1) - except Exception as e: - caller = inspect.getframeinfo(inspect.stack()[1][0]) - tdLog.notice(f"{caller.filename}({caller.lineno}) failed: sql:{sql}, {repr(e)}") - raise Exception(repr(e)) - return (self.queryRows, timeout) - - def cq(self): - tdSql.execute( - "create table cq1 as select avg(c1) from tcq1 where ts > -946800000000 interval(10d) sliding(1d)" - ) - self.waitedQuery("select * from cq1", 1, 120) - - def querycq(self): - tdSql.query("select * from cq1") - tdSql.checkData(0, 1, 1.0) - tdSql.checkData(10, 1, 2.0) - - def run(self): - tdSql.execute("drop database if exists dbcq") - tdSql.execute("create database if not exists dbcq keep 36500") - tdSql.execute("use dbcq") - - tdSql.execute("create table stbcq (ts timestamp, c1 int ) TAGS(t1 int)") - tdSql.execute("create table tcq1 using stbcq tags(1)") - - self.insertnow() - self.cq() - self.querycq() - - # after wal and sync, check again - tdSql.query("show dnodes") - index = tdSql.getData(0, 0) - tdDnodes.stop(index) - tdDnodes.start(index) - - self.querycq() - - def stop(self): - tdSql.close() - tdLog.success(f"{__file__} successfully executed") - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/stream/history.py b/tests/pytest/stream/history.py deleted file mode 100644 index cb8a4d5986..0000000000 --- a/tests/pytest/stream/history.py +++ /dev/null @@ -1,67 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import time -import taos -from util.log import tdLog -from util.cases import tdCases -from util.sql import tdSql - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def run(self): - tdSql.prepare() - - tdSql.execute("create table cars(ts timestamp, s int) tags(id int)") - tdSql.execute("create table car0 using cars tags(0)") - tdSql.execute("create table car1 using cars tags(1)") - tdSql.execute("create table car2 using cars tags(2)") - tdSql.execute("create table car3 using cars tags(3)") - tdSql.execute("create table car4 using cars tags(4)") - - tdSql.execute("insert into car0 values('2019-01-01 00:00:00.103', 1)") - tdSql.execute("insert into car1 values('2019-01-01 00:00:00.234', 1)") - tdSql.execute("insert into car0 values('2019-01-01 00:00:01.012', 1)") - tdSql.execute("insert into car0 values('2019-01-01 00:00:02.003', 1)") - tdSql.execute("insert into car2 values('2019-01-01 00:00:02.328', 1)") - tdSql.execute("insert into car0 values('2019-01-01 00:00:03.139', 1)") - tdSql.execute("insert into car0 values('2019-01-01 00:00:04.348', 1)") - tdSql.execute("insert into car0 values('2019-01-01 00:00:05.783', 1)") - tdSql.execute("insert into car1 values('2019-01-01 00:00:01.893', 1)") - tdSql.execute("insert into car1 values('2019-01-01 00:00:02.712', 1)") - tdSql.execute("insert into car1 values('2019-01-01 00:00:03.982', 1)") - tdSql.execute("insert into car3 values('2019-01-01 00:00:01.389', 1)") - tdSql.execute("insert into car4 values('2019-01-01 00:00:01.829', 1)") - - tdSql.error("create table strm as select count(*) from cars") - - tdSql.execute("create table strm as select count(*) from cars interval(4s)") - tdSql.waitedQuery("select * from strm", 2, 100) - tdSql.checkData(0, 1, 11) - tdSql.checkData(1, 1, 2) - - - - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/stream/metric_1.py b/tests/pytest/stream/metric_1.py deleted file mode 100644 index b4cccac69c..0000000000 --- a/tests/pytest/stream/metric_1.py +++ /dev/null @@ -1,104 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import time -import taos -from util.log import tdLog -from util.cases import tdCases -from util.sql import tdSql - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def createFuncStream(self, expr, suffix, value): - tbname = "strm_" + suffix - tdLog.info("create stream table %s" % tbname) - tdSql.query("select %s from stb interval(1d)" % expr) - tdSql.checkData(0, 1, value) - tdSql.execute("create table %s as select %s from stb interval(1d)" % (tbname, expr)) - - def checkStreamData(self, suffix, value): - sql = "select * from strm_" + suffix - tdSql.waitedQuery(sql, 1, 120) - tdSql.checkData(0, 1, value) - - def run(self): - tbNum = 10 - rowNum = 20 - - tdSql.prepare() - - tdLog.info("===== preparing data =====") - tdSql.execute( - "create table stb(ts timestamp, tbcol int, tbcol2 float) tags(tgcol int)") - for i in range(tbNum): - tdSql.execute("create table tb%d using stb tags(%d)" % (i, i)) - for j in range(rowNum): - tdSql.execute( - "insert into tb%d values (now - %dm, %d, %d)" % - (i, 1440 - j, j, j)) - time.sleep(0.1) - - self.createFuncStream("count(*)", "c1", 200) - self.createFuncStream("count(tbcol)", "c2", 200) - self.createFuncStream("count(tbcol2)", "c3", 200) - self.createFuncStream("avg(tbcol)", "av", 9.5) - self.createFuncStream("sum(tbcol)", "su", 1900) - self.createFuncStream("min(tbcol)", "mi", 0) - self.createFuncStream("max(tbcol)", "ma", 19) - self.createFuncStream("first(tbcol)", "fi", 0) - self.createFuncStream("last(tbcol)", "la", 19) - #tdSql.query("select stddev(tbcol) from stb interval(1d)") - #tdSql.query("select leastsquares(tbcol, 1, 1) from stb interval(1d)") - tdSql.query("select top(tbcol, 1) from stb interval(1d)") - tdSql.query("select bottom(tbcol, 1) from stb interval(1d)") - #tdSql.query("select percentile(tbcol, 1) from stb interval(1d)") - #tdSql.query("select diff(tbcol) from stb interval(1d)") - - tdSql.query("select count(tbcol) from stb where ts < now + 4m interval(1d)") - tdSql.checkData(0, 1, 200) - #tdSql.execute("create table strm_wh as select count(tbcol) from stb where ts < now + 4m interval(1d)") - - self.createFuncStream("count(tbcol)", "as", 200) - - tdSql.query("select count(tbcol) from stb interval(1d) group by tgcol") - tdSql.checkData(0, 1, 20) - - tdSql.query("select count(tbcol) from stb where ts < now + 4m interval(1d) group by tgcol") - tdSql.checkData(0, 1, 20) - - self.checkStreamData("c1", 200) - self.checkStreamData("c2", 200) - self.checkStreamData("c3", 200) - self.checkStreamData("av", 9.5) - self.checkStreamData("su", 1900) - self.checkStreamData("mi", 0) - self.checkStreamData("ma", 19) - self.checkStreamData("fi", 0) - self.checkStreamData("la", 19) - #self.checkStreamData("wh", 200) - self.checkStreamData("as", 200) - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) - - diff --git a/tests/pytest/stream/metric_n.py b/tests/pytest/stream/metric_n.py deleted file mode 100644 index d223fe81fc..0000000000 --- a/tests/pytest/stream/metric_n.py +++ /dev/null @@ -1,123 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import time -import taos -from util.log import tdLog -from util.cases import tdCases -from util.sql import tdSql - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def run(self): - tbNum = 10 - rowNum = 20 - totalNum = tbNum * rowNum - - tdSql.prepare() - - tdLog.info("===== preparing data =====") - tdSql.execute( - "create table stb(ts timestamp, tbcol int, tbcol2 float) tags(tgcol int)") - for i in range(tbNum): - tdSql.execute("create table tb%d using stb tags(%d)" % (i, i)) - for j in range(rowNum): - tdSql.execute( - "insert into tb%d values (now - %dm, %d, %d)" % - (i, 1440 - j, j, j)) - time.sleep(0.1) - - tdLog.info("===== step 1 =====") - tdSql.query("select count(*), count(tbcol), count(tbcol2) from stb interval(1d)") - tdSql.checkData(0, 1, totalNum) - tdSql.checkData(0, 2, totalNum) - tdSql.checkData(0, 3, totalNum) - - tdLog.info("===== step 2 =====") - tdSql.execute("create table strm_c3 as select count(*), count(tbcol), count(tbcol2) from stb interval(1d)") - - tdLog.info("===== step 3 =====") - tdSql.execute("create table strm_c32 as select count(*), count(tbcol) as c1, count(tbcol2) as c2, count(tbcol) as c3, count(tbcol) as c4, count(tbcol) as c5, count(tbcol) as c6, count(tbcol) as c7, count(tbcol) as c8, count(tbcol) as c9, count(tbcol) as c10, count(tbcol) as c11, count(tbcol) as c12, count(tbcol) as c13, count(tbcol) as c14, count(tbcol) as c15, count(tbcol) as c16, count(tbcol) as c17, count(tbcol) as c18, count(tbcol) as c19, count(tbcol) as c20, count(tbcol) as c21, count(tbcol) as c22, count(tbcol) as c23, count(tbcol) as c24, count(tbcol) as c25, count(tbcol) as c26, count(tbcol) as c27, count(tbcol) as c28, count(tbcol) as c29, count(tbcol) as c30 from stb interval(1d)") - - tdLog.info("===== step 4 =====") - tdSql.query("select count(*), count(tbcol) as c1, count(tbcol2) as c2, count(tbcol) as c3, count(tbcol) as c4, count(tbcol) as c5, count(tbcol) as c6, count(tbcol) as c7, count(tbcol) as c8, count(tbcol) as c9, count(tbcol) as c10, count(tbcol) as c11, count(tbcol) as c12, count(tbcol) as c13, count(tbcol) as c14, count(tbcol) as c15, count(tbcol) as c16, count(tbcol) as c17, count(tbcol) as c18, count(tbcol) as c19, count(tbcol) as c20, count(tbcol) as c21, count(tbcol) as c22, count(tbcol) as c23, count(tbcol) as c24, count(tbcol) as c25, count(tbcol) as c26, count(tbcol) as c27, count(tbcol) as c28, count(tbcol) as c29, count(tbcol) as c30 from stb interval(1d)") - tdSql.checkData(0, 1, totalNum) - tdSql.checkData(0, 2, totalNum) - tdSql.checkData(0, 3, totalNum) - - tdLog.info("===== step 5 =====") - tdSql.execute("create table strm_c31 as select count(*), count(tbcol) as c1, count(tbcol2) as c2, count(tbcol) as c3, count(tbcol) as c4, count(tbcol) as c5, count(tbcol) as c6, count(tbcol) as c7, count(tbcol) as c8, count(tbcol) as c9, count(tbcol) as c10, count(tbcol) as c11, count(tbcol) as c12, count(tbcol) as c13, count(tbcol) as c14, count(tbcol) as c15, count(tbcol) as c16, count(tbcol) as c17, count(tbcol) as c18, count(tbcol) as c19, count(tbcol) as c20, count(tbcol) as c21, count(tbcol) as c22, count(tbcol) as c23, count(tbcol) as c24, count(tbcol) as c25, count(tbcol) as c26, count(tbcol) as c27, count(tbcol) as c28, count(tbcol) as c29, count(tbcol) as c30 from stb interval(1d)") - - tdLog.info("===== step 6 =====") - tdSql.query("select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from stb interval(1d)") - tdSql.checkData(0, 1, 9.5) - tdSql.checkData(0, 2, 1900) - tdSql.checkData(0, 3, 0) - tdSql.checkData(0, 4, 19) - tdSql.checkData(0, 5, 0) - tdSql.checkData(0, 6, 19) - tdSql.execute("create table strm_avg as select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from stb interval(1d)") - - tdLog.info("===== step 7 =====") - tdSql.query("select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol), count(tbcol) from stb where ts < now + 4m interval(1d)") - tdSql.checkData(0, 1, 9.5) - tdSql.checkData(0, 2, 1900) - tdSql.checkData(0, 3, 0) - tdSql.checkData(0, 4, 19) - tdSql.checkData(0, 5, 0) - tdSql.checkData(0, 6, 19) - tdSql.checkData(0, 7, totalNum) - - tdLog.info("===== step 8 =====") - tdSql.query("select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol), count(tbcol) from stb where ts < now + 4m interval(1d)") - tdSql.checkData(0, 1, 9.5) - tdSql.checkData(0, 2, 1900) - tdSql.checkData(0, 3, 0) - tdSql.checkData(0, 4, 19) - tdSql.checkData(0, 5, 0) - tdSql.checkData(0, 6, 19) - tdSql.checkData(0, 7, totalNum) - - tdLog.info("===== step 9 =====") - tdSql.waitedQuery("select * from strm_c3", 1, 120) - tdSql.checkData(0, 1, totalNum) - tdSql.checkData(0, 2, totalNum) - tdSql.checkData(0, 3, totalNum) - - tdLog.info("===== step 10 =====") - tdSql.waitedQuery("select * from strm_c31", 1, 30) - for i in range(1, 10): - tdSql.checkData(0, i, totalNum) - - tdLog.info("===== step 11 =====") - tdSql.waitedQuery("select * from strm_avg", 1, 20) - tdSql.checkData(0, 1, 9.5) - tdSql.checkData(0, 2, 1900) - tdSql.checkData(0, 3, 0) - tdSql.checkData(0, 4, 19) - tdSql.checkData(0, 5, 0) - tdSql.checkData(0, 6, 19) - - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/stream/new.py b/tests/pytest/stream/new.py deleted file mode 100644 index 4a0e47c01a..0000000000 --- a/tests/pytest/stream/new.py +++ /dev/null @@ -1,79 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import time -import taos -from util.log import tdLog -from util.cases import tdCases -from util.sql import tdSql - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def run(self): - rowNum = 200 - tdSql.prepare() - - tdLog.info("=============== step1") - tdSql.execute("create table mt(ts timestamp, tbcol int, tbcol2 float) TAGS(tgcol int)") - for i in range(5): - tdSql.execute("create table tb%d using mt tags(%d)" % (i, i)) - for j in range(rowNum): - tdSql.execute("insert into tb%d values(now + %ds, %d, %d)" % (i, j, j, j)) - time.sleep(0.1) - - tdLog.info("=============== step2") - tdSql.query("select count(*), count(tbcol), count(tbcol2) from mt interval(10s)") - tdSql.execute("create table st as select count(*), count(tbcol), count(tbcol2) from mt interval(10s)") - - tdLog.info("=============== step3") - start = time.time() - tdSql.waitedQuery("select * from st", 1, 180) - delay = int(time.time() - start) + 80 - v = tdSql.getData(0, 3) - if v >= 51: - tdLog.exit("value is %d, which is larger than 51" % v) - - tdLog.info("=============== step4") - for i in range(5, 10): - tdSql.execute("create table tb%d using mt tags(%d)" % (i, i)) - for j in range(rowNum): - tdSql.execute("insert into tb%d values(now + %ds, %d, %d)" % (i, j, j, j)) - - tdLog.info("=============== step5") - maxValue = 0 - for i in range(delay): - time.sleep(1) - tdSql.query("select * from st order by ts desc") - v = tdSql.getData(0, 3) - if v > maxValue: - maxValue = v - if v > 51: - break - - if maxValue <= 51: - tdLog.exit("value is %d, which is smaller than 51" % maxValue) - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) - - diff --git a/tests/pytest/stream/parser.py b/tests/pytest/stream/parser.py deleted file mode 100644 index 3b231d2b39..0000000000 --- a/tests/pytest/stream/parser.py +++ /dev/null @@ -1,182 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import time -import taos -from util.log import tdLog -from util.cases import tdCases -from util.sql import tdSql - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - ''' - def bug2222(self): - tdSql.prepare() - tdSql.execute("create table superreal(ts timestamp, addr binary(5), val float) tags (deviceNo binary(20))") - tdSql.execute("create table real_001 using superreal tags('001')") - tdSql.execute("create table tj_001 as select sum(val) from real_001 interval(1m)") - - t = datetime.datetime.now() - for i in range(60): - ts = t.strftime("%Y-%m-%d %H:%M") - t += datetime.timedelta(minutes=1) - sql = "insert into real_001 values('%s:0%d', '1', %d)" % (ts, 0, i) - for j in range(4): - sql += ",('%s:0%d', '%d', %d)" % (ts, j + 1, j + 1, i) - tdSql.execute(sql) - time.sleep(60 + random.random() * 60 - 30) - ''' - - def tbase300(self): - tdLog.debug("begin tbase300") - - tdSql.prepare() - tdSql.execute("create table mt(ts timestamp, c1 int, c2 int) tags(t1 int)") - tdSql.execute("create table tb1 using mt tags(1)"); - tdSql.execute("create table tb2 using mt tags(2)"); - tdSql.execute("create table strm as select count(*), avg(c1), sum(c2), max(c1), min(c2),first(c1), last(c2) from mt interval(4s) sliding(2s)") - #tdSql.execute("create table strm as select count(*), avg(c1), sum(c2), max(c1), min(c2), first(c1) from mt interval(4s) sliding(2s)") - tdLog.sleep(10) - tdSql.execute("insert into tb2 values(now, 1, 1)"); - tdSql.execute("insert into tb1 values(now, 1, 1)"); - tdLog.sleep(4) - tdSql.query("select * from mt") - tdSql.query("select * from strm") - tdSql.execute("drop table tb1") - - tdSql.waitedQuery("select * from strm", 1, 100) - if tdSql.queryRows < 1 or tdSql.queryRows > 2: - tdLog.exit("rows should be 1 or 2") - - tdSql.execute("drop table tb2") - tdSql.execute("drop table mt") - tdSql.execute("drop table strm") - - def tbase304(self): - tdLog.debug("begin tbase304") - # we cannot reset query cache in server side, as a workaround, - # set super table name to mt304, need to change back to mt later - tdSql.execute("create table mt304 (ts timestamp, c1 int) tags(t1 int, t2 int)") - tdSql.execute("create table tb1 using mt304 tags(1, 1)") - tdSql.execute("create table tb2 using mt304 tags(1, -1)") - time.sleep(0.1) - tdSql.execute("create table strm as select count(*), avg(c1) from mt304 where t2 >= 0 interval(4s) sliding(2s)") - tdSql.execute("insert into tb1 values (now,1)") - tdSql.execute("insert into tb2 values (now,2)") - - tdSql.waitedQuery("select * from strm", 1, 100) - if tdSql.queryRows < 1 or tdSql.queryRows > 2: - tdLog.exit("rows should be 1 or 2") - - tdSql.checkData(0, 1, 1) - tdSql.checkData(0, 2, 1.000000000) - tdSql.execute("alter table mt304 drop tag t2") - tdSql.execute("insert into tb2 values (now,2)") - tdSql.execute("insert into tb1 values (now,1)") - tdSql.query("select * from strm") - tdSql.execute("alter table mt304 add tag t2 int") - tdLog.sleep(1) - tdSql.query("select * from strm") - - def wildcardFilterOnTags(self): - tdLog.debug("begin wildcardFilterOnTag") - tdSql.prepare() - tdSql.execute("create table stb (ts timestamp, c1 int, c2 binary(10)) tags(t1 binary(10))") - tdSql.execute("create table tb1 using stb tags('a1')") - tdSql.execute("create table tb2 using stb tags('b2')") - tdSql.execute("create table tb3 using stb tags('a3')") - tdSql.execute("create table strm as select count(*), avg(c1), first(c2) from stb where t1 like 'a%' interval(4s) sliding(2s)") - tdSql.query("describe strm") - tdSql.checkRows(4) - - tdLog.sleep(1) - tdSql.execute("insert into tb1 values (now, 0, 'tb1')") - tdLog.sleep(4) - tdSql.execute("insert into tb2 values (now, 2, 'tb2')") - tdLog.sleep(4) - tdSql.execute("insert into tb3 values (now, 0, 'tb3')") - - tdSql.waitedQuery("select * from strm", 4, 60) - tdSql.checkRows(4) - tdSql.checkData(0, 2, 0.000000000) - if tdSql.getData(0, 3) == 'tb2': - tdLog.exit("unexpected value of data03") - if tdSql.getData(1, 3) == 'tb2': - tdLog.exit("unexpected value of data13") - if tdSql.getData(2, 3) == 'tb2': - tdLog.exit("unexpected value of data23") - if tdSql.getData(3, 3) == 'tb2': - tdLog.exit("unexpected value of data33") - - tdLog.info("add table tb4 to see if stream still works correctly") - # The vnode client needs to refresh metadata cache to allow strm calculate tb4's data. - # But the current refreshing frequency is every 10 min - # commented out the case below to save running time - tdSql.execute("create table tb4 using stb tags('a4')") - tdSql.execute("insert into tb4 values(now, 4, 'tb4')") - tdSql.waitedQuery("select * from strm order by ts desc", 6, 60) - tdSql.checkRows(6) - tdSql.checkData(0, 2, 4) - tdSql.checkData(0, 3, "tb4") - - tdLog.info("change tag values to see if stream still works correctly") - tdSql.execute("alter table tb4 set tag t1='b4'") - tdLog.sleep(3) - tdSql.execute("insert into tb1 values (now, 1, 'tb1_a1')") - tdLog.sleep(4) - tdSql.execute("insert into tb4 values (now, -4, 'tb4_b4')") - tdSql.waitedQuery("select * from strm order by ts desc", 8, 100) - tdSql.checkRows(8) - tdSql.checkData(0, 2, 1) - tdSql.checkData(0, 3, "tb1_a1") - - def datatypes(self): - tdLog.debug("begin data types") - tdSql.prepare() - tdSql.execute("create table stb3 (ts timestamp, c1 int, c2 bigint, c3 float, c4 double, c5 binary(15), c6 nchar(15), c7 bool) tags(t1 int, t2 binary(15))") - tdSql.execute("create table tb0 using stb3 tags(0, 'tb0')") - tdSql.execute("create table tb1 using stb3 tags(1, 'tb1')") - tdSql.execute("create table tb2 using stb3 tags(2, 'tb2')") - tdSql.execute("create table tb3 using stb3 tags(3, 'tb3')") - tdSql.execute("create table tb4 using stb3 tags(4, 'tb4')") - - tdSql.execute("create table strm0 as select count(ts), count(c1), max(c2), min(c4), first(c5), last(c6) from stb3 where ts < now + 30s interval(4s) sliding(2s)") - #tdSql.execute("create table strm0 as select count(ts), count(c1), max(c2), min(c4), first(c5) from stb where ts < now + 30s interval(4s) sliding(2s)") - tdLog.sleep(1) - tdSql.execute("insert into tb0 values (now, 0, 0, 0, 0, 'binary0', '涛思0', true) tb1 values (now, 1, 1, 1, 1, 'binary1', '涛思1', false) tb2 values (now, 2, 2, 2, 2, 'binary2', '涛思2', true) tb3 values (now, 3, 3, 3, 3, 'binary3', '涛思3', false) tb4 values (now, 4, 4, 4, 4, 'binary4', '涛思4', true) ") - - tdSql.waitedQuery("select * from strm0 order by ts desc", 2, 120) - tdSql.checkRows(2) - - tdSql.execute("insert into tb0 values (now, 10, 10, 10, 10, 'binary0', '涛思0', true) tb1 values (now, 11, 11, 11, 11, 'binary1', '涛思1', false) tb2 values (now, 12, 12, 12, 12, 'binary2', '涛思2', true) tb3 values (now, 13, 13, 13, 13, 'binary3', '涛思3', false) tb4 values (now, 14, 14, 14, 14, 'binary4', '涛思4', true) ") - tdSql.waitedQuery("select * from strm0 order by ts desc", 4, 120) - tdSql.checkRows(4) - - def run(self): - self.tbase300() - self.tbase304() - self.wildcardFilterOnTags() - self.datatypes() - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/stream/showStreamExecTimeisNull.py b/tests/pytest/stream/showStreamExecTimeisNull.py deleted file mode 100644 index 8a2a09cec6..0000000000 --- a/tests/pytest/stream/showStreamExecTimeisNull.py +++ /dev/null @@ -1,98 +0,0 @@ -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -from util.log import * -from util.cases import * -from util.sql import * -from util.dnodes import * - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug(f"start to execute {__file__}") - tdSql.init(conn.cursor(), logSql) - - def insertnow(self): - - # timestamp list: - # 0 -> "1970-01-01 08:00:00" | -28800000 -> "1970-01-01 00:00:00" | -946800000000 -> "1940-01-01 00:00:00" - # -631180800000 -> "1950-01-01 00:00:00" - - tsp1 = 0 - tsp2 = -28800000 - tsp3 = -946800000000 - tsp4 = "1969-01-01 00:00:00.000" - - tdSql.execute("insert into tcq1 values (now-11d, 5)") - tdSql.execute(f"insert into tcq1 values ({tsp1}, 4)") - tdSql.execute(f"insert into tcq1 values ({tsp2}, 3)") - tdSql.execute(f"insert into tcq1 values ('{tsp4}', 2)") - tdSql.execute(f"insert into tcq1 values ({tsp3}, 1)") - - def waitedQuery(self, sql, expectRows, timeout): - tdLog.info(f"sql: {sql}, try to retrieve {expectRows} rows in {timeout} seconds") - try: - for i in range(timeout): - tdSql.cursor.execute(sql) - self.queryResult = tdSql.cursor.fetchall() - self.queryRows = len(self.queryResult) - self.queryCols = len(tdSql.cursor.description) - # tdLog.info("sql: %s, try to retrieve %d rows,get %d rows" % (sql, expectRows, self.queryRows)) - if self.queryRows >= expectRows: - return (self.queryRows, i) - time.sleep(1) - except Exception as e: - caller = inspect.getframeinfo(inspect.stack()[1][0]) - tdLog.notice(f"{caller.filename}({caller.lineno}) failed: sql:{sql}, {repr(e)}") - raise Exception(repr(e)) - return (self.queryRows, timeout) - - def showstream(self): - tdSql.execute( - "create table cq1 as select avg(c1) from tcq1 interval(10d) sliding(1d)" - ) - sql = "show streams" - timeout = 30 - exception = "ValueError('year -292275055 is out of range')" - try: - for i in range(timeout): - tdSql.cursor.execute(sql) - self.queryResult = tdSql.cursor.fetchall() - self.queryRows = len(self.queryResult) - self.queryCols = len(tdSql.cursor.description) - # tdLog.info("sql: %s, try to retrieve %d rows,get %d rows" % (sql, expectRows, self.queryRows)) - if self.queryRows >= 1: - tdSql.query(sql) - tdSql.checkData(0, 5, None) - return (self.queryRows, i) - time.sleep(1) - except Exception as e: - tdLog.exit(f"sql: {sql} except raise {exception}, actually raise {repr(e)} ") - # else: - # tdLog.exit(f"sql: {sql} except raise {exception}, actually not") - - def run(self): - tdSql.execute("drop database if exists dbcq") - tdSql.execute("create database if not exists dbcq keep 36500") - tdSql.execute("use dbcq") - - tdSql.execute("create table stbcq (ts timestamp, c1 int ) TAGS(t1 int)") - tdSql.execute("create table tcq1 using stbcq tags(1)") - - self.insertnow() - self.showstream() - - - def stop(self): - tdSql.close() - tdLog.success(f"{__file__} successfully executed") - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) \ No newline at end of file diff --git a/tests/pytest/stream/stream1.py b/tests/pytest/stream/stream1.py deleted file mode 100644 index c657379441..0000000000 --- a/tests/pytest/stream/stream1.py +++ /dev/null @@ -1,142 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import time -import taos -from util.log import tdLog -from util.cases import tdCases -from util.sql import tdSql - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def run(self): - tbNum = 10 - rowNum = 20 - - tdSql.prepare() - - tdLog.info("===== step1 =====") - tdSql.execute( - "create table stb0(ts timestamp, col1 int, col2 float) tags(tgcol int)") - for i in range(tbNum): - tdSql.execute("create table tb%d using stb0 tags(%d)" % (i, i)) - for j in range(rowNum): - tdSql.execute( - "insert into tb%d values (now - %dm, %d, %d)" % - (i, 1440 - j, j, j)) - time.sleep(0.1) - - tdLog.info("===== step2 =====") - tdSql.query( - "select count(*), count(col1), count(col2) from tb0 interval(1d)") - tdSql.checkData(0, 1, rowNum) - tdSql.checkData(0, 2, rowNum) - tdSql.checkData(0, 3, rowNum) - tdSql.query("show tables") - tdSql.checkRows(tbNum) - tdSql.execute( - "create table s0 as select count(*), count(col1), count(col2) from tb0 interval(1d)") - tdSql.query("show tables") - tdSql.checkRows(tbNum + 1) - - tdLog.info("===== step3 =====") - tdSql.waitedQuery("select * from s0", 1, 120) - try: - tdSql.checkData(0, 1, rowNum) - tdSql.checkData(0, 2, rowNum) - tdSql.checkData(0, 3, rowNum) - except Exception as e: - tdLog.info(repr(e)) - - tdLog.info("===== step4 =====") - tdSql.execute("drop table s0") - tdSql.query("show tables") - tdSql.checkRows(tbNum) - - tdLog.info("===== step5 =====") - tdSql.error("select * from s0") - - tdLog.info("===== step6 =====") - time.sleep(0.1) - tdSql.execute( - "create table s0 as select count(*), count(col1), count(col2) from tb0 interval(1d)") - tdSql.query("show tables") - tdSql.checkRows(tbNum + 1) - - tdLog.info("===== step7 =====") - tdSql.waitedQuery("select * from s0", 1, 120) - try: - tdSql.checkData(0, 1, rowNum) - tdSql.checkData(0, 2, rowNum) - tdSql.checkData(0, 3, rowNum) - except Exception as e: - tdLog.info(repr(e)) - - tdLog.info("===== step8 =====") - tdSql.query( - "select count(*), count(col1), count(col2) from stb0 interval(1d)") - tdSql.checkData(0, 1, rowNum * tbNum) - tdSql.checkData(0, 2, rowNum * tbNum) - tdSql.checkData(0, 3, rowNum * tbNum) - tdSql.query("show tables") - tdSql.checkRows(tbNum + 1) - - tdSql.execute( - "create table s1 as select count(*), count(col1), count(col2) from stb0 interval(1d)") - tdSql.query("show tables") - tdSql.checkRows(tbNum + 2) - - tdLog.info("===== step9 =====") - tdSql.waitedQuery("select * from s1", 1, 120) - try: - tdSql.checkData(0, 1, rowNum * tbNum) - tdSql.checkData(0, 2, rowNum * tbNum) - tdSql.checkData(0, 3, rowNum * tbNum) - except Exception as e: - tdLog.info(repr(e)) - - tdLog.info("===== step10 =====") - tdSql.execute("drop table s1") - tdSql.query("show tables") - tdSql.checkRows(tbNum + 1) - - tdLog.info("===== step11 =====") - tdSql.error("select * from s1") - - tdLog.info("===== step12 =====") - tdSql.execute( - "create table s1 as select count(*), count(col1), count(col2) from stb0 interval(1d)") - tdSql.query("show tables") - tdSql.checkRows(tbNum + 2) - - tdLog.info("===== step13 =====") - tdSql.waitedQuery("select * from s1", 1, 120) - try: - tdSql.checkData(0, 1, rowNum * tbNum) - tdSql.checkData(0, 2, rowNum * tbNum) - tdSql.checkData(0, 3, rowNum * tbNum) - except Exception as e: - tdLog.info(repr(e)) - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/stream/stream2.py b/tests/pytest/stream/stream2.py deleted file mode 100644 index 9b4eb8725c..0000000000 --- a/tests/pytest/stream/stream2.py +++ /dev/null @@ -1,164 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import time -import taos -from util.log import tdLog -from util.cases import tdCases -from util.sql import tdSql - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def run(self): - tbNum = 10 - rowNum = 20 - totalNum = tbNum * rowNum - - tdSql.prepare() - - tdLog.info("===== step1 =====") - tdSql.execute( - "create table stb0(ts timestamp, col1 int, col2 float) tags(tgcol int)") - for i in range(tbNum): - tdSql.execute("create table tb%d using stb0 tags(%d)" % (i, i)) - for j in range(rowNum): - tdSql.execute( - "insert into tb%d values (now - %dm, %d, %d)" % - (i, 1440 - j, j, j)) - time.sleep(0.1) - - tdLog.info("===== step2 =====") - tdSql.query("select count(col1) from tb0 interval(1d)") - tdSql.checkData(0, 1, rowNum) - tdSql.query("show tables") - tdSql.checkRows(tbNum) - tdSql.execute( - "create table s0 as select count(col1) from tb0 interval(1d)") - tdSql.query("show tables") - tdSql.checkRows(tbNum + 1) - - tdLog.info("===== step3 =====") - tdSql.waitedQuery("select * from s0", 1, 120) - try: - tdSql.checkData(0, 1, rowNum) - except Exception as e: - tdLog.info(repr(e)) - - tdLog.info("===== step4 =====") - tdSql.execute("drop table s0") - tdSql.query("show tables") - try: - tdSql.checkRows(tbNum) - except Exception as e: - tdLog.info(repr(e)) - - tdLog.info("===== step5 =====") - tdSql.error("select * from s0") - - tdLog.info("===== step6 =====") - tdSql.execute( - "create table s0 as select count(*), count(col1), count(col2) from tb0 interval(1d)") - tdSql.query("show tables") - try: - tdSql.checkRows(tbNum + 1) - except Exception as e: - tdLog.info(repr(e)) - - tdLog.info("===== step7 =====") - tdSql.waitedQuery("select * from s0", 1, 120) - try: - tdSql.checkData(0, 1, rowNum) - tdSql.checkData(0, 2, rowNum) - tdSql.checkData(0, 3, rowNum) - except Exception as e: - tdLog.info(repr(e)) - - - time.sleep(5) - tdSql.query("show streams") - tdSql.checkRows(1) - tdSql.checkData(0, 2, 's0') - - tdLog.info("===== step8 =====") - tdSql.query( - "select count(*), count(col1), count(col2) from stb0 interval(1d)") - try: - tdSql.checkData(0, 1, totalNum) - tdSql.checkData(0, 2, totalNum) - tdSql.checkData(0, 3, totalNum) - except Exception as e: - tdLog.info(repr(e)) - tdSql.query("show tables") - tdSql.checkRows(tbNum + 1) - tdSql.execute( - "create table s1 as select count(*), count(col1), count(col2) from stb0 interval(1d)") - tdSql.query("show tables") - tdSql.checkRows(tbNum + 2) - - tdLog.info("===== step9 =====") - tdSql.waitedQuery("select * from s1", 1, 120) - try: - tdSql.checkData(0, 1, totalNum) - tdSql.checkData(0, 2, totalNum) - tdSql.checkData(0, 3, totalNum) - except Exception as e: - tdLog.info(repr(e)) - - tdLog.info("===== step10 =====") - tdSql.execute("drop table s1") - tdSql.query("show tables") - try: - tdSql.checkRows(tbNum + 1) - except Exception as e: - tdLog.info(repr(e)) - - tdLog.info("===== step11 =====") - tdSql.error("select * from s1") - - tdLog.info("===== step12 =====") - tdSql.execute( - "create table s1 as select count(col1) from stb0 interval(1d)") - tdSql.query("show tables") - try: - tdSql.checkRows(tbNum + 2) - except Exception as e: - tdLog.info(repr(e)) - - tdLog.info("===== step13 =====") - tdSql.waitedQuery("select * from s1", 1, 120) - try: - tdSql.checkData(0, 1, totalNum) - #tdSql.checkData(0, 2, None) - #tdSql.checkData(0, 3, None) - except Exception as e: - tdLog.info(repr(e)) - - time.sleep(5) - tdSql.query("show streams") - tdSql.checkRows(2) - tdSql.checkData(0, 2, 's1') - tdSql.checkData(1, 2, 's0') - - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/stream/stream3.py b/tests/pytest/stream/stream3.py deleted file mode 100644 index 9a5c6c9aec..0000000000 --- a/tests/pytest/stream/stream3.py +++ /dev/null @@ -1,108 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import time -import taos -from util.log import tdLog -from util.cases import tdCases -from util.sql import tdSql - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def run(self): - ts = 1500000000000 - tbNum = 10 - rowNum = 20 - - tdSql.prepare() - - tdLog.info("===== step1 =====") - tdSql.execute( - "create table stb0(ts timestamp, col1 binary(20), col2 nchar(20)) tags(tgcol int)") - for i in range(tbNum): - tdSql.execute("create table tb%d using stb0 tags(%d)" % (i, i)) - for j in range(rowNum): - tdSql.execute( - "insert into tb%d values (%d, 'binary%d', 'nchar%d')" % - (i, ts + 60000 * j, j, j)) - tdSql.execute("insert into tb0 values(%d, null, null)" % (ts + 10000000)) - time.sleep(0.1) - - tdLog.info("===== step2 =====") - tdSql.query( - "select count(*), count(col1), count(col2) from stb0 interval(1d)") - tdSql.checkData(0, 1, rowNum * tbNum + 1) - tdSql.checkData(0, 2, rowNum * tbNum) - tdSql.checkData(0, 3, rowNum * tbNum) - - tdSql.query("show tables") - tdSql.checkRows(tbNum) - tdSql.execute( - "create table s0 as select count(*), count(col1), count(col2) from stb0 interval(1d)") - tdSql.query("show tables") - tdSql.checkRows(tbNum + 1) - - tdLog.info("===== step3 =====") - tdSql.waitedQuery("select * from s0", 1, 120) - try: - tdSql.checkData(0, 1, rowNum * tbNum + 1) - tdSql.checkData(0, 2, rowNum * tbNum) - tdSql.checkData(0, 3, rowNum * tbNum) - except Exception as e: - tdLog.info(repr(e)) - - tdLog.info("===== step4 =====") - tdSql.execute("drop table s0") - tdSql.query("show tables") - tdSql.checkRows(tbNum) - - tdLog.info("===== step5 =====") - tdSql.error("select * from s0") - - tdLog.info("===== step6 =====") - time.sleep(0.1) - tdSql.execute( - "create table s0 as select count(*), count(col1), count(col2) from tb0 interval(1d)") - tdSql.query("show tables") - tdSql.checkRows(tbNum + 1) - - tdLog.info("===== step7 =====") - tdSql.waitedQuery("select * from s0", 1, 120) - try: - tdSql.checkData(0, 1, rowNum + 1) - tdSql.checkData(0, 2, rowNum) - tdSql.checkData(0, 3, rowNum) - except Exception as e: - tdLog.info(repr(e)) - - tdLog.info("===== step8 =====") - tdSql.query( - "select count(*), count(col1), count(col2) from stb0 interval(1d)") - tdSql.checkData(0, 1, rowNum * tbNum + 1) - tdSql.checkData(0, 2, rowNum * tbNum) - tdSql.checkData(0, 3, rowNum * tbNum) - tdSql.query("show tables") - tdSql.checkRows(tbNum + 1) - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/stream/sys.py b/tests/pytest/stream/sys.py deleted file mode 100644 index c9a3fccfe6..0000000000 --- a/tests/pytest/stream/sys.py +++ /dev/null @@ -1,62 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# migrated from 'stream_on_sys.sim' -# -*- coding: utf-8 -*- -import sys -import time -import taos -from util.log import tdLog -from util.cases import tdCases -from util.sql import tdSql - - -class TDTestCase: - updatecfgDict = {'monitor': 1} - - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - - def run(self): - time.sleep(5) - tdSql.execute("use log") - - tdSql.execute("create table cpustrm as select count(*), avg(cpu_taosd), max(cpu_taosd), min(cpu_taosd), avg(cpu_system), max(cpu_cores), min(cpu_cores), last(cpu_cores) from log.dn1 interval(4s)") - tdSql.execute("create table memstrm as select count(*), avg(mem_taosd), max(mem_taosd), min(mem_taosd), avg(mem_system), first(mem_total), last(mem_total) from log.dn1 interval(4s)") - tdSql.execute("create table diskstrm as select count(*), avg(disk_used), last(disk_used), avg(disk_total), first(disk_total) from log.dn1 interval(4s)") - tdSql.execute("create table bandstrm as select count(*), avg(band_speed), last(band_speed) from log.dn1 interval(4s)") - tdSql.execute("create table reqstrm as select count(*), avg(req_http), last(req_http), avg(req_select), last(req_select), avg(req_insert), last(req_insert) from log.dn1 interval(4s)") - tdSql.execute("create table iostrm as select count(*), avg(io_read), last(io_read), avg(io_write), last(io_write) from log.dn1 interval(4s)") - - sqls = [ - "select * from cpustrm", - "select * from memstrm", - "select * from diskstrm", - "select * from bandstrm", - "select * from reqstrm", - "select * from iostrm", - ] - for sql in sqls: - (rows, _) = tdSql.waitedQuery(sql, 1, 240) - if rows < 1: - tdLog.exit("failed: sql:%s, expect at least one row" % sql) - - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) - diff --git a/tests/pytest/stream/table_1.py b/tests/pytest/stream/table_1.py deleted file mode 100644 index b205491fad..0000000000 --- a/tests/pytest/stream/table_1.py +++ /dev/null @@ -1,89 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import time -import taos -from util.log import tdLog -from util.cases import tdCases -from util.sql import tdSql - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def createFuncStream(self, expr, suffix, value): - tbname = "strm_" + suffix - tdLog.info("create stream table %s" % tbname) - tdSql.query("select %s from tb1 interval(1d)" % expr) - tdSql.checkData(0, 1, value) - tdSql.execute("create table %s as select %s from tb1 interval(1d)" % (tbname, expr)) - - def checkStreamData(self, suffix, value): - sql = "select * from strm_" + suffix - tdSql.waitedQuery(sql, 1, 120) - tdSql.checkData(0, 1, value) - - def run(self): - tbNum = 10 - rowNum = 20 - - tdSql.prepare() - - tdLog.info("===== step1 =====") - tdSql.execute( - "create table stb(ts timestamp, tbcol int, tbcol2 float) tags(tgcol int)") - for i in range(tbNum): - tdSql.execute("create table tb%d using stb tags(%d)" % (i, i)) - for j in range(rowNum): - tdSql.execute( - "insert into tb%d values (now - %dm, %d, %d)" % - (i, 1440 - j, j, j)) - time.sleep(1) - - self.createFuncStream("count(*)", "c1", rowNum) - self.createFuncStream("count(tbcol)", "c2", rowNum) - self.createFuncStream("count(tbcol2)", "c3", rowNum) - self.createFuncStream("avg(tbcol)", "av", 9.5) - self.createFuncStream("sum(tbcol)", "su", 190) - self.createFuncStream("min(tbcol)", "mi", 0) - self.createFuncStream("max(tbcol)", "ma", 19) - self.createFuncStream("first(tbcol)", "fi", 0) - self.createFuncStream("last(tbcol)", "la", 19) - self.createFuncStream("stddev(tbcol)", "st", 5.766281297335398) - self.createFuncStream("percentile(tbcol, 1)", "pe", 0.19) - self.createFuncStream("count(tbcol)", "as", rowNum) - - self.checkStreamData("c1", rowNum) - self.checkStreamData("c2", rowNum) - self.checkStreamData("c3", rowNum) - self.checkStreamData("av", 9.5) - self.checkStreamData("su", 190) - self.checkStreamData("mi", 0) - self.checkStreamData("ma", 19) - self.checkStreamData("fi", 0) - self.checkStreamData("la", 19) - self.checkStreamData("st", 5.766281297335398) - self.checkStreamData("pe", 0.19) - self.checkStreamData("as", rowNum) - - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) diff --git a/tests/pytest/stream/table_n.py b/tests/pytest/stream/table_n.py deleted file mode 100644 index 371af76977..0000000000 --- a/tests/pytest/stream/table_n.py +++ /dev/null @@ -1,143 +0,0 @@ -################################################################### -# Copyright (c) 2016 by TAOS Technologies, Inc. -# All rights reserved. -# -# This file is proprietary and confidential to TAOS Technologies. -# No part of this file may be reproduced, stored, transmitted, -# disclosed or used in any form or by any means other than as -# expressly provided by the written permission from Jianhui Tao -# -################################################################### - -# -*- coding: utf-8 -*- - -import sys -import time -import taos -from util.log import tdLog -from util.cases import tdCases -from util.sql import tdSql - - -class TDTestCase: - def init(self, conn, logSql): - tdLog.debug("start to execute %s" % __file__) - tdSql.init(conn.cursor(), logSql) - - def run(self): - tbNum = 10 - rowNum = 20 - - tdSql.prepare() - - tdLog.info("===== preparing data =====") - tdSql.execute( - "create table stb(ts timestamp, tbcol int, tbcol2 float) tags(tgcol int)") - for i in range(tbNum): - tdSql.execute("create table tb%d using stb tags(%d)" % (i, i)) - for j in range(rowNum): - tdSql.execute( - "insert into tb%d values (now - %dm, %d, %d)" % - (i, 1440 - j, j, j)) - time.sleep(0.1) - - tdLog.info("===== step 1 =====") - tdSql.query("select count(*), count(tbcol), count(tbcol2) from tb1 interval(1d)") - tdSql.checkData(0, 1, rowNum) - tdSql.checkData(0, 2, rowNum) - tdSql.checkData(0, 3, rowNum) - - tdLog.info("===== step 2 =====") - tdSql.execute("create table strm_c3 as select count(*), count(tbcol), count(tbcol2) from tb1 interval(1d)") - - tdLog.info("===== step 3 =====") - tdSql.execute("create table strm_c32 as select count(*), count(tbcol) as c1, count(tbcol2) as c2, count(tbcol) as c3, count(tbcol) as c4, count(tbcol) as c5, count(tbcol) as c6, count(tbcol) as c7, count(tbcol) as c8, count(tbcol) as c9, count(tbcol) as c10, count(tbcol) as c11, count(tbcol) as c12, count(tbcol) as c13, count(tbcol) as c14, count(tbcol) as c15, count(tbcol) as c16, count(tbcol) as c17, count(tbcol) as c18, count(tbcol) as c19, count(tbcol) as c20, count(tbcol) as c21, count(tbcol) as c22, count(tbcol) as c23, count(tbcol) as c24, count(tbcol) as c25, count(tbcol) as c26, count(tbcol) as c27, count(tbcol) as c28, count(tbcol) as c29, count(tbcol) as c30 from tb1 interval(1d)") - - tdLog.info("===== step 4 =====") - tdSql.query("select count(*), count(tbcol) as c1, count(tbcol2) as c2, count(tbcol) as c3, count(tbcol) as c4, count(tbcol) as c5, count(tbcol) as c6, count(tbcol) as c7, count(tbcol) as c8, count(tbcol) as c9, count(tbcol) as c10, count(tbcol) as c11, count(tbcol) as c12, count(tbcol) as c13, count(tbcol) as c14, count(tbcol) as c15, count(tbcol) as c16, count(tbcol) as c17, count(tbcol) as c18, count(tbcol) as c19, count(tbcol) as c20, count(tbcol) as c21, count(tbcol) as c22, count(tbcol) as c23, count(tbcol) as c24, count(tbcol) as c25, count(tbcol) as c26, count(tbcol) as c27, count(tbcol) as c28, count(tbcol) as c29, count(tbcol) as c30 from tb1 interval(1d)") - tdSql.checkData(0, 1, rowNum) - tdSql.checkData(0, 2, rowNum) - tdSql.checkData(0, 3, rowNum) - - tdLog.info("===== step 5 =====") - tdSql.execute("create table strm_c31 as select count(*), count(tbcol) as c1, count(tbcol2) as c2, count(tbcol) as c3, count(tbcol) as c4, count(tbcol) as c5, count(tbcol) as c6, count(tbcol) as c7, count(tbcol) as c8, count(tbcol) as c9, count(tbcol) as c10, count(tbcol) as c11, count(tbcol) as c12, count(tbcol) as c13, count(tbcol) as c14, count(tbcol) as c15, count(tbcol) as c16, count(tbcol) as c17, count(tbcol) as c18, count(tbcol) as c19, count(tbcol) as c20, count(tbcol) as c21, count(tbcol) as c22, count(tbcol) as c23, count(tbcol) as c24, count(tbcol) as c25, count(tbcol) as c26, count(tbcol) as c27, count(tbcol) as c28, count(tbcol) as c29, count(tbcol) as c30 from tb1 interval(1d)") - - tdLog.info("===== step 6 =====") - tdSql.query("select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from tb1 interval(1d)") - tdSql.checkData(0, 1, 9.5) - tdSql.checkData(0, 2, 190) - tdSql.checkData(0, 3, 0) - tdSql.checkData(0, 4, 19) - tdSql.checkData(0, 5, 0) - tdSql.checkData(0, 6, 19) - tdSql.execute("create table strm_avg as select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from tb1 interval(1d)") - - tdLog.info("===== step 7 =====") - tdSql.query("select stddev(tbcol), leastsquares(tbcol, 1, 1), percentile(tbcol, 1) from tb1 interval(1d)") - tdSql.checkData(0, 1, 5.766281297335398) - tdSql.checkData(0, 3, 0.19) - tdSql.execute("create table strm_ot as select stddev(tbcol), leastsquares(tbcol, 1, 1), percentile(tbcol, 1) from tb1 interval(1d)") - - tdLog.info("===== step 8 =====") - tdSql.query("select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol), stddev(tbcol), percentile(tbcol, 1), count(tbcol), leastsquares(tbcol, 1, 1) from tb1 interval(1d)") - tdSql.checkData(0, 1, 9.5) - tdSql.checkData(0, 2, 190) - tdSql.checkData(0, 3, 0) - tdSql.checkData(0, 4, 19) - tdSql.checkData(0, 5, 0) - tdSql.checkData(0, 6, 19) - tdSql.checkData(0, 7, 5.766281297335398) - tdSql.checkData(0, 8, 0.19) - tdSql.checkData(0, 9, rowNum) - tdSql.execute("create table strm_to as select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol), stddev(tbcol), percentile(tbcol, 1), count(tbcol), leastsquares(tbcol, 1, 1) from tb1 interval(1d)") - - tdLog.info("===== step 9 =====") - tdSql.query("select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol), stddev(tbcol), percentile(tbcol, 1), count(tbcol), leastsquares(tbcol, 1, 1) from tb1 where ts < now + 4m interval(1d)") - tdSql.checkData(0, 9, rowNum) - tdSql.execute("create table strm_wh as select avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol), stddev(tbcol), percentile(tbcol, 1), count(tbcol), leastsquares(tbcol, 1, 1) from tb1 where ts < now + 4m interval(1d)") - - tdLog.info("===== step 10 =====") - tdSql.waitedQuery("select * from strm_c3", 1, 120) - tdSql.checkData(0, 1, rowNum) - tdSql.checkData(0, 2, rowNum) - tdSql.checkData(0, 3, rowNum) - - tdLog.info("===== step 11 =====") - tdSql.waitedQuery("select * from strm_c31", 1, 30) - for i in range(1, 10): - tdSql.checkData(0, i, rowNum) - - tdLog.info("===== step 12 =====") - tdSql.waitedQuery("select * from strm_avg", 1, 20) - tdSql.checkData(0, 1, 9.5) - tdSql.checkData(0, 2, 190) - tdSql.checkData(0, 3, 0) - tdSql.checkData(0, 4, 19) - tdSql.checkData(0, 5, 0) - tdSql.checkData(0, 6, 19) - - tdLog.info("===== step 13 =====") - tdSql.waitedQuery("select * from strm_ot", 1, 20) - tdSql.checkData(0, 1, 5.766281297335398) - tdSql.checkData(0, 3, 0.19) - - tdLog.info("===== step 14 =====") - tdSql.waitedQuery("select * from strm_to", 1, 20) - tdSql.checkData(0, 1, 9.5) - tdSql.checkData(0, 2, 190) - tdSql.checkData(0, 3, 0) - tdSql.checkData(0, 4, 19) - tdSql.checkData(0, 5, 0) - tdSql.checkData(0, 6, 19) - tdSql.checkData(0, 7, 5.766281297335398) - tdSql.checkData(0, 8, 0.19) - tdSql.checkData(0, 9, rowNum) - - - def stop(self): - tdSql.close() - tdLog.success("%s successfully executed" % __file__) - - -tdCases.addWindows(__file__, TDTestCase()) -tdCases.addLinux(__file__, TDTestCase()) From e144303190eedf26b037cf4eaf729f0a45655995 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Wed, 25 May 2022 19:13:16 +0800 Subject: [PATCH 35/63] fix(os): run case on win --- source/libs/catalog/src/ctgCache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/catalog/src/ctgCache.c b/source/libs/catalog/src/ctgCache.c index 9aec2588e9..8ed5954cae 100644 --- a/source/libs/catalog/src/ctgCache.c +++ b/source/libs/catalog/src/ctgCache.c @@ -1458,7 +1458,7 @@ _return: } void ctgUpdateThreadFuncUnexpectedStopped(void) { - if (CTG_IS_LOCKED(&gCtgMgmt.lock)) CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock); + if (CTG_IS_LOCKED(&gCtgMgmt.lock) == TD_RWLATCH_WRITE_FLAG_COPY) CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock); } void* ctgUpdateThreadFunc(void* param) { From 91925ffb0859a73c27cc1eba0c77dc6d9f7a4b93 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Wed, 25 May 2022 19:20:02 +0800 Subject: [PATCH 36/63] fix(os): run case on win --- source/libs/catalog/src/ctgCache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/libs/catalog/src/ctgCache.c b/source/libs/catalog/src/ctgCache.c index 8ed5954cae..19b3e5f172 100644 --- a/source/libs/catalog/src/ctgCache.c +++ b/source/libs/catalog/src/ctgCache.c @@ -1463,7 +1463,9 @@ void ctgUpdateThreadFuncUnexpectedStopped(void) { void* ctgUpdateThreadFunc(void* param) { setThreadName("catalog"); +#ifdef WINDOWS atexit(ctgUpdateThreadFuncUnexpectedStopped); +#endif qInfo("catalog update thread started"); CTG_LOCK(CTG_READ, &gCtgMgmt.lock); From f6fb34269fc2a92bc3f73dc759c6943c2ff72514 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Wed, 25 May 2022 19:29:34 +0800 Subject: [PATCH 37/63] fix(os): run case on win --- source/client/src/clientHb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index eca9102bf0..c288b5d2f8 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -588,7 +588,9 @@ void hbThreadFuncUnexpectedStopped(void) { static void *hbThreadFunc(void *param) { setThreadName("hb"); +#ifdef WINDOWS atexit(hbThreadFuncUnexpectedStopped); +#endif while (1) { int8_t threadStop = atomic_val_compare_exchange_8(&clientHbMgr.threadStop, 1, 2); if (1 == threadStop) { From 86c9446a84deb49668ce7968b3acb78dfba97f13 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Wed, 25 May 2022 19:37:52 +0800 Subject: [PATCH 38/63] fix(stream): handle null data --- source/common/src/tdatablock.c | 18 +++++++++++------- source/libs/stream/src/tstream.c | 4 +++- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 816fdab3d2..733693f584 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -350,7 +350,7 @@ int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock, int32_t tsColumnIndex) return -1; } - int32_t index = (tsColumnIndex == -1)? 0:tsColumnIndex; + int32_t index = (tsColumnIndex == -1) ? 0 : tsColumnIndex; SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, index); if (pColInfoData->info.type != TSDB_DATA_TYPE_TIMESTAMP) { return 0; @@ -599,8 +599,8 @@ int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) { } int32_t blockDataFromBuf1(SSDataBlock* pBlock, const char* buf, size_t capacity) { - pBlock->info.rows = *(int32_t*) buf; - pBlock->info.groupId = *(uint64_t*) (buf + sizeof(int32_t)); + pBlock->info.rows = *(int32_t*)buf; + pBlock->info.groupId = *(uint64_t*)(buf + sizeof(int32_t)); int32_t numOfCols = pBlock->info.numOfCols; const char* pStart = buf + sizeof(uint32_t) + sizeof(uint64_t); @@ -669,7 +669,7 @@ size_t blockDataGetSerialMetaSize(const SSDataBlock* pBlock) { return sizeof(int32_t) + sizeof(uint64_t) + pBlock->info.numOfCols * sizeof(int32_t); } -double blockDataGetSerialRowSize(const SSDataBlock* pBlock) { +double blockDataGetSerialRowSize(const SSDataBlock* pBlock) { ASSERT(pBlock != NULL); double rowSize = 0; @@ -1232,7 +1232,7 @@ size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize) { // the true value must be less than the value of nRows int32_t additional = 0; - for(int32_t i = 0; i < pBlock->info.numOfCols; ++i) { + for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) { SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, i); if (IS_VAR_DATA_TYPE(pCol->info.type)) { additional += nRows * sizeof(int32_t); @@ -1728,8 +1728,12 @@ SSubmitReq* tdBlockToSubmit(const SArray* pBlocks, const STSchema* pTSchema, boo for (int32_t k = 0; k < pTSchema->numOfCols; k++) { const STColumn* pColumn = &pTSchema->columns[k]; SColumnInfoData* pColData = taosArrayGet(pDataBlock->pDataBlock, k); - void* data = colDataGetData(pColData, j); - tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, data, true, pColumn->offset, k); + if (colDataIsNull_s(pColData, j)) { + tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NONE, NULL, false, pColumn->offset, k); + } else { + void* data = colDataGetData(pColData, j); + tdAppendColValToRow(&rb, pColumn->colId, pColumn->type, TD_VTYPE_NORM, data, true, pColumn->offset, k); + } } int32_t rowLen = TD_ROW_LEN(rowData); rowData = POINTER_SHIFT(rowData, rowLen); diff --git a/source/libs/stream/src/tstream.c b/source/libs/stream/src/tstream.c index dd7e38a458..933b37825f 100644 --- a/source/libs/stream/src/tstream.c +++ b/source/libs/stream/src/tstream.c @@ -158,7 +158,9 @@ static int32_t streamTaskExecImpl(SStreamTask* pTask, void* data, SArray* pRes) ASSERT(false); } if (output == NULL) break; - taosArrayPush(pRes, output); + // TODO: do we need free memory? + SSDataBlock* outputCopy = createOneDataBlock(output, true); + taosArrayPush(pRes, outputCopy); } // destroy From 704fc2562291ef3a9387b169869d1fa37e1f4807 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Wed, 25 May 2022 19:43:09 +0800 Subject: [PATCH 39/63] fix(os): run case on win --- tests/pytest/test.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/pytest/test.py b/tests/pytest/test.py index 5c9dae688f..af6191e170 100644 --- a/tests/pytest/test.py +++ b/tests/pytest/test.py @@ -148,9 +148,11 @@ if __name__ == "__main__": tdDnodes.deploy(1,{}) tdDnodes.startWin(1) else: - remote_conn = Connection("root@%s"%host) - with remote_conn.cd('/var/lib/jenkins/workspace/TDinternal/community/tests/pytest'): - remote_conn.run("python3 ./test.py") + # remote_conn = Connection("root@%s"%host) + # with remote_conn.cd('/var/lib/jenkins/workspace/TDinternal/community/tests/pytest'): + # remote_conn.run("python3 ./test.py") + os.system("docker exec -d tdengine_test bash -c \"cd ~/TDinternal/community/tests/pytest && python3 ./test.py\"") + time.sleep(2) tdDnodes.init(deployPath) conn = taos.connect( host="%s" % (host), From 18241f7170b3bd9a0d31f2da918a81920117b1ee Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Wed, 25 May 2022 20:24:47 +0800 Subject: [PATCH 40/63] chore: remove out-of-date example --- examples/c/stream.c | 178 -------------------------------------------- 1 file changed, 178 deletions(-) delete mode 100644 examples/c/stream.c diff --git a/examples/c/stream.c b/examples/c/stream.c deleted file mode 100644 index 41365813ae..0000000000 --- a/examples/c/stream.c +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#include -#include -#include -#include -#include -#include "../../../include/client/taos.h" // include TDengine header file - -typedef struct { - char server_ip[64]; - char db_name[64]; - char tbl_name[64]; -} param; - -int g_thread_exit_flag = 0; -void* insert_rows(void *sarg); - -void streamCallBack(void *param, TAOS_RES *res, TAOS_ROW row) -{ - // in this simple demo, it just print out the result - char temp[128]; - - TAOS_FIELD *fields = taos_fetch_fields(res); - int numFields = taos_num_fields(res); - - taos_print_row(temp, row, fields, numFields); - - printf("\n%s\n", temp); -} - -int main(int argc, char *argv[]) -{ - TAOS *taos; - char db_name[64]; - char tbl_name[64]; - char sql[1024] = { 0 }; - - if (argc != 4) { - printf("usage: %s server-ip dbname tblname\n", argv[0]); - exit(0); - } - - strcpy(db_name, argv[2]); - strcpy(tbl_name, argv[3]); - - // create pthread to insert into row per second for stream calc - param *t_param = (param *)malloc(sizeof(param)); - if (NULL == t_param) - { - printf("failed to malloc\n"); - exit(1); - } - memset(t_param, 0, sizeof(param)); - strcpy(t_param->server_ip, argv[1]); - strcpy(t_param->db_name, db_name); - strcpy(t_param->tbl_name, tbl_name); - - pthread_t pid; - pthread_create(&pid, NULL, (void * (*)(void *))insert_rows, t_param); - - sleep(3); // waiting for database is created. - // open connection to database - taos = taos_connect(argv[1], "root", "taosdata", db_name, 0); - if (taos == NULL) { - printf("failed to connet to server:%s\n", argv[1]); - free(t_param); - exit(1); - } - - // starting stream calc, - printf("please input stream SQL:[e.g., select count(*) from tblname interval(5s) sliding(2s);]\n"); - fgets(sql, sizeof(sql), stdin); - if (sql[0] == 0) { - printf("input NULL stream SQL, so exit!\n"); - free(t_param); - exit(1); - } - - // param is set to NULL in this demo, it shall be set to the pointer to app context - TAOS_STREAM *pStream = taos_open_stream(taos, sql, streamCallBack, 0, NULL, NULL); - if (NULL == pStream) { - printf("failed to create stream\n"); - free(t_param); - exit(1); - } - - printf("presss any key to exit\n"); - getchar(); - - taos_close_stream(pStream); - - g_thread_exit_flag = 1; - pthread_join(pid, NULL); - - taos_close(taos); - free(t_param); - - return 0; -} - - -void* insert_rows(void *sarg) -{ - TAOS *taos; - char command[1024] = { 0 }; - param *winfo = (param * )sarg; - - if (NULL == winfo){ - printf("para is null!\n"); - exit(1); - } - - taos = taos_connect(winfo->server_ip, "root", "taosdata", NULL, 0); - if (taos == NULL) { - printf("failed to connet to server:%s\n", winfo->server_ip); - exit(1); - } - - // drop database - sprintf(command, "drop database %s;", winfo->db_name); - if (taos_query(taos, command) != 0) { - printf("failed to drop database, reason:%s\n", taos_errstr(taos)); - exit(1); - } - - // create database - sprintf(command, "create database %s;", winfo->db_name); - if (taos_query(taos, command) != 0) { - printf("failed to create database, reason:%s\n", taos_errstr(taos)); - exit(1); - } - - // use database - sprintf(command, "use %s;", winfo->db_name); - if (taos_query(taos, command) != 0) { - printf("failed to use database, reason:%s\n", taos_errstr(taos)); - exit(1); - } - - // create table - sprintf(command, "create table %s (ts timestamp, speed int);", winfo->tbl_name); - if (taos_query(taos, command) != 0) { - printf("failed to create table, reason:%s\n", taos_errstr(taos)); - exit(1); - } - - // insert data - int64_t begin = (int64_t)time(NULL); - int index = 0; - while (1) { - if (g_thread_exit_flag) break; - - index++; - sprintf(command, "insert into %s values (%ld, %d)", winfo->tbl_name, (begin + index) * 1000, index); - if (taos_query(taos, command)) { - printf("failed to insert row [%s], reason:%s\n", command, taos_errstr(taos)); - } - sleep(1); - } - - taos_close(taos); - return 0; -} - From 5d80e808835b1bbbe8f8e9b2388c424a475f55a3 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 25 May 2022 20:35:49 +0800 Subject: [PATCH 41/63] fix: dump sdb to json --- tests/test/c/sdbDump.c | 61 ++++++++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 26 deletions(-) diff --git a/tests/test/c/sdbDump.c b/tests/test/c/sdbDump.c index 2a19ae778f..d7f50a2fae 100644 --- a/tests/test/c/sdbDump.c +++ b/tests/test/c/sdbDump.c @@ -20,10 +20,13 @@ #include "tconfig.h" #include "tjson.h" -#define TMP_SDB_DATA_DIR "/tmp/dumpsdb" -#define TMP_SDB_MNODE_DIR "/tmp/dumpsdb/mnode" -#define TMP_SDB_FILE "/tmp/dumpsdb/mnode/data/sdb.data" -#define TMP_SDB_PATH "/tmp/dumpsdb/mnode/data" +#define TMP_DNODE_DIR "/tmp/dumpsdb" +#define TMP_MNODE_DIR "/tmp/dumpsdb/mnode" +#define TMP_SDB_DATA_DIR "/tmp/dumpsdb/mnode/data" +#define TMP_SDB_SYNC_DIR "/tmp/dumpsdb/mnode/sync" +#define TMP_SDB_DATA_FILE "/tmp/dumpsdb/mnode/data/sdb.data" +#define TMP_SDB_RAFT_CFG_FILE "/tmp/dumpsdb/mnode/sync/raft_config.json" +#define TMP_SDB_RAFT_STORE_FILE "/tmp/dumpsdb/mnode/sync/raft_store.json" void reportStartup(const char *name, const char *desc) {} @@ -318,6 +321,10 @@ void dumpHeader(SSdb *pSdb, SJson *json) { } int32_t dumpSdb() { + wDebugFlag = 0; + mDebugFlag = 0; + sDebugFlag = 0; + SMsgCb msgCb = {0}; msgCb.reportStartupFp = reportStartup; msgCb.sendReqFp = sendReq; @@ -325,9 +332,10 @@ int32_t dumpSdb() { msgCb.mgmt = (SMgmtWrapper *)(&msgCb); // hack tmsgSetDefault(&msgCb); walInit(); + syncInit(); SMnodeOpt opt = {.msgCb = msgCb}; - SMnode *pMnode = mndOpen(TMP_SDB_MNODE_DIR, &opt); + SMnode *pMnode = mndOpen(TMP_MNODE_DIR, &opt); if (pMnode == NULL) return -1; SSdb *pSdb = pMnode->pSdb; @@ -369,13 +377,11 @@ int32_t dumpSdb() { taosCloseFile(&pFile); tjsonDelete(json); taosMemoryFree(pCont); - taosRemoveDir(TMP_SDB_DATA_DIR); + taosRemoveDir(TMP_DNODE_DIR); return 0; } int32_t parseArgs(int32_t argc, char *argv[]) { - char file[PATH_MAX] = {0}; - for (int32_t i = 1; i < argc; ++i) { if (strcmp(argv[i], "-c") == 0) { if (i < argc - 1) { @@ -388,20 +394,8 @@ int32_t parseArgs(int32_t argc, char *argv[]) { printf("'-c' requires a parameter, default is %s\n", configDir); return -1; } - } else if (strcmp(argv[i], "-f") == 0) { - if (i < argc - 1) { - if (strlen(argv[++i]) >= PATH_MAX) { - printf("file path overflow"); - return -1; - } - tstrncpy(file, argv[i], PATH_MAX); - } else { - printf("'-f' requires a parameter, default is %s\n", configDir); - return -1; - } } else { printf("-c Configuration directory. \n"); - printf("-f Input sdb.data file. \n"); return -1; } } @@ -416,13 +410,28 @@ int32_t parseArgs(int32_t argc, char *argv[]) { return -1; } - if (file[0] == 0) { - snprintf(file, PATH_MAX, "%s/mnode/data/sdb.data", tsDataDir); - } + char dataFile[PATH_MAX] = {0}; + char raftCfgFile[PATH_MAX] = {0}; + char raftStoreFile[PATH_MAX] = {0}; + snprintf(dataFile, PATH_MAX, "%s/mnode/data/sdb.data", tsDataDir); + snprintf(raftCfgFile, PATH_MAX, "%s/mnode/sync/raft_config.json", tsDataDir); + snprintf(raftStoreFile, PATH_MAX, "%s/mnode/sync/raft_store.json", tsDataDir); - strcpy(tsDataDir, TMP_SDB_DATA_DIR); - taosMulMkDir(TMP_SDB_PATH); - taosCopyFile(file, TMP_SDB_FILE); + char cmd[PATH_MAX * 2] = {0}; + snprintf(cmd, sizeof(cmd), "rm -rf %s", TMP_DNODE_DIR); + system(cmd); + snprintf(cmd, sizeof(cmd), "mkdir -p %s", TMP_SDB_DATA_DIR); + system(cmd); + snprintf(cmd, sizeof(cmd), "mkdir -p %s", TMP_SDB_SYNC_DIR); + system(cmd); + snprintf(cmd, sizeof(cmd), "cp %s %s 2>/dev/null", dataFile, TMP_SDB_DATA_FILE); + system(cmd); + snprintf(cmd, sizeof(cmd), "cp %s %s 2>/dev/null", raftCfgFile, TMP_SDB_RAFT_CFG_FILE); + system(cmd); + snprintf(cmd, sizeof(cmd), "cp %s %s 2>/dev/null", raftStoreFile, TMP_SDB_RAFT_STORE_FILE); + system(cmd); + + strcpy(tsDataDir, TMP_DNODE_DIR); return 0; } From 5a15739cc377195cf77aff2e5ce222afcacbac6a Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Wed, 25 May 2022 20:37:00 +0800 Subject: [PATCH 42/63] fix(os): run case on win --- tests/pytest/test.py | 10 +++------- tests/pytest/util/dnodes.py | 4 +--- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/tests/pytest/test.py b/tests/pytest/test.py index af6191e170..9d146462f2 100644 --- a/tests/pytest/test.py +++ b/tests/pytest/test.py @@ -148,17 +148,13 @@ if __name__ == "__main__": tdDnodes.deploy(1,{}) tdDnodes.startWin(1) else: - # remote_conn = Connection("root@%s"%host) - # with remote_conn.cd('/var/lib/jenkins/workspace/TDinternal/community/tests/pytest'): - # remote_conn.run("python3 ./test.py") - os.system("docker exec -d tdengine_test bash -c \"cd ~/TDinternal/community/tests/pytest && python3 ./test.py\"") - time.sleep(2) + remote_conn = Connection("root@%s"%host) + with remote_conn.cd('/var/lib/jenkins/workspace/TDinternal/community/tests/pytest'): + remote_conn.run("python3 ./test.py") tdDnodes.init(deployPath) conn = taos.connect( host="%s" % (host), config=tdDnodes.sim.getCfgDir()) - print(host) - print(tdDnodes.sim.getCfgDir()) tdCases.runOneWindows(conn, fileName) tdCases.logSql(logSql) else: diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index cc02703c4f..12e13c9b5c 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -518,8 +518,7 @@ class TDDnodes: processID = subprocess.check_output( psCmd, shell=True).decode("utf-8") - binPath = os.path.dirname(os.path.realpath(__file__)) - binPath = binPath + "/../../../debug/" + binPath = self.dnodes[0].getPath() + "/../../../" tdLog.debug("binPath %s" % (binPath)) binPath = os.path.realpath(binPath) tdLog.debug("binPath real path %s" % (binPath)) @@ -546,7 +545,6 @@ class TDDnodes: for i in range(len(self.dnodes)): self.dnodes[i].init(self.path) - print(self.path) self.sim = TDSimClient(self.path) def setTestCluster(self, value): From 60b65b9fc9cbdde2000ec3462c95c17b180175d3 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 25 May 2022 20:45:45 +0800 Subject: [PATCH 43/63] refactor: log for apply index --- source/dnode/mnode/impl/src/mndSync.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/dnode/mnode/impl/src/mndSync.c b/source/dnode/mnode/impl/src/mndSync.c index 20d0be0529..aa391ad0d3 100644 --- a/source/dnode/mnode/impl/src/mndSync.c +++ b/source/dnode/mnode/impl/src/mndSync.c @@ -31,7 +31,8 @@ void mndSyncCommitMsg(struct SSyncFSM *pFsm, const SRpcMsg *pMsg, SFsmCbMeta cbM SMnode *pMnode = pFsm->data; SSdbRaw *pRaw = pMsg->pCont; - mTrace("raw:%p, apply to sdb, ver:%" PRId64 " role:%s", pRaw, cbMeta.index, syncStr(cbMeta.state)); + mTrace("raw:%p, apply to sdb, ver:%" PRId64 " term:%" PRId64 " role:%s", pRaw, cbMeta.index, cbMeta.term, + syncStr(cbMeta.state)); sdbWriteWithoutFree(pMnode->pSdb, pRaw); sdbSetApplyIndex(pMnode->pSdb, cbMeta.index); sdbSetApplyTerm(pMnode->pSdb, cbMeta.term); From 55ec2aa008d34c4ea37ede7ffd74dda220dfff38 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Wed, 25 May 2022 20:56:21 +0800 Subject: [PATCH 44/63] catalog async test --- include/libs/catalog/catalog.h | 7 +- include/libs/qcom/query.h | 2 +- source/libs/catalog/inc/catalogInt.h | 2 +- source/libs/catalog/src/catalog.c | 17 ++- source/libs/catalog/src/ctgAsync.c | 188 +++++++++++++------------ source/libs/catalog/src/ctgCache.c | 4 +- source/libs/catalog/src/ctgDbg.c | 70 +++++++-- source/libs/catalog/src/ctgRemote.c | 24 ++-- source/libs/catalog/src/ctgUtil.c | 17 ++- source/libs/parser/src/parTranslater.c | 2 + source/libs/qcom/src/querymsg.c | 30 ++-- 11 files changed, 227 insertions(+), 136 deletions(-) diff --git a/include/libs/catalog/catalog.h b/include/libs/catalog/catalog.h index e64fb4235c..e68d799dc1 100644 --- a/include/libs/catalog/catalog.h +++ b/include/libs/catalog/catalog.h @@ -64,7 +64,7 @@ typedef struct SCatalogReq { } SCatalogReq; typedef struct SMetaData { - SArray *pTableMeta; // SArray + SArray *pTableMeta; // SArray SArray *pDbVgroup; // SArray*> SArray *pTableHash; // SArray SArray *pUdfList; // SArray @@ -248,6 +248,8 @@ int32_t catalogGetTableHashVgroup(SCatalog* pCatalog, void * pTransporter, const */ int32_t catalogGetAllMeta(SCatalog* pCatalog, void *pTransporter, const SEpSet* pMgmtEps, const SCatalogReq* pReq, SMetaData* pRsp); +int32_t catalogAsyncGetAllMeta(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, uint64_t reqId, const SCatalogReq* pReq, catalogCallback fp, void* param, int64_t* jobId); + int32_t catalogGetQnodeList(SCatalog* pCatalog, void *pTransporter, const SEpSet* pMgmtEps, SArray* pQnodeList); int32_t catalogGetExpiredSTables(SCatalog* pCatalog, SSTableMetaVersion **stables, uint32_t *num); @@ -267,6 +269,9 @@ int32_t catalogChkAuth(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const int32_t catalogUpdateUserAuthInfo(SCatalog* pCtg, SGetUserAuthRsp* pAuth); +int32_t ctgdLaunchAsyncCall(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, uint64_t reqId); + + /** * Destroy catalog and relase all resources */ diff --git a/include/libs/qcom/query.h b/include/libs/qcom/query.h index 68a1e08f51..6b1f2903a3 100644 --- a/include/libs/qcom/query.h +++ b/include/libs/qcom/query.h @@ -180,7 +180,7 @@ char* jobTaskStatusStr(int32_t status); SSchema createSchema(int8_t type, int32_t bytes, col_id_t colId, const char* name); -extern int32_t (*queryBuildMsg[TDMT_MAX])(void* input, char** msg, int32_t msgSize, int32_t* msgLen); +extern int32_t (*queryBuildMsg[TDMT_MAX])(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallocFp)(int32_t)); extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t msgSize); #define SET_META_TYPE_NULL(t) (t) = META_TYPE_NULL_TABLE diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index 9f66b6c598..d59bd1c50b 100644 --- a/source/libs/catalog/inc/catalogInt.h +++ b/source/libs/catalog/inc/catalogInt.h @@ -171,7 +171,7 @@ typedef struct SCtgJob { uint64_t queryId; SCatalog* pCtg; void* pTrans; - const SEpSet* pMgmtEps; + SEpSet pMgmtEps; void* userParam; catalogCallback userFp; int32_t tbMetaNum; diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index 4afebf9951..98d40930ac 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -327,28 +327,31 @@ int32_t ctgChkAuth(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const c return TSDB_CODE_SUCCESS; } - SGetUserAuthRsp authRsp = {0}; - CTG_ERR_RET(ctgGetUserDbAuthFromMnode(CTG_PARAMS_LIST(), user, &authRsp, NULL)); + SGetUserAuthRsp* authRsp = taosMemoryCalloc(1, sizeof(SGetUserAuthRsp)); + if (NULL == authRsp) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + CTG_ERR_RET(ctgGetUserDbAuthFromMnode(CTG_PARAMS_LIST(), user, authRsp, NULL)); - if (authRsp.superAuth) { + if (authRsp->superAuth) { *pass = true; goto _return; } - if (authRsp.createdDbs && taosHashGet(authRsp.createdDbs, dbFName, strlen(dbFName))) { + if (authRsp->createdDbs && taosHashGet(authRsp->createdDbs, dbFName, strlen(dbFName))) { *pass = true; goto _return; } - if (type == AUTH_TYPE_READ && authRsp.readDbs && taosHashGet(authRsp.readDbs, dbFName, strlen(dbFName))) { + if (type == AUTH_TYPE_READ && authRsp->readDbs && taosHashGet(authRsp->readDbs, dbFName, strlen(dbFName))) { *pass = true; - } else if (type == AUTH_TYPE_WRITE && authRsp.writeDbs && taosHashGet(authRsp.writeDbs, dbFName, strlen(dbFName))) { + } else if (type == AUTH_TYPE_WRITE && authRsp->writeDbs && taosHashGet(authRsp->writeDbs, dbFName, strlen(dbFName))) { *pass = true; } _return: - ctgPutUpdateUserToQueue(pCtg, &authRsp, false); + ctgPutUpdateUserToQueue(pCtg, authRsp, false); return TSDB_CODE_SUCCESS; } diff --git a/source/libs/catalog/src/ctgAsync.c b/source/libs/catalog/src/ctgAsync.c index 4908dc5101..b3e4bf6d22 100644 --- a/source/libs/catalog/src/ctgAsync.c +++ b/source/libs/catalog/src/ctgAsync.c @@ -21,173 +21,189 @@ #include "tref.h" int32_t ctgInitGetTbMetaTask(SCtgJob *pJob, int32_t taskIdx, SName *name) { - SCtgTask *pTask = taosArrayGet(pJob->pTasks, taskIdx); + SCtgTask task = {0}; - pTask->type = CTG_TASK_GET_TB_META; - pTask->taskId = taskIdx; - pTask->pJob = pJob; + task.type = CTG_TASK_GET_TB_META; + task.taskId = taskIdx; + task.pJob = pJob; - pTask->taskCtx = taosMemoryCalloc(1, sizeof(SCtgTbMetaCtx)); - if (NULL == pTask->taskCtx) { + task.taskCtx = taosMemoryCalloc(1, sizeof(SCtgTbMetaCtx)); + if (NULL == task.taskCtx) { CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } - SCtgTbMetaCtx* ctx = pTask->taskCtx; + SCtgTbMetaCtx* ctx = task.taskCtx; ctx->pName = taosMemoryMalloc(sizeof(*name)); if (NULL == ctx->pName) { - taosMemoryFree(pTask->taskCtx); + taosMemoryFree(task.taskCtx); CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } memcpy(ctx->pName, name, sizeof(*name)); ctx->flag = CTG_FLAG_UNKNOWN_STB; - qDebug("QID:%" PRIx64 " task %d type %d initialized, tableName:%s", pJob->queryId, taskIdx, pTask->type, name->tname); + taosArrayPush(pJob->pTasks, &task); + + qDebug("QID:%" PRIx64 " task %d type %d initialized, tableName:%s", pJob->queryId, taskIdx, task.type, name->tname); return TSDB_CODE_SUCCESS; } int32_t ctgInitGetDbVgTask(SCtgJob *pJob, int32_t taskIdx, char *dbFName) { - SCtgTask *pTask = taosArrayGet(pJob->pTasks, taskIdx); + SCtgTask task = {0}; - pTask->type = CTG_TASK_GET_DB_VGROUP; - pTask->taskId = taskIdx; - pTask->pJob = pJob; + task.type = CTG_TASK_GET_DB_VGROUP; + task.taskId = taskIdx; + task.pJob = pJob; - pTask->taskCtx = taosMemoryCalloc(1, sizeof(SCtgDbVgCtx)); - if (NULL == pTask->taskCtx) { + task.taskCtx = taosMemoryCalloc(1, sizeof(SCtgDbVgCtx)); + if (NULL == task.taskCtx) { CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } - SCtgDbVgCtx* ctx = pTask->taskCtx; + SCtgDbVgCtx* ctx = task.taskCtx; memcpy(ctx->dbFName, dbFName, sizeof(ctx->dbFName)); - qDebug("QID:%" PRIx64 " task %d type %d initialized, dbFName:%s", pJob->queryId, taskIdx, pTask->type, dbFName); + taosArrayPush(pJob->pTasks, &task); + + qDebug("QID:%" PRIx64 " task %d type %d initialized, dbFName:%s", pJob->queryId, taskIdx, task.type, dbFName); return TSDB_CODE_SUCCESS; } int32_t ctgInitGetDbCfgTask(SCtgJob *pJob, int32_t taskIdx, char *dbFName) { - SCtgTask *pTask = taosArrayGet(pJob->pTasks, taskIdx); + SCtgTask task = {0}; - pTask->type = CTG_TASK_GET_DB_CFG; - pTask->taskId = taskIdx; - pTask->pJob = pJob; + task.type = CTG_TASK_GET_DB_CFG; + task.taskId = taskIdx; + task.pJob = pJob; - pTask->taskCtx = taosMemoryCalloc(1, sizeof(SCtgDbCfgCtx)); - if (NULL == pTask->taskCtx) { + task.taskCtx = taosMemoryCalloc(1, sizeof(SCtgDbCfgCtx)); + if (NULL == task.taskCtx) { CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } - SCtgDbCfgCtx* ctx = pTask->taskCtx; + SCtgDbCfgCtx* ctx = task.taskCtx; memcpy(ctx->dbFName, dbFName, sizeof(ctx->dbFName)); - qDebug("QID:%" PRIx64 " task %d type %d initialized, dbFName:%s", pJob->queryId, taskIdx, pTask->type, dbFName); + taosArrayPush(pJob->pTasks, &task); + + qDebug("QID:%" PRIx64 " task %d type %d initialized, dbFName:%s", pJob->queryId, taskIdx, task.type, dbFName); return TSDB_CODE_SUCCESS; } int32_t ctgInitGetTbHashTask(SCtgJob *pJob, int32_t taskIdx, SName *name) { - SCtgTask *pTask = taosArrayGet(pJob->pTasks, taskIdx); + SCtgTask task = {0}; - pTask->type = CTG_TASK_GET_TB_HASH; - pTask->taskId = taskIdx; - pTask->pJob = pJob; + task.type = CTG_TASK_GET_TB_HASH; + task.taskId = taskIdx; + task.pJob = pJob; - pTask->taskCtx = taosMemoryCalloc(1, sizeof(SCtgTbHashCtx)); - if (NULL == pTask->taskCtx) { + task.taskCtx = taosMemoryCalloc(1, sizeof(SCtgTbHashCtx)); + if (NULL == task.taskCtx) { CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } - SCtgTbHashCtx* ctx = pTask->taskCtx; + SCtgTbHashCtx* ctx = task.taskCtx; ctx->pName = taosMemoryMalloc(sizeof(*name)); if (NULL == ctx->pName) { - taosMemoryFree(pTask->taskCtx); + taosMemoryFree(task.taskCtx); CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } memcpy(ctx->pName, name, sizeof(*name)); tNameGetFullDbName(ctx->pName, ctx->dbFName); - qDebug("QID:%" PRIx64 " task %d type %d initialized, tableName:%s", pJob->queryId, taskIdx, pTask->type, name->tname); + taosArrayPush(pJob->pTasks, &task); + + qDebug("QID:%" PRIx64 " task %d type %d initialized, tableName:%s", pJob->queryId, taskIdx, task.type, name->tname); return TSDB_CODE_SUCCESS; } int32_t ctgInitGetQnodeTask(SCtgJob *pJob, int32_t taskIdx) { - SCtgTask *pTask = taosArrayGet(pJob->pTasks, taskIdx); + SCtgTask task = {0}; - pTask->type = CTG_TASK_GET_QNODE; - pTask->taskId = taskIdx; - pTask->pJob = pJob; - pTask->taskCtx = NULL; + task.type = CTG_TASK_GET_QNODE; + task.taskId = taskIdx; + task.pJob = pJob; + task.taskCtx = NULL; - qDebug("QID:%" PRIx64 " task %d type %d initialized", pJob->queryId, taskIdx, pTask->type); + taosArrayPush(pJob->pTasks, &task); + + qDebug("QID:%" PRIx64 " task %d type %d initialized", pJob->queryId, taskIdx, task.type); return TSDB_CODE_SUCCESS; } int32_t ctgInitGetIndexTask(SCtgJob *pJob, int32_t taskIdx, char *name) { - SCtgTask *pTask = taosArrayGet(pJob->pTasks, taskIdx); + SCtgTask task = {0}; - pTask->type = CTG_TASK_GET_INDEX; - pTask->taskId = taskIdx; - pTask->pJob = pJob; + task.type = CTG_TASK_GET_INDEX; + task.taskId = taskIdx; + task.pJob = pJob; - pTask->taskCtx = taosMemoryCalloc(1, sizeof(SCtgIndexCtx)); - if (NULL == pTask->taskCtx) { + task.taskCtx = taosMemoryCalloc(1, sizeof(SCtgIndexCtx)); + if (NULL == task.taskCtx) { CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } - SCtgIndexCtx* ctx = pTask->taskCtx; + SCtgIndexCtx* ctx = task.taskCtx; strcpy(ctx->indexFName, name); - qDebug("QID:%" PRIx64 " task %d type %d initialized, indexFName:%s", pJob->queryId, taskIdx, pTask->type, name); + taosArrayPush(pJob->pTasks, &task); + + qDebug("QID:%" PRIx64 " task %d type %d initialized, indexFName:%s", pJob->queryId, taskIdx, task.type, name); return TSDB_CODE_SUCCESS; } int32_t ctgInitGetUdfTask(SCtgJob *pJob, int32_t taskIdx, char *name) { - SCtgTask *pTask = taosArrayGet(pJob->pTasks, taskIdx); + SCtgTask task = {0}; - pTask->type = CTG_TASK_GET_UDF; - pTask->taskId = taskIdx; - pTask->pJob = pJob; + task.type = CTG_TASK_GET_UDF; + task.taskId = taskIdx; + task.pJob = pJob; - pTask->taskCtx = taosMemoryCalloc(1, sizeof(SCtgUdfCtx)); - if (NULL == pTask->taskCtx) { + task.taskCtx = taosMemoryCalloc(1, sizeof(SCtgUdfCtx)); + if (NULL == task.taskCtx) { CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } - SCtgUdfCtx* ctx = pTask->taskCtx; + SCtgUdfCtx* ctx = task.taskCtx; strcpy(ctx->udfName, name); - qDebug("QID:%" PRIx64 " task %d type %d initialized, udfName:%s", pJob->queryId, taskIdx, pTask->type, name); + taosArrayPush(pJob->pTasks, &task); + + qDebug("QID:%" PRIx64 " task %d type %d initialized, udfName:%s", pJob->queryId, taskIdx, task.type, name); return TSDB_CODE_SUCCESS; } int32_t ctgInitGetUserTask(SCtgJob *pJob, int32_t taskIdx, SUserAuthInfo *user) { - SCtgTask *pTask = taosArrayGet(pJob->pTasks, taskIdx); + SCtgTask task = {0}; - pTask->type = CTG_TASK_GET_USER; - pTask->taskId = taskIdx; - pTask->pJob = pJob; + task.type = CTG_TASK_GET_USER; + task.taskId = taskIdx; + task.pJob = pJob; - pTask->taskCtx = taosMemoryCalloc(1, sizeof(SCtgUserCtx)); - if (NULL == pTask->taskCtx) { + task.taskCtx = taosMemoryCalloc(1, sizeof(SCtgUserCtx)); + if (NULL == task.taskCtx) { CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } - SCtgUserCtx* ctx = pTask->taskCtx; + SCtgUserCtx* ctx = task.taskCtx; memcpy(&ctx->user, user, sizeof(*user)); - qDebug("QID:%" PRIx64 " task %d type %d initialized, user:%s", pJob->queryId, taskIdx, pTask->type, user->user); + taosArrayPush(pJob->pTasks, &task); + + qDebug("QID:%" PRIx64 " task %d type %d initialized, user:%s", pJob->queryId, taskIdx, task.type, user->user); return TSDB_CODE_SUCCESS; } @@ -222,7 +238,7 @@ int32_t ctgInitJob(CTG_PARAMS, SCtgJob** job, uint64_t reqId, const SCatalogReq* pJob->userFp = fp; pJob->pCtg = pCtg; pJob->pTrans = pTrans; - pJob->pMgmtEps = pMgmtEps; + pJob->pMgmtEps = *pMgmtEps; pJob->userParam = param; pJob->tbMetaNum = tbMetaNum; @@ -303,15 +319,13 @@ _return: int32_t ctgDumpTbMetaRes(SCtgTask* pTask) { SCtgJob* pJob = pTask->pJob; if (NULL == pJob->jobRes.pTableMeta) { - pJob->jobRes.pTableMeta = taosArrayInit(pJob->tbMetaNum, sizeof(STableMeta)); + pJob->jobRes.pTableMeta = taosArrayInit(pJob->tbMetaNum, POINTER_BYTES); if (NULL == pJob->jobRes.pTableMeta) { CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } } - taosArrayPush(pJob->jobRes.pTableMeta, pTask->res); - - taosMemoryFreeClear(pTask->res); + taosArrayPush(pJob->jobRes.pTableMeta, &pTask->res); return TSDB_CODE_SUCCESS; } @@ -340,7 +354,7 @@ int32_t ctgDumpTbHashRes(SCtgTask* pTask) { } } - taosArrayPush(pJob->jobRes.pTableHash, &pTask->res); + taosArrayPush(pJob->jobRes.pTableHash, pTask->res); return TSDB_CODE_SUCCESS; } @@ -376,7 +390,7 @@ int32_t ctgDumpDbCfgRes(SCtgTask* pTask) { } } - taosArrayPush(pJob->jobRes.pDbCfg, &pTask->res); + taosArrayPush(pJob->jobRes.pDbCfg, pTask->res); return TSDB_CODE_SUCCESS; } @@ -451,7 +465,7 @@ int32_t ctgHandleGetTbMetaRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf * SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx; SCatalog* pCtg = pTask->pJob->pCtg; void *pTrans = pTask->pJob->pTrans; - const SEpSet* pMgmtEps = pTask->pJob->pMgmtEps; + const SEpSet* pMgmtEps = &pTask->pJob->pMgmtEps; switch (reqType) { case TDMT_MND_USE_DB: { @@ -529,7 +543,7 @@ int32_t ctgHandleGetTbMetaRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf * taosMemoryFreeClear(pOut->tbMeta); - CTG_ERR_JRET(ctgGetTbMetaFromMnode(CTG_PARAMS_LIST(), ctx->pName, NULL, pTask)); + CTG_RET(ctgGetTbMetaFromMnode(CTG_PARAMS_LIST(), ctx->pName, NULL, pTask)); } else if (CTG_IS_META_BOTH(pOut->metaType)) { int32_t exist = 0; if (!CTG_FLAG_IS_FORCE_UPDATE(ctx->flag)) { @@ -538,7 +552,7 @@ int32_t ctgHandleGetTbMetaRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf * if (0 == exist) { TSWAP(pTask->msgCtx.lastOut, pTask->msgCtx.out); - CTG_ERR_JRET(ctgGetTbMetaFromMnodeImpl(CTG_PARAMS_LIST(), pOut->dbFName, pOut->tbName, NULL, pTask)); + CTG_RET(ctgGetTbMetaFromMnodeImpl(CTG_PARAMS_LIST(), pOut->dbFName, pOut->tbName, NULL, pTask)); } else { taosMemoryFreeClear(pOut->tbMeta); @@ -598,7 +612,7 @@ int32_t ctgHandleGetDbVgRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pM SCtgDbVgCtx* ctx = (SCtgDbVgCtx*)pTask->taskCtx; SCatalog* pCtg = pTask->pJob->pCtg; void *pTrans = pTask->pJob->pTrans; - const SEpSet* pMgmtEps = pTask->pJob->pMgmtEps; + const SEpSet* pMgmtEps = &pTask->pJob->pMgmtEps; switch (reqType) { case TDMT_MND_USE_DB: { @@ -632,7 +646,7 @@ int32_t ctgHandleGetTbHashRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf * SCtgTbHashCtx* ctx = (SCtgTbHashCtx*)pTask->taskCtx; SCatalog* pCtg = pTask->pJob->pCtg; void *pTrans = pTask->pJob->pTrans; - const SEpSet* pMgmtEps = pTask->pJob->pMgmtEps; + const SEpSet* pMgmtEps = &pTask->pJob->pMgmtEps; switch (reqType) { case TDMT_MND_USE_DB: { @@ -724,7 +738,7 @@ int32_t ctgHandleGetUserRsp(SCtgTask* pTask, int32_t reqType, const SDataBuf *pM SCtgUserCtx* ctx = (SCtgUserCtx*)pTask->taskCtx; SCatalog* pCtg = pTask->pJob->pCtg; void *pTrans = pTask->pJob->pTrans; - const SEpSet* pMgmtEps = pTask->pJob->pMgmtEps; + const SEpSet* pMgmtEps = &pTask->pJob->pMgmtEps; bool pass = false; SGetUserAuthRsp* pOut = (SGetUserAuthRsp*)pTask->msgCtx.out; @@ -766,7 +780,7 @@ _return: int32_t ctgAsyncRefreshTbMeta(SCtgTask *pTask) { SCatalog* pCtg = pTask->pJob->pCtg; void *pTrans = pTask->pJob->pTrans; - const SEpSet* pMgmtEps = pTask->pJob->pMgmtEps; + const SEpSet* pMgmtEps = &pTask->pJob->pMgmtEps; int32_t code = 0; SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx; @@ -788,7 +802,7 @@ int32_t ctgAsyncRefreshTbMeta(SCtgTask *pTask) { tNameGetFullDbName(ctx->pName, dbFName); CTG_ERR_RET(ctgAcquireVgInfoFromCache(pCtg, dbFName, &dbCache)); - if (NULL == dbCache) { + if (dbCache) { SVgroupInfo vgInfo = {0}; CTG_ERR_RET(ctgGetVgInfoFromHashValue(pCtg, dbCache->vgInfo, ctx->pName, &vgInfo)); @@ -817,7 +831,7 @@ _return: int32_t ctgLaunchGetTbMetaTask(SCtgTask *pTask) { SCatalog* pCtg = pTask->pJob->pCtg; void *pTrans = pTask->pJob->pTrans; - const SEpSet* pMgmtEps = pTask->pJob->pMgmtEps; + const SEpSet* pMgmtEps = &pTask->pJob->pMgmtEps; CTG_ERR_RET(ctgGetTbMetaFromCache(CTG_PARAMS_LIST(), (SCtgTbMetaCtx*)pTask->taskCtx, (STableMeta**)&pTask->res)); if (pTask->res) { @@ -834,7 +848,7 @@ int32_t ctgLaunchGetDbVgTask(SCtgTask *pTask) { int32_t code = 0; SCatalog* pCtg = pTask->pJob->pCtg; void *pTrans = pTask->pJob->pTrans; - const SEpSet* pMgmtEps = pTask->pJob->pMgmtEps; + const SEpSet* pMgmtEps = &pTask->pJob->pMgmtEps; SCtgDBCache *dbCache = NULL; SCtgDbVgCtx* pCtx = (SCtgDbVgCtx*)pTask->taskCtx; @@ -866,7 +880,7 @@ int32_t ctgLaunchGetTbHashTask(SCtgTask *pTask) { int32_t code = 0; SCatalog* pCtg = pTask->pJob->pCtg; void *pTrans = pTask->pJob->pTrans; - const SEpSet* pMgmtEps = pTask->pJob->pMgmtEps; + const SEpSet* pMgmtEps = &pTask->pJob->pMgmtEps; SCtgDBCache *dbCache = NULL; SCtgTbHashCtx* pCtx = (SCtgTbHashCtx*)pTask->taskCtx; @@ -901,7 +915,7 @@ _return: int32_t ctgLaunchGetQnodeTask(SCtgTask *pTask) { SCatalog* pCtg = pTask->pJob->pCtg; void *pTrans = pTask->pJob->pTrans; - const SEpSet* pMgmtEps = pTask->pJob->pMgmtEps; + const SEpSet* pMgmtEps = &pTask->pJob->pMgmtEps; CTG_ERR_RET(ctgGetQnodeListFromMnode(CTG_PARAMS_LIST(), NULL, pTask)); @@ -911,7 +925,7 @@ int32_t ctgLaunchGetQnodeTask(SCtgTask *pTask) { int32_t ctgLaunchGetDbCfgTask(SCtgTask *pTask) { SCatalog* pCtg = pTask->pJob->pCtg; void *pTrans = pTask->pJob->pTrans; - const SEpSet* pMgmtEps = pTask->pJob->pMgmtEps; + const SEpSet* pMgmtEps = &pTask->pJob->pMgmtEps; SCtgDbCfgCtx* pCtx = (SCtgDbCfgCtx*)pTask->taskCtx; CTG_ERR_RET(ctgGetDBCfgFromMnode(CTG_PARAMS_LIST(), pCtx->dbFName, NULL, pTask)); @@ -922,7 +936,7 @@ int32_t ctgLaunchGetDbCfgTask(SCtgTask *pTask) { int32_t ctgLaunchGetIndexTask(SCtgTask *pTask) { SCatalog* pCtg = pTask->pJob->pCtg; void *pTrans = pTask->pJob->pTrans; - const SEpSet* pMgmtEps = pTask->pJob->pMgmtEps; + const SEpSet* pMgmtEps = &pTask->pJob->pMgmtEps; SCtgIndexCtx* pCtx = (SCtgIndexCtx*)pTask->taskCtx; CTG_ERR_RET(ctgGetIndexInfoFromMnode(CTG_PARAMS_LIST(), pCtx->indexFName, NULL, pTask)); @@ -933,7 +947,7 @@ int32_t ctgLaunchGetIndexTask(SCtgTask *pTask) { int32_t ctgLaunchGetUdfTask(SCtgTask *pTask) { SCatalog* pCtg = pTask->pJob->pCtg; void *pTrans = pTask->pJob->pTrans; - const SEpSet* pMgmtEps = pTask->pJob->pMgmtEps; + const SEpSet* pMgmtEps = &pTask->pJob->pMgmtEps; SCtgUdfCtx* pCtx = (SCtgUdfCtx*)pTask->taskCtx; CTG_ERR_RET(ctgGetUdfInfoFromMnode(CTG_PARAMS_LIST(), pCtx->udfName, NULL, pTask)); @@ -944,7 +958,7 @@ int32_t ctgLaunchGetUdfTask(SCtgTask *pTask) { int32_t ctgLaunchGetUserTask(SCtgTask *pTask) { SCatalog* pCtg = pTask->pJob->pCtg; void *pTrans = pTask->pJob->pTrans; - const SEpSet* pMgmtEps = pTask->pJob->pMgmtEps; + const SEpSet* pMgmtEps = &pTask->pJob->pMgmtEps; SCtgUserCtx* pCtx = (SCtgUserCtx*)pTask->taskCtx; bool inCache = false; bool pass = false; diff --git a/source/libs/catalog/src/ctgCache.c b/source/libs/catalog/src/ctgCache.c index 6335a056b9..27cd41eed5 100644 --- a/source/libs/catalog/src/ctgCache.c +++ b/source/libs/catalog/src/ctgCache.c @@ -248,7 +248,7 @@ int32_t ctgReadTbMetaFromCache(SCatalog* pCtg, SCtgTbMetaCtx* ctx, STableMeta** ctgAcquireDBCache(pCtg, dbFName, &dbCache); if (NULL == dbCache) { - ctgDebug("db %s not in cache", ctx->pName->tname); + ctgDebug("db %d.%s not in cache", ctx->pName->acctId, ctx->pName->dbname); return TSDB_CODE_SUCCESS; } @@ -716,6 +716,8 @@ int32_t ctgPutUpdateUserToQueue(SCatalog* pCtg, SGetUserAuthRsp *pAuth, bool syn CTG_ERR_JRET(ctgPushAction(pCtg, &action)); + taosMemoryFree(pAuth); + return TSDB_CODE_SUCCESS; _return: diff --git a/source/libs/catalog/src/ctgDbg.c b/source/libs/catalog/src/ctgDbg.c index 9897370f2d..849c66fd12 100644 --- a/source/libs/catalog/src/ctgDbg.c +++ b/source/libs/catalog/src/ctgDbg.c @@ -25,9 +25,9 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) { ASSERT(*(int32_t*)param == 1); taosMemoryFree(param); - ctgDebug("async call result: %s", tstrerror(code)); + qDebug("async call result: %s", tstrerror(code)); if (NULL == pResult) { - ctgDebug("empty meta result"); + qDebug("empty meta result"); return; } @@ -36,25 +36,24 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) { if (pResult->pTableMeta && taosArrayGetSize(pResult->pTableMeta) > 0) { num = taosArrayGetSize(pResult->pTableMeta); for (int32_t i = 0; i < num; ++i) { - STableMeta *p = taosArrayGet(pResult->pTableMeta, i); + STableMeta *p = *(STableMeta **)taosArrayGet(pResult->pTableMeta, i); STableComInfo *c = &p->tableInfo; if (TSDB_CHILD_TABLE == p->tableType) { - ctgDebug("table meta: type:%d, vgId:%d, uid:%" PRIx64 ",suid:%" PRIx64, p->tableType, p->vgId, p->uid, p->suid); - return; + qDebug("table meta: type:%d, vgId:%d, uid:%" PRIx64 ",suid:%" PRIx64, p->tableType, p->vgId, p->uid, p->suid); } else { - ctgDebug("table meta: type:%d, vgId:%d, uid:%" PRIx64 ",suid:%" PRIx64 ",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d", + qDebug("table meta: type:%d, vgId:%d, uid:%" PRIx64 ",suid:%" PRIx64 ",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d", p->tableType, p->vgId, p->uid, p->suid, p->sversion, p->tversion, c->numOfTags, c->precision, c->numOfColumns, c->rowSize); } int32_t colNum = c->numOfColumns + c->numOfTags; for (int32_t j = 0; j < colNum; ++j) { SSchema *s = &p->schema[j]; - ctgDebug("[%d] name:%s, type:%d, colId:%d, bytes:%d", j, s->name, s->type, s->colId, s->bytes); + qDebug("[%d] name:%s, type:%d, colId:%d, bytes:%d", j, s->name, s->type, s->colId, s->bytes); } } } else { - ctgDebug("empty table meta"); + qDebug("empty table meta"); } if (pResult->pDbVgroup && taosArrayGetSize(pResult->pDbVgroup) > 0) { @@ -62,14 +61,65 @@ void ctgdUserCallback(SMetaData* pResult, void* param, int32_t code) { for (int32_t i = 0; i < num; ++i) { SArray *pDb = *(SArray**)taosArrayGet(pResult->pDbVgroup, i); int32_t vgNum = taosArrayGetSize(pDb); + qDebug("db %d vgInfo:", i); for (int32_t j = 0; j < vgNum; ++j) { SVgroupInfo* pInfo = taosArrayGet(pDb, j); - ctgDebug(param, ...); + qDebug("vg %d info: vgId:%d", j, pInfo->vgId); } } } else { - ctgDebug("empty db vgroup"); + qDebug("empty db vgroup"); } + + if (pResult->pTableHash && taosArrayGetSize(pResult->pTableHash) > 0) { + num = taosArrayGetSize(pResult->pTableHash); + for (int32_t i = 0; i < num; ++i) { + SVgroupInfo* pInfo = taosArrayGet(pResult->pTableHash, i); + qDebug("table %d vg info: vgId:%d", i, pInfo->vgId); + } + } else { + qDebug("empty table hash vgroup"); + } + + if (pResult->pUdfList && taosArrayGetSize(pResult->pUdfList) > 0) { + num = taosArrayGetSize(pResult->pUdfList); + for (int32_t i = 0; i < num; ++i) { + SFuncInfo* pInfo = taosArrayGet(pResult->pUdfList, i); + qDebug("udf %d info: name:%s, funcType:%d", i, pInfo->name, pInfo->funcType); + } + } else { + qDebug("empty udf info"); + } + + if (pResult->pDbCfg && taosArrayGetSize(pResult->pDbCfg) > 0) { + num = taosArrayGetSize(pResult->pDbCfg); + for (int32_t i = 0; i < num; ++i) { + SDbCfgInfo* pInfo = taosArrayGet(pResult->pDbCfg, i); + qDebug("db %d info: numOFVgroups:%d, numOfStables:%d", i, pInfo->numOfVgroups, pInfo->numOfStables); + } + } else { + qDebug("empty db cfg info"); + } + + if (pResult->pUser && taosArrayGetSize(pResult->pUser) > 0) { + num = taosArrayGetSize(pResult->pUser); + for (int32_t i = 0; i < num; ++i) { + bool* auth = taosArrayGet(pResult->pUser, i); + qDebug("user auth %d info: %d", i, *auth); + } + } else { + qDebug("empty user auth info"); + } + + if (pResult->pQnodeList && taosArrayGetSize(pResult->pQnodeList) > 0) { + num = taosArrayGetSize(pResult->pQnodeList); + for (int32_t i = 0; i < num; ++i) { + SQueryNodeAddr* qaddr = taosArrayGet(pResult->pQnodeList, i); + qDebug("qnode %d info: id:%d", i, qaddr->nodeId); + } + } else { + qDebug("empty qnode info"); + } } int32_t ctgdLaunchAsyncCall(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, uint64_t reqId) { diff --git a/source/libs/catalog/src/ctgRemote.c b/source/libs/catalog/src/ctgRemote.c index 9e86b863f4..4def1fff4f 100644 --- a/source/libs/catalog/src/ctgRemote.c +++ b/source/libs/catalog/src/ctgRemote.c @@ -264,10 +264,11 @@ int32_t ctgGetQnodeListFromMnode(CTG_PARAMS, SArray *out, SCtgTask* pTask) { char *msg = NULL; int32_t msgLen = 0; int32_t reqType = TDMT_MND_QNODE_LIST; + void*(*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; ctgDebug("try to get qnode list from mnode, mgmtEpInUse:%d", pMgmtEps->inUse); - int32_t code = queryBuildMsg[TMSG_INDEX(reqType)](NULL, &msg, 0, &msgLen); + int32_t code = queryBuildMsg[TMSG_INDEX(reqType)](NULL, &msg, 0, &msgLen, mallocFp); if (code) { ctgError("Build qnode list msg failed, error:%s", tstrerror(code)); CTG_ERR_RET(code); @@ -301,10 +302,11 @@ int32_t ctgGetDBVgInfoFromMnode(CTG_PARAMS, SBuildUseDBInput *input, SUseDbOutpu char *msg = NULL; int32_t msgLen = 0; int32_t reqType = TDMT_MND_USE_DB; + void*(*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; ctgDebug("try to get db vgInfo from mnode, dbFName:%s", input->db); - int32_t code = queryBuildMsg[TMSG_INDEX(reqType)](input, &msg, 0, &msgLen); + int32_t code = queryBuildMsg[TMSG_INDEX(reqType)](input, &msg, 0, &msgLen, mallocFp); if (code) { ctgError("Build use db msg failed, code:%x, db:%s", code, input->db); CTG_ERR_RET(code); @@ -338,10 +340,11 @@ int32_t ctgGetDBCfgFromMnode(CTG_PARAMS, const char *dbFName, SDbCfgInfo *out, S char *msg = NULL; int32_t msgLen = 0; int32_t reqType = TDMT_MND_GET_DB_CFG; + void*(*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; ctgDebug("try to get db cfg from mnode, dbFName:%s", dbFName); - int32_t code = queryBuildMsg[TMSG_INDEX(reqType)]((void *)dbFName, &msg, 0, &msgLen); + int32_t code = queryBuildMsg[TMSG_INDEX(reqType)]((void *)dbFName, &msg, 0, &msgLen, mallocFp); if (code) { ctgError("Build get db cfg msg failed, code:%x, db:%s", code, dbFName); CTG_ERR_RET(code); @@ -375,10 +378,11 @@ int32_t ctgGetIndexInfoFromMnode(CTG_PARAMS, const char *indexName, SIndexInfo * char *msg = NULL; int32_t msgLen = 0; int32_t reqType = TDMT_MND_GET_INDEX; + void*(*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; ctgDebug("try to get index from mnode, indexName:%s", indexName); - int32_t code = queryBuildMsg[TMSG_INDEX(reqType)]((void *)indexName, &msg, 0, &msgLen); + int32_t code = queryBuildMsg[TMSG_INDEX(reqType)]((void *)indexName, &msg, 0, &msgLen, mallocFp); if (code) { ctgError("Build get index msg failed, code:%x, db:%s", code, indexName); CTG_ERR_RET(code); @@ -412,10 +416,11 @@ int32_t ctgGetUdfInfoFromMnode(CTG_PARAMS, const char *funcName, SFuncInfo *out, char *msg = NULL; int32_t msgLen = 0; int32_t reqType = TDMT_MND_RETRIEVE_FUNC; + void*(*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; ctgDebug("try to get udf info from mnode, funcName:%s", funcName); - int32_t code = queryBuildMsg[TMSG_INDEX(reqType)]((void *)funcName, &msg, 0, &msgLen); + int32_t code = queryBuildMsg[TMSG_INDEX(reqType)]((void *)funcName, &msg, 0, &msgLen, mallocFp); if (code) { ctgError("Build get udf msg failed, code:%x, db:%s", code, funcName); CTG_ERR_RET(code); @@ -449,10 +454,11 @@ int32_t ctgGetUserDbAuthFromMnode(CTG_PARAMS, const char *user, SGetUserAuthRsp char *msg = NULL; int32_t msgLen = 0; int32_t reqType = TDMT_MND_GET_USER_AUTH; + void*(*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; ctgDebug("try to get user auth from mnode, user:%s", user); - int32_t code = queryBuildMsg[TMSG_INDEX(reqType)]((void *)user, &msg, 0, &msgLen); + int32_t code = queryBuildMsg[TMSG_INDEX(reqType)]((void *)user, &msg, 0, &msgLen, mallocFp); if (code) { ctgError("Build get user auth msg failed, code:%x, db:%s", code, user); CTG_ERR_RET(code); @@ -491,10 +497,11 @@ int32_t ctgGetTbMetaFromMnodeImpl(CTG_PARAMS, char *dbFName, char* tbName, STabl int32_t reqType = TDMT_MND_TABLE_META; char tbFName[TSDB_TABLE_FNAME_LEN]; sprintf(tbFName, "%s.%s", dbFName, tbName); + void*(*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; ctgDebug("try to get table meta from mnode, tbFName:%s", tbFName); - int32_t code = queryBuildMsg[TMSG_INDEX(reqType)](&bInput, &msg, 0, &msgLen); + int32_t code = queryBuildMsg[TMSG_INDEX(reqType)](&bInput, &msg, 0, &msgLen, mallocFp); if (code) { ctgError("Build mnode stablemeta msg failed, code:%x", code); CTG_ERR_RET(code); @@ -537,6 +544,7 @@ int32_t ctgGetTbMetaFromVnode(CTG_PARAMS, const SName* pTableName, SVgroupInfo * int32_t reqType = TDMT_VND_TABLE_META; char tbFName[TSDB_TABLE_FNAME_LEN]; sprintf(tbFName, "%s.%s", dbFName, pTableName->tname); + void*(*mallocFp)(int32_t) = pTask ? taosMemoryMalloc : rpcMallocCont; ctgDebug("try to get table meta from vnode, vgId:%d, tbFName:%s", vgroupInfo->vgId, tbFName); @@ -544,7 +552,7 @@ int32_t ctgGetTbMetaFromVnode(CTG_PARAMS, const SName* pTableName, SVgroupInfo * char *msg = NULL; int32_t msgLen = 0; - int32_t code = queryBuildMsg[TMSG_INDEX(reqType)](&bInput, &msg, 0, &msgLen); + int32_t code = queryBuildMsg[TMSG_INDEX(reqType)](&bInput, &msg, 0, &msgLen, mallocFp); if (code) { ctgError("Build vnode tablemeta msg failed, code:%x, tbFName:%s", code, tbFName); CTG_ERR_RET(code); diff --git a/source/libs/catalog/src/ctgUtil.c b/source/libs/catalog/src/ctgUtil.c index 2d7fb8aa97..1f78a97733 100644 --- a/source/libs/catalog/src/ctgUtil.c +++ b/source/libs/catalog/src/ctgUtil.c @@ -35,7 +35,7 @@ void ctgFreeSMetaData(SMetaData* pData) { taosArrayDestroy(pData->pUdfList); pData->pUdfList = NULL; - + for (int32_t i = 0; i < taosArrayGetSize(pData->pDbCfg); ++i) { SDbCfgInfo* pInfo = taosArrayGet(pData->pDbCfg, i); taosArrayDestroy(pInfo->pRetensions); @@ -167,12 +167,15 @@ void ctgFreeHandle(SCatalog* pCtg) { void ctgFreeSUseDbOutput(SUseDbOutput* pOutput) { - if (NULL == pOutput || NULL == pOutput->dbVgroup) { + if (NULL == pOutput) { return; } - taosHashCleanup(pOutput->dbVgroup->vgHash); - taosMemoryFreeClear(pOutput->dbVgroup); + if (pOutput->dbVgroup) { + taosHashCleanup(pOutput->dbVgroup->vgHash); + taosMemoryFreeClear(pOutput->dbVgroup); + } + taosMemoryFree(pOutput); } @@ -267,6 +270,7 @@ void ctgFreeTask(SCtgTask* pTask) { switch (pTask->type) { case CTG_TASK_GET_QNODE: { taosArrayDestroy((SArray*)pTask->res); + taosMemoryFreeClear(pTask->taskCtx); pTask->res = NULL; break; } @@ -277,17 +281,19 @@ void ctgFreeTask(SCtgTask* pTask) { ctgFreeSTableMetaOutput((STableMetaOutput*)pTask->msgCtx.lastOut); pTask->msgCtx.lastOut = NULL; } + taosMemoryFreeClear(pTask->taskCtx); taosMemoryFreeClear(pTask->res); break; } case CTG_TASK_GET_DB_VGROUP: { taosArrayDestroy((SArray*)pTask->res); + taosMemoryFreeClear(pTask->taskCtx); pTask->res = NULL; break; } case CTG_TASK_GET_DB_CFG: { + taosMemoryFreeClear(pTask->taskCtx); if (pTask->res) { - taosArrayDestroy(((SDbCfgInfo*)pTask->res)->pRetensions); taosMemoryFreeClear(pTask->res); } break; @@ -295,6 +301,7 @@ void ctgFreeTask(SCtgTask* pTask) { case CTG_TASK_GET_TB_HASH: { SCtgTbHashCtx* taskCtx = (SCtgTbHashCtx*)pTask->taskCtx; taosMemoryFreeClear(taskCtx->pName); + taosMemoryFreeClear(pTask->taskCtx); taosMemoryFreeClear(pTask->res); break; } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 472f74e4e8..3c3147f978 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -2766,6 +2766,8 @@ static int32_t buildRollupAst(STranslateContext* pCxt, SCreateTableStmt* pStmt, break; } } + + taosArrayDestroy(dbCfg.pRetensions); return code; } diff --git a/source/libs/qcom/src/querymsg.c b/source/libs/qcom/src/querymsg.c index fb9319bede..636b2b50a8 100644 --- a/source/libs/qcom/src/querymsg.c +++ b/source/libs/qcom/src/querymsg.c @@ -22,7 +22,7 @@ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wformat-truncation" -int32_t (*queryBuildMsg[TDMT_MAX])(void *input, char **msg, int32_t msgSize, int32_t *msgLen) = {0}; +int32_t (*queryBuildMsg[TDMT_MAX])(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallocFp)(int32_t)) = {0}; int32_t (*queryProcessMsgRsp[TDMT_MAX])(void *output, char *msg, int32_t msgSize) = {0}; int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) { @@ -58,7 +58,7 @@ int32_t queryBuildUseDbOutput(SUseDbOutput *pOut, SUseDbRsp *usedbRsp) { return TSDB_CODE_SUCCESS; } -int32_t queryBuildTableMetaReqMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen) { +int32_t queryBuildTableMetaReqMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) { SBuildTableMetaInput *pInput = input; if (NULL == input || NULL == msg || NULL == msgLen) { return TSDB_CODE_TSC_INVALID_INPUT; @@ -72,7 +72,7 @@ int32_t queryBuildTableMetaReqMsg(void *input, char **msg, int32_t msgSize, int3 tstrncpy(infoReq.tbName, pInput->tbName, TSDB_TABLE_NAME_LEN); int32_t bufLen = tSerializeSTableInfoReq(NULL, 0, &infoReq); - void *pBuf = rpcMallocCont(bufLen); + void *pBuf = (*mallcFp)(bufLen); tSerializeSTableInfoReq(pBuf, bufLen, &infoReq); *msg = pBuf; @@ -81,7 +81,7 @@ int32_t queryBuildTableMetaReqMsg(void *input, char **msg, int32_t msgSize, int3 return TSDB_CODE_SUCCESS; } -int32_t queryBuildUseDbMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen) { +int32_t queryBuildUseDbMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int32_t)) { SBuildUseDBInput *pInput = input; if (NULL == pInput || NULL == msg || NULL == msgLen) { return TSDB_CODE_TSC_INVALID_INPUT; @@ -95,7 +95,7 @@ int32_t queryBuildUseDbMsg(void *input, char **msg, int32_t msgSize, int32_t *ms usedbReq.numOfTable = pInput->numOfTable; int32_t bufLen = tSerializeSUseDbReq(NULL, 0, &usedbReq); - void *pBuf = rpcMallocCont(bufLen); + void *pBuf = (*mallcFp)(bufLen); tSerializeSUseDbReq(pBuf, bufLen, &usedbReq); *msg = pBuf; @@ -104,7 +104,7 @@ int32_t queryBuildUseDbMsg(void *input, char **msg, int32_t msgSize, int32_t *ms return TSDB_CODE_SUCCESS; } -int32_t queryBuildQnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen) { +int32_t queryBuildQnodeListMsg(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; } @@ -113,7 +113,7 @@ int32_t queryBuildQnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t qnodeListReq.rowNum = -1; int32_t bufLen = tSerializeSQnodeListReq(NULL, 0, &qnodeListReq); - void *pBuf = rpcMallocCont(bufLen); + void *pBuf = (*mallcFp)(bufLen); tSerializeSQnodeListReq(pBuf, bufLen, &qnodeListReq); *msg = pBuf; @@ -122,7 +122,7 @@ int32_t queryBuildQnodeListMsg(void *input, char **msg, int32_t msgSize, int32_t return TSDB_CODE_SUCCESS; } -int32_t queryBuildGetDBCfgMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen) { +int32_t queryBuildGetDBCfgMsg(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; } @@ -131,7 +131,7 @@ int32_t queryBuildGetDBCfgMsg(void *input, char **msg, int32_t msgSize, int32_t strcpy(dbCfgReq.db, input); int32_t bufLen = tSerializeSDbCfgReq(NULL, 0, &dbCfgReq); - void *pBuf = rpcMallocCont(bufLen); + void *pBuf = (*mallcFp)(bufLen); tSerializeSDbCfgReq(pBuf, bufLen, &dbCfgReq); *msg = pBuf; @@ -140,7 +140,7 @@ int32_t queryBuildGetDBCfgMsg(void *input, char **msg, int32_t msgSize, int32_t return TSDB_CODE_SUCCESS; } -int32_t queryBuildGetIndexMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen) { +int32_t queryBuildGetIndexMsg(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; } @@ -149,7 +149,7 @@ int32_t queryBuildGetIndexMsg(void *input, char **msg, int32_t msgSize, int32_t strcpy(indexReq.indexFName, input); int32_t bufLen = tSerializeSUserIndexReq(NULL, 0, &indexReq); - void *pBuf = rpcMallocCont(bufLen); + void *pBuf = (*mallcFp)(bufLen); tSerializeSUserIndexReq(pBuf, bufLen, &indexReq); *msg = pBuf; @@ -158,7 +158,7 @@ int32_t queryBuildGetIndexMsg(void *input, char **msg, int32_t msgSize, int32_t return TSDB_CODE_SUCCESS; } -int32_t queryBuildRetrieveFuncMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen) { +int32_t queryBuildRetrieveFuncMsg(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; } @@ -170,7 +170,7 @@ int32_t queryBuildRetrieveFuncMsg(void *input, char **msg, int32_t msgSize, int3 taosArrayPush(funcReq.pFuncNames, input); int32_t bufLen = tSerializeSRetrieveFuncReq(NULL, 0, &funcReq); - void *pBuf = rpcMallocCont(bufLen); + void *pBuf = (*mallcFp)(bufLen); tSerializeSRetrieveFuncReq(pBuf, bufLen, &funcReq); taosArrayDestroy(funcReq.pFuncNames); @@ -181,7 +181,7 @@ int32_t queryBuildRetrieveFuncMsg(void *input, char **msg, int32_t msgSize, int3 return TSDB_CODE_SUCCESS; } -int32_t queryBuildGetUserAuthMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen) { +int32_t queryBuildGetUserAuthMsg(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; } @@ -190,7 +190,7 @@ int32_t queryBuildGetUserAuthMsg(void *input, char **msg, int32_t msgSize, int32 strncpy(req.user, input, sizeof(req.user)); int32_t bufLen = tSerializeSGetUserAuthReq(NULL, 0, &req); - void *pBuf = rpcMallocCont(bufLen); + void *pBuf = (*mallcFp)(bufLen); tSerializeSGetUserAuthReq(pBuf, bufLen, &req); *msg = pBuf; From 070f60409bc76d476461b3e054eddd6ac0cbf53d Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Wed, 25 May 2022 21:20:11 +0800 Subject: [PATCH 45/63] feat: sql command 'drop cgroup' --- include/common/tmsg.h | 1 + include/common/tmsgdef.h | 1 + include/common/ttokendef.h | 322 +- include/libs/nodes/cmdnodes.h | 8 + include/libs/nodes/nodes.h | 2 +- include/libs/nodes/plannodes.h | 2 + include/libs/nodes/querynodes.h | 2 + include/util/tdef.h | 9 +- source/common/src/tdatablock.c | 32 +- source/common/src/tmsg.c | 5 +- source/libs/function/src/builtins.c | 8 +- source/libs/nodes/src/nodesCloneFuncs.c | 3 + source/libs/nodes/src/nodesUtilFuncs.c | 220 +- source/libs/parser/inc/parAst.h | 5 +- source/libs/parser/inc/sql.y | 6 + source/libs/parser/src/parAstCreater.c | 155 +- source/libs/parser/src/parCalcConst.c | 10 +- source/libs/parser/src/parTokenizer.c | 14 +- source/libs/parser/src/parTranslater.c | 211 +- source/libs/parser/src/sql.c | 5381 +++++++++-------- source/libs/parser/test/parInitialCTest.cpp | 7 +- source/libs/parser/test/parInitialDTest.cpp | 34 +- source/libs/parser/test/parSelectTest.cpp | 4 +- source/libs/planner/src/planLogicCreater.c | 7 +- source/libs/planner/src/planSpliter.c | 70 +- source/libs/planner/test/planSubqueryTest.cpp | 2 + 26 files changed, 3391 insertions(+), 3130 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 32cb739535..5f78f2b756 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -696,6 +696,7 @@ typedef struct { int8_t replications; int8_t strict; int8_t cacheLastRow; + int8_t schemaless; int8_t ignoreExist; int32_t numOfRetensions; SArray* pRetensions; // SRetention diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index e8e931daa5..4bbb3a4a48 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -144,6 +144,7 @@ enum { TD_DEF_MSG_TYPE(TDMT_MND_CREATE_TOPIC, "mnode-create-topic", SMCreateTopicReq, SMCreateTopicRsp) TD_DEF_MSG_TYPE(TDMT_MND_ALTER_TOPIC, "mnode-alter-topic", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_DROP_TOPIC, "mnode-drop-topic", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_DROP_CGROUP, "mnode-drop-cgroup", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_SUBSCRIBE, "mnode-subscribe", SCMSubscribeReq, SCMSubscribeRsp) TD_DEF_MSG_TYPE(TDMT_MND_MQ_ASK_EP, "mnode-mq-ask-ep", SMqAskEpReq, SMqAskEpRsp) TD_DEF_MSG_TYPE(TDMT_MND_MQ_TIMER, "mnode-mq-tmr", SMTimerReq, NULL) diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 68199fa519..2fc524eeac 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -93,166 +93,168 @@ #define TK_VGROUPS 75 #define TK_SINGLE_STABLE 76 #define TK_RETENTIONS 77 -#define TK_NK_COLON 78 -#define TK_TABLE 79 -#define TK_NK_LP 80 -#define TK_NK_RP 81 -#define TK_STABLE 82 -#define TK_ADD 83 -#define TK_COLUMN 84 -#define TK_MODIFY 85 -#define TK_RENAME 86 -#define TK_TAG 87 -#define TK_SET 88 -#define TK_NK_EQ 89 -#define TK_USING 90 -#define TK_TAGS 91 -#define TK_COMMENT 92 -#define TK_BOOL 93 -#define TK_TINYINT 94 -#define TK_SMALLINT 95 -#define TK_INT 96 -#define TK_INTEGER 97 -#define TK_BIGINT 98 -#define TK_FLOAT 99 -#define TK_DOUBLE 100 -#define TK_BINARY 101 -#define TK_TIMESTAMP 102 -#define TK_NCHAR 103 -#define TK_UNSIGNED 104 -#define TK_JSON 105 -#define TK_VARCHAR 106 -#define TK_MEDIUMBLOB 107 -#define TK_BLOB 108 -#define TK_VARBINARY 109 -#define TK_DECIMAL 110 -#define TK_DELAY 111 -#define TK_FILE_FACTOR 112 -#define TK_NK_FLOAT 113 -#define TK_ROLLUP 114 -#define TK_TTL 115 -#define TK_SMA 116 -#define TK_SHOW 117 -#define TK_DATABASES 118 -#define TK_TABLES 119 -#define TK_STABLES 120 -#define TK_MNODES 121 -#define TK_MODULES 122 -#define TK_QNODES 123 -#define TK_FUNCTIONS 124 -#define TK_INDEXES 125 -#define TK_ACCOUNTS 126 -#define TK_APPS 127 -#define TK_CONNECTIONS 128 -#define TK_LICENCE 129 -#define TK_GRANTS 130 -#define TK_QUERIES 131 -#define TK_SCORES 132 -#define TK_TOPICS 133 -#define TK_VARIABLES 134 -#define TK_BNODES 135 -#define TK_SNODES 136 -#define TK_CLUSTER 137 -#define TK_TRANSACTIONS 138 -#define TK_LIKE 139 -#define TK_INDEX 140 -#define TK_FULLTEXT 141 -#define TK_FUNCTION 142 -#define TK_INTERVAL 143 -#define TK_TOPIC 144 -#define TK_AS 145 -#define TK_WITH 146 -#define TK_SCHEMA 147 -#define TK_DESC 148 -#define TK_DESCRIBE 149 -#define TK_RESET 150 -#define TK_QUERY 151 -#define TK_CACHE 152 -#define TK_EXPLAIN 153 -#define TK_ANALYZE 154 -#define TK_VERBOSE 155 -#define TK_NK_BOOL 156 -#define TK_RATIO 157 -#define TK_COMPACT 158 -#define TK_VNODES 159 -#define TK_IN 160 -#define TK_OUTPUTTYPE 161 -#define TK_AGGREGATE 162 -#define TK_BUFSIZE 163 -#define TK_STREAM 164 -#define TK_INTO 165 -#define TK_TRIGGER 166 -#define TK_AT_ONCE 167 -#define TK_WINDOW_CLOSE 168 -#define TK_WATERMARK 169 -#define TK_KILL 170 -#define TK_CONNECTION 171 -#define TK_TRANSACTION 172 -#define TK_MERGE 173 -#define TK_VGROUP 174 -#define TK_REDISTRIBUTE 175 -#define TK_SPLIT 176 -#define TK_SYNCDB 177 -#define TK_NULL 178 -#define TK_NK_QUESTION 179 -#define TK_NK_ARROW 180 -#define TK_ROWTS 181 -#define TK_TBNAME 182 -#define TK_QSTARTTS 183 -#define TK_QENDTS 184 -#define TK_WSTARTTS 185 -#define TK_WENDTS 186 -#define TK_WDURATION 187 -#define TK_CAST 188 -#define TK_NOW 189 -#define TK_TODAY 190 -#define TK_TIMEZONE 191 -#define TK_COUNT 192 -#define TK_FIRST 193 -#define TK_LAST 194 -#define TK_LAST_ROW 195 -#define TK_BETWEEN 196 -#define TK_IS 197 -#define TK_NK_LT 198 -#define TK_NK_GT 199 -#define TK_NK_LE 200 -#define TK_NK_GE 201 -#define TK_NK_NE 202 -#define TK_MATCH 203 -#define TK_NMATCH 204 -#define TK_CONTAINS 205 -#define TK_JOIN 206 -#define TK_INNER 207 -#define TK_SELECT 208 -#define TK_DISTINCT 209 -#define TK_WHERE 210 -#define TK_PARTITION 211 -#define TK_BY 212 -#define TK_SESSION 213 -#define TK_STATE_WINDOW 214 -#define TK_SLIDING 215 -#define TK_FILL 216 -#define TK_VALUE 217 -#define TK_NONE 218 -#define TK_PREV 219 -#define TK_LINEAR 220 -#define TK_NEXT 221 -#define TK_GROUP 222 -#define TK_HAVING 223 -#define TK_ORDER 224 -#define TK_SLIMIT 225 -#define TK_SOFFSET 226 -#define TK_LIMIT 227 -#define TK_OFFSET 228 -#define TK_ASC 229 -#define TK_NULLS 230 -#define TK_ID 231 -#define TK_NK_BITNOT 232 -#define TK_INSERT 233 -#define TK_VALUES 234 -#define TK_IMPORT 235 -#define TK_NK_SEMI 236 -#define TK_FILE 237 +#define TK_SCHEMALESS 78 +#define TK_NK_COLON 79 +#define TK_TABLE 80 +#define TK_NK_LP 81 +#define TK_NK_RP 82 +#define TK_STABLE 83 +#define TK_ADD 84 +#define TK_COLUMN 85 +#define TK_MODIFY 86 +#define TK_RENAME 87 +#define TK_TAG 88 +#define TK_SET 89 +#define TK_NK_EQ 90 +#define TK_USING 91 +#define TK_TAGS 92 +#define TK_COMMENT 93 +#define TK_BOOL 94 +#define TK_TINYINT 95 +#define TK_SMALLINT 96 +#define TK_INT 97 +#define TK_INTEGER 98 +#define TK_BIGINT 99 +#define TK_FLOAT 100 +#define TK_DOUBLE 101 +#define TK_BINARY 102 +#define TK_TIMESTAMP 103 +#define TK_NCHAR 104 +#define TK_UNSIGNED 105 +#define TK_JSON 106 +#define TK_VARCHAR 107 +#define TK_MEDIUMBLOB 108 +#define TK_BLOB 109 +#define TK_VARBINARY 110 +#define TK_DECIMAL 111 +#define TK_DELAY 112 +#define TK_FILE_FACTOR 113 +#define TK_NK_FLOAT 114 +#define TK_ROLLUP 115 +#define TK_TTL 116 +#define TK_SMA 117 +#define TK_SHOW 118 +#define TK_DATABASES 119 +#define TK_TABLES 120 +#define TK_STABLES 121 +#define TK_MNODES 122 +#define TK_MODULES 123 +#define TK_QNODES 124 +#define TK_FUNCTIONS 125 +#define TK_INDEXES 126 +#define TK_ACCOUNTS 127 +#define TK_APPS 128 +#define TK_CONNECTIONS 129 +#define TK_LICENCE 130 +#define TK_GRANTS 131 +#define TK_QUERIES 132 +#define TK_SCORES 133 +#define TK_TOPICS 134 +#define TK_VARIABLES 135 +#define TK_BNODES 136 +#define TK_SNODES 137 +#define TK_CLUSTER 138 +#define TK_TRANSACTIONS 139 +#define TK_LIKE 140 +#define TK_INDEX 141 +#define TK_FULLTEXT 142 +#define TK_FUNCTION 143 +#define TK_INTERVAL 144 +#define TK_TOPIC 145 +#define TK_AS 146 +#define TK_CGROUP 147 +#define TK_WITH 148 +#define TK_SCHEMA 149 +#define TK_DESC 150 +#define TK_DESCRIBE 151 +#define TK_RESET 152 +#define TK_QUERY 153 +#define TK_CACHE 154 +#define TK_EXPLAIN 155 +#define TK_ANALYZE 156 +#define TK_VERBOSE 157 +#define TK_NK_BOOL 158 +#define TK_RATIO 159 +#define TK_COMPACT 160 +#define TK_VNODES 161 +#define TK_IN 162 +#define TK_OUTPUTTYPE 163 +#define TK_AGGREGATE 164 +#define TK_BUFSIZE 165 +#define TK_STREAM 166 +#define TK_INTO 167 +#define TK_TRIGGER 168 +#define TK_AT_ONCE 169 +#define TK_WINDOW_CLOSE 170 +#define TK_WATERMARK 171 +#define TK_KILL 172 +#define TK_CONNECTION 173 +#define TK_TRANSACTION 174 +#define TK_MERGE 175 +#define TK_VGROUP 176 +#define TK_REDISTRIBUTE 177 +#define TK_SPLIT 178 +#define TK_SYNCDB 179 +#define TK_NULL 180 +#define TK_NK_QUESTION 181 +#define TK_NK_ARROW 182 +#define TK_ROWTS 183 +#define TK_TBNAME 184 +#define TK_QSTARTTS 185 +#define TK_QENDTS 186 +#define TK_WSTARTTS 187 +#define TK_WENDTS 188 +#define TK_WDURATION 189 +#define TK_CAST 190 +#define TK_NOW 191 +#define TK_TODAY 192 +#define TK_TIMEZONE 193 +#define TK_COUNT 194 +#define TK_FIRST 195 +#define TK_LAST 196 +#define TK_LAST_ROW 197 +#define TK_BETWEEN 198 +#define TK_IS 199 +#define TK_NK_LT 200 +#define TK_NK_GT 201 +#define TK_NK_LE 202 +#define TK_NK_GE 203 +#define TK_NK_NE 204 +#define TK_MATCH 205 +#define TK_NMATCH 206 +#define TK_CONTAINS 207 +#define TK_JOIN 208 +#define TK_INNER 209 +#define TK_SELECT 210 +#define TK_DISTINCT 211 +#define TK_WHERE 212 +#define TK_PARTITION 213 +#define TK_BY 214 +#define TK_SESSION 215 +#define TK_STATE_WINDOW 216 +#define TK_SLIDING 217 +#define TK_FILL 218 +#define TK_VALUE 219 +#define TK_NONE 220 +#define TK_PREV 221 +#define TK_LINEAR 222 +#define TK_NEXT 223 +#define TK_GROUP 224 +#define TK_HAVING 225 +#define TK_ORDER 226 +#define TK_SLIMIT 227 +#define TK_SOFFSET 228 +#define TK_LIMIT 229 +#define TK_OFFSET 230 +#define TK_ASC 231 +#define TK_NULLS 232 +#define TK_ID 233 +#define TK_NK_BITNOT 234 +#define TK_INSERT 235 +#define TK_VALUES 236 +#define TK_IMPORT 237 +#define TK_NK_SEMI 238 +#define TK_FILE 239 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 82bf4e1f45..7bd3a40c71 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -50,6 +50,7 @@ typedef struct SDatabaseOptions { int32_t numOfVgroups; int8_t singleStable; SNodeList* pRetentions; + int8_t schemaless; } SDatabaseOptions; typedef struct SCreateDatabaseStmt { @@ -260,6 +261,13 @@ typedef struct SDropTopicStmt { bool ignoreNotExists; } SDropTopicStmt; +typedef struct SDropCGroupStmt { + ENodeType type; + char topicName[TSDB_TABLE_NAME_LEN]; + char cgroup[TSDB_CGROUP_LEN]; + bool ignoreNotExists; +} SDropCGroupStmt; + typedef struct SAlterLocalStmt { ENodeType type; char config[TSDB_DNODE_CONFIG_LEN]; diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index b9cb708c9c..ad30bd7552 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -131,6 +131,7 @@ typedef enum ENodeType { QUERY_NODE_DROP_MNODE_STMT, QUERY_NODE_CREATE_TOPIC_STMT, QUERY_NODE_DROP_TOPIC_STMT, + QUERY_NODE_DROP_CGROUP_STMT, QUERY_NODE_ALTER_LOCAL_STMT, QUERY_NODE_EXPLAIN_STMT, QUERY_NODE_DESCRIBE_STMT, @@ -242,7 +243,6 @@ typedef struct SNodeList { #define SNodeptr void* -int32_t nodesNodeSize(ENodeType type); SNodeptr nodesMakeNode(ENodeType type); void nodesDestroyNode(SNodeptr pNode); diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 6c4d14ffa1..367addbe9b 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -31,6 +31,7 @@ typedef struct SLogicNode { SNodeList* pChildren; struct SLogicNode* pParent; int32_t optimizedFlag; + uint8_t precision; } SLogicNode; typedef enum EScanType { SCAN_TYPE_TAG = 1, SCAN_TYPE_TABLE, SCAN_TYPE_SYSTEM_TABLE, SCAN_TYPE_STREAM } EScanType; @@ -61,6 +62,7 @@ typedef struct SJoinLogicNode { SLogicNode node; EJoinType joinType; SNode* pOnConditions; + bool isSingleTableJoin; } SJoinLogicNode; typedef struct SAggLogicNode { diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index f2ce1dd7f5..16014893ca 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -132,6 +132,7 @@ typedef struct STableNode { char tableName[TSDB_TABLE_NAME_LEN]; char tableAlias[TSDB_TABLE_NAME_LEN]; uint8_t precision; + bool singleTable; } STableNode; struct STableMeta; @@ -242,6 +243,7 @@ typedef struct SSelectStmt { bool hasAggFuncs; bool hasRepeatScanFuncs; bool hasIndefiniteRowsFunc; + bool hasSelectFunc; bool hasSelectValFunc; } SSelectStmt; diff --git a/include/util/tdef.h b/include/util/tdef.h index 808fcf0152..f527523433 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -334,9 +334,12 @@ typedef enum ELogicConditionType { #define TSDB_DB_STREAM_MODE_OFF 0 #define TSDB_DB_STREAM_MODE_ON 1 #define TSDB_DEFAULT_DB_STREAM_MODE 0 -#define TSDB_DB_SINGLE_STABLE_ON 0 -#define TSDB_DB_SINGLE_STABLE_OFF 1 -#define TSDB_DEFAULT_DB_SINGLE_STABLE 0 +#define TSDB_DB_SINGLE_STABLE_ON 1 +#define TSDB_DB_SINGLE_STABLE_OFF 0 +#define TSDB_DEFAULT_DB_SINGLE_STABLE TSDB_DB_SINGLE_STABLE_OFF +#define TSDB_DB_SCHEMALESS_ON 1 +#define TSDB_DB_SCHEMALESS_OFF 0 +#define TSDB_DEFAULT_DB_SCHEMALESS TSDB_DB_SCHEMALESS_OFF #define TSDB_MIN_ROLLUP_FILE_FACTOR 0 #define TSDB_MAX_ROLLUP_FILE_FACTOR 1 diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 51bcd05ea1..1864806ebf 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -275,8 +275,10 @@ int32_t colDataMergeCol(SColumnInfoData* pColumnInfoData, uint32_t numOfRow1, in doBitmapMerge(pColumnInfoData, numOfRow1, pSource, numOfRow2); - int32_t offset = pColumnInfoData->info.bytes * numOfRow1; - memcpy(pColumnInfoData->pData + offset, pSource->pData, pSource->info.bytes * numOfRow2); + if (pSource->pData) { + int32_t offset = pColumnInfoData->info.bytes * numOfRow1; + memcpy(pColumnInfoData->pData + offset, pSource->pData, pSource->info.bytes * numOfRow2); + } } return numOfRow1 + numOfRow2; @@ -319,14 +321,16 @@ int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* p pColumnInfoData->nullbitmap = tmp; memcpy(pColumnInfoData->nullbitmap, pSource->nullbitmap, BitmapLen(numOfRows)); - int32_t newSize = numOfRows * pColumnInfoData->info.bytes; - tmp = taosMemoryRealloc(pColumnInfoData->pData, newSize); - if (tmp == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; - } + if (pColumnInfoData->pData) { + int32_t newSize = numOfRows * pColumnInfoData->info.bytes; + tmp = taosMemoryRealloc(pColumnInfoData->pData, newSize); + if (tmp == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } - pColumnInfoData->pData = tmp; - memcpy(pColumnInfoData->pData, pSource->pData, pSource->info.bytes * numOfRows); + pColumnInfoData->pData = tmp; + memcpy(pColumnInfoData->pData, pSource->pData, pSource->info.bytes * numOfRows); + } } pColumnInfoData->hasNull = pSource->hasNull; @@ -350,7 +354,7 @@ int32_t blockDataUpdateTsWindow(SSDataBlock* pDataBlock, int32_t tsColumnIndex) return -1; } - int32_t index = (tsColumnIndex == -1)? 0:tsColumnIndex; + int32_t index = (tsColumnIndex == -1) ? 0 : tsColumnIndex; SColumnInfoData* pColInfoData = taosArrayGet(pDataBlock->pDataBlock, index); if (pColInfoData->info.type != TSDB_DATA_TYPE_TIMESTAMP) { return 0; @@ -605,8 +609,8 @@ int32_t blockDataFromBuf(SSDataBlock* pBlock, const char* buf) { } int32_t blockDataFromBuf1(SSDataBlock* pBlock, const char* buf, size_t capacity) { - pBlock->info.rows = *(int32_t*) buf; - pBlock->info.groupId = *(uint64_t*) (buf + sizeof(int32_t)); + pBlock->info.rows = *(int32_t*)buf; + pBlock->info.groupId = *(uint64_t*)(buf + sizeof(int32_t)); int32_t numOfCols = pBlock->info.numOfCols; const char* pStart = buf + sizeof(uint32_t) + sizeof(uint64_t); @@ -675,7 +679,7 @@ size_t blockDataGetSerialMetaSize(const SSDataBlock* pBlock) { return sizeof(int32_t) + sizeof(uint64_t) + pBlock->info.numOfCols * sizeof(int32_t); } -double blockDataGetSerialRowSize(const SSDataBlock* pBlock) { +double blockDataGetSerialRowSize(const SSDataBlock* pBlock) { ASSERT(pBlock != NULL); double rowSize = 0; @@ -1238,7 +1242,7 @@ size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize) { // the true value must be less than the value of nRows int32_t additional = 0; - for(int32_t i = 0; i < pBlock->info.numOfCols; ++i) { + for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) { SColumnInfoData* pCol = taosArrayGet(pBlock->pDataBlock, i); if (IS_VAR_DATA_TYPE(pCol->info.type)) { additional += nRows * sizeof(int32_t); diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 7f886b078a..32db8c0761 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -1675,6 +1675,7 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) { if (tEncodeI8(&encoder, pReq->replications) < 0) return -1; if (tEncodeI8(&encoder, pReq->strict) < 0) return -1; if (tEncodeI8(&encoder, pReq->cacheLastRow) < 0) return -1; + if (tEncodeI8(&encoder, pReq->schemaless) < 0) return -1; if (tEncodeI8(&encoder, pReq->ignoreExist) < 0) return -1; if (tEncodeI32(&encoder, pReq->numOfRetensions) < 0) return -1; for (int32_t i = 0; i < pReq->numOfRetensions; ++i) { @@ -1715,6 +1716,7 @@ int32_t tDeserializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) if (tDecodeI8(&decoder, &pReq->replications) < 0) return -1; if (tDecodeI8(&decoder, &pReq->strict) < 0) return -1; if (tDecodeI8(&decoder, &pReq->cacheLastRow) < 0) return -1; + if (tDecodeI8(&decoder, &pReq->schemaless) < 0) return -1; if (tDecodeI8(&decoder, &pReq->ignoreExist) < 0) return -1; if (tDecodeI32(&decoder, &pReq->numOfRetensions) < 0) return -1; pReq->pRetensions = taosArrayInit(pReq->numOfRetensions, sizeof(SRetention)); @@ -3347,7 +3349,8 @@ int32_t tDeserializeSExplainRsp(void *buf, int32_t bufLen, SExplainRsp *pRsp) { if (tDecodeDouble(&decoder, &pRsp->subplanInfo[i].totalCost) < 0) return -1; if (tDecodeU64(&decoder, &pRsp->subplanInfo[i].numOfRows) < 0) return -1; if (tDecodeU32(&decoder, &pRsp->subplanInfo[i].verboseLen) < 0) return -1; - if (tDecodeBinary(&decoder, (uint8_t**) &pRsp->subplanInfo[i].verboseInfo, &pRsp->subplanInfo[i].verboseLen) < 0) return -1; + if (tDecodeBinary(&decoder, (uint8_t **)&pRsp->subplanInfo[i].verboseInfo, &pRsp->subplanInfo[i].verboseLen) < 0) + return -1; } tEndDecode(&decoder); diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 2cec75c8d3..a1accf2e73 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -190,14 +190,14 @@ static int32_t translateApercentile(SFunctionNode* pFunc, char* pErrBuf, int32_t if (nodeType(pParamNode) != QUERY_NODE_VALUE) { return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); } - + SValueNode* pValue = (SValueNode*)pParamNode; if (pValue->datum.i < 0 || pValue->datum.i > 100) { return invaildFuncParaValueErrMsg(pErrBuf, len, pFunc->functionName); } pValue->notReserved = true; - + if (3 == paraNum) { SNode* pPara3 = nodesListGetNode(pFunc->pParameterList, 2); if (QUERY_NODE_VALUE != nodeType(pPara3) || !validAperventileAlgo((SValueNode*)pPara3)) { @@ -837,7 +837,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "top", .type = FUNCTION_TYPE_TOP, - .classification = FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC, .translateFunc = translateTop, .getEnvFunc = getTopBotFuncEnv, .initFunc = functionSetup, @@ -847,7 +847,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "bottom", .type = FUNCTION_TYPE_BOTTOM, - .classification = FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_INDEFINITE_ROWS_FUNC, .translateFunc = translateBottom, .getEnvFunc = getTopBotFuncEnv, .initFunc = functionSetup, diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index 5774dcaa1d..68d3741b48 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -191,6 +191,7 @@ static SNode* tableNodeCopy(const STableNode* pSrc, STableNode* pDst) { COPY_CHAR_ARRAY_FIELD(tableName); COPY_CHAR_ARRAY_FIELD(tableAlias); COPY_SCALAR_FIELD(precision); + COPY_SCALAR_FIELD(singleTable); return (SNode*)pDst; } @@ -326,6 +327,7 @@ static SNode* logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) { COPY_SCALAR_FIELD(sliding); COPY_SCALAR_FIELD(intervalUnit); COPY_SCALAR_FIELD(slidingUnit); + CLONE_NODE_FIELD(pTagCond); return (SNode*)pDst; } @@ -333,6 +335,7 @@ static SNode* 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; } diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 3f7003dfa3..6dbfdab67a 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -21,149 +21,160 @@ #include "taoserror.h" #include "thash.h" -int32_t nodesNodeSize(ENodeType type) { +static SNode* makeNode(ENodeType type, size_t size) { + SNode* p = taosMemoryCalloc(1, size); + if (NULL == p) { + return NULL; + } + setNodeType(p, type); + return p; +} + +SNodeptr nodesMakeNode(ENodeType type) { switch (type) { case QUERY_NODE_COLUMN: - return sizeof(SColumnNode); + return makeNode(type, sizeof(SColumnNode)); case QUERY_NODE_VALUE: - return sizeof(SValueNode); + return makeNode(type, sizeof(SValueNode)); case QUERY_NODE_OPERATOR: - return sizeof(SOperatorNode); + return makeNode(type, sizeof(SOperatorNode)); case QUERY_NODE_LOGIC_CONDITION: - return sizeof(SLogicConditionNode); + return makeNode(type, sizeof(SLogicConditionNode)); case QUERY_NODE_FUNCTION: - return sizeof(SFunctionNode); + return makeNode(type, sizeof(SFunctionNode)); case QUERY_NODE_REAL_TABLE: - return sizeof(SRealTableNode); + return makeNode(type, sizeof(SRealTableNode)); case QUERY_NODE_TEMP_TABLE: - return sizeof(STempTableNode); + return makeNode(type, sizeof(STempTableNode)); case QUERY_NODE_JOIN_TABLE: - return sizeof(SJoinTableNode); + return makeNode(type, sizeof(SJoinTableNode)); case QUERY_NODE_GROUPING_SET: - return sizeof(SGroupingSetNode); + return makeNode(type, sizeof(SGroupingSetNode)); case QUERY_NODE_ORDER_BY_EXPR: - return sizeof(SOrderByExprNode); + return makeNode(type, sizeof(SOrderByExprNode)); case QUERY_NODE_LIMIT: - return sizeof(SLimitNode); + return makeNode(type, sizeof(SLimitNode)); case QUERY_NODE_STATE_WINDOW: - return sizeof(SStateWindowNode); + return makeNode(type, sizeof(SStateWindowNode)); case QUERY_NODE_SESSION_WINDOW: - return sizeof(SSessionWindowNode); + return makeNode(type, sizeof(SSessionWindowNode)); case QUERY_NODE_INTERVAL_WINDOW: - return sizeof(SIntervalWindowNode); + return makeNode(type, sizeof(SIntervalWindowNode)); case QUERY_NODE_NODE_LIST: - return sizeof(SNodeListNode); + return makeNode(type, sizeof(SNodeListNode)); case QUERY_NODE_FILL: - return sizeof(SFillNode); + return makeNode(type, sizeof(SFillNode)); case QUERY_NODE_RAW_EXPR: - return sizeof(SRawExprNode); + return makeNode(type, sizeof(SRawExprNode)); case QUERY_NODE_TARGET: - return sizeof(STargetNode); + return makeNode(type, sizeof(STargetNode)); case QUERY_NODE_DATABLOCK_DESC: - return sizeof(SDataBlockDescNode); + return makeNode(type, sizeof(SDataBlockDescNode)); case QUERY_NODE_SLOT_DESC: - return sizeof(SSlotDescNode); + return makeNode(type, sizeof(SSlotDescNode)); case QUERY_NODE_COLUMN_DEF: - return sizeof(SColumnDefNode); + return makeNode(type, sizeof(SColumnDefNode)); case QUERY_NODE_DOWNSTREAM_SOURCE: - return sizeof(SDownstreamSourceNode); + return makeNode(type, sizeof(SDownstreamSourceNode)); case QUERY_NODE_DATABASE_OPTIONS: - return sizeof(SDatabaseOptions); + return makeNode(type, sizeof(SDatabaseOptions)); case QUERY_NODE_TABLE_OPTIONS: - return sizeof(STableOptions); + return makeNode(type, sizeof(STableOptions)); case QUERY_NODE_INDEX_OPTIONS: - return sizeof(SIndexOptions); + return makeNode(type, sizeof(SIndexOptions)); case QUERY_NODE_EXPLAIN_OPTIONS: - return sizeof(SExplainOptions); + return makeNode(type, sizeof(SExplainOptions)); case QUERY_NODE_STREAM_OPTIONS: - return sizeof(SStreamOptions); + return makeNode(type, sizeof(SStreamOptions)); case QUERY_NODE_TOPIC_OPTIONS: - return sizeof(STopicOptions); + return makeNode(type, sizeof(STopicOptions)); case QUERY_NODE_LEFT_VALUE: - return sizeof(SLeftValueNode); + return makeNode(type, sizeof(SLeftValueNode)); case QUERY_NODE_SET_OPERATOR: - return sizeof(SSetOperator); + return makeNode(type, sizeof(SSetOperator)); case QUERY_NODE_SELECT_STMT: - return sizeof(SSelectStmt); + return makeNode(type, sizeof(SSelectStmt)); case QUERY_NODE_VNODE_MODIF_STMT: - return sizeof(SVnodeModifOpStmt); + return makeNode(type, sizeof(SVnodeModifOpStmt)); case QUERY_NODE_CREATE_DATABASE_STMT: - return sizeof(SCreateDatabaseStmt); + return makeNode(type, sizeof(SCreateDatabaseStmt)); case QUERY_NODE_DROP_DATABASE_STMT: - return sizeof(SDropDatabaseStmt); + return makeNode(type, sizeof(SDropDatabaseStmt)); case QUERY_NODE_ALTER_DATABASE_STMT: - return sizeof(SAlterDatabaseStmt); + return makeNode(type, sizeof(SAlterDatabaseStmt)); case QUERY_NODE_CREATE_TABLE_STMT: - return sizeof(SCreateTableStmt); + return makeNode(type, sizeof(SCreateTableStmt)); case QUERY_NODE_CREATE_SUBTABLE_CLAUSE: - return sizeof(SCreateSubTableClause); + return makeNode(type, sizeof(SCreateSubTableClause)); case QUERY_NODE_CREATE_MULTI_TABLE_STMT: - return sizeof(SCreateMultiTableStmt); + return makeNode(type, sizeof(SCreateMultiTableStmt)); case QUERY_NODE_DROP_TABLE_CLAUSE: - return sizeof(SDropTableClause); + return makeNode(type, sizeof(SDropTableClause)); case QUERY_NODE_DROP_TABLE_STMT: - return sizeof(SDropTableStmt); + return makeNode(type, sizeof(SDropTableStmt)); case QUERY_NODE_DROP_SUPER_TABLE_STMT: - return sizeof(SDropSuperTableStmt); + return makeNode(type, sizeof(SDropSuperTableStmt)); case QUERY_NODE_ALTER_TABLE_STMT: - return sizeof(SAlterTableStmt); + return makeNode(type, sizeof(SAlterTableStmt)); case QUERY_NODE_CREATE_USER_STMT: - return sizeof(SCreateUserStmt); + return makeNode(type, sizeof(SCreateUserStmt)); case QUERY_NODE_ALTER_USER_STMT: - return sizeof(SAlterUserStmt); + return makeNode(type, sizeof(SAlterUserStmt)); case QUERY_NODE_DROP_USER_STMT: - return sizeof(SDropUserStmt); + return makeNode(type, sizeof(SDropUserStmt)); case QUERY_NODE_USE_DATABASE_STMT: - return sizeof(SUseDatabaseStmt); + return makeNode(type, sizeof(SUseDatabaseStmt)); case QUERY_NODE_CREATE_DNODE_STMT: - return sizeof(SCreateDnodeStmt); + return makeNode(type, sizeof(SCreateDnodeStmt)); case QUERY_NODE_DROP_DNODE_STMT: - return sizeof(SDropDnodeStmt); + return makeNode(type, sizeof(SDropDnodeStmt)); case QUERY_NODE_ALTER_DNODE_STMT: - return sizeof(SAlterDnodeStmt); + return makeNode(type, sizeof(SAlterDnodeStmt)); case QUERY_NODE_CREATE_INDEX_STMT: - return sizeof(SCreateIndexStmt); + return makeNode(type, sizeof(SCreateIndexStmt)); case QUERY_NODE_DROP_INDEX_STMT: - return sizeof(SDropIndexStmt); + return makeNode(type, sizeof(SDropIndexStmt)); case QUERY_NODE_CREATE_QNODE_STMT: case QUERY_NODE_CREATE_BNODE_STMT: case QUERY_NODE_CREATE_SNODE_STMT: case QUERY_NODE_CREATE_MNODE_STMT: - return sizeof(SCreateComponentNodeStmt); + return makeNode(type, sizeof(SCreateComponentNodeStmt)); case QUERY_NODE_DROP_QNODE_STMT: case QUERY_NODE_DROP_BNODE_STMT: case QUERY_NODE_DROP_SNODE_STMT: case QUERY_NODE_DROP_MNODE_STMT: - return sizeof(SDropComponentNodeStmt); + return makeNode(type, sizeof(SDropComponentNodeStmt)); case QUERY_NODE_CREATE_TOPIC_STMT: - return sizeof(SCreateTopicStmt); + return makeNode(type, sizeof(SCreateTopicStmt)); case QUERY_NODE_DROP_TOPIC_STMT: - return sizeof(SDropTopicStmt); + return makeNode(type, sizeof(SDropTopicStmt)); + case QUERY_NODE_DROP_CGROUP_STMT: + return makeNode(type, sizeof(SDropCGroupStmt)); case QUERY_NODE_EXPLAIN_STMT: - return sizeof(SExplainStmt); + return makeNode(type, sizeof(SExplainStmt)); case QUERY_NODE_DESCRIBE_STMT: - return sizeof(SDescribeStmt); + return makeNode(type, sizeof(SDescribeStmt)); case QUERY_NODE_RESET_QUERY_CACHE_STMT: - return sizeof(SNode); + return makeNode(type, sizeof(SNode)); case QUERY_NODE_COMPACT_STMT: break; case QUERY_NODE_CREATE_FUNCTION_STMT: - return sizeof(SCreateFunctionStmt); + return makeNode(type, sizeof(SCreateFunctionStmt)); case QUERY_NODE_DROP_FUNCTION_STMT: - return sizeof(SDropFunctionStmt); + return makeNode(type, sizeof(SDropFunctionStmt)); case QUERY_NODE_CREATE_STREAM_STMT: - return sizeof(SCreateStreamStmt); + return makeNode(type, sizeof(SCreateStreamStmt)); case QUERY_NODE_DROP_STREAM_STMT: - return sizeof(SDropStreamStmt); + return makeNode(type, sizeof(SDropStreamStmt)); case QUERY_NODE_MERGE_VGROUP_STMT: case QUERY_NODE_REDISTRIBUTE_VGROUP_STMT: case QUERY_NODE_SPLIT_VGROUP_STMT: case QUERY_NODE_SYNCDB_STMT: break; case QUERY_NODE_GRANT_STMT: - return sizeof(SGrantStmt); + return makeNode(type, sizeof(SGrantStmt)); case QUERY_NODE_REVOKE_STMT: - return sizeof(SRevokeStmt); + return makeNode(type, sizeof(SRevokeStmt)); case QUERY_NODE_SHOW_DNODES_STMT: case QUERY_NODE_SHOW_MNODES_STMT: case QUERY_NODE_SHOW_MODULES_STMT: @@ -194,89 +205,80 @@ int32_t nodesNodeSize(ENodeType type) { case QUERY_NODE_SHOW_CREATE_TABLE_STMT: case QUERY_NODE_SHOW_CREATE_STABLE_STMT: case QUERY_NODE_SHOW_TRANSACTIONS_STMT: - return sizeof(SShowStmt); + return makeNode(type, sizeof(SShowStmt)); case QUERY_NODE_KILL_CONNECTION_STMT: case QUERY_NODE_KILL_QUERY_STMT: case QUERY_NODE_KILL_TRANSACTION_STMT: - return sizeof(SKillStmt); + return makeNode(type, sizeof(SKillStmt)); case QUERY_NODE_LOGIC_PLAN_SCAN: - return sizeof(SScanLogicNode); + return makeNode(type, sizeof(SScanLogicNode)); case QUERY_NODE_LOGIC_PLAN_JOIN: - return sizeof(SJoinLogicNode); + return makeNode(type, sizeof(SJoinLogicNode)); case QUERY_NODE_LOGIC_PLAN_AGG: - return sizeof(SAggLogicNode); + return makeNode(type, sizeof(SAggLogicNode)); case QUERY_NODE_LOGIC_PLAN_PROJECT: - return sizeof(SProjectLogicNode); + return makeNode(type, sizeof(SProjectLogicNode)); case QUERY_NODE_LOGIC_PLAN_VNODE_MODIF: - return sizeof(SVnodeModifLogicNode); + return makeNode(type, sizeof(SVnodeModifLogicNode)); case QUERY_NODE_LOGIC_PLAN_EXCHANGE: - return sizeof(SExchangeLogicNode); + return makeNode(type, sizeof(SExchangeLogicNode)); case QUERY_NODE_LOGIC_PLAN_WINDOW: - return sizeof(SWindowLogicNode); + return makeNode(type, sizeof(SWindowLogicNode)); case QUERY_NODE_LOGIC_PLAN_FILL: - return sizeof(SFillLogicNode); + return makeNode(type, sizeof(SFillLogicNode)); case QUERY_NODE_LOGIC_PLAN_SORT: - return sizeof(SSortLogicNode); + return makeNode(type, sizeof(SSortLogicNode)); case QUERY_NODE_LOGIC_PLAN_PARTITION: - return sizeof(SPartitionLogicNode); + return makeNode(type, sizeof(SPartitionLogicNode)); case QUERY_NODE_LOGIC_SUBPLAN: - return sizeof(SLogicSubplan); + return makeNode(type, sizeof(SLogicSubplan)); case QUERY_NODE_LOGIC_PLAN: - return sizeof(SQueryLogicPlan); + return makeNode(type, sizeof(SQueryLogicPlan)); case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: - return sizeof(STagScanPhysiNode); + return makeNode(type, sizeof(STagScanPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: - return sizeof(STableScanPhysiNode); + return makeNode(type, sizeof(STableScanPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN: - return sizeof(STableSeqScanPhysiNode); + return makeNode(type, sizeof(STableSeqScanPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN: - return sizeof(SStreamScanPhysiNode); + return makeNode(type, sizeof(SStreamScanPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN: - return sizeof(SSystemTableScanPhysiNode); + return makeNode(type, sizeof(SSystemTableScanPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_PROJECT: - return sizeof(SProjectPhysiNode); + return makeNode(type, sizeof(SProjectPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_JOIN: - return sizeof(SJoinPhysiNode); + return makeNode(type, sizeof(SJoinPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_AGG: - return sizeof(SAggPhysiNode); + return makeNode(type, sizeof(SAggPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE: - return sizeof(SExchangePhysiNode); + return makeNode(type, sizeof(SExchangePhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_SORT: - return sizeof(SSortPhysiNode); + return makeNode(type, sizeof(SSortPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_INTERVAL: - return sizeof(SIntervalPhysiNode); + return makeNode(type, sizeof(SIntervalPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_STREAM_INTERVAL: - return sizeof(SStreamIntervalPhysiNode); + return makeNode(type, sizeof(SStreamIntervalPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_FILL: - return sizeof(SFillPhysiNode); + return makeNode(type, sizeof(SFillPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW: - return sizeof(SSessionWinodwPhysiNode); + return makeNode(type, sizeof(SSessionWinodwPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_STATE_WINDOW: - return sizeof(SStateWinodwPhysiNode); + return makeNode(type, sizeof(SStateWinodwPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_PARTITION: - return sizeof(SPartitionPhysiNode); + return makeNode(type, sizeof(SPartitionPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_DISPATCH: - return sizeof(SDataDispatcherNode); + return makeNode(type, sizeof(SDataDispatcherNode)); case QUERY_NODE_PHYSICAL_PLAN_INSERT: - return sizeof(SDataInserterNode); + return makeNode(type, sizeof(SDataInserterNode)); case QUERY_NODE_PHYSICAL_SUBPLAN: - return sizeof(SSubplan); + return makeNode(type, sizeof(SSubplan)); case QUERY_NODE_PHYSICAL_PLAN: - return sizeof(SQueryPlan); + return makeNode(type, sizeof(SQueryPlan)); default: break; } nodesError("nodesMakeNode unknown node = %s", nodesNodeName(type)); - return 0; -} - -SNodeptr nodesMakeNode(ENodeType type) { - SNode* p = taosMemoryCalloc(1, nodesNodeSize(type)); - if (NULL == p) { - return NULL; - } - setNodeType(p, type); - return p; + return NULL; } static void destroyVgDataBlockArray(SArray* pArray) { diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 474471d35b..a1c304118b 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -53,7 +53,8 @@ typedef enum EDatabaseOptionType { DB_OPTION_WAL, DB_OPTION_VGROUPS, DB_OPTION_SINGLE_STABLE, - DB_OPTION_RETENTIONS + DB_OPTION_RETENTIONS, + DB_OPTION_SCHEMALESS } EDatabaseOptionType; typedef enum ETableOptionType { @@ -169,6 +170,8 @@ SNode* createTopicOptions(SAstCreateContext* pCxt); SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pQuery, const SToken* pSubscribeDbName, SNode* pOptions); SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName); +SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pCGroupId, + const SToken* pTopicName); SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, const SToken* pValue); SNode* createDefaultExplainOptions(SAstCreateContext* pCxt); SNode* setExplainVerbose(SAstCreateContext* pCxt, SNode* pOptions, const SToken* pVal); diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 2cba1eb043..1fb60f83a5 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -180,6 +180,7 @@ db_options(A) ::= db_options(B) WAL NK_INTEGER(C). db_options(A) ::= db_options(B) VGROUPS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_VGROUPS, &C); } db_options(A) ::= db_options(B) SINGLE_STABLE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_SINGLE_STABLE, &C); } db_options(A) ::= db_options(B) RETENTIONS retention_list(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_RETENTIONS, C); } +db_options(A) ::= db_options(B) SCHEMALESS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_SCHEMALESS, &C); } alter_db_options(A) ::= alter_db_option(B). { A = createAlterDatabaseOptions(pCxt); A = setAlterDatabaseOption(pCxt, A, &B); } alter_db_options(A) ::= alter_db_options(B) alter_db_option(C). { A = setAlterDatabaseOption(pCxt, B, &C); } @@ -407,6 +408,7 @@ cmd ::= CREATE TOPIC not_exists_opt(A) cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) topic_options(D) AS db_name(C). { pCxt->pRootNode = createCreateTopicStmt(pCxt, A, &B, NULL, &C, D); } cmd ::= DROP TOPIC exists_opt(A) topic_name(B). { pCxt->pRootNode = createDropTopicStmt(pCxt, A, &B); } +cmd ::= DROP CGROUP exists_opt(A) cgroup_name(B) ON topic_name(C). { pCxt->pRootNode = createDropCGroupStmt(pCxt, A, &B, &C); } topic_options(A) ::= . { A = createTopicOptions(pCxt); } topic_options(A) ::= topic_options(B) WITH TABLE. { ((STopicOptions*)B)->withTable = true; A = B; } @@ -565,6 +567,10 @@ topic_name(A) ::= NK_ID(B). %destructor stream_name { } stream_name(A) ::= NK_ID(B). { A = B; } +%type cgroup_name { SToken } +%destructor cgroup_name { } +cgroup_name(A) ::= NK_ID(B). { A = B; } + /************************************************ expression **********************************************************/ expression(A) ::= literal(B). { A = B; } expression(A) ::= pseudo_column(B). { A = B; } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index eb814b3315..6b4c5f0ce5 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -29,12 +29,11 @@ } \ } while (0) -#define CHECK_RAW_EXPR_NODE(node) \ - do { \ - if (NULL == (node) || QUERY_NODE_RAW_EXPR != nodeType(node)) { \ - pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR; \ - return NULL; \ - } \ +#define CHECK_PARSER_STATUS(pCxt) \ + do { \ + if (TSDB_CODE_SUCCESS != pCxt->errCode) { \ + return NULL; \ + } \ } while (0) SToken nil_token = {.type = TK_NK_NIL, .n = 0, .z = NULL}; @@ -206,6 +205,7 @@ static bool checkComment(SAstCreateContext* pCxt, const SToken* pCommentToken, b } SNode* createRawExprNode(SAstCreateContext* pCxt, const SToken* pToken, SNode* pNode) { + CHECK_PARSER_STATUS(pCxt); SRawExprNode* target = (SRawExprNode*)nodesMakeNode(QUERY_NODE_RAW_EXPR); CHECK_OUT_OF_MEM(target); target->p = pToken->z; @@ -215,6 +215,7 @@ SNode* createRawExprNode(SAstCreateContext* pCxt, const SToken* pToken, SNode* p } SNode* createRawExprNodeExt(SAstCreateContext* pCxt, const SToken* pStart, const SToken* pEnd, SNode* pNode) { + CHECK_PARSER_STATUS(pCxt); SRawExprNode* target = (SRawExprNode*)nodesMakeNode(QUERY_NODE_RAW_EXPR); CHECK_OUT_OF_MEM(target); target->p = pStart->z; @@ -224,7 +225,7 @@ SNode* createRawExprNodeExt(SAstCreateContext* pCxt, const SToken* pStart, const } SNode* releaseRawExprNode(SAstCreateContext* pCxt, SNode* pNode) { - CHECK_RAW_EXPR_NODE(pNode); + CHECK_PARSER_STATUS(pCxt); SRawExprNode* pRawExpr = (SRawExprNode*)pNode; SNode* pExpr = pRawExpr->pNode; if (nodesIsExprNode(pExpr)) { @@ -247,6 +248,7 @@ SToken getTokenFromRawExprNode(SAstCreateContext* pCxt, SNode* pNode) { } SNodeList* createNodeList(SAstCreateContext* pCxt, SNode* pNode) { + CHECK_PARSER_STATUS(pCxt); SNodeList* list = nodesMakeList(); CHECK_OUT_OF_MEM(list); pCxt->errCode = nodesListAppend(list, pNode); @@ -254,11 +256,13 @@ SNodeList* createNodeList(SAstCreateContext* pCxt, SNode* pNode) { } SNodeList* addNodeToList(SAstCreateContext* pCxt, SNodeList* pList, SNode* pNode) { + CHECK_PARSER_STATUS(pCxt); pCxt->errCode = nodesListAppend(pList, pNode); return pList; } SNode* createColumnNode(SAstCreateContext* pCxt, SToken* pTableAlias, SToken* pColumnName) { + CHECK_PARSER_STATUS(pCxt); if (!checkTableName(pCxt, pTableAlias) || !checkColumnName(pCxt, pColumnName)) { return NULL; } @@ -272,6 +276,7 @@ SNode* createColumnNode(SAstCreateContext* pCxt, SToken* pTableAlias, SToken* pC } SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* pLiteral) { + CHECK_PARSER_STATUS(pCxt); SValueNode* val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); CHECK_OUT_OF_MEM(val); val->literal = strndup(pLiteral->z, pLiteral->n); @@ -291,6 +296,7 @@ SNode* createValueNode(SAstCreateContext* pCxt, int32_t dataType, const SToken* } SNode* createDurationValueNode(SAstCreateContext* pCxt, const SToken* pLiteral) { + CHECK_PARSER_STATUS(pCxt); SValueNode* val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); CHECK_OUT_OF_MEM(val); val->literal = strndup(pLiteral->z, pLiteral->n); @@ -304,6 +310,7 @@ SNode* createDurationValueNode(SAstCreateContext* pCxt, const SToken* pLiteral) } SNode* createDefaultDatabaseCondValue(SAstCreateContext* pCxt) { + CHECK_PARSER_STATUS(pCxt); if (NULL == pCxt->pQueryCxt->db) { return NULL; } @@ -321,6 +328,7 @@ SNode* createDefaultDatabaseCondValue(SAstCreateContext* pCxt) { } SNode* createPlaceholderValueNode(SAstCreateContext* pCxt, const SToken* pLiteral) { + CHECK_PARSER_STATUS(pCxt); SValueNode* val = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); CHECK_OUT_OF_MEM(val); val->literal = strndup(pLiteral->z, pLiteral->n); @@ -338,6 +346,7 @@ SNode* createPlaceholderValueNode(SAstCreateContext* pCxt, const SToken* pLitera } SNode* createLogicConditionNode(SAstCreateContext* pCxt, ELogicConditionType type, SNode* pParam1, SNode* pParam2) { + CHECK_PARSER_STATUS(pCxt); SLogicConditionNode* cond = (SLogicConditionNode*)nodesMakeNode(QUERY_NODE_LOGIC_CONDITION); CHECK_OUT_OF_MEM(cond); cond->condType = type; @@ -360,6 +369,7 @@ SNode* createLogicConditionNode(SAstCreateContext* pCxt, ELogicConditionType typ } SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pLeft, SNode* pRight) { + CHECK_PARSER_STATUS(pCxt); SOperatorNode* op = (SOperatorNode*)nodesMakeNode(QUERY_NODE_OPERATOR); CHECK_OUT_OF_MEM(op); op->opType = type; @@ -369,17 +379,20 @@ SNode* createOperatorNode(SAstCreateContext* pCxt, EOperatorType type, SNode* pL } SNode* createBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight) { + CHECK_PARSER_STATUS(pCxt); return createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, createOperatorNode(pCxt, OP_TYPE_GREATER_EQUAL, pExpr, pLeft), createOperatorNode(pCxt, OP_TYPE_LOWER_EQUAL, nodesCloneNode(pExpr), pRight)); } SNode* createNotBetweenAnd(SAstCreateContext* pCxt, SNode* pExpr, SNode* pLeft, SNode* pRight) { + CHECK_PARSER_STATUS(pCxt); return createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, createOperatorNode(pCxt, OP_TYPE_LOWER_THAN, pExpr, pLeft), createOperatorNode(pCxt, OP_TYPE_GREATER_THAN, nodesCloneNode(pExpr), pRight)); } static SNode* createPrimaryKeyCol(SAstCreateContext* pCxt) { + CHECK_PARSER_STATUS(pCxt); SColumnNode* pCol = nodesMakeNode(QUERY_NODE_COLUMN); CHECK_OUT_OF_MEM(pCol); pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID; @@ -388,6 +401,7 @@ static SNode* createPrimaryKeyCol(SAstCreateContext* pCxt) { } SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNodeList* pParameterList) { + CHECK_PARSER_STATUS(pCxt); if (0 == strncasecmp("_rowts", pFuncName->z, pFuncName->n) || 0 == strncasecmp("_c0", pFuncName->z, pFuncName->n)) { return createPrimaryKeyCol(pCxt); } @@ -399,6 +413,7 @@ SNode* createFunctionNode(SAstCreateContext* pCxt, const SToken* pFuncName, SNod } SNode* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataType dt) { + CHECK_PARSER_STATUS(pCxt); SFunctionNode* func = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); CHECK_OUT_OF_MEM(func); strcpy(func->functionName, "cast"); @@ -413,6 +428,7 @@ SNode* createCastFunctionNode(SAstCreateContext* pCxt, SNode* pExpr, SDataType d } SNode* createNodeListNode(SAstCreateContext* pCxt, SNodeList* pList) { + CHECK_PARSER_STATUS(pCxt); SNodeListNode* list = (SNodeListNode*)nodesMakeNode(QUERY_NODE_NODE_LIST); CHECK_OUT_OF_MEM(list); list->pNodeList = pList; @@ -420,6 +436,7 @@ SNode* createNodeListNode(SAstCreateContext* pCxt, SNodeList* pList) { } SNode* createNodeListNodeEx(SAstCreateContext* pCxt, SNode* p1, SNode* p2) { + CHECK_PARSER_STATUS(pCxt); SNodeListNode* list = (SNodeListNode*)nodesMakeNode(QUERY_NODE_NODE_LIST); CHECK_OUT_OF_MEM(list); list->pNodeList = nodesMakeList(); @@ -430,6 +447,7 @@ SNode* createNodeListNodeEx(SAstCreateContext* pCxt, SNode* p1, SNode* p2) { } SNode* createRealTableNode(SAstCreateContext* pCxt, SToken* pDbName, SToken* pTableName, SToken* pTableAlias) { + CHECK_PARSER_STATUS(pCxt); if (!checkDbName(pCxt, pDbName, true) || !checkTableName(pCxt, pTableName) || !checkTableName(pCxt, pTableAlias)) { return NULL; } @@ -450,6 +468,7 @@ SNode* createRealTableNode(SAstCreateContext* pCxt, SToken* pDbName, SToken* pTa } SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, const SToken* pTableAlias) { + CHECK_PARSER_STATUS(pCxt); STempTableNode* tempTable = (STempTableNode*)nodesMakeNode(QUERY_NODE_TEMP_TABLE); CHECK_OUT_OF_MEM(tempTable); tempTable->pSubquery = pSubquery; @@ -467,6 +486,7 @@ SNode* createTempTableNode(SAstCreateContext* pCxt, SNode* pSubquery, const STok } SNode* createJoinTableNode(SAstCreateContext* pCxt, EJoinType type, SNode* pLeft, SNode* pRight, SNode* pJoinCond) { + CHECK_PARSER_STATUS(pCxt); SJoinTableNode* joinTable = (SJoinTableNode*)nodesMakeNode(QUERY_NODE_JOIN_TABLE); CHECK_OUT_OF_MEM(joinTable); joinTable->joinType = type; @@ -477,6 +497,7 @@ SNode* createJoinTableNode(SAstCreateContext* pCxt, EJoinType type, SNode* pLeft } SNode* createLimitNode(SAstCreateContext* pCxt, const SToken* pLimit, const SToken* pOffset) { + CHECK_PARSER_STATUS(pCxt); SLimitNode* limitNode = (SLimitNode*)nodesMakeNode(QUERY_NODE_LIMIT); CHECK_OUT_OF_MEM(limitNode); limitNode->limit = taosStr2Int64(pLimit->z, NULL, 10); @@ -487,6 +508,7 @@ SNode* createLimitNode(SAstCreateContext* pCxt, const SToken* pLimit, const STok } SNode* createOrderByExprNode(SAstCreateContext* pCxt, SNode* pExpr, EOrder order, ENullOrder nullOrder) { + CHECK_PARSER_STATUS(pCxt); SOrderByExprNode* orderByExpr = (SOrderByExprNode*)nodesMakeNode(QUERY_NODE_ORDER_BY_EXPR); CHECK_OUT_OF_MEM(orderByExpr); orderByExpr->pExpr = pExpr; @@ -499,6 +521,7 @@ SNode* createOrderByExprNode(SAstCreateContext* pCxt, SNode* pExpr, EOrder order } SNode* createSessionWindowNode(SAstCreateContext* pCxt, SNode* pCol, SNode* pGap) { + CHECK_PARSER_STATUS(pCxt); SSessionWindowNode* session = (SSessionWindowNode*)nodesMakeNode(QUERY_NODE_SESSION_WINDOW); CHECK_OUT_OF_MEM(session); session->pCol = (SColumnNode*)pCol; @@ -507,6 +530,7 @@ SNode* createSessionWindowNode(SAstCreateContext* pCxt, SNode* pCol, SNode* pGap } SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pExpr) { + CHECK_PARSER_STATUS(pCxt); SStateWindowNode* state = (SStateWindowNode*)nodesMakeNode(QUERY_NODE_STATE_WINDOW); CHECK_OUT_OF_MEM(state); state->pCol = createPrimaryKeyCol(pCxt); @@ -520,6 +544,7 @@ SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pExpr) { SNode* createIntervalWindowNode(SAstCreateContext* pCxt, SNode* pInterval, SNode* pOffset, SNode* pSliding, SNode* pFill) { + CHECK_PARSER_STATUS(pCxt); SIntervalWindowNode* interval = (SIntervalWindowNode*)nodesMakeNode(QUERY_NODE_INTERVAL_WINDOW); CHECK_OUT_OF_MEM(interval); interval->pCol = createPrimaryKeyCol(pCxt); @@ -535,6 +560,7 @@ SNode* createIntervalWindowNode(SAstCreateContext* pCxt, SNode* pInterval, SNode } SNode* createFillNode(SAstCreateContext* pCxt, EFillMode mode, SNode* pValues) { + CHECK_PARSER_STATUS(pCxt); SFillNode* fill = (SFillNode*)nodesMakeNode(QUERY_NODE_FILL); CHECK_OUT_OF_MEM(fill); fill->mode = mode; @@ -549,6 +575,7 @@ SNode* createFillNode(SAstCreateContext* pCxt, EFillMode mode, SNode* pValues) { } SNode* createGroupingSetNode(SAstCreateContext* pCxt, SNode* pNode) { + CHECK_PARSER_STATUS(pCxt); SGroupingSetNode* groupingSet = (SGroupingSetNode*)nodesMakeNode(QUERY_NODE_GROUPING_SET); CHECK_OUT_OF_MEM(groupingSet); groupingSet->groupingSetType = GP_TYPE_NORMAL; @@ -558,9 +585,7 @@ SNode* createGroupingSetNode(SAstCreateContext* pCxt, SNode* pNode) { } SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, const SToken* pAlias) { - if (NULL == pNode || TSDB_CODE_SUCCESS != pCxt->errCode) { - return pNode; - } + CHECK_PARSER_STATUS(pCxt); int32_t len = TMIN(sizeof(((SExprNode*)pNode)->aliasName) - 1, pAlias->n); strncpy(((SExprNode*)pNode)->aliasName, pAlias->z, len); ((SExprNode*)pNode)->aliasName[len] = '\0'; @@ -570,6 +595,7 @@ SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, const SToken* p } SNode* addWhereClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pWhere) { + CHECK_PARSER_STATUS(pCxt); if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { ((SSelectStmt*)pStmt)->pWhere = pWhere; } @@ -577,6 +603,7 @@ SNode* addWhereClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pWhere) { } SNode* addPartitionByClause(SAstCreateContext* pCxt, SNode* pStmt, SNodeList* pPartitionByList) { + CHECK_PARSER_STATUS(pCxt); if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { ((SSelectStmt*)pStmt)->pPartitionByList = pPartitionByList; } @@ -584,6 +611,7 @@ SNode* addPartitionByClause(SAstCreateContext* pCxt, SNode* pStmt, SNodeList* pP } SNode* addWindowClauseClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pWindow) { + CHECK_PARSER_STATUS(pCxt); if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { ((SSelectStmt*)pStmt)->pWindow = pWindow; } @@ -591,6 +619,7 @@ SNode* addWindowClauseClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pWind } SNode* addGroupByClause(SAstCreateContext* pCxt, SNode* pStmt, SNodeList* pGroupByList) { + CHECK_PARSER_STATUS(pCxt); if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { ((SSelectStmt*)pStmt)->pGroupByList = pGroupByList; } @@ -598,6 +627,7 @@ SNode* addGroupByClause(SAstCreateContext* pCxt, SNode* pStmt, SNodeList* pGroup } SNode* addHavingClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pHaving) { + CHECK_PARSER_STATUS(pCxt); if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { ((SSelectStmt*)pStmt)->pHaving = pHaving; } @@ -605,6 +635,7 @@ SNode* addHavingClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pHaving) { } SNode* addOrderByClause(SAstCreateContext* pCxt, SNode* pStmt, SNodeList* pOrderByList) { + CHECK_PARSER_STATUS(pCxt); if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { ((SSelectStmt*)pStmt)->pOrderByList = pOrderByList; } @@ -612,6 +643,7 @@ SNode* addOrderByClause(SAstCreateContext* pCxt, SNode* pStmt, SNodeList* pOrder } SNode* addSlimitClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pSlimit) { + CHECK_PARSER_STATUS(pCxt); if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { ((SSelectStmt*)pStmt)->pSlimit = (SLimitNode*)pSlimit; } @@ -619,6 +651,7 @@ SNode* addSlimitClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pSlimit) { } SNode* addLimitClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pLimit) { + CHECK_PARSER_STATUS(pCxt); if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { ((SSelectStmt*)pStmt)->pLimit = (SLimitNode*)pLimit; } @@ -626,6 +659,7 @@ SNode* addLimitClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pLimit) { } SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pProjectionList, SNode* pTable) { + CHECK_PARSER_STATUS(pCxt); SSelectStmt* select = (SSelectStmt*)nodesMakeNode(QUERY_NODE_SELECT_STMT); CHECK_OUT_OF_MEM(select); select->isDistinct = isDistinct; @@ -637,6 +671,7 @@ SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pPr } SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode* pLeft, SNode* pRight) { + CHECK_PARSER_STATUS(pCxt); SSetOperator* setOp = (SSetOperator*)nodesMakeNode(QUERY_NODE_SET_OPERATOR); CHECK_OUT_OF_MEM(setOp); setOp->opType = type; @@ -647,6 +682,7 @@ SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode* } SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt) { + CHECK_PARSER_STATUS(pCxt); SDatabaseOptions* pOptions = nodesMakeNode(QUERY_NODE_DATABASE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->buffer = TSDB_DEFAULT_BUFFER_PER_VNODE; @@ -667,10 +703,12 @@ SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt) { pOptions->walLevel = TSDB_DEFAULT_WAL_LEVEL; pOptions->numOfVgroups = TSDB_DEFAULT_VN_PER_DB; pOptions->singleStable = TSDB_DEFAULT_DB_SINGLE_STABLE; + pOptions->schemaless = TSDB_DEFAULT_DB_SCHEMALESS; return (SNode*)pOptions; } SNode* createAlterDatabaseOptions(SAstCreateContext* pCxt) { + CHECK_PARSER_STATUS(pCxt); SDatabaseOptions* pOptions = nodesMakeNode(QUERY_NODE_DATABASE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->buffer = -1; @@ -691,10 +729,12 @@ SNode* createAlterDatabaseOptions(SAstCreateContext* pCxt) { pOptions->walLevel = -1; pOptions->numOfVgroups = -1; pOptions->singleStable = -1; + pOptions->schemaless = -1; return (SNode*)pOptions; } SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, void* pVal) { + CHECK_PARSER_STATUS(pCxt); switch (type) { case DB_OPTION_BUFFER: ((SDatabaseOptions*)pOptions)->buffer = taosStr2Int32(((SToken*)pVal)->z, NULL, 10); @@ -754,6 +794,9 @@ SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOpti case DB_OPTION_RETENTIONS: ((SDatabaseOptions*)pOptions)->pRetentions = pVal; break; + case DB_OPTION_SCHEMALESS: + ((SDatabaseOptions*)pOptions)->schemaless = taosStr2Int8(((SToken*)pVal)->z, NULL, 10); + break; default: break; } @@ -761,6 +804,7 @@ SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOpti } SNode* setAlterDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOption* pAlterOption) { + CHECK_PARSER_STATUS(pCxt); switch (pAlterOption->type) { case DB_OPTION_KEEP: case DB_OPTION_RETENTIONS: @@ -772,6 +816,7 @@ SNode* setAlterDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOp } SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, SToken* pDbName, SNode* pOptions) { + CHECK_PARSER_STATUS(pCxt); if (!checkDbName(pCxt, pDbName, false)) { return NULL; } @@ -784,6 +829,7 @@ SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, STok } SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pDbName) { + CHECK_PARSER_STATUS(pCxt); if (!checkDbName(pCxt, pDbName, false)) { return NULL; } @@ -795,6 +841,7 @@ SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, STo } SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode* pOptions) { + CHECK_PARSER_STATUS(pCxt); if (!checkDbName(pCxt, pDbName, false)) { return NULL; } @@ -806,6 +853,7 @@ SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode* } SNode* createDefaultTableOptions(SAstCreateContext* pCxt) { + CHECK_PARSER_STATUS(pCxt); STableOptions* pOptions = nodesMakeNode(QUERY_NODE_TABLE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->delay = TSDB_DEFAULT_ROLLUP_DELAY; @@ -815,6 +863,7 @@ SNode* createDefaultTableOptions(SAstCreateContext* pCxt) { } SNode* createAlterTableOptions(SAstCreateContext* pCxt) { + CHECK_PARSER_STATUS(pCxt); STableOptions* pOptions = nodesMakeNode(QUERY_NODE_TABLE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->delay = -1; @@ -824,6 +873,7 @@ SNode* createAlterTableOptions(SAstCreateContext* pCxt) { } SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, void* pVal) { + CHECK_PARSER_STATUS(pCxt); switch (type) { case TABLE_OPTION_COMMENT: if (checkComment(pCxt, (SToken*)pVal, true)) { @@ -853,6 +903,7 @@ SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType } SNode* createColumnDefNode(SAstCreateContext* pCxt, SToken* pColName, SDataType dataType, const SToken* pComment) { + CHECK_PARSER_STATUS(pCxt); if (!checkColumnName(pCxt, pColName) || !checkComment(pCxt, pComment, false)) { return NULL; } @@ -879,9 +930,7 @@ SDataType createVarLenDataType(uint8_t type, const SToken* pLen) { SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNodeList* pCols, SNodeList* pTags, SNode* pOptions) { - if (NULL == pRealTable) { - return NULL; - } + CHECK_PARSER_STATUS(pCxt); SCreateTableStmt* pStmt = (SCreateTableStmt*)nodesMakeNode(QUERY_NODE_CREATE_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName); @@ -896,9 +945,7 @@ SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, SNode* SNode* createCreateSubTableClause(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNode* pUseRealTable, SNodeList* pSpecificTags, SNodeList* pValsOfTags, SNode* pOptions) { - if (NULL == pRealTable) { - return NULL; - } + CHECK_PARSER_STATUS(pCxt); SCreateSubTableClause* pStmt = nodesMakeNode(QUERY_NODE_CREATE_SUBTABLE_CLAUSE); CHECK_OUT_OF_MEM(pStmt); strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName); @@ -914,6 +961,7 @@ SNode* createCreateSubTableClause(SAstCreateContext* pCxt, bool ignoreExists, SN } SNode* createCreateMultiTableStmt(SAstCreateContext* pCxt, SNodeList* pSubTables) { + CHECK_PARSER_STATUS(pCxt); SCreateMultiTableStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_MULTI_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->pSubTables = pSubTables; @@ -921,9 +969,7 @@ SNode* createCreateMultiTableStmt(SAstCreateContext* pCxt, SNodeList* pSubTables } SNode* createDropTableClause(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable) { - if (NULL == pRealTable) { - return NULL; - } + CHECK_PARSER_STATUS(pCxt); SDropTableClause* pStmt = nodesMakeNode(QUERY_NODE_DROP_TABLE_CLAUSE); CHECK_OUT_OF_MEM(pStmt); strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName); @@ -934,6 +980,7 @@ SNode* createDropTableClause(SAstCreateContext* pCxt, bool ignoreNotExists, SNod } SNode* createDropTableStmt(SAstCreateContext* pCxt, SNodeList* pTables) { + CHECK_PARSER_STATUS(pCxt); SDropTableStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->pTables = pTables; @@ -941,6 +988,7 @@ SNode* createDropTableStmt(SAstCreateContext* pCxt, SNodeList* pTables) { } SNode* createDropSuperTableStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable) { + CHECK_PARSER_STATUS(pCxt); SDropSuperTableStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_SUPER_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName); @@ -958,9 +1006,7 @@ static SNode* createAlterTableStmtFinalize(SNode* pRealTable, SAlterTableStmt* p } SNode* createAlterTableModifyOptions(SAstCreateContext* pCxt, SNode* pRealTable, SNode* pOptions) { - if (NULL == pRealTable) { - return NULL; - } + CHECK_PARSER_STATUS(pCxt); SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->alterType = TSDB_ALTER_TABLE_UPDATE_OPTIONS; @@ -970,7 +1016,8 @@ SNode* createAlterTableModifyOptions(SAstCreateContext* pCxt, SNode* pRealTable, SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, SToken* pColName, SDataType dataType) { - if (NULL == pRealTable || !checkColumnName(pCxt, pColName)) { + CHECK_PARSER_STATUS(pCxt); + if (!checkColumnName(pCxt, pColName)) { return NULL; } SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); @@ -982,7 +1029,8 @@ SNode* createAlterTableAddModifyCol(SAstCreateContext* pCxt, SNode* pRealTable, } SNode* createAlterTableDropCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, SToken* pColName) { - if (NULL == pRealTable || !checkColumnName(pCxt, pColName)) { + CHECK_PARSER_STATUS(pCxt); + if (!checkColumnName(pCxt, pColName)) { return NULL; } SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); @@ -994,7 +1042,8 @@ SNode* createAlterTableDropCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_ SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int8_t alterType, SToken* pOldColName, SToken* pNewColName) { - if (NULL == pRealTable || !checkColumnName(pCxt, pOldColName) || !checkColumnName(pCxt, pNewColName)) { + CHECK_PARSER_STATUS(pCxt); + if (!checkColumnName(pCxt, pOldColName) || !checkColumnName(pCxt, pNewColName)) { return NULL; } SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); @@ -1006,7 +1055,8 @@ SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int } SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, SToken* pTagName, SNode* pVal) { - if (NULL == pRealTable || !checkColumnName(pCxt, pTagName)) { + CHECK_PARSER_STATUS(pCxt); + if (!checkColumnName(pCxt, pTagName)) { return NULL; } SAlterTableStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_TABLE_STMT); @@ -1018,6 +1068,7 @@ SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, SToken } SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName) { + CHECK_PARSER_STATUS(pCxt); if (!checkDbName(pCxt, pDbName, false)) { return NULL; } @@ -1033,13 +1084,13 @@ static bool needDbShowStmt(ENodeType type) { } SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbNamePattern) { + CHECK_PARSER_STATUS(pCxt); if (needDbShowStmt(type) && NULL == pDbName && NULL == pCxt->pQueryCxt->db) { snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "db not specified"); pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR; return NULL; } SShowStmt* pStmt = nodesMakeNode(type); - ; CHECK_OUT_OF_MEM(pStmt); pStmt->pDbName = pDbName; pStmt->pTbNamePattern = pTbNamePattern; @@ -1047,18 +1098,21 @@ SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, S } SNode* createShowCreateDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName) { + CHECK_PARSER_STATUS(pCxt); SNode* pStmt = nodesMakeNode(QUERY_NODE_SHOW_CREATE_DATABASE_STMT); CHECK_OUT_OF_MEM(pStmt); return pStmt; } SNode* createShowCreateTableStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pRealTable) { + CHECK_PARSER_STATUS(pCxt); SNode* pStmt = nodesMakeNode(type); CHECK_OUT_OF_MEM(pStmt); return pStmt; } SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword) { + CHECK_PARSER_STATUS(pCxt); char password[TSDB_USET_PASSWORD_LEN] = {0}; if (!checkUserName(pCxt, pUserName) || !checkPassword(pCxt, pPassword, password)) { return NULL; @@ -1071,6 +1125,7 @@ SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const ST } SNode* createAlterUserStmt(SAstCreateContext* pCxt, SToken* pUserName, int8_t alterType, const SToken* pVal) { + CHECK_PARSER_STATUS(pCxt); if (!checkUserName(pCxt, pUserName)) { return NULL; } @@ -1090,6 +1145,7 @@ SNode* createAlterUserStmt(SAstCreateContext* pCxt, SToken* pUserName, int8_t al } SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName) { + CHECK_PARSER_STATUS(pCxt); if (!checkUserName(pCxt, pUserName)) { return NULL; } @@ -1100,6 +1156,7 @@ SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName) { } SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SToken* pPort) { + CHECK_PARSER_STATUS(pCxt); int32_t port = 0; char fqdn[TSDB_FQDN_LEN] = {0}; if (NULL == pPort) { @@ -1121,6 +1178,7 @@ SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const } SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode) { + CHECK_PARSER_STATUS(pCxt); SDropDnodeStmt* pStmt = (SDropDnodeStmt*)nodesMakeNode(QUERY_NODE_DROP_DNODE_STMT); CHECK_OUT_OF_MEM(pStmt); if (TK_NK_INTEGER == pDnode->type) { @@ -1136,6 +1194,7 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode) { SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SToken* pConfig, const SToken* pValue) { + CHECK_PARSER_STATUS(pCxt); SAlterDnodeStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_DNODE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->dnodeId = taosStr2Int32(pDnode->z, NULL, 10); @@ -1148,6 +1207,7 @@ SNode* createAlterDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode, const SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool ignoreExists, SToken* pIndexName, SToken* pTableName, SNodeList* pCols, SNode* pOptions) { + CHECK_PARSER_STATUS(pCxt); if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName) || !checkDbName(pCxt, NULL, true)) { return NULL; } @@ -1164,6 +1224,7 @@ SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, bool igno SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding) { + CHECK_PARSER_STATUS(pCxt); SIndexOptions* pOptions = nodesMakeNode(QUERY_NODE_INDEX_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->pFuncs = pFuncs; @@ -1174,6 +1235,7 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt } SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pIndexName, SToken* pTableName) { + CHECK_PARSER_STATUS(pCxt); if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName)) { return NULL; } @@ -1186,6 +1248,7 @@ SNode* createDropIndexStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken } SNode* createCreateComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId) { + CHECK_PARSER_STATUS(pCxt); SCreateComponentNodeStmt* pStmt = nodesMakeNode(type); CHECK_OUT_OF_MEM(pStmt); pStmt->dnodeId = taosStr2Int32(pDnodeId->z, NULL, 10); @@ -1194,6 +1257,7 @@ SNode* createCreateComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, co } SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pDnodeId) { + CHECK_PARSER_STATUS(pCxt); SDropComponentNodeStmt* pStmt = nodesMakeNode(type); CHECK_OUT_OF_MEM(pStmt); pStmt->dnodeId = taosStr2Int32(pDnodeId->z, NULL, 10); @@ -1202,6 +1266,7 @@ SNode* createDropComponentNodeStmt(SAstCreateContext* pCxt, ENodeType type, cons } SNode* createTopicOptions(SAstCreateContext* pCxt) { + CHECK_PARSER_STATUS(pCxt); STopicOptions* pOptions = nodesMakeNode(QUERY_NODE_TOPIC_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->withTable = false; @@ -1212,6 +1277,7 @@ SNode* createTopicOptions(SAstCreateContext* pCxt) { SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pQuery, const SToken* pSubscribeDbName, SNode* pOptions) { + CHECK_PARSER_STATUS(pCxt); SCreateTopicStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT); CHECK_OUT_OF_MEM(pStmt); strncpy(pStmt->topicName, pTopicName->z, pTopicName->n); @@ -1225,6 +1291,7 @@ SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const S } SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName) { + CHECK_PARSER_STATUS(pCxt); SDropTopicStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_TOPIC_STMT); CHECK_OUT_OF_MEM(pStmt); strncpy(pStmt->topicName, pTopicName->z, pTopicName->n); @@ -1232,7 +1299,19 @@ SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const return (SNode*)pStmt; } +SNode* createDropCGroupStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pCGroupId, + const SToken* pTopicName) { + CHECK_PARSER_STATUS(pCxt); + SDropCGroupStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_CGROUP_STMT); + CHECK_OUT_OF_MEM(pStmt); + pStmt->ignoreNotExists = ignoreNotExists; + strncpy(pStmt->topicName, pTopicName->z, pTopicName->n); + strncpy(pStmt->cgroup, pCGroupId->z, pCGroupId->n); + return (SNode*)pStmt; +} + SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, const SToken* pValue) { + CHECK_PARSER_STATUS(pCxt); SAlterLocalStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_LOCAL_STMT); CHECK_OUT_OF_MEM(pStmt); trimString(pConfig->z, pConfig->n, pStmt->config, sizeof(pStmt->config)); @@ -1243,6 +1322,7 @@ SNode* createAlterLocalStmt(SAstCreateContext* pCxt, const SToken* pConfig, cons } SNode* createDefaultExplainOptions(SAstCreateContext* pCxt) { + CHECK_PARSER_STATUS(pCxt); SExplainOptions* pOptions = nodesMakeNode(QUERY_NODE_EXPLAIN_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->verbose = TSDB_DEFAULT_EXPLAIN_VERBOSE; @@ -1251,16 +1331,19 @@ SNode* createDefaultExplainOptions(SAstCreateContext* pCxt) { } SNode* setExplainVerbose(SAstCreateContext* pCxt, SNode* pOptions, const SToken* pVal) { + CHECK_PARSER_STATUS(pCxt); ((SExplainOptions*)pOptions)->verbose = (0 == strncasecmp(pVal->z, "true", pVal->n)); return pOptions; } SNode* setExplainRatio(SAstCreateContext* pCxt, SNode* pOptions, const SToken* pVal) { + CHECK_PARSER_STATUS(pCxt); ((SExplainOptions*)pOptions)->ratio = taosStr2Double(pVal->z, NULL); return pOptions; } SNode* createExplainStmt(SAstCreateContext* pCxt, bool analyze, SNode* pOptions, SNode* pQuery) { + CHECK_PARSER_STATUS(pCxt); SExplainStmt* pStmt = nodesMakeNode(QUERY_NODE_EXPLAIN_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->analyze = analyze; @@ -1270,9 +1353,7 @@ SNode* createExplainStmt(SAstCreateContext* pCxt, bool analyze, SNode* pOptions, } SNode* createDescribeStmt(SAstCreateContext* pCxt, SNode* pRealTable) { - if (NULL == pRealTable) { - return NULL; - } + CHECK_PARSER_STATUS(pCxt); SDescribeStmt* pStmt = nodesMakeNode(QUERY_NODE_DESCRIBE_STMT); CHECK_OUT_OF_MEM(pStmt); strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName); @@ -1282,12 +1363,14 @@ SNode* createDescribeStmt(SAstCreateContext* pCxt, SNode* pRealTable) { } SNode* createResetQueryCacheStmt(SAstCreateContext* pCxt) { + CHECK_PARSER_STATUS(pCxt); SNode* pStmt = nodesMakeNode(QUERY_NODE_RESET_QUERY_CACHE_STMT); CHECK_OUT_OF_MEM(pStmt); return pStmt; } SNode* createCompactStmt(SAstCreateContext* pCxt, SNodeList* pVgroups) { + CHECK_PARSER_STATUS(pCxt); SNode* pStmt = nodesMakeNode(QUERY_NODE_COMPACT_STMT); CHECK_OUT_OF_MEM(pStmt); return pStmt; @@ -1295,6 +1378,7 @@ SNode* createCompactStmt(SAstCreateContext* pCxt, SNodeList* pVgroups) { SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool aggFunc, const SToken* pFuncName, const SToken* pLibPath, SDataType dataType, int32_t bufSize) { + CHECK_PARSER_STATUS(pCxt); if (pLibPath->n <= 2) { pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR; return NULL; @@ -1311,6 +1395,7 @@ SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool ignoreExists, bool } SNode* createDropFunctionStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pFuncName) { + CHECK_PARSER_STATUS(pCxt); SDropFunctionStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_FUNCTION_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->ignoreNotExists = ignoreNotExists; @@ -1319,6 +1404,7 @@ SNode* createDropFunctionStmt(SAstCreateContext* pCxt, bool ignoreNotExists, con } SNode* createStreamOptions(SAstCreateContext* pCxt) { + CHECK_PARSER_STATUS(pCxt); SStreamOptions* pOptions = nodesMakeNode(QUERY_NODE_STREAM_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->triggerType = STREAM_TRIGGER_AT_ONCE; @@ -1327,6 +1413,7 @@ SNode* createStreamOptions(SAstCreateContext* pCxt) { SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pStreamName, SNode* pRealTable, SNode* pOptions, SNode* pQuery) { + CHECK_PARSER_STATUS(pCxt); SCreateStreamStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_STREAM_STMT); CHECK_OUT_OF_MEM(pStmt); strncpy(pStmt->streamName, pStreamName->z, pStreamName->n); @@ -1342,6 +1429,7 @@ SNode* createCreateStreamStmt(SAstCreateContext* pCxt, bool ignoreExists, const } SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pStreamName) { + CHECK_PARSER_STATUS(pCxt); SDropStreamStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_STREAM_STMT); CHECK_OUT_OF_MEM(pStmt); strncpy(pStmt->streamName, pStreamName->z, pStreamName->n); @@ -1350,6 +1438,7 @@ SNode* createDropStreamStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const } SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId) { + CHECK_PARSER_STATUS(pCxt); SKillStmt* pStmt = nodesMakeNode(type); CHECK_OUT_OF_MEM(pStmt); pStmt->targetId = taosStr2Int32(pId->z, NULL, 10); @@ -1357,30 +1446,35 @@ SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId } SNode* createMergeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId1, const SToken* pVgId2) { + CHECK_PARSER_STATUS(pCxt); SNode* pStmt = nodesMakeNode(QUERY_NODE_MERGE_VGROUP_STMT); CHECK_OUT_OF_MEM(pStmt); return pStmt; } SNode* createRedistributeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId, SNodeList* pDnodes) { + CHECK_PARSER_STATUS(pCxt); SNode* pStmt = nodesMakeNode(QUERY_NODE_REDISTRIBUTE_VGROUP_STMT); CHECK_OUT_OF_MEM(pStmt); return pStmt; } SNode* createSplitVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId) { + CHECK_PARSER_STATUS(pCxt); SNode* pStmt = nodesMakeNode(QUERY_NODE_SPLIT_VGROUP_STMT); CHECK_OUT_OF_MEM(pStmt); return pStmt; } SNode* createSyncdbStmt(SAstCreateContext* pCxt, const SToken* pDbName) { + CHECK_PARSER_STATUS(pCxt); SNode* pStmt = nodesMakeNode(QUERY_NODE_SYNCDB_STMT); CHECK_OUT_OF_MEM(pStmt); return pStmt; } SNode* createGrantStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDbName, SToken* pUserName) { + CHECK_PARSER_STATUS(pCxt); if (!checkDbName(pCxt, pDbName, false) || !checkUserName(pCxt, pUserName)) { return NULL; } @@ -1393,6 +1487,7 @@ SNode* createGrantStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDbN } SNode* createRevokeStmt(SAstCreateContext* pCxt, int64_t privileges, SToken* pDbName, SToken* pUserName) { + CHECK_PARSER_STATUS(pCxt); if (!checkDbName(pCxt, pDbName, false) || !checkUserName(pCxt, pUserName)) { return NULL; } diff --git a/source/libs/parser/src/parCalcConst.c b/source/libs/parser/src/parCalcConst.c index 7b24d93ad1..42b001c131 100644 --- a/source/libs/parser/src/parCalcConst.c +++ b/source/libs/parser/src/parCalcConst.c @@ -176,11 +176,11 @@ static int32_t calcConstProject(SNode* pProject, SNode** pNew) { } int32_t code = scalarCalculateConstants(pProject, pNew); - if (TSDB_CODE_SUCCESS == code && QUERY_NODE_VALUE == nodeType(pNew) && NULL != pAssociation) { + if (TSDB_CODE_SUCCESS == code && QUERY_NODE_VALUE == nodeType(*pNew) && NULL != pAssociation) { int32_t size = taosArrayGetSize(pAssociation); for (int32_t i = 0; i < size; ++i) { - SNode** pCol = taosArrayGet(pAssociation, i); - *pCol = nodesCloneNode(pNew); + SNode** pCol = taosArrayGetP(pAssociation, i); + *pCol = nodesCloneNode(*pNew); if (NULL == *pCol) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -233,9 +233,9 @@ static int32_t calcConstGroupBy(SCalcConstContext* pCxt, SSelectStmt* pSelect) { } static int32_t calcConstSelect(SCalcConstContext* pCxt, SSelectStmt* pSelect, bool subquery) { - int32_t code = calcConstProjections(pCxt, pSelect, subquery); + int32_t code = calcConstFromTable(pCxt, pSelect); if (TSDB_CODE_SUCCESS == code) { - code = calcConstFromTable(pCxt, pSelect); + code = calcConstProjections(pCxt, pSelect, subquery); } if (TSDB_CODE_SUCCESS == code) { code = calcConstSelectCondition(pCxt, pSelect, &pSelect->pWhere); diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 8fb9780f8a..540de2d639 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -53,6 +53,7 @@ static SKeyword keywordTable[] = { {"CACHE", TK_CACHE}, {"CACHELAST", TK_CACHELAST}, {"CAST", TK_CAST}, + {"CGROUP", TK_CGROUP}, {"CLUSTER", TK_CLUSTER}, {"COLUMN", TK_COLUMN}, {"COMMENT", TK_COMMENT}, @@ -156,6 +157,7 @@ static SKeyword keywordTable[] = { {"REVOKE", TK_REVOKE}, {"ROLLUP", TK_ROLLUP}, {"SCHEMA", TK_SCHEMA}, + {"SCHEMALESS", TK_SCHEMALESS}, {"SCORES", TK_SCORES}, {"SELECT", TK_SELECT}, {"SESSION", TK_SESSION}, @@ -605,12 +607,12 @@ uint32_t tGetToken(const char* z, uint32_t* tokenId) { } return i; } - case '[': { - for (i = 1; z[i] && z[i - 1] != ']'; i++) { - } - *tokenId = TK_NK_ID; - return i; - } + // case '[': { + // for (i = 1; z[i] && z[i - 1] != ']'; i++) { + // } + // *tokenId = TK_NK_ID; + // return i; + // } case 'T': case 't': case 'F': diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 472f74e4e8..196ad6ef7c 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -342,12 +342,14 @@ static void setColumnInfoBySchema(const SRealTableNode* pTable, const SSchema* p } } -static void setColumnInfoByExpr(const STableNode* pTable, SExprNode* pExpr, SColumnNode* pCol) { +static void setColumnInfoByExpr(const STableNode* pTable, SExprNode* pExpr, SColumnNode** pColRef) { + SColumnNode* pCol = *pColRef; + pCol->pProjectRef = (SNode*)pExpr; if (NULL == pExpr->pAssociation) { pExpr->pAssociation = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES); } - taosArrayPush(pExpr->pAssociation, &pCol); + taosArrayPush(pExpr->pAssociation, &pColRef); if (NULL != pTable) { strcpy(pCol->tableAlias, pTable->tableAlias); } else if (QUERY_NODE_COLUMN == nodeType(pExpr)) { @@ -385,7 +387,7 @@ 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); + setColumnInfoByExpr(pTable, (SExprNode*)pNode, &pCol); nodesListAppend(pList, (SNode*)pCol); } } @@ -425,8 +427,9 @@ static bool isPrimaryKey(STempTableNode* pTable, SNode* pExpr) { return isPrimaryKeyImpl(pTable, pExpr); } -static bool findAndSetColumn(SColumnNode* pCol, const STableNode* pTable) { - bool found = false; +static bool findAndSetColumn(SColumnNode** pColRef, const STableNode* pTable) { + SColumnNode* pCol = *pColRef; + bool found = false; if (QUERY_NODE_REAL_TABLE == nodeType(pTable)) { const STableMeta* pMeta = ((SRealTableNode*)pTable)->pMeta; if (isInternalPrimaryKey(pCol)) { @@ -448,7 +451,7 @@ static bool findAndSetColumn(SColumnNode* pCol, const STableNode* pTable) { SExprNode* pExpr = (SExprNode*)pNode; if (0 == strcmp(pCol->colName, pExpr->aliasName) || (isPrimaryKey((STempTableNode*)pTable, pNode) && isInternalPrimaryKey(pCol))) { - setColumnInfoByExpr(pTable, pExpr, pCol); + setColumnInfoByExpr(pTable, pExpr, pColRef); found = true; break; } @@ -457,36 +460,36 @@ static bool findAndSetColumn(SColumnNode* pCol, const STableNode* pTable) { return found; } -static EDealRes translateColumnWithPrefix(STranslateContext* pCxt, SColumnNode* pCol) { +static EDealRes translateColumnWithPrefix(STranslateContext* pCxt, SColumnNode** pCol) { SArray* pTables = taosArrayGetP(pCxt->pNsLevel, pCxt->currLevel); size_t nums = taosArrayGetSize(pTables); bool foundTable = false; for (size_t i = 0; i < nums; ++i) { STableNode* pTable = taosArrayGetP(pTables, i); - if (belongTable(pCxt->pParseCxt->db, pCol, pTable)) { + if (belongTable(pCxt->pParseCxt->db, (*pCol), pTable)) { foundTable = true; if (findAndSetColumn(pCol, pTable)) { break; } - return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_COLUMN, pCol->colName); + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_COLUMN, (*pCol)->colName); } } if (!foundTable) { - return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_TABLE_NOT_EXIST, pCol->tableAlias); + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_TABLE_NOT_EXIST, (*pCol)->tableAlias); } return DEAL_RES_CONTINUE; } -static EDealRes translateColumnWithoutPrefix(STranslateContext* pCxt, SColumnNode* pCol) { +static EDealRes translateColumnWithoutPrefix(STranslateContext* pCxt, SColumnNode** pCol) { SArray* pTables = taosArrayGetP(pCxt->pNsLevel, pCxt->currLevel); size_t nums = taosArrayGetSize(pTables); bool found = false; - bool isInternalPk = isInternalPrimaryKey(pCol); + bool isInternalPk = isInternalPrimaryKey(*pCol); for (size_t i = 0; i < nums; ++i) { STableNode* pTable = taosArrayGetP(pTables, i); if (findAndSetColumn(pCol, pTable)) { if (found) { - return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_AMBIGUOUS_COLUMN, pCol->colName); + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_AMBIGUOUS_COLUMN, (*pCol)->colName); } found = true; if (isInternalPk) { @@ -501,18 +504,18 @@ static EDealRes translateColumnWithoutPrefix(STranslateContext* pCxt, SColumnNod } return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_INTERNAL_PK); } else { - return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_COLUMN, pCol->colName); + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_COLUMN, (*pCol)->colName); } } return DEAL_RES_CONTINUE; } -static bool translateColumnUseAlias(STranslateContext* pCxt, SColumnNode* pCol) { +static bool translateColumnUseAlias(STranslateContext* pCxt, SColumnNode** pCol) { SNodeList* pProjectionList = pCxt->pCurrStmt->pProjectionList; SNode* pNode; FOREACH(pNode, pProjectionList) { SExprNode* pExpr = (SExprNode*)pNode; - if (0 == strcmp(pCol->colName, pExpr->aliasName)) { + if (0 == strcmp((*pCol)->colName, pExpr->aliasName)) { setColumnInfoByExpr(NULL, pExpr, pCol); return true; } @@ -520,14 +523,14 @@ static bool translateColumnUseAlias(STranslateContext* pCxt, SColumnNode* pCol) return false; } -static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode* pCol) { +static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode** pCol) { // count(*)/first(*)/last(*) and so on - if (0 == strcmp(pCol->colName, "*")) { + if (0 == strcmp((*pCol)->colName, "*")) { return DEAL_RES_CONTINUE; } EDealRes res = DEAL_RES_CONTINUE; - if ('\0' != pCol->tableAlias[0]) { + if ('\0' != (*pCol)->tableAlias[0]) { res = translateColumnWithPrefix(pCxt, pCol); } else { bool found = false; @@ -870,6 +873,55 @@ static int32_t getFuncInfo(STranslateContext* pCxt, SFunctionNode* pFunc) { return fmGetFuncInfo(¶m, pFunc); } +static int32_t translateAggFunc(STranslateContext* pCxt, SFunctionNode* pFunc) { + if (beforeHaving(pCxt->currClause)) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION); + } + if (hasInvalidFuncNesting(pFunc->pParameterList)) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_AGG_FUNC_NESTING); + } + if (pCxt->pCurrStmt->hasIndefiniteRowsFunc) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC); + } + + if (isCountStar(pFunc)) { + return rewriteCountStar(pCxt, pFunc); + } + return TSDB_CODE_SUCCESS; +} + +static int32_t translateScanPseudoColumnFunc(STranslateContext* pCxt, SFunctionNode* pFunc) { + if (0 == LIST_LENGTH(pFunc->pParameterList)) { + if (QUERY_NODE_REAL_TABLE != nodeType(pCxt->pCurrStmt->pFromTable)) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TBNAME); + } + } else { + SValueNode* pVal = nodesListGetNode(pFunc->pParameterList, 0); + STableNode* pTable = NULL; + pCxt->errCode = findTable(pCxt, pVal->literal, &pTable); + if (TSDB_CODE_SUCCESS == pCxt->errCode && (NULL == pTable || QUERY_NODE_REAL_TABLE != nodeType(pTable))) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TBNAME); + } + } + return TSDB_CODE_SUCCESS; +} + +static int32_t translateIndefiniteRowsFunc(STranslateContext* pCxt, SFunctionNode* pFunc) { + if (SQL_CLAUSE_SELECT != pCxt->currClause || pCxt->pCurrStmt->hasIndefiniteRowsFunc || pCxt->pCurrStmt->hasAggFuncs) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_NOT_ALLOWED_FUNC); + } + if (hasInvalidFuncNesting(pFunc->pParameterList)) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_AGG_FUNC_NESTING); + } + return TSDB_CODE_SUCCESS; +} + +static void setFuncClassification(SSelectStmt* pSelect, SFunctionNode* pFunc) { + pSelect->hasAggFuncs = pSelect->hasAggFuncs ? true : fmIsAggFunc(pFunc->funcId); + pSelect->hasRepeatScanFuncs = pSelect->hasRepeatScanFuncs ? true : fmIsRepeatScanFunc(pFunc->funcId); + pSelect->hasIndefiniteRowsFunc = pSelect->hasIndefiniteRowsFunc ? true : fmIsIndefiniteRowsFunc(pFunc->funcId); +} + static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc) { SNode* pParam = NULL; FOREACH(pParam, pFunc->pParameterList) { @@ -880,48 +932,16 @@ static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc) pCxt->errCode = getFuncInfo(pCxt, pFunc); if (TSDB_CODE_SUCCESS == pCxt->errCode && fmIsAggFunc(pFunc->funcId)) { - if (beforeHaving(pCxt->currClause)) { - return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION); - } - if (hasInvalidFuncNesting(pFunc->pParameterList)) { - return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_AGG_FUNC_NESTING); - } - if (pCxt->pCurrStmt->hasIndefiniteRowsFunc) { - return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_NOT_ALLOWED_FUNC); - } - - pCxt->pCurrStmt->hasAggFuncs = true; - if (isCountStar(pFunc)) { - pCxt->errCode = rewriteCountStar(pCxt, pFunc); - } - - if (fmIsRepeatScanFunc(pFunc->funcId)) { - pCxt->pCurrStmt->hasRepeatScanFuncs = true; - } + pCxt->errCode = translateAggFunc(pCxt, pFunc); } if (TSDB_CODE_SUCCESS == pCxt->errCode && fmIsScanPseudoColumnFunc(pFunc->funcId)) { - if (0 == LIST_LENGTH(pFunc->pParameterList)) { - if (QUERY_NODE_REAL_TABLE != nodeType(pCxt->pCurrStmt->pFromTable)) { - return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_TBNAME); - } - } else { - SValueNode* pVal = nodesListGetNode(pFunc->pParameterList, 0); - STableNode* pTable = NULL; - pCxt->errCode = findTable(pCxt, pVal->literal, &pTable); - if (TSDB_CODE_SUCCESS == pCxt->errCode && (NULL == pTable || QUERY_NODE_REAL_TABLE != nodeType(pTable))) { - return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_TBNAME); - } - } + pCxt->errCode = translateScanPseudoColumnFunc(pCxt, pFunc); } if (TSDB_CODE_SUCCESS == pCxt->errCode && fmIsIndefiniteRowsFunc(pFunc->funcId)) { - if (SQL_CLAUSE_SELECT != pCxt->currClause || pCxt->pCurrStmt->hasIndefiniteRowsFunc || - pCxt->pCurrStmt->hasAggFuncs) { - return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_NOT_ALLOWED_FUNC); - } - if (hasInvalidFuncNesting(pFunc->pParameterList)) { - return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_AGG_FUNC_NESTING); - } - pCxt->pCurrStmt->hasIndefiniteRowsFunc = true; + pCxt->errCode = translateIndefiniteRowsFunc(pCxt, pFunc); + } + if (TSDB_CODE_SUCCESS == pCxt->errCode) { + setFuncClassification(pCxt->pCurrStmt, pFunc); } return TSDB_CODE_SUCCESS == pCxt->errCode ? DEAL_RES_CONTINUE : DEAL_RES_ERROR; } @@ -936,34 +956,34 @@ static EDealRes translateLogicCond(STranslateContext* pCxt, SLogicConditionNode* return DEAL_RES_CONTINUE; } -static EDealRes doTranslateExpr(SNode* pNode, void* pContext) { +static EDealRes doTranslateExpr(SNode** pNode, void* pContext) { STranslateContext* pCxt = (STranslateContext*)pContext; - switch (nodeType(pNode)) { + switch (nodeType(*pNode)) { case QUERY_NODE_COLUMN: - return translateColumn(pCxt, (SColumnNode*)pNode); + return translateColumn(pCxt, (SColumnNode**)pNode); case QUERY_NODE_VALUE: - return translateValue(pCxt, (SValueNode*)pNode); + return translateValue(pCxt, (SValueNode*)*pNode); case QUERY_NODE_OPERATOR: - return translateOperator(pCxt, (SOperatorNode*)pNode); + return translateOperator(pCxt, (SOperatorNode*)*pNode); case QUERY_NODE_FUNCTION: - return translateFunction(pCxt, (SFunctionNode*)pNode); + return translateFunction(pCxt, (SFunctionNode*)*pNode); case QUERY_NODE_LOGIC_CONDITION: - return translateLogicCond(pCxt, (SLogicConditionNode*)pNode); + return translateLogicCond(pCxt, (SLogicConditionNode*)*pNode); case QUERY_NODE_TEMP_TABLE: - return translateExprSubquery(pCxt, ((STempTableNode*)pNode)->pSubquery); + return translateExprSubquery(pCxt, ((STempTableNode*)*pNode)->pSubquery); default: break; } return DEAL_RES_CONTINUE; } -static int32_t translateExpr(STranslateContext* pCxt, SNode* pNode) { - nodesWalkExprPostOrder(pNode, doTranslateExpr, pCxt); +static int32_t translateExpr(STranslateContext* pCxt, SNode** pNode) { + nodesRewriteExprPostOrder(pNode, doTranslateExpr, pCxt); return pCxt->errCode; } static int32_t translateExprList(STranslateContext* pCxt, SNodeList* pList) { - nodesWalkExprsPostOrder(pList, doTranslateExpr, pCxt); + nodesRewriteExprsPostOrder(pList, doTranslateExpr, pCxt); return pCxt->errCode; } @@ -1238,12 +1258,31 @@ static uint8_t getStmtPrecision(SNode* pStmt) { return 0; } +static bool stmtIsSingleTable(SNode* pStmt) { + if (QUERY_NODE_SELECT_STMT == nodeType(pStmt)) { + return ((STableNode*)((SSelectStmt*)pStmt)->pFromTable)->singleTable; + } + return false; +} + static uint8_t getJoinTablePrecision(SJoinTableNode* pJoinTable) { uint8_t lp = ((STableNode*)pJoinTable->pLeft)->precision; uint8_t rp = ((STableNode*)pJoinTable->pRight)->precision; return (lp > rp ? rp : lp); } +static bool joinTableIsSingleTable(SJoinTableNode* pJoinTable) { + return (((STableNode*)pJoinTable->pLeft)->singleTable && ((STableNode*)pJoinTable->pRight)->singleTable); +} + +static bool isSingleTable(SRealTableNode* pRealTable) { + int8_t tableType = pRealTable->pMeta->tableType; + if (TSDB_SYSTEM_TABLE == tableType) { + return 0 != strcmp(pRealTable->table.tableName, TSDB_INS_TABLE_USER_TABLES); + } + return (TSDB_CHILD_TABLE == tableType || TSDB_NORMAL_TABLE == tableType); +} + static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pTable)) { @@ -1262,6 +1301,7 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) { code = setTableVgroupList(pCxt, &name, pRealTable); } pRealTable->table.precision = pRealTable->pMeta->tableInfo.precision; + pRealTable->table.singleTable = isSingleTable(pRealTable); if (TSDB_CODE_SUCCESS == code) { code = addNamespace(pCxt, pRealTable); } @@ -1272,6 +1312,7 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) { code = translateSubquery(pCxt, pTempTable->pSubquery); if (TSDB_CODE_SUCCESS == code) { pTempTable->table.precision = getStmtPrecision(pTempTable->pSubquery); + pTempTable->table.singleTable = stmtIsSingleTable(pTempTable->pSubquery); code = addNamespace(pCxt, pTempTable); } break; @@ -1284,7 +1325,8 @@ static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) { } if (TSDB_CODE_SUCCESS == code) { pJoinTable->table.precision = getJoinTablePrecision(pJoinTable); - code = translateExpr(pCxt, pJoinTable->pOnCond); + pJoinTable->table.singleTable = joinTableIsSingleTable(pJoinTable); + code = translateExpr(pCxt, &pJoinTable->pOnCond); } break; } @@ -1517,7 +1559,7 @@ static int32_t translateOrderByPosition(STranslateContext* pCxt, SNodeList* pPro if (NULL == pCol) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_OUT_OF_MEMORY); } - setColumnInfoByExpr(NULL, (SExprNode*)nodesListGetNode(pProjectionList, pos - 1), pCol); + setColumnInfoByExpr(NULL, (SExprNode*)nodesListGetNode(pProjectionList, pos - 1), &pCol); ((SOrderByExprNode*)pNode)->pExpr = (SNode*)pCol; nodesDestroyNode(pExpr); } @@ -1563,7 +1605,7 @@ static int32_t translateHaving(STranslateContext* pCxt, SSelectStmt* pSelect) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION); } pCxt->currClause = SQL_CLAUSE_HAVING; - int32_t code = translateExpr(pCxt, pSelect->pHaving); + int32_t code = translateExpr(pCxt, &pSelect->pHaving); if (TSDB_CODE_SUCCESS == code) { code = checkExprForGroupBy(pCxt, &pSelect->pHaving); } @@ -1811,7 +1853,7 @@ static int32_t translateWindow(STranslateContext* pCxt, SSelectStmt* pSelect) { return TSDB_CODE_SUCCESS; } pCxt->currClause = SQL_CLAUSE_WINDOW; - int32_t code = translateExpr(pCxt, pSelect->pWindow); + int32_t code = translateExpr(pCxt, &pSelect->pWindow); if (TSDB_CODE_SUCCESS == code) { code = checkWindow(pCxt, pSelect); } @@ -1825,7 +1867,7 @@ static int32_t translatePartitionBy(STranslateContext* pCxt, SNodeList* pPartiti static int32_t translateWhere(STranslateContext* pCxt, SNode* pWhere) { pCxt->currClause = SQL_CLAUSE_WHERE; - return translateExpr(pCxt, pWhere); + return translateExpr(pCxt, &pWhere); } static int32_t translateFrom(STranslateContext* pCxt, SSelectStmt* pSelect) { @@ -1857,7 +1899,7 @@ static int32_t createPrimaryKeyColByTable(STranslateContext* pCxt, STableNode* p } pCol->colId = PRIMARYKEY_TIMESTAMP_COL_ID; strcpy(pCol->colName, PK_TS_COL_INTERNAL_NAME); - if (!findAndSetColumn(pCol, pTable)) { + if (!findAndSetColumn(&pCol, pTable)) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_TIMELINE_FUNC); } *pPrimaryKey = (SNode*)pCol; @@ -2075,6 +2117,7 @@ static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pS pReq->replications = pStmt->pOptions->replica; pReq->strict = pStmt->pOptions->strict; pReq->cacheLastRow = pStmt->pOptions->cachelast; + pReq->schemaless = pStmt->pOptions->schemaless; pReq->ignoreExist = pStmt->ignoreExists; return buildCreateDbRetentions(pStmt->pOptions->pRetentions, pReq); } @@ -2274,6 +2317,9 @@ static int32_t checkDatabaseOptions(STranslateContext* pCxt, const char* pDbName if (TSDB_CODE_SUCCESS == code) { code = checkDbRetentionsOption(pCxt, pOptions->pRetentions); } + if (TSDB_CODE_SUCCESS == code) { + code = checkDbEnumOption(pCxt, "schemaless", pOptions->schemaless, TSDB_DB_SCHEMALESS_ON, TSDB_DB_SCHEMALESS_OFF); + } if (TSDB_CODE_SUCCESS == code) { code = checkOptionsDependency(pCxt, pDbName, pOptions); } @@ -3267,6 +3313,18 @@ static int32_t translateDropTopic(STranslateContext* pCxt, SDropTopicStmt* pStmt return buildCmdMsg(pCxt, TDMT_MND_DROP_TOPIC, (FSerializeFunc)tSerializeSMDropTopicReq, &dropReq); } +static int32_t translateDropCGroup(STranslateContext* pCxt, SDropCGroupStmt* pStmt) { + SMDropCgroupReq dropReq = {0}; + + SName name; + tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->topicName, strlen(pStmt->topicName)); + tNameGetFullDbName(&name, dropReq.topic); + dropReq.igNotExists = pStmt->ignoreNotExists; + strcpy(dropReq.cgroup, pStmt->cgroup); + + return buildCmdMsg(pCxt, TDMT_MND_DROP_CGROUP, (FSerializeFunc)tSerializeSMDropCgroupReq, &dropReq); +} + static int32_t translateAlterLocal(STranslateContext* pCxt, SAlterLocalStmt* pStmt) { // todo return TSDB_CODE_SUCCESS; @@ -3326,6 +3384,8 @@ static int32_t buildCreateStreamReq(STranslateContext* pCxt, SCreateStreamStmt* pReq->igExists = pStmt->ignoreExists; SName name; + // tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->streamName, strlen(pStmt->streamName)); + // tNameGetFullDbName(&name, pReq->name); tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pCxt->pParseCxt->db, pStmt->streamName, &name), pReq->name); if ('\0' != pStmt->targetTabName[0]) { @@ -3550,6 +3610,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_DROP_TOPIC_STMT: code = translateDropTopic(pCxt, (SDropTopicStmt*)pNode); break; + case QUERY_NODE_DROP_CGROUP_STMT: + code = translateDropCGroup(pCxt, (SDropCGroupStmt*)pNode); + break; case QUERY_NODE_ALTER_LOCAL_STMT: code = translateAlterLocal(pCxt, (SAlterLocalStmt*)pNode); break; diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 0854bb83e4..262abac54b 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -100,25 +100,25 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 358 +#define YYNOCODE 361 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - EOrder yy14; - ENullOrder yy17; - SNodeList* yy60; - SToken yy105; - int32_t yy140; - SNode* yy172; - EFillMode yy202; - SDataType yy248; - EOperatorType yy572; - int64_t yy593; - SAlterOption yy609; - bool yy617; - EJoinType yy636; + EFillMode yy18; + SAlterOption yy25; + SToken yy53; + EOperatorType yy136; + int32_t yy158; + ENullOrder yy185; + SNodeList* yy236; + EJoinType yy342; + EOrder yy430; + int64_t yy435; + SDataType yy450; + bool yy603; + SNode* yy636; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -134,17 +134,17 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 605 -#define YYNRULE 452 -#define YYNTOKEN 238 -#define YY_MAX_SHIFT 604 -#define YY_MIN_SHIFTREDUCE 893 -#define YY_MAX_SHIFTREDUCE 1344 -#define YY_ERROR_ACTION 1345 -#define YY_ACCEPT_ACTION 1346 -#define YY_NO_ACTION 1347 -#define YY_MIN_REDUCE 1348 -#define YY_MAX_REDUCE 1799 +#define YYNSTATE 611 +#define YYNRULE 455 +#define YYNTOKEN 240 +#define YY_MAX_SHIFT 610 +#define YY_MIN_SHIFTREDUCE 901 +#define YY_MAX_SHIFTREDUCE 1355 +#define YY_ERROR_ACTION 1356 +#define YY_ACCEPT_ACTION 1357 +#define YY_NO_ACTION 1358 +#define YY_MIN_REDUCE 1359 +#define YY_MAX_REDUCE 1813 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -211,601 +211,604 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2154) +#define YY_ACTTAB_COUNT (2153) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 1467, 1777, 1777, 1646, 383, 1634, 384, 1380, 292, 11, - /* 10 */ 10, 343, 35, 33, 1776, 146, 24, 923, 1774, 1774, - /* 20 */ 301, 391, 1159, 384, 1380, 1631, 36, 34, 32, 31, - /* 30 */ 30, 1662, 26, 36, 34, 32, 31, 30, 518, 503, - /* 40 */ 1627, 1633, 36, 34, 32, 31, 30, 1157, 1346, 502, - /* 50 */ 1777, 522, 130, 1617, 1360, 927, 928, 518, 14, 483, - /* 60 */ 35, 33, 1285, 145, 1165, 28, 223, 1774, 301, 1675, - /* 70 */ 1159, 349, 80, 1647, 505, 1649, 1650, 501, 77, 522, - /* 80 */ 1, 62, 1715, 1777, 1181, 519, 273, 1711, 518, 1261, - /* 90 */ 1634, 113, 398, 309, 108, 1157, 1775, 104, 1777, 1470, - /* 100 */ 1774, 1646, 601, 1473, 419, 271, 14, 317, 35, 33, - /* 110 */ 1631, 147, 1165, 1158, 1478, 1774, 301, 38, 1159, 36, - /* 120 */ 34, 32, 31, 30, 388, 1627, 1633, 56, 2, 1662, - /* 130 */ 1181, 36, 34, 32, 31, 30, 522, 503, 36, 34, - /* 140 */ 32, 31, 30, 1157, 55, 1523, 1777, 502, 39, 131, - /* 150 */ 601, 1617, 291, 1435, 14, 1371, 1160, 1521, 1662, 145, - /* 160 */ 1165, 1158, 559, 1774, 1450, 274, 472, 1675, 140, 1341, - /* 170 */ 132, 1647, 505, 1649, 1650, 501, 2, 522, 1163, 1164, - /* 180 */ 1517, 1209, 1210, 1212, 1213, 1214, 1215, 1216, 498, 520, - /* 190 */ 1224, 1225, 1226, 1227, 1228, 1229, 1247, 1410, 601, 519, - /* 200 */ 1299, 471, 1183, 55, 1160, 1617, 1456, 1196, 148, 1158, - /* 210 */ 473, 347, 447, 94, 484, 1791, 93, 92, 91, 90, - /* 220 */ 89, 88, 87, 86, 85, 1729, 1163, 1164, 1478, 1209, - /* 230 */ 1210, 1212, 1213, 1214, 1215, 1216, 498, 520, 1224, 1225, - /* 240 */ 1226, 1227, 1228, 1229, 1454, 148, 1248, 479, 1523, 1726, - /* 250 */ 1340, 1777, 1160, 597, 596, 306, 1309, 433, 432, 55, - /* 260 */ 1521, 1523, 431, 398, 145, 109, 428, 1253, 1774, 427, - /* 270 */ 426, 425, 148, 1522, 1163, 1164, 112, 1209, 1210, 1212, - /* 280 */ 1213, 1214, 1215, 1216, 498, 520, 1224, 1225, 1226, 1227, - /* 290 */ 1228, 1229, 35, 33, 1349, 465, 1307, 1308, 1310, 1311, - /* 300 */ 301, 556, 1159, 27, 299, 1242, 1243, 1244, 1245, 1246, - /* 310 */ 1250, 1251, 1252, 110, 939, 94, 62, 1469, 93, 92, - /* 320 */ 91, 90, 89, 88, 87, 86, 85, 1157, 143, 1722, - /* 330 */ 1723, 148, 1727, 519, 1184, 519, 479, 1631, 1474, 417, - /* 340 */ 35, 33, 1230, 506, 1165, 348, 304, 104, 301, 1568, - /* 350 */ 1159, 55, 1627, 1633, 424, 36, 34, 32, 31, 30, - /* 360 */ 8, 479, 1478, 522, 1478, 112, 36, 34, 32, 31, - /* 370 */ 30, 1556, 433, 432, 1635, 1157, 154, 431, 156, 1646, - /* 380 */ 109, 428, 601, 519, 427, 426, 425, 148, 35, 33, - /* 390 */ 112, 556, 1165, 1158, 1631, 358, 301, 305, 1159, 1523, - /* 400 */ 60, 274, 110, 59, 1182, 128, 312, 1662, 9, 1627, - /* 410 */ 1633, 1521, 1478, 1185, 1480, 503, 481, 142, 1722, 1723, - /* 420 */ 522, 1727, 468, 1157, 1196, 502, 342, 110, 341, 1617, - /* 430 */ 601, 313, 1247, 64, 289, 1397, 1160, 188, 1559, 1561, - /* 440 */ 1165, 1158, 144, 1722, 1723, 1675, 1727, 548, 263, 1647, - /* 450 */ 505, 1649, 1650, 501, 1370, 522, 9, 434, 1163, 1164, - /* 460 */ 334, 1209, 1210, 1212, 1213, 1214, 1215, 1216, 498, 520, - /* 470 */ 1224, 1225, 1226, 1227, 1228, 1229, 283, 311, 601, 148, - /* 480 */ 336, 332, 1248, 1120, 1160, 128, 475, 455, 148, 1158, - /* 490 */ 373, 1122, 474, 469, 1480, 1463, 519, 36, 34, 32, - /* 500 */ 31, 30, 1369, 1253, 1617, 1465, 1163, 1164, 359, 1209, - /* 510 */ 1210, 1212, 1213, 1214, 1215, 1216, 498, 520, 1224, 1225, - /* 520 */ 1226, 1227, 1228, 1229, 284, 1478, 282, 281, 1368, 421, - /* 530 */ 558, 1292, 1160, 423, 158, 157, 456, 1183, 214, 27, - /* 540 */ 299, 1242, 1243, 1244, 1245, 1246, 1250, 1251, 1252, 1646, - /* 550 */ 382, 1121, 1617, 386, 1163, 1164, 422, 1209, 1210, 1212, - /* 560 */ 1213, 1214, 1215, 1216, 498, 520, 1224, 1225, 1226, 1227, - /* 570 */ 1228, 1229, 35, 33, 270, 1777, 1181, 1662, 1617, 519, - /* 580 */ 301, 314, 1159, 366, 1249, 482, 378, 1461, 145, 128, - /* 590 */ 554, 397, 1774, 390, 423, 502, 386, 1235, 1480, 1617, - /* 600 */ 940, 54, 939, 1183, 379, 1254, 70, 1157, 1478, 553, - /* 610 */ 552, 1367, 551, 550, 549, 1675, 1366, 422, 81, 1647, - /* 620 */ 505, 1649, 1650, 501, 1165, 522, 1365, 1471, 1715, 941, - /* 630 */ 127, 1186, 294, 1711, 141, 1407, 32, 31, 30, 191, - /* 640 */ 2, 25, 1029, 545, 544, 543, 1033, 542, 1035, 1036, - /* 650 */ 541, 1038, 538, 1743, 1044, 535, 1046, 1047, 532, 529, - /* 660 */ 497, 1617, 601, 1364, 1363, 1362, 1617, 1359, 1358, 1357, - /* 670 */ 1356, 1355, 1354, 1158, 377, 1353, 1617, 372, 371, 370, - /* 680 */ 369, 368, 365, 364, 363, 362, 361, 357, 356, 355, - /* 690 */ 354, 353, 352, 351, 350, 577, 576, 575, 316, 1211, - /* 700 */ 574, 573, 572, 114, 567, 566, 565, 564, 563, 562, - /* 710 */ 561, 560, 121, 1617, 1617, 1617, 1160, 1617, 1617, 1617, - /* 720 */ 1617, 1617, 1617, 1352, 7, 1617, 128, 1351, 430, 429, - /* 730 */ 1646, 571, 569, 1560, 1561, 1481, 927, 928, 1163, 1164, - /* 740 */ 1729, 1209, 1210, 1212, 1213, 1214, 1215, 1216, 498, 520, - /* 750 */ 1224, 1225, 1226, 1227, 1228, 1229, 199, 129, 1662, 519, - /* 760 */ 1284, 1646, 252, 1729, 1725, 1211, 503, 991, 1159, 519, - /* 770 */ 1183, 1475, 1606, 1617, 250, 53, 502, 1617, 52, 506, - /* 780 */ 1617, 1597, 1734, 1280, 993, 1569, 483, 1724, 1478, 1662, - /* 790 */ 1144, 1145, 487, 1157, 479, 159, 1675, 482, 1478, 80, - /* 800 */ 1647, 505, 1649, 1650, 501, 246, 522, 502, 1508, 1715, - /* 810 */ 1165, 1617, 519, 273, 1711, 570, 454, 324, 179, 55, - /* 820 */ 1168, 177, 485, 112, 516, 1777, 181, 1675, 490, 180, - /* 830 */ 81, 1647, 505, 1649, 1650, 501, 1637, 522, 145, 519, - /* 840 */ 1715, 1478, 1774, 483, 294, 1711, 141, 183, 601, 185, - /* 850 */ 182, 517, 184, 445, 495, 337, 79, 1646, 215, 1158, - /* 860 */ 110, 519, 519, 547, 461, 1742, 443, 964, 1478, 47, - /* 870 */ 272, 118, 1639, 236, 315, 212, 1722, 478, 1392, 477, - /* 880 */ 11, 10, 1777, 1390, 965, 1662, 1171, 58, 57, 346, - /* 890 */ 1478, 1478, 153, 503, 1280, 147, 1361, 340, 46, 1774, - /* 900 */ 436, 1167, 1160, 502, 202, 439, 37, 1617, 1436, 269, - /* 910 */ 37, 457, 330, 37, 326, 322, 150, 225, 1343, 1344, - /* 920 */ 1646, 1455, 116, 1675, 1163, 1164, 81, 1647, 505, 1649, - /* 930 */ 1650, 501, 1211, 522, 218, 117, 1715, 466, 1306, 76, - /* 940 */ 294, 1711, 1790, 448, 204, 118, 1255, 148, 1662, 72, - /* 950 */ 1217, 1749, 1663, 1115, 1381, 46, 503, 227, 527, 209, - /* 960 */ 416, 174, 511, 480, 1518, 1283, 502, 1170, 1745, 217, - /* 970 */ 1617, 117, 1646, 139, 1239, 233, 220, 488, 222, 415, - /* 980 */ 411, 407, 403, 173, 118, 1022, 1675, 119, 117, 81, - /* 990 */ 1647, 505, 1649, 1650, 501, 245, 522, 1453, 1050, 1715, - /* 1000 */ 1662, 3, 1181, 294, 1711, 1790, 319, 63, 503, 323, - /* 1010 */ 171, 1054, 991, 554, 1772, 491, 280, 279, 502, 241, - /* 1020 */ 1128, 155, 1617, 360, 1061, 1558, 367, 1059, 120, 375, - /* 1030 */ 374, 1646, 553, 552, 380, 551, 550, 549, 1675, 1187, - /* 1040 */ 376, 81, 1647, 505, 1649, 1650, 501, 438, 522, 381, - /* 1050 */ 389, 1715, 1190, 162, 392, 294, 1711, 1790, 393, 1662, - /* 1060 */ 1189, 164, 446, 394, 166, 395, 1733, 503, 170, 1188, - /* 1070 */ 165, 396, 167, 399, 169, 61, 187, 502, 418, 172, - /* 1080 */ 1165, 1617, 1646, 420, 1468, 176, 1464, 483, 441, 554, - /* 1090 */ 84, 242, 163, 435, 288, 1601, 178, 1675, 186, 1646, - /* 1100 */ 259, 1647, 505, 1649, 1650, 501, 122, 522, 553, 552, - /* 1110 */ 1662, 551, 550, 549, 123, 1466, 1462, 124, 503, 125, - /* 1120 */ 449, 189, 51, 453, 450, 50, 1777, 1662, 502, 243, - /* 1130 */ 458, 192, 1617, 194, 1186, 503, 197, 459, 483, 147, - /* 1140 */ 1746, 467, 509, 1774, 1756, 502, 6, 200, 1675, 1617, - /* 1150 */ 463, 259, 1647, 505, 1649, 1650, 501, 1646, 522, 464, - /* 1160 */ 476, 5, 1736, 203, 1755, 1675, 293, 210, 82, 1647, - /* 1170 */ 505, 1649, 1650, 501, 1280, 522, 111, 1777, 1715, 470, - /* 1180 */ 208, 1185, 1714, 1711, 1348, 1662, 40, 211, 492, 1646, - /* 1190 */ 145, 1773, 135, 503, 1774, 1730, 295, 489, 18, 1567, - /* 1200 */ 1793, 507, 508, 502, 1566, 512, 303, 1617, 103, 102, - /* 1210 */ 101, 100, 99, 98, 97, 96, 95, 1662, 216, 479, - /* 1220 */ 1696, 513, 229, 1675, 219, 500, 82, 1647, 505, 1649, - /* 1230 */ 1650, 501, 514, 522, 231, 502, 1715, 69, 486, 1617, - /* 1240 */ 494, 1711, 1646, 493, 221, 244, 1479, 71, 112, 525, - /* 1250 */ 1451, 247, 600, 238, 48, 1675, 134, 253, 267, 1647, - /* 1260 */ 505, 1649, 1650, 501, 499, 522, 496, 1687, 483, 290, - /* 1270 */ 1662, 260, 249, 254, 251, 1611, 1610, 318, 503, 1607, - /* 1280 */ 320, 321, 1153, 1154, 151, 110, 325, 1605, 502, 327, - /* 1290 */ 328, 329, 1617, 1604, 331, 1603, 333, 1602, 335, 1646, - /* 1300 */ 212, 1722, 478, 1587, 477, 152, 339, 1777, 1675, 338, - /* 1310 */ 1131, 82, 1647, 505, 1649, 1650, 501, 1581, 522, 1130, - /* 1320 */ 145, 1715, 1580, 344, 1774, 345, 1712, 1662, 604, 1579, - /* 1330 */ 1578, 1551, 1098, 1550, 1549, 503, 1548, 1547, 1546, 1545, - /* 1340 */ 1544, 1543, 240, 1100, 115, 502, 1646, 1542, 1541, 1617, - /* 1350 */ 1540, 1539, 462, 1538, 105, 1537, 1536, 1535, 1534, 1533, - /* 1360 */ 593, 589, 585, 581, 239, 1675, 1532, 1531, 268, 1647, - /* 1370 */ 505, 1649, 1650, 501, 1662, 522, 1530, 1529, 1528, 1527, - /* 1380 */ 1526, 1525, 503, 1524, 1409, 1646, 1377, 138, 78, 160, - /* 1390 */ 1376, 234, 502, 1595, 1589, 1573, 1617, 106, 385, 930, - /* 1400 */ 161, 929, 107, 1564, 1457, 387, 168, 1408, 1406, 401, - /* 1410 */ 400, 958, 1675, 1662, 1404, 132, 1647, 505, 1649, 1650, - /* 1420 */ 501, 503, 522, 1402, 1400, 515, 402, 1389, 406, 404, - /* 1430 */ 1388, 502, 175, 405, 410, 1617, 1646, 414, 298, 408, - /* 1440 */ 1375, 409, 1459, 1458, 413, 412, 1398, 1064, 1065, 990, - /* 1450 */ 460, 1675, 989, 195, 268, 1647, 505, 1649, 1650, 501, - /* 1460 */ 1792, 522, 45, 988, 1662, 1646, 987, 568, 1393, 570, - /* 1470 */ 285, 1136, 500, 190, 286, 1391, 984, 287, 983, 1374, - /* 1480 */ 982, 440, 502, 437, 442, 1373, 1617, 444, 1594, 83, - /* 1490 */ 1588, 1138, 451, 1662, 1572, 1571, 126, 1646, 1563, 4, - /* 1500 */ 65, 503, 1675, 196, 37, 267, 1647, 505, 1649, 1650, - /* 1510 */ 501, 502, 522, 49, 1688, 1617, 452, 193, 300, 15, - /* 1520 */ 201, 43, 1305, 206, 41, 1662, 1298, 133, 207, 205, - /* 1530 */ 22, 1675, 23, 503, 268, 1647, 505, 1649, 1650, 501, - /* 1540 */ 1637, 522, 1277, 502, 66, 213, 198, 1617, 1276, 42, - /* 1550 */ 302, 136, 1334, 1646, 16, 17, 13, 1323, 1329, 10, - /* 1560 */ 1328, 19, 296, 1675, 1333, 1332, 268, 1647, 505, 1649, - /* 1570 */ 1650, 501, 297, 522, 1219, 137, 149, 29, 1204, 510, - /* 1580 */ 1218, 1662, 12, 20, 1646, 21, 226, 1240, 1562, 503, - /* 1590 */ 504, 224, 230, 232, 72, 1636, 235, 1303, 1175, 502, - /* 1600 */ 1221, 228, 67, 1617, 68, 526, 1678, 521, 44, 310, - /* 1610 */ 1051, 1048, 1662, 1646, 524, 528, 530, 531, 533, 1675, - /* 1620 */ 503, 1045, 255, 1647, 505, 1649, 1650, 501, 534, 522, - /* 1630 */ 502, 1039, 536, 537, 1617, 1037, 539, 1043, 1042, 540, - /* 1640 */ 1041, 1662, 1040, 1028, 73, 74, 1060, 75, 1057, 503, - /* 1650 */ 1675, 1056, 546, 262, 1647, 505, 1649, 1650, 501, 502, - /* 1660 */ 522, 956, 1646, 1617, 555, 557, 237, 997, 308, 307, - /* 1670 */ 978, 977, 973, 1646, 1058, 976, 994, 975, 1173, 1675, - /* 1680 */ 974, 972, 264, 1647, 505, 1649, 1650, 501, 971, 522, - /* 1690 */ 1662, 992, 968, 967, 966, 963, 962, 1405, 503, 961, - /* 1700 */ 578, 1662, 579, 1166, 580, 1403, 582, 583, 502, 503, - /* 1710 */ 584, 1401, 1617, 586, 587, 588, 1399, 590, 592, 502, - /* 1720 */ 1165, 591, 1387, 1617, 1646, 1386, 594, 1372, 1675, 595, - /* 1730 */ 598, 256, 1647, 505, 1649, 1650, 501, 1161, 522, 1675, - /* 1740 */ 599, 603, 265, 1647, 505, 1649, 1650, 501, 248, 522, - /* 1750 */ 602, 1347, 1662, 1646, 1347, 1347, 1347, 1347, 523, 1347, - /* 1760 */ 503, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1169, - /* 1770 */ 502, 1347, 1347, 1347, 1617, 1347, 1347, 1347, 1347, 1347, - /* 1780 */ 1347, 1662, 1347, 1347, 1347, 1646, 1347, 1347, 1347, 503, - /* 1790 */ 1675, 1347, 1347, 257, 1647, 505, 1649, 1650, 501, 502, - /* 1800 */ 522, 1347, 1347, 1617, 1347, 1347, 1347, 1347, 1347, 1347, - /* 1810 */ 1347, 1347, 1174, 1662, 1347, 1347, 1347, 1347, 1347, 1675, - /* 1820 */ 1347, 503, 266, 1647, 505, 1649, 1650, 501, 1347, 522, - /* 1830 */ 1347, 502, 1347, 1347, 1177, 1617, 1347, 1347, 1347, 1347, - /* 1840 */ 1347, 1646, 1347, 1347, 1347, 520, 1224, 1225, 1347, 1347, - /* 1850 */ 1347, 1675, 1347, 1347, 258, 1647, 505, 1649, 1650, 501, - /* 1860 */ 1347, 522, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1662, - /* 1870 */ 1347, 1347, 1646, 1347, 1347, 1347, 1347, 503, 1347, 1347, - /* 1880 */ 1347, 1347, 1347, 1347, 1347, 1347, 1347, 502, 1347, 1347, - /* 1890 */ 1347, 1617, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1347, - /* 1900 */ 1662, 1646, 1347, 1347, 1347, 1347, 1347, 1675, 503, 1347, - /* 1910 */ 1658, 1647, 505, 1649, 1650, 501, 1347, 522, 502, 1347, - /* 1920 */ 1347, 1347, 1617, 1347, 1347, 1347, 1347, 1347, 1347, 1662, - /* 1930 */ 1347, 1347, 1646, 1347, 1347, 1347, 1347, 503, 1675, 1347, - /* 1940 */ 1347, 1657, 1647, 505, 1649, 1650, 501, 502, 522, 1347, - /* 1950 */ 1347, 1617, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1347, - /* 1960 */ 1662, 1646, 1347, 1347, 1347, 1347, 1347, 1675, 503, 1347, - /* 1970 */ 1656, 1647, 505, 1649, 1650, 501, 1347, 522, 502, 1347, - /* 1980 */ 1347, 1347, 1617, 1347, 1347, 1347, 1347, 1347, 1347, 1662, - /* 1990 */ 1347, 1347, 1347, 1347, 1347, 1347, 1347, 503, 1675, 1347, - /* 2000 */ 1347, 277, 1647, 505, 1649, 1650, 501, 502, 522, 1347, - /* 2010 */ 1347, 1617, 1646, 1347, 1347, 1347, 1347, 1347, 1347, 1347, - /* 2020 */ 1347, 1347, 1347, 1646, 1347, 1347, 1347, 1675, 1347, 1347, - /* 2030 */ 276, 1647, 505, 1649, 1650, 501, 1347, 522, 1347, 1347, - /* 2040 */ 1662, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 503, 1347, - /* 2050 */ 1347, 1662, 1347, 1347, 1347, 1347, 1347, 1347, 502, 503, - /* 2060 */ 1347, 1347, 1617, 1347, 1347, 1347, 1347, 1347, 1347, 502, - /* 2070 */ 1347, 1347, 1347, 1617, 1347, 1347, 1347, 1646, 1675, 1347, - /* 2080 */ 1347, 278, 1647, 505, 1649, 1650, 501, 1347, 522, 1675, - /* 2090 */ 1347, 1347, 275, 1647, 505, 1649, 1650, 501, 1347, 522, - /* 2100 */ 1347, 1347, 1347, 1347, 1347, 1662, 1347, 1347, 1347, 1347, - /* 2110 */ 1347, 1347, 1347, 503, 1347, 1347, 1347, 1347, 1347, 1347, - /* 2120 */ 1347, 1347, 1347, 502, 1347, 1347, 1347, 1617, 1347, 1347, - /* 2130 */ 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1347, 1347, - /* 2140 */ 1347, 1347, 1347, 1675, 1347, 1347, 261, 1647, 505, 1649, - /* 2150 */ 1650, 501, 1347, 522, + /* 0 */ 386, 1647, 387, 1391, 295, 394, 524, 387, 1391, 28, + /* 10 */ 226, 931, 35, 33, 130, 1676, 1371, 1660, 104, 1791, + /* 20 */ 304, 1644, 1169, 477, 523, 424, 36, 34, 32, 31, + /* 30 */ 30, 385, 1790, 62, 389, 1490, 1788, 1640, 1646, 36, + /* 40 */ 34, 32, 31, 30, 1535, 1676, 108, 1167, 527, 935, + /* 50 */ 936, 294, 1000, 508, 524, 1485, 1533, 154, 14, 476, + /* 60 */ 35, 33, 1296, 507, 1175, 24, 350, 1630, 304, 1002, + /* 70 */ 1169, 1418, 277, 488, 523, 36, 34, 32, 31, 30, + /* 80 */ 56, 1, 60, 1490, 1689, 59, 524, 80, 1661, 510, + /* 90 */ 1663, 1664, 506, 1359, 527, 1167, 1207, 1729, 104, 603, + /* 100 */ 602, 276, 1725, 607, 1258, 429, 14, 36, 34, 32, + /* 110 */ 31, 30, 1175, 1791, 1168, 1490, 140, 103, 102, 101, + /* 120 */ 100, 99, 98, 97, 96, 95, 147, 376, 1529, 2, + /* 130 */ 1788, 583, 582, 581, 319, 39, 580, 579, 578, 114, + /* 140 */ 573, 572, 571, 570, 569, 568, 567, 566, 121, 562, + /* 150 */ 511, 607, 1568, 307, 1259, 55, 1580, 55, 1170, 156, + /* 160 */ 94, 1791, 1168, 93, 92, 91, 90, 89, 88, 87, + /* 170 */ 86, 85, 158, 157, 146, 352, 1264, 1352, 1788, 393, + /* 180 */ 1173, 1174, 389, 1220, 1221, 1223, 1224, 1225, 1226, 1227, + /* 190 */ 503, 525, 1235, 1236, 1237, 1238, 1239, 1240, 1468, 36, + /* 200 */ 34, 32, 31, 30, 64, 292, 1170, 131, 191, 274, + /* 210 */ 148, 1447, 27, 302, 1253, 1254, 1255, 1256, 1257, 1261, + /* 220 */ 1262, 1263, 1421, 36, 34, 32, 31, 30, 1173, 1174, + /* 230 */ 484, 1220, 1221, 1223, 1224, 1225, 1226, 1227, 503, 525, + /* 240 */ 1235, 1236, 1237, 1238, 1239, 1240, 35, 33, 1467, 948, + /* 250 */ 70, 947, 438, 437, 304, 403, 1169, 436, 1351, 112, + /* 260 */ 109, 433, 308, 1791, 432, 431, 430, 35, 33, 1310, + /* 270 */ 128, 1483, 1660, 403, 523, 304, 1789, 1169, 949, 1492, + /* 280 */ 1788, 1167, 438, 437, 148, 1193, 148, 436, 62, 972, + /* 290 */ 109, 433, 14, 1207, 432, 431, 430, 110, 1175, 1360, + /* 300 */ 1676, 1303, 1167, 1382, 1660, 524, 973, 1193, 508, 524, + /* 310 */ 1486, 486, 142, 1736, 1737, 2, 1741, 351, 507, 1175, + /* 320 */ 94, 361, 1630, 93, 92, 91, 90, 89, 88, 87, + /* 330 */ 86, 85, 1676, 1381, 1490, 38, 8, 607, 1490, 1689, + /* 340 */ 487, 559, 82, 1661, 510, 1663, 1664, 506, 1168, 527, + /* 350 */ 507, 1191, 1729, 1630, 1630, 1535, 1728, 1725, 607, 128, + /* 360 */ 558, 557, 309, 556, 555, 554, 1380, 1533, 1493, 1168, + /* 370 */ 565, 1689, 1462, 1535, 81, 1661, 510, 1663, 1664, 506, + /* 380 */ 315, 527, 524, 1630, 1729, 1533, 1743, 26, 297, 1725, + /* 390 */ 141, 478, 1170, 54, 362, 435, 434, 36, 34, 32, + /* 400 */ 31, 30, 218, 36, 34, 32, 31, 30, 466, 1756, + /* 410 */ 1740, 1490, 55, 1170, 1173, 1174, 1630, 1220, 1221, 1223, + /* 420 */ 1224, 1225, 1226, 1227, 503, 525, 1235, 1236, 1237, 1238, + /* 430 */ 1239, 1240, 460, 577, 575, 1173, 1174, 1379, 1220, 1221, + /* 440 */ 1223, 1224, 1225, 1226, 1227, 503, 525, 1235, 1236, 1237, + /* 450 */ 1238, 1239, 1240, 35, 33, 1241, 1378, 443, 1195, 610, + /* 460 */ 316, 304, 1377, 1169, 148, 148, 249, 1571, 1573, 1520, + /* 470 */ 1246, 1222, 451, 243, 35, 33, 1193, 1481, 1376, 1660, + /* 480 */ 1647, 461, 304, 312, 1169, 105, 190, 1630, 1167, 524, + /* 490 */ 473, 599, 595, 591, 587, 242, 391, 1644, 446, 1357, + /* 500 */ 1644, 402, 1191, 440, 561, 1175, 1630, 1676, 189, 1167, + /* 510 */ 337, 484, 1630, 1640, 1646, 508, 1640, 1646, 1490, 484, + /* 520 */ 78, 1791, 9, 237, 527, 507, 1175, 527, 1630, 1630, + /* 530 */ 339, 335, 564, 51, 145, 488, 50, 127, 1788, 511, + /* 540 */ 112, 148, 576, 9, 607, 1581, 1689, 1194, 112, 80, + /* 550 */ 1661, 510, 1663, 1664, 506, 1168, 527, 520, 320, 1729, + /* 560 */ 1375, 479, 474, 276, 1725, 607, 36, 34, 32, 31, + /* 570 */ 30, 1648, 1130, 314, 1479, 1791, 1168, 428, 110, 553, + /* 580 */ 1132, 128, 465, 340, 217, 198, 110, 1465, 145, 55, + /* 590 */ 1492, 1644, 1788, 143, 1736, 1737, 77, 1741, 1791, 1170, + /* 600 */ 427, 144, 1736, 1737, 1146, 1741, 193, 1640, 1646, 113, + /* 610 */ 1630, 145, 277, 1572, 1573, 1788, 490, 1482, 527, 1295, + /* 620 */ 1170, 1173, 1174, 1374, 1220, 1221, 1223, 1224, 1225, 1226, + /* 630 */ 1227, 503, 525, 1235, 1236, 1237, 1238, 1239, 1240, 286, + /* 640 */ 1222, 1131, 1173, 1174, 1258, 1220, 1221, 1223, 1224, 1225, + /* 650 */ 1226, 1227, 503, 525, 1235, 1236, 1237, 1238, 1239, 1240, + /* 660 */ 35, 33, 273, 559, 1191, 345, 1320, 344, 304, 524, + /* 670 */ 1169, 369, 524, 1630, 381, 32, 31, 30, 1748, 1291, + /* 680 */ 559, 1487, 558, 557, 1610, 556, 555, 554, 287, 7, + /* 690 */ 285, 284, 382, 426, 1259, 1167, 947, 428, 1490, 558, + /* 700 */ 557, 1490, 556, 555, 554, 470, 1318, 1319, 1321, 1322, + /* 710 */ 1535, 317, 1175, 11, 10, 1373, 1264, 1743, 148, 128, + /* 720 */ 427, 422, 1534, 935, 936, 1743, 1154, 1155, 1492, 2, + /* 730 */ 1038, 550, 549, 548, 1042, 547, 1044, 1045, 546, 1047, + /* 740 */ 543, 1739, 1053, 540, 1055, 1056, 537, 534, 346, 1738, + /* 750 */ 1370, 607, 27, 302, 1253, 1254, 1255, 1256, 1257, 1261, + /* 760 */ 1262, 1263, 1168, 380, 1466, 1630, 375, 374, 373, 372, + /* 770 */ 371, 368, 367, 366, 365, 364, 360, 359, 358, 357, + /* 780 */ 356, 355, 354, 353, 524, 524, 129, 524, 1791, 1196, + /* 790 */ 492, 255, 1192, 1193, 1272, 1260, 521, 522, 1475, 239, + /* 800 */ 1630, 145, 1369, 253, 53, 1788, 1170, 52, 1368, 1367, + /* 810 */ 1366, 452, 1365, 1490, 1490, 1364, 1490, 1265, 524, 1363, + /* 820 */ 1660, 561, 1362, 47, 159, 275, 1294, 1477, 1173, 1174, + /* 830 */ 318, 1220, 1221, 1223, 1224, 1225, 1226, 1227, 503, 525, + /* 840 */ 1235, 1236, 1237, 1238, 1239, 1240, 495, 1490, 1676, 55, + /* 850 */ 1473, 1791, 1630, 25, 1619, 194, 487, 1408, 1630, 1630, + /* 860 */ 1630, 1291, 1630, 1403, 145, 1630, 507, 1401, 1788, 1630, + /* 870 */ 1630, 182, 1630, 184, 180, 186, 183, 188, 185, 439, + /* 880 */ 187, 1660, 500, 450, 502, 441, 79, 1689, 76, 444, + /* 890 */ 81, 1661, 510, 1663, 1664, 506, 448, 527, 72, 327, + /* 900 */ 1729, 11, 10, 552, 297, 1725, 141, 1372, 459, 1676, + /* 910 */ 1354, 1355, 1650, 1448, 1660, 202, 1178, 508, 58, 57, + /* 920 */ 349, 118, 46, 153, 471, 1757, 1177, 507, 343, 205, + /* 930 */ 221, 1630, 37, 37, 37, 453, 212, 1677, 1392, 228, + /* 940 */ 272, 421, 1676, 333, 1530, 329, 325, 150, 1689, 1652, + /* 950 */ 508, 81, 1661, 510, 1663, 1664, 506, 1222, 527, 1759, + /* 960 */ 507, 1729, 462, 1317, 1630, 297, 1725, 1804, 1191, 116, + /* 970 */ 207, 117, 485, 1266, 1228, 1124, 1763, 493, 148, 1660, + /* 980 */ 230, 1689, 220, 1181, 81, 1661, 510, 1663, 1664, 506, + /* 990 */ 223, 527, 118, 1180, 1729, 1660, 46, 532, 297, 1725, + /* 1000 */ 1804, 322, 117, 225, 1250, 3, 118, 1676, 326, 1786, + /* 1010 */ 516, 282, 236, 1000, 283, 508, 119, 117, 244, 155, + /* 1020 */ 1138, 363, 370, 1676, 1570, 507, 378, 1660, 377, 1630, + /* 1030 */ 379, 508, 383, 1031, 1197, 496, 384, 248, 1059, 392, + /* 1040 */ 1200, 507, 395, 1063, 162, 1630, 1689, 1070, 396, 82, + /* 1050 */ 1661, 510, 1663, 1664, 506, 1676, 527, 1068, 120, 1729, + /* 1060 */ 1199, 164, 1689, 508, 1726, 81, 1661, 510, 1663, 1664, + /* 1070 */ 506, 1201, 527, 507, 397, 1729, 398, 1630, 1660, 297, + /* 1080 */ 1725, 1804, 167, 488, 399, 169, 1198, 400, 401, 172, + /* 1090 */ 1747, 61, 404, 1660, 1689, 175, 423, 262, 1661, 510, + /* 1100 */ 1663, 1664, 506, 425, 527, 84, 1676, 1175, 1480, 179, + /* 1110 */ 1476, 291, 181, 1614, 508, 122, 123, 1478, 1474, 124, + /* 1120 */ 125, 1676, 245, 1791, 507, 192, 455, 195, 1630, 508, + /* 1130 */ 246, 197, 454, 464, 488, 463, 147, 200, 1196, 507, + /* 1140 */ 1788, 458, 472, 1630, 1660, 1689, 1770, 203, 262, 1661, + /* 1150 */ 510, 1663, 1664, 506, 514, 527, 6, 1750, 469, 1769, + /* 1160 */ 1689, 211, 481, 82, 1661, 510, 1663, 1664, 506, 206, + /* 1170 */ 527, 1760, 1676, 1729, 1791, 296, 475, 499, 1725, 1195, + /* 1180 */ 505, 468, 5, 1291, 111, 40, 497, 145, 1744, 1807, + /* 1190 */ 507, 1788, 298, 18, 1630, 512, 1660, 513, 494, 306, + /* 1200 */ 311, 310, 1579, 135, 1578, 1660, 214, 517, 518, 519, + /* 1210 */ 1183, 1689, 213, 1787, 270, 1661, 510, 1663, 1664, 506, + /* 1220 */ 504, 527, 501, 1701, 1676, 219, 232, 71, 491, 1710, + /* 1230 */ 234, 247, 508, 1676, 69, 1176, 250, 1491, 241, 222, + /* 1240 */ 606, 508, 507, 1463, 498, 48, 1630, 530, 224, 256, + /* 1250 */ 134, 507, 1175, 1660, 263, 1630, 257, 293, 467, 252, + /* 1260 */ 254, 1624, 1623, 1689, 321, 1620, 132, 1661, 510, 1663, + /* 1270 */ 1664, 506, 1689, 527, 323, 271, 1661, 510, 1663, 1664, + /* 1280 */ 506, 1676, 527, 324, 1163, 1660, 1164, 151, 1618, 508, + /* 1290 */ 328, 528, 330, 331, 1617, 332, 334, 1616, 336, 507, + /* 1300 */ 1615, 338, 1179, 1630, 1600, 152, 341, 1141, 342, 1140, + /* 1310 */ 489, 1805, 1594, 1676, 1593, 347, 348, 1660, 1592, 1591, + /* 1320 */ 1689, 508, 1107, 266, 1661, 510, 1663, 1664, 506, 1563, + /* 1330 */ 527, 507, 1562, 1561, 1560, 1630, 1559, 1558, 1557, 1556, + /* 1340 */ 1555, 1554, 1553, 1552, 1551, 1676, 1184, 1550, 1549, 1548, + /* 1350 */ 1547, 1546, 1689, 508, 1545, 132, 1661, 510, 1663, 1664, + /* 1360 */ 506, 480, 527, 507, 115, 1660, 1544, 1630, 1187, 1543, + /* 1370 */ 301, 1542, 1541, 1540, 1109, 1539, 1538, 1537, 1660, 525, + /* 1380 */ 1235, 1236, 1536, 1420, 1689, 1388, 160, 271, 1661, 510, + /* 1390 */ 1663, 1664, 506, 1676, 527, 938, 106, 138, 937, 388, + /* 1400 */ 1806, 505, 1387, 161, 390, 107, 1676, 1608, 1602, 1586, + /* 1410 */ 1585, 507, 1576, 1469, 508, 1630, 166, 171, 1660, 1419, + /* 1420 */ 966, 1417, 1415, 407, 507, 405, 1413, 411, 1630, 415, + /* 1430 */ 1411, 303, 1689, 419, 406, 270, 1661, 510, 1663, 1664, + /* 1440 */ 506, 409, 527, 410, 1702, 1689, 1676, 413, 271, 1661, + /* 1450 */ 510, 1663, 1664, 506, 508, 527, 414, 1400, 177, 1399, + /* 1460 */ 418, 417, 1386, 1471, 507, 1074, 1660, 1470, 1630, 1073, + /* 1470 */ 139, 305, 574, 576, 999, 1169, 420, 416, 412, 408, + /* 1480 */ 176, 45, 998, 178, 997, 1689, 996, 993, 271, 1661, + /* 1490 */ 510, 1663, 1664, 506, 1676, 527, 992, 991, 1409, 288, + /* 1500 */ 1167, 1404, 508, 289, 442, 63, 1402, 290, 174, 1385, + /* 1510 */ 447, 445, 507, 1384, 449, 83, 1630, 1175, 1607, 1148, + /* 1520 */ 49, 1601, 456, 1660, 1584, 126, 1583, 1575, 199, 65, + /* 1530 */ 196, 4, 133, 1689, 201, 37, 258, 1661, 510, 1663, + /* 1540 */ 1664, 506, 204, 527, 15, 457, 43, 1316, 1309, 208, + /* 1550 */ 22, 1676, 209, 23, 210, 66, 607, 1288, 1650, 508, + /* 1560 */ 1287, 216, 1345, 42, 136, 41, 173, 1168, 165, 507, + /* 1570 */ 170, 1660, 168, 1630, 17, 1340, 1339, 16, 13, 1334, + /* 1580 */ 10, 299, 1344, 1343, 300, 1251, 19, 137, 149, 1230, + /* 1590 */ 1689, 163, 1215, 265, 1661, 510, 1663, 1664, 506, 1676, + /* 1600 */ 527, 1660, 509, 1574, 29, 515, 12, 508, 1649, 233, + /* 1610 */ 72, 1170, 1229, 20, 235, 1185, 531, 507, 238, 21, + /* 1620 */ 229, 1630, 227, 529, 1314, 964, 313, 231, 67, 1676, + /* 1630 */ 68, 1660, 1692, 1173, 1174, 1232, 526, 508, 1689, 44, + /* 1640 */ 533, 267, 1661, 510, 1663, 1664, 506, 507, 527, 1060, + /* 1650 */ 1057, 1630, 535, 538, 536, 541, 544, 1054, 539, 1676, + /* 1660 */ 1037, 1052, 1048, 542, 1069, 1046, 545, 508, 1689, 551, + /* 1670 */ 1051, 259, 1661, 510, 1663, 1664, 506, 507, 527, 1660, + /* 1680 */ 73, 1630, 74, 75, 1066, 1065, 1050, 560, 1660, 1049, + /* 1690 */ 988, 1006, 563, 240, 986, 985, 984, 983, 1689, 981, + /* 1700 */ 1067, 268, 1661, 510, 1663, 1664, 506, 1676, 527, 982, + /* 1710 */ 1003, 980, 979, 1001, 976, 508, 1676, 975, 974, 971, + /* 1720 */ 970, 969, 1416, 584, 508, 507, 585, 586, 1414, 1630, + /* 1730 */ 588, 589, 590, 1412, 507, 592, 1660, 593, 1630, 594, + /* 1740 */ 1410, 596, 597, 598, 1398, 600, 1689, 601, 1397, 260, + /* 1750 */ 1661, 510, 1663, 1664, 506, 1689, 527, 1383, 269, 1661, + /* 1760 */ 510, 1663, 1664, 506, 1676, 527, 609, 604, 605, 1358, + /* 1770 */ 1358, 1171, 508, 251, 608, 1358, 1358, 1358, 1358, 1358, + /* 1780 */ 1358, 1358, 507, 1358, 1660, 1358, 1630, 1358, 1358, 1358, + /* 1790 */ 1358, 1358, 1358, 1358, 1358, 1660, 1358, 1358, 1358, 1358, + /* 1800 */ 1358, 1358, 1358, 1689, 1358, 1358, 261, 1661, 510, 1663, + /* 1810 */ 1664, 506, 1676, 527, 1660, 1358, 1358, 1358, 1358, 1358, + /* 1820 */ 508, 1358, 1358, 1676, 1358, 1358, 1358, 1358, 1358, 1358, + /* 1830 */ 507, 508, 1358, 1358, 1630, 1358, 1358, 1358, 1358, 1358, + /* 1840 */ 1358, 507, 1676, 1358, 1358, 1630, 1358, 1358, 1358, 1358, + /* 1850 */ 508, 1689, 1358, 1358, 1672, 1661, 510, 1663, 1664, 506, + /* 1860 */ 507, 527, 1689, 1358, 1630, 1671, 1661, 510, 1663, 1664, + /* 1870 */ 506, 1358, 527, 1660, 1358, 1358, 1358, 1358, 1358, 1358, + /* 1880 */ 1358, 1689, 1660, 1358, 1670, 1661, 510, 1663, 1664, 506, + /* 1890 */ 1358, 527, 1358, 1358, 1358, 1358, 1358, 1358, 1358, 1358, + /* 1900 */ 1358, 1676, 1358, 1358, 1358, 1358, 1358, 1358, 1358, 508, + /* 1910 */ 1676, 1358, 1358, 1358, 1358, 1358, 1358, 1358, 508, 507, + /* 1920 */ 1358, 1358, 1358, 1630, 1358, 1358, 1358, 1358, 507, 1358, + /* 1930 */ 1358, 1358, 1630, 1358, 1358, 1358, 1358, 1358, 1358, 1358, + /* 1940 */ 1689, 1358, 1660, 280, 1661, 510, 1663, 1664, 506, 1689, + /* 1950 */ 527, 1660, 279, 1661, 510, 1663, 1664, 506, 1358, 527, + /* 1960 */ 1358, 1358, 1358, 1358, 1358, 1358, 1358, 1358, 1358, 1358, + /* 1970 */ 1676, 1358, 1358, 1358, 1358, 1358, 1358, 1358, 508, 1676, + /* 1980 */ 1358, 1358, 1358, 1358, 1358, 1358, 1358, 508, 507, 1358, + /* 1990 */ 1358, 1358, 1630, 1358, 1358, 1358, 1358, 507, 1358, 1660, + /* 2000 */ 1358, 1630, 1358, 1358, 1358, 1358, 1358, 1358, 1358, 1689, + /* 2010 */ 484, 1358, 281, 1661, 510, 1663, 1664, 506, 1689, 527, + /* 2020 */ 1358, 278, 1661, 510, 1663, 1664, 506, 1676, 527, 1358, + /* 2030 */ 1358, 1358, 1358, 1358, 1358, 508, 1358, 1358, 1358, 112, + /* 2040 */ 1358, 1358, 1358, 1358, 1358, 507, 484, 1358, 1358, 1630, + /* 2050 */ 1358, 1358, 1358, 1358, 1358, 1358, 1358, 1358, 1358, 488, + /* 2060 */ 1358, 1358, 1358, 1358, 1358, 1358, 1689, 1358, 1358, 264, + /* 2070 */ 1661, 510, 1663, 1664, 506, 112, 527, 110, 1358, 1358, + /* 2080 */ 1358, 1358, 1358, 1358, 1358, 1358, 1358, 1358, 1358, 1358, + /* 2090 */ 1358, 1358, 215, 1736, 483, 488, 482, 1358, 1358, 1791, + /* 2100 */ 1358, 1358, 1358, 1358, 1358, 1358, 1358, 1358, 1358, 1358, + /* 2110 */ 1358, 1358, 147, 110, 1358, 1358, 1788, 1358, 1358, 1358, + /* 2120 */ 1358, 1358, 1358, 1358, 1358, 1358, 1358, 1358, 215, 1736, + /* 2130 */ 483, 1358, 482, 1358, 1358, 1791, 1358, 1358, 1358, 1358, + /* 2140 */ 1358, 1358, 1358, 1358, 1358, 1358, 1358, 1358, 145, 1358, + /* 2150 */ 1358, 1358, 1788, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 270, 336, 336, 241, 244, 271, 246, 247, 274, 1, - /* 10 */ 2, 297, 12, 13, 349, 349, 2, 4, 353, 353, - /* 20 */ 20, 244, 22, 246, 247, 291, 12, 13, 14, 15, - /* 30 */ 16, 269, 2, 12, 13, 14, 15, 16, 20, 277, - /* 40 */ 306, 307, 12, 13, 14, 15, 16, 47, 238, 287, - /* 50 */ 336, 317, 240, 291, 242, 42, 43, 20, 58, 297, - /* 60 */ 12, 13, 14, 349, 64, 321, 322, 353, 20, 307, - /* 70 */ 22, 248, 310, 311, 312, 313, 314, 315, 251, 317, - /* 80 */ 80, 253, 320, 336, 20, 248, 324, 325, 20, 81, - /* 90 */ 271, 264, 57, 274, 266, 47, 349, 260, 336, 272, - /* 100 */ 353, 241, 102, 275, 267, 282, 58, 297, 12, 13, - /* 110 */ 291, 349, 64, 113, 277, 353, 20, 80, 22, 12, - /* 120 */ 13, 14, 15, 16, 14, 306, 307, 4, 80, 269, - /* 130 */ 20, 12, 13, 14, 15, 16, 317, 277, 12, 13, - /* 140 */ 14, 15, 16, 47, 80, 269, 336, 287, 80, 254, - /* 150 */ 102, 291, 276, 258, 58, 241, 156, 281, 269, 349, - /* 160 */ 64, 113, 257, 353, 259, 58, 277, 307, 268, 148, - /* 170 */ 310, 311, 312, 313, 314, 315, 80, 317, 178, 179, - /* 180 */ 280, 181, 182, 183, 184, 185, 186, 187, 188, 189, - /* 190 */ 190, 191, 192, 193, 194, 195, 89, 0, 102, 248, - /* 200 */ 81, 312, 20, 80, 156, 291, 0, 81, 208, 113, - /* 210 */ 20, 260, 297, 21, 354, 355, 24, 25, 26, 27, - /* 220 */ 28, 29, 30, 31, 32, 308, 178, 179, 277, 181, - /* 230 */ 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, - /* 240 */ 192, 193, 194, 195, 0, 208, 139, 248, 269, 332, - /* 250 */ 229, 336, 156, 249, 250, 276, 178, 60, 61, 80, - /* 260 */ 281, 269, 65, 57, 349, 68, 69, 160, 353, 72, - /* 270 */ 73, 74, 208, 281, 178, 179, 277, 181, 182, 183, - /* 280 */ 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, - /* 290 */ 194, 195, 12, 13, 0, 217, 218, 219, 220, 221, - /* 300 */ 20, 57, 22, 196, 197, 198, 199, 200, 201, 202, - /* 310 */ 203, 204, 205, 314, 22, 21, 253, 271, 24, 25, - /* 320 */ 26, 27, 28, 29, 30, 31, 32, 47, 329, 330, - /* 330 */ 331, 208, 333, 248, 20, 248, 248, 291, 275, 47, - /* 340 */ 12, 13, 14, 287, 64, 260, 290, 260, 20, 293, - /* 350 */ 22, 80, 306, 307, 267, 12, 13, 14, 15, 16, - /* 360 */ 80, 248, 277, 317, 277, 277, 12, 13, 14, 15, - /* 370 */ 16, 277, 60, 61, 271, 47, 55, 65, 284, 241, - /* 380 */ 68, 69, 102, 248, 72, 73, 74, 208, 12, 13, - /* 390 */ 277, 57, 64, 113, 291, 260, 20, 261, 22, 269, - /* 400 */ 79, 58, 314, 82, 20, 269, 276, 269, 80, 306, - /* 410 */ 307, 281, 277, 20, 278, 277, 328, 329, 330, 331, - /* 420 */ 317, 333, 143, 47, 81, 287, 155, 314, 157, 291, - /* 430 */ 102, 279, 89, 165, 166, 0, 156, 169, 286, 287, - /* 440 */ 64, 113, 329, 330, 331, 307, 333, 91, 310, 311, - /* 450 */ 312, 313, 314, 315, 241, 317, 80, 22, 178, 179, - /* 460 */ 151, 181, 182, 183, 184, 185, 186, 187, 188, 189, - /* 470 */ 190, 191, 192, 193, 194, 195, 35, 261, 102, 208, - /* 480 */ 171, 172, 139, 79, 156, 269, 348, 248, 208, 113, - /* 490 */ 75, 87, 213, 214, 278, 270, 248, 12, 13, 14, - /* 500 */ 15, 16, 241, 160, 291, 270, 178, 179, 260, 181, - /* 510 */ 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, - /* 520 */ 192, 193, 194, 195, 83, 277, 85, 86, 241, 88, - /* 530 */ 64, 14, 156, 92, 119, 120, 297, 20, 145, 196, - /* 540 */ 197, 198, 199, 200, 201, 202, 203, 204, 205, 241, - /* 550 */ 245, 147, 291, 248, 178, 179, 115, 181, 182, 183, - /* 560 */ 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, - /* 570 */ 194, 195, 12, 13, 18, 336, 20, 269, 291, 248, - /* 580 */ 20, 261, 22, 27, 139, 277, 30, 270, 349, 269, - /* 590 */ 92, 260, 353, 245, 92, 287, 248, 14, 278, 291, - /* 600 */ 20, 3, 22, 20, 48, 160, 251, 47, 277, 111, - /* 610 */ 112, 241, 114, 115, 116, 307, 241, 115, 310, 311, - /* 620 */ 312, 313, 314, 315, 64, 317, 241, 272, 320, 49, - /* 630 */ 145, 20, 324, 325, 326, 0, 14, 15, 16, 270, - /* 640 */ 80, 196, 93, 94, 95, 96, 97, 98, 99, 100, - /* 650 */ 101, 102, 103, 345, 105, 106, 107, 108, 109, 110, - /* 660 */ 270, 291, 102, 241, 241, 241, 291, 241, 241, 241, - /* 670 */ 241, 241, 241, 113, 118, 241, 291, 121, 122, 123, - /* 680 */ 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, - /* 690 */ 134, 135, 136, 137, 138, 60, 61, 62, 63, 182, - /* 700 */ 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, - /* 710 */ 75, 76, 77, 291, 291, 291, 156, 291, 291, 291, - /* 720 */ 291, 291, 291, 241, 37, 291, 269, 241, 255, 256, - /* 730 */ 241, 255, 256, 286, 287, 278, 42, 43, 178, 179, - /* 740 */ 308, 181, 182, 183, 184, 185, 186, 187, 188, 189, - /* 750 */ 190, 191, 192, 193, 194, 195, 145, 18, 269, 248, - /* 760 */ 4, 241, 23, 308, 332, 182, 277, 47, 22, 248, - /* 770 */ 20, 260, 0, 291, 35, 36, 287, 291, 39, 287, - /* 780 */ 291, 260, 206, 207, 64, 293, 297, 332, 277, 269, - /* 790 */ 167, 168, 41, 47, 248, 56, 307, 277, 277, 310, - /* 800 */ 311, 312, 313, 314, 315, 262, 317, 287, 265, 320, - /* 810 */ 64, 291, 248, 324, 325, 41, 300, 45, 84, 80, - /* 820 */ 47, 87, 224, 277, 260, 336, 84, 307, 41, 87, - /* 830 */ 310, 311, 312, 313, 314, 315, 44, 317, 349, 248, - /* 840 */ 320, 277, 353, 297, 324, 325, 326, 84, 102, 84, - /* 850 */ 87, 260, 87, 21, 58, 81, 117, 241, 338, 113, - /* 860 */ 314, 248, 248, 270, 344, 345, 34, 47, 277, 145, - /* 870 */ 146, 41, 80, 260, 260, 329, 330, 331, 0, 333, - /* 880 */ 1, 2, 336, 0, 64, 269, 113, 148, 149, 150, - /* 890 */ 277, 277, 153, 277, 207, 349, 242, 158, 41, 353, - /* 900 */ 22, 47, 156, 287, 41, 22, 41, 291, 258, 170, - /* 910 */ 41, 81, 173, 41, 175, 176, 177, 41, 193, 194, - /* 920 */ 241, 0, 41, 307, 178, 179, 310, 311, 312, 313, - /* 930 */ 314, 315, 182, 317, 356, 41, 320, 347, 81, 80, - /* 940 */ 324, 325, 326, 304, 81, 41, 81, 208, 269, 90, - /* 950 */ 81, 335, 269, 81, 247, 41, 277, 81, 41, 341, - /* 960 */ 249, 33, 81, 334, 280, 209, 287, 113, 309, 350, - /* 970 */ 291, 41, 241, 45, 178, 81, 350, 226, 350, 51, - /* 980 */ 52, 53, 54, 55, 41, 81, 307, 41, 41, 310, - /* 990 */ 311, 312, 313, 314, 315, 81, 317, 0, 81, 320, - /* 1000 */ 269, 337, 20, 324, 325, 326, 248, 79, 277, 45, - /* 1010 */ 82, 81, 47, 92, 335, 228, 255, 305, 287, 298, - /* 1020 */ 154, 40, 291, 248, 81, 248, 285, 81, 81, 139, - /* 1030 */ 283, 241, 111, 112, 248, 114, 115, 116, 307, 20, - /* 1040 */ 283, 310, 311, 312, 313, 314, 315, 4, 317, 243, - /* 1050 */ 243, 320, 20, 253, 302, 324, 325, 326, 287, 269, - /* 1060 */ 20, 253, 19, 295, 253, 277, 335, 277, 140, 20, - /* 1070 */ 142, 288, 144, 248, 253, 253, 33, 287, 243, 253, - /* 1080 */ 64, 291, 241, 269, 269, 269, 269, 297, 45, 92, - /* 1090 */ 248, 302, 164, 50, 243, 291, 269, 307, 55, 241, - /* 1100 */ 310, 311, 312, 313, 314, 315, 269, 317, 111, 112, - /* 1110 */ 269, 114, 115, 116, 269, 269, 269, 269, 277, 269, - /* 1120 */ 163, 251, 79, 287, 301, 82, 336, 269, 287, 295, - /* 1130 */ 277, 251, 291, 251, 20, 277, 251, 288, 297, 349, - /* 1140 */ 309, 216, 215, 353, 346, 287, 223, 292, 307, 291, - /* 1150 */ 211, 310, 311, 312, 313, 314, 315, 241, 317, 291, - /* 1160 */ 222, 210, 343, 292, 346, 307, 291, 339, 310, 311, - /* 1170 */ 312, 313, 314, 315, 207, 317, 277, 336, 320, 291, - /* 1180 */ 342, 20, 324, 325, 0, 269, 40, 327, 227, 241, - /* 1190 */ 349, 352, 340, 277, 353, 308, 230, 225, 80, 292, - /* 1200 */ 357, 291, 291, 287, 292, 142, 291, 291, 24, 25, - /* 1210 */ 26, 27, 28, 29, 30, 31, 32, 269, 351, 248, - /* 1220 */ 323, 289, 277, 307, 351, 277, 310, 311, 312, 313, - /* 1230 */ 314, 315, 288, 317, 251, 287, 320, 251, 352, 291, - /* 1240 */ 324, 325, 241, 352, 351, 265, 277, 80, 277, 273, - /* 1250 */ 259, 248, 243, 251, 299, 307, 303, 263, 310, 311, - /* 1260 */ 312, 313, 314, 315, 316, 317, 318, 319, 297, 296, - /* 1270 */ 269, 263, 252, 263, 239, 0, 0, 72, 277, 0, - /* 1280 */ 47, 174, 47, 47, 47, 314, 174, 0, 287, 47, - /* 1290 */ 47, 174, 291, 0, 47, 0, 47, 0, 47, 241, - /* 1300 */ 329, 330, 331, 0, 333, 80, 159, 336, 307, 160, - /* 1310 */ 113, 310, 311, 312, 313, 314, 315, 0, 317, 156, - /* 1320 */ 349, 320, 0, 152, 353, 151, 325, 269, 19, 0, - /* 1330 */ 0, 0, 44, 0, 0, 277, 0, 0, 0, 0, - /* 1340 */ 0, 0, 33, 22, 40, 287, 241, 0, 0, 291, - /* 1350 */ 0, 0, 294, 0, 45, 0, 0, 0, 0, 0, - /* 1360 */ 51, 52, 53, 54, 55, 307, 0, 0, 310, 311, - /* 1370 */ 312, 313, 314, 315, 269, 317, 0, 0, 0, 0, - /* 1380 */ 0, 0, 277, 0, 0, 241, 0, 41, 79, 40, - /* 1390 */ 0, 82, 287, 0, 0, 0, 291, 37, 44, 14, - /* 1400 */ 38, 14, 37, 0, 0, 44, 37, 0, 0, 45, - /* 1410 */ 47, 59, 307, 269, 0, 310, 311, 312, 313, 314, - /* 1420 */ 315, 277, 317, 0, 0, 116, 37, 0, 37, 47, - /* 1430 */ 0, 287, 87, 45, 37, 291, 241, 37, 294, 47, - /* 1440 */ 0, 45, 0, 0, 45, 47, 0, 22, 47, 47, - /* 1450 */ 141, 307, 47, 144, 310, 311, 312, 313, 314, 315, - /* 1460 */ 355, 317, 89, 47, 269, 241, 47, 41, 0, 41, - /* 1470 */ 22, 162, 277, 164, 22, 0, 47, 22, 47, 0, - /* 1480 */ 47, 47, 287, 48, 22, 0, 291, 22, 0, 20, - /* 1490 */ 0, 47, 22, 269, 0, 0, 161, 241, 0, 41, - /* 1500 */ 80, 277, 307, 37, 41, 310, 311, 312, 313, 314, - /* 1510 */ 315, 287, 317, 145, 319, 291, 145, 142, 294, 212, - /* 1520 */ 81, 41, 81, 41, 206, 269, 81, 80, 44, 80, - /* 1530 */ 80, 307, 41, 277, 310, 311, 312, 313, 314, 315, - /* 1540 */ 44, 317, 81, 287, 80, 44, 140, 291, 81, 41, - /* 1550 */ 294, 44, 81, 241, 212, 41, 212, 81, 47, 2, - /* 1560 */ 47, 41, 47, 307, 47, 47, 310, 311, 312, 313, - /* 1570 */ 314, 315, 47, 317, 81, 44, 44, 80, 22, 143, - /* 1580 */ 81, 269, 80, 80, 241, 80, 80, 178, 0, 277, - /* 1590 */ 180, 81, 37, 140, 90, 44, 44, 81, 22, 287, - /* 1600 */ 81, 80, 80, 291, 80, 47, 80, 80, 80, 47, - /* 1610 */ 81, 81, 269, 241, 91, 80, 47, 80, 47, 307, - /* 1620 */ 277, 81, 310, 311, 312, 313, 314, 315, 80, 317, - /* 1630 */ 287, 81, 47, 80, 291, 81, 47, 104, 104, 80, - /* 1640 */ 104, 269, 104, 22, 80, 80, 47, 80, 47, 277, - /* 1650 */ 307, 22, 92, 310, 311, 312, 313, 314, 315, 287, - /* 1660 */ 317, 59, 241, 291, 58, 78, 41, 64, 12, 13, - /* 1670 */ 47, 47, 22, 241, 113, 47, 64, 47, 22, 307, - /* 1680 */ 47, 47, 310, 311, 312, 313, 314, 315, 47, 317, - /* 1690 */ 269, 47, 47, 47, 47, 47, 47, 0, 277, 47, - /* 1700 */ 47, 269, 45, 47, 37, 0, 47, 45, 287, 277, - /* 1710 */ 37, 0, 291, 47, 45, 37, 0, 47, 37, 287, - /* 1720 */ 64, 45, 0, 291, 241, 0, 47, 0, 307, 46, - /* 1730 */ 22, 310, 311, 312, 313, 314, 315, 22, 317, 307, - /* 1740 */ 21, 20, 310, 311, 312, 313, 314, 315, 22, 317, - /* 1750 */ 21, 358, 269, 241, 358, 358, 358, 358, 102, 358, - /* 1760 */ 277, 358, 358, 358, 358, 358, 358, 358, 358, 113, - /* 1770 */ 287, 358, 358, 358, 291, 358, 358, 358, 358, 358, - /* 1780 */ 358, 269, 358, 358, 358, 241, 358, 358, 358, 277, - /* 1790 */ 307, 358, 358, 310, 311, 312, 313, 314, 315, 287, - /* 1800 */ 317, 358, 358, 291, 358, 358, 358, 358, 358, 358, - /* 1810 */ 358, 358, 156, 269, 358, 358, 358, 358, 358, 307, - /* 1820 */ 358, 277, 310, 311, 312, 313, 314, 315, 358, 317, - /* 1830 */ 358, 287, 358, 358, 178, 291, 358, 358, 358, 358, - /* 1840 */ 358, 241, 358, 358, 358, 189, 190, 191, 358, 358, - /* 1850 */ 358, 307, 358, 358, 310, 311, 312, 313, 314, 315, - /* 1860 */ 358, 317, 358, 358, 358, 358, 358, 358, 358, 269, - /* 1870 */ 358, 358, 241, 358, 358, 358, 358, 277, 358, 358, - /* 1880 */ 358, 358, 358, 358, 358, 358, 358, 287, 358, 358, - /* 1890 */ 358, 291, 358, 358, 358, 358, 358, 358, 358, 358, - /* 1900 */ 269, 241, 358, 358, 358, 358, 358, 307, 277, 358, - /* 1910 */ 310, 311, 312, 313, 314, 315, 358, 317, 287, 358, - /* 1920 */ 358, 358, 291, 358, 358, 358, 358, 358, 358, 269, - /* 1930 */ 358, 358, 241, 358, 358, 358, 358, 277, 307, 358, - /* 1940 */ 358, 310, 311, 312, 313, 314, 315, 287, 317, 358, - /* 1950 */ 358, 291, 358, 358, 358, 358, 358, 358, 358, 358, - /* 1960 */ 269, 241, 358, 358, 358, 358, 358, 307, 277, 358, - /* 1970 */ 310, 311, 312, 313, 314, 315, 358, 317, 287, 358, - /* 1980 */ 358, 358, 291, 358, 358, 358, 358, 358, 358, 269, - /* 1990 */ 358, 358, 358, 358, 358, 358, 358, 277, 307, 358, - /* 2000 */ 358, 310, 311, 312, 313, 314, 315, 287, 317, 358, - /* 2010 */ 358, 291, 241, 358, 358, 358, 358, 358, 358, 358, - /* 2020 */ 358, 358, 358, 241, 358, 358, 358, 307, 358, 358, - /* 2030 */ 310, 311, 312, 313, 314, 315, 358, 317, 358, 358, - /* 2040 */ 269, 358, 358, 358, 358, 358, 358, 358, 277, 358, - /* 2050 */ 358, 269, 358, 358, 358, 358, 358, 358, 287, 277, - /* 2060 */ 358, 358, 291, 358, 358, 358, 358, 358, 358, 287, - /* 2070 */ 358, 358, 358, 291, 358, 358, 358, 241, 307, 358, - /* 2080 */ 358, 310, 311, 312, 313, 314, 315, 358, 317, 307, - /* 2090 */ 358, 358, 310, 311, 312, 313, 314, 315, 358, 317, - /* 2100 */ 358, 358, 358, 358, 358, 269, 358, 358, 358, 358, - /* 2110 */ 358, 358, 358, 277, 358, 358, 358, 358, 358, 358, - /* 2120 */ 358, 358, 358, 287, 358, 358, 358, 291, 358, 358, - /* 2130 */ 358, 358, 358, 358, 358, 358, 358, 358, 358, 358, - /* 2140 */ 358, 358, 358, 307, 358, 358, 310, 311, 312, 313, - /* 2150 */ 314, 315, 358, 317, + /* 0 */ 246, 273, 248, 249, 276, 246, 250, 248, 249, 324, + /* 10 */ 325, 4, 12, 13, 242, 271, 244, 243, 262, 339, + /* 20 */ 20, 293, 22, 279, 20, 269, 12, 13, 14, 15, + /* 30 */ 16, 247, 352, 255, 250, 279, 356, 309, 310, 12, + /* 40 */ 13, 14, 15, 16, 271, 271, 268, 47, 320, 42, + /* 50 */ 43, 278, 47, 279, 250, 277, 283, 55, 58, 315, + /* 60 */ 12, 13, 14, 289, 64, 2, 262, 293, 20, 64, + /* 70 */ 22, 0, 58, 299, 20, 12, 13, 14, 15, 16, + /* 80 */ 4, 81, 80, 279, 310, 83, 250, 313, 314, 315, + /* 90 */ 316, 317, 318, 0, 320, 47, 82, 323, 262, 251, + /* 100 */ 252, 327, 328, 103, 90, 269, 58, 12, 13, 14, + /* 110 */ 15, 16, 64, 339, 114, 279, 270, 24, 25, 26, + /* 120 */ 27, 28, 29, 30, 31, 32, 352, 75, 282, 81, + /* 130 */ 356, 60, 61, 62, 63, 81, 65, 66, 67, 68, + /* 140 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, + /* 150 */ 289, 103, 279, 292, 140, 81, 295, 81, 158, 286, + /* 160 */ 21, 339, 114, 24, 25, 26, 27, 28, 29, 30, + /* 170 */ 31, 32, 120, 121, 352, 250, 162, 150, 356, 247, + /* 180 */ 180, 181, 250, 183, 184, 185, 186, 187, 188, 189, + /* 190 */ 190, 191, 192, 193, 194, 195, 196, 197, 0, 12, + /* 200 */ 13, 14, 15, 16, 167, 168, 158, 256, 171, 284, + /* 210 */ 210, 260, 198, 199, 200, 201, 202, 203, 204, 205, + /* 220 */ 206, 207, 0, 12, 13, 14, 15, 16, 180, 181, + /* 230 */ 250, 183, 184, 185, 186, 187, 188, 189, 190, 191, + /* 240 */ 192, 193, 194, 195, 196, 197, 12, 13, 0, 20, + /* 250 */ 253, 22, 60, 61, 20, 57, 22, 65, 231, 279, + /* 260 */ 68, 69, 263, 339, 72, 73, 74, 12, 13, 82, + /* 270 */ 271, 274, 243, 57, 20, 20, 352, 22, 49, 280, + /* 280 */ 356, 47, 60, 61, 210, 20, 210, 65, 255, 47, + /* 290 */ 68, 69, 58, 82, 72, 73, 74, 317, 64, 0, + /* 300 */ 271, 14, 47, 243, 243, 250, 64, 20, 279, 250, + /* 310 */ 277, 331, 332, 333, 334, 81, 336, 262, 289, 64, + /* 320 */ 21, 262, 293, 24, 25, 26, 27, 28, 29, 30, + /* 330 */ 31, 32, 271, 243, 279, 81, 81, 103, 279, 310, + /* 340 */ 279, 93, 313, 314, 315, 316, 317, 318, 114, 320, + /* 350 */ 289, 20, 323, 293, 293, 271, 327, 328, 103, 271, + /* 360 */ 112, 113, 278, 115, 116, 117, 243, 283, 280, 114, + /* 370 */ 259, 310, 261, 271, 313, 314, 315, 316, 317, 318, + /* 380 */ 278, 320, 250, 293, 323, 283, 311, 2, 327, 328, + /* 390 */ 329, 20, 158, 3, 262, 257, 258, 12, 13, 14, + /* 400 */ 15, 16, 341, 12, 13, 14, 15, 16, 347, 348, + /* 410 */ 335, 279, 81, 158, 180, 181, 293, 183, 184, 185, + /* 420 */ 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, + /* 430 */ 196, 197, 250, 257, 258, 180, 181, 243, 183, 184, + /* 440 */ 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, + /* 450 */ 195, 196, 197, 12, 13, 14, 243, 4, 20, 19, + /* 460 */ 281, 20, 243, 22, 210, 210, 264, 288, 289, 267, + /* 470 */ 14, 184, 19, 33, 12, 13, 20, 273, 243, 243, + /* 480 */ 273, 299, 20, 276, 22, 45, 33, 293, 47, 250, + /* 490 */ 144, 51, 52, 53, 54, 55, 14, 293, 45, 240, + /* 500 */ 293, 262, 20, 50, 57, 64, 293, 271, 55, 47, + /* 510 */ 153, 250, 293, 309, 310, 279, 309, 310, 279, 250, + /* 520 */ 80, 339, 81, 83, 320, 289, 64, 320, 293, 293, + /* 530 */ 173, 174, 64, 80, 352, 299, 83, 146, 356, 289, + /* 540 */ 279, 210, 41, 81, 103, 295, 310, 20, 279, 313, + /* 550 */ 314, 315, 316, 317, 318, 114, 320, 117, 299, 323, + /* 560 */ 243, 215, 216, 327, 328, 103, 12, 13, 14, 15, + /* 570 */ 16, 273, 80, 263, 272, 339, 114, 93, 317, 92, + /* 580 */ 88, 271, 142, 82, 146, 145, 317, 0, 352, 81, + /* 590 */ 280, 293, 356, 332, 333, 334, 253, 336, 339, 158, + /* 600 */ 116, 332, 333, 334, 164, 336, 166, 309, 310, 266, + /* 610 */ 293, 352, 58, 288, 289, 356, 226, 274, 320, 4, + /* 620 */ 158, 180, 181, 243, 183, 184, 185, 186, 187, 188, + /* 630 */ 189, 190, 191, 192, 193, 194, 195, 196, 197, 35, + /* 640 */ 184, 149, 180, 181, 90, 183, 184, 185, 186, 187, + /* 650 */ 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, + /* 660 */ 12, 13, 18, 93, 20, 157, 180, 159, 20, 250, + /* 670 */ 22, 27, 250, 293, 30, 14, 15, 16, 208, 209, + /* 680 */ 93, 262, 112, 113, 262, 115, 116, 117, 84, 37, + /* 690 */ 86, 87, 48, 89, 140, 47, 22, 93, 279, 112, + /* 700 */ 113, 279, 115, 116, 117, 219, 220, 221, 222, 223, + /* 710 */ 271, 263, 64, 1, 2, 243, 162, 311, 210, 271, + /* 720 */ 116, 47, 283, 42, 43, 311, 169, 170, 280, 81, + /* 730 */ 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, + /* 740 */ 104, 335, 106, 107, 108, 109, 110, 111, 299, 335, + /* 750 */ 243, 103, 198, 199, 200, 201, 202, 203, 204, 205, + /* 760 */ 206, 207, 114, 119, 0, 293, 122, 123, 124, 125, + /* 770 */ 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, + /* 780 */ 136, 137, 138, 139, 250, 250, 18, 250, 339, 20, + /* 790 */ 41, 23, 20, 20, 82, 140, 262, 262, 272, 262, + /* 800 */ 293, 352, 243, 35, 36, 356, 158, 39, 243, 243, + /* 810 */ 243, 299, 243, 279, 279, 243, 279, 162, 250, 243, + /* 820 */ 243, 57, 243, 146, 56, 148, 211, 272, 180, 181, + /* 830 */ 262, 183, 184, 185, 186, 187, 188, 189, 190, 191, + /* 840 */ 192, 193, 194, 195, 196, 197, 41, 279, 271, 81, + /* 850 */ 272, 339, 293, 198, 0, 272, 279, 0, 293, 293, + /* 860 */ 293, 209, 293, 0, 352, 293, 289, 0, 356, 293, + /* 870 */ 293, 85, 293, 85, 88, 85, 88, 85, 88, 22, + /* 880 */ 88, 243, 58, 21, 272, 22, 118, 310, 81, 22, + /* 890 */ 313, 314, 315, 316, 317, 318, 34, 320, 91, 45, + /* 900 */ 323, 1, 2, 272, 327, 328, 329, 244, 303, 271, + /* 910 */ 195, 196, 44, 260, 243, 146, 47, 279, 150, 151, + /* 920 */ 152, 41, 41, 155, 350, 348, 47, 289, 160, 41, + /* 930 */ 359, 293, 41, 41, 41, 307, 344, 271, 249, 41, + /* 940 */ 172, 251, 271, 175, 282, 177, 178, 179, 310, 81, + /* 950 */ 279, 313, 314, 315, 316, 317, 318, 184, 320, 312, + /* 960 */ 289, 323, 82, 82, 293, 327, 328, 329, 20, 41, + /* 970 */ 82, 41, 337, 82, 82, 82, 338, 228, 210, 243, + /* 980 */ 82, 310, 353, 114, 313, 314, 315, 316, 317, 318, + /* 990 */ 353, 320, 41, 114, 323, 243, 41, 41, 327, 328, + /* 1000 */ 329, 250, 41, 353, 180, 340, 41, 271, 45, 338, + /* 1010 */ 82, 308, 82, 47, 257, 279, 41, 41, 301, 40, + /* 1020 */ 156, 250, 287, 271, 250, 289, 140, 243, 285, 293, + /* 1030 */ 285, 279, 250, 82, 20, 230, 245, 82, 82, 245, + /* 1040 */ 20, 289, 305, 82, 255, 293, 310, 82, 289, 313, + /* 1050 */ 314, 315, 316, 317, 318, 271, 320, 82, 82, 323, + /* 1060 */ 20, 255, 310, 279, 328, 313, 314, 315, 316, 317, + /* 1070 */ 318, 20, 320, 289, 297, 323, 300, 293, 243, 327, + /* 1080 */ 328, 329, 255, 299, 297, 255, 20, 279, 290, 255, + /* 1090 */ 338, 255, 250, 243, 310, 255, 245, 313, 314, 315, + /* 1100 */ 316, 317, 318, 271, 320, 250, 271, 64, 271, 271, + /* 1110 */ 271, 245, 271, 293, 279, 271, 271, 271, 271, 271, + /* 1120 */ 271, 271, 305, 339, 289, 253, 304, 253, 293, 279, + /* 1130 */ 297, 253, 165, 290, 299, 279, 352, 253, 20, 289, + /* 1140 */ 356, 289, 218, 293, 243, 310, 349, 294, 313, 314, + /* 1150 */ 315, 316, 317, 318, 217, 320, 225, 346, 293, 349, + /* 1160 */ 310, 345, 224, 313, 314, 315, 316, 317, 318, 294, + /* 1170 */ 320, 312, 271, 323, 339, 293, 293, 327, 328, 20, + /* 1180 */ 279, 213, 212, 209, 279, 40, 229, 352, 311, 360, + /* 1190 */ 289, 356, 232, 81, 293, 293, 243, 293, 227, 293, + /* 1200 */ 12, 13, 294, 343, 294, 243, 330, 143, 291, 290, + /* 1210 */ 22, 310, 342, 355, 313, 314, 315, 316, 317, 318, + /* 1220 */ 319, 320, 321, 322, 271, 354, 279, 81, 355, 326, + /* 1230 */ 253, 267, 279, 271, 253, 47, 250, 279, 253, 354, + /* 1240 */ 245, 279, 289, 261, 355, 302, 293, 275, 354, 265, + /* 1250 */ 306, 289, 64, 243, 265, 293, 265, 298, 296, 254, + /* 1260 */ 241, 0, 0, 310, 72, 0, 313, 314, 315, 316, + /* 1270 */ 317, 318, 310, 320, 47, 313, 314, 315, 316, 317, + /* 1280 */ 318, 271, 320, 176, 47, 243, 47, 47, 0, 279, + /* 1290 */ 176, 103, 47, 47, 0, 176, 47, 0, 47, 289, + /* 1300 */ 0, 47, 114, 293, 0, 81, 162, 114, 161, 158, + /* 1310 */ 357, 358, 0, 271, 0, 154, 153, 243, 0, 0, + /* 1320 */ 310, 279, 44, 313, 314, 315, 316, 317, 318, 0, + /* 1330 */ 320, 289, 0, 0, 0, 293, 0, 0, 0, 0, + /* 1340 */ 0, 0, 0, 0, 0, 271, 158, 0, 0, 0, + /* 1350 */ 0, 0, 310, 279, 0, 313, 314, 315, 316, 317, + /* 1360 */ 318, 351, 320, 289, 40, 243, 0, 293, 180, 0, + /* 1370 */ 296, 0, 0, 0, 22, 0, 0, 0, 243, 191, + /* 1380 */ 192, 193, 0, 0, 310, 0, 40, 313, 314, 315, + /* 1390 */ 316, 317, 318, 271, 320, 14, 37, 41, 14, 44, + /* 1400 */ 358, 279, 0, 38, 44, 37, 271, 0, 0, 0, + /* 1410 */ 0, 289, 0, 0, 279, 293, 37, 37, 243, 0, + /* 1420 */ 59, 0, 0, 37, 289, 47, 0, 37, 293, 37, + /* 1430 */ 0, 296, 310, 37, 45, 313, 314, 315, 316, 317, + /* 1440 */ 318, 47, 320, 45, 322, 310, 271, 47, 313, 314, + /* 1450 */ 315, 316, 317, 318, 279, 320, 45, 0, 33, 0, + /* 1460 */ 45, 47, 0, 0, 289, 47, 243, 0, 293, 22, + /* 1470 */ 45, 296, 41, 41, 47, 22, 51, 52, 53, 54, + /* 1480 */ 55, 90, 47, 88, 47, 310, 47, 47, 313, 314, + /* 1490 */ 315, 316, 317, 318, 271, 320, 47, 47, 0, 22, + /* 1500 */ 47, 0, 279, 22, 48, 80, 0, 22, 83, 0, + /* 1510 */ 22, 47, 289, 0, 22, 20, 293, 64, 0, 47, + /* 1520 */ 146, 0, 22, 243, 0, 163, 0, 0, 37, 81, + /* 1530 */ 143, 41, 81, 310, 141, 41, 313, 314, 315, 316, + /* 1540 */ 317, 318, 82, 320, 214, 146, 41, 82, 82, 81, + /* 1550 */ 81, 271, 41, 41, 44, 81, 103, 82, 44, 279, + /* 1560 */ 82, 44, 82, 41, 44, 208, 141, 114, 143, 289, + /* 1570 */ 145, 243, 147, 293, 41, 47, 47, 214, 214, 82, + /* 1580 */ 2, 47, 47, 47, 47, 180, 41, 44, 44, 82, + /* 1590 */ 310, 166, 22, 313, 314, 315, 316, 317, 318, 271, + /* 1600 */ 320, 243, 182, 0, 81, 144, 81, 279, 44, 37, + /* 1610 */ 91, 158, 82, 81, 141, 22, 47, 289, 44, 81, + /* 1620 */ 81, 293, 82, 92, 82, 59, 47, 81, 81, 271, + /* 1630 */ 81, 243, 81, 180, 181, 82, 81, 279, 310, 81, + /* 1640 */ 81, 313, 314, 315, 316, 317, 318, 289, 320, 82, + /* 1650 */ 82, 293, 47, 47, 81, 47, 47, 82, 81, 271, + /* 1660 */ 22, 105, 82, 81, 47, 82, 81, 279, 310, 93, + /* 1670 */ 105, 313, 314, 315, 316, 317, 318, 289, 320, 243, + /* 1680 */ 81, 293, 81, 81, 47, 22, 105, 58, 243, 105, + /* 1690 */ 47, 64, 79, 41, 47, 47, 47, 47, 310, 22, + /* 1700 */ 114, 313, 314, 315, 316, 317, 318, 271, 320, 47, + /* 1710 */ 64, 47, 47, 47, 47, 279, 271, 47, 47, 47, + /* 1720 */ 47, 47, 0, 47, 279, 289, 45, 37, 0, 293, + /* 1730 */ 47, 45, 37, 0, 289, 47, 243, 45, 293, 37, + /* 1740 */ 0, 47, 45, 37, 0, 47, 310, 46, 0, 313, + /* 1750 */ 314, 315, 316, 317, 318, 310, 320, 0, 313, 314, + /* 1760 */ 315, 316, 317, 318, 271, 320, 20, 22, 21, 361, + /* 1770 */ 361, 22, 279, 22, 21, 361, 361, 361, 361, 361, + /* 1780 */ 361, 361, 289, 361, 243, 361, 293, 361, 361, 361, + /* 1790 */ 361, 361, 361, 361, 361, 243, 361, 361, 361, 361, + /* 1800 */ 361, 361, 361, 310, 361, 361, 313, 314, 315, 316, + /* 1810 */ 317, 318, 271, 320, 243, 361, 361, 361, 361, 361, + /* 1820 */ 279, 361, 361, 271, 361, 361, 361, 361, 361, 361, + /* 1830 */ 289, 279, 361, 361, 293, 361, 361, 361, 361, 361, + /* 1840 */ 361, 289, 271, 361, 361, 293, 361, 361, 361, 361, + /* 1850 */ 279, 310, 361, 361, 313, 314, 315, 316, 317, 318, + /* 1860 */ 289, 320, 310, 361, 293, 313, 314, 315, 316, 317, + /* 1870 */ 318, 361, 320, 243, 361, 361, 361, 361, 361, 361, + /* 1880 */ 361, 310, 243, 361, 313, 314, 315, 316, 317, 318, + /* 1890 */ 361, 320, 361, 361, 361, 361, 361, 361, 361, 361, + /* 1900 */ 361, 271, 361, 361, 361, 361, 361, 361, 361, 279, + /* 1910 */ 271, 361, 361, 361, 361, 361, 361, 361, 279, 289, + /* 1920 */ 361, 361, 361, 293, 361, 361, 361, 361, 289, 361, + /* 1930 */ 361, 361, 293, 361, 361, 361, 361, 361, 361, 361, + /* 1940 */ 310, 361, 243, 313, 314, 315, 316, 317, 318, 310, + /* 1950 */ 320, 243, 313, 314, 315, 316, 317, 318, 361, 320, + /* 1960 */ 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + /* 1970 */ 271, 361, 361, 361, 361, 361, 361, 361, 279, 271, + /* 1980 */ 361, 361, 361, 361, 361, 361, 361, 279, 289, 361, + /* 1990 */ 361, 361, 293, 361, 361, 361, 361, 289, 361, 243, + /* 2000 */ 361, 293, 361, 361, 361, 361, 361, 361, 361, 310, + /* 2010 */ 250, 361, 313, 314, 315, 316, 317, 318, 310, 320, + /* 2020 */ 361, 313, 314, 315, 316, 317, 318, 271, 320, 361, + /* 2030 */ 361, 361, 361, 361, 361, 279, 361, 361, 361, 279, + /* 2040 */ 361, 361, 361, 361, 361, 289, 250, 361, 361, 293, + /* 2050 */ 361, 361, 361, 361, 361, 361, 361, 361, 361, 299, + /* 2060 */ 361, 361, 361, 361, 361, 361, 310, 361, 361, 313, + /* 2070 */ 314, 315, 316, 317, 318, 279, 320, 317, 361, 361, + /* 2080 */ 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + /* 2090 */ 361, 361, 332, 333, 334, 299, 336, 361, 361, 339, + /* 2100 */ 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, + /* 2110 */ 361, 361, 352, 317, 361, 361, 356, 361, 361, 361, + /* 2120 */ 361, 361, 361, 361, 361, 361, 361, 361, 332, 333, + /* 2130 */ 334, 361, 336, 361, 361, 339, 361, 361, 361, 361, + /* 2140 */ 361, 361, 361, 361, 361, 361, 361, 361, 352, 361, + /* 2150 */ 361, 361, 356, }; -#define YY_SHIFT_COUNT (604) +#define YY_SHIFT_COUNT (610) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1729) +#define YY_SHIFT_MAX (1757) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 739, 0, 0, 48, 96, 96, 96, 96, 280, 280, - /* 10 */ 96, 96, 328, 376, 560, 376, 376, 376, 376, 376, - /* 20 */ 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, - /* 30 */ 376, 376, 376, 376, 376, 376, 376, 376, 37, 37, - /* 40 */ 68, 68, 68, 1656, 1656, 1656, 1656, 64, 271, 179, - /* 50 */ 18, 18, 13, 13, 123, 179, 179, 18, 18, 18, - /* 60 */ 18, 18, 18, 35, 18, 182, 190, 314, 182, 18, - /* 70 */ 18, 182, 18, 182, 182, 314, 182, 18, 334, 556, - /* 80 */ 343, 107, 107, 192, 312, 746, 746, 746, 746, 746, - /* 90 */ 746, 746, 746, 746, 746, 746, 746, 746, 746, 746, - /* 100 */ 746, 746, 746, 746, 441, 580, 110, 110, 206, 720, - /* 110 */ 393, 393, 393, 244, 720, 384, 314, 182, 182, 314, - /* 120 */ 356, 466, 549, 549, 549, 549, 549, 549, 549, 1309, - /* 130 */ 294, 197, 21, 78, 268, 279, 517, 583, 694, 292, - /* 140 */ 502, 611, 576, 687, 576, 598, 598, 598, 756, 750, - /* 150 */ 982, 964, 965, 866, 982, 982, 981, 890, 890, 982, - /* 160 */ 1019, 1019, 1032, 35, 314, 35, 1040, 35, 384, 1049, - /* 170 */ 35, 35, 982, 35, 1019, 182, 182, 182, 182, 182, - /* 180 */ 182, 182, 182, 182, 182, 182, 982, 1019, 1016, 1032, - /* 190 */ 334, 957, 314, 334, 1040, 334, 384, 1049, 334, 1114, - /* 200 */ 925, 927, 1016, 925, 927, 1016, 1016, 182, 923, 938, - /* 210 */ 939, 951, 967, 384, 1161, 1146, 961, 972, 966, 961, - /* 220 */ 972, 961, 972, 1118, 927, 1016, 1016, 927, 1016, 1063, - /* 230 */ 384, 1049, 334, 356, 334, 384, 1167, 466, 982, 334, - /* 240 */ 1019, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 2154, 635, - /* 250 */ 928, 1184, 1043, 921, 997, 119, 14, 30, 485, 126, - /* 260 */ 498, 354, 354, 354, 354, 354, 354, 354, 354, 309, - /* 270 */ 321, 415, 404, 8, 445, 622, 622, 622, 622, 772, - /* 280 */ 774, 734, 742, 763, 765, 435, 878, 883, 832, 623, - /* 290 */ 724, 830, 857, 863, 879, 725, 751, 787, 865, 796, - /* 300 */ 869, 792, 872, 876, 881, 894, 904, 773, 854, 914, - /* 310 */ 917, 930, 943, 946, 947, 859, 820, 1275, 1276, 1205, - /* 320 */ 1279, 1233, 1107, 1235, 1236, 1237, 1112, 1287, 1242, 1243, - /* 330 */ 1117, 1293, 1247, 1295, 1249, 1297, 1251, 1303, 1225, 1149, - /* 340 */ 1147, 1197, 1163, 1317, 1322, 1171, 1174, 1329, 1330, 1288, - /* 350 */ 1331, 1333, 1334, 1336, 1337, 1338, 1339, 1340, 1341, 1347, - /* 360 */ 1348, 1350, 1351, 1353, 1355, 1356, 1357, 1358, 1304, 1359, - /* 370 */ 1366, 1367, 1376, 1377, 1378, 1321, 1379, 1380, 1381, 1383, - /* 380 */ 1384, 1386, 1349, 1360, 1346, 1385, 1354, 1387, 1361, 1390, - /* 390 */ 1362, 1365, 1393, 1394, 1395, 1403, 1369, 1404, 1352, 1407, - /* 400 */ 1408, 1363, 1364, 1389, 1414, 1382, 1388, 1391, 1423, 1392, - /* 410 */ 1396, 1397, 1424, 1398, 1399, 1400, 1427, 1430, 1440, 1442, - /* 420 */ 1373, 1345, 1401, 1425, 1443, 1402, 1405, 1416, 1419, 1426, - /* 430 */ 1428, 1429, 1431, 1433, 1446, 1448, 1468, 1452, 1435, 1475, - /* 440 */ 1455, 1434, 1479, 1462, 1485, 1465, 1469, 1488, 1368, 1444, - /* 450 */ 1490, 1335, 1470, 1371, 1375, 1494, 1495, 1498, 1420, 1466, - /* 460 */ 1406, 1458, 1463, 1307, 1439, 1480, 1441, 1447, 1449, 1450, - /* 470 */ 1445, 1482, 1484, 1496, 1464, 1491, 1342, 1461, 1467, 1501, - /* 480 */ 1318, 1508, 1507, 1471, 1514, 1344, 1476, 1511, 1513, 1515, - /* 490 */ 1517, 1518, 1525, 1476, 1557, 1409, 1520, 1493, 1497, 1499, - /* 500 */ 1531, 1502, 1503, 1532, 1556, 1410, 1505, 1510, 1516, 1506, - /* 510 */ 1521, 1436, 1522, 1588, 1555, 1453, 1524, 1504, 1551, 1552, - /* 520 */ 1526, 1519, 1527, 1576, 1528, 1523, 1529, 1558, 1562, 1535, - /* 530 */ 1530, 1569, 1537, 1540, 1571, 1548, 1550, 1585, 1553, 1554, - /* 540 */ 1589, 1559, 1533, 1534, 1536, 1538, 1621, 1560, 1564, 1565, - /* 550 */ 1599, 1567, 1561, 1601, 1629, 1602, 1606, 1603, 1587, 1625, - /* 560 */ 1623, 1624, 1628, 1630, 1633, 1650, 1634, 1641, 1612, 1426, - /* 570 */ 1644, 1428, 1645, 1646, 1647, 1648, 1649, 1652, 1697, 1653, - /* 580 */ 1657, 1667, 1705, 1659, 1662, 1673, 1711, 1666, 1669, 1678, - /* 590 */ 1716, 1670, 1676, 1681, 1722, 1679, 1683, 1725, 1727, 1708, - /* 600 */ 1719, 1715, 1726, 1729, 1721, + /* 0 */ 768, 0, 0, 48, 234, 234, 234, 234, 255, 255, + /* 10 */ 234, 234, 441, 462, 648, 462, 462, 462, 462, 462, + /* 20 */ 462, 462, 462, 462, 462, 462, 462, 462, 462, 462, + /* 30 */ 462, 462, 462, 462, 462, 462, 462, 462, 254, 254, + /* 40 */ 54, 54, 54, 1188, 1188, 1188, 1188, 331, 508, 74, + /* 50 */ 4, 4, 7, 7, 76, 74, 74, 4, 4, 4, + /* 60 */ 4, 4, 4, 216, 4, 265, 371, 527, 265, 4, + /* 70 */ 4, 265, 4, 265, 265, 527, 265, 4, 447, 644, + /* 80 */ 14, 554, 554, 139, 192, 1453, 1453, 1453, 1453, 1453, + /* 90 */ 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, 1453, + /* 100 */ 1453, 1453, 1453, 1453, 604, 229, 482, 482, 198, 5, + /* 110 */ 438, 438, 438, 764, 5, 772, 527, 265, 265, 527, + /* 120 */ 487, 468, 636, 636, 636, 636, 636, 636, 636, 440, + /* 130 */ 299, 222, 27, 486, 37, 346, 287, 456, 681, 674, + /* 140 */ 484, 769, 470, 652, 470, 390, 390, 390, 615, 773, + /* 150 */ 948, 963, 966, 864, 948, 948, 979, 886, 886, 948, + /* 160 */ 1014, 1014, 1020, 216, 527, 216, 1040, 1051, 216, 1040, + /* 170 */ 216, 772, 1066, 216, 216, 948, 216, 1014, 265, 265, + /* 180 */ 265, 265, 265, 265, 265, 265, 265, 265, 265, 948, + /* 190 */ 1014, 1043, 1020, 447, 967, 527, 447, 1040, 447, 772, + /* 200 */ 1066, 447, 1118, 924, 937, 1043, 924, 937, 1043, 1043, + /* 210 */ 265, 931, 938, 968, 970, 974, 772, 1159, 1145, 957, + /* 220 */ 971, 960, 957, 971, 957, 971, 1112, 937, 1043, 1043, + /* 230 */ 937, 1043, 1064, 772, 1066, 447, 487, 447, 772, 1146, + /* 240 */ 468, 948, 447, 1014, 2153, 2153, 2153, 2153, 2153, 2153, + /* 250 */ 2153, 2153, 71, 1425, 93, 453, 248, 587, 187, 63, + /* 260 */ 385, 391, 211, 570, 95, 95, 95, 95, 95, 95, + /* 270 */ 95, 95, 357, 2, 52, 492, 712, 655, 661, 661, + /* 280 */ 661, 661, 854, 501, 786, 788, 790, 792, 857, 863, + /* 290 */ 867, 862, 557, 677, 880, 881, 888, 900, 715, 749, + /* 300 */ 805, 891, 824, 892, 868, 893, 898, 928, 930, 951, + /* 310 */ 869, 879, 955, 956, 961, 965, 975, 976, 807, 242, + /* 320 */ 1261, 1262, 1192, 1265, 1227, 1107, 1237, 1239, 1240, 1114, + /* 330 */ 1288, 1245, 1246, 1119, 1294, 1249, 1297, 1251, 1300, 1254, + /* 340 */ 1304, 1224, 1144, 1147, 1193, 1151, 1312, 1314, 1161, 1163, + /* 350 */ 1318, 1319, 1278, 1329, 1332, 1333, 1334, 1336, 1337, 1338, + /* 360 */ 1339, 1340, 1341, 1342, 1343, 1344, 1347, 1348, 1349, 1350, + /* 370 */ 1351, 1324, 1354, 1366, 1369, 1371, 1372, 1373, 1352, 1375, + /* 380 */ 1376, 1377, 1382, 1383, 1385, 1346, 1359, 1356, 1381, 1355, + /* 390 */ 1384, 1360, 1402, 1365, 1368, 1407, 1408, 1409, 1379, 1410, + /* 400 */ 1412, 1380, 1413, 1361, 1419, 1421, 1378, 1389, 1386, 1422, + /* 410 */ 1394, 1398, 1390, 1426, 1400, 1411, 1392, 1430, 1414, 1415, + /* 420 */ 1396, 1457, 1459, 1462, 1463, 1391, 1395, 1418, 1447, 1467, + /* 430 */ 1427, 1435, 1437, 1439, 1431, 1432, 1440, 1449, 1450, 1498, + /* 440 */ 1477, 1501, 1481, 1456, 1506, 1485, 1464, 1509, 1488, 1513, + /* 450 */ 1492, 1495, 1518, 1374, 1472, 1521, 1362, 1500, 1399, 1387, + /* 460 */ 1524, 1526, 1527, 1448, 1491, 1393, 1490, 1494, 1330, 1460, + /* 470 */ 1505, 1465, 1451, 1468, 1469, 1466, 1511, 1510, 1514, 1474, + /* 480 */ 1512, 1363, 1475, 1478, 1517, 1357, 1522, 1520, 1480, 1533, + /* 490 */ 1364, 1497, 1528, 1529, 1534, 1535, 1536, 1537, 1497, 1578, + /* 500 */ 1405, 1545, 1507, 1523, 1530, 1543, 1525, 1532, 1544, 1570, + /* 510 */ 1420, 1538, 1540, 1542, 1539, 1546, 1461, 1547, 1603, 1572, + /* 520 */ 1473, 1549, 1519, 1564, 1574, 1551, 1553, 1555, 1593, 1558, + /* 530 */ 1531, 1567, 1569, 1579, 1559, 1568, 1605, 1573, 1575, 1606, + /* 540 */ 1577, 1580, 1608, 1582, 1583, 1609, 1585, 1556, 1565, 1581, + /* 550 */ 1584, 1638, 1576, 1599, 1601, 1617, 1602, 1586, 1637, 1663, + /* 560 */ 1566, 1629, 1643, 1627, 1613, 1652, 1647, 1648, 1649, 1650, + /* 570 */ 1662, 1677, 1664, 1665, 1646, 1431, 1666, 1432, 1667, 1670, + /* 580 */ 1671, 1672, 1673, 1674, 1722, 1676, 1681, 1690, 1728, 1683, + /* 590 */ 1686, 1695, 1733, 1688, 1692, 1702, 1740, 1694, 1697, 1706, + /* 600 */ 1744, 1698, 1701, 1748, 1757, 1745, 1747, 1749, 1751, 1753, + /* 610 */ 1746, }; -#define YY_REDUCE_COUNT (248) -#define YY_REDUCE_MIN (-335) -#define YY_REDUCE_MAX (1836) +#define YY_REDUCE_COUNT (251) +#define YY_REDUCE_MIN (-320) +#define YY_REDUCE_MAX (1796) static const short yy_reduce_ofst[] = { - /* 0 */ -190, -238, 489, 520, 308, 616, 679, 731, 790, 841, - /* 10 */ 858, 916, 948, -140, 1001, 1058, 138, 1105, 1144, 1195, - /* 20 */ 1224, 1256, 1312, 1343, 1372, 1421, 1432, 1483, 1512, 1544, - /* 30 */ 1600, 1631, 1660, 1691, 1720, 1771, 1782, 1836, 546, 971, - /* 40 */ 88, -1, 113, -266, -181, 46, 103, 239, -286, -85, - /* 50 */ -163, 87, -240, -223, -335, -334, -253, -49, 85, 135, - /* 60 */ 248, 331, 511, -172, 521, -124, -111, 56, 136, 564, - /* 70 */ 591, -21, 613, 216, 130, 152, 320, 614, -173, -177, - /* 80 */ -256, -256, -256, -188, -105, -86, 213, 261, 287, 370, - /* 90 */ 375, 385, 422, 423, 424, 426, 427, 428, 429, 430, - /* 100 */ 431, 434, 482, 486, -100, 4, 305, 348, 63, 473, - /* 110 */ -83, 432, 455, 355, 476, 94, 492, 457, -8, 447, - /* 120 */ 543, -95, -270, 225, 235, 317, 369, 390, 593, 516, - /* 130 */ 654, 650, 578, 590, 639, 618, 683, 683, 707, 711, - /* 140 */ 684, 659, 629, 629, 629, 619, 626, 628, 664, 683, - /* 150 */ 758, 712, 761, 721, 775, 777, 741, 747, 757, 786, - /* 160 */ 806, 807, 752, 800, 771, 808, 768, 811, 788, 783, - /* 170 */ 821, 822, 825, 826, 835, 814, 815, 816, 817, 827, - /* 180 */ 837, 845, 846, 847, 848, 850, 842, 851, 804, 789, - /* 190 */ 870, 823, 836, 880, 834, 882, 853, 849, 885, 831, - /* 200 */ 798, 855, 868, 818, 871, 875, 888, 683, 819, 838, - /* 210 */ 852, 828, 629, 899, 887, 860, 839, 867, 843, 886, - /* 220 */ 873, 891, 893, 897, 907, 910, 911, 912, 915, 932, - /* 230 */ 945, 944, 983, 980, 986, 969, 976, 991, 1003, 1002, - /* 240 */ 1009, 955, 953, 973, 994, 1008, 1010, 1020, 1035, + /* 0 */ 259, -226, 236, 61, 577, 638, 671, 752, 784, 835, + /* 10 */ 29, 850, 901, 953, 736, 962, 1010, 1042, 1074, 1122, + /* 20 */ 1135, 1175, 1223, 1280, 1328, 1358, 1388, 1436, 1445, 1493, + /* 30 */ 1541, 1552, 1571, 1630, 1639, 1699, 1708, 1756, 1760, 1796, + /* 40 */ -20, 261, 269, -272, 207, 204, 298, 182, 449, 512, + /* 50 */ -244, -164, -246, -241, -320, -178, -76, -196, 55, 59, + /* 60 */ 132, 239, 419, -222, 422, -227, -256, -139, -1, 534, + /* 70 */ 535, 84, 537, 310, 102, 179, 448, 568, 343, -75, + /* 80 */ -315, -315, -315, -228, -49, 60, 90, 123, 194, 213, + /* 90 */ 219, 235, 317, 380, 472, 507, 559, 565, 566, 567, + /* 100 */ 569, 572, 576, 579, -154, -152, -216, -68, 33, 138, + /* 110 */ 75, 406, 414, -3, 176, -127, 250, 88, 439, 325, + /* 120 */ 202, 111, 302, 526, 555, 578, 583, 612, 631, 605, + /* 130 */ 663, 653, 571, 574, 628, 592, 666, 666, 689, 690, + /* 140 */ 662, 647, 635, 635, 635, 629, 637, 650, 665, 666, + /* 150 */ 751, 703, 757, 717, 771, 774, 735, 743, 745, 782, + /* 160 */ 791, 794, 737, 789, 759, 806, 777, 776, 827, 787, + /* 170 */ 830, 808, 798, 834, 836, 842, 840, 851, 832, 837, + /* 180 */ 838, 839, 841, 844, 845, 846, 847, 848, 849, 855, + /* 190 */ 866, 820, 817, 872, 822, 852, 874, 833, 878, 856, + /* 200 */ 843, 884, 859, 797, 853, 865, 810, 875, 882, 883, + /* 210 */ 666, 811, 816, 860, 870, 635, 905, 877, 876, 858, + /* 220 */ 871, 829, 873, 885, 889, 894, 903, 908, 902, 904, + /* 230 */ 910, 906, 917, 947, 919, 977, 964, 981, 958, 972, + /* 240 */ 982, 986, 985, 995, 943, 944, 959, 984, 989, 991, + /* 250 */ 1005, 1019, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 10 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 20 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 30 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 40 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 50 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 60 */ 1345, 1345, 1345, 1414, 1345, 1345, 1345, 1345, 1345, 1345, - /* 70 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1412, 1552, - /* 80 */ 1345, 1717, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 90 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 100 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1414, 1345, - /* 110 */ 1728, 1728, 1728, 1412, 1345, 1345, 1345, 1345, 1345, 1345, - /* 120 */ 1507, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1590, - /* 130 */ 1345, 1345, 1794, 1345, 1596, 1752, 1345, 1345, 1345, 1345, - /* 140 */ 1460, 1744, 1720, 1734, 1721, 1779, 1779, 1779, 1737, 1345, - /* 150 */ 1345, 1345, 1345, 1582, 1345, 1345, 1557, 1554, 1554, 1345, - /* 160 */ 1345, 1345, 1345, 1414, 1345, 1414, 1345, 1414, 1345, 1345, - /* 170 */ 1414, 1414, 1345, 1414, 1345, 1345, 1345, 1345, 1345, 1345, - /* 180 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 190 */ 1412, 1592, 1345, 1412, 1345, 1412, 1345, 1345, 1412, 1345, - /* 200 */ 1759, 1757, 1345, 1759, 1757, 1345, 1345, 1345, 1771, 1767, - /* 210 */ 1750, 1748, 1734, 1345, 1345, 1345, 1785, 1781, 1797, 1785, - /* 220 */ 1781, 1785, 1781, 1345, 1757, 1345, 1345, 1757, 1345, 1565, - /* 230 */ 1345, 1345, 1412, 1345, 1412, 1345, 1476, 1345, 1345, 1412, - /* 240 */ 1345, 1584, 1598, 1574, 1510, 1510, 1510, 1415, 1350, 1345, - /* 250 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 260 */ 1472, 1661, 1770, 1769, 1693, 1692, 1691, 1689, 1660, 1345, - /* 270 */ 1345, 1345, 1345, 1345, 1345, 1654, 1655, 1653, 1652, 1345, - /* 280 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 290 */ 1345, 1345, 1345, 1345, 1718, 1345, 1782, 1786, 1345, 1345, - /* 300 */ 1345, 1638, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 310 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 320 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 330 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 340 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 350 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 360 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 370 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 380 */ 1345, 1345, 1345, 1345, 1379, 1345, 1345, 1345, 1345, 1345, - /* 390 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 400 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 410 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 420 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1441, - /* 430 */ 1440, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 440 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 450 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 460 */ 1345, 1741, 1751, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 470 */ 1345, 1345, 1345, 1638, 1345, 1768, 1345, 1727, 1723, 1345, - /* 480 */ 1345, 1719, 1345, 1345, 1780, 1345, 1345, 1345, 1345, 1345, - /* 490 */ 1345, 1345, 1345, 1345, 1713, 1345, 1686, 1345, 1345, 1345, - /* 500 */ 1345, 1345, 1345, 1345, 1345, 1648, 1345, 1345, 1345, 1345, - /* 510 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1637, 1345, - /* 520 */ 1677, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1504, - /* 530 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 540 */ 1345, 1345, 1489, 1487, 1486, 1485, 1345, 1482, 1345, 1345, - /* 550 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1434, - /* 560 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1425, - /* 570 */ 1345, 1424, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 580 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 590 */ 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, 1345, - /* 600 */ 1345, 1345, 1345, 1345, 1345, + /* 0 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 10 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 20 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 30 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 40 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 50 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 60 */ 1356, 1356, 1356, 1425, 1356, 1356, 1356, 1356, 1356, 1356, + /* 70 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1423, 1564, + /* 80 */ 1356, 1731, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 90 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 100 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1425, 1356, + /* 110 */ 1742, 1742, 1742, 1423, 1356, 1356, 1356, 1356, 1356, 1356, + /* 120 */ 1519, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1603, + /* 130 */ 1356, 1356, 1808, 1356, 1609, 1766, 1356, 1356, 1356, 1356, + /* 140 */ 1472, 1758, 1734, 1748, 1735, 1793, 1793, 1793, 1751, 1356, + /* 150 */ 1356, 1356, 1356, 1595, 1356, 1356, 1569, 1566, 1566, 1356, + /* 160 */ 1356, 1356, 1356, 1425, 1356, 1425, 1356, 1356, 1425, 1356, + /* 170 */ 1425, 1356, 1356, 1425, 1425, 1356, 1425, 1356, 1356, 1356, + /* 180 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 190 */ 1356, 1356, 1356, 1423, 1605, 1356, 1423, 1356, 1423, 1356, + /* 200 */ 1356, 1423, 1356, 1773, 1771, 1356, 1773, 1771, 1356, 1356, + /* 210 */ 1356, 1785, 1781, 1764, 1762, 1748, 1356, 1356, 1356, 1799, + /* 220 */ 1795, 1811, 1799, 1795, 1799, 1795, 1356, 1771, 1356, 1356, + /* 230 */ 1771, 1356, 1577, 1356, 1356, 1423, 1356, 1423, 1356, 1488, + /* 240 */ 1356, 1356, 1423, 1356, 1597, 1611, 1587, 1522, 1522, 1522, + /* 250 */ 1426, 1361, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 260 */ 1356, 1356, 1356, 1484, 1675, 1784, 1783, 1707, 1706, 1705, + /* 270 */ 1703, 1674, 1356, 1356, 1356, 1356, 1356, 1356, 1668, 1669, + /* 280 */ 1667, 1666, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 290 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1732, 1356, 1796, + /* 300 */ 1800, 1356, 1356, 1356, 1651, 1356, 1356, 1356, 1356, 1356, + /* 310 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 320 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 330 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 340 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 350 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 360 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 370 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 380 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1390, 1356, 1356, + /* 390 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 400 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 410 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 420 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 430 */ 1356, 1356, 1356, 1356, 1453, 1452, 1356, 1356, 1356, 1356, + /* 440 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 450 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 460 */ 1356, 1356, 1356, 1356, 1356, 1356, 1755, 1765, 1356, 1356, + /* 470 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1651, 1356, + /* 480 */ 1782, 1356, 1741, 1737, 1356, 1356, 1733, 1356, 1356, 1794, + /* 490 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1727, + /* 500 */ 1356, 1700, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 510 */ 1662, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 520 */ 1356, 1356, 1356, 1650, 1356, 1691, 1356, 1356, 1356, 1356, + /* 530 */ 1356, 1356, 1356, 1356, 1516, 1356, 1356, 1356, 1356, 1356, + /* 540 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1501, 1499, 1498, + /* 550 */ 1497, 1356, 1494, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 560 */ 1356, 1356, 1356, 1356, 1356, 1445, 1356, 1356, 1356, 1356, + /* 570 */ 1356, 1356, 1356, 1356, 1356, 1436, 1356, 1435, 1356, 1356, + /* 580 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 590 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 600 */ 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, 1356, + /* 610 */ 1356, }; /********** End of lemon-generated parsing tables *****************************/ @@ -903,6 +906,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* VGROUPS => nothing */ 0, /* SINGLE_STABLE => nothing */ 0, /* RETENTIONS => nothing */ + 0, /* SCHEMALESS => nothing */ 0, /* NK_COLON => nothing */ 0, /* TABLE => nothing */ 0, /* NK_LP => nothing */ @@ -971,6 +975,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* INTERVAL => nothing */ 0, /* TOPIC => nothing */ 0, /* AS => nothing */ + 0, /* CGROUP => nothing */ 0, /* WITH => nothing */ 0, /* SCHEMA => nothing */ 0, /* DESC => nothing */ @@ -1057,12 +1062,12 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ID => nothing */ - 231, /* NK_BITNOT => ID */ - 231, /* INSERT => ID */ - 231, /* VALUES => ID */ - 231, /* IMPORT => ID */ - 231, /* NK_SEMI => ID */ - 231, /* FILE => ID */ + 233, /* NK_BITNOT => ID */ + 233, /* INSERT => ID */ + 233, /* VALUES => ID */ + 233, /* IMPORT => ID */ + 233, /* NK_SEMI => ID */ + 233, /* FILE => ID */ }; #endif /* YYFALLBACK */ @@ -1228,286 +1233,289 @@ static const char *const yyTokenName[] = { /* 75 */ "VGROUPS", /* 76 */ "SINGLE_STABLE", /* 77 */ "RETENTIONS", - /* 78 */ "NK_COLON", - /* 79 */ "TABLE", - /* 80 */ "NK_LP", - /* 81 */ "NK_RP", - /* 82 */ "STABLE", - /* 83 */ "ADD", - /* 84 */ "COLUMN", - /* 85 */ "MODIFY", - /* 86 */ "RENAME", - /* 87 */ "TAG", - /* 88 */ "SET", - /* 89 */ "NK_EQ", - /* 90 */ "USING", - /* 91 */ "TAGS", - /* 92 */ "COMMENT", - /* 93 */ "BOOL", - /* 94 */ "TINYINT", - /* 95 */ "SMALLINT", - /* 96 */ "INT", - /* 97 */ "INTEGER", - /* 98 */ "BIGINT", - /* 99 */ "FLOAT", - /* 100 */ "DOUBLE", - /* 101 */ "BINARY", - /* 102 */ "TIMESTAMP", - /* 103 */ "NCHAR", - /* 104 */ "UNSIGNED", - /* 105 */ "JSON", - /* 106 */ "VARCHAR", - /* 107 */ "MEDIUMBLOB", - /* 108 */ "BLOB", - /* 109 */ "VARBINARY", - /* 110 */ "DECIMAL", - /* 111 */ "DELAY", - /* 112 */ "FILE_FACTOR", - /* 113 */ "NK_FLOAT", - /* 114 */ "ROLLUP", - /* 115 */ "TTL", - /* 116 */ "SMA", - /* 117 */ "SHOW", - /* 118 */ "DATABASES", - /* 119 */ "TABLES", - /* 120 */ "STABLES", - /* 121 */ "MNODES", - /* 122 */ "MODULES", - /* 123 */ "QNODES", - /* 124 */ "FUNCTIONS", - /* 125 */ "INDEXES", - /* 126 */ "ACCOUNTS", - /* 127 */ "APPS", - /* 128 */ "CONNECTIONS", - /* 129 */ "LICENCE", - /* 130 */ "GRANTS", - /* 131 */ "QUERIES", - /* 132 */ "SCORES", - /* 133 */ "TOPICS", - /* 134 */ "VARIABLES", - /* 135 */ "BNODES", - /* 136 */ "SNODES", - /* 137 */ "CLUSTER", - /* 138 */ "TRANSACTIONS", - /* 139 */ "LIKE", - /* 140 */ "INDEX", - /* 141 */ "FULLTEXT", - /* 142 */ "FUNCTION", - /* 143 */ "INTERVAL", - /* 144 */ "TOPIC", - /* 145 */ "AS", - /* 146 */ "WITH", - /* 147 */ "SCHEMA", - /* 148 */ "DESC", - /* 149 */ "DESCRIBE", - /* 150 */ "RESET", - /* 151 */ "QUERY", - /* 152 */ "CACHE", - /* 153 */ "EXPLAIN", - /* 154 */ "ANALYZE", - /* 155 */ "VERBOSE", - /* 156 */ "NK_BOOL", - /* 157 */ "RATIO", - /* 158 */ "COMPACT", - /* 159 */ "VNODES", - /* 160 */ "IN", - /* 161 */ "OUTPUTTYPE", - /* 162 */ "AGGREGATE", - /* 163 */ "BUFSIZE", - /* 164 */ "STREAM", - /* 165 */ "INTO", - /* 166 */ "TRIGGER", - /* 167 */ "AT_ONCE", - /* 168 */ "WINDOW_CLOSE", - /* 169 */ "WATERMARK", - /* 170 */ "KILL", - /* 171 */ "CONNECTION", - /* 172 */ "TRANSACTION", - /* 173 */ "MERGE", - /* 174 */ "VGROUP", - /* 175 */ "REDISTRIBUTE", - /* 176 */ "SPLIT", - /* 177 */ "SYNCDB", - /* 178 */ "NULL", - /* 179 */ "NK_QUESTION", - /* 180 */ "NK_ARROW", - /* 181 */ "ROWTS", - /* 182 */ "TBNAME", - /* 183 */ "QSTARTTS", - /* 184 */ "QENDTS", - /* 185 */ "WSTARTTS", - /* 186 */ "WENDTS", - /* 187 */ "WDURATION", - /* 188 */ "CAST", - /* 189 */ "NOW", - /* 190 */ "TODAY", - /* 191 */ "TIMEZONE", - /* 192 */ "COUNT", - /* 193 */ "FIRST", - /* 194 */ "LAST", - /* 195 */ "LAST_ROW", - /* 196 */ "BETWEEN", - /* 197 */ "IS", - /* 198 */ "NK_LT", - /* 199 */ "NK_GT", - /* 200 */ "NK_LE", - /* 201 */ "NK_GE", - /* 202 */ "NK_NE", - /* 203 */ "MATCH", - /* 204 */ "NMATCH", - /* 205 */ "CONTAINS", - /* 206 */ "JOIN", - /* 207 */ "INNER", - /* 208 */ "SELECT", - /* 209 */ "DISTINCT", - /* 210 */ "WHERE", - /* 211 */ "PARTITION", - /* 212 */ "BY", - /* 213 */ "SESSION", - /* 214 */ "STATE_WINDOW", - /* 215 */ "SLIDING", - /* 216 */ "FILL", - /* 217 */ "VALUE", - /* 218 */ "NONE", - /* 219 */ "PREV", - /* 220 */ "LINEAR", - /* 221 */ "NEXT", - /* 222 */ "GROUP", - /* 223 */ "HAVING", - /* 224 */ "ORDER", - /* 225 */ "SLIMIT", - /* 226 */ "SOFFSET", - /* 227 */ "LIMIT", - /* 228 */ "OFFSET", - /* 229 */ "ASC", - /* 230 */ "NULLS", - /* 231 */ "ID", - /* 232 */ "NK_BITNOT", - /* 233 */ "INSERT", - /* 234 */ "VALUES", - /* 235 */ "IMPORT", - /* 236 */ "NK_SEMI", - /* 237 */ "FILE", - /* 238 */ "cmd", - /* 239 */ "account_options", - /* 240 */ "alter_account_options", - /* 241 */ "literal", - /* 242 */ "alter_account_option", - /* 243 */ "user_name", - /* 244 */ "privileges", - /* 245 */ "priv_level", - /* 246 */ "priv_type_list", - /* 247 */ "priv_type", - /* 248 */ "db_name", - /* 249 */ "dnode_endpoint", - /* 250 */ "dnode_host_name", - /* 251 */ "not_exists_opt", - /* 252 */ "db_options", - /* 253 */ "exists_opt", - /* 254 */ "alter_db_options", - /* 255 */ "integer_list", - /* 256 */ "variable_list", - /* 257 */ "retention_list", - /* 258 */ "alter_db_option", - /* 259 */ "retention", - /* 260 */ "full_table_name", - /* 261 */ "column_def_list", - /* 262 */ "tags_def_opt", - /* 263 */ "table_options", - /* 264 */ "multi_create_clause", - /* 265 */ "tags_def", - /* 266 */ "multi_drop_clause", - /* 267 */ "alter_table_clause", - /* 268 */ "alter_table_options", - /* 269 */ "column_name", - /* 270 */ "type_name", - /* 271 */ "signed_literal", - /* 272 */ "create_subtable_clause", - /* 273 */ "specific_tags_opt", - /* 274 */ "literal_list", - /* 275 */ "drop_table_clause", - /* 276 */ "col_name_list", - /* 277 */ "table_name", - /* 278 */ "column_def", - /* 279 */ "func_name_list", - /* 280 */ "alter_table_option", - /* 281 */ "col_name", - /* 282 */ "db_name_cond_opt", - /* 283 */ "like_pattern_opt", - /* 284 */ "table_name_cond", - /* 285 */ "from_db_opt", - /* 286 */ "func_name", - /* 287 */ "function_name", - /* 288 */ "index_name", - /* 289 */ "index_options", - /* 290 */ "func_list", - /* 291 */ "duration_literal", - /* 292 */ "sliding_opt", - /* 293 */ "func", - /* 294 */ "expression_list", - /* 295 */ "topic_name", - /* 296 */ "topic_options", - /* 297 */ "query_expression", - /* 298 */ "analyze_opt", - /* 299 */ "explain_options", - /* 300 */ "agg_func_opt", - /* 301 */ "bufsize_opt", - /* 302 */ "stream_name", - /* 303 */ "stream_options", - /* 304 */ "into_opt", - /* 305 */ "dnode_list", - /* 306 */ "signed", - /* 307 */ "literal_func", - /* 308 */ "table_alias", - /* 309 */ "column_alias", - /* 310 */ "expression", - /* 311 */ "pseudo_column", - /* 312 */ "column_reference", - /* 313 */ "function_expression", - /* 314 */ "subquery", - /* 315 */ "star_func", - /* 316 */ "star_func_para_list", - /* 317 */ "noarg_func", - /* 318 */ "other_para_list", - /* 319 */ "star_func_para", - /* 320 */ "predicate", - /* 321 */ "compare_op", - /* 322 */ "in_op", - /* 323 */ "in_predicate_value", - /* 324 */ "boolean_value_expression", - /* 325 */ "boolean_primary", - /* 326 */ "common_expression", - /* 327 */ "from_clause", - /* 328 */ "table_reference_list", - /* 329 */ "table_reference", - /* 330 */ "table_primary", - /* 331 */ "joined_table", - /* 332 */ "alias_opt", - /* 333 */ "parenthesized_joined_table", - /* 334 */ "join_type", - /* 335 */ "search_condition", - /* 336 */ "query_specification", - /* 337 */ "set_quantifier_opt", - /* 338 */ "select_list", - /* 339 */ "where_clause_opt", - /* 340 */ "partition_by_clause_opt", - /* 341 */ "twindow_clause_opt", - /* 342 */ "group_by_clause_opt", - /* 343 */ "having_clause_opt", - /* 344 */ "select_sublist", - /* 345 */ "select_item", - /* 346 */ "fill_opt", - /* 347 */ "fill_mode", - /* 348 */ "group_by_list", - /* 349 */ "query_expression_body", - /* 350 */ "order_by_clause_opt", - /* 351 */ "slimit_clause_opt", - /* 352 */ "limit_clause_opt", - /* 353 */ "query_primary", - /* 354 */ "sort_specification_list", - /* 355 */ "sort_specification", - /* 356 */ "ordering_specification_opt", - /* 357 */ "null_ordering_opt", + /* 78 */ "SCHEMALESS", + /* 79 */ "NK_COLON", + /* 80 */ "TABLE", + /* 81 */ "NK_LP", + /* 82 */ "NK_RP", + /* 83 */ "STABLE", + /* 84 */ "ADD", + /* 85 */ "COLUMN", + /* 86 */ "MODIFY", + /* 87 */ "RENAME", + /* 88 */ "TAG", + /* 89 */ "SET", + /* 90 */ "NK_EQ", + /* 91 */ "USING", + /* 92 */ "TAGS", + /* 93 */ "COMMENT", + /* 94 */ "BOOL", + /* 95 */ "TINYINT", + /* 96 */ "SMALLINT", + /* 97 */ "INT", + /* 98 */ "INTEGER", + /* 99 */ "BIGINT", + /* 100 */ "FLOAT", + /* 101 */ "DOUBLE", + /* 102 */ "BINARY", + /* 103 */ "TIMESTAMP", + /* 104 */ "NCHAR", + /* 105 */ "UNSIGNED", + /* 106 */ "JSON", + /* 107 */ "VARCHAR", + /* 108 */ "MEDIUMBLOB", + /* 109 */ "BLOB", + /* 110 */ "VARBINARY", + /* 111 */ "DECIMAL", + /* 112 */ "DELAY", + /* 113 */ "FILE_FACTOR", + /* 114 */ "NK_FLOAT", + /* 115 */ "ROLLUP", + /* 116 */ "TTL", + /* 117 */ "SMA", + /* 118 */ "SHOW", + /* 119 */ "DATABASES", + /* 120 */ "TABLES", + /* 121 */ "STABLES", + /* 122 */ "MNODES", + /* 123 */ "MODULES", + /* 124 */ "QNODES", + /* 125 */ "FUNCTIONS", + /* 126 */ "INDEXES", + /* 127 */ "ACCOUNTS", + /* 128 */ "APPS", + /* 129 */ "CONNECTIONS", + /* 130 */ "LICENCE", + /* 131 */ "GRANTS", + /* 132 */ "QUERIES", + /* 133 */ "SCORES", + /* 134 */ "TOPICS", + /* 135 */ "VARIABLES", + /* 136 */ "BNODES", + /* 137 */ "SNODES", + /* 138 */ "CLUSTER", + /* 139 */ "TRANSACTIONS", + /* 140 */ "LIKE", + /* 141 */ "INDEX", + /* 142 */ "FULLTEXT", + /* 143 */ "FUNCTION", + /* 144 */ "INTERVAL", + /* 145 */ "TOPIC", + /* 146 */ "AS", + /* 147 */ "CGROUP", + /* 148 */ "WITH", + /* 149 */ "SCHEMA", + /* 150 */ "DESC", + /* 151 */ "DESCRIBE", + /* 152 */ "RESET", + /* 153 */ "QUERY", + /* 154 */ "CACHE", + /* 155 */ "EXPLAIN", + /* 156 */ "ANALYZE", + /* 157 */ "VERBOSE", + /* 158 */ "NK_BOOL", + /* 159 */ "RATIO", + /* 160 */ "COMPACT", + /* 161 */ "VNODES", + /* 162 */ "IN", + /* 163 */ "OUTPUTTYPE", + /* 164 */ "AGGREGATE", + /* 165 */ "BUFSIZE", + /* 166 */ "STREAM", + /* 167 */ "INTO", + /* 168 */ "TRIGGER", + /* 169 */ "AT_ONCE", + /* 170 */ "WINDOW_CLOSE", + /* 171 */ "WATERMARK", + /* 172 */ "KILL", + /* 173 */ "CONNECTION", + /* 174 */ "TRANSACTION", + /* 175 */ "MERGE", + /* 176 */ "VGROUP", + /* 177 */ "REDISTRIBUTE", + /* 178 */ "SPLIT", + /* 179 */ "SYNCDB", + /* 180 */ "NULL", + /* 181 */ "NK_QUESTION", + /* 182 */ "NK_ARROW", + /* 183 */ "ROWTS", + /* 184 */ "TBNAME", + /* 185 */ "QSTARTTS", + /* 186 */ "QENDTS", + /* 187 */ "WSTARTTS", + /* 188 */ "WENDTS", + /* 189 */ "WDURATION", + /* 190 */ "CAST", + /* 191 */ "NOW", + /* 192 */ "TODAY", + /* 193 */ "TIMEZONE", + /* 194 */ "COUNT", + /* 195 */ "FIRST", + /* 196 */ "LAST", + /* 197 */ "LAST_ROW", + /* 198 */ "BETWEEN", + /* 199 */ "IS", + /* 200 */ "NK_LT", + /* 201 */ "NK_GT", + /* 202 */ "NK_LE", + /* 203 */ "NK_GE", + /* 204 */ "NK_NE", + /* 205 */ "MATCH", + /* 206 */ "NMATCH", + /* 207 */ "CONTAINS", + /* 208 */ "JOIN", + /* 209 */ "INNER", + /* 210 */ "SELECT", + /* 211 */ "DISTINCT", + /* 212 */ "WHERE", + /* 213 */ "PARTITION", + /* 214 */ "BY", + /* 215 */ "SESSION", + /* 216 */ "STATE_WINDOW", + /* 217 */ "SLIDING", + /* 218 */ "FILL", + /* 219 */ "VALUE", + /* 220 */ "NONE", + /* 221 */ "PREV", + /* 222 */ "LINEAR", + /* 223 */ "NEXT", + /* 224 */ "GROUP", + /* 225 */ "HAVING", + /* 226 */ "ORDER", + /* 227 */ "SLIMIT", + /* 228 */ "SOFFSET", + /* 229 */ "LIMIT", + /* 230 */ "OFFSET", + /* 231 */ "ASC", + /* 232 */ "NULLS", + /* 233 */ "ID", + /* 234 */ "NK_BITNOT", + /* 235 */ "INSERT", + /* 236 */ "VALUES", + /* 237 */ "IMPORT", + /* 238 */ "NK_SEMI", + /* 239 */ "FILE", + /* 240 */ "cmd", + /* 241 */ "account_options", + /* 242 */ "alter_account_options", + /* 243 */ "literal", + /* 244 */ "alter_account_option", + /* 245 */ "user_name", + /* 246 */ "privileges", + /* 247 */ "priv_level", + /* 248 */ "priv_type_list", + /* 249 */ "priv_type", + /* 250 */ "db_name", + /* 251 */ "dnode_endpoint", + /* 252 */ "dnode_host_name", + /* 253 */ "not_exists_opt", + /* 254 */ "db_options", + /* 255 */ "exists_opt", + /* 256 */ "alter_db_options", + /* 257 */ "integer_list", + /* 258 */ "variable_list", + /* 259 */ "retention_list", + /* 260 */ "alter_db_option", + /* 261 */ "retention", + /* 262 */ "full_table_name", + /* 263 */ "column_def_list", + /* 264 */ "tags_def_opt", + /* 265 */ "table_options", + /* 266 */ "multi_create_clause", + /* 267 */ "tags_def", + /* 268 */ "multi_drop_clause", + /* 269 */ "alter_table_clause", + /* 270 */ "alter_table_options", + /* 271 */ "column_name", + /* 272 */ "type_name", + /* 273 */ "signed_literal", + /* 274 */ "create_subtable_clause", + /* 275 */ "specific_tags_opt", + /* 276 */ "literal_list", + /* 277 */ "drop_table_clause", + /* 278 */ "col_name_list", + /* 279 */ "table_name", + /* 280 */ "column_def", + /* 281 */ "func_name_list", + /* 282 */ "alter_table_option", + /* 283 */ "col_name", + /* 284 */ "db_name_cond_opt", + /* 285 */ "like_pattern_opt", + /* 286 */ "table_name_cond", + /* 287 */ "from_db_opt", + /* 288 */ "func_name", + /* 289 */ "function_name", + /* 290 */ "index_name", + /* 291 */ "index_options", + /* 292 */ "func_list", + /* 293 */ "duration_literal", + /* 294 */ "sliding_opt", + /* 295 */ "func", + /* 296 */ "expression_list", + /* 297 */ "topic_name", + /* 298 */ "topic_options", + /* 299 */ "query_expression", + /* 300 */ "cgroup_name", + /* 301 */ "analyze_opt", + /* 302 */ "explain_options", + /* 303 */ "agg_func_opt", + /* 304 */ "bufsize_opt", + /* 305 */ "stream_name", + /* 306 */ "stream_options", + /* 307 */ "into_opt", + /* 308 */ "dnode_list", + /* 309 */ "signed", + /* 310 */ "literal_func", + /* 311 */ "table_alias", + /* 312 */ "column_alias", + /* 313 */ "expression", + /* 314 */ "pseudo_column", + /* 315 */ "column_reference", + /* 316 */ "function_expression", + /* 317 */ "subquery", + /* 318 */ "star_func", + /* 319 */ "star_func_para_list", + /* 320 */ "noarg_func", + /* 321 */ "other_para_list", + /* 322 */ "star_func_para", + /* 323 */ "predicate", + /* 324 */ "compare_op", + /* 325 */ "in_op", + /* 326 */ "in_predicate_value", + /* 327 */ "boolean_value_expression", + /* 328 */ "boolean_primary", + /* 329 */ "common_expression", + /* 330 */ "from_clause", + /* 331 */ "table_reference_list", + /* 332 */ "table_reference", + /* 333 */ "table_primary", + /* 334 */ "joined_table", + /* 335 */ "alias_opt", + /* 336 */ "parenthesized_joined_table", + /* 337 */ "join_type", + /* 338 */ "search_condition", + /* 339 */ "query_specification", + /* 340 */ "set_quantifier_opt", + /* 341 */ "select_list", + /* 342 */ "where_clause_opt", + /* 343 */ "partition_by_clause_opt", + /* 344 */ "twindow_clause_opt", + /* 345 */ "group_by_clause_opt", + /* 346 */ "having_clause_opt", + /* 347 */ "select_sublist", + /* 348 */ "select_item", + /* 349 */ "fill_opt", + /* 350 */ "fill_mode", + /* 351 */ "group_by_list", + /* 352 */ "query_expression_body", + /* 353 */ "order_by_clause_opt", + /* 354 */ "slimit_clause_opt", + /* 355 */ "limit_clause_opt", + /* 356 */ "query_primary", + /* 357 */ "sort_specification_list", + /* 358 */ "sort_specification", + /* 359 */ "ordering_specification_opt", + /* 360 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1602,371 +1610,374 @@ static const char *const yyRuleName[] = { /* 84 */ "db_options ::= db_options VGROUPS NK_INTEGER", /* 85 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", /* 86 */ "db_options ::= db_options RETENTIONS retention_list", - /* 87 */ "alter_db_options ::= alter_db_option", - /* 88 */ "alter_db_options ::= alter_db_options alter_db_option", - /* 89 */ "alter_db_option ::= BUFFER NK_INTEGER", - /* 90 */ "alter_db_option ::= CACHELAST NK_INTEGER", - /* 91 */ "alter_db_option ::= FSYNC NK_INTEGER", - /* 92 */ "alter_db_option ::= KEEP integer_list", - /* 93 */ "alter_db_option ::= KEEP variable_list", - /* 94 */ "alter_db_option ::= PAGES NK_INTEGER", - /* 95 */ "alter_db_option ::= REPLICA NK_INTEGER", - /* 96 */ "alter_db_option ::= STRICT NK_INTEGER", - /* 97 */ "alter_db_option ::= WAL NK_INTEGER", - /* 98 */ "integer_list ::= NK_INTEGER", - /* 99 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER", - /* 100 */ "variable_list ::= NK_VARIABLE", - /* 101 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE", - /* 102 */ "retention_list ::= retention", - /* 103 */ "retention_list ::= retention_list NK_COMMA retention", - /* 104 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE", - /* 105 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", - /* 106 */ "cmd ::= CREATE TABLE multi_create_clause", - /* 107 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", - /* 108 */ "cmd ::= DROP TABLE multi_drop_clause", - /* 109 */ "cmd ::= DROP STABLE exists_opt full_table_name", - /* 110 */ "cmd ::= ALTER TABLE alter_table_clause", - /* 111 */ "cmd ::= ALTER STABLE alter_table_clause", - /* 112 */ "alter_table_clause ::= full_table_name alter_table_options", - /* 113 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", - /* 114 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", - /* 115 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", - /* 116 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", - /* 117 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", - /* 118 */ "alter_table_clause ::= full_table_name DROP TAG column_name", - /* 119 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", - /* 120 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", - /* 121 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", - /* 122 */ "multi_create_clause ::= create_subtable_clause", - /* 123 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 124 */ "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", - /* 125 */ "multi_drop_clause ::= drop_table_clause", - /* 126 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", - /* 127 */ "drop_table_clause ::= exists_opt full_table_name", - /* 128 */ "specific_tags_opt ::=", - /* 129 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", - /* 130 */ "full_table_name ::= table_name", - /* 131 */ "full_table_name ::= db_name NK_DOT table_name", - /* 132 */ "column_def_list ::= column_def", - /* 133 */ "column_def_list ::= column_def_list NK_COMMA column_def", - /* 134 */ "column_def ::= column_name type_name", - /* 135 */ "column_def ::= column_name type_name COMMENT NK_STRING", - /* 136 */ "type_name ::= BOOL", - /* 137 */ "type_name ::= TINYINT", - /* 138 */ "type_name ::= SMALLINT", - /* 139 */ "type_name ::= INT", - /* 140 */ "type_name ::= INTEGER", - /* 141 */ "type_name ::= BIGINT", - /* 142 */ "type_name ::= FLOAT", - /* 143 */ "type_name ::= DOUBLE", - /* 144 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 145 */ "type_name ::= TIMESTAMP", - /* 146 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 147 */ "type_name ::= TINYINT UNSIGNED", - /* 148 */ "type_name ::= SMALLINT UNSIGNED", - /* 149 */ "type_name ::= INT UNSIGNED", - /* 150 */ "type_name ::= BIGINT UNSIGNED", - /* 151 */ "type_name ::= JSON", - /* 152 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 153 */ "type_name ::= MEDIUMBLOB", - /* 154 */ "type_name ::= BLOB", - /* 155 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 156 */ "type_name ::= DECIMAL", - /* 157 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 158 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 159 */ "tags_def_opt ::=", - /* 160 */ "tags_def_opt ::= tags_def", - /* 161 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", - /* 162 */ "table_options ::=", - /* 163 */ "table_options ::= table_options COMMENT NK_STRING", - /* 164 */ "table_options ::= table_options DELAY NK_INTEGER", - /* 165 */ "table_options ::= table_options FILE_FACTOR NK_FLOAT", - /* 166 */ "table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP", - /* 167 */ "table_options ::= table_options TTL NK_INTEGER", - /* 168 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 169 */ "alter_table_options ::= alter_table_option", - /* 170 */ "alter_table_options ::= alter_table_options alter_table_option", - /* 171 */ "alter_table_option ::= COMMENT NK_STRING", - /* 172 */ "alter_table_option ::= TTL NK_INTEGER", - /* 173 */ "col_name_list ::= col_name", - /* 174 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 175 */ "col_name ::= column_name", - /* 176 */ "cmd ::= SHOW DNODES", - /* 177 */ "cmd ::= SHOW USERS", - /* 178 */ "cmd ::= SHOW DATABASES", - /* 179 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", - /* 180 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", - /* 181 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", - /* 182 */ "cmd ::= SHOW MNODES", - /* 183 */ "cmd ::= SHOW MODULES", - /* 184 */ "cmd ::= SHOW QNODES", - /* 185 */ "cmd ::= SHOW FUNCTIONS", - /* 186 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", - /* 187 */ "cmd ::= SHOW STREAMS", - /* 188 */ "cmd ::= SHOW ACCOUNTS", - /* 189 */ "cmd ::= SHOW APPS", - /* 190 */ "cmd ::= SHOW CONNECTIONS", - /* 191 */ "cmd ::= SHOW LICENCE", - /* 192 */ "cmd ::= SHOW GRANTS", - /* 193 */ "cmd ::= SHOW CREATE DATABASE db_name", - /* 194 */ "cmd ::= SHOW CREATE TABLE full_table_name", - /* 195 */ "cmd ::= SHOW CREATE STABLE full_table_name", - /* 196 */ "cmd ::= SHOW QUERIES", - /* 197 */ "cmd ::= SHOW SCORES", - /* 198 */ "cmd ::= SHOW TOPICS", - /* 199 */ "cmd ::= SHOW VARIABLES", - /* 200 */ "cmd ::= SHOW BNODES", - /* 201 */ "cmd ::= SHOW SNODES", - /* 202 */ "cmd ::= SHOW CLUSTER", - /* 203 */ "cmd ::= SHOW TRANSACTIONS", - /* 204 */ "db_name_cond_opt ::=", - /* 205 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 206 */ "like_pattern_opt ::=", - /* 207 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 208 */ "table_name_cond ::= table_name", - /* 209 */ "from_db_opt ::=", - /* 210 */ "from_db_opt ::= FROM db_name", - /* 211 */ "func_name_list ::= func_name", - /* 212 */ "func_name_list ::= func_name_list NK_COMMA func_name", - /* 213 */ "func_name ::= function_name", - /* 214 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options", - /* 215 */ "cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP", - /* 216 */ "cmd ::= DROP INDEX exists_opt index_name ON table_name", - /* 217 */ "index_options ::=", - /* 218 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", - /* 219 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", - /* 220 */ "func_list ::= func", - /* 221 */ "func_list ::= func_list NK_COMMA func", - /* 222 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 223 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name topic_options AS query_expression", - /* 224 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name topic_options AS db_name", - /* 225 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 226 */ "topic_options ::=", - /* 227 */ "topic_options ::= topic_options WITH TABLE", - /* 228 */ "topic_options ::= topic_options WITH SCHEMA", - /* 229 */ "topic_options ::= topic_options WITH TAG", - /* 230 */ "cmd ::= DESC full_table_name", - /* 231 */ "cmd ::= DESCRIBE full_table_name", - /* 232 */ "cmd ::= RESET QUERY CACHE", - /* 233 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", - /* 234 */ "analyze_opt ::=", - /* 235 */ "analyze_opt ::= ANALYZE", - /* 236 */ "explain_options ::=", - /* 237 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 238 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 239 */ "cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP", - /* 240 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", - /* 241 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 242 */ "agg_func_opt ::=", - /* 243 */ "agg_func_opt ::= AGGREGATE", - /* 244 */ "bufsize_opt ::=", - /* 245 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 246 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression", - /* 247 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 248 */ "into_opt ::=", - /* 249 */ "into_opt ::= INTO full_table_name", - /* 250 */ "stream_options ::=", - /* 251 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 252 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 253 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 254 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 255 */ "cmd ::= KILL QUERY NK_INTEGER", - /* 256 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 257 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 258 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 259 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 260 */ "dnode_list ::= DNODE NK_INTEGER", - /* 261 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 262 */ "cmd ::= SYNCDB db_name REPLICA", - /* 263 */ "cmd ::= query_expression", - /* 264 */ "literal ::= NK_INTEGER", - /* 265 */ "literal ::= NK_FLOAT", - /* 266 */ "literal ::= NK_STRING", - /* 267 */ "literal ::= NK_BOOL", - /* 268 */ "literal ::= TIMESTAMP NK_STRING", - /* 269 */ "literal ::= duration_literal", - /* 270 */ "literal ::= NULL", - /* 271 */ "literal ::= NK_QUESTION", - /* 272 */ "duration_literal ::= NK_VARIABLE", - /* 273 */ "signed ::= NK_INTEGER", - /* 274 */ "signed ::= NK_PLUS NK_INTEGER", - /* 275 */ "signed ::= NK_MINUS NK_INTEGER", - /* 276 */ "signed ::= NK_FLOAT", - /* 277 */ "signed ::= NK_PLUS NK_FLOAT", - /* 278 */ "signed ::= NK_MINUS NK_FLOAT", - /* 279 */ "signed_literal ::= signed", - /* 280 */ "signed_literal ::= NK_STRING", - /* 281 */ "signed_literal ::= NK_BOOL", - /* 282 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 283 */ "signed_literal ::= duration_literal", - /* 284 */ "signed_literal ::= NULL", - /* 285 */ "signed_literal ::= literal_func", - /* 286 */ "literal_list ::= signed_literal", - /* 287 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 288 */ "db_name ::= NK_ID", - /* 289 */ "table_name ::= NK_ID", - /* 290 */ "column_name ::= NK_ID", - /* 291 */ "function_name ::= NK_ID", - /* 292 */ "table_alias ::= NK_ID", - /* 293 */ "column_alias ::= NK_ID", - /* 294 */ "user_name ::= NK_ID", - /* 295 */ "index_name ::= NK_ID", - /* 296 */ "topic_name ::= NK_ID", - /* 297 */ "stream_name ::= NK_ID", - /* 298 */ "expression ::= literal", - /* 299 */ "expression ::= pseudo_column", - /* 300 */ "expression ::= column_reference", - /* 301 */ "expression ::= function_expression", - /* 302 */ "expression ::= subquery", - /* 303 */ "expression ::= NK_LP expression NK_RP", - /* 304 */ "expression ::= NK_PLUS expression", - /* 305 */ "expression ::= NK_MINUS expression", - /* 306 */ "expression ::= expression NK_PLUS expression", - /* 307 */ "expression ::= expression NK_MINUS expression", - /* 308 */ "expression ::= expression NK_STAR expression", - /* 309 */ "expression ::= expression NK_SLASH expression", - /* 310 */ "expression ::= expression NK_REM expression", - /* 311 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 312 */ "expression_list ::= expression", - /* 313 */ "expression_list ::= expression_list NK_COMMA expression", - /* 314 */ "column_reference ::= column_name", - /* 315 */ "column_reference ::= table_name NK_DOT column_name", - /* 316 */ "pseudo_column ::= ROWTS", - /* 317 */ "pseudo_column ::= TBNAME", - /* 318 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 319 */ "pseudo_column ::= QSTARTTS", - /* 320 */ "pseudo_column ::= QENDTS", - /* 321 */ "pseudo_column ::= WSTARTTS", - /* 322 */ "pseudo_column ::= WENDTS", - /* 323 */ "pseudo_column ::= WDURATION", - /* 324 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 325 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 326 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP", - /* 327 */ "function_expression ::= literal_func", - /* 328 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 329 */ "literal_func ::= NOW", - /* 330 */ "noarg_func ::= NOW", - /* 331 */ "noarg_func ::= TODAY", - /* 332 */ "noarg_func ::= TIMEZONE", - /* 333 */ "star_func ::= COUNT", - /* 334 */ "star_func ::= FIRST", - /* 335 */ "star_func ::= LAST", - /* 336 */ "star_func ::= LAST_ROW", - /* 337 */ "star_func_para_list ::= NK_STAR", - /* 338 */ "star_func_para_list ::= other_para_list", - /* 339 */ "other_para_list ::= star_func_para", - /* 340 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 341 */ "star_func_para ::= expression", - /* 342 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 343 */ "predicate ::= expression compare_op expression", - /* 344 */ "predicate ::= expression BETWEEN expression AND expression", - /* 345 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 346 */ "predicate ::= expression IS NULL", - /* 347 */ "predicate ::= expression IS NOT NULL", - /* 348 */ "predicate ::= expression in_op in_predicate_value", - /* 349 */ "compare_op ::= NK_LT", - /* 350 */ "compare_op ::= NK_GT", - /* 351 */ "compare_op ::= NK_LE", - /* 352 */ "compare_op ::= NK_GE", - /* 353 */ "compare_op ::= NK_NE", - /* 354 */ "compare_op ::= NK_EQ", - /* 355 */ "compare_op ::= LIKE", - /* 356 */ "compare_op ::= NOT LIKE", - /* 357 */ "compare_op ::= MATCH", - /* 358 */ "compare_op ::= NMATCH", - /* 359 */ "compare_op ::= CONTAINS", - /* 360 */ "in_op ::= IN", - /* 361 */ "in_op ::= NOT IN", - /* 362 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 363 */ "boolean_value_expression ::= boolean_primary", - /* 364 */ "boolean_value_expression ::= NOT boolean_primary", - /* 365 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 366 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 367 */ "boolean_primary ::= predicate", - /* 368 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 369 */ "common_expression ::= expression", - /* 370 */ "common_expression ::= boolean_value_expression", - /* 371 */ "from_clause ::= FROM table_reference_list", - /* 372 */ "table_reference_list ::= table_reference", - /* 373 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 374 */ "table_reference ::= table_primary", - /* 375 */ "table_reference ::= joined_table", - /* 376 */ "table_primary ::= table_name alias_opt", - /* 377 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 378 */ "table_primary ::= subquery alias_opt", - /* 379 */ "table_primary ::= parenthesized_joined_table", - /* 380 */ "alias_opt ::=", - /* 381 */ "alias_opt ::= table_alias", - /* 382 */ "alias_opt ::= AS table_alias", - /* 383 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 384 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 385 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 386 */ "join_type ::=", - /* 387 */ "join_type ::= INNER", - /* 388 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 389 */ "set_quantifier_opt ::=", - /* 390 */ "set_quantifier_opt ::= DISTINCT", - /* 391 */ "set_quantifier_opt ::= ALL", - /* 392 */ "select_list ::= NK_STAR", - /* 393 */ "select_list ::= select_sublist", - /* 394 */ "select_sublist ::= select_item", - /* 395 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 396 */ "select_item ::= common_expression", - /* 397 */ "select_item ::= common_expression column_alias", - /* 398 */ "select_item ::= common_expression AS column_alias", - /* 399 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 400 */ "where_clause_opt ::=", - /* 401 */ "where_clause_opt ::= WHERE search_condition", - /* 402 */ "partition_by_clause_opt ::=", - /* 403 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 404 */ "twindow_clause_opt ::=", - /* 405 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 406 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", - /* 407 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 408 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 409 */ "sliding_opt ::=", - /* 410 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 411 */ "fill_opt ::=", - /* 412 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 413 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 414 */ "fill_mode ::= NONE", - /* 415 */ "fill_mode ::= PREV", - /* 416 */ "fill_mode ::= NULL", - /* 417 */ "fill_mode ::= LINEAR", - /* 418 */ "fill_mode ::= NEXT", - /* 419 */ "group_by_clause_opt ::=", - /* 420 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 421 */ "group_by_list ::= expression", - /* 422 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 423 */ "having_clause_opt ::=", - /* 424 */ "having_clause_opt ::= HAVING search_condition", - /* 425 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 426 */ "query_expression_body ::= query_primary", - /* 427 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 428 */ "query_expression_body ::= query_expression_body UNION query_expression_body", - /* 429 */ "query_primary ::= query_specification", - /* 430 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", - /* 431 */ "order_by_clause_opt ::=", - /* 432 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 433 */ "slimit_clause_opt ::=", - /* 434 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 435 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 436 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 437 */ "limit_clause_opt ::=", - /* 438 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 439 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 440 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 441 */ "subquery ::= NK_LP query_expression NK_RP", - /* 442 */ "search_condition ::= common_expression", - /* 443 */ "sort_specification_list ::= sort_specification", - /* 444 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 445 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 446 */ "ordering_specification_opt ::=", - /* 447 */ "ordering_specification_opt ::= ASC", - /* 448 */ "ordering_specification_opt ::= DESC", - /* 449 */ "null_ordering_opt ::=", - /* 450 */ "null_ordering_opt ::= NULLS FIRST", - /* 451 */ "null_ordering_opt ::= NULLS LAST", + /* 87 */ "db_options ::= db_options SCHEMALESS NK_INTEGER", + /* 88 */ "alter_db_options ::= alter_db_option", + /* 89 */ "alter_db_options ::= alter_db_options alter_db_option", + /* 90 */ "alter_db_option ::= BUFFER NK_INTEGER", + /* 91 */ "alter_db_option ::= CACHELAST NK_INTEGER", + /* 92 */ "alter_db_option ::= FSYNC NK_INTEGER", + /* 93 */ "alter_db_option ::= KEEP integer_list", + /* 94 */ "alter_db_option ::= KEEP variable_list", + /* 95 */ "alter_db_option ::= PAGES NK_INTEGER", + /* 96 */ "alter_db_option ::= REPLICA NK_INTEGER", + /* 97 */ "alter_db_option ::= STRICT NK_INTEGER", + /* 98 */ "alter_db_option ::= WAL NK_INTEGER", + /* 99 */ "integer_list ::= NK_INTEGER", + /* 100 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER", + /* 101 */ "variable_list ::= NK_VARIABLE", + /* 102 */ "variable_list ::= variable_list NK_COMMA NK_VARIABLE", + /* 103 */ "retention_list ::= retention", + /* 104 */ "retention_list ::= retention_list NK_COMMA retention", + /* 105 */ "retention ::= NK_VARIABLE NK_COLON NK_VARIABLE", + /* 106 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", + /* 107 */ "cmd ::= CREATE TABLE multi_create_clause", + /* 108 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", + /* 109 */ "cmd ::= DROP TABLE multi_drop_clause", + /* 110 */ "cmd ::= DROP STABLE exists_opt full_table_name", + /* 111 */ "cmd ::= ALTER TABLE alter_table_clause", + /* 112 */ "cmd ::= ALTER STABLE alter_table_clause", + /* 113 */ "alter_table_clause ::= full_table_name alter_table_options", + /* 114 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", + /* 115 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", + /* 116 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", + /* 117 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", + /* 118 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", + /* 119 */ "alter_table_clause ::= full_table_name DROP TAG column_name", + /* 120 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", + /* 121 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", + /* 122 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal", + /* 123 */ "multi_create_clause ::= create_subtable_clause", + /* 124 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", + /* 125 */ "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", + /* 126 */ "multi_drop_clause ::= drop_table_clause", + /* 127 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", + /* 128 */ "drop_table_clause ::= exists_opt full_table_name", + /* 129 */ "specific_tags_opt ::=", + /* 130 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", + /* 131 */ "full_table_name ::= table_name", + /* 132 */ "full_table_name ::= db_name NK_DOT table_name", + /* 133 */ "column_def_list ::= column_def", + /* 134 */ "column_def_list ::= column_def_list NK_COMMA column_def", + /* 135 */ "column_def ::= column_name type_name", + /* 136 */ "column_def ::= column_name type_name COMMENT NK_STRING", + /* 137 */ "type_name ::= BOOL", + /* 138 */ "type_name ::= TINYINT", + /* 139 */ "type_name ::= SMALLINT", + /* 140 */ "type_name ::= INT", + /* 141 */ "type_name ::= INTEGER", + /* 142 */ "type_name ::= BIGINT", + /* 143 */ "type_name ::= FLOAT", + /* 144 */ "type_name ::= DOUBLE", + /* 145 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", + /* 146 */ "type_name ::= TIMESTAMP", + /* 147 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", + /* 148 */ "type_name ::= TINYINT UNSIGNED", + /* 149 */ "type_name ::= SMALLINT UNSIGNED", + /* 150 */ "type_name ::= INT UNSIGNED", + /* 151 */ "type_name ::= BIGINT UNSIGNED", + /* 152 */ "type_name ::= JSON", + /* 153 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", + /* 154 */ "type_name ::= MEDIUMBLOB", + /* 155 */ "type_name ::= BLOB", + /* 156 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", + /* 157 */ "type_name ::= DECIMAL", + /* 158 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", + /* 159 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 160 */ "tags_def_opt ::=", + /* 161 */ "tags_def_opt ::= tags_def", + /* 162 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", + /* 163 */ "table_options ::=", + /* 164 */ "table_options ::= table_options COMMENT NK_STRING", + /* 165 */ "table_options ::= table_options DELAY NK_INTEGER", + /* 166 */ "table_options ::= table_options FILE_FACTOR NK_FLOAT", + /* 167 */ "table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP", + /* 168 */ "table_options ::= table_options TTL NK_INTEGER", + /* 169 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 170 */ "alter_table_options ::= alter_table_option", + /* 171 */ "alter_table_options ::= alter_table_options alter_table_option", + /* 172 */ "alter_table_option ::= COMMENT NK_STRING", + /* 173 */ "alter_table_option ::= TTL NK_INTEGER", + /* 174 */ "col_name_list ::= col_name", + /* 175 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 176 */ "col_name ::= column_name", + /* 177 */ "cmd ::= SHOW DNODES", + /* 178 */ "cmd ::= SHOW USERS", + /* 179 */ "cmd ::= SHOW DATABASES", + /* 180 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", + /* 181 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", + /* 182 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", + /* 183 */ "cmd ::= SHOW MNODES", + /* 184 */ "cmd ::= SHOW MODULES", + /* 185 */ "cmd ::= SHOW QNODES", + /* 186 */ "cmd ::= SHOW FUNCTIONS", + /* 187 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", + /* 188 */ "cmd ::= SHOW STREAMS", + /* 189 */ "cmd ::= SHOW ACCOUNTS", + /* 190 */ "cmd ::= SHOW APPS", + /* 191 */ "cmd ::= SHOW CONNECTIONS", + /* 192 */ "cmd ::= SHOW LICENCE", + /* 193 */ "cmd ::= SHOW GRANTS", + /* 194 */ "cmd ::= SHOW CREATE DATABASE db_name", + /* 195 */ "cmd ::= SHOW CREATE TABLE full_table_name", + /* 196 */ "cmd ::= SHOW CREATE STABLE full_table_name", + /* 197 */ "cmd ::= SHOW QUERIES", + /* 198 */ "cmd ::= SHOW SCORES", + /* 199 */ "cmd ::= SHOW TOPICS", + /* 200 */ "cmd ::= SHOW VARIABLES", + /* 201 */ "cmd ::= SHOW BNODES", + /* 202 */ "cmd ::= SHOW SNODES", + /* 203 */ "cmd ::= SHOW CLUSTER", + /* 204 */ "cmd ::= SHOW TRANSACTIONS", + /* 205 */ "db_name_cond_opt ::=", + /* 206 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 207 */ "like_pattern_opt ::=", + /* 208 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 209 */ "table_name_cond ::= table_name", + /* 210 */ "from_db_opt ::=", + /* 211 */ "from_db_opt ::= FROM db_name", + /* 212 */ "func_name_list ::= func_name", + /* 213 */ "func_name_list ::= func_name_list NK_COMMA func_name", + /* 214 */ "func_name ::= function_name", + /* 215 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options", + /* 216 */ "cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP", + /* 217 */ "cmd ::= DROP INDEX exists_opt index_name ON table_name", + /* 218 */ "index_options ::=", + /* 219 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", + /* 220 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", + /* 221 */ "func_list ::= func", + /* 222 */ "func_list ::= func_list NK_COMMA func", + /* 223 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 224 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name topic_options AS query_expression", + /* 225 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name topic_options AS db_name", + /* 226 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 227 */ "cmd ::= DROP CGROUP exists_opt cgroup_name ON topic_name", + /* 228 */ "topic_options ::=", + /* 229 */ "topic_options ::= topic_options WITH TABLE", + /* 230 */ "topic_options ::= topic_options WITH SCHEMA", + /* 231 */ "topic_options ::= topic_options WITH TAG", + /* 232 */ "cmd ::= DESC full_table_name", + /* 233 */ "cmd ::= DESCRIBE full_table_name", + /* 234 */ "cmd ::= RESET QUERY CACHE", + /* 235 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", + /* 236 */ "analyze_opt ::=", + /* 237 */ "analyze_opt ::= ANALYZE", + /* 238 */ "explain_options ::=", + /* 239 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 240 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 241 */ "cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP", + /* 242 */ "cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", + /* 243 */ "cmd ::= DROP FUNCTION exists_opt function_name", + /* 244 */ "agg_func_opt ::=", + /* 245 */ "agg_func_opt ::= AGGREGATE", + /* 246 */ "bufsize_opt ::=", + /* 247 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 248 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression", + /* 249 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 250 */ "into_opt ::=", + /* 251 */ "into_opt ::= INTO full_table_name", + /* 252 */ "stream_options ::=", + /* 253 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 254 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 255 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 256 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 257 */ "cmd ::= KILL QUERY NK_INTEGER", + /* 258 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 259 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 260 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 261 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 262 */ "dnode_list ::= DNODE NK_INTEGER", + /* 263 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 264 */ "cmd ::= SYNCDB db_name REPLICA", + /* 265 */ "cmd ::= query_expression", + /* 266 */ "literal ::= NK_INTEGER", + /* 267 */ "literal ::= NK_FLOAT", + /* 268 */ "literal ::= NK_STRING", + /* 269 */ "literal ::= NK_BOOL", + /* 270 */ "literal ::= TIMESTAMP NK_STRING", + /* 271 */ "literal ::= duration_literal", + /* 272 */ "literal ::= NULL", + /* 273 */ "literal ::= NK_QUESTION", + /* 274 */ "duration_literal ::= NK_VARIABLE", + /* 275 */ "signed ::= NK_INTEGER", + /* 276 */ "signed ::= NK_PLUS NK_INTEGER", + /* 277 */ "signed ::= NK_MINUS NK_INTEGER", + /* 278 */ "signed ::= NK_FLOAT", + /* 279 */ "signed ::= NK_PLUS NK_FLOAT", + /* 280 */ "signed ::= NK_MINUS NK_FLOAT", + /* 281 */ "signed_literal ::= signed", + /* 282 */ "signed_literal ::= NK_STRING", + /* 283 */ "signed_literal ::= NK_BOOL", + /* 284 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 285 */ "signed_literal ::= duration_literal", + /* 286 */ "signed_literal ::= NULL", + /* 287 */ "signed_literal ::= literal_func", + /* 288 */ "literal_list ::= signed_literal", + /* 289 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 290 */ "db_name ::= NK_ID", + /* 291 */ "table_name ::= NK_ID", + /* 292 */ "column_name ::= NK_ID", + /* 293 */ "function_name ::= NK_ID", + /* 294 */ "table_alias ::= NK_ID", + /* 295 */ "column_alias ::= NK_ID", + /* 296 */ "user_name ::= NK_ID", + /* 297 */ "index_name ::= NK_ID", + /* 298 */ "topic_name ::= NK_ID", + /* 299 */ "stream_name ::= NK_ID", + /* 300 */ "cgroup_name ::= NK_ID", + /* 301 */ "expression ::= literal", + /* 302 */ "expression ::= pseudo_column", + /* 303 */ "expression ::= column_reference", + /* 304 */ "expression ::= function_expression", + /* 305 */ "expression ::= subquery", + /* 306 */ "expression ::= NK_LP expression NK_RP", + /* 307 */ "expression ::= NK_PLUS expression", + /* 308 */ "expression ::= NK_MINUS expression", + /* 309 */ "expression ::= expression NK_PLUS expression", + /* 310 */ "expression ::= expression NK_MINUS expression", + /* 311 */ "expression ::= expression NK_STAR expression", + /* 312 */ "expression ::= expression NK_SLASH expression", + /* 313 */ "expression ::= expression NK_REM expression", + /* 314 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 315 */ "expression_list ::= expression", + /* 316 */ "expression_list ::= expression_list NK_COMMA expression", + /* 317 */ "column_reference ::= column_name", + /* 318 */ "column_reference ::= table_name NK_DOT column_name", + /* 319 */ "pseudo_column ::= ROWTS", + /* 320 */ "pseudo_column ::= TBNAME", + /* 321 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 322 */ "pseudo_column ::= QSTARTTS", + /* 323 */ "pseudo_column ::= QENDTS", + /* 324 */ "pseudo_column ::= WSTARTTS", + /* 325 */ "pseudo_column ::= WENDTS", + /* 326 */ "pseudo_column ::= WDURATION", + /* 327 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 328 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 329 */ "function_expression ::= CAST NK_LP expression AS type_name NK_RP", + /* 330 */ "function_expression ::= literal_func", + /* 331 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 332 */ "literal_func ::= NOW", + /* 333 */ "noarg_func ::= NOW", + /* 334 */ "noarg_func ::= TODAY", + /* 335 */ "noarg_func ::= TIMEZONE", + /* 336 */ "star_func ::= COUNT", + /* 337 */ "star_func ::= FIRST", + /* 338 */ "star_func ::= LAST", + /* 339 */ "star_func ::= LAST_ROW", + /* 340 */ "star_func_para_list ::= NK_STAR", + /* 341 */ "star_func_para_list ::= other_para_list", + /* 342 */ "other_para_list ::= star_func_para", + /* 343 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 344 */ "star_func_para ::= expression", + /* 345 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 346 */ "predicate ::= expression compare_op expression", + /* 347 */ "predicate ::= expression BETWEEN expression AND expression", + /* 348 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 349 */ "predicate ::= expression IS NULL", + /* 350 */ "predicate ::= expression IS NOT NULL", + /* 351 */ "predicate ::= expression in_op in_predicate_value", + /* 352 */ "compare_op ::= NK_LT", + /* 353 */ "compare_op ::= NK_GT", + /* 354 */ "compare_op ::= NK_LE", + /* 355 */ "compare_op ::= NK_GE", + /* 356 */ "compare_op ::= NK_NE", + /* 357 */ "compare_op ::= NK_EQ", + /* 358 */ "compare_op ::= LIKE", + /* 359 */ "compare_op ::= NOT LIKE", + /* 360 */ "compare_op ::= MATCH", + /* 361 */ "compare_op ::= NMATCH", + /* 362 */ "compare_op ::= CONTAINS", + /* 363 */ "in_op ::= IN", + /* 364 */ "in_op ::= NOT IN", + /* 365 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 366 */ "boolean_value_expression ::= boolean_primary", + /* 367 */ "boolean_value_expression ::= NOT boolean_primary", + /* 368 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 369 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 370 */ "boolean_primary ::= predicate", + /* 371 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 372 */ "common_expression ::= expression", + /* 373 */ "common_expression ::= boolean_value_expression", + /* 374 */ "from_clause ::= FROM table_reference_list", + /* 375 */ "table_reference_list ::= table_reference", + /* 376 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 377 */ "table_reference ::= table_primary", + /* 378 */ "table_reference ::= joined_table", + /* 379 */ "table_primary ::= table_name alias_opt", + /* 380 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 381 */ "table_primary ::= subquery alias_opt", + /* 382 */ "table_primary ::= parenthesized_joined_table", + /* 383 */ "alias_opt ::=", + /* 384 */ "alias_opt ::= table_alias", + /* 385 */ "alias_opt ::= AS table_alias", + /* 386 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 387 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 388 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 389 */ "join_type ::=", + /* 390 */ "join_type ::= INNER", + /* 391 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 392 */ "set_quantifier_opt ::=", + /* 393 */ "set_quantifier_opt ::= DISTINCT", + /* 394 */ "set_quantifier_opt ::= ALL", + /* 395 */ "select_list ::= NK_STAR", + /* 396 */ "select_list ::= select_sublist", + /* 397 */ "select_sublist ::= select_item", + /* 398 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 399 */ "select_item ::= common_expression", + /* 400 */ "select_item ::= common_expression column_alias", + /* 401 */ "select_item ::= common_expression AS column_alias", + /* 402 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 403 */ "where_clause_opt ::=", + /* 404 */ "where_clause_opt ::= WHERE search_condition", + /* 405 */ "partition_by_clause_opt ::=", + /* 406 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 407 */ "twindow_clause_opt ::=", + /* 408 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 409 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", + /* 410 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 411 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 412 */ "sliding_opt ::=", + /* 413 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 414 */ "fill_opt ::=", + /* 415 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 416 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 417 */ "fill_mode ::= NONE", + /* 418 */ "fill_mode ::= PREV", + /* 419 */ "fill_mode ::= NULL", + /* 420 */ "fill_mode ::= LINEAR", + /* 421 */ "fill_mode ::= NEXT", + /* 422 */ "group_by_clause_opt ::=", + /* 423 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 424 */ "group_by_list ::= expression", + /* 425 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 426 */ "having_clause_opt ::=", + /* 427 */ "having_clause_opt ::= HAVING search_condition", + /* 428 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 429 */ "query_expression_body ::= query_primary", + /* 430 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 431 */ "query_expression_body ::= query_expression_body UNION query_expression_body", + /* 432 */ "query_primary ::= query_specification", + /* 433 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", + /* 434 */ "order_by_clause_opt ::=", + /* 435 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 436 */ "slimit_clause_opt ::=", + /* 437 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 438 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 439 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 440 */ "limit_clause_opt ::=", + /* 441 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 442 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 443 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 444 */ "subquery ::= NK_LP query_expression NK_RP", + /* 445 */ "search_condition ::= common_expression", + /* 446 */ "sort_specification_list ::= sort_specification", + /* 447 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 448 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 449 */ "ordering_specification_opt ::=", + /* 450 */ "ordering_specification_opt ::= ASC", + /* 451 */ "ordering_specification_opt ::= DESC", + /* 452 */ "null_ordering_opt ::=", + /* 453 */ "null_ordering_opt ::= NULLS FIRST", + /* 454 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2093,174 +2104,175 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 238: /* cmd */ - case 241: /* literal */ - case 252: /* db_options */ - case 254: /* alter_db_options */ - case 259: /* retention */ - case 260: /* full_table_name */ - case 263: /* table_options */ - case 267: /* alter_table_clause */ - case 268: /* alter_table_options */ - case 271: /* signed_literal */ - case 272: /* create_subtable_clause */ - case 275: /* drop_table_clause */ - case 278: /* column_def */ - case 281: /* col_name */ - case 282: /* db_name_cond_opt */ - case 283: /* like_pattern_opt */ - case 284: /* table_name_cond */ - case 285: /* from_db_opt */ - case 286: /* func_name */ - case 289: /* index_options */ - case 291: /* duration_literal */ - case 292: /* sliding_opt */ - case 293: /* func */ - case 296: /* topic_options */ - case 297: /* query_expression */ - case 299: /* explain_options */ - case 303: /* stream_options */ - case 304: /* into_opt */ - case 306: /* signed */ - case 307: /* literal_func */ - case 310: /* expression */ - case 311: /* pseudo_column */ - case 312: /* column_reference */ - case 313: /* function_expression */ - case 314: /* subquery */ - case 319: /* star_func_para */ - case 320: /* predicate */ - case 323: /* in_predicate_value */ - case 324: /* boolean_value_expression */ - case 325: /* boolean_primary */ - case 326: /* common_expression */ - case 327: /* from_clause */ - case 328: /* table_reference_list */ - case 329: /* table_reference */ - case 330: /* table_primary */ - case 331: /* joined_table */ - case 333: /* parenthesized_joined_table */ - case 335: /* search_condition */ - case 336: /* query_specification */ - case 339: /* where_clause_opt */ - case 341: /* twindow_clause_opt */ - case 343: /* having_clause_opt */ - case 345: /* select_item */ - case 346: /* fill_opt */ - case 349: /* query_expression_body */ - case 351: /* slimit_clause_opt */ - case 352: /* limit_clause_opt */ - case 353: /* query_primary */ - case 355: /* sort_specification */ + case 240: /* cmd */ + case 243: /* literal */ + case 254: /* db_options */ + case 256: /* alter_db_options */ + case 261: /* retention */ + case 262: /* full_table_name */ + case 265: /* table_options */ + case 269: /* alter_table_clause */ + case 270: /* alter_table_options */ + case 273: /* signed_literal */ + case 274: /* create_subtable_clause */ + case 277: /* drop_table_clause */ + case 280: /* column_def */ + case 283: /* col_name */ + case 284: /* db_name_cond_opt */ + case 285: /* like_pattern_opt */ + case 286: /* table_name_cond */ + case 287: /* from_db_opt */ + case 288: /* func_name */ + case 291: /* index_options */ + case 293: /* duration_literal */ + case 294: /* sliding_opt */ + case 295: /* func */ + case 298: /* topic_options */ + case 299: /* query_expression */ + case 302: /* explain_options */ + case 306: /* stream_options */ + case 307: /* into_opt */ + case 309: /* signed */ + case 310: /* literal_func */ + case 313: /* expression */ + case 314: /* pseudo_column */ + case 315: /* column_reference */ + case 316: /* function_expression */ + case 317: /* subquery */ + case 322: /* star_func_para */ + case 323: /* predicate */ + case 326: /* in_predicate_value */ + case 327: /* boolean_value_expression */ + case 328: /* boolean_primary */ + case 329: /* common_expression */ + case 330: /* from_clause */ + case 331: /* table_reference_list */ + case 332: /* table_reference */ + case 333: /* table_primary */ + case 334: /* joined_table */ + case 336: /* parenthesized_joined_table */ + case 338: /* search_condition */ + case 339: /* query_specification */ + case 342: /* where_clause_opt */ + case 344: /* twindow_clause_opt */ + case 346: /* having_clause_opt */ + case 348: /* select_item */ + case 349: /* fill_opt */ + case 352: /* query_expression_body */ + case 354: /* slimit_clause_opt */ + case 355: /* limit_clause_opt */ + case 356: /* query_primary */ + case 358: /* sort_specification */ { - nodesDestroyNode((yypminor->yy172)); + nodesDestroyNode((yypminor->yy636)); } break; - case 239: /* account_options */ - case 240: /* alter_account_options */ - case 242: /* alter_account_option */ - case 301: /* bufsize_opt */ + case 241: /* account_options */ + case 242: /* alter_account_options */ + case 244: /* alter_account_option */ + case 304: /* bufsize_opt */ { } break; - case 243: /* user_name */ - case 245: /* priv_level */ - case 248: /* db_name */ - case 249: /* dnode_endpoint */ - case 250: /* dnode_host_name */ - case 269: /* column_name */ - case 277: /* table_name */ - case 287: /* function_name */ - case 288: /* index_name */ - case 295: /* topic_name */ - case 302: /* stream_name */ - case 308: /* table_alias */ - case 309: /* column_alias */ - case 315: /* star_func */ - case 317: /* noarg_func */ - case 332: /* alias_opt */ + case 245: /* user_name */ + case 247: /* priv_level */ + case 250: /* db_name */ + case 251: /* dnode_endpoint */ + case 252: /* dnode_host_name */ + case 271: /* column_name */ + case 279: /* table_name */ + case 289: /* function_name */ + case 290: /* index_name */ + case 297: /* topic_name */ + case 300: /* cgroup_name */ + case 305: /* stream_name */ + case 311: /* table_alias */ + case 312: /* column_alias */ + case 318: /* star_func */ + case 320: /* noarg_func */ + case 335: /* alias_opt */ { } break; - case 244: /* privileges */ - case 246: /* priv_type_list */ - case 247: /* priv_type */ + case 246: /* privileges */ + case 248: /* priv_type_list */ + case 249: /* priv_type */ { } break; - case 251: /* not_exists_opt */ - case 253: /* exists_opt */ - case 298: /* analyze_opt */ - case 300: /* agg_func_opt */ - case 337: /* set_quantifier_opt */ + case 253: /* not_exists_opt */ + case 255: /* exists_opt */ + case 301: /* analyze_opt */ + case 303: /* agg_func_opt */ + case 340: /* set_quantifier_opt */ { } break; - case 255: /* integer_list */ - case 256: /* variable_list */ - case 257: /* retention_list */ - case 261: /* column_def_list */ - case 262: /* tags_def_opt */ - case 264: /* multi_create_clause */ - case 265: /* tags_def */ - case 266: /* multi_drop_clause */ - case 273: /* specific_tags_opt */ - case 274: /* literal_list */ - case 276: /* col_name_list */ - case 279: /* func_name_list */ - case 290: /* func_list */ - case 294: /* expression_list */ - case 305: /* dnode_list */ - case 316: /* star_func_para_list */ - case 318: /* other_para_list */ - case 338: /* select_list */ - case 340: /* partition_by_clause_opt */ - case 342: /* group_by_clause_opt */ - case 344: /* select_sublist */ - case 348: /* group_by_list */ - case 350: /* order_by_clause_opt */ - case 354: /* sort_specification_list */ + case 257: /* integer_list */ + case 258: /* variable_list */ + case 259: /* retention_list */ + case 263: /* column_def_list */ + case 264: /* tags_def_opt */ + case 266: /* multi_create_clause */ + case 267: /* tags_def */ + case 268: /* multi_drop_clause */ + case 275: /* specific_tags_opt */ + case 276: /* literal_list */ + case 278: /* col_name_list */ + case 281: /* func_name_list */ + case 292: /* func_list */ + case 296: /* expression_list */ + case 308: /* dnode_list */ + case 319: /* star_func_para_list */ + case 321: /* other_para_list */ + case 341: /* select_list */ + case 343: /* partition_by_clause_opt */ + case 345: /* group_by_clause_opt */ + case 347: /* select_sublist */ + case 351: /* group_by_list */ + case 353: /* order_by_clause_opt */ + case 357: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy60)); + nodesDestroyList((yypminor->yy236)); } break; - case 258: /* alter_db_option */ - case 280: /* alter_table_option */ + case 260: /* alter_db_option */ + case 282: /* alter_table_option */ { } break; - case 270: /* type_name */ + case 272: /* type_name */ { } break; - case 321: /* compare_op */ - case 322: /* in_op */ + case 324: /* compare_op */ + case 325: /* in_op */ { } break; - case 334: /* join_type */ + case 337: /* join_type */ { } break; - case 347: /* fill_mode */ + case 350: /* fill_mode */ { } break; - case 356: /* ordering_specification_opt */ + case 359: /* ordering_specification_opt */ { } break; - case 357: /* null_ordering_opt */ + case 360: /* null_ordering_opt */ { } @@ -2559,458 +2571,461 @@ 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[] = { - { 238, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - { 238, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - { 239, 0 }, /* (2) account_options ::= */ - { 239, -3 }, /* (3) account_options ::= account_options PPS literal */ - { 239, -3 }, /* (4) account_options ::= account_options TSERIES literal */ - { 239, -3 }, /* (5) account_options ::= account_options STORAGE literal */ - { 239, -3 }, /* (6) account_options ::= account_options STREAMS literal */ - { 239, -3 }, /* (7) account_options ::= account_options QTIME literal */ - { 239, -3 }, /* (8) account_options ::= account_options DBS literal */ - { 239, -3 }, /* (9) account_options ::= account_options USERS literal */ - { 239, -3 }, /* (10) account_options ::= account_options CONNS literal */ - { 239, -3 }, /* (11) account_options ::= account_options STATE literal */ - { 240, -1 }, /* (12) alter_account_options ::= alter_account_option */ - { 240, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - { 242, -2 }, /* (14) alter_account_option ::= PASS literal */ - { 242, -2 }, /* (15) alter_account_option ::= PPS literal */ - { 242, -2 }, /* (16) alter_account_option ::= TSERIES literal */ - { 242, -2 }, /* (17) alter_account_option ::= STORAGE literal */ - { 242, -2 }, /* (18) alter_account_option ::= STREAMS literal */ - { 242, -2 }, /* (19) alter_account_option ::= QTIME literal */ - { 242, -2 }, /* (20) alter_account_option ::= DBS literal */ - { 242, -2 }, /* (21) alter_account_option ::= USERS literal */ - { 242, -2 }, /* (22) alter_account_option ::= CONNS literal */ - { 242, -2 }, /* (23) alter_account_option ::= STATE literal */ - { 238, -5 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING */ - { 238, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 238, -5 }, /* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ - { 238, -3 }, /* (27) cmd ::= DROP USER user_name */ - { 238, -6 }, /* (28) cmd ::= GRANT privileges ON priv_level TO user_name */ - { 238, -6 }, /* (29) cmd ::= REVOKE privileges ON priv_level FROM user_name */ - { 244, -1 }, /* (30) privileges ::= ALL */ - { 244, -1 }, /* (31) privileges ::= priv_type_list */ - { 246, -1 }, /* (32) priv_type_list ::= priv_type */ - { 246, -3 }, /* (33) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - { 247, -1 }, /* (34) priv_type ::= READ */ - { 247, -1 }, /* (35) priv_type ::= WRITE */ - { 245, -3 }, /* (36) priv_level ::= NK_STAR NK_DOT NK_STAR */ - { 245, -3 }, /* (37) priv_level ::= db_name NK_DOT NK_STAR */ - { 238, -3 }, /* (38) cmd ::= CREATE DNODE dnode_endpoint */ - { 238, -5 }, /* (39) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ - { 238, -3 }, /* (40) cmd ::= DROP DNODE NK_INTEGER */ - { 238, -3 }, /* (41) cmd ::= DROP DNODE dnode_endpoint */ - { 238, -4 }, /* (42) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - { 238, -5 }, /* (43) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - { 238, -4 }, /* (44) cmd ::= ALTER ALL DNODES NK_STRING */ - { 238, -5 }, /* (45) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - { 249, -1 }, /* (46) dnode_endpoint ::= NK_STRING */ - { 250, -1 }, /* (47) dnode_host_name ::= NK_ID */ - { 250, -1 }, /* (48) dnode_host_name ::= NK_IPTOKEN */ - { 238, -3 }, /* (49) cmd ::= ALTER LOCAL NK_STRING */ - { 238, -4 }, /* (50) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - { 238, -5 }, /* (51) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 238, -5 }, /* (52) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 238, -5 }, /* (53) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - { 238, -5 }, /* (54) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - { 238, -5 }, /* (55) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - { 238, -5 }, /* (56) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - { 238, -5 }, /* (57) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - { 238, -5 }, /* (58) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - { 238, -5 }, /* (59) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 238, -4 }, /* (60) cmd ::= DROP DATABASE exists_opt db_name */ - { 238, -2 }, /* (61) cmd ::= USE db_name */ - { 238, -4 }, /* (62) cmd ::= ALTER DATABASE db_name alter_db_options */ - { 251, -3 }, /* (63) not_exists_opt ::= IF NOT EXISTS */ - { 251, 0 }, /* (64) not_exists_opt ::= */ - { 253, -2 }, /* (65) exists_opt ::= IF EXISTS */ - { 253, 0 }, /* (66) exists_opt ::= */ - { 252, 0 }, /* (67) db_options ::= */ - { 252, -3 }, /* (68) db_options ::= db_options BUFFER NK_INTEGER */ - { 252, -3 }, /* (69) db_options ::= db_options CACHELAST NK_INTEGER */ - { 252, -3 }, /* (70) db_options ::= db_options COMP NK_INTEGER */ - { 252, -3 }, /* (71) db_options ::= db_options DAYS NK_INTEGER */ - { 252, -3 }, /* (72) db_options ::= db_options DAYS NK_VARIABLE */ - { 252, -3 }, /* (73) db_options ::= db_options FSYNC NK_INTEGER */ - { 252, -3 }, /* (74) db_options ::= db_options MAXROWS NK_INTEGER */ - { 252, -3 }, /* (75) db_options ::= db_options MINROWS NK_INTEGER */ - { 252, -3 }, /* (76) db_options ::= db_options KEEP integer_list */ - { 252, -3 }, /* (77) db_options ::= db_options KEEP variable_list */ - { 252, -3 }, /* (78) db_options ::= db_options PAGES NK_INTEGER */ - { 252, -3 }, /* (79) db_options ::= db_options PAGESIZE NK_INTEGER */ - { 252, -3 }, /* (80) db_options ::= db_options PRECISION NK_STRING */ - { 252, -3 }, /* (81) db_options ::= db_options REPLICA NK_INTEGER */ - { 252, -3 }, /* (82) db_options ::= db_options STRICT NK_INTEGER */ - { 252, -3 }, /* (83) db_options ::= db_options WAL NK_INTEGER */ - { 252, -3 }, /* (84) db_options ::= db_options VGROUPS NK_INTEGER */ - { 252, -3 }, /* (85) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 252, -3 }, /* (86) db_options ::= db_options RETENTIONS retention_list */ - { 254, -1 }, /* (87) alter_db_options ::= alter_db_option */ - { 254, -2 }, /* (88) alter_db_options ::= alter_db_options alter_db_option */ - { 258, -2 }, /* (89) alter_db_option ::= BUFFER NK_INTEGER */ - { 258, -2 }, /* (90) alter_db_option ::= CACHELAST NK_INTEGER */ - { 258, -2 }, /* (91) alter_db_option ::= FSYNC NK_INTEGER */ - { 258, -2 }, /* (92) alter_db_option ::= KEEP integer_list */ - { 258, -2 }, /* (93) alter_db_option ::= KEEP variable_list */ - { 258, -2 }, /* (94) alter_db_option ::= PAGES NK_INTEGER */ - { 258, -2 }, /* (95) alter_db_option ::= REPLICA NK_INTEGER */ - { 258, -2 }, /* (96) alter_db_option ::= STRICT NK_INTEGER */ - { 258, -2 }, /* (97) alter_db_option ::= WAL NK_INTEGER */ - { 255, -1 }, /* (98) integer_list ::= NK_INTEGER */ - { 255, -3 }, /* (99) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - { 256, -1 }, /* (100) variable_list ::= NK_VARIABLE */ - { 256, -3 }, /* (101) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - { 257, -1 }, /* (102) retention_list ::= retention */ - { 257, -3 }, /* (103) retention_list ::= retention_list NK_COMMA retention */ - { 259, -3 }, /* (104) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - { 238, -9 }, /* (105) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 238, -3 }, /* (106) cmd ::= CREATE TABLE multi_create_clause */ - { 238, -9 }, /* (107) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 238, -3 }, /* (108) cmd ::= DROP TABLE multi_drop_clause */ - { 238, -4 }, /* (109) cmd ::= DROP STABLE exists_opt full_table_name */ - { 238, -3 }, /* (110) cmd ::= ALTER TABLE alter_table_clause */ - { 238, -3 }, /* (111) cmd ::= ALTER STABLE alter_table_clause */ - { 267, -2 }, /* (112) alter_table_clause ::= full_table_name alter_table_options */ - { 267, -5 }, /* (113) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - { 267, -4 }, /* (114) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - { 267, -5 }, /* (115) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - { 267, -5 }, /* (116) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - { 267, -5 }, /* (117) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - { 267, -4 }, /* (118) alter_table_clause ::= full_table_name DROP TAG column_name */ - { 267, -5 }, /* (119) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - { 267, -5 }, /* (120) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 267, -6 }, /* (121) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ - { 264, -1 }, /* (122) multi_create_clause ::= create_subtable_clause */ - { 264, -2 }, /* (123) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 272, -10 }, /* (124) 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 */ - { 266, -1 }, /* (125) multi_drop_clause ::= drop_table_clause */ - { 266, -2 }, /* (126) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 275, -2 }, /* (127) drop_table_clause ::= exists_opt full_table_name */ - { 273, 0 }, /* (128) specific_tags_opt ::= */ - { 273, -3 }, /* (129) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - { 260, -1 }, /* (130) full_table_name ::= table_name */ - { 260, -3 }, /* (131) full_table_name ::= db_name NK_DOT table_name */ - { 261, -1 }, /* (132) column_def_list ::= column_def */ - { 261, -3 }, /* (133) column_def_list ::= column_def_list NK_COMMA column_def */ - { 278, -2 }, /* (134) column_def ::= column_name type_name */ - { 278, -4 }, /* (135) column_def ::= column_name type_name COMMENT NK_STRING */ - { 270, -1 }, /* (136) type_name ::= BOOL */ - { 270, -1 }, /* (137) type_name ::= TINYINT */ - { 270, -1 }, /* (138) type_name ::= SMALLINT */ - { 270, -1 }, /* (139) type_name ::= INT */ - { 270, -1 }, /* (140) type_name ::= INTEGER */ - { 270, -1 }, /* (141) type_name ::= BIGINT */ - { 270, -1 }, /* (142) type_name ::= FLOAT */ - { 270, -1 }, /* (143) type_name ::= DOUBLE */ - { 270, -4 }, /* (144) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 270, -1 }, /* (145) type_name ::= TIMESTAMP */ - { 270, -4 }, /* (146) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 270, -2 }, /* (147) type_name ::= TINYINT UNSIGNED */ - { 270, -2 }, /* (148) type_name ::= SMALLINT UNSIGNED */ - { 270, -2 }, /* (149) type_name ::= INT UNSIGNED */ - { 270, -2 }, /* (150) type_name ::= BIGINT UNSIGNED */ - { 270, -1 }, /* (151) type_name ::= JSON */ - { 270, -4 }, /* (152) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 270, -1 }, /* (153) type_name ::= MEDIUMBLOB */ - { 270, -1 }, /* (154) type_name ::= BLOB */ - { 270, -4 }, /* (155) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 270, -1 }, /* (156) type_name ::= DECIMAL */ - { 270, -4 }, /* (157) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 270, -6 }, /* (158) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 262, 0 }, /* (159) tags_def_opt ::= */ - { 262, -1 }, /* (160) tags_def_opt ::= tags_def */ - { 265, -4 }, /* (161) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 263, 0 }, /* (162) table_options ::= */ - { 263, -3 }, /* (163) table_options ::= table_options COMMENT NK_STRING */ - { 263, -3 }, /* (164) table_options ::= table_options DELAY NK_INTEGER */ - { 263, -3 }, /* (165) table_options ::= table_options FILE_FACTOR NK_FLOAT */ - { 263, -5 }, /* (166) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ - { 263, -3 }, /* (167) table_options ::= table_options TTL NK_INTEGER */ - { 263, -5 }, /* (168) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 268, -1 }, /* (169) alter_table_options ::= alter_table_option */ - { 268, -2 }, /* (170) alter_table_options ::= alter_table_options alter_table_option */ - { 280, -2 }, /* (171) alter_table_option ::= COMMENT NK_STRING */ - { 280, -2 }, /* (172) alter_table_option ::= TTL NK_INTEGER */ - { 276, -1 }, /* (173) col_name_list ::= col_name */ - { 276, -3 }, /* (174) col_name_list ::= col_name_list NK_COMMA col_name */ - { 281, -1 }, /* (175) col_name ::= column_name */ - { 238, -2 }, /* (176) cmd ::= SHOW DNODES */ - { 238, -2 }, /* (177) cmd ::= SHOW USERS */ - { 238, -2 }, /* (178) cmd ::= SHOW DATABASES */ - { 238, -4 }, /* (179) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - { 238, -4 }, /* (180) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - { 238, -3 }, /* (181) cmd ::= SHOW db_name_cond_opt VGROUPS */ - { 238, -2 }, /* (182) cmd ::= SHOW MNODES */ - { 238, -2 }, /* (183) cmd ::= SHOW MODULES */ - { 238, -2 }, /* (184) cmd ::= SHOW QNODES */ - { 238, -2 }, /* (185) cmd ::= SHOW FUNCTIONS */ - { 238, -5 }, /* (186) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 238, -2 }, /* (187) cmd ::= SHOW STREAMS */ - { 238, -2 }, /* (188) cmd ::= SHOW ACCOUNTS */ - { 238, -2 }, /* (189) cmd ::= SHOW APPS */ - { 238, -2 }, /* (190) cmd ::= SHOW CONNECTIONS */ - { 238, -2 }, /* (191) cmd ::= SHOW LICENCE */ - { 238, -2 }, /* (192) cmd ::= SHOW GRANTS */ - { 238, -4 }, /* (193) cmd ::= SHOW CREATE DATABASE db_name */ - { 238, -4 }, /* (194) cmd ::= SHOW CREATE TABLE full_table_name */ - { 238, -4 }, /* (195) cmd ::= SHOW CREATE STABLE full_table_name */ - { 238, -2 }, /* (196) cmd ::= SHOW QUERIES */ - { 238, -2 }, /* (197) cmd ::= SHOW SCORES */ - { 238, -2 }, /* (198) cmd ::= SHOW TOPICS */ - { 238, -2 }, /* (199) cmd ::= SHOW VARIABLES */ - { 238, -2 }, /* (200) cmd ::= SHOW BNODES */ - { 238, -2 }, /* (201) cmd ::= SHOW SNODES */ - { 238, -2 }, /* (202) cmd ::= SHOW CLUSTER */ - { 238, -2 }, /* (203) cmd ::= SHOW TRANSACTIONS */ - { 282, 0 }, /* (204) db_name_cond_opt ::= */ - { 282, -2 }, /* (205) db_name_cond_opt ::= db_name NK_DOT */ - { 283, 0 }, /* (206) like_pattern_opt ::= */ - { 283, -2 }, /* (207) like_pattern_opt ::= LIKE NK_STRING */ - { 284, -1 }, /* (208) table_name_cond ::= table_name */ - { 285, 0 }, /* (209) from_db_opt ::= */ - { 285, -2 }, /* (210) from_db_opt ::= FROM db_name */ - { 279, -1 }, /* (211) func_name_list ::= func_name */ - { 279, -3 }, /* (212) func_name_list ::= func_name_list NK_COMMA func_name */ - { 286, -1 }, /* (213) func_name ::= function_name */ - { 238, -8 }, /* (214) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ - { 238, -10 }, /* (215) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ - { 238, -6 }, /* (216) cmd ::= DROP INDEX exists_opt index_name ON table_name */ - { 289, 0 }, /* (217) index_options ::= */ - { 289, -9 }, /* (218) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ - { 289, -11 }, /* (219) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ - { 290, -1 }, /* (220) func_list ::= func */ - { 290, -3 }, /* (221) func_list ::= func_list NK_COMMA func */ - { 293, -4 }, /* (222) func ::= function_name NK_LP expression_list NK_RP */ - { 238, -7 }, /* (223) cmd ::= CREATE TOPIC not_exists_opt topic_name topic_options AS query_expression */ - { 238, -7 }, /* (224) cmd ::= CREATE TOPIC not_exists_opt topic_name topic_options AS db_name */ - { 238, -4 }, /* (225) cmd ::= DROP TOPIC exists_opt topic_name */ - { 296, 0 }, /* (226) topic_options ::= */ - { 296, -3 }, /* (227) topic_options ::= topic_options WITH TABLE */ - { 296, -3 }, /* (228) topic_options ::= topic_options WITH SCHEMA */ - { 296, -3 }, /* (229) topic_options ::= topic_options WITH TAG */ - { 238, -2 }, /* (230) cmd ::= DESC full_table_name */ - { 238, -2 }, /* (231) cmd ::= DESCRIBE full_table_name */ - { 238, -3 }, /* (232) cmd ::= RESET QUERY CACHE */ - { 238, -4 }, /* (233) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ - { 298, 0 }, /* (234) analyze_opt ::= */ - { 298, -1 }, /* (235) analyze_opt ::= ANALYZE */ - { 299, 0 }, /* (236) explain_options ::= */ - { 299, -3 }, /* (237) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 299, -3 }, /* (238) explain_options ::= explain_options RATIO NK_FLOAT */ - { 238, -6 }, /* (239) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ - { 238, -10 }, /* (240) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ - { 238, -4 }, /* (241) cmd ::= DROP FUNCTION exists_opt function_name */ - { 300, 0 }, /* (242) agg_func_opt ::= */ - { 300, -1 }, /* (243) agg_func_opt ::= AGGREGATE */ - { 301, 0 }, /* (244) bufsize_opt ::= */ - { 301, -2 }, /* (245) bufsize_opt ::= BUFSIZE NK_INTEGER */ - { 238, -8 }, /* (246) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ - { 238, -4 }, /* (247) cmd ::= DROP STREAM exists_opt stream_name */ - { 304, 0 }, /* (248) into_opt ::= */ - { 304, -2 }, /* (249) into_opt ::= INTO full_table_name */ - { 303, 0 }, /* (250) stream_options ::= */ - { 303, -3 }, /* (251) stream_options ::= stream_options TRIGGER AT_ONCE */ - { 303, -3 }, /* (252) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - { 303, -3 }, /* (253) stream_options ::= stream_options WATERMARK duration_literal */ - { 238, -3 }, /* (254) cmd ::= KILL CONNECTION NK_INTEGER */ - { 238, -3 }, /* (255) cmd ::= KILL QUERY NK_INTEGER */ - { 238, -3 }, /* (256) cmd ::= KILL TRANSACTION NK_INTEGER */ - { 238, -4 }, /* (257) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - { 238, -4 }, /* (258) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - { 238, -3 }, /* (259) cmd ::= SPLIT VGROUP NK_INTEGER */ - { 305, -2 }, /* (260) dnode_list ::= DNODE NK_INTEGER */ - { 305, -3 }, /* (261) dnode_list ::= dnode_list DNODE NK_INTEGER */ - { 238, -3 }, /* (262) cmd ::= SYNCDB db_name REPLICA */ - { 238, -1 }, /* (263) cmd ::= query_expression */ - { 241, -1 }, /* (264) literal ::= NK_INTEGER */ - { 241, -1 }, /* (265) literal ::= NK_FLOAT */ - { 241, -1 }, /* (266) literal ::= NK_STRING */ - { 241, -1 }, /* (267) literal ::= NK_BOOL */ - { 241, -2 }, /* (268) literal ::= TIMESTAMP NK_STRING */ - { 241, -1 }, /* (269) literal ::= duration_literal */ - { 241, -1 }, /* (270) literal ::= NULL */ - { 241, -1 }, /* (271) literal ::= NK_QUESTION */ - { 291, -1 }, /* (272) duration_literal ::= NK_VARIABLE */ - { 306, -1 }, /* (273) signed ::= NK_INTEGER */ - { 306, -2 }, /* (274) signed ::= NK_PLUS NK_INTEGER */ - { 306, -2 }, /* (275) signed ::= NK_MINUS NK_INTEGER */ - { 306, -1 }, /* (276) signed ::= NK_FLOAT */ - { 306, -2 }, /* (277) signed ::= NK_PLUS NK_FLOAT */ - { 306, -2 }, /* (278) signed ::= NK_MINUS NK_FLOAT */ - { 271, -1 }, /* (279) signed_literal ::= signed */ - { 271, -1 }, /* (280) signed_literal ::= NK_STRING */ - { 271, -1 }, /* (281) signed_literal ::= NK_BOOL */ - { 271, -2 }, /* (282) signed_literal ::= TIMESTAMP NK_STRING */ - { 271, -1 }, /* (283) signed_literal ::= duration_literal */ - { 271, -1 }, /* (284) signed_literal ::= NULL */ - { 271, -1 }, /* (285) signed_literal ::= literal_func */ - { 274, -1 }, /* (286) literal_list ::= signed_literal */ - { 274, -3 }, /* (287) literal_list ::= literal_list NK_COMMA signed_literal */ - { 248, -1 }, /* (288) db_name ::= NK_ID */ - { 277, -1 }, /* (289) table_name ::= NK_ID */ - { 269, -1 }, /* (290) column_name ::= NK_ID */ - { 287, -1 }, /* (291) function_name ::= NK_ID */ - { 308, -1 }, /* (292) table_alias ::= NK_ID */ - { 309, -1 }, /* (293) column_alias ::= NK_ID */ - { 243, -1 }, /* (294) user_name ::= NK_ID */ - { 288, -1 }, /* (295) index_name ::= NK_ID */ - { 295, -1 }, /* (296) topic_name ::= NK_ID */ - { 302, -1 }, /* (297) stream_name ::= NK_ID */ - { 310, -1 }, /* (298) expression ::= literal */ - { 310, -1 }, /* (299) expression ::= pseudo_column */ - { 310, -1 }, /* (300) expression ::= column_reference */ - { 310, -1 }, /* (301) expression ::= function_expression */ - { 310, -1 }, /* (302) expression ::= subquery */ - { 310, -3 }, /* (303) expression ::= NK_LP expression NK_RP */ - { 310, -2 }, /* (304) expression ::= NK_PLUS expression */ - { 310, -2 }, /* (305) expression ::= NK_MINUS expression */ - { 310, -3 }, /* (306) expression ::= expression NK_PLUS expression */ - { 310, -3 }, /* (307) expression ::= expression NK_MINUS expression */ - { 310, -3 }, /* (308) expression ::= expression NK_STAR expression */ - { 310, -3 }, /* (309) expression ::= expression NK_SLASH expression */ - { 310, -3 }, /* (310) expression ::= expression NK_REM expression */ - { 310, -3 }, /* (311) expression ::= column_reference NK_ARROW NK_STRING */ - { 294, -1 }, /* (312) expression_list ::= expression */ - { 294, -3 }, /* (313) expression_list ::= expression_list NK_COMMA expression */ - { 312, -1 }, /* (314) column_reference ::= column_name */ - { 312, -3 }, /* (315) column_reference ::= table_name NK_DOT column_name */ - { 311, -1 }, /* (316) pseudo_column ::= ROWTS */ - { 311, -1 }, /* (317) pseudo_column ::= TBNAME */ - { 311, -3 }, /* (318) pseudo_column ::= table_name NK_DOT TBNAME */ - { 311, -1 }, /* (319) pseudo_column ::= QSTARTTS */ - { 311, -1 }, /* (320) pseudo_column ::= QENDTS */ - { 311, -1 }, /* (321) pseudo_column ::= WSTARTTS */ - { 311, -1 }, /* (322) pseudo_column ::= WENDTS */ - { 311, -1 }, /* (323) pseudo_column ::= WDURATION */ - { 313, -4 }, /* (324) function_expression ::= function_name NK_LP expression_list NK_RP */ - { 313, -4 }, /* (325) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - { 313, -6 }, /* (326) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ - { 313, -1 }, /* (327) function_expression ::= literal_func */ - { 307, -3 }, /* (328) literal_func ::= noarg_func NK_LP NK_RP */ - { 307, -1 }, /* (329) literal_func ::= NOW */ - { 317, -1 }, /* (330) noarg_func ::= NOW */ - { 317, -1 }, /* (331) noarg_func ::= TODAY */ - { 317, -1 }, /* (332) noarg_func ::= TIMEZONE */ - { 315, -1 }, /* (333) star_func ::= COUNT */ - { 315, -1 }, /* (334) star_func ::= FIRST */ - { 315, -1 }, /* (335) star_func ::= LAST */ - { 315, -1 }, /* (336) star_func ::= LAST_ROW */ - { 316, -1 }, /* (337) star_func_para_list ::= NK_STAR */ - { 316, -1 }, /* (338) star_func_para_list ::= other_para_list */ - { 318, -1 }, /* (339) other_para_list ::= star_func_para */ - { 318, -3 }, /* (340) other_para_list ::= other_para_list NK_COMMA star_func_para */ - { 319, -1 }, /* (341) star_func_para ::= expression */ - { 319, -3 }, /* (342) star_func_para ::= table_name NK_DOT NK_STAR */ - { 320, -3 }, /* (343) predicate ::= expression compare_op expression */ - { 320, -5 }, /* (344) predicate ::= expression BETWEEN expression AND expression */ - { 320, -6 }, /* (345) predicate ::= expression NOT BETWEEN expression AND expression */ - { 320, -3 }, /* (346) predicate ::= expression IS NULL */ - { 320, -4 }, /* (347) predicate ::= expression IS NOT NULL */ - { 320, -3 }, /* (348) predicate ::= expression in_op in_predicate_value */ - { 321, -1 }, /* (349) compare_op ::= NK_LT */ - { 321, -1 }, /* (350) compare_op ::= NK_GT */ - { 321, -1 }, /* (351) compare_op ::= NK_LE */ - { 321, -1 }, /* (352) compare_op ::= NK_GE */ - { 321, -1 }, /* (353) compare_op ::= NK_NE */ - { 321, -1 }, /* (354) compare_op ::= NK_EQ */ - { 321, -1 }, /* (355) compare_op ::= LIKE */ - { 321, -2 }, /* (356) compare_op ::= NOT LIKE */ - { 321, -1 }, /* (357) compare_op ::= MATCH */ - { 321, -1 }, /* (358) compare_op ::= NMATCH */ - { 321, -1 }, /* (359) compare_op ::= CONTAINS */ - { 322, -1 }, /* (360) in_op ::= IN */ - { 322, -2 }, /* (361) in_op ::= NOT IN */ - { 323, -3 }, /* (362) in_predicate_value ::= NK_LP expression_list NK_RP */ - { 324, -1 }, /* (363) boolean_value_expression ::= boolean_primary */ - { 324, -2 }, /* (364) boolean_value_expression ::= NOT boolean_primary */ - { 324, -3 }, /* (365) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 324, -3 }, /* (366) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 325, -1 }, /* (367) boolean_primary ::= predicate */ - { 325, -3 }, /* (368) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 326, -1 }, /* (369) common_expression ::= expression */ - { 326, -1 }, /* (370) common_expression ::= boolean_value_expression */ - { 327, -2 }, /* (371) from_clause ::= FROM table_reference_list */ - { 328, -1 }, /* (372) table_reference_list ::= table_reference */ - { 328, -3 }, /* (373) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 329, -1 }, /* (374) table_reference ::= table_primary */ - { 329, -1 }, /* (375) table_reference ::= joined_table */ - { 330, -2 }, /* (376) table_primary ::= table_name alias_opt */ - { 330, -4 }, /* (377) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 330, -2 }, /* (378) table_primary ::= subquery alias_opt */ - { 330, -1 }, /* (379) table_primary ::= parenthesized_joined_table */ - { 332, 0 }, /* (380) alias_opt ::= */ - { 332, -1 }, /* (381) alias_opt ::= table_alias */ - { 332, -2 }, /* (382) alias_opt ::= AS table_alias */ - { 333, -3 }, /* (383) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 333, -3 }, /* (384) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 331, -6 }, /* (385) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 334, 0 }, /* (386) join_type ::= */ - { 334, -1 }, /* (387) join_type ::= INNER */ - { 336, -9 }, /* (388) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - { 337, 0 }, /* (389) set_quantifier_opt ::= */ - { 337, -1 }, /* (390) set_quantifier_opt ::= DISTINCT */ - { 337, -1 }, /* (391) set_quantifier_opt ::= ALL */ - { 338, -1 }, /* (392) select_list ::= NK_STAR */ - { 338, -1 }, /* (393) select_list ::= select_sublist */ - { 344, -1 }, /* (394) select_sublist ::= select_item */ - { 344, -3 }, /* (395) select_sublist ::= select_sublist NK_COMMA select_item */ - { 345, -1 }, /* (396) select_item ::= common_expression */ - { 345, -2 }, /* (397) select_item ::= common_expression column_alias */ - { 345, -3 }, /* (398) select_item ::= common_expression AS column_alias */ - { 345, -3 }, /* (399) select_item ::= table_name NK_DOT NK_STAR */ - { 339, 0 }, /* (400) where_clause_opt ::= */ - { 339, -2 }, /* (401) where_clause_opt ::= WHERE search_condition */ - { 340, 0 }, /* (402) partition_by_clause_opt ::= */ - { 340, -3 }, /* (403) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 341, 0 }, /* (404) twindow_clause_opt ::= */ - { 341, -6 }, /* (405) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 341, -4 }, /* (406) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ - { 341, -6 }, /* (407) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 341, -8 }, /* (408) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 292, 0 }, /* (409) sliding_opt ::= */ - { 292, -4 }, /* (410) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 346, 0 }, /* (411) fill_opt ::= */ - { 346, -4 }, /* (412) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 346, -6 }, /* (413) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 347, -1 }, /* (414) fill_mode ::= NONE */ - { 347, -1 }, /* (415) fill_mode ::= PREV */ - { 347, -1 }, /* (416) fill_mode ::= NULL */ - { 347, -1 }, /* (417) fill_mode ::= LINEAR */ - { 347, -1 }, /* (418) fill_mode ::= NEXT */ - { 342, 0 }, /* (419) group_by_clause_opt ::= */ - { 342, -3 }, /* (420) group_by_clause_opt ::= GROUP BY group_by_list */ - { 348, -1 }, /* (421) group_by_list ::= expression */ - { 348, -3 }, /* (422) group_by_list ::= group_by_list NK_COMMA expression */ - { 343, 0 }, /* (423) having_clause_opt ::= */ - { 343, -2 }, /* (424) having_clause_opt ::= HAVING search_condition */ - { 297, -4 }, /* (425) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 349, -1 }, /* (426) query_expression_body ::= query_primary */ - { 349, -4 }, /* (427) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 349, -3 }, /* (428) query_expression_body ::= query_expression_body UNION query_expression_body */ - { 353, -1 }, /* (429) query_primary ::= query_specification */ - { 353, -6 }, /* (430) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ - { 350, 0 }, /* (431) order_by_clause_opt ::= */ - { 350, -3 }, /* (432) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 351, 0 }, /* (433) slimit_clause_opt ::= */ - { 351, -2 }, /* (434) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 351, -4 }, /* (435) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 351, -4 }, /* (436) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 352, 0 }, /* (437) limit_clause_opt ::= */ - { 352, -2 }, /* (438) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 352, -4 }, /* (439) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 352, -4 }, /* (440) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 314, -3 }, /* (441) subquery ::= NK_LP query_expression NK_RP */ - { 335, -1 }, /* (442) search_condition ::= common_expression */ - { 354, -1 }, /* (443) sort_specification_list ::= sort_specification */ - { 354, -3 }, /* (444) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 355, -3 }, /* (445) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 356, 0 }, /* (446) ordering_specification_opt ::= */ - { 356, -1 }, /* (447) ordering_specification_opt ::= ASC */ - { 356, -1 }, /* (448) ordering_specification_opt ::= DESC */ - { 357, 0 }, /* (449) null_ordering_opt ::= */ - { 357, -2 }, /* (450) null_ordering_opt ::= NULLS FIRST */ - { 357, -2 }, /* (451) null_ordering_opt ::= NULLS LAST */ + { 240, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + { 240, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + { 241, 0 }, /* (2) account_options ::= */ + { 241, -3 }, /* (3) account_options ::= account_options PPS literal */ + { 241, -3 }, /* (4) account_options ::= account_options TSERIES literal */ + { 241, -3 }, /* (5) account_options ::= account_options STORAGE literal */ + { 241, -3 }, /* (6) account_options ::= account_options STREAMS literal */ + { 241, -3 }, /* (7) account_options ::= account_options QTIME literal */ + { 241, -3 }, /* (8) account_options ::= account_options DBS literal */ + { 241, -3 }, /* (9) account_options ::= account_options USERS literal */ + { 241, -3 }, /* (10) account_options ::= account_options CONNS literal */ + { 241, -3 }, /* (11) account_options ::= account_options STATE literal */ + { 242, -1 }, /* (12) alter_account_options ::= alter_account_option */ + { 242, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + { 244, -2 }, /* (14) alter_account_option ::= PASS literal */ + { 244, -2 }, /* (15) alter_account_option ::= PPS literal */ + { 244, -2 }, /* (16) alter_account_option ::= TSERIES literal */ + { 244, -2 }, /* (17) alter_account_option ::= STORAGE literal */ + { 244, -2 }, /* (18) alter_account_option ::= STREAMS literal */ + { 244, -2 }, /* (19) alter_account_option ::= QTIME literal */ + { 244, -2 }, /* (20) alter_account_option ::= DBS literal */ + { 244, -2 }, /* (21) alter_account_option ::= USERS literal */ + { 244, -2 }, /* (22) alter_account_option ::= CONNS literal */ + { 244, -2 }, /* (23) alter_account_option ::= STATE literal */ + { 240, -5 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING */ + { 240, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 240, -5 }, /* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ + { 240, -3 }, /* (27) cmd ::= DROP USER user_name */ + { 240, -6 }, /* (28) cmd ::= GRANT privileges ON priv_level TO user_name */ + { 240, -6 }, /* (29) cmd ::= REVOKE privileges ON priv_level FROM user_name */ + { 246, -1 }, /* (30) privileges ::= ALL */ + { 246, -1 }, /* (31) privileges ::= priv_type_list */ + { 248, -1 }, /* (32) priv_type_list ::= priv_type */ + { 248, -3 }, /* (33) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + { 249, -1 }, /* (34) priv_type ::= READ */ + { 249, -1 }, /* (35) priv_type ::= WRITE */ + { 247, -3 }, /* (36) priv_level ::= NK_STAR NK_DOT NK_STAR */ + { 247, -3 }, /* (37) priv_level ::= db_name NK_DOT NK_STAR */ + { 240, -3 }, /* (38) cmd ::= CREATE DNODE dnode_endpoint */ + { 240, -5 }, /* (39) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ + { 240, -3 }, /* (40) cmd ::= DROP DNODE NK_INTEGER */ + { 240, -3 }, /* (41) cmd ::= DROP DNODE dnode_endpoint */ + { 240, -4 }, /* (42) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 240, -5 }, /* (43) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 240, -4 }, /* (44) cmd ::= ALTER ALL DNODES NK_STRING */ + { 240, -5 }, /* (45) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 251, -1 }, /* (46) dnode_endpoint ::= NK_STRING */ + { 252, -1 }, /* (47) dnode_host_name ::= NK_ID */ + { 252, -1 }, /* (48) dnode_host_name ::= NK_IPTOKEN */ + { 240, -3 }, /* (49) cmd ::= ALTER LOCAL NK_STRING */ + { 240, -4 }, /* (50) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 240, -5 }, /* (51) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (52) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (53) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (54) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (55) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (56) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (57) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (58) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + { 240, -5 }, /* (59) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 240, -4 }, /* (60) cmd ::= DROP DATABASE exists_opt db_name */ + { 240, -2 }, /* (61) cmd ::= USE db_name */ + { 240, -4 }, /* (62) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 253, -3 }, /* (63) not_exists_opt ::= IF NOT EXISTS */ + { 253, 0 }, /* (64) not_exists_opt ::= */ + { 255, -2 }, /* (65) exists_opt ::= IF EXISTS */ + { 255, 0 }, /* (66) exists_opt ::= */ + { 254, 0 }, /* (67) db_options ::= */ + { 254, -3 }, /* (68) db_options ::= db_options BUFFER NK_INTEGER */ + { 254, -3 }, /* (69) db_options ::= db_options CACHELAST NK_INTEGER */ + { 254, -3 }, /* (70) db_options ::= db_options COMP NK_INTEGER */ + { 254, -3 }, /* (71) db_options ::= db_options DAYS NK_INTEGER */ + { 254, -3 }, /* (72) db_options ::= db_options DAYS NK_VARIABLE */ + { 254, -3 }, /* (73) db_options ::= db_options FSYNC NK_INTEGER */ + { 254, -3 }, /* (74) db_options ::= db_options MAXROWS NK_INTEGER */ + { 254, -3 }, /* (75) db_options ::= db_options MINROWS NK_INTEGER */ + { 254, -3 }, /* (76) db_options ::= db_options KEEP integer_list */ + { 254, -3 }, /* (77) db_options ::= db_options KEEP variable_list */ + { 254, -3 }, /* (78) db_options ::= db_options PAGES NK_INTEGER */ + { 254, -3 }, /* (79) db_options ::= db_options PAGESIZE NK_INTEGER */ + { 254, -3 }, /* (80) db_options ::= db_options PRECISION NK_STRING */ + { 254, -3 }, /* (81) db_options ::= db_options REPLICA NK_INTEGER */ + { 254, -3 }, /* (82) db_options ::= db_options STRICT NK_INTEGER */ + { 254, -3 }, /* (83) db_options ::= db_options WAL NK_INTEGER */ + { 254, -3 }, /* (84) db_options ::= db_options VGROUPS NK_INTEGER */ + { 254, -3 }, /* (85) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 254, -3 }, /* (86) db_options ::= db_options RETENTIONS retention_list */ + { 254, -3 }, /* (87) db_options ::= db_options SCHEMALESS NK_INTEGER */ + { 256, -1 }, /* (88) alter_db_options ::= alter_db_option */ + { 256, -2 }, /* (89) alter_db_options ::= alter_db_options alter_db_option */ + { 260, -2 }, /* (90) alter_db_option ::= BUFFER NK_INTEGER */ + { 260, -2 }, /* (91) alter_db_option ::= CACHELAST NK_INTEGER */ + { 260, -2 }, /* (92) alter_db_option ::= FSYNC NK_INTEGER */ + { 260, -2 }, /* (93) alter_db_option ::= KEEP integer_list */ + { 260, -2 }, /* (94) alter_db_option ::= KEEP variable_list */ + { 260, -2 }, /* (95) alter_db_option ::= PAGES NK_INTEGER */ + { 260, -2 }, /* (96) alter_db_option ::= REPLICA NK_INTEGER */ + { 260, -2 }, /* (97) alter_db_option ::= STRICT NK_INTEGER */ + { 260, -2 }, /* (98) alter_db_option ::= WAL NK_INTEGER */ + { 257, -1 }, /* (99) integer_list ::= NK_INTEGER */ + { 257, -3 }, /* (100) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + { 258, -1 }, /* (101) variable_list ::= NK_VARIABLE */ + { 258, -3 }, /* (102) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + { 259, -1 }, /* (103) retention_list ::= retention */ + { 259, -3 }, /* (104) retention_list ::= retention_list NK_COMMA retention */ + { 261, -3 }, /* (105) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + { 240, -9 }, /* (106) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 240, -3 }, /* (107) cmd ::= CREATE TABLE multi_create_clause */ + { 240, -9 }, /* (108) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 240, -3 }, /* (109) cmd ::= DROP TABLE multi_drop_clause */ + { 240, -4 }, /* (110) cmd ::= DROP STABLE exists_opt full_table_name */ + { 240, -3 }, /* (111) cmd ::= ALTER TABLE alter_table_clause */ + { 240, -3 }, /* (112) cmd ::= ALTER STABLE alter_table_clause */ + { 269, -2 }, /* (113) alter_table_clause ::= full_table_name alter_table_options */ + { 269, -5 }, /* (114) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 269, -4 }, /* (115) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 269, -5 }, /* (116) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 269, -5 }, /* (117) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 269, -5 }, /* (118) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 269, -4 }, /* (119) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 269, -5 }, /* (120) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 269, -5 }, /* (121) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 269, -6 }, /* (122) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ + { 266, -1 }, /* (123) multi_create_clause ::= create_subtable_clause */ + { 266, -2 }, /* (124) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 274, -10 }, /* (125) 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 */ + { 268, -1 }, /* (126) multi_drop_clause ::= drop_table_clause */ + { 268, -2 }, /* (127) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 277, -2 }, /* (128) drop_table_clause ::= exists_opt full_table_name */ + { 275, 0 }, /* (129) specific_tags_opt ::= */ + { 275, -3 }, /* (130) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + { 262, -1 }, /* (131) full_table_name ::= table_name */ + { 262, -3 }, /* (132) full_table_name ::= db_name NK_DOT table_name */ + { 263, -1 }, /* (133) column_def_list ::= column_def */ + { 263, -3 }, /* (134) column_def_list ::= column_def_list NK_COMMA column_def */ + { 280, -2 }, /* (135) column_def ::= column_name type_name */ + { 280, -4 }, /* (136) column_def ::= column_name type_name COMMENT NK_STRING */ + { 272, -1 }, /* (137) type_name ::= BOOL */ + { 272, -1 }, /* (138) type_name ::= TINYINT */ + { 272, -1 }, /* (139) type_name ::= SMALLINT */ + { 272, -1 }, /* (140) type_name ::= INT */ + { 272, -1 }, /* (141) type_name ::= INTEGER */ + { 272, -1 }, /* (142) type_name ::= BIGINT */ + { 272, -1 }, /* (143) type_name ::= FLOAT */ + { 272, -1 }, /* (144) type_name ::= DOUBLE */ + { 272, -4 }, /* (145) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 272, -1 }, /* (146) type_name ::= TIMESTAMP */ + { 272, -4 }, /* (147) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 272, -2 }, /* (148) type_name ::= TINYINT UNSIGNED */ + { 272, -2 }, /* (149) type_name ::= SMALLINT UNSIGNED */ + { 272, -2 }, /* (150) type_name ::= INT UNSIGNED */ + { 272, -2 }, /* (151) type_name ::= BIGINT UNSIGNED */ + { 272, -1 }, /* (152) type_name ::= JSON */ + { 272, -4 }, /* (153) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 272, -1 }, /* (154) type_name ::= MEDIUMBLOB */ + { 272, -1 }, /* (155) type_name ::= BLOB */ + { 272, -4 }, /* (156) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 272, -1 }, /* (157) type_name ::= DECIMAL */ + { 272, -4 }, /* (158) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 272, -6 }, /* (159) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 264, 0 }, /* (160) tags_def_opt ::= */ + { 264, -1 }, /* (161) tags_def_opt ::= tags_def */ + { 267, -4 }, /* (162) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 265, 0 }, /* (163) table_options ::= */ + { 265, -3 }, /* (164) table_options ::= table_options COMMENT NK_STRING */ + { 265, -3 }, /* (165) table_options ::= table_options DELAY NK_INTEGER */ + { 265, -3 }, /* (166) table_options ::= table_options FILE_FACTOR NK_FLOAT */ + { 265, -5 }, /* (167) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ + { 265, -3 }, /* (168) table_options ::= table_options TTL NK_INTEGER */ + { 265, -5 }, /* (169) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 270, -1 }, /* (170) alter_table_options ::= alter_table_option */ + { 270, -2 }, /* (171) alter_table_options ::= alter_table_options alter_table_option */ + { 282, -2 }, /* (172) alter_table_option ::= COMMENT NK_STRING */ + { 282, -2 }, /* (173) alter_table_option ::= TTL NK_INTEGER */ + { 278, -1 }, /* (174) col_name_list ::= col_name */ + { 278, -3 }, /* (175) col_name_list ::= col_name_list NK_COMMA col_name */ + { 283, -1 }, /* (176) col_name ::= column_name */ + { 240, -2 }, /* (177) cmd ::= SHOW DNODES */ + { 240, -2 }, /* (178) cmd ::= SHOW USERS */ + { 240, -2 }, /* (179) cmd ::= SHOW DATABASES */ + { 240, -4 }, /* (180) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 240, -4 }, /* (181) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 240, -3 }, /* (182) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 240, -2 }, /* (183) cmd ::= SHOW MNODES */ + { 240, -2 }, /* (184) cmd ::= SHOW MODULES */ + { 240, -2 }, /* (185) cmd ::= SHOW QNODES */ + { 240, -2 }, /* (186) cmd ::= SHOW FUNCTIONS */ + { 240, -5 }, /* (187) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 240, -2 }, /* (188) cmd ::= SHOW STREAMS */ + { 240, -2 }, /* (189) cmd ::= SHOW ACCOUNTS */ + { 240, -2 }, /* (190) cmd ::= SHOW APPS */ + { 240, -2 }, /* (191) cmd ::= SHOW CONNECTIONS */ + { 240, -2 }, /* (192) cmd ::= SHOW LICENCE */ + { 240, -2 }, /* (193) cmd ::= SHOW GRANTS */ + { 240, -4 }, /* (194) cmd ::= SHOW CREATE DATABASE db_name */ + { 240, -4 }, /* (195) cmd ::= SHOW CREATE TABLE full_table_name */ + { 240, -4 }, /* (196) cmd ::= SHOW CREATE STABLE full_table_name */ + { 240, -2 }, /* (197) cmd ::= SHOW QUERIES */ + { 240, -2 }, /* (198) cmd ::= SHOW SCORES */ + { 240, -2 }, /* (199) cmd ::= SHOW TOPICS */ + { 240, -2 }, /* (200) cmd ::= SHOW VARIABLES */ + { 240, -2 }, /* (201) cmd ::= SHOW BNODES */ + { 240, -2 }, /* (202) cmd ::= SHOW SNODES */ + { 240, -2 }, /* (203) cmd ::= SHOW CLUSTER */ + { 240, -2 }, /* (204) cmd ::= SHOW TRANSACTIONS */ + { 284, 0 }, /* (205) db_name_cond_opt ::= */ + { 284, -2 }, /* (206) db_name_cond_opt ::= db_name NK_DOT */ + { 285, 0 }, /* (207) like_pattern_opt ::= */ + { 285, -2 }, /* (208) like_pattern_opt ::= LIKE NK_STRING */ + { 286, -1 }, /* (209) table_name_cond ::= table_name */ + { 287, 0 }, /* (210) from_db_opt ::= */ + { 287, -2 }, /* (211) from_db_opt ::= FROM db_name */ + { 281, -1 }, /* (212) func_name_list ::= func_name */ + { 281, -3 }, /* (213) func_name_list ::= func_name_list NK_COMMA func_name */ + { 288, -1 }, /* (214) func_name ::= function_name */ + { 240, -8 }, /* (215) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ + { 240, -10 }, /* (216) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ + { 240, -6 }, /* (217) cmd ::= DROP INDEX exists_opt index_name ON table_name */ + { 291, 0 }, /* (218) index_options ::= */ + { 291, -9 }, /* (219) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ + { 291, -11 }, /* (220) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ + { 292, -1 }, /* (221) func_list ::= func */ + { 292, -3 }, /* (222) func_list ::= func_list NK_COMMA func */ + { 295, -4 }, /* (223) func ::= function_name NK_LP expression_list NK_RP */ + { 240, -7 }, /* (224) cmd ::= CREATE TOPIC not_exists_opt topic_name topic_options AS query_expression */ + { 240, -7 }, /* (225) cmd ::= CREATE TOPIC not_exists_opt topic_name topic_options AS db_name */ + { 240, -4 }, /* (226) cmd ::= DROP TOPIC exists_opt topic_name */ + { 240, -6 }, /* (227) cmd ::= DROP CGROUP exists_opt cgroup_name ON topic_name */ + { 298, 0 }, /* (228) topic_options ::= */ + { 298, -3 }, /* (229) topic_options ::= topic_options WITH TABLE */ + { 298, -3 }, /* (230) topic_options ::= topic_options WITH SCHEMA */ + { 298, -3 }, /* (231) topic_options ::= topic_options WITH TAG */ + { 240, -2 }, /* (232) cmd ::= DESC full_table_name */ + { 240, -2 }, /* (233) cmd ::= DESCRIBE full_table_name */ + { 240, -3 }, /* (234) cmd ::= RESET QUERY CACHE */ + { 240, -4 }, /* (235) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ + { 301, 0 }, /* (236) analyze_opt ::= */ + { 301, -1 }, /* (237) analyze_opt ::= ANALYZE */ + { 302, 0 }, /* (238) explain_options ::= */ + { 302, -3 }, /* (239) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 302, -3 }, /* (240) explain_options ::= explain_options RATIO NK_FLOAT */ + { 240, -6 }, /* (241) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ + { 240, -10 }, /* (242) cmd ::= CREATE agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + { 240, -4 }, /* (243) cmd ::= DROP FUNCTION exists_opt function_name */ + { 303, 0 }, /* (244) agg_func_opt ::= */ + { 303, -1 }, /* (245) agg_func_opt ::= AGGREGATE */ + { 304, 0 }, /* (246) bufsize_opt ::= */ + { 304, -2 }, /* (247) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 240, -8 }, /* (248) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ + { 240, -4 }, /* (249) cmd ::= DROP STREAM exists_opt stream_name */ + { 307, 0 }, /* (250) into_opt ::= */ + { 307, -2 }, /* (251) into_opt ::= INTO full_table_name */ + { 306, 0 }, /* (252) stream_options ::= */ + { 306, -3 }, /* (253) stream_options ::= stream_options TRIGGER AT_ONCE */ + { 306, -3 }, /* (254) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + { 306, -3 }, /* (255) stream_options ::= stream_options WATERMARK duration_literal */ + { 240, -3 }, /* (256) cmd ::= KILL CONNECTION NK_INTEGER */ + { 240, -3 }, /* (257) cmd ::= KILL QUERY NK_INTEGER */ + { 240, -3 }, /* (258) cmd ::= KILL TRANSACTION NK_INTEGER */ + { 240, -4 }, /* (259) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 240, -4 }, /* (260) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 240, -3 }, /* (261) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 308, -2 }, /* (262) dnode_list ::= DNODE NK_INTEGER */ + { 308, -3 }, /* (263) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 240, -3 }, /* (264) cmd ::= SYNCDB db_name REPLICA */ + { 240, -1 }, /* (265) cmd ::= query_expression */ + { 243, -1 }, /* (266) literal ::= NK_INTEGER */ + { 243, -1 }, /* (267) literal ::= NK_FLOAT */ + { 243, -1 }, /* (268) literal ::= NK_STRING */ + { 243, -1 }, /* (269) literal ::= NK_BOOL */ + { 243, -2 }, /* (270) literal ::= TIMESTAMP NK_STRING */ + { 243, -1 }, /* (271) literal ::= duration_literal */ + { 243, -1 }, /* (272) literal ::= NULL */ + { 243, -1 }, /* (273) literal ::= NK_QUESTION */ + { 293, -1 }, /* (274) duration_literal ::= NK_VARIABLE */ + { 309, -1 }, /* (275) signed ::= NK_INTEGER */ + { 309, -2 }, /* (276) signed ::= NK_PLUS NK_INTEGER */ + { 309, -2 }, /* (277) signed ::= NK_MINUS NK_INTEGER */ + { 309, -1 }, /* (278) signed ::= NK_FLOAT */ + { 309, -2 }, /* (279) signed ::= NK_PLUS NK_FLOAT */ + { 309, -2 }, /* (280) signed ::= NK_MINUS NK_FLOAT */ + { 273, -1 }, /* (281) signed_literal ::= signed */ + { 273, -1 }, /* (282) signed_literal ::= NK_STRING */ + { 273, -1 }, /* (283) signed_literal ::= NK_BOOL */ + { 273, -2 }, /* (284) signed_literal ::= TIMESTAMP NK_STRING */ + { 273, -1 }, /* (285) signed_literal ::= duration_literal */ + { 273, -1 }, /* (286) signed_literal ::= NULL */ + { 273, -1 }, /* (287) signed_literal ::= literal_func */ + { 276, -1 }, /* (288) literal_list ::= signed_literal */ + { 276, -3 }, /* (289) literal_list ::= literal_list NK_COMMA signed_literal */ + { 250, -1 }, /* (290) db_name ::= NK_ID */ + { 279, -1 }, /* (291) table_name ::= NK_ID */ + { 271, -1 }, /* (292) column_name ::= NK_ID */ + { 289, -1 }, /* (293) function_name ::= NK_ID */ + { 311, -1 }, /* (294) table_alias ::= NK_ID */ + { 312, -1 }, /* (295) column_alias ::= NK_ID */ + { 245, -1 }, /* (296) user_name ::= NK_ID */ + { 290, -1 }, /* (297) index_name ::= NK_ID */ + { 297, -1 }, /* (298) topic_name ::= NK_ID */ + { 305, -1 }, /* (299) stream_name ::= NK_ID */ + { 300, -1 }, /* (300) cgroup_name ::= NK_ID */ + { 313, -1 }, /* (301) expression ::= literal */ + { 313, -1 }, /* (302) expression ::= pseudo_column */ + { 313, -1 }, /* (303) expression ::= column_reference */ + { 313, -1 }, /* (304) expression ::= function_expression */ + { 313, -1 }, /* (305) expression ::= subquery */ + { 313, -3 }, /* (306) expression ::= NK_LP expression NK_RP */ + { 313, -2 }, /* (307) expression ::= NK_PLUS expression */ + { 313, -2 }, /* (308) expression ::= NK_MINUS expression */ + { 313, -3 }, /* (309) expression ::= expression NK_PLUS expression */ + { 313, -3 }, /* (310) expression ::= expression NK_MINUS expression */ + { 313, -3 }, /* (311) expression ::= expression NK_STAR expression */ + { 313, -3 }, /* (312) expression ::= expression NK_SLASH expression */ + { 313, -3 }, /* (313) expression ::= expression NK_REM expression */ + { 313, -3 }, /* (314) expression ::= column_reference NK_ARROW NK_STRING */ + { 296, -1 }, /* (315) expression_list ::= expression */ + { 296, -3 }, /* (316) expression_list ::= expression_list NK_COMMA expression */ + { 315, -1 }, /* (317) column_reference ::= column_name */ + { 315, -3 }, /* (318) column_reference ::= table_name NK_DOT column_name */ + { 314, -1 }, /* (319) pseudo_column ::= ROWTS */ + { 314, -1 }, /* (320) pseudo_column ::= TBNAME */ + { 314, -3 }, /* (321) pseudo_column ::= table_name NK_DOT TBNAME */ + { 314, -1 }, /* (322) pseudo_column ::= QSTARTTS */ + { 314, -1 }, /* (323) pseudo_column ::= QENDTS */ + { 314, -1 }, /* (324) pseudo_column ::= WSTARTTS */ + { 314, -1 }, /* (325) pseudo_column ::= WENDTS */ + { 314, -1 }, /* (326) pseudo_column ::= WDURATION */ + { 316, -4 }, /* (327) function_expression ::= function_name NK_LP expression_list NK_RP */ + { 316, -4 }, /* (328) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + { 316, -6 }, /* (329) function_expression ::= CAST NK_LP expression AS type_name NK_RP */ + { 316, -1 }, /* (330) function_expression ::= literal_func */ + { 310, -3 }, /* (331) literal_func ::= noarg_func NK_LP NK_RP */ + { 310, -1 }, /* (332) literal_func ::= NOW */ + { 320, -1 }, /* (333) noarg_func ::= NOW */ + { 320, -1 }, /* (334) noarg_func ::= TODAY */ + { 320, -1 }, /* (335) noarg_func ::= TIMEZONE */ + { 318, -1 }, /* (336) star_func ::= COUNT */ + { 318, -1 }, /* (337) star_func ::= FIRST */ + { 318, -1 }, /* (338) star_func ::= LAST */ + { 318, -1 }, /* (339) star_func ::= LAST_ROW */ + { 319, -1 }, /* (340) star_func_para_list ::= NK_STAR */ + { 319, -1 }, /* (341) star_func_para_list ::= other_para_list */ + { 321, -1 }, /* (342) other_para_list ::= star_func_para */ + { 321, -3 }, /* (343) other_para_list ::= other_para_list NK_COMMA star_func_para */ + { 322, -1 }, /* (344) star_func_para ::= expression */ + { 322, -3 }, /* (345) star_func_para ::= table_name NK_DOT NK_STAR */ + { 323, -3 }, /* (346) predicate ::= expression compare_op expression */ + { 323, -5 }, /* (347) predicate ::= expression BETWEEN expression AND expression */ + { 323, -6 }, /* (348) predicate ::= expression NOT BETWEEN expression AND expression */ + { 323, -3 }, /* (349) predicate ::= expression IS NULL */ + { 323, -4 }, /* (350) predicate ::= expression IS NOT NULL */ + { 323, -3 }, /* (351) predicate ::= expression in_op in_predicate_value */ + { 324, -1 }, /* (352) compare_op ::= NK_LT */ + { 324, -1 }, /* (353) compare_op ::= NK_GT */ + { 324, -1 }, /* (354) compare_op ::= NK_LE */ + { 324, -1 }, /* (355) compare_op ::= NK_GE */ + { 324, -1 }, /* (356) compare_op ::= NK_NE */ + { 324, -1 }, /* (357) compare_op ::= NK_EQ */ + { 324, -1 }, /* (358) compare_op ::= LIKE */ + { 324, -2 }, /* (359) compare_op ::= NOT LIKE */ + { 324, -1 }, /* (360) compare_op ::= MATCH */ + { 324, -1 }, /* (361) compare_op ::= NMATCH */ + { 324, -1 }, /* (362) compare_op ::= CONTAINS */ + { 325, -1 }, /* (363) in_op ::= IN */ + { 325, -2 }, /* (364) in_op ::= NOT IN */ + { 326, -3 }, /* (365) in_predicate_value ::= NK_LP expression_list NK_RP */ + { 327, -1 }, /* (366) boolean_value_expression ::= boolean_primary */ + { 327, -2 }, /* (367) boolean_value_expression ::= NOT boolean_primary */ + { 327, -3 }, /* (368) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 327, -3 }, /* (369) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 328, -1 }, /* (370) boolean_primary ::= predicate */ + { 328, -3 }, /* (371) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 329, -1 }, /* (372) common_expression ::= expression */ + { 329, -1 }, /* (373) common_expression ::= boolean_value_expression */ + { 330, -2 }, /* (374) from_clause ::= FROM table_reference_list */ + { 331, -1 }, /* (375) table_reference_list ::= table_reference */ + { 331, -3 }, /* (376) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 332, -1 }, /* (377) table_reference ::= table_primary */ + { 332, -1 }, /* (378) table_reference ::= joined_table */ + { 333, -2 }, /* (379) table_primary ::= table_name alias_opt */ + { 333, -4 }, /* (380) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 333, -2 }, /* (381) table_primary ::= subquery alias_opt */ + { 333, -1 }, /* (382) table_primary ::= parenthesized_joined_table */ + { 335, 0 }, /* (383) alias_opt ::= */ + { 335, -1 }, /* (384) alias_opt ::= table_alias */ + { 335, -2 }, /* (385) alias_opt ::= AS table_alias */ + { 336, -3 }, /* (386) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 336, -3 }, /* (387) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 334, -6 }, /* (388) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 337, 0 }, /* (389) join_type ::= */ + { 337, -1 }, /* (390) join_type ::= INNER */ + { 339, -9 }, /* (391) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + { 340, 0 }, /* (392) set_quantifier_opt ::= */ + { 340, -1 }, /* (393) set_quantifier_opt ::= DISTINCT */ + { 340, -1 }, /* (394) set_quantifier_opt ::= ALL */ + { 341, -1 }, /* (395) select_list ::= NK_STAR */ + { 341, -1 }, /* (396) select_list ::= select_sublist */ + { 347, -1 }, /* (397) select_sublist ::= select_item */ + { 347, -3 }, /* (398) select_sublist ::= select_sublist NK_COMMA select_item */ + { 348, -1 }, /* (399) select_item ::= common_expression */ + { 348, -2 }, /* (400) select_item ::= common_expression column_alias */ + { 348, -3 }, /* (401) select_item ::= common_expression AS column_alias */ + { 348, -3 }, /* (402) select_item ::= table_name NK_DOT NK_STAR */ + { 342, 0 }, /* (403) where_clause_opt ::= */ + { 342, -2 }, /* (404) where_clause_opt ::= WHERE search_condition */ + { 343, 0 }, /* (405) partition_by_clause_opt ::= */ + { 343, -3 }, /* (406) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 344, 0 }, /* (407) twindow_clause_opt ::= */ + { 344, -6 }, /* (408) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 344, -4 }, /* (409) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ + { 344, -6 }, /* (410) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 344, -8 }, /* (411) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 294, 0 }, /* (412) sliding_opt ::= */ + { 294, -4 }, /* (413) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 349, 0 }, /* (414) fill_opt ::= */ + { 349, -4 }, /* (415) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 349, -6 }, /* (416) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 350, -1 }, /* (417) fill_mode ::= NONE */ + { 350, -1 }, /* (418) fill_mode ::= PREV */ + { 350, -1 }, /* (419) fill_mode ::= NULL */ + { 350, -1 }, /* (420) fill_mode ::= LINEAR */ + { 350, -1 }, /* (421) fill_mode ::= NEXT */ + { 345, 0 }, /* (422) group_by_clause_opt ::= */ + { 345, -3 }, /* (423) group_by_clause_opt ::= GROUP BY group_by_list */ + { 351, -1 }, /* (424) group_by_list ::= expression */ + { 351, -3 }, /* (425) group_by_list ::= group_by_list NK_COMMA expression */ + { 346, 0 }, /* (426) having_clause_opt ::= */ + { 346, -2 }, /* (427) having_clause_opt ::= HAVING search_condition */ + { 299, -4 }, /* (428) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 352, -1 }, /* (429) query_expression_body ::= query_primary */ + { 352, -4 }, /* (430) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 352, -3 }, /* (431) query_expression_body ::= query_expression_body UNION query_expression_body */ + { 356, -1 }, /* (432) query_primary ::= query_specification */ + { 356, -6 }, /* (433) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ + { 353, 0 }, /* (434) order_by_clause_opt ::= */ + { 353, -3 }, /* (435) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 354, 0 }, /* (436) slimit_clause_opt ::= */ + { 354, -2 }, /* (437) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 354, -4 }, /* (438) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 354, -4 }, /* (439) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 355, 0 }, /* (440) limit_clause_opt ::= */ + { 355, -2 }, /* (441) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 355, -4 }, /* (442) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 355, -4 }, /* (443) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 317, -3 }, /* (444) subquery ::= NK_LP query_expression NK_RP */ + { 338, -1 }, /* (445) search_condition ::= common_expression */ + { 357, -1 }, /* (446) sort_specification_list ::= sort_specification */ + { 357, -3 }, /* (447) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 358, -3 }, /* (448) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 359, 0 }, /* (449) ordering_specification_opt ::= */ + { 359, -1 }, /* (450) ordering_specification_opt ::= ASC */ + { 359, -1 }, /* (451) ordering_specification_opt ::= DESC */ + { 360, 0 }, /* (452) null_ordering_opt ::= */ + { 360, -2 }, /* (453) null_ordering_opt ::= NULLS FIRST */ + { 360, -2 }, /* (454) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3099,11 +3114,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,239,&yymsp[0].minor); + yy_destructor(yypParser,241,&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,240,&yymsp[0].minor); + yy_destructor(yypParser,242,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -3117,20 +3132,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,239,&yymsp[-2].minor); +{ yy_destructor(yypParser,241,&yymsp[-2].minor); { } - yy_destructor(yypParser,241,&yymsp[0].minor); + yy_destructor(yypParser,243,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,242,&yymsp[0].minor); +{ yy_destructor(yypParser,244,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,240,&yymsp[-1].minor); +{ yy_destructor(yypParser,242,&yymsp[-1].minor); { } - yy_destructor(yypParser,242,&yymsp[0].minor); + yy_destructor(yypParser,244,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -3144,63 +3159,63 @@ 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,241,&yymsp[0].minor); + yy_destructor(yypParser,243,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy105, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy53, &yymsp[0].minor.yy0); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy105, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy53, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; case 26: /* cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy105, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy53, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } break; case 27: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy105); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy53); } break; case 28: /* cmd ::= GRANT privileges ON priv_level TO user_name */ -{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy593, &yymsp[-2].minor.yy105, &yymsp[0].minor.yy105); } +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-4].minor.yy435, &yymsp[-2].minor.yy53, &yymsp[0].minor.yy53); } break; case 29: /* cmd ::= REVOKE privileges ON priv_level FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy593, &yymsp[-2].minor.yy105, &yymsp[0].minor.yy105); } +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-4].minor.yy435, &yymsp[-2].minor.yy53, &yymsp[0].minor.yy53); } break; case 30: /* privileges ::= ALL */ -{ yymsp[0].minor.yy593 = PRIVILEGE_TYPE_ALL; } +{ yymsp[0].minor.yy435 = PRIVILEGE_TYPE_ALL; } break; case 31: /* privileges ::= priv_type_list */ case 32: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==32); -{ yylhsminor.yy593 = yymsp[0].minor.yy593; } - yymsp[0].minor.yy593 = yylhsminor.yy593; +{ yylhsminor.yy435 = yymsp[0].minor.yy435; } + yymsp[0].minor.yy435 = yylhsminor.yy435; break; case 33: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy593 = yymsp[-2].minor.yy593 | yymsp[0].minor.yy593; } - yymsp[-2].minor.yy593 = yylhsminor.yy593; +{ yylhsminor.yy435 = yymsp[-2].minor.yy435 | yymsp[0].minor.yy435; } + yymsp[-2].minor.yy435 = yylhsminor.yy435; break; case 34: /* priv_type ::= READ */ -{ yymsp[0].minor.yy593 = PRIVILEGE_TYPE_READ; } +{ yymsp[0].minor.yy435 = PRIVILEGE_TYPE_READ; } break; case 35: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy593 = PRIVILEGE_TYPE_WRITE; } +{ yymsp[0].minor.yy435 = PRIVILEGE_TYPE_WRITE; } break; case 36: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy105 = yymsp[-2].minor.yy0; } - yymsp[-2].minor.yy105 = yylhsminor.yy105; +{ yylhsminor.yy53 = yymsp[-2].minor.yy0; } + yymsp[-2].minor.yy53 = yylhsminor.yy53; break; case 37: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy105 = yymsp[-2].minor.yy105; } - yymsp[-2].minor.yy105 = yylhsminor.yy105; +{ yylhsminor.yy53 = yymsp[-2].minor.yy53; } + yymsp[-2].minor.yy53 = yylhsminor.yy53; break; case 38: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy105, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy53, NULL); } break; case 39: /* cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy105, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy53, &yymsp[0].minor.yy0); } break; case 40: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; case 41: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy105); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy53); } break; case 42: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -3217,25 +3232,26 @@ static YYACTIONTYPE yy_reduce( case 46: /* dnode_endpoint ::= NK_STRING */ case 47: /* dnode_host_name ::= NK_ID */ yytestcase(yyruleno==47); case 48: /* dnode_host_name ::= NK_IPTOKEN */ yytestcase(yyruleno==48); - case 288: /* db_name ::= NK_ID */ yytestcase(yyruleno==288); - case 289: /* table_name ::= NK_ID */ yytestcase(yyruleno==289); - case 290: /* column_name ::= NK_ID */ yytestcase(yyruleno==290); - case 291: /* function_name ::= NK_ID */ yytestcase(yyruleno==291); - case 292: /* table_alias ::= NK_ID */ yytestcase(yyruleno==292); - case 293: /* column_alias ::= NK_ID */ yytestcase(yyruleno==293); - case 294: /* user_name ::= NK_ID */ yytestcase(yyruleno==294); - case 295: /* index_name ::= NK_ID */ yytestcase(yyruleno==295); - case 296: /* topic_name ::= NK_ID */ yytestcase(yyruleno==296); - case 297: /* stream_name ::= NK_ID */ yytestcase(yyruleno==297); - case 330: /* noarg_func ::= NOW */ yytestcase(yyruleno==330); - case 331: /* noarg_func ::= TODAY */ yytestcase(yyruleno==331); - case 332: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==332); - case 333: /* star_func ::= COUNT */ yytestcase(yyruleno==333); - case 334: /* star_func ::= FIRST */ yytestcase(yyruleno==334); - case 335: /* star_func ::= LAST */ yytestcase(yyruleno==335); - case 336: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==336); -{ yylhsminor.yy105 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy105 = yylhsminor.yy105; + case 290: /* db_name ::= NK_ID */ yytestcase(yyruleno==290); + case 291: /* table_name ::= NK_ID */ yytestcase(yyruleno==291); + case 292: /* column_name ::= NK_ID */ yytestcase(yyruleno==292); + case 293: /* function_name ::= NK_ID */ yytestcase(yyruleno==293); + case 294: /* table_alias ::= NK_ID */ yytestcase(yyruleno==294); + case 295: /* column_alias ::= NK_ID */ yytestcase(yyruleno==295); + case 296: /* user_name ::= NK_ID */ yytestcase(yyruleno==296); + case 297: /* index_name ::= NK_ID */ yytestcase(yyruleno==297); + case 298: /* topic_name ::= NK_ID */ yytestcase(yyruleno==298); + case 299: /* stream_name ::= NK_ID */ yytestcase(yyruleno==299); + case 300: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==300); + case 333: /* noarg_func ::= NOW */ yytestcase(yyruleno==333); + case 334: /* noarg_func ::= TODAY */ yytestcase(yyruleno==334); + case 335: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==335); + case 336: /* star_func ::= COUNT */ yytestcase(yyruleno==336); + case 337: /* star_func ::= FIRST */ yytestcase(yyruleno==337); + case 338: /* star_func ::= LAST */ yytestcase(yyruleno==338); + case 339: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==339); +{ yylhsminor.yy53 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy53 = yylhsminor.yy53; break; case 49: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -3268,1154 +3284,1161 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } break; case 59: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy617, &yymsp[-1].minor.yy105, yymsp[0].minor.yy172); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy603, &yymsp[-1].minor.yy53, yymsp[0].minor.yy636); } break; case 60: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy617, &yymsp[0].minor.yy105); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy603, &yymsp[0].minor.yy53); } break; case 61: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy105); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy53); } break; case 62: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy105, yymsp[0].minor.yy172); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy53, yymsp[0].minor.yy636); } break; case 63: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy617 = true; } +{ yymsp[-2].minor.yy603 = true; } break; case 64: /* not_exists_opt ::= */ case 66: /* exists_opt ::= */ yytestcase(yyruleno==66); - case 234: /* analyze_opt ::= */ yytestcase(yyruleno==234); - case 242: /* agg_func_opt ::= */ yytestcase(yyruleno==242); - case 389: /* set_quantifier_opt ::= */ yytestcase(yyruleno==389); -{ yymsp[1].minor.yy617 = false; } + case 236: /* analyze_opt ::= */ yytestcase(yyruleno==236); + case 244: /* agg_func_opt ::= */ yytestcase(yyruleno==244); + case 392: /* set_quantifier_opt ::= */ yytestcase(yyruleno==392); +{ yymsp[1].minor.yy603 = false; } break; case 65: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy617 = true; } +{ yymsp[-1].minor.yy603 = true; } break; case 67: /* db_options ::= */ -{ yymsp[1].minor.yy172 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy636 = createDefaultDatabaseOptions(pCxt); } break; case 68: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy172 = setDatabaseOption(pCxt, yymsp[-2].minor.yy172, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; +{ yylhsminor.yy636 = setDatabaseOption(pCxt, yymsp[-2].minor.yy636, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; case 69: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ yylhsminor.yy172 = setDatabaseOption(pCxt, yymsp[-2].minor.yy172, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; +{ yylhsminor.yy636 = setDatabaseOption(pCxt, yymsp[-2].minor.yy636, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; case 70: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy172 = setDatabaseOption(pCxt, yymsp[-2].minor.yy172, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; +{ yylhsminor.yy636 = setDatabaseOption(pCxt, yymsp[-2].minor.yy636, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; case 71: /* db_options ::= db_options DAYS NK_INTEGER */ case 72: /* db_options ::= db_options DAYS NK_VARIABLE */ yytestcase(yyruleno==72); -{ yylhsminor.yy172 = setDatabaseOption(pCxt, yymsp[-2].minor.yy172, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; +{ yylhsminor.yy636 = setDatabaseOption(pCxt, yymsp[-2].minor.yy636, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; case 73: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ yylhsminor.yy172 = setDatabaseOption(pCxt, yymsp[-2].minor.yy172, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; +{ yylhsminor.yy636 = setDatabaseOption(pCxt, yymsp[-2].minor.yy636, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; case 74: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy172 = setDatabaseOption(pCxt, yymsp[-2].minor.yy172, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; +{ yylhsminor.yy636 = setDatabaseOption(pCxt, yymsp[-2].minor.yy636, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; case 75: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy172 = setDatabaseOption(pCxt, yymsp[-2].minor.yy172, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; +{ yylhsminor.yy636 = setDatabaseOption(pCxt, yymsp[-2].minor.yy636, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; case 76: /* db_options ::= db_options KEEP integer_list */ case 77: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==77); -{ yylhsminor.yy172 = setDatabaseOption(pCxt, yymsp[-2].minor.yy172, DB_OPTION_KEEP, yymsp[0].minor.yy60); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; +{ yylhsminor.yy636 = setDatabaseOption(pCxt, yymsp[-2].minor.yy636, DB_OPTION_KEEP, yymsp[0].minor.yy236); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; case 78: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy172 = setDatabaseOption(pCxt, yymsp[-2].minor.yy172, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; +{ yylhsminor.yy636 = setDatabaseOption(pCxt, yymsp[-2].minor.yy636, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; case 79: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy172 = setDatabaseOption(pCxt, yymsp[-2].minor.yy172, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; +{ yylhsminor.yy636 = setDatabaseOption(pCxt, yymsp[-2].minor.yy636, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; case 80: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy172 = setDatabaseOption(pCxt, yymsp[-2].minor.yy172, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; +{ yylhsminor.yy636 = setDatabaseOption(pCxt, yymsp[-2].minor.yy636, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; case 81: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy172 = setDatabaseOption(pCxt, yymsp[-2].minor.yy172, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; +{ yylhsminor.yy636 = setDatabaseOption(pCxt, yymsp[-2].minor.yy636, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; case 82: /* db_options ::= db_options STRICT NK_INTEGER */ -{ yylhsminor.yy172 = setDatabaseOption(pCxt, yymsp[-2].minor.yy172, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; +{ yylhsminor.yy636 = setDatabaseOption(pCxt, yymsp[-2].minor.yy636, DB_OPTION_STRICT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; case 83: /* db_options ::= db_options WAL NK_INTEGER */ -{ yylhsminor.yy172 = setDatabaseOption(pCxt, yymsp[-2].minor.yy172, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; +{ yylhsminor.yy636 = setDatabaseOption(pCxt, yymsp[-2].minor.yy636, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; case 84: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy172 = setDatabaseOption(pCxt, yymsp[-2].minor.yy172, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; +{ yylhsminor.yy636 = setDatabaseOption(pCxt, yymsp[-2].minor.yy636, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; case 85: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy172 = setDatabaseOption(pCxt, yymsp[-2].minor.yy172, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; +{ yylhsminor.yy636 = setDatabaseOption(pCxt, yymsp[-2].minor.yy636, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; case 86: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy172 = setDatabaseOption(pCxt, yymsp[-2].minor.yy172, DB_OPTION_RETENTIONS, yymsp[0].minor.yy60); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; - break; - case 87: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy172 = createAlterDatabaseOptions(pCxt); yylhsminor.yy172 = setAlterDatabaseOption(pCxt, yylhsminor.yy172, &yymsp[0].minor.yy609); } - yymsp[0].minor.yy172 = yylhsminor.yy172; - break; - case 88: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy172 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy172, &yymsp[0].minor.yy609); } - yymsp[-1].minor.yy172 = yylhsminor.yy172; - break; - case 89: /* alter_db_option ::= BUFFER NK_INTEGER */ -{ yymsp[-1].minor.yy609.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy609.val = yymsp[0].minor.yy0; } - break; - case 90: /* alter_db_option ::= CACHELAST NK_INTEGER */ -{ yymsp[-1].minor.yy609.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy609.val = yymsp[0].minor.yy0; } - break; - case 91: /* alter_db_option ::= FSYNC NK_INTEGER */ -{ yymsp[-1].minor.yy609.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy609.val = yymsp[0].minor.yy0; } - break; - case 92: /* alter_db_option ::= KEEP integer_list */ - case 93: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==93); -{ yymsp[-1].minor.yy609.type = DB_OPTION_KEEP; yymsp[-1].minor.yy609.pList = yymsp[0].minor.yy60; } - break; - case 94: /* alter_db_option ::= PAGES NK_INTEGER */ -{ yymsp[-1].minor.yy609.type = DB_OPTION_PAGES; yymsp[-1].minor.yy609.val = yymsp[0].minor.yy0; } - break; - case 95: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy609.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy609.val = yymsp[0].minor.yy0; } - break; - case 96: /* alter_db_option ::= STRICT NK_INTEGER */ -{ yymsp[-1].minor.yy609.type = DB_OPTION_STRICT; yymsp[-1].minor.yy609.val = yymsp[0].minor.yy0; } - break; - case 97: /* alter_db_option ::= WAL NK_INTEGER */ -{ yymsp[-1].minor.yy609.type = DB_OPTION_WAL; yymsp[-1].minor.yy609.val = yymsp[0].minor.yy0; } - break; - case 98: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy60 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy60 = yylhsminor.yy60; - break; - case 99: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 261: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==261); -{ yylhsminor.yy60 = addNodeToList(pCxt, yymsp[-2].minor.yy60, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy60 = yylhsminor.yy60; - break; - case 100: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy60 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy60 = yylhsminor.yy60; - break; - case 101: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy60 = addNodeToList(pCxt, yymsp[-2].minor.yy60, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy60 = yylhsminor.yy60; - break; - case 102: /* retention_list ::= retention */ - case 122: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==122); - case 125: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==125); - case 132: /* column_def_list ::= column_def */ yytestcase(yyruleno==132); - case 173: /* col_name_list ::= col_name */ yytestcase(yyruleno==173); - case 211: /* func_name_list ::= func_name */ yytestcase(yyruleno==211); - case 220: /* func_list ::= func */ yytestcase(yyruleno==220); - case 286: /* literal_list ::= signed_literal */ yytestcase(yyruleno==286); - case 339: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==339); - case 394: /* select_sublist ::= select_item */ yytestcase(yyruleno==394); - case 443: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==443); -{ yylhsminor.yy60 = createNodeList(pCxt, yymsp[0].minor.yy172); } - yymsp[0].minor.yy60 = yylhsminor.yy60; - break; - case 103: /* retention_list ::= retention_list NK_COMMA retention */ - case 133: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==133); - case 174: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==174); - case 212: /* func_name_list ::= func_name_list NK_COMMA func_name */ yytestcase(yyruleno==212); - case 221: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==221); - case 287: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==287); - case 340: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==340); - case 395: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==395); - case 444: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==444); -{ yylhsminor.yy60 = addNodeToList(pCxt, yymsp[-2].minor.yy60, yymsp[0].minor.yy172); } - yymsp[-2].minor.yy60 = yylhsminor.yy60; - break; - case 104: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ -{ yylhsminor.yy172 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; - break; - case 105: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - case 107: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==107); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy617, yymsp[-5].minor.yy172, yymsp[-3].minor.yy60, yymsp[-1].minor.yy60, yymsp[0].minor.yy172); } - break; - case 106: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy60); } - break; - case 108: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy60); } - break; - case 109: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy617, yymsp[0].minor.yy172); } - break; - case 110: /* cmd ::= ALTER TABLE alter_table_clause */ - case 111: /* cmd ::= ALTER STABLE alter_table_clause */ yytestcase(yyruleno==111); - case 263: /* cmd ::= query_expression */ yytestcase(yyruleno==263); -{ pCxt->pRootNode = yymsp[0].minor.yy172; } - break; - case 112: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy172 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy172, yymsp[0].minor.yy172); } - yymsp[-1].minor.yy172 = yylhsminor.yy172; - break; - case 113: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy172 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy172, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy105, yymsp[0].minor.yy248); } - yymsp[-4].minor.yy172 = yylhsminor.yy172; - break; - case 114: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy172 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy172, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy105); } - yymsp[-3].minor.yy172 = yylhsminor.yy172; - break; - case 115: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy172 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy172, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy105, yymsp[0].minor.yy248); } - yymsp[-4].minor.yy172 = yylhsminor.yy172; +{ yylhsminor.yy636 = setDatabaseOption(pCxt, yymsp[-2].minor.yy636, DB_OPTION_RETENTIONS, yymsp[0].minor.yy236); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; + break; + case 87: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ +{ yylhsminor.yy636 = setDatabaseOption(pCxt, yymsp[-2].minor.yy636, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; + break; + case 88: /* alter_db_options ::= alter_db_option */ +{ yylhsminor.yy636 = createAlterDatabaseOptions(pCxt); yylhsminor.yy636 = setAlterDatabaseOption(pCxt, yylhsminor.yy636, &yymsp[0].minor.yy25); } + yymsp[0].minor.yy636 = yylhsminor.yy636; + break; + case 89: /* alter_db_options ::= alter_db_options alter_db_option */ +{ yylhsminor.yy636 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy636, &yymsp[0].minor.yy25); } + yymsp[-1].minor.yy636 = yylhsminor.yy636; + break; + case 90: /* alter_db_option ::= BUFFER NK_INTEGER */ +{ yymsp[-1].minor.yy25.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy25.val = yymsp[0].minor.yy0; } + break; + case 91: /* alter_db_option ::= CACHELAST NK_INTEGER */ +{ yymsp[-1].minor.yy25.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy25.val = yymsp[0].minor.yy0; } + break; + case 92: /* alter_db_option ::= FSYNC NK_INTEGER */ +{ yymsp[-1].minor.yy25.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy25.val = yymsp[0].minor.yy0; } + break; + case 93: /* alter_db_option ::= KEEP integer_list */ + case 94: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==94); +{ yymsp[-1].minor.yy25.type = DB_OPTION_KEEP; yymsp[-1].minor.yy25.pList = yymsp[0].minor.yy236; } + break; + case 95: /* alter_db_option ::= PAGES NK_INTEGER */ +{ yymsp[-1].minor.yy25.type = DB_OPTION_PAGES; yymsp[-1].minor.yy25.val = yymsp[0].minor.yy0; } + break; + case 96: /* alter_db_option ::= REPLICA NK_INTEGER */ +{ yymsp[-1].minor.yy25.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy25.val = yymsp[0].minor.yy0; } + break; + case 97: /* alter_db_option ::= STRICT NK_INTEGER */ +{ yymsp[-1].minor.yy25.type = DB_OPTION_STRICT; yymsp[-1].minor.yy25.val = yymsp[0].minor.yy0; } + break; + case 98: /* alter_db_option ::= WAL NK_INTEGER */ +{ yymsp[-1].minor.yy25.type = DB_OPTION_WAL; yymsp[-1].minor.yy25.val = yymsp[0].minor.yy0; } + break; + case 99: /* integer_list ::= NK_INTEGER */ +{ yylhsminor.yy236 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy236 = yylhsminor.yy236; + break; + case 100: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ + case 263: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==263); +{ yylhsminor.yy236 = addNodeToList(pCxt, yymsp[-2].minor.yy236, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy236 = yylhsminor.yy236; + break; + case 101: /* variable_list ::= NK_VARIABLE */ +{ yylhsminor.yy236 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy236 = yylhsminor.yy236; + break; + case 102: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ +{ yylhsminor.yy236 = addNodeToList(pCxt, yymsp[-2].minor.yy236, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy236 = yylhsminor.yy236; + break; + case 103: /* retention_list ::= retention */ + case 123: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==123); + case 126: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==126); + case 133: /* column_def_list ::= column_def */ yytestcase(yyruleno==133); + case 174: /* col_name_list ::= col_name */ yytestcase(yyruleno==174); + case 212: /* func_name_list ::= func_name */ yytestcase(yyruleno==212); + case 221: /* func_list ::= func */ yytestcase(yyruleno==221); + case 288: /* literal_list ::= signed_literal */ yytestcase(yyruleno==288); + case 342: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==342); + case 397: /* select_sublist ::= select_item */ yytestcase(yyruleno==397); + case 446: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==446); +{ yylhsminor.yy236 = createNodeList(pCxt, yymsp[0].minor.yy636); } + yymsp[0].minor.yy236 = yylhsminor.yy236; + break; + case 104: /* retention_list ::= retention_list NK_COMMA retention */ + case 134: /* column_def_list ::= column_def_list NK_COMMA column_def */ yytestcase(yyruleno==134); + case 175: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==175); + case 213: /* func_name_list ::= func_name_list NK_COMMA func_name */ yytestcase(yyruleno==213); + case 222: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==222); + case 289: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==289); + case 343: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==343); + case 398: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==398); + case 447: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==447); +{ yylhsminor.yy236 = addNodeToList(pCxt, yymsp[-2].minor.yy236, yymsp[0].minor.yy636); } + yymsp[-2].minor.yy236 = yylhsminor.yy236; + break; + case 105: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ +{ yylhsminor.yy636 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; + break; + case 106: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + case 108: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==108); +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy603, yymsp[-5].minor.yy636, yymsp[-3].minor.yy236, yymsp[-1].minor.yy236, yymsp[0].minor.yy636); } + break; + case 107: /* cmd ::= CREATE TABLE multi_create_clause */ +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy236); } + break; + case 109: /* cmd ::= DROP TABLE multi_drop_clause */ +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy236); } + break; + case 110: /* cmd ::= DROP STABLE exists_opt full_table_name */ +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy603, yymsp[0].minor.yy636); } + break; + case 111: /* cmd ::= ALTER TABLE alter_table_clause */ + case 112: /* cmd ::= ALTER STABLE alter_table_clause */ yytestcase(yyruleno==112); + case 265: /* cmd ::= query_expression */ yytestcase(yyruleno==265); +{ pCxt->pRootNode = yymsp[0].minor.yy636; } + break; + case 113: /* alter_table_clause ::= full_table_name alter_table_options */ +{ yylhsminor.yy636 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy636, yymsp[0].minor.yy636); } + yymsp[-1].minor.yy636 = yylhsminor.yy636; + break; + case 114: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ +{ yylhsminor.yy636 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy636, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy53, yymsp[0].minor.yy450); } + yymsp[-4].minor.yy636 = yylhsminor.yy636; + break; + case 115: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ +{ yylhsminor.yy636 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy636, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy53); } + yymsp[-3].minor.yy636 = yylhsminor.yy636; + break; + case 116: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ +{ yylhsminor.yy636 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy636, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy53, yymsp[0].minor.yy450); } + yymsp[-4].minor.yy636 = yylhsminor.yy636; break; - case 116: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy172 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy172, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy105, &yymsp[0].minor.yy105); } - yymsp[-4].minor.yy172 = yylhsminor.yy172; - break; - case 117: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy172 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy172, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy105, yymsp[0].minor.yy248); } - yymsp[-4].minor.yy172 = yylhsminor.yy172; - break; - case 118: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy172 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy172, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy105); } - yymsp[-3].minor.yy172 = yylhsminor.yy172; + case 117: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ +{ yylhsminor.yy636 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy636, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy53, &yymsp[0].minor.yy53); } + yymsp[-4].minor.yy636 = yylhsminor.yy636; + break; + case 118: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ +{ yylhsminor.yy636 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy636, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy53, yymsp[0].minor.yy450); } + yymsp[-4].minor.yy636 = yylhsminor.yy636; + break; + case 119: /* alter_table_clause ::= full_table_name DROP TAG column_name */ +{ yylhsminor.yy636 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy636, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy53); } + yymsp[-3].minor.yy636 = yylhsminor.yy636; break; - case 119: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy172 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy172, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy105, yymsp[0].minor.yy248); } - yymsp[-4].minor.yy172 = yylhsminor.yy172; + case 120: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ +{ yylhsminor.yy636 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy636, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy53, yymsp[0].minor.yy450); } + yymsp[-4].minor.yy636 = yylhsminor.yy636; break; - case 120: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy172 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy172, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy105, &yymsp[0].minor.yy105); } - yymsp[-4].minor.yy172 = yylhsminor.yy172; - break; - case 121: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ -{ yylhsminor.yy172 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy172, &yymsp[-2].minor.yy105, yymsp[0].minor.yy172); } - yymsp[-5].minor.yy172 = yylhsminor.yy172; + case 121: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ +{ yylhsminor.yy636 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy636, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy53, &yymsp[0].minor.yy53); } + yymsp[-4].minor.yy636 = yylhsminor.yy636; + break; + case 122: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ signed_literal */ +{ yylhsminor.yy636 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy636, &yymsp[-2].minor.yy53, yymsp[0].minor.yy636); } + yymsp[-5].minor.yy636 = yylhsminor.yy636; break; - case 123: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 126: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==126); -{ yylhsminor.yy60 = addNodeToList(pCxt, yymsp[-1].minor.yy60, yymsp[0].minor.yy172); } - yymsp[-1].minor.yy60 = yylhsminor.yy60; + case 124: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ + case 127: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==127); +{ yylhsminor.yy236 = addNodeToList(pCxt, yymsp[-1].minor.yy236, yymsp[0].minor.yy636); } + yymsp[-1].minor.yy236 = yylhsminor.yy236; break; - case 124: /* 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.yy172 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy617, yymsp[-8].minor.yy172, yymsp[-6].minor.yy172, yymsp[-5].minor.yy60, yymsp[-2].minor.yy60, yymsp[0].minor.yy172); } - yymsp[-9].minor.yy172 = yylhsminor.yy172; + case 125: /* 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.yy636 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy603, yymsp[-8].minor.yy636, yymsp[-6].minor.yy636, yymsp[-5].minor.yy236, yymsp[-2].minor.yy236, yymsp[0].minor.yy636); } + yymsp[-9].minor.yy636 = yylhsminor.yy636; break; - case 127: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy172 = createDropTableClause(pCxt, yymsp[-1].minor.yy617, yymsp[0].minor.yy172); } - yymsp[-1].minor.yy172 = yylhsminor.yy172; + case 128: /* drop_table_clause ::= exists_opt full_table_name */ +{ yylhsminor.yy636 = createDropTableClause(pCxt, yymsp[-1].minor.yy603, yymsp[0].minor.yy636); } + yymsp[-1].minor.yy636 = yylhsminor.yy636; break; - case 128: /* specific_tags_opt ::= */ - case 159: /* tags_def_opt ::= */ yytestcase(yyruleno==159); - case 402: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==402); - case 419: /* group_by_clause_opt ::= */ yytestcase(yyruleno==419); - case 431: /* order_by_clause_opt ::= */ yytestcase(yyruleno==431); -{ yymsp[1].minor.yy60 = NULL; } + case 129: /* specific_tags_opt ::= */ + case 160: /* tags_def_opt ::= */ yytestcase(yyruleno==160); + case 405: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==405); + case 422: /* group_by_clause_opt ::= */ yytestcase(yyruleno==422); + case 434: /* order_by_clause_opt ::= */ yytestcase(yyruleno==434); +{ yymsp[1].minor.yy236 = NULL; } break; - case 129: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy60 = yymsp[-1].minor.yy60; } + case 130: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ +{ yymsp[-2].minor.yy236 = yymsp[-1].minor.yy236; } break; - case 130: /* full_table_name ::= table_name */ -{ yylhsminor.yy172 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy105, NULL); } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 131: /* full_table_name ::= table_name */ +{ yylhsminor.yy636 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy53, NULL); } + yymsp[0].minor.yy636 = yylhsminor.yy636; break; - case 131: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy172 = createRealTableNode(pCxt, &yymsp[-2].minor.yy105, &yymsp[0].minor.yy105, NULL); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 132: /* full_table_name ::= db_name NK_DOT table_name */ +{ yylhsminor.yy636 = createRealTableNode(pCxt, &yymsp[-2].minor.yy53, &yymsp[0].minor.yy53, NULL); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 134: /* column_def ::= column_name type_name */ -{ yylhsminor.yy172 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy105, yymsp[0].minor.yy248, NULL); } - yymsp[-1].minor.yy172 = yylhsminor.yy172; + case 135: /* column_def ::= column_name type_name */ +{ yylhsminor.yy636 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy53, yymsp[0].minor.yy450, NULL); } + yymsp[-1].minor.yy636 = yylhsminor.yy636; break; - case 135: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy172 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy105, yymsp[-2].minor.yy248, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy172 = yylhsminor.yy172; + case 136: /* column_def ::= column_name type_name COMMENT NK_STRING */ +{ yylhsminor.yy636 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy53, yymsp[-2].minor.yy450, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy636 = yylhsminor.yy636; break; - case 136: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy248 = createDataType(TSDB_DATA_TYPE_BOOL); } + case 137: /* type_name ::= BOOL */ +{ yymsp[0].minor.yy450 = createDataType(TSDB_DATA_TYPE_BOOL); } break; - case 137: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy248 = createDataType(TSDB_DATA_TYPE_TINYINT); } + case 138: /* type_name ::= TINYINT */ +{ yymsp[0].minor.yy450 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; - case 138: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy248 = createDataType(TSDB_DATA_TYPE_SMALLINT); } + case 139: /* type_name ::= SMALLINT */ +{ yymsp[0].minor.yy450 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; - case 139: /* type_name ::= INT */ - case 140: /* type_name ::= INTEGER */ yytestcase(yyruleno==140); -{ yymsp[0].minor.yy248 = createDataType(TSDB_DATA_TYPE_INT); } + case 140: /* type_name ::= INT */ + case 141: /* type_name ::= INTEGER */ yytestcase(yyruleno==141); +{ yymsp[0].minor.yy450 = createDataType(TSDB_DATA_TYPE_INT); } break; - case 141: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy248 = createDataType(TSDB_DATA_TYPE_BIGINT); } + case 142: /* type_name ::= BIGINT */ +{ yymsp[0].minor.yy450 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; - case 142: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy248 = createDataType(TSDB_DATA_TYPE_FLOAT); } + case 143: /* type_name ::= FLOAT */ +{ yymsp[0].minor.yy450 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; - case 143: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy248 = createDataType(TSDB_DATA_TYPE_DOUBLE); } + case 144: /* type_name ::= DOUBLE */ +{ yymsp[0].minor.yy450 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; - case 144: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy248 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } + case 145: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy450 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; - case 145: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy248 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } + case 146: /* type_name ::= TIMESTAMP */ +{ yymsp[0].minor.yy450 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; - case 146: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy248 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } + case 147: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy450 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; - case 147: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy248 = createDataType(TSDB_DATA_TYPE_UTINYINT); } + case 148: /* type_name ::= TINYINT UNSIGNED */ +{ yymsp[-1].minor.yy450 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; - case 148: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy248 = createDataType(TSDB_DATA_TYPE_USMALLINT); } + case 149: /* type_name ::= SMALLINT UNSIGNED */ +{ yymsp[-1].minor.yy450 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; - case 149: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy248 = createDataType(TSDB_DATA_TYPE_UINT); } + case 150: /* type_name ::= INT UNSIGNED */ +{ yymsp[-1].minor.yy450 = createDataType(TSDB_DATA_TYPE_UINT); } break; - case 150: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy248 = createDataType(TSDB_DATA_TYPE_UBIGINT); } + case 151: /* type_name ::= BIGINT UNSIGNED */ +{ yymsp[-1].minor.yy450 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; - case 151: /* type_name ::= JSON */ -{ yymsp[0].minor.yy248 = createDataType(TSDB_DATA_TYPE_JSON); } + case 152: /* type_name ::= JSON */ +{ yymsp[0].minor.yy450 = createDataType(TSDB_DATA_TYPE_JSON); } break; - case 152: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy248 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } + case 153: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy450 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; - case 153: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy248 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } + case 154: /* type_name ::= MEDIUMBLOB */ +{ yymsp[0].minor.yy450 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; - case 154: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy248 = createDataType(TSDB_DATA_TYPE_BLOB); } + case 155: /* type_name ::= BLOB */ +{ yymsp[0].minor.yy450 = createDataType(TSDB_DATA_TYPE_BLOB); } break; - case 155: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy248 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } + case 156: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy450 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; - case 156: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy248 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 157: /* type_name ::= DECIMAL */ +{ yymsp[0].minor.yy450 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 157: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy248 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 158: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy450 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 158: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy248 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 159: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy450 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 160: /* tags_def_opt ::= tags_def */ - case 338: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==338); - case 393: /* select_list ::= select_sublist */ yytestcase(yyruleno==393); -{ yylhsminor.yy60 = yymsp[0].minor.yy60; } - yymsp[0].minor.yy60 = yylhsminor.yy60; + case 161: /* tags_def_opt ::= tags_def */ + case 341: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==341); + case 396: /* select_list ::= select_sublist */ yytestcase(yyruleno==396); +{ yylhsminor.yy236 = yymsp[0].minor.yy236; } + yymsp[0].minor.yy236 = yylhsminor.yy236; break; - case 161: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy60 = yymsp[-1].minor.yy60; } + case 162: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ +{ yymsp[-3].minor.yy236 = yymsp[-1].minor.yy236; } break; - case 162: /* table_options ::= */ -{ yymsp[1].minor.yy172 = createDefaultTableOptions(pCxt); } + case 163: /* table_options ::= */ +{ yymsp[1].minor.yy636 = createDefaultTableOptions(pCxt); } break; - case 163: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy172 = setTableOption(pCxt, yymsp[-2].minor.yy172, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 164: /* table_options ::= table_options COMMENT NK_STRING */ +{ yylhsminor.yy636 = setTableOption(pCxt, yymsp[-2].minor.yy636, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 164: /* table_options ::= table_options DELAY NK_INTEGER */ -{ yylhsminor.yy172 = setTableOption(pCxt, yymsp[-2].minor.yy172, TABLE_OPTION_DELAY, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 165: /* table_options ::= table_options DELAY NK_INTEGER */ +{ yylhsminor.yy636 = setTableOption(pCxt, yymsp[-2].minor.yy636, TABLE_OPTION_DELAY, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 165: /* table_options ::= table_options FILE_FACTOR NK_FLOAT */ -{ yylhsminor.yy172 = setTableOption(pCxt, yymsp[-2].minor.yy172, TABLE_OPTION_FILE_FACTOR, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 166: /* table_options ::= table_options FILE_FACTOR NK_FLOAT */ +{ yylhsminor.yy636 = setTableOption(pCxt, yymsp[-2].minor.yy636, TABLE_OPTION_FILE_FACTOR, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 166: /* table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ -{ yylhsminor.yy172 = setTableOption(pCxt, yymsp[-4].minor.yy172, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy60); } - yymsp[-4].minor.yy172 = yylhsminor.yy172; + case 167: /* table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ +{ yylhsminor.yy636 = setTableOption(pCxt, yymsp[-4].minor.yy636, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy236); } + yymsp[-4].minor.yy636 = yylhsminor.yy636; break; - case 167: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy172 = setTableOption(pCxt, yymsp[-2].minor.yy172, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 168: /* table_options ::= table_options TTL NK_INTEGER */ +{ yylhsminor.yy636 = setTableOption(pCxt, yymsp[-2].minor.yy636, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 168: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy172 = setTableOption(pCxt, yymsp[-4].minor.yy172, TABLE_OPTION_SMA, yymsp[-1].minor.yy60); } - yymsp[-4].minor.yy172 = yylhsminor.yy172; + case 169: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ +{ yylhsminor.yy636 = setTableOption(pCxt, yymsp[-4].minor.yy636, TABLE_OPTION_SMA, yymsp[-1].minor.yy236); } + yymsp[-4].minor.yy636 = yylhsminor.yy636; break; - case 169: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy172 = createAlterTableOptions(pCxt); yylhsminor.yy172 = setTableOption(pCxt, yylhsminor.yy172, yymsp[0].minor.yy609.type, &yymsp[0].minor.yy609.val); } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 170: /* alter_table_options ::= alter_table_option */ +{ yylhsminor.yy636 = createAlterTableOptions(pCxt); yylhsminor.yy636 = setTableOption(pCxt, yylhsminor.yy636, yymsp[0].minor.yy25.type, &yymsp[0].minor.yy25.val); } + yymsp[0].minor.yy636 = yylhsminor.yy636; break; - case 170: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy172 = setTableOption(pCxt, yymsp[-1].minor.yy172, yymsp[0].minor.yy609.type, &yymsp[0].minor.yy609.val); } - yymsp[-1].minor.yy172 = yylhsminor.yy172; + case 171: /* alter_table_options ::= alter_table_options alter_table_option */ +{ yylhsminor.yy636 = setTableOption(pCxt, yymsp[-1].minor.yy636, yymsp[0].minor.yy25.type, &yymsp[0].minor.yy25.val); } + yymsp[-1].minor.yy636 = yylhsminor.yy636; break; - case 171: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy609.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy609.val = yymsp[0].minor.yy0; } + case 172: /* alter_table_option ::= COMMENT NK_STRING */ +{ yymsp[-1].minor.yy25.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy25.val = yymsp[0].minor.yy0; } break; - case 172: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy609.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy609.val = yymsp[0].minor.yy0; } + case 173: /* alter_table_option ::= TTL NK_INTEGER */ +{ yymsp[-1].minor.yy25.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy25.val = yymsp[0].minor.yy0; } break; - case 175: /* col_name ::= column_name */ -{ yylhsminor.yy172 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy105); } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 176: /* col_name ::= column_name */ +{ yylhsminor.yy636 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy53); } + yymsp[0].minor.yy636 = yylhsminor.yy636; break; - case 176: /* cmd ::= SHOW DNODES */ + case 177: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL, NULL); } break; - case 177: /* cmd ::= SHOW USERS */ + case 178: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL, NULL); } break; - case 178: /* cmd ::= SHOW DATABASES */ + case 179: /* cmd ::= SHOW DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL, NULL); } break; - case 179: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy172, yymsp[0].minor.yy172); } + case 180: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy636, yymsp[0].minor.yy636); } break; - case 180: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy172, yymsp[0].minor.yy172); } + case 181: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy636, yymsp[0].minor.yy636); } break; - case 181: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy172, NULL); } + case 182: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy636, NULL); } break; - case 182: /* cmd ::= SHOW MNODES */ + case 183: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL, NULL); } break; - case 183: /* cmd ::= SHOW MODULES */ + case 184: /* cmd ::= SHOW MODULES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MODULES_STMT, NULL, NULL); } break; - case 184: /* cmd ::= SHOW QNODES */ + case 185: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT, NULL, NULL); } break; - case 185: /* cmd ::= SHOW FUNCTIONS */ + case 186: /* cmd ::= SHOW FUNCTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT, NULL, NULL); } break; - case 186: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[-1].minor.yy172, yymsp[0].minor.yy172); } + case 187: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[-1].minor.yy636, yymsp[0].minor.yy636); } break; - case 187: /* cmd ::= SHOW STREAMS */ + case 188: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT, NULL, NULL); } break; - case 188: /* cmd ::= SHOW ACCOUNTS */ + case 189: /* cmd ::= SHOW ACCOUNTS */ { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } break; - case 189: /* cmd ::= SHOW APPS */ + case 190: /* cmd ::= SHOW APPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT, NULL, NULL); } break; - case 190: /* cmd ::= SHOW CONNECTIONS */ + case 191: /* cmd ::= SHOW CONNECTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT, NULL, NULL); } break; - case 191: /* cmd ::= SHOW LICENCE */ - case 192: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==192); + case 192: /* cmd ::= SHOW LICENCE */ + case 193: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==193); { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT, NULL, NULL); } break; - case 193: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy105); } + case 194: /* cmd ::= SHOW CREATE DATABASE db_name */ +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy53); } break; - case 194: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy172); } + case 195: /* cmd ::= SHOW CREATE TABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy636); } break; - case 195: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy172); } + case 196: /* cmd ::= SHOW CREATE STABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy636); } break; - case 196: /* cmd ::= SHOW QUERIES */ + case 197: /* cmd ::= SHOW QUERIES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT, NULL, NULL); } break; - case 197: /* cmd ::= SHOW SCORES */ + case 198: /* cmd ::= SHOW SCORES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT, NULL, NULL); } break; - case 198: /* cmd ::= SHOW TOPICS */ + case 199: /* cmd ::= SHOW TOPICS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT, NULL, NULL); } break; - case 199: /* cmd ::= SHOW VARIABLES */ + case 200: /* cmd ::= SHOW VARIABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLE_STMT, NULL, NULL); } break; - case 200: /* cmd ::= SHOW BNODES */ + case 201: /* cmd ::= SHOW BNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT, NULL, NULL); } break; - case 201: /* cmd ::= SHOW SNODES */ + case 202: /* cmd ::= SHOW SNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT, NULL, NULL); } break; - case 202: /* cmd ::= SHOW CLUSTER */ + case 203: /* cmd ::= SHOW CLUSTER */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT, NULL, NULL); } break; - case 203: /* cmd ::= SHOW TRANSACTIONS */ + case 204: /* cmd ::= SHOW TRANSACTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT, NULL, NULL); } break; - case 204: /* db_name_cond_opt ::= */ - case 209: /* from_db_opt ::= */ yytestcase(yyruleno==209); -{ yymsp[1].minor.yy172 = createDefaultDatabaseCondValue(pCxt); } + case 205: /* db_name_cond_opt ::= */ + case 210: /* from_db_opt ::= */ yytestcase(yyruleno==210); +{ yymsp[1].minor.yy636 = createDefaultDatabaseCondValue(pCxt); } break; - case 205: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy172 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy105); } - yymsp[-1].minor.yy172 = yylhsminor.yy172; + case 206: /* db_name_cond_opt ::= db_name NK_DOT */ +{ yylhsminor.yy636 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy53); } + yymsp[-1].minor.yy636 = yylhsminor.yy636; break; - case 206: /* like_pattern_opt ::= */ - case 217: /* index_options ::= */ yytestcase(yyruleno==217); - case 248: /* into_opt ::= */ yytestcase(yyruleno==248); - case 400: /* where_clause_opt ::= */ yytestcase(yyruleno==400); - case 404: /* twindow_clause_opt ::= */ yytestcase(yyruleno==404); - case 409: /* sliding_opt ::= */ yytestcase(yyruleno==409); - case 411: /* fill_opt ::= */ yytestcase(yyruleno==411); - case 423: /* having_clause_opt ::= */ yytestcase(yyruleno==423); - case 433: /* slimit_clause_opt ::= */ yytestcase(yyruleno==433); - case 437: /* limit_clause_opt ::= */ yytestcase(yyruleno==437); -{ yymsp[1].minor.yy172 = NULL; } + case 207: /* like_pattern_opt ::= */ + case 218: /* index_options ::= */ yytestcase(yyruleno==218); + case 250: /* into_opt ::= */ yytestcase(yyruleno==250); + case 403: /* where_clause_opt ::= */ yytestcase(yyruleno==403); + case 407: /* twindow_clause_opt ::= */ yytestcase(yyruleno==407); + case 412: /* sliding_opt ::= */ yytestcase(yyruleno==412); + case 414: /* fill_opt ::= */ yytestcase(yyruleno==414); + case 426: /* having_clause_opt ::= */ yytestcase(yyruleno==426); + case 436: /* slimit_clause_opt ::= */ yytestcase(yyruleno==436); + case 440: /* limit_clause_opt ::= */ yytestcase(yyruleno==440); +{ yymsp[1].minor.yy636 = NULL; } break; - case 207: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy172 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + case 208: /* like_pattern_opt ::= LIKE NK_STRING */ +{ yymsp[-1].minor.yy636 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; - case 208: /* table_name_cond ::= table_name */ -{ yylhsminor.yy172 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy105); } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 209: /* table_name_cond ::= table_name */ +{ yylhsminor.yy636 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy53); } + yymsp[0].minor.yy636 = yylhsminor.yy636; break; - case 210: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy172 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy105); } + case 211: /* from_db_opt ::= FROM db_name */ +{ yymsp[-1].minor.yy636 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy53); } break; - case 213: /* func_name ::= function_name */ -{ yylhsminor.yy172 = createFunctionNode(pCxt, &yymsp[0].minor.yy105, NULL); } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 214: /* func_name ::= function_name */ +{ yylhsminor.yy636 = createFunctionNode(pCxt, &yymsp[0].minor.yy53, NULL); } + yymsp[0].minor.yy636 = yylhsminor.yy636; break; - case 214: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy617, &yymsp[-3].minor.yy105, &yymsp[-1].minor.yy105, NULL, yymsp[0].minor.yy172); } + case 215: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy603, &yymsp[-3].minor.yy53, &yymsp[-1].minor.yy53, NULL, yymsp[0].minor.yy636); } break; - case 215: /* cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, yymsp[-6].minor.yy617, &yymsp[-5].minor.yy105, &yymsp[-3].minor.yy105, yymsp[-1].minor.yy60, NULL); } + case 216: /* cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, yymsp[-6].minor.yy603, &yymsp[-5].minor.yy53, &yymsp[-3].minor.yy53, yymsp[-1].minor.yy236, NULL); } break; - case 216: /* cmd ::= DROP INDEX exists_opt index_name ON table_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-3].minor.yy617, &yymsp[-2].minor.yy105, &yymsp[0].minor.yy105); } + case 217: /* cmd ::= DROP INDEX exists_opt index_name ON table_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-3].minor.yy603, &yymsp[-2].minor.yy53, &yymsp[0].minor.yy53); } break; - case 218: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ -{ yymsp[-8].minor.yy172 = createIndexOption(pCxt, yymsp[-6].minor.yy60, releaseRawExprNode(pCxt, yymsp[-2].minor.yy172), NULL, yymsp[0].minor.yy172); } + case 219: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ +{ yymsp[-8].minor.yy636 = createIndexOption(pCxt, yymsp[-6].minor.yy236, releaseRawExprNode(pCxt, yymsp[-2].minor.yy636), NULL, yymsp[0].minor.yy636); } break; - case 219: /* 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.yy172 = createIndexOption(pCxt, yymsp[-8].minor.yy60, releaseRawExprNode(pCxt, yymsp[-4].minor.yy172), releaseRawExprNode(pCxt, yymsp[-2].minor.yy172), yymsp[0].minor.yy172); } + case 220: /* 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.yy636 = createIndexOption(pCxt, yymsp[-8].minor.yy236, releaseRawExprNode(pCxt, yymsp[-4].minor.yy636), releaseRawExprNode(pCxt, yymsp[-2].minor.yy636), yymsp[0].minor.yy636); } break; - case 222: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy172 = createFunctionNode(pCxt, &yymsp[-3].minor.yy105, yymsp[-1].minor.yy60); } - yymsp[-3].minor.yy172 = yylhsminor.yy172; + case 223: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy636 = createFunctionNode(pCxt, &yymsp[-3].minor.yy53, yymsp[-1].minor.yy236); } + yymsp[-3].minor.yy636 = yylhsminor.yy636; break; - case 223: /* cmd ::= CREATE TOPIC not_exists_opt topic_name topic_options AS query_expression */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-4].minor.yy617, &yymsp[-3].minor.yy105, yymsp[0].minor.yy172, NULL, yymsp[-2].minor.yy172); } + case 224: /* cmd ::= CREATE TOPIC not_exists_opt topic_name topic_options AS query_expression */ +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-4].minor.yy603, &yymsp[-3].minor.yy53, yymsp[0].minor.yy636, NULL, yymsp[-2].minor.yy636); } break; - case 224: /* cmd ::= CREATE TOPIC not_exists_opt topic_name topic_options AS db_name */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-4].minor.yy617, &yymsp[-3].minor.yy105, NULL, &yymsp[0].minor.yy105, yymsp[-2].minor.yy172); } + case 225: /* cmd ::= CREATE TOPIC not_exists_opt topic_name topic_options AS db_name */ +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-4].minor.yy603, &yymsp[-3].minor.yy53, NULL, &yymsp[0].minor.yy53, yymsp[-2].minor.yy636); } break; - case 225: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy617, &yymsp[0].minor.yy105); } + case 226: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy603, &yymsp[0].minor.yy53); } break; - case 226: /* topic_options ::= */ -{ yymsp[1].minor.yy172 = createTopicOptions(pCxt); } + case 227: /* cmd ::= DROP CGROUP exists_opt cgroup_name ON topic_name */ +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy603, &yymsp[-2].minor.yy53, &yymsp[0].minor.yy53); } break; - case 227: /* topic_options ::= topic_options WITH TABLE */ -{ ((STopicOptions*)yymsp[-2].minor.yy172)->withTable = true; yylhsminor.yy172 = yymsp[-2].minor.yy172; } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 228: /* topic_options ::= */ +{ yymsp[1].minor.yy636 = createTopicOptions(pCxt); } break; - case 228: /* topic_options ::= topic_options WITH SCHEMA */ -{ ((STopicOptions*)yymsp[-2].minor.yy172)->withSchema = true; yylhsminor.yy172 = yymsp[-2].minor.yy172; } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 229: /* topic_options ::= topic_options WITH TABLE */ +{ ((STopicOptions*)yymsp[-2].minor.yy636)->withTable = true; yylhsminor.yy636 = yymsp[-2].minor.yy636; } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 229: /* topic_options ::= topic_options WITH TAG */ -{ ((STopicOptions*)yymsp[-2].minor.yy172)->withTag = true; yylhsminor.yy172 = yymsp[-2].minor.yy172; } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 230: /* topic_options ::= topic_options WITH SCHEMA */ +{ ((STopicOptions*)yymsp[-2].minor.yy636)->withSchema = true; yylhsminor.yy636 = yymsp[-2].minor.yy636; } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 230: /* cmd ::= DESC full_table_name */ - case 231: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==231); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy172); } + case 231: /* topic_options ::= topic_options WITH TAG */ +{ ((STopicOptions*)yymsp[-2].minor.yy636)->withTag = true; yylhsminor.yy636 = yymsp[-2].minor.yy636; } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 232: /* cmd ::= RESET QUERY CACHE */ + case 232: /* cmd ::= DESC full_table_name */ + case 233: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==233); +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy636); } + break; + case 234: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; - case 233: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy617, yymsp[-1].minor.yy172, yymsp[0].minor.yy172); } + case 235: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy603, yymsp[-1].minor.yy636, yymsp[0].minor.yy636); } break; - case 235: /* analyze_opt ::= ANALYZE */ - case 243: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==243); - case 390: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==390); -{ yymsp[0].minor.yy617 = true; } + case 237: /* analyze_opt ::= ANALYZE */ + case 245: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==245); + case 393: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==393); +{ yymsp[0].minor.yy603 = true; } break; - case 236: /* explain_options ::= */ -{ yymsp[1].minor.yy172 = createDefaultExplainOptions(pCxt); } + case 238: /* explain_options ::= */ +{ yymsp[1].minor.yy636 = createDefaultExplainOptions(pCxt); } break; - case 237: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy172 = setExplainVerbose(pCxt, yymsp[-2].minor.yy172, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 239: /* explain_options ::= explain_options VERBOSE NK_BOOL */ +{ yylhsminor.yy636 = setExplainVerbose(pCxt, yymsp[-2].minor.yy636, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 238: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy172 = setExplainRatio(pCxt, yymsp[-2].minor.yy172, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 240: /* explain_options ::= explain_options RATIO NK_FLOAT */ +{ yylhsminor.yy636 = setExplainRatio(pCxt, yymsp[-2].minor.yy636, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 239: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ -{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy60); } + case 241: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ +{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy236); } break; - case 240: /* 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.yy617, yymsp[-8].minor.yy617, &yymsp[-5].minor.yy105, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy248, yymsp[0].minor.yy140); } + case 242: /* 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.yy603, yymsp[-8].minor.yy603, &yymsp[-5].minor.yy53, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy450, yymsp[0].minor.yy158); } break; - case 241: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy617, &yymsp[0].minor.yy105); } + case 243: /* cmd ::= DROP FUNCTION exists_opt function_name */ +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy603, &yymsp[0].minor.yy53); } break; - case 244: /* bufsize_opt ::= */ -{ yymsp[1].minor.yy140 = 0; } + case 246: /* bufsize_opt ::= */ +{ yymsp[1].minor.yy158 = 0; } break; - case 245: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ -{ yymsp[-1].minor.yy140 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } + case 247: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ +{ yymsp[-1].minor.yy158 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 246: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy617, &yymsp[-4].minor.yy105, yymsp[-2].minor.yy172, yymsp[-3].minor.yy172, yymsp[0].minor.yy172); } + case 248: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options into_opt AS query_expression */ +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-5].minor.yy603, &yymsp[-4].minor.yy53, yymsp[-2].minor.yy636, yymsp[-3].minor.yy636, yymsp[0].minor.yy636); } break; - case 247: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy617, &yymsp[0].minor.yy105); } + case 249: /* cmd ::= DROP STREAM exists_opt stream_name */ +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy603, &yymsp[0].minor.yy53); } break; - case 249: /* into_opt ::= INTO full_table_name */ - case 371: /* from_clause ::= FROM table_reference_list */ yytestcase(yyruleno==371); - case 401: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==401); - case 424: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==424); -{ yymsp[-1].minor.yy172 = yymsp[0].minor.yy172; } + case 251: /* into_opt ::= INTO full_table_name */ + case 374: /* from_clause ::= FROM table_reference_list */ yytestcase(yyruleno==374); + case 404: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==404); + case 427: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==427); +{ yymsp[-1].minor.yy636 = yymsp[0].minor.yy636; } break; - case 250: /* stream_options ::= */ -{ yymsp[1].minor.yy172 = createStreamOptions(pCxt); } + case 252: /* stream_options ::= */ +{ yymsp[1].minor.yy636 = createStreamOptions(pCxt); } break; - case 251: /* stream_options ::= stream_options TRIGGER AT_ONCE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy172)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy172 = yymsp[-2].minor.yy172; } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 253: /* stream_options ::= stream_options TRIGGER AT_ONCE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy636)->triggerType = STREAM_TRIGGER_AT_ONCE; yylhsminor.yy636 = yymsp[-2].minor.yy636; } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 252: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ -{ ((SStreamOptions*)yymsp[-2].minor.yy172)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy172 = yymsp[-2].minor.yy172; } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 254: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ +{ ((SStreamOptions*)yymsp[-2].minor.yy636)->triggerType = STREAM_TRIGGER_WINDOW_CLOSE; yylhsminor.yy636 = yymsp[-2].minor.yy636; } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 253: /* stream_options ::= stream_options WATERMARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy172)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy172); yylhsminor.yy172 = yymsp[-2].minor.yy172; } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 255: /* stream_options ::= stream_options WATERMARK duration_literal */ +{ ((SStreamOptions*)yymsp[-2].minor.yy636)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy636); yylhsminor.yy636 = yymsp[-2].minor.yy636; } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 254: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 256: /* cmd ::= KILL CONNECTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 255: /* cmd ::= KILL QUERY NK_INTEGER */ + case 257: /* cmd ::= KILL QUERY NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_QUERY_STMT, &yymsp[0].minor.yy0); } break; - case 256: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 258: /* cmd ::= KILL TRANSACTION NK_INTEGER */ { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } break; - case 257: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 259: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 258: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy60); } + case 260: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy236); } break; - case 259: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 261: /* cmd ::= SPLIT VGROUP NK_INTEGER */ { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 260: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy60 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + case 262: /* dnode_list ::= DNODE NK_INTEGER */ +{ yymsp[-1].minor.yy236 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } break; - case 262: /* cmd ::= SYNCDB db_name REPLICA */ -{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy105); } + case 264: /* cmd ::= SYNCDB db_name REPLICA */ +{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy53); } break; - case 264: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy172 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 266: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy636 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy636 = yylhsminor.yy636; break; - case 265: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy172 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 267: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy636 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy636 = yylhsminor.yy636; break; - case 266: /* literal ::= NK_STRING */ -{ yylhsminor.yy172 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 268: /* literal ::= NK_STRING */ +{ yylhsminor.yy636 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy636 = yylhsminor.yy636; break; - case 267: /* literal ::= NK_BOOL */ -{ yylhsminor.yy172 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 269: /* literal ::= NK_BOOL */ +{ yylhsminor.yy636 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy636 = yylhsminor.yy636; break; - case 268: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy172 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy172 = yylhsminor.yy172; + case 270: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy636 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy636 = yylhsminor.yy636; break; - case 269: /* literal ::= duration_literal */ - case 279: /* signed_literal ::= signed */ yytestcase(yyruleno==279); - case 298: /* expression ::= literal */ yytestcase(yyruleno==298); - case 299: /* expression ::= pseudo_column */ yytestcase(yyruleno==299); - case 300: /* expression ::= column_reference */ yytestcase(yyruleno==300); - case 301: /* expression ::= function_expression */ yytestcase(yyruleno==301); - case 302: /* expression ::= subquery */ yytestcase(yyruleno==302); - case 327: /* function_expression ::= literal_func */ yytestcase(yyruleno==327); - case 363: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==363); - case 367: /* boolean_primary ::= predicate */ yytestcase(yyruleno==367); - case 369: /* common_expression ::= expression */ yytestcase(yyruleno==369); - case 370: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==370); - case 372: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==372); - case 374: /* table_reference ::= table_primary */ yytestcase(yyruleno==374); - case 375: /* table_reference ::= joined_table */ yytestcase(yyruleno==375); - case 379: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==379); - case 426: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==426); - case 429: /* query_primary ::= query_specification */ yytestcase(yyruleno==429); -{ yylhsminor.yy172 = yymsp[0].minor.yy172; } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 271: /* literal ::= duration_literal */ + case 281: /* signed_literal ::= signed */ yytestcase(yyruleno==281); + case 301: /* expression ::= literal */ yytestcase(yyruleno==301); + case 302: /* expression ::= pseudo_column */ yytestcase(yyruleno==302); + case 303: /* expression ::= column_reference */ yytestcase(yyruleno==303); + case 304: /* expression ::= function_expression */ yytestcase(yyruleno==304); + case 305: /* expression ::= subquery */ yytestcase(yyruleno==305); + case 330: /* function_expression ::= literal_func */ yytestcase(yyruleno==330); + case 366: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==366); + case 370: /* boolean_primary ::= predicate */ yytestcase(yyruleno==370); + case 372: /* common_expression ::= expression */ yytestcase(yyruleno==372); + case 373: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==373); + case 375: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==375); + case 377: /* table_reference ::= table_primary */ yytestcase(yyruleno==377); + case 378: /* table_reference ::= joined_table */ yytestcase(yyruleno==378); + case 382: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==382); + case 429: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==429); + case 432: /* query_primary ::= query_specification */ yytestcase(yyruleno==432); +{ yylhsminor.yy636 = yymsp[0].minor.yy636; } + yymsp[0].minor.yy636 = yylhsminor.yy636; break; - case 270: /* literal ::= NULL */ -{ yylhsminor.yy172 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 272: /* literal ::= NULL */ +{ yylhsminor.yy636 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy636 = yylhsminor.yy636; break; - case 271: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy172 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 273: /* literal ::= NK_QUESTION */ +{ yylhsminor.yy636 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy636 = yylhsminor.yy636; break; - case 272: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy172 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 274: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy636 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy636 = yylhsminor.yy636; break; - case 273: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy172 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 275: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy636 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy636 = yylhsminor.yy636; break; - case 274: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy172 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + case 276: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy636 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } break; - case 275: /* signed ::= NK_MINUS NK_INTEGER */ + case 277: /* 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.yy172 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy636 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy172 = yylhsminor.yy172; + yymsp[-1].minor.yy636 = yylhsminor.yy636; break; - case 276: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy172 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 278: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy636 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy636 = yylhsminor.yy636; break; - case 277: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy172 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 279: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy636 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 278: /* signed ::= NK_MINUS NK_FLOAT */ + case 280: /* 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.yy172 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy636 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy172 = yylhsminor.yy172; + yymsp[-1].minor.yy636 = yylhsminor.yy636; break; - case 280: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy172 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 282: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy636 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy636 = yylhsminor.yy636; break; - case 281: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy172 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 283: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy636 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy636 = yylhsminor.yy636; break; - case 282: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy172 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 284: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy636 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 283: /* signed_literal ::= duration_literal */ - case 285: /* signed_literal ::= literal_func */ yytestcase(yyruleno==285); - case 341: /* star_func_para ::= expression */ yytestcase(yyruleno==341); - case 396: /* select_item ::= common_expression */ yytestcase(yyruleno==396); - case 442: /* search_condition ::= common_expression */ yytestcase(yyruleno==442); -{ yylhsminor.yy172 = releaseRawExprNode(pCxt, yymsp[0].minor.yy172); } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 285: /* signed_literal ::= duration_literal */ + case 287: /* signed_literal ::= literal_func */ yytestcase(yyruleno==287); + case 344: /* star_func_para ::= expression */ yytestcase(yyruleno==344); + case 399: /* select_item ::= common_expression */ yytestcase(yyruleno==399); + case 445: /* search_condition ::= common_expression */ yytestcase(yyruleno==445); +{ yylhsminor.yy636 = releaseRawExprNode(pCxt, yymsp[0].minor.yy636); } + yymsp[0].minor.yy636 = yylhsminor.yy636; break; - case 284: /* signed_literal ::= NULL */ -{ yylhsminor.yy172 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 286: /* signed_literal ::= NULL */ +{ yylhsminor.yy636 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy636 = yylhsminor.yy636; break; - case 303: /* expression ::= NK_LP expression NK_RP */ - case 368: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==368); -{ yylhsminor.yy172 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy172)); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 306: /* expression ::= NK_LP expression NK_RP */ + case 371: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==371); +{ yylhsminor.yy636 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy636)); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 304: /* expression ::= NK_PLUS expression */ + case 307: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy172); - yylhsminor.yy172 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy172)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy636); + yylhsminor.yy636 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy636)); } - yymsp[-1].minor.yy172 = yylhsminor.yy172; + yymsp[-1].minor.yy636 = yylhsminor.yy636; break; - case 305: /* expression ::= NK_MINUS expression */ + case 308: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy172); - yylhsminor.yy172 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy172), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy636); + yylhsminor.yy636 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy636), NULL)); } - yymsp[-1].minor.yy172 = yylhsminor.yy172; + yymsp[-1].minor.yy636 = yylhsminor.yy636; break; - case 306: /* expression ::= expression NK_PLUS expression */ + case 309: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy172); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy172); - yylhsminor.yy172 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy172), releaseRawExprNode(pCxt, yymsp[0].minor.yy172))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy636); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy636); + yylhsminor.yy636 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy636), releaseRawExprNode(pCxt, yymsp[0].minor.yy636))); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 307: /* expression ::= expression NK_MINUS expression */ + case 310: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy172); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy172); - yylhsminor.yy172 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy172), releaseRawExprNode(pCxt, yymsp[0].minor.yy172))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy636); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy636); + yylhsminor.yy636 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy636), releaseRawExprNode(pCxt, yymsp[0].minor.yy636))); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 308: /* expression ::= expression NK_STAR expression */ + case 311: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy172); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy172); - yylhsminor.yy172 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy172), releaseRawExprNode(pCxt, yymsp[0].minor.yy172))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy636); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy636); + yylhsminor.yy636 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy636), releaseRawExprNode(pCxt, yymsp[0].minor.yy636))); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 309: /* expression ::= expression NK_SLASH expression */ + case 312: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy172); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy172); - yylhsminor.yy172 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy172), releaseRawExprNode(pCxt, yymsp[0].minor.yy172))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy636); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy636); + yylhsminor.yy636 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy636), releaseRawExprNode(pCxt, yymsp[0].minor.yy636))); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 310: /* expression ::= expression NK_REM expression */ + case 313: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy172); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy172); - yylhsminor.yy172 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy172), releaseRawExprNode(pCxt, yymsp[0].minor.yy172))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy636); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy636); + yylhsminor.yy636 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy636), releaseRawExprNode(pCxt, yymsp[0].minor.yy636))); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 311: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 314: /* expression ::= column_reference NK_ARROW NK_STRING */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy172); - yylhsminor.yy172 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy172), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy636); + yylhsminor.yy636 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy636), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 312: /* expression_list ::= expression */ -{ yylhsminor.yy60 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy172)); } - yymsp[0].minor.yy60 = yylhsminor.yy60; + case 315: /* expression_list ::= expression */ +{ yylhsminor.yy236 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy636)); } + yymsp[0].minor.yy236 = yylhsminor.yy236; break; - case 313: /* expression_list ::= expression_list NK_COMMA expression */ -{ yylhsminor.yy60 = addNodeToList(pCxt, yymsp[-2].minor.yy60, releaseRawExprNode(pCxt, yymsp[0].minor.yy172)); } - yymsp[-2].minor.yy60 = yylhsminor.yy60; + case 316: /* expression_list ::= expression_list NK_COMMA expression */ +{ yylhsminor.yy236 = addNodeToList(pCxt, yymsp[-2].minor.yy236, releaseRawExprNode(pCxt, yymsp[0].minor.yy636)); } + yymsp[-2].minor.yy236 = yylhsminor.yy236; break; - case 314: /* column_reference ::= column_name */ -{ yylhsminor.yy172 = createRawExprNode(pCxt, &yymsp[0].minor.yy105, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy105)); } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 317: /* column_reference ::= column_name */ +{ yylhsminor.yy636 = createRawExprNode(pCxt, &yymsp[0].minor.yy53, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy53)); } + yymsp[0].minor.yy636 = yylhsminor.yy636; break; - case 315: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy172 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy105, &yymsp[0].minor.yy105, createColumnNode(pCxt, &yymsp[-2].minor.yy105, &yymsp[0].minor.yy105)); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 318: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy636 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy53, &yymsp[0].minor.yy53, createColumnNode(pCxt, &yymsp[-2].minor.yy53, &yymsp[0].minor.yy53)); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 316: /* pseudo_column ::= ROWTS */ - case 317: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==317); - case 319: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==319); - case 320: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==320); - case 321: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==321); - case 322: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==322); - case 323: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==323); - case 329: /* literal_func ::= NOW */ yytestcase(yyruleno==329); -{ yylhsminor.yy172 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy172 = yylhsminor.yy172; + case 319: /* pseudo_column ::= ROWTS */ + case 320: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==320); + case 322: /* pseudo_column ::= QSTARTTS */ yytestcase(yyruleno==322); + case 323: /* pseudo_column ::= QENDTS */ yytestcase(yyruleno==323); + case 324: /* pseudo_column ::= WSTARTTS */ yytestcase(yyruleno==324); + case 325: /* pseudo_column ::= WENDTS */ yytestcase(yyruleno==325); + case 326: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==326); + case 332: /* literal_func ::= NOW */ yytestcase(yyruleno==332); +{ yylhsminor.yy636 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy636 = yylhsminor.yy636; break; - case 318: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy172 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy105, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy105)))); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 321: /* pseudo_column ::= table_name NK_DOT TBNAME */ +{ yylhsminor.yy636 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy53, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy53)))); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 324: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 325: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==325); -{ yylhsminor.yy172 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy105, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy105, yymsp[-1].minor.yy60)); } - yymsp[-3].minor.yy172 = yylhsminor.yy172; + case 327: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 328: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==328); +{ yylhsminor.yy636 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy53, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy53, yymsp[-1].minor.yy236)); } + yymsp[-3].minor.yy636 = yylhsminor.yy636; break; - case 326: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */ -{ yylhsminor.yy172 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy172), yymsp[-1].minor.yy248)); } - yymsp[-5].minor.yy172 = yylhsminor.yy172; + case 329: /* function_expression ::= CAST NK_LP expression AS type_name NK_RP */ +{ yylhsminor.yy636 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy636), yymsp[-1].minor.yy450)); } + yymsp[-5].minor.yy636 = yylhsminor.yy636; break; - case 328: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy172 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy105, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy105, NULL)); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 331: /* literal_func ::= noarg_func NK_LP NK_RP */ +{ yylhsminor.yy636 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy53, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy53, NULL)); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 337: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy60 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy60 = yylhsminor.yy60; + case 340: /* star_func_para_list ::= NK_STAR */ +{ yylhsminor.yy236 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy236 = yylhsminor.yy236; break; - case 342: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 399: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==399); -{ yylhsminor.yy172 = createColumnNode(pCxt, &yymsp[-2].minor.yy105, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 345: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 402: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==402); +{ yylhsminor.yy636 = createColumnNode(pCxt, &yymsp[-2].minor.yy53, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 343: /* predicate ::= expression compare_op expression */ - case 348: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==348); + case 346: /* predicate ::= expression compare_op expression */ + case 351: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==351); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy172); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy172); - yylhsminor.yy172 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy572, releaseRawExprNode(pCxt, yymsp[-2].minor.yy172), releaseRawExprNode(pCxt, yymsp[0].minor.yy172))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy636); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy636); + yylhsminor.yy636 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy136, releaseRawExprNode(pCxt, yymsp[-2].minor.yy636), releaseRawExprNode(pCxt, yymsp[0].minor.yy636))); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 344: /* predicate ::= expression BETWEEN expression AND expression */ + case 347: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy172); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy172); - yylhsminor.yy172 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy172), releaseRawExprNode(pCxt, yymsp[-2].minor.yy172), releaseRawExprNode(pCxt, yymsp[0].minor.yy172))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy636); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy636); + yylhsminor.yy636 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy636), releaseRawExprNode(pCxt, yymsp[-2].minor.yy636), releaseRawExprNode(pCxt, yymsp[0].minor.yy636))); } - yymsp[-4].minor.yy172 = yylhsminor.yy172; + yymsp[-4].minor.yy636 = yylhsminor.yy636; break; - case 345: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 348: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy172); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy172); - yylhsminor.yy172 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy172), releaseRawExprNode(pCxt, yymsp[-2].minor.yy172), releaseRawExprNode(pCxt, yymsp[0].minor.yy172))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy636); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy636); + yylhsminor.yy636 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy636), releaseRawExprNode(pCxt, yymsp[-2].minor.yy636), releaseRawExprNode(pCxt, yymsp[0].minor.yy636))); } - yymsp[-5].minor.yy172 = yylhsminor.yy172; + yymsp[-5].minor.yy636 = yylhsminor.yy636; break; - case 346: /* predicate ::= expression IS NULL */ + case 349: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy172); - yylhsminor.yy172 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy172), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy636); + yylhsminor.yy636 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy636), NULL)); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 347: /* predicate ::= expression IS NOT NULL */ + case 350: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy172); - yylhsminor.yy172 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy172), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy636); + yylhsminor.yy636 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy636), NULL)); } - yymsp[-3].minor.yy172 = yylhsminor.yy172; + yymsp[-3].minor.yy636 = yylhsminor.yy636; break; - case 349: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy572 = OP_TYPE_LOWER_THAN; } + case 352: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy136 = OP_TYPE_LOWER_THAN; } break; - case 350: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy572 = OP_TYPE_GREATER_THAN; } + case 353: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy136 = OP_TYPE_GREATER_THAN; } break; - case 351: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy572 = OP_TYPE_LOWER_EQUAL; } + case 354: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy136 = OP_TYPE_LOWER_EQUAL; } break; - case 352: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy572 = OP_TYPE_GREATER_EQUAL; } + case 355: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy136 = OP_TYPE_GREATER_EQUAL; } break; - case 353: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy572 = OP_TYPE_NOT_EQUAL; } + case 356: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy136 = OP_TYPE_NOT_EQUAL; } break; - case 354: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy572 = OP_TYPE_EQUAL; } + case 357: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy136 = OP_TYPE_EQUAL; } break; - case 355: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy572 = OP_TYPE_LIKE; } + case 358: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy136 = OP_TYPE_LIKE; } break; - case 356: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy572 = OP_TYPE_NOT_LIKE; } + case 359: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy136 = OP_TYPE_NOT_LIKE; } break; - case 357: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy572 = OP_TYPE_MATCH; } + case 360: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy136 = OP_TYPE_MATCH; } break; - case 358: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy572 = OP_TYPE_NMATCH; } + case 361: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy136 = OP_TYPE_NMATCH; } break; - case 359: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy572 = OP_TYPE_JSON_CONTAINS; } + case 362: /* compare_op ::= CONTAINS */ +{ yymsp[0].minor.yy136 = OP_TYPE_JSON_CONTAINS; } break; - case 360: /* in_op ::= IN */ -{ yymsp[0].minor.yy572 = OP_TYPE_IN; } + case 363: /* in_op ::= IN */ +{ yymsp[0].minor.yy136 = OP_TYPE_IN; } break; - case 361: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy572 = OP_TYPE_NOT_IN; } + case 364: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy136 = OP_TYPE_NOT_IN; } break; - case 362: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy172 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy60)); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 365: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy636 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy236)); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 364: /* boolean_value_expression ::= NOT boolean_primary */ + case 367: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy172); - yylhsminor.yy172 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy172), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy636); + yylhsminor.yy636 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy636), NULL)); } - yymsp[-1].minor.yy172 = yylhsminor.yy172; + yymsp[-1].minor.yy636 = yylhsminor.yy636; break; - case 365: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 368: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy172); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy172); - yylhsminor.yy172 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy172), releaseRawExprNode(pCxt, yymsp[0].minor.yy172))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy636); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy636); + yylhsminor.yy636 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy636), releaseRawExprNode(pCxt, yymsp[0].minor.yy636))); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 366: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 369: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy172); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy172); - yylhsminor.yy172 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy172), releaseRawExprNode(pCxt, yymsp[0].minor.yy172))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy636); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy636); + yylhsminor.yy636 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy636), releaseRawExprNode(pCxt, yymsp[0].minor.yy636))); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 373: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy172 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy172, yymsp[0].minor.yy172, NULL); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 376: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy636 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy636, yymsp[0].minor.yy636, NULL); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 376: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy172 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy105, &yymsp[0].minor.yy105); } - yymsp[-1].minor.yy172 = yylhsminor.yy172; + case 379: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy636 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy53, &yymsp[0].minor.yy53); } + yymsp[-1].minor.yy636 = yylhsminor.yy636; break; - case 377: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy172 = createRealTableNode(pCxt, &yymsp[-3].minor.yy105, &yymsp[-1].minor.yy105, &yymsp[0].minor.yy105); } - yymsp[-3].minor.yy172 = yylhsminor.yy172; + case 380: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy636 = createRealTableNode(pCxt, &yymsp[-3].minor.yy53, &yymsp[-1].minor.yy53, &yymsp[0].minor.yy53); } + yymsp[-3].minor.yy636 = yylhsminor.yy636; break; - case 378: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy172 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy172), &yymsp[0].minor.yy105); } - yymsp[-1].minor.yy172 = yylhsminor.yy172; + case 381: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy636 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy636), &yymsp[0].minor.yy53); } + yymsp[-1].minor.yy636 = yylhsminor.yy636; break; - case 380: /* alias_opt ::= */ -{ yymsp[1].minor.yy105 = nil_token; } + case 383: /* alias_opt ::= */ +{ yymsp[1].minor.yy53 = nil_token; } break; - case 381: /* alias_opt ::= table_alias */ -{ yylhsminor.yy105 = yymsp[0].minor.yy105; } - yymsp[0].minor.yy105 = yylhsminor.yy105; + case 384: /* alias_opt ::= table_alias */ +{ yylhsminor.yy53 = yymsp[0].minor.yy53; } + yymsp[0].minor.yy53 = yylhsminor.yy53; break; - case 382: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy105 = yymsp[0].minor.yy105; } + case 385: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy53 = yymsp[0].minor.yy53; } break; - case 383: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 384: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==384); -{ yymsp[-2].minor.yy172 = yymsp[-1].minor.yy172; } + case 386: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 387: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==387); +{ yymsp[-2].minor.yy636 = yymsp[-1].minor.yy636; } break; - case 385: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy172 = createJoinTableNode(pCxt, yymsp[-4].minor.yy636, yymsp[-5].minor.yy172, yymsp[-2].minor.yy172, yymsp[0].minor.yy172); } - yymsp[-5].minor.yy172 = yylhsminor.yy172; + case 388: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy636 = createJoinTableNode(pCxt, yymsp[-4].minor.yy342, yymsp[-5].minor.yy636, yymsp[-2].minor.yy636, yymsp[0].minor.yy636); } + yymsp[-5].minor.yy636 = yylhsminor.yy636; break; - case 386: /* join_type ::= */ -{ yymsp[1].minor.yy636 = JOIN_TYPE_INNER; } + case 389: /* join_type ::= */ +{ yymsp[1].minor.yy342 = JOIN_TYPE_INNER; } break; - case 387: /* join_type ::= INNER */ -{ yymsp[0].minor.yy636 = JOIN_TYPE_INNER; } + case 390: /* join_type ::= INNER */ +{ yymsp[0].minor.yy342 = JOIN_TYPE_INNER; } break; - case 388: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 391: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { - yymsp[-8].minor.yy172 = createSelectStmt(pCxt, yymsp[-7].minor.yy617, yymsp[-6].minor.yy60, yymsp[-5].minor.yy172); - yymsp[-8].minor.yy172 = addWhereClause(pCxt, yymsp[-8].minor.yy172, yymsp[-4].minor.yy172); - yymsp[-8].minor.yy172 = addPartitionByClause(pCxt, yymsp[-8].minor.yy172, yymsp[-3].minor.yy60); - yymsp[-8].minor.yy172 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy172, yymsp[-2].minor.yy172); - yymsp[-8].minor.yy172 = addGroupByClause(pCxt, yymsp[-8].minor.yy172, yymsp[-1].minor.yy60); - yymsp[-8].minor.yy172 = addHavingClause(pCxt, yymsp[-8].minor.yy172, yymsp[0].minor.yy172); + yymsp[-8].minor.yy636 = createSelectStmt(pCxt, yymsp[-7].minor.yy603, yymsp[-6].minor.yy236, yymsp[-5].minor.yy636); + yymsp[-8].minor.yy636 = addWhereClause(pCxt, yymsp[-8].minor.yy636, yymsp[-4].minor.yy636); + yymsp[-8].minor.yy636 = addPartitionByClause(pCxt, yymsp[-8].minor.yy636, yymsp[-3].minor.yy236); + yymsp[-8].minor.yy636 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy636, yymsp[-2].minor.yy636); + yymsp[-8].minor.yy636 = addGroupByClause(pCxt, yymsp[-8].minor.yy636, yymsp[-1].minor.yy236); + yymsp[-8].minor.yy636 = addHavingClause(pCxt, yymsp[-8].minor.yy636, yymsp[0].minor.yy636); } break; - case 391: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy617 = false; } + case 394: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy603 = false; } break; - case 392: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy60 = NULL; } + case 395: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy236 = NULL; } break; - case 397: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy172 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy172), &yymsp[0].minor.yy105); } - yymsp[-1].minor.yy172 = yylhsminor.yy172; + case 400: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy636 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy636), &yymsp[0].minor.yy53); } + yymsp[-1].minor.yy636 = yylhsminor.yy636; break; - case 398: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy172 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy172), &yymsp[0].minor.yy105); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 401: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy636 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy636), &yymsp[0].minor.yy53); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 403: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 420: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==420); - case 432: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==432); -{ yymsp[-2].minor.yy60 = yymsp[0].minor.yy60; } + case 406: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 423: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==423); + case 435: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==435); +{ yymsp[-2].minor.yy236 = yymsp[0].minor.yy236; } break; - case 405: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy172 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy172), releaseRawExprNode(pCxt, yymsp[-1].minor.yy172)); } + case 408: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy636 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy636), releaseRawExprNode(pCxt, yymsp[-1].minor.yy636)); } break; - case 406: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ -{ yymsp[-3].minor.yy172 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy172)); } + case 409: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ +{ yymsp[-3].minor.yy636 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy636)); } break; - case 407: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy172 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy172), NULL, yymsp[-1].minor.yy172, yymsp[0].minor.yy172); } + case 410: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy636 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy636), NULL, yymsp[-1].minor.yy636, yymsp[0].minor.yy636); } break; - case 408: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy172 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy172), releaseRawExprNode(pCxt, yymsp[-3].minor.yy172), yymsp[-1].minor.yy172, yymsp[0].minor.yy172); } + case 411: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy636 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy636), releaseRawExprNode(pCxt, yymsp[-3].minor.yy636), yymsp[-1].minor.yy636, yymsp[0].minor.yy636); } break; - case 410: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ -{ yymsp[-3].minor.yy172 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy172); } + case 413: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ +{ yymsp[-3].minor.yy636 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy636); } break; - case 412: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy172 = createFillNode(pCxt, yymsp[-1].minor.yy202, NULL); } + case 415: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy636 = createFillNode(pCxt, yymsp[-1].minor.yy18, NULL); } break; - case 413: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy172 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy60)); } + case 416: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy636 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy236)); } break; - case 414: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy202 = FILL_MODE_NONE; } + case 417: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy18 = FILL_MODE_NONE; } break; - case 415: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy202 = FILL_MODE_PREV; } + case 418: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy18 = FILL_MODE_PREV; } break; - case 416: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy202 = FILL_MODE_NULL; } + case 419: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy18 = FILL_MODE_NULL; } break; - case 417: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy202 = FILL_MODE_LINEAR; } + case 420: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy18 = FILL_MODE_LINEAR; } break; - case 418: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy202 = FILL_MODE_NEXT; } + case 421: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy18 = FILL_MODE_NEXT; } break; - case 421: /* group_by_list ::= expression */ -{ yylhsminor.yy60 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy172))); } - yymsp[0].minor.yy60 = yylhsminor.yy60; + case 424: /* group_by_list ::= expression */ +{ yylhsminor.yy236 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy636))); } + yymsp[0].minor.yy236 = yylhsminor.yy236; break; - case 422: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy60 = addNodeToList(pCxt, yymsp[-2].minor.yy60, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy172))); } - yymsp[-2].minor.yy60 = yylhsminor.yy60; + case 425: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy236 = addNodeToList(pCxt, yymsp[-2].minor.yy236, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy636))); } + yymsp[-2].minor.yy236 = yylhsminor.yy236; break; - case 425: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 428: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy172 = addOrderByClause(pCxt, yymsp[-3].minor.yy172, yymsp[-2].minor.yy60); - yylhsminor.yy172 = addSlimitClause(pCxt, yylhsminor.yy172, yymsp[-1].minor.yy172); - yylhsminor.yy172 = addLimitClause(pCxt, yylhsminor.yy172, yymsp[0].minor.yy172); + yylhsminor.yy636 = addOrderByClause(pCxt, yymsp[-3].minor.yy636, yymsp[-2].minor.yy236); + yylhsminor.yy636 = addSlimitClause(pCxt, yylhsminor.yy636, yymsp[-1].minor.yy636); + yylhsminor.yy636 = addLimitClause(pCxt, yylhsminor.yy636, yymsp[0].minor.yy636); } - yymsp[-3].minor.yy172 = yylhsminor.yy172; + yymsp[-3].minor.yy636 = yylhsminor.yy636; break; - case 427: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy172 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy172, yymsp[0].minor.yy172); } - yymsp[-3].minor.yy172 = yylhsminor.yy172; + case 430: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy636 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy636, yymsp[0].minor.yy636); } + yymsp[-3].minor.yy636 = yylhsminor.yy636; break; - case 428: /* query_expression_body ::= query_expression_body UNION query_expression_body */ -{ yylhsminor.yy172 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy172, yymsp[0].minor.yy172); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 431: /* query_expression_body ::= query_expression_body UNION query_expression_body */ +{ yylhsminor.yy636 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy636, yymsp[0].minor.yy636); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 430: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ -{ yymsp[-5].minor.yy172 = yymsp[-4].minor.yy172; } - yy_destructor(yypParser,350,&yymsp[-3].minor); - yy_destructor(yypParser,351,&yymsp[-2].minor); - yy_destructor(yypParser,352,&yymsp[-1].minor); + case 433: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ +{ yymsp[-5].minor.yy636 = yymsp[-4].minor.yy636; } + yy_destructor(yypParser,353,&yymsp[-3].minor); + yy_destructor(yypParser,354,&yymsp[-2].minor); + yy_destructor(yypParser,355,&yymsp[-1].minor); break; - case 434: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 438: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==438); -{ yymsp[-1].minor.yy172 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 437: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 441: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==441); +{ yymsp[-1].minor.yy636 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 435: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 439: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==439); -{ yymsp[-3].minor.yy172 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 438: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 442: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==442); +{ yymsp[-3].minor.yy636 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 436: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 440: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==440); -{ yymsp[-3].minor.yy172 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 439: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 443: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==443); +{ yymsp[-3].minor.yy636 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 441: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy172 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy172); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 444: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy636 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy636); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 445: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy172 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy172), yymsp[-1].minor.yy14, yymsp[0].minor.yy17); } - yymsp[-2].minor.yy172 = yylhsminor.yy172; + case 448: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy636 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy636), yymsp[-1].minor.yy430, yymsp[0].minor.yy185); } + yymsp[-2].minor.yy636 = yylhsminor.yy636; break; - case 446: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy14 = ORDER_ASC; } + case 449: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy430 = ORDER_ASC; } break; - case 447: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy14 = ORDER_ASC; } + case 450: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy430 = ORDER_ASC; } break; - case 448: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy14 = ORDER_DESC; } + case 451: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy430 = ORDER_DESC; } break; - case 449: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy17 = NULL_ORDER_DEFAULT; } + case 452: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy185 = NULL_ORDER_DEFAULT; } break; - case 450: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy17 = NULL_ORDER_FIRST; } + case 453: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy185 = NULL_ORDER_FIRST; } break; - case 451: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy17 = NULL_ORDER_LAST; } + case 454: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy185 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/parInitialCTest.cpp b/source/libs/parser/test/parInitialCTest.cpp index abcb6bca8b..a5e7ef51a7 100644 --- a/source/libs/parser/test/parInitialCTest.cpp +++ b/source/libs/parser/test/parInitialCTest.cpp @@ -90,6 +90,7 @@ TEST_F(ParserInitialCTest, createDatabase) { expect.walLevel = TSDB_DEFAULT_WAL_LEVEL; expect.numOfVgroups = TSDB_DEFAULT_VN_PER_DB; expect.numOfStables = TSDB_DEFAULT_DB_SINGLE_STABLE; + expect.schemaless = TSDB_DEFAULT_DB_SCHEMALESS; }; auto setDbBufferFunc = [&](int32_t buffer) { expect.buffer = buffer; }; @@ -124,6 +125,7 @@ TEST_F(ParserInitialCTest, createDatabase) { taosArrayPush(expect.pRetensions, &retention); ++expect.numOfRetensions; }; + auto setDbSchemalessFunc = [&](int8_t schemaless) { expect.schemaless = schemaless; }; setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) { ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_CREATE_DATABASE_STMT); @@ -149,6 +151,7 @@ TEST_F(ParserInitialCTest, createDatabase) { ASSERT_EQ(req.replications, expect.replications); ASSERT_EQ(req.strict, expect.strict); ASSERT_EQ(req.cacheLastRow, expect.cacheLastRow); + ASSERT_EQ(req.schemaless, expect.schemaless); ASSERT_EQ(req.ignoreExist, expect.ignoreExist); ASSERT_EQ(req.numOfRetensions, expect.numOfRetensions); if (expect.numOfRetensions > 0) { @@ -188,6 +191,7 @@ TEST_F(ParserInitialCTest, createDatabase) { setDbWalLevelFunc(2); setDbVgroupsFunc(100); setDbSingleStableFunc(1); + setDbSchemalessFunc(1); run("CREATE DATABASE IF NOT EXISTS wxy_db " "BUFFER 64 " "CACHELAST 2 " @@ -205,7 +209,8 @@ TEST_F(ParserInitialCTest, createDatabase) { "STRICT 1 " "WAL 2 " "VGROUPS 100 " - "SINGLE_STABLE 1 "); + "SINGLE_STABLE 1 " + "SCHEMALESS 1"); setCreateDbReqFunc("wxy_db", 1); setDbDaysFunc(100); diff --git a/source/libs/parser/test/parInitialDTest.cpp b/source/libs/parser/test/parInitialDTest.cpp index 1153b238b1..7cf3337fea 100644 --- a/source/libs/parser/test/parInitialDTest.cpp +++ b/source/libs/parser/test/parInitialDTest.cpp @@ -19,7 +19,7 @@ using namespace std; namespace ParserTest { -class ParserInitialDTest : public ParserTestBase {}; +class ParserInitialDTest : public ParserDdlTest {}; // todo delete // todo desc @@ -29,7 +29,37 @@ class ParserInitialDTest : public ParserTestBase {}; TEST_F(ParserInitialDTest, dropBnode) { useDb("root", "test"); - run("drop bnode on dnode 1"); + run("DROP BNODE ON DNODE 1"); +} + +// DROP CGROUP [ IF EXISTS ] cgroup_name ON topic_name +TEST_F(ParserInitialDTest, dropCGroup) { + useDb("root", "test"); + + SMDropCgroupReq expect = {0}; + + auto setDropCgroupReqFunc = [&](const char* pTopicName, const char* pCGroupName, int8_t igNotExists = 0) { + memset(&expect, 0, sizeof(SMDropCgroupReq)); + snprintf(expect.topic, sizeof(expect.topic), "0.%s", pTopicName); + strcpy(expect.cgroup, pCGroupName); + expect.igNotExists = igNotExists; + }; + + setCheckDdlFunc([&](const SQuery* pQuery, ParserStage stage) { + ASSERT_EQ(nodeType(pQuery->pRoot), QUERY_NODE_DROP_CGROUP_STMT); + SMDropCgroupReq req = {0}; + ASSERT_TRUE(TSDB_CODE_SUCCESS == tDeserializeSMDropCgroupReq(pQuery->pCmdMsg->pMsg, pQuery->pCmdMsg->msgLen, &req)); + + ASSERT_EQ(std::string(req.topic), std::string(expect.topic)); + ASSERT_EQ(std::string(req.cgroup), std::string(expect.cgroup)); + ASSERT_EQ(req.igNotExists, expect.igNotExists); + }); + + setDropCgroupReqFunc("tp1", "cg1"); + run("DROP CGROUP cg1 ON tp1"); + + setDropCgroupReqFunc("tp1", "cg1", 1); + run("DROP CGROUP IF EXISTS cg1 ON tp1"); } // todo drop database diff --git a/source/libs/parser/test/parSelectTest.cpp b/source/libs/parser/test/parSelectTest.cpp index b68ef2c591..f00500faa4 100644 --- a/source/libs/parser/test/parSelectTest.cpp +++ b/source/libs/parser/test/parSelectTest.cpp @@ -121,13 +121,13 @@ TEST_F(ParserSelectTest, selectFunc) { run("SELECT MAX(c1), c2 FROM t1 STATE_WINDOW(c3)"); } -TEST_F(ParserSelectTest, nonstdFunc) { +TEST_F(ParserSelectTest, IndefiniteRowsFunc) { useDb("root", "test"); run("SELECT DIFF(c1) FROM t1"); } -TEST_F(ParserSelectTest, nonstdFuncSemanticCheck) { +TEST_F(ParserSelectTest, IndefiniteRowsFuncSemanticCheck) { useDb("root", "test"); run("SELECT DIFF(c1), c2 FROM t1", TSDB_CODE_PAR_NOT_ALLOWED_FUNC, PARSER_STAGE_TRANSLATE); diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 4e77ae5fba..467b26b7c4 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -321,6 +321,7 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect } pJoin->joinType = pJoinTable->joinType; + pJoin->isSingleTableJoin = pJoinTable->table.singleTable; int32_t code = TSDB_CODE_SUCCESS; @@ -418,7 +419,7 @@ static SColumnNode* createColumnByExpr(const char* pStmtName, SExprNode* pExpr) } static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { - if (!pSelect->hasAggFuncs && !pSelect->hasIndefiniteRowsFunc && NULL == pSelect->pGroupByList) { + if (!pSelect->hasAggFuncs && NULL == pSelect->pGroupByList) { return TSDB_CODE_SUCCESS; } @@ -442,8 +443,8 @@ static int32_t createAggLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, code = rewriteExprForSelect(pAgg->pGroupKeys, pSelect, SQL_CLAUSE_GROUP_BY); } - if (TSDB_CODE_SUCCESS == code && (pSelect->hasAggFuncs || pSelect->hasIndefiniteRowsFunc)) { - code = nodesCollectFuncs(pSelect, SQL_CLAUSE_GROUP_BY, fmIsVectorFunc, &pAgg->pAggFuncs); + if (TSDB_CODE_SUCCESS == code && pSelect->hasAggFuncs) { + code = nodesCollectFuncs(pSelect, SQL_CLAUSE_GROUP_BY, fmIsAggFunc, &pAgg->pAggFuncs); } // rewrite the expression in subsequent clauses diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index 1a97d9ab1b..ea149f8363 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -18,7 +18,6 @@ #define SPLIT_FLAG_MASK(n) (1 << n) #define SPLIT_FLAG_STS SPLIT_FLAG_MASK(0) -#define SPLIT_FLAG_CTJ SPLIT_FLAG_MASK(1) #define SPLIT_FLAG_SET_MASK(val, mask) (val) |= (mask) #define SPLIT_FLAG_TEST_MASK(val, mask) (((val) & (mask)) != 0) @@ -42,7 +41,8 @@ typedef struct SStsInfo { } SStsInfo; typedef struct SCtjInfo { - SScanLogicNode* pScan; + SJoinLogicNode* pJoin; + SLogicNode* pSplitNode; SLogicSubplan* pSubplan; } SCtjInfo; @@ -58,7 +58,7 @@ typedef struct SUnInfo { typedef bool (*FSplFindSplitNode)(SLogicSubplan* pSubplan, void* pInfo); -static SLogicSubplan* splCreateScanSubplan(SSplitContext* pCxt, SScanLogicNode* pScan, int32_t flag) { +static SLogicSubplan* splCreateSubplan(SSplitContext* pCxt, SLogicNode* pNode, int32_t flag) { SLogicSubplan* pSubplan = nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN); if (NULL == pSubplan) { return NULL; @@ -66,35 +66,37 @@ static SLogicSubplan* splCreateScanSubplan(SSplitContext* pCxt, SScanLogicNode* pSubplan->id.queryId = pCxt->queryId; pSubplan->id.groupId = pCxt->groupId; pSubplan->subplanType = SUBPLAN_TYPE_SCAN; - pSubplan->pNode = (SLogicNode*)nodesCloneNode(pScan); - TSWAP(pSubplan->pVgroupList, ((SScanLogicNode*)pSubplan->pNode)->pVgroupList); + pSubplan->pNode = (SLogicNode*)nodesCloneNode(pNode); + if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode)) { + TSWAP(pSubplan->pVgroupList, ((SScanLogicNode*)pSubplan->pNode)->pVgroupList); + } SPLIT_FLAG_SET_MASK(pSubplan->splitFlag, flag); return pSubplan; } -static int32_t splCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SScanLogicNode* pScan, +static int32_t splCreateExchangeNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pSplitNode, ESubplanType subplanType) { SExchangeLogicNode* pExchange = nodesMakeNode(QUERY_NODE_LOGIC_PLAN_EXCHANGE); if (NULL == pExchange) { return TSDB_CODE_OUT_OF_MEMORY; } pExchange->srcGroupId = pCxt->groupId; - pExchange->precision = pScan->pMeta->tableInfo.precision; - pExchange->node.pTargets = nodesCloneList(pScan->node.pTargets); + pExchange->precision = pSplitNode->precision; + pExchange->node.pTargets = nodesCloneList(pSplitNode->pTargets); if (NULL == pExchange->node.pTargets) { return TSDB_CODE_OUT_OF_MEMORY; } - pSubplan->subplanType = SUBPLAN_TYPE_MERGE; + pSubplan->subplanType = subplanType; - if (NULL == pScan->node.pParent) { + if (NULL == pSplitNode->pParent) { pSubplan->pNode = (SLogicNode*)pExchange; return TSDB_CODE_SUCCESS; } SNode* pNode; - FOREACH(pNode, pScan->node.pParent->pChildren) { - if (nodesEqualNode(pNode, pScan)) { + FOREACH(pNode, pSplitNode->pParent->pChildren) { + if (nodesEqualNode(pNode, pSplitNode)) { REPLACE_NODE(pExchange); nodesDestroyNode(pNode); return TSDB_CODE_SUCCESS; @@ -148,33 +150,31 @@ static int32_t stsSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) { if (!splMatch(pCxt, pSubplan, SPLIT_FLAG_STS, (FSplFindSplitNode)stsFindSplitNode, &info)) { return TSDB_CODE_SUCCESS; } - int32_t code = - nodesListMakeStrictAppend(&info.pSubplan->pChildren, splCreateScanSubplan(pCxt, info.pScan, SPLIT_FLAG_STS)); + int32_t code = nodesListMakeStrictAppend(&info.pSubplan->pChildren, + splCreateSubplan(pCxt, (SLogicNode*)info.pScan, SPLIT_FLAG_STS)); if (TSDB_CODE_SUCCESS == code) { - code = splCreateExchangeNode(pCxt, info.pSubplan, info.pScan, SUBPLAN_TYPE_MERGE); + code = splCreateExchangeNode(pCxt, info.pSubplan, (SLogicNode*)info.pScan, SUBPLAN_TYPE_MERGE); } ++(pCxt->groupId); pCxt->split = true; return code; } -static bool ctjIsSingleTable(int8_t tableType) { - return (TSDB_CHILD_TABLE == tableType || TSDB_NORMAL_TABLE == tableType); +static bool needSplit(SJoinLogicNode* pJoin) { + if (!pJoin->isSingleTableJoin) { + return false; + } + return QUERY_NODE_LOGIC_PLAN_EXCHANGE != nodeType(nodesListGetNode(pJoin->node.pChildren, 0)) && + QUERY_NODE_LOGIC_PLAN_EXCHANGE != nodeType(nodesListGetNode(pJoin->node.pChildren, 1)); } -static SLogicNode* ctjMatchByNode(SLogicNode* pNode) { - if (QUERY_NODE_LOGIC_PLAN_JOIN == nodeType(pNode)) { - SLogicNode* pLeft = (SLogicNode*)nodesListGetNode(pNode->pChildren, 0); - SLogicNode* pRight = (SLogicNode*)nodesListGetNode(pNode->pChildren, 1); - if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pLeft) && ctjIsSingleTable(((SScanLogicNode*)pLeft)->pMeta->tableType) && - QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pRight) && - ctjIsSingleTable(((SScanLogicNode*)pRight)->pMeta->tableType)) { - return pRight; - } +static SJoinLogicNode* ctjMatchByNode(SLogicNode* pNode) { + if (QUERY_NODE_LOGIC_PLAN_JOIN == nodeType(pNode) && needSplit((SJoinLogicNode*)pNode)) { + return (SJoinLogicNode*)pNode; } SNode* pChild; FOREACH(pChild, pNode->pChildren) { - SLogicNode* pSplitNode = ctjMatchByNode((SLogicNode*)pChild); + SJoinLogicNode* pSplitNode = ctjMatchByNode((SLogicNode*)pChild); if (NULL != pSplitNode) { return pSplitNode; } @@ -183,23 +183,23 @@ static SLogicNode* ctjMatchByNode(SLogicNode* pNode) { } static bool ctjFindSplitNode(SLogicSubplan* pSubplan, SCtjInfo* pInfo) { - SLogicNode* pSplitNode = ctjMatchByNode(pSubplan->pNode); - if (NULL != pSplitNode) { - pInfo->pScan = (SScanLogicNode*)pSplitNode; + SJoinLogicNode* pJoin = ctjMatchByNode(pSubplan->pNode); + if (NULL != pJoin) { + pInfo->pJoin = pJoin; + pInfo->pSplitNode = nodesListGetNode(pJoin->node.pChildren, 1); pInfo->pSubplan = pSubplan; } - return NULL != pSplitNode; + return NULL != pJoin; } static int32_t ctjSplit(SSplitContext* pCxt, SLogicSubplan* pSubplan) { SCtjInfo info = {0}; - if (!splMatch(pCxt, pSubplan, SPLIT_FLAG_CTJ, (FSplFindSplitNode)ctjFindSplitNode, &info)) { + if (!splMatch(pCxt, pSubplan, 0, (FSplFindSplitNode)ctjFindSplitNode, &info)) { return TSDB_CODE_SUCCESS; } - int32_t code = - nodesListMakeStrictAppend(&info.pSubplan->pChildren, splCreateScanSubplan(pCxt, info.pScan, SPLIT_FLAG_CTJ)); + int32_t code = nodesListMakeStrictAppend(&info.pSubplan->pChildren, splCreateSubplan(pCxt, info.pSplitNode, 0)); if (TSDB_CODE_SUCCESS == code) { - code = splCreateExchangeNode(pCxt, info.pSubplan, info.pScan, info.pSubplan->subplanType); + code = splCreateExchangeNode(pCxt, info.pSubplan, info.pSplitNode, info.pSubplan->subplanType); } ++(pCxt->groupId); pCxt->split = true; diff --git a/source/libs/planner/test/planSubqueryTest.cpp b/source/libs/planner/test/planSubqueryTest.cpp index 2d559c6f3b..f82e10e998 100644 --- a/source/libs/planner/test/planSubqueryTest.cpp +++ b/source/libs/planner/test/planSubqueryTest.cpp @@ -26,6 +26,8 @@ TEST_F(PlanSubqeuryTest, basic) { run("SELECT * FROM (SELECT * FROM t1)"); run("SELECT LAST(c1) FROM (SELECT * FROM t1)"); + + run("SELECT c1 FROM (SELECT TODAY() AS c1 FROM t1)"); } TEST_F(PlanSubqeuryTest, doubleGroupBy) { From deeeefdb04abf6a37e47d609c5e6aa6c7dff6808 Mon Sep 17 00:00:00 2001 From: afwerar <1296468573@qq.com> Date: Wed, 25 May 2022 21:31:19 +0800 Subject: [PATCH 46/63] fix(os): dll exit error --- source/libs/catalog/src/ctgCache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/libs/catalog/src/ctgCache.c b/source/libs/catalog/src/ctgCache.c index 19b3e5f172..8e8de402a7 100644 --- a/source/libs/catalog/src/ctgCache.c +++ b/source/libs/catalog/src/ctgCache.c @@ -1458,7 +1458,7 @@ _return: } void ctgUpdateThreadFuncUnexpectedStopped(void) { - if (CTG_IS_LOCKED(&gCtgMgmt.lock) == TD_RWLATCH_WRITE_FLAG_COPY) CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock); + if (CTG_IS_LOCKED(&gCtgMgmt.lock) > 0) CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock); } void* ctgUpdateThreadFunc(void* param) { From 8d56f7e1ecb2191bedb5abb6c9668fd396a040a4 Mon Sep 17 00:00:00 2001 From: dapan1121 Date: Wed, 25 May 2022 22:05:29 +0800 Subject: [PATCH 47/63] fix mem free issue --- source/libs/catalog/src/catalog.c | 17 +++++++---------- source/libs/catalog/src/ctgAsync.c | 2 +- source/libs/catalog/src/ctgCache.c | 2 -- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index 98d40930ac..4afebf9951 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -327,31 +327,28 @@ int32_t ctgChkAuth(SCatalog* pCtg, void *pTrans, const SEpSet* pMgmtEps, const c return TSDB_CODE_SUCCESS; } - SGetUserAuthRsp* authRsp = taosMemoryCalloc(1, sizeof(SGetUserAuthRsp)); - if (NULL == authRsp) { - CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); - } - CTG_ERR_RET(ctgGetUserDbAuthFromMnode(CTG_PARAMS_LIST(), user, authRsp, NULL)); + SGetUserAuthRsp authRsp = {0}; + CTG_ERR_RET(ctgGetUserDbAuthFromMnode(CTG_PARAMS_LIST(), user, &authRsp, NULL)); - if (authRsp->superAuth) { + if (authRsp.superAuth) { *pass = true; goto _return; } - if (authRsp->createdDbs && taosHashGet(authRsp->createdDbs, dbFName, strlen(dbFName))) { + if (authRsp.createdDbs && taosHashGet(authRsp.createdDbs, dbFName, strlen(dbFName))) { *pass = true; goto _return; } - if (type == AUTH_TYPE_READ && authRsp->readDbs && taosHashGet(authRsp->readDbs, dbFName, strlen(dbFName))) { + if (type == AUTH_TYPE_READ && authRsp.readDbs && taosHashGet(authRsp.readDbs, dbFName, strlen(dbFName))) { *pass = true; - } else if (type == AUTH_TYPE_WRITE && authRsp->writeDbs && taosHashGet(authRsp->writeDbs, dbFName, strlen(dbFName))) { + } else if (type == AUTH_TYPE_WRITE && authRsp.writeDbs && taosHashGet(authRsp.writeDbs, dbFName, strlen(dbFName))) { *pass = true; } _return: - ctgPutUpdateUserToQueue(pCtg, authRsp, false); + ctgPutUpdateUserToQueue(pCtg, &authRsp, false); return TSDB_CODE_SUCCESS; } diff --git a/source/libs/catalog/src/ctgAsync.c b/source/libs/catalog/src/ctgAsync.c index b3e4bf6d22..0341c3638b 100644 --- a/source/libs/catalog/src/ctgAsync.c +++ b/source/libs/catalog/src/ctgAsync.c @@ -770,7 +770,7 @@ _return: } ctgPutUpdateUserToQueue(pCtg, pOut, false); - pTask->msgCtx.out = NULL; + taosMemoryFreeClear(pTask->msgCtx.out); ctgHandleTaskEnd(pTask, code); diff --git a/source/libs/catalog/src/ctgCache.c b/source/libs/catalog/src/ctgCache.c index 27cd41eed5..3c7d1e2bce 100644 --- a/source/libs/catalog/src/ctgCache.c +++ b/source/libs/catalog/src/ctgCache.c @@ -715,8 +715,6 @@ int32_t ctgPutUpdateUserToQueue(SCatalog* pCtg, SGetUserAuthRsp *pAuth, bool syn action.data = msg; CTG_ERR_JRET(ctgPushAction(pCtg, &action)); - - taosMemoryFree(pAuth); return TSDB_CODE_SUCCESS; From 0de64aa805148b4449d034406168c160b220286c Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Wed, 25 May 2022 22:33:41 +0800 Subject: [PATCH 48/63] feat: sql command 'drop cgroup' --- source/common/src/tdatablock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 0350510894..61ac01e4fa 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -321,7 +321,7 @@ int32_t colDataAssign(SColumnInfoData* pColumnInfoData, const SColumnInfoData* p pColumnInfoData->nullbitmap = tmp; memcpy(pColumnInfoData->nullbitmap, pSource->nullbitmap, BitmapLen(numOfRows)); - if (pColumnInfoData->pData) { + if (pSource->pData) { int32_t newSize = numOfRows * pColumnInfoData->info.bytes; tmp = taosMemoryRealloc(pColumnInfoData->pData, newSize); if (tmp == NULL) { From 80d780eb03dd223428a15bc6e09b520137700b28 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Wed, 25 May 2022 22:47:56 +0800 Subject: [PATCH 49/63] fix: use schema version of row when commit --- source/dnode/vnode/src/inc/tsdb.h | 13 +++++++--- source/dnode/vnode/src/tsdb/tsdbCommit.c | 30 ++++++++++++---------- source/dnode/vnode/src/tsdb/tsdbMemTable.c | 25 ++++++++++-------- source/dnode/vnode/src/tsdb/tsdbReadImpl.c | 2 +- 4 files changed, 41 insertions(+), 29 deletions(-) diff --git a/source/dnode/vnode/src/inc/tsdb.h b/source/dnode/vnode/src/inc/tsdb.h index 1195f9e2b3..6d3d23cc20 100644 --- a/source/dnode/vnode/src/inc/tsdb.h +++ b/source/dnode/vnode/src/inc/tsdb.h @@ -40,8 +40,8 @@ typedef struct STable STable; int tsdbMemTableCreate(STsdb *pTsdb, STsdbMemTable **ppMemTable); void tsdbMemTableDestroy(STsdb *pTsdb, STsdbMemTable *pMemTable); -int tsdbLoadDataFromCache(STable *pTable, SSkipListIterator *pIter, TSKEY maxKey, int maxRowsToRead, SDataCols *pCols, - TKEY *filterKeys, int nFilterKeys, bool keepDup, SMergeInfo *pMergeInfo); +int tsdbLoadDataFromCache(STsdb *pTsdb, STable *pTable, SSkipListIterator *pIter, TSKEY maxKey, int maxRowsToRead, + SDataCols *pCols, TKEY *filterKeys, int nFilterKeys, bool keepDup, SMergeInfo *pMergeInfo); // tsdbCommit ================ @@ -179,7 +179,14 @@ struct STsdbFS { int tsdbLockRepo(STsdb *pTsdb); int tsdbUnlockRepo(STsdb *pTsdb); -static FORCE_INLINE STSchema *tsdbGetTableSchemaImpl(STable *pTable, bool lock, bool copy, int32_t version) { +static FORCE_INLINE STSchema *tsdbGetTableSchemaImpl(STsdb *pTsdb, STable *pTable, bool lock, bool copy, + int32_t version) { + + if ((version != -1) && (schemaVersion(pTable->pSchema) != version)) { + taosMemoryFreeClear(pTable->pSchema); + pTable->pSchema = metaGetTbTSchema(REPO_META(pTsdb), pTable->uid, version); + } + return pTable->pSchema; } diff --git a/source/dnode/vnode/src/tsdb/tsdbCommit.c b/source/dnode/vnode/src/tsdb/tsdbCommit.c index 93ec6028f8..d462b7e046 100644 --- a/source/dnode/vnode/src/tsdb/tsdbCommit.c +++ b/source/dnode/vnode/src/tsdb/tsdbCommit.c @@ -84,7 +84,7 @@ static int tsdbMergeBlockData(SCommitH *pCommith, SCommitIter *pIter, SDataCols static void tsdbResetCommitTable(SCommitH *pCommith); static void tsdbCloseCommitFile(SCommitH *pCommith, bool hasError); static bool tsdbCanAddSubBlock(SCommitH *pCommith, SBlock *pBlock, SMergeInfo *pInfo); -static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIter *pCommitIter, SDataCols *pTarget, +static void tsdbLoadAndMergeFromCache(STsdb *pTsdb, SDataCols *pDataCols, int *iter, SCommitIter *pCommitIter, SDataCols *pTarget, TSKEY maxKey, int maxRows, int8_t update); int tsdbWriteBlockIdx(SDFile *pHeadf, SArray *pIdxA, void **ppBuf); @@ -301,7 +301,8 @@ static void tsdbSeekCommitIter(SCommitH *pCommith, TSKEY key) { SCommitIter *pIter = pCommith->iters + i; if (pIter->pTable == NULL || pIter->pIter == NULL) continue; - tsdbLoadDataFromCache(pIter->pTable, pIter->pIter, key - 1, INT32_MAX, NULL, NULL, 0, true, NULL); + tsdbLoadDataFromCache(TSDB_COMMIT_REPO(pCommith), pIter->pTable, pIter->pIter, key - 1, INT32_MAX, NULL, NULL, 0, + true, NULL); } } @@ -947,7 +948,7 @@ static int tsdbMoveBlkIdx(SCommitH *pCommith, SBlockIdx *pIdx) { } static int tsdbSetCommitTable(SCommitH *pCommith, STable *pTable) { - STSchema *pSchema = tsdbGetTableSchemaImpl(pTable, false, false, -1); + STSchema *pSchema = tsdbGetTableSchemaImpl(TSDB_COMMIT_REPO(pCommith),pTable, false, false, -1); pCommith->pTable = pTable; @@ -1254,8 +1255,8 @@ static int tsdbCommitMemData(SCommitH *pCommith, SCommitIter *pIter, TSKEY keyLi SBlock block; while (true) { - tsdbLoadDataFromCache(pIter->pTable, pIter->pIter, keyLimit, defaultRows, pCommith->pDataCols, NULL, 0, - pCfg->update, &mInfo); + tsdbLoadDataFromCache(TSDB_COMMIT_REPO(pCommith), pIter->pTable, pIter->pIter, keyLimit, defaultRows, + pCommith->pDataCols, NULL, 0, pCfg->update, &mInfo); if (pCommith->pDataCols->numOfRows <= 0) break; @@ -1298,8 +1299,9 @@ static int tsdbMergeMemData(SCommitH *pCommith, SCommitIter *pIter, int bidx) { SSkipListIterator titer = *(pIter->pIter); if (tsdbLoadBlockDataCols(&(pCommith->readh), pBlock, NULL, &colId, 1, false) < 0) return -1; - tsdbLoadDataFromCache(pIter->pTable, &titer, keyLimit, INT32_MAX, NULL, pCommith->readh.pDCols[0]->cols[0].pData, - pCommith->readh.pDCols[0]->numOfRows, pCfg->update, &mInfo); + tsdbLoadDataFromCache(TSDB_COMMIT_REPO(pCommith), pIter->pTable, &titer, keyLimit, INT32_MAX, NULL, + pCommith->readh.pDCols[0]->cols[0].pData, pCommith->readh.pDCols[0]->numOfRows, pCfg->update, + &mInfo); if (mInfo.nOperations == 0) { // no new data to insert (all updates denied) @@ -1313,9 +1315,9 @@ static int tsdbMergeMemData(SCommitH *pCommith, SCommitIter *pIter, int bidx) { *(pIter->pIter) = titer; } else if (tsdbCanAddSubBlock(pCommith, pBlock, &mInfo)) { // Add a sub-block - tsdbLoadDataFromCache(pIter->pTable, pIter->pIter, keyLimit, INT32_MAX, pCommith->pDataCols, - pCommith->readh.pDCols[0]->cols[0].pData, pCommith->readh.pDCols[0]->numOfRows, pCfg->update, - &mInfo); + tsdbLoadDataFromCache(TSDB_COMMIT_REPO(pCommith), pIter->pTable, pIter->pIter, keyLimit, INT32_MAX, + pCommith->pDataCols, pCommith->readh.pDCols[0]->cols[0].pData, + pCommith->readh.pDCols[0]->numOfRows, pCfg->update, &mInfo); if (pBlock->last) { pDFile = TSDB_COMMIT_LAST_FILE(pCommith); } else { @@ -1420,7 +1422,7 @@ static int tsdbMergeBlockData(SCommitH *pCommith, SCommitIter *pIter, SDataCols int biter = 0; while (true) { - tsdbLoadAndMergeFromCache(pCommith->readh.pDCols[0], &biter, pIter, pCommith->pDataCols, keyLimit, defaultRows, + tsdbLoadAndMergeFromCache(TSDB_COMMIT_REPO(pCommith), pCommith->readh.pDCols[0], &biter, pIter, pCommith->pDataCols, keyLimit, defaultRows, pCfg->update); if (pCommith->pDataCols->numOfRows == 0) break; @@ -1445,7 +1447,7 @@ static int tsdbMergeBlockData(SCommitH *pCommith, SCommitIter *pIter, SDataCols return 0; } -static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIter *pCommitIter, SDataCols *pTarget, +static void tsdbLoadAndMergeFromCache(STsdb *pTsdb, SDataCols *pDataCols, int *iter, SCommitIter *pCommitIter, SDataCols *pTarget, TSKEY maxKey, int maxRows, int8_t update) { TSKEY key1 = INT64_MAX; TSKEY key2 = INT64_MAX; @@ -1487,7 +1489,7 @@ static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIt ++(*iter); } else if (key1 > key2) { if (pSchema == NULL || schemaVersion(pSchema) != TD_ROW_SVER(row)) { - pSchema = tsdbGetTableSchemaImpl(pCommitIter->pTable, false, false, TD_ROW_SVER(row)); + pSchema = tsdbGetTableSchemaImpl(pTsdb, pCommitIter->pTable, false, false, TD_ROW_SVER(row)); ASSERT(pSchema != NULL); } @@ -1527,7 +1529,7 @@ static void tsdbLoadAndMergeFromCache(SDataCols *pDataCols, int *iter, SCommitIt if (TD_SUPPORT_UPDATE(update)) { // copy mem data(Multi-Version) if (pSchema == NULL || schemaVersion(pSchema) != TD_ROW_SVER(row)) { - pSchema = tsdbGetTableSchemaImpl(pCommitIter->pTable, false, false, TD_ROW_SVER(row)); + pSchema = tsdbGetTableSchemaImpl(pTsdb, pCommitIter->pTable, false, false, TD_ROW_SVER(row)); ASSERT(pSchema != NULL); } diff --git a/source/dnode/vnode/src/tsdb/tsdbMemTable.c b/source/dnode/vnode/src/tsdb/tsdbMemTable.c index d8426db127..0a77274a21 100644 --- a/source/dnode/vnode/src/tsdb/tsdbMemTable.c +++ b/source/dnode/vnode/src/tsdb/tsdbMemTable.c @@ -20,7 +20,8 @@ static void tsdbFreeTbData(STbData *pTbData); static char *tsdbGetTsTupleKey(const void *data); static int tsdbTbDataComp(const void *arg1, const void *arg2); static char *tsdbTbDataGetUid(const void *arg); -static int tsdbAppendTableRowToCols(STable *pTable, SDataCols *pCols, STSchema **ppSchema, STSRow *row, bool merge); +static int tsdbAppendTableRowToCols(STsdb *pTsdb, STable *pTable, SDataCols *pCols, STSchema **ppSchema, STSRow *row, + bool merge); int tsdbMemTableCreate(STsdb *pTsdb, STsdbMemTable **ppMemTable) { STsdbMemTable *pMemTable; @@ -88,8 +89,8 @@ void tsdbMemTableDestroy(STsdb *pTsdb, STsdbMemTable *pMemTable) { * * The function tries to procceed AS MUCH AS POSSIBLE. */ -int tsdbLoadDataFromCache(STable *pTable, SSkipListIterator *pIter, TSKEY maxKey, int maxRowsToRead, SDataCols *pCols, - TKEY *filterKeys, int nFilterKeys, bool keepDup, SMergeInfo *pMergeInfo) { +int tsdbLoadDataFromCache(STsdb *pTsdb, STable *pTable, SSkipListIterator *pIter, TSKEY maxKey, int maxRowsToRead, + SDataCols *pCols, TKEY *filterKeys, int nFilterKeys, bool keepDup, SMergeInfo *pMergeInfo) { ASSERT(maxRowsToRead > 0 && nFilterKeys >= 0); if (pIter == NULL) return 0; STSchema *pSchema = NULL; @@ -222,12 +223,12 @@ int tsdbLoadDataFromCache(STable *pTable, SSkipListIterator *pIter, TSKEY maxKey if (lastKey != TSKEY_INITIAL_VAL) { ++pCols->numOfRows; } - tsdbAppendTableRowToCols(pTable, pCols, &pSchema, row, false); + tsdbAppendTableRowToCols(pTsdb, pTable, pCols, &pSchema, row, false); } lastKey = rowKey; } else { if (keepDup) { - tsdbAppendTableRowToCols(pTable, pCols, &pSchema, row, true); + tsdbAppendTableRowToCols(pTsdb, pTable, pCols, &pSchema, row, true); } else { // discard } @@ -249,7 +250,7 @@ int tsdbLoadDataFromCache(STable *pTable, SSkipListIterator *pIter, TSKEY maxKey if (pCols && pMergeInfo->nOperations >= pCols->maxPoints) break; pMergeInfo->rowsDeleteSucceed++; pMergeInfo->nOperations++; - tsdbAppendTableRowToCols(pTable, pCols, &pSchema, row, false); + tsdbAppendTableRowToCols(pTsdb, pTable, pCols, &pSchema, row, false); } else { if (keepDup) { if (pCols && pMergeInfo->nOperations >= pCols->maxPoints) break; @@ -262,11 +263,11 @@ int tsdbLoadDataFromCache(STable *pTable, SSkipListIterator *pIter, TSKEY maxKey if (lastKey != TSKEY_INITIAL_VAL) { ++pCols->numOfRows; } - tsdbAppendTableRowToCols(pTable, pCols, &pSchema, row, false); + tsdbAppendTableRowToCols(pTsdb, pTable, pCols, &pSchema, row, false); } lastKey = rowKey; } else { - tsdbAppendTableRowToCols(pTable, pCols, &pSchema, row, true); + tsdbAppendTableRowToCols(pTsdb, pTable, pCols, &pSchema, row, true); } } else { pMergeInfo->keyFirst = TMIN(pMergeInfo->keyFirst, fKey); @@ -321,7 +322,7 @@ int tsdbInsertTableData(STsdb *pTsdb, SSubmitMsgIter *pMsgIter, SSubmitBlk *pBlo return -1; } strcat(pRsp->tblFName, mr.me.name); - + if (mr.me.type == TSDB_NORMAL_TABLE) { sverNew = mr.me.ntbEntry.schema.sver; } else { @@ -431,10 +432,12 @@ static char *tsdbTbDataGetUid(const void *arg) { STbData *pTbData = (STbData *)arg; return (char *)(&(pTbData->uid)); } -static int tsdbAppendTableRowToCols(STable *pTable, SDataCols *pCols, STSchema **ppSchema, STSRow *row, bool merge) { + +static int tsdbAppendTableRowToCols(STsdb *pTsdb, STable *pTable, SDataCols *pCols, STSchema **ppSchema, STSRow *row, + bool merge) { if (pCols) { if (*ppSchema == NULL || schemaVersion(*ppSchema) != TD_ROW_SVER(row)) { - *ppSchema = tsdbGetTableSchemaImpl(pTable, false, false, TD_ROW_SVER(row)); + *ppSchema = tsdbGetTableSchemaImpl(pTsdb, pTable, false, false, TD_ROW_SVER(row)); if (*ppSchema == NULL) { ASSERT(false); return -1; diff --git a/source/dnode/vnode/src/tsdb/tsdbReadImpl.c b/source/dnode/vnode/src/tsdb/tsdbReadImpl.c index f66037b16d..d51521c41c 100644 --- a/source/dnode/vnode/src/tsdb/tsdbReadImpl.c +++ b/source/dnode/vnode/src/tsdb/tsdbReadImpl.c @@ -157,7 +157,7 @@ int tsdbLoadBlockIdx(SReadH *pReadh) { } int tsdbSetReadTable(SReadH *pReadh, STable *pTable) { - STSchema *pSchema = tsdbGetTableSchemaImpl(pTable, false, false, -1); + STSchema *pSchema = tsdbGetTableSchemaImpl(TSDB_READ_REPO(pReadh), pTable, false, false, -1); pReadh->pTable = pTable; From 55c010dd6cde2c178e5933fab0926c7f5d274aa6 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Wed, 25 May 2022 22:50:41 +0800 Subject: [PATCH 50/63] fix: code optimization --- source/dnode/vnode/src/tsdb/tsdbDelete.c | 61 ------------------------ 1 file changed, 61 deletions(-) delete mode 100644 source/dnode/vnode/src/tsdb/tsdbDelete.c diff --git a/source/dnode/vnode/src/tsdb/tsdbDelete.c b/source/dnode/vnode/src/tsdb/tsdbDelete.c deleted file mode 100644 index ef18b8ff66..0000000000 --- a/source/dnode/vnode/src/tsdb/tsdbDelete.c +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2019 TAOS Data, Inc. - * - * This program is free software: you can use, redistribute, and/or modify - * it under the terms of the GNU Affero General Public License, version 3 - * or later ("AGPL"), as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -#include "tsdb.h" - -typedef struct STombStoneItem STombStoneItem; -typedef struct STombStones STombStones; - -struct STombStones { - TdThreadRwlock lock; - SHashObj* pTmStones; // key: uid, value: tombstone items sorted by version - T_REF_DECLARE() -}; - -struct STombStoneItem { - int64_t tbUid; // child/normal table - int64_t version; - int64_t gversion; // global unique version assigned by mnode - SArray* tsFilters; -}; - -// SBlock 中除了原有的 keyFirst/keyLast,应该不再需要记录 versionMin 和 versionMax -// 因为在查询时,新到的 query 的 version,一定大于原有写入的数据 version。 - -// mem [ts1:v200, ts1:v201, ts2:v300,ts2:v310,ts2:320, ts5:400,ts5:v500,ts6:v600, ts7:v700, ts8:v800] - -// imem [ts2:80,ts2:v90,ts2:v100] - -// file [blk1: ts1:v10,ts1:v11,ts2:v20,ts2:v21 - [blk2: ts2:v30,ts2:v31,ts2:v35 - [blk3: ts2:v40,ts2:v45,ts2:v50,ts3:v60,ts4:v70 - -// delete [ctb1, ts2-ts5:v315] -// [ctb1, ts5:v450] -// [ctb1, ts6:v550] -// 根据 delete version, 逆序过滤。 - -// sql: select * from ctb1 where ts < ts8 and ts > ts1; // query version = 460; - -int32_t tsdbLoadBlockDataMV(SFileBlockIter *pBlockIter, SMemIter *pMemIter, SDataCols *pTarget, SArray *pTmStoneArray, int64_t queryVersion){ - - // 首先,query executor 根据 查询的 ts 范围,找到最后一条记录的位置。 - // 1) 有可能只在 mem/imem - // 2) 有可能只在 某一个文件 - // 3) 有可能 mem/imem 和 文件中均包含。 - - - -} From d137ce1c7378f5b60d3440b136d7781c4a8a9ed4 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Wed, 25 May 2022 23:07:06 +0800 Subject: [PATCH 51/63] refactor: create mnode handle --- include/common/tmsg.h | 1 - source/common/src/tmsg.c | 2 - source/dnode/mgmt/mgmt_mnode/src/mmHandle.c | 2 +- source/dnode/mgmt/test/CMakeLists.txt | 2 +- source/dnode/mnode/impl/src/mndMnode.c | 190 ++++++++++---------- 5 files changed, 100 insertions(+), 97 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index d938646f00..41e55ddf91 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1273,7 +1273,6 @@ int32_t tSerializeSCreateDropMQSBNodeReq(void* buf, int32_t bufLen, SMCreateQnod int32_t tDeserializeSCreateDropMQSBNodeReq(void* buf, int32_t bufLen, SMCreateQnodeReq* pReq); typedef struct { - int32_t dnodeId; int8_t replica; SReplica replicas[TSDB_MAX_REPLICA]; } SDCreateMnodeReq, SDAlterMnodeReq; diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 93a592f120..d99df90766 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -3186,7 +3186,6 @@ int32_t tSerializeSDCreateMnodeReq(void *buf, int32_t bufLen, SDCreateMnodeReq * tEncoderInit(&encoder, buf, bufLen); if (tStartEncode(&encoder) < 0) return -1; - if (tEncodeI32(&encoder, pReq->dnodeId) < 0) return -1; if (tEncodeI8(&encoder, pReq->replica) < 0) return -1; for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) { SReplica *pReplica = &pReq->replicas[i]; @@ -3204,7 +3203,6 @@ int32_t tDeserializeSDCreateMnodeReq(void *buf, int32_t bufLen, SDCreateMnodeReq tDecoderInit(&decoder, buf, bufLen); if (tStartDecode(&decoder) < 0) return -1; - if (tDecodeI32(&decoder, &pReq->dnodeId) < 0) return -1; if (tDecodeI8(&decoder, &pReq->replica) < 0) return -1; for (int32_t i = 0; i < TSDB_MAX_REPLICA; ++i) { SReplica *pReplica = &pReq->replicas[i]; diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c index 90d7b88859..f6350ba279 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c @@ -79,7 +79,7 @@ int32_t mmProcessCreateReq(const SMgmtInputOpt *pInput, SRpcMsg *pMsg) { return -1; } - if (createReq.replica <= 1 || (createReq.dnodeId != pInput->pData->dnodeId && pInput->pData->dnodeId != 0)) { + if (createReq.replica != 1) { terrno = TSDB_CODE_INVALID_OPTION; dError("failed to create mnode since %s", terrstr()); return -1; diff --git a/source/dnode/mgmt/test/CMakeLists.txt b/source/dnode/mgmt/test/CMakeLists.txt index e1656ceb34..6b1919bf18 100644 --- a/source/dnode/mgmt/test/CMakeLists.txt +++ b/source/dnode/mgmt/test/CMakeLists.txt @@ -3,7 +3,7 @@ if(${BUILD_TEST}) add_subdirectory(qnode) add_subdirectory(bnode) add_subdirectory(snode) - add_subdirectory(mnode) + #add_subdirectory(mnode) add_subdirectory(vnode) add_subdirectory(sut) endif(${BUILD_TEST}) diff --git a/source/dnode/mnode/impl/src/mndMnode.c b/source/dnode/mnode/impl/src/mndMnode.c index a47221ea39..afdc27a96a 100644 --- a/source/dnode/mnode/impl/src/mndMnode.c +++ b/source/dnode/mnode/impl/src/mndMnode.c @@ -267,75 +267,83 @@ static int32_t mndSetCreateMnodeCommitLogs(SMnode *pMnode, STrans *pTrans, SMnod } static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnodeObj *pDnode, SMnodeObj *pObj) { - SSdb *pSdb = pMnode->pSdb; - void *pIter = NULL; - int32_t numOfReplicas = 0; - + SSdb *pSdb = pMnode->pSdb; + void *pIter = NULL; + int32_t numOfReplicas = 0; + SDAlterMnodeReq alterReq = {0}; SDCreateMnodeReq createReq = {0}; + SEpSet alterEpset = {0}; + SEpSet createEpset = {0}; + while (1) { SMnodeObj *pMObj = NULL; pIter = sdbFetch(pSdb, SDB_MNODE, pIter, (void **)&pMObj); if (pIter == NULL) break; - SReplica *pReplica = &createReq.replicas[numOfReplicas]; - pReplica->id = pMObj->id; - pReplica->port = pMObj->pDnode->port; - memcpy(pReplica->fqdn, pMObj->pDnode->fqdn, TSDB_FQDN_LEN); - numOfReplicas++; + alterReq.replicas[numOfReplicas].id = pMObj->id; + alterReq.replicas[numOfReplicas].port = pMObj->pDnode->port; + memcpy(alterReq.replicas[numOfReplicas].fqdn, pMObj->pDnode->fqdn, TSDB_FQDN_LEN); + alterEpset.eps[numOfReplicas].port = pMObj->pDnode->port; + memcpy(alterEpset.eps[numOfReplicas].fqdn, pMObj->pDnode->fqdn, TSDB_FQDN_LEN); + if (pMObj->state == TAOS_SYNC_STATE_LEADER) { + alterEpset.inUse = numOfReplicas; + } + + numOfReplicas++; sdbRelease(pSdb, pMObj); } - SReplica *pReplica = &createReq.replicas[numOfReplicas]; - pReplica->id = pDnode->id; - pReplica->port = pDnode->port; - memcpy(pReplica->fqdn, pDnode->fqdn, TSDB_FQDN_LEN); - numOfReplicas++; + alterReq.replica = numOfReplicas + 1; + alterReq.replicas[numOfReplicas].id = pDnode->id; + alterReq.replicas[numOfReplicas].port = pDnode->port; + memcpy(alterReq.replicas[numOfReplicas].fqdn, pDnode->fqdn, TSDB_FQDN_LEN); - createReq.replica = numOfReplicas; + alterEpset.numOfEps = numOfReplicas + 1; + alterEpset.eps[numOfReplicas].port = pDnode->port; + memcpy(alterEpset.eps[numOfReplicas].fqdn, pDnode->fqdn, TSDB_FQDN_LEN); - while (1) { - SMnodeObj *pMObj = NULL; - pIter = sdbFetch(pSdb, SDB_MNODE, pIter, (void **)&pMObj); - if (pIter == NULL) break; + createReq.replica = 1; + createReq.replicas[0].id = pDnode->id; + createReq.replicas[0].port = pDnode->port; + memcpy(createReq.replicas[0].fqdn, pDnode->fqdn, TSDB_FQDN_LEN); - STransAction action = {0}; + createEpset.numOfEps = 1; + createEpset.eps[0].port = pDnode->port; + memcpy(createEpset.eps[0].fqdn, pDnode->fqdn, TSDB_FQDN_LEN); - createReq.dnodeId = pMObj->id; - int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &createReq); + { + int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &alterReq); void *pReq = taosMemoryMalloc(contLen); - tSerializeSDCreateMnodeReq(pReq, contLen, &createReq); + tSerializeSDCreateMnodeReq(pReq, contLen, &alterReq); - action.epSet = mndGetDnodeEpset(pMObj->pDnode); - action.pCont = pReq; - action.contLen = contLen; - action.msgType = TDMT_DND_ALTER_MNODE; - action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED; + STransAction action = { + .epSet = alterEpset, + .pCont = pReq, + .contLen = contLen, + .msgType = TDMT_DND_ALTER_MNODE, + .acceptableCode = 0, + }; if (mndTransAppendRedoAction(pTrans, &action) != 0) { taosMemoryFree(pReq); - sdbCancelFetch(pSdb, pIter); - sdbRelease(pSdb, pMObj); return -1; } - - sdbRelease(pSdb, pMObj); } { - STransAction action = {0}; - action.epSet = mndGetDnodeEpset(pDnode); - - createReq.dnodeId = pObj->id; int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &createReq); void *pReq = taosMemoryMalloc(contLen); tSerializeSDCreateMnodeReq(pReq, contLen, &createReq); - action.epSet = mndGetDnodeEpset(pDnode); - action.pCont = pReq; - action.contLen = contLen; - action.msgType = TDMT_DND_CREATE_MNODE; - action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED; + STransAction action = { + .epSet = createEpset, + .pCont = pReq, + .contLen = contLen, + .msgType = TDMT_DND_CREATE_MNODE, + .acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED, + }; + if (mndTransAppendRedoAction(pTrans, &action) != 0) { taosMemoryFree(pReq); return -1; @@ -441,73 +449,77 @@ static int32_t mndSetDropMnodeCommitLogs(SMnode *pMnode, STrans *pTrans, SMnodeO } static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnodeObj *pDnode, SMnodeObj *pObj) { - SSdb *pSdb = pMnode->pSdb; - void *pIter = NULL; - int32_t numOfReplicas = 0; - + SSdb *pSdb = pMnode->pSdb; + void *pIter = NULL; + int32_t numOfReplicas = 0; SDAlterMnodeReq alterReq = {0}; + SDDropMnodeReq dropReq = {0}; + SEpSet alterEpset = {0}; + SEpSet dropEpSet = {0}; + while (1) { SMnodeObj *pMObj = NULL; pIter = sdbFetch(pSdb, SDB_MNODE, pIter, (void **)&pMObj); if (pIter == NULL) break; - - if (pMObj->id != pObj->id) { - SReplica *pReplica = &alterReq.replicas[numOfReplicas]; - pReplica->id = pMObj->id; - pReplica->port = pMObj->pDnode->port; - memcpy(pReplica->fqdn, pMObj->pDnode->fqdn, TSDB_FQDN_LEN); - numOfReplicas++; + if (pMObj->id == pObj->id) { + sdbRelease(pSdb, pMObj); + continue; } + alterReq.replicas[numOfReplicas].id = pMObj->id; + alterReq.replicas[numOfReplicas].port = pMObj->pDnode->port; + memcpy(alterReq.replicas[numOfReplicas].fqdn, pMObj->pDnode->fqdn, TSDB_FQDN_LEN); + + alterEpset.eps[numOfReplicas].port = pMObj->pDnode->port; + memcpy(alterEpset.eps[numOfReplicas].fqdn, pMObj->pDnode->fqdn, TSDB_FQDN_LEN); + if (pMObj->state == TAOS_SYNC_STATE_LEADER) { + alterEpset.inUse = numOfReplicas; + } + + numOfReplicas++; sdbRelease(pSdb, pMObj); } alterReq.replica = numOfReplicas; + alterEpset.numOfEps = numOfReplicas; - while (1) { - SMnodeObj *pMObj = NULL; - pIter = sdbFetch(pSdb, SDB_MNODE, pIter, (void **)&pMObj); - if (pIter == NULL) break; - if (pMObj->id != pObj->id) { - STransAction action = {0}; + dropReq.dnodeId = pDnode->id; + dropEpSet.numOfEps = 1; + dropEpSet.eps[0].port = pDnode->port; + memcpy(dropEpSet.eps[0].fqdn, pDnode->fqdn, TSDB_FQDN_LEN); - alterReq.dnodeId = pMObj->id; - int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &alterReq); - void *pReq = taosMemoryMalloc(contLen); - tSerializeSDCreateMnodeReq(pReq, contLen, &alterReq); + { + int32_t contLen = tSerializeSDCreateMnodeReq(NULL, 0, &alterReq); + void *pReq = taosMemoryMalloc(contLen); + tSerializeSDCreateMnodeReq(pReq, contLen, &alterReq); - action.epSet = mndGetDnodeEpset(pMObj->pDnode); - action.pCont = pReq; - action.contLen = contLen; - action.msgType = TDMT_DND_ALTER_MNODE; - action.acceptableCode = TSDB_CODE_NODE_ALREADY_DEPLOYED; + STransAction action = { + .epSet = alterEpset, + .pCont = pReq, + .contLen = contLen, + .msgType = TDMT_DND_ALTER_MNODE, + .acceptableCode = 0, + }; - if (mndTransAppendRedoAction(pTrans, &action) != 0) { - taosMemoryFree(pReq); - sdbCancelFetch(pSdb, pIter); - sdbRelease(pSdb, pMObj); - return -1; - } + if (mndTransAppendRedoAction(pTrans, &action) != 0) { + taosMemoryFree(pReq); + return -1; } - - sdbRelease(pSdb, pMObj); } { - STransAction action = {0}; - action.epSet = mndGetDnodeEpset(pDnode); - - SDDropMnodeReq dropReq = {0}; - dropReq.dnodeId = pObj->id; int32_t contLen = tSerializeSCreateDropMQSBNodeReq(NULL, 0, &dropReq); void *pReq = taosMemoryMalloc(contLen); tSerializeSCreateDropMQSBNodeReq(pReq, contLen, &dropReq); - action.epSet = mndGetDnodeEpset(pDnode); - action.pCont = pReq; - action.contLen = contLen; - action.msgType = TDMT_DND_DROP_MNODE; - action.acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED; + STransAction action = { + .epSet = dropEpSet, + .pCont = pReq, + .contLen = contLen, + .msgType = TDMT_DND_DROP_MNODE, + .acceptableCode = TSDB_CODE_NODE_NOT_DEPLOYED, + }; + if (mndTransAppendRedoAction(pTrans, &action) != 0) { taosMemoryFree(pReq); return -1; @@ -662,7 +674,7 @@ static void mndCancelGetNextMnode(SMnode *pMnode, void *pIter) { } static int32_t mndProcessAlterMnodeReq(SRpcMsg *pReq) { - SMnode *pMnode = pReq->info.node; + SMnode *pMnode = pReq->info.node; SDAlterMnodeReq alterReq = {0}; if (tDeserializeSDCreateMnodeReq(pReq->pCont, pReq->contLen, &alterReq) != 0) { @@ -670,12 +682,6 @@ static int32_t mndProcessAlterMnodeReq(SRpcMsg *pReq) { return -1; } - if (alterReq.dnodeId != pMnode->selfDnodeId) { - terrno = TSDB_CODE_INVALID_OPTION; - mError("failed to alter mnode since %s, input:%d cur:%d", terrstr(), alterReq.dnodeId, pMnode->selfDnodeId); - return -1; - } - SSyncCfg cfg = {.replicaNum = alterReq.replica, .myIndex = -1}; for (int32_t i = 0; i < alterReq.replica; ++i) { SNodeInfo *pNode = &cfg.nodeInfo[i]; From ea3f7d756f58770213931de584e4cf328f6c62d1 Mon Sep 17 00:00:00 2001 From: Sean Ely <105326513+sean-tdengine@users.noreply.github.com> Date: Wed, 25 May 2022 08:47:24 -0700 Subject: [PATCH 52/63] docs: grammar: data type Minor grammar changes to the SQL data types page. --- docs-en/12-taos-sql/01-data-type.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs-en/12-taos-sql/01-data-type.md b/docs-en/12-taos-sql/01-data-type.md index 931e3bbac7..86ec941f95 100644 --- a/docs-en/12-taos-sql/01-data-type.md +++ b/docs-en/12-taos-sql/01-data-type.md @@ -3,13 +3,13 @@ title: Data Types description: "The data types supported by TDengine include timestamp, float, JSON, etc" --- -When using TDengine to store and query data, the most important part of the data is timestamp. Timestamp must be specified when creating and inserting data rows or querying data, timestamp must follow below rules: +When using TDengine to store and query data, the most important part of the data is timestamp. Timestamp must be specified when creating and inserting data rows or querying data, timestamp must follow the rules below: - the format must be `YYYY-MM-DD HH:mm:ss.MS`, the default time precision is millisecond (ms), for example `2017-08-12 18:25:58.128` - internal function `now` can be used to get the current timestamp of the client side - the current timestamp of the client side is applied when `now` is used to insert data - Epoch Time:timestamp can also be a long integer number, which means the number of seconds, milliseconds or nanoseconds, depending on the time precision, from 1970-01-01 00:00:00.000 (UTC/GMT) -- timestamp can be applied with add/subtract operation, for example `now-2h` means 2 hours back from the time at which query is executed,the unit can be b(nanosecond), u(microsecond), a(millisecond), s(second), m(minute), h(hour), d(day), w(week.。 So `select * from t1 where ts > now-2w and ts <= now-1w` means the data between two weeks ago and one week ago. The time unit can also be n (calendar month) or y (calendar year) when specifying the time window for down sampling operation. +- timestamp can be applied with add/subtract operation, for example `now-2h` means 2 hours back from the time at which query is executed,the unit can be b(nanosecond), u(microsecond), a(millisecond), s(second), m(minute), h(hour), d(day), or w(week). So `select * from t1 where ts > now-2w and ts <= now-1w` means the data between two weeks ago and one week ago. The time unit can also be n (calendar month) or y (calendar year) when specifying the time window for down sampling operation. Time precision in TDengine can be set by the `PRECISION` parameter when executing `CREATE DATABASE`, like below, the default time precision is millisecond. @@ -17,7 +17,7 @@ Time precision in TDengine can be set by the `PRECISION` parameter when executin CREATE DATABASE db_name PRECISION 'ns'; ``` -In TDengine, below data types can be used when specifying a column or tag. +In TDengine, the data types below can be used when specifying a column or tag. | # | **type** | **Bytes** | **Description** | | --- | :-------: | --------- | ------------------------- | @@ -25,12 +25,12 @@ In TDengine, below data types can be used when specifying a column or tag. | 2 | INT | 4 | Integer, the value range is [-2^31+1, 2^31-1], while -2^31 is treated as NULL | | 3 | BIGINT | 8 | Long integer, the value range is [-2^63+1, 2^63-1], while -2^63 is treated as NULL | | 4 | FLOAT | 4 | Floating point number, the effective number of digits is 6-7, the value range is [-3.4E38, 3.4E38] | -| 5 | DOUBLE | 8 | double precision floating point number, the effective number of digits is 15-16, the value range is [-1.7E308, 1.7E308] | +| 5 | DOUBLE | 8 | Double precision floating point number, the effective number of digits is 15-16, the value range is [-1.7E308, 1.7E308] | | 6 | BINARY | User Defined | Single-byte string for ASCII visible characters. Length must be specified when defining a column or tag of binary type. The string length can be up to 16374 bytes. The string value must be quoted with single quotes. The literal single quote inside the string must be preceded with back slash like `\'` | | 7 | SMALLINT | 2 | Short integer, the value range is [-32767, 32767], while -32768 is treated as NULL | | 8 | TINYINT | 1 | Single-byte integer, the value range is [-127, 127], while -128 is treated as NULL | | 9 | BOOL | 1 | Bool, the value range is {true, false} | -| 10 | NCHAR | User Defined| Multiple-Byte string that can include like Chinese characters. Each character of NCHAR type consumes 4 bytes storage. The string value should be quoted with single quotes. Literal single quote inside the string must be preceded with backslash, like `\’`. The length must be specified when defining a column or tag of NCHAR type, for example nchar(10) means it can store at most 10 characters of nchar type and will consume fixed storage of 40 bytes. Error will be reported the string value exceeds the length defined. | +| 10 | NCHAR | User Defined| Multiple-Byte string that can include like Chinese characters. Each character of NCHAR type consumes 4 bytes storage. The string value should be quoted with single quotes. Literal single quote inside the string must be preceded with backslash, like `\’`. The length must be specified when defining a column or tag of NCHAR type, for example nchar(10) means it can store at most 10 characters of nchar type and will consume fixed storage of 40 bytes. An error will be reported if the string value exceeds the length defined. | | 11 | JSON | | json type can only be used on tag, a tag of json type is excluded with any other tags of any other type | :::tip From 85c05527b72da46d49ad14ceefc5abcbb1836733 Mon Sep 17 00:00:00 2001 From: Sean Ely <105326513+sean-tdengine@users.noreply.github.com> Date: Wed, 25 May 2022 08:57:15 -0700 Subject: [PATCH 53/63] docs: grammar: sql database Minor grammar changes to the SQL > Database page --- docs-en/12-taos-sql/02-database.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs-en/12-taos-sql/02-database.md b/docs-en/12-taos-sql/02-database.md index 85b71bbde7..98b75b30b3 100644 --- a/docs-en/12-taos-sql/02-database.md +++ b/docs-en/12-taos-sql/02-database.md @@ -35,7 +35,7 @@ CREATE DATABASE [IF NOT EXISTS] db_name [KEEP keep] [DAYS days] [UPDATE 1]; - maxVgroupsPerDb: [Description](/reference/config/#maxvgroupsperdb) - comp: [Description](/reference/config/#comp) - precision: [Description](/reference/config/#precision) -6. Please be noted that all of the parameters mentioned in this section can be configured in configuration file `taosd.cfg` at server side and used by default, can be override if they are specified in `create database` statement. +6. Please note that all of the parameters mentioned in this section can be configured in configuration file `taosd.cfg` at server side and used by default, the default parameters can be overriden if they are specified in `create database` statement. ::: @@ -69,7 +69,7 @@ All data in the database will be deleted too. This command must be used with cau ## Change Database Configuration -Some examples are shown below to demonstrate how to change the configuration of a database. Please be noted that some configuration parameters can be changed after the database is created, but some others can't, for details of the configuration parameters of database please refer to [Configuration Parameters](/reference/config/). +Some examples are shown below to demonstrate how to change the configuration of a database. Please note that some configuration parameters can be changed after the database is created, but some others can't, for details of the configuration parameters of database please refer to [Configuration Parameters](/reference/config/). ``` ALTER DATABASE db_name COMP 2; @@ -124,4 +124,4 @@ SHOW DATABASES; SHOW CREATE DATABASE db_name; ``` -This command is useful when migrating the data from one TDengine cluster to another one. Firstly this command can be used to get the CREATE statement, which in turn can be used in another TDengine to create an exactly same database. +This command is useful when migrating the data from one TDengine cluster to another one. This command can be used to get the CREATE statement, which can be used in another TDengine to create the exact same database. From 28ef348b7297147951959c049f47e0e1428b9d64 Mon Sep 17 00:00:00 2001 From: Sean Ely <105326513+sean-tdengine@users.noreply.github.com> Date: Wed, 25 May 2022 09:08:09 -0700 Subject: [PATCH 54/63] docs: grammar: sql table Minor grammar changes to the SQL > Table page. --- docs-en/12-taos-sql/03-table.md | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/docs-en/12-taos-sql/03-table.md b/docs-en/12-taos-sql/03-table.md index a1524f45f9..678965893e 100644 --- a/docs-en/12-taos-sql/03-table.md +++ b/docs-en/12-taos-sql/03-table.md @@ -12,12 +12,12 @@ CREATE TABLE [IF NOT EXISTS] tb_name (timestamp_field_name TIMESTAMP, field1_nam :::info -1. The first column of a table must be in TIMESTAMP type, and it will be set as primary key automatically -2. The maximum length of table name is 192 bytes. -3. The maximum length of each row is 16k bytes, please be notes that the extra 2 bytes used by each BINARY/NCHAR column are also counted in. -4. The name of sub-table can only be consisted of English characters, digits and underscore, and can't be started with digit. Table names are case insensitive. -5. The maximum length in bytes must be specified when using BINARY or NCHAR type. -6. Escape character "\`" can be used to avoid the conflict between table names and reserved keywords, above rules will be bypassed when using escape character on table names, but the upper limit for name length is still valid. The table names specified using escape character are case sensitive. Only ASCII visible characters can be used with escape character. +1. The first column of a table must be of TIMESTAMP type, and it will be set as the primary key automatically +2. The maximum length of the table name is 192 bytes. +3. The maximum length of each row is 16k bytes, please note that the extra 2 bytes used by each BINARY/NCHAR column are also counted. +4. The name of the subtable can only consist of English characters, digits and underscore, and can't start with a digit. Table names are case insensitive. +5. The maximum length in bytes must be specified when using BINARY or NCHAR types. +6. Escape character "\`" can be used to avoid the conflict between table names and reserved keywords, above rules will be bypassed when using escape character on table names, but the upper limit for the name length is still valid. The table names specified using escape character are case sensitive. Only ASCII visible characters can be used with escape character. For example \`aBc\` and \`abc\` are different table names but `abc` and `aBc` are same table names because they are both converted to `abc` internally. ::: @@ -28,9 +28,9 @@ CREATE TABLE [IF NOT EXISTS] tb_name (timestamp_field_name TIMESTAMP, field1_nam CREATE TABLE [IF NOT EXISTS] tb_name USING stb_name TAGS (tag_value1, ...); ``` -The above command creates a subtable using the specified super table as template and the specified tab values. +The above command creates a subtable using the specified super table as a template and the specified tag values. -### Create Subtable Using STable As Template With A Part of Tags +### Create Subtable Using STable As Template With A Subset of Tags ``` CREATE TABLE [IF NOT EXISTS] tb_name USING stb_name (tag_name1, ...) TAGS (tag_value1, ...); @@ -44,11 +44,11 @@ The tags for which no value is specified will be set to NULL. CREATE TABLE [IF NOT EXISTS] tb_name1 USING stb_name TAGS (tag_value1, ...) [IF NOT EXISTS] tb_name2 USING stb_name TAGS (tag_value2, ...) ...; ``` -This way can be used to create a lot of tables in a single SQL statement to accelerate the speed of the creating tables. +This can be used to create a lot of tables in a single SQL statement to accelerate the speed of the creating tables. :::info -- Creating tables in batch must use super table as template. +- Creating tables in batch must use a super table as a template. - The length of single statement is suggested to be between 1,000 and 3,000 bytes for best performance. ::: @@ -71,7 +71,7 @@ SHOW TABLES [LIKE tb_name_wildcard]; SHOW CREATE TABLE tb_name; ``` -This way is useful when migrating the data in one TDengine cluster to another one because it can be used to create exactly same tables in the target database. +This is useful when migrating the data in one TDengine cluster to another one because it can be used to create the exact same tables in the target database. ## Show Table Definition @@ -90,7 +90,7 @@ ALTER TABLE tb_name ADD COLUMN field_name data_type; :::info 1. The maximum number of columns is 4096, the minimum number of columns is 2. -2. The maximum length of column name is 64 bytes. +2. The maximum length of a column name is 64 bytes. ::: @@ -101,7 +101,7 @@ ALTER TABLE tb_name DROP COLUMN field_name; ``` :::note -If a table is created using a super table as template, the table definition can only be changed on the corresponding super table, but the change will be automatically applied to all the sub tables created using this super table as template. For tables created in normal way, the table definition can be changed directly on the table. +If a table is created using a super table as template, the table definition can only be changed on the corresponding super table, and the change will be automatically applied to all the subtables created using this super table as template. For tables created in the normal way, the table definition can be changed directly on the table. ::: @@ -111,10 +111,10 @@ If a table is created using a super table as template, the table definition can ALTER TABLE tb_name MODIFY COLUMN field_name data_type(length); ``` -The the type of a column is variable length, like BINARY or NCHAR, this way can be used to change (or increase) the length of the column. +The type of a column is variable length, like BINARY or NCHAR, this can be used to change (or increase) the length of the column. :::note -If a table is created using a super table as template, the table definition can only be changed on the corresponding super table, but the change will be automatically applied to all the sub tables created using this super table as template. For tables created in normal way, the table definition can be changed directly on the table. +If a table is created using a super table as template, the table definition can only be changed on the corresponding super table, and the change will be automatically applied to all the subtables created using this super table as template. For tables created in the normal way, the table definition can be changed directly on the table. ::: From 786cb5beca5d28671330abb36cac133310655aa0 Mon Sep 17 00:00:00 2001 From: Sean Ely <105326513+sean-tdengine@users.noreply.github.com> Date: Wed, 25 May 2022 09:16:30 -0700 Subject: [PATCH 55/63] docs: grammar: sql stable Minor grammar updates to SQL > STable page. --- docs-en/12-taos-sql/04-stable.md | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docs-en/12-taos-sql/04-stable.md b/docs-en/12-taos-sql/04-stable.md index b7817f9028..7354484f75 100644 --- a/docs-en/12-taos-sql/04-stable.md +++ b/docs-en/12-taos-sql/04-stable.md @@ -15,14 +15,14 @@ Keyword `STable`, abbreviated for super table, is supported since version 2.0.15 CREATE STable [IF NOT EXISTS] stb_name (timestamp_field_name TIMESTAMP, field1_name data_type1 [, field2_name data_type2 ...]) TAGS (tag1_name tag_type1, tag2_name tag_type2 [, tag3_name tag_type3]); ``` -The SQL statement of creating STable is similar to that of creating table, but a special column named as `TAGS` must be specified with the names and types of the tags. +The SQL statement of creating a STable is similar to that of creating a table, but a special column set named `TAGS` must be specified with the names and types of the tags. :::info 1. The tag types specified in TAGS should NOT be timestamp. Since 2.1.3.0 timestamp type can be used in TAGS column, but its value must be fixed and arithmetic operation can't be applied on it. -2. The tag names specified in TAGS should NOT be same as other columns. -3. The tag names specified in TAGS should NOT be same as any reserved keywords.(Please refer to [keywords](/taos-sql/keywords/) -4. The maximum number of tags specified in TAGS is 128, but there must be at least one tag, and the total length of all tag columns should NOT exceed 16KB. +2. The tag names specified in TAGS should NOT be the same as other columns. +3. The tag names specified in TAGS should NOT be the same as any reserved keywords.(Please refer to [keywords](/taos-sql/keywords/) +4. The maximum number of tags specified in TAGS is 128, there must be at least one tag, and the total length of all tag columns should NOT exceed 16KB. ::: @@ -32,7 +32,7 @@ The SQL statement of creating STable is similar to that of creating table, but a DROP STable [IF EXISTS] stb_name; ``` -All the sub-tables created using the deleted STable will be deleted automatically. +All the subtables created using the deleted STable will be deleted automatically. ## Show All STables @@ -40,7 +40,7 @@ All the sub-tables created using the deleted STable will be deleted automaticall SHOW STableS [LIKE tb_name_wildcard]; ``` -This command can be used to display the information of all STables in the current database, including name, creation time, number of columns, number of tags, number of tables created using this STable. +This command can be used to display the information of all STables in the current database, including name, creation time, number of columns, number of tags, and number of tables created using this STable. ## Show The Create Statement of A STable @@ -48,7 +48,7 @@ This command can be used to display the information of all STables in the curren SHOW CREATE STable stb_name; ``` -This command is useful in migrating data from one TDengine cluster to another one because it can be used to create an exactly same STable in the target database. +This command is useful in migrating data from one TDengine cluster to another because it can be used to create the exact same STable in the target database. ## Get STable Definition @@ -94,7 +94,7 @@ This command is used to add a new tag for a STable and specify the tag type. ALTER STable stb_name DROP TAG tag_name; ``` -The tag will be removed automatically from all the sub tables crated using the super table as template once a tag is removed from a super table. +The tag will be removed automatically from all the subtables created using the super table as template once a tag is removed from a super table. ### Change A Tag @@ -102,7 +102,7 @@ The tag will be removed automatically from all the sub tables crated using the s ALTER STable stb_name CHANGE TAG old_tag_name new_tag_name; ``` -The tag name will be changed automatically from all the sub tables crated using the super table as template once a tag name is changed for a super table. +The tag name will be changed automatically for all the subtables created using the super table as template once a tag name is changed for a super table. ### Change Tag Length @@ -113,6 +113,6 @@ ALTER STable stb_name MODIFY TAG tag_name data_type(length); This command can be used to change (or increase, more specifically) the length of a tag of variable length types, like BINARY or NCHAR. :::note -Changing tag value can be applied to only sub tables. All other tag operations, like add tag, remove tag, however, can be applied to only STable. If a new tag is added for a STable, the tag will be added with NULL value for all its sub tables. +Changing tag values can be applied to only subtables. All other tag operations, like add tag, remove tag, however, can be applied to only STable. If a new tag is added for a STable, the tag will be added with NULL value for all its subtables. ::: From 7e8a722cfbfe9aea8bb65b885622aa6c3b816aff Mon Sep 17 00:00:00 2001 From: Sean Ely <105326513+sean-tdengine@users.noreply.github.com> Date: Wed, 25 May 2022 11:39:59 -0700 Subject: [PATCH 56/63] docs: grammar: sql insert Minor grammar changes to the SQL Insert page --- docs-en/12-taos-sql/05-insert.md | 36 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/docs-en/12-taos-sql/05-insert.md b/docs-en/12-taos-sql/05-insert.md index d511bd5c91..1336cd7238 100644 --- a/docs-en/12-taos-sql/05-insert.md +++ b/docs-en/12-taos-sql/05-insert.md @@ -19,15 +19,15 @@ INSERT INTO ## Insert Single or Multiple Rows -Single row or multiple rows specified with VALUES can be inserted into a specific table. For example +Single row or multiple rows specified with VALUES can be inserted into a specific table. For example: -Single row is inserted using below statement. +A single row is inserted using the below statement. ```sq; INSERT INTO d1001 VALUES (NOW, 10.2, 219, 0.32); ``` -Double rows can be inserted using below statement. +Double rows are inserted using the below statement. ```sql INSERT INTO d1001 VALUES ('2021-07-13 14:06:32.272', 10.2, 219, 0.32) (1626164208000, 10.15, 217, 0.33); @@ -36,7 +36,7 @@ INSERT INTO d1001 VALUES ('2021-07-13 14:06:32.272', 10.2, 219, 0.32) (162616420 :::note 1. In the second example above, different formats are used in the two rows to be inserted. In the first row, the timestamp format is a date and time string, which is interpreted from the string value only. In the second row, the timestamp format is a long integer, which will be interpreted based on the database time precision. -2. When trying to insert multiple rows in single statement, only the timestamp of one row can be set as NOW, otherwise there will be duplicate timestamps among the rows and the result may be out of expectation because NOW will be interpreted as the time when the statement is executed. +2. When trying to insert multiple rows in a single statement, only the timestamp of one row can be set as NOW, otherwise there will be duplicate timestamps among the rows and the result may be out of expectation because NOW will be interpreted as the time when the statement is executed. 3. The oldest timestamp that is allowed is subtracting the KEEP parameter from current time. 4. The newest timestamp that is allowed is adding the DAYS parameter to current time. @@ -51,13 +51,13 @@ INSERT INTO d1001 (ts, current, phase) VALUES ('2021-07-13 14:06:33.196', 10.27, ``` :::info -If no columns are explicitly specified, all the columns must be provided with values, this is called "all column mode". The insert performance of all column mode is much better than specifying a part of columns, so it's encouraged to use "all column mode" while providing NULL value explicitly for the columns for which no actual value can be provided. +If no columns are explicitly specified, all the columns must be provided with values, this is called "all column mode". The insert performance of all column mode is much better than specifying a subset of columns, so it's encouraged to use "all column mode" while providing NULL value explicitly for the columns for which no actual value can be provided. ::: ## Insert Into Multiple Tables -One or multiple rows can be inserted into multiple tables in single SQL statement, with or without specifying specific columns. +One or multiple rows can be inserted into multiple tables in a single SQL statement, with or without specifying specific columns. ```sql INSERT INTO d1001 VALUES ('2021-07-13 14:06:34.630', 10.2, 219, 0.32) ('2021-07-13 14:06:35.779', 10.15, 217, 0.33) @@ -66,19 +66,19 @@ INSERT INTO d1001 VALUES ('2021-07-13 14:06:34.630', 10.2, 219, 0.32) ('2021-07- ## Automatically Create Table When Inserting -If it's not sure whether the table already exists, the table can be created automatically while inserting using below SQL statement. To use this functionality, a STable must be used as template and tag values must be provided. +If it's unknown whether the table already exists, the table can be created automatically while inserting using the SQL statement below. To use this functionality, a STable must be used as template and tag values must be provided. ```sql INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) VALUES ('2021-07-13 14:06:32.272', 10.2, 219, 0.32); ``` -It's not necessary to provide values for all tag when creating tables automatically, the tags without values provided will be set to NULL. +It's not necessary to provide values for all tags when creating tables automatically, the tags without values provided will be set to NULL. ```sql INSERT INTO d21001 USING meters (groupId) TAGS (2) VALUES ('2021-07-13 14:06:33.196', 10.15, 217, 0.33); ``` -Multiple rows can also be inserted into same table in single SQL statement using this way. +Multiple rows can also be inserted into the same table in a single SQL statement. ```sql INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) VALUES ('2021-07-13 14:06:34.630', 10.2, 219, 0.32) ('2021-07-13 14:06:35.779', 10.15, 217, 0.33) @@ -87,19 +87,19 @@ INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) VALUES ('202 ``` :::info -Prior to version 2.0.20.5, when using `INSERT` to create table automatically and specify the columns, the column names must follow the table name immediately. From version 2.0.20.5, the column names can follow the table name immediately, also can be put between `TAGS` and `VALUES`. In same SQL statement, however, these two ways of specifying column names can't be mixed. +Prior to version 2.0.20.5, when using `INSERT` to create tables automatically and specifying the columns, the column names must follow the table name immediately. From version 2.0.20.5, the column names can follow the table name immediately, also can be put between `TAGS` and `VALUES`. In the same SQL statement, however, these two ways of specifying column names can't be mixed. ::: ## Insert Rows From A File -Besides using `VALUES` to insert one or multiple rows, the data to be inserted can also be prepared in a CSV file with comma as separator and each field value quoted by single quotes. Table definition is not required in the CSV file. For example, if file "/tmp/csvfile.csv" contains below data: +Besides using `VALUES` to insert one or multiple rows, the data to be inserted can also be prepared in a CSV file with comma as separator and each field value quoted by single quotes. Table definition is not required in the CSV file. For example, if file "/tmp/csvfile.csv" contains the below data: ``` '2021-07-13 14:07:34.630', '10.2', '219', '0.32' '2021-07-13 14:07:35.779', '10.15', '217', '0.33' ``` -Then data in this file can be inserted by below SQL statement: +Then data in this file can be inserted by the SQL statement below: ```sql INSERT INTO d1001 FILE '/tmp/csvfile.csv'; @@ -107,13 +107,13 @@ INSERT INTO d1001 FILE '/tmp/csvfile.csv'; ## Create Tables Automatically and Insert Rows From File -From version 2.1.5.0, tables can be automatically created using a super table as template when inserting data from a CSV file, Like below: +From version 2.1.5.0, tables can be automatically created using a super table as template when inserting data from a CSV file, like below: ```sql INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) FILE '/tmp/csvfile.csv'; ``` -Multiple tables can be automatically created and inserted in single SQL statement, like below: +Multiple tables can be automatically created and inserted in a single SQL statement, like below: ```sql INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) FILE '/tmp/csvfile_21001.csv' @@ -122,15 +122,15 @@ INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) FILE '/tmp/c ## More About Insert -For SQL statement like `insert`, stream parsing strategy is applied. That means before an error is found and the execution is aborted, the part prior to the error point has already been executed. Below is an experiment to help understand the behavior. +For SQL statement like `insert`, a stream parsing strategy is applied. That means before an error is found and the execution is aborted, the part prior to the error point has already been executed. Below is an experiment to help understand the behavior. -Firstly, a super table is created. +First, a super table is created. ```sql CREATE TABLE meters(ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS(location BINARY(30), groupId INT); ``` -It can be proved that the super table has been created by `SHOW STableS`, but no table exists by `SHOW TABLES`. +It can be proven that the super table has been created by `SHOW STableS`, but no table exists using `SHOW TABLES`. ``` taos> SHOW STableS; @@ -161,4 +161,4 @@ taos> SHOW TABLES; Query OK, 1 row(s) in set (0.001091s) ``` -From the above experiment, we can see that even though the value to be inserted is invalid but the table is still created. +From the above experiment, we can see that while the value to be inserted is invalid the table is still created. From f7811dd3cfc07d53f4bf348bb74580fa928bc3c6 Mon Sep 17 00:00:00 2001 From: Sean Ely <105326513+sean-tdengine@users.noreply.github.com> Date: Wed, 25 May 2022 12:46:17 -0700 Subject: [PATCH 57/63] docs: grammar: sql select Minor grammar updates to the SQL > Select page --- docs-en/12-taos-sql/06-select.md | 38 ++++++++++++++++---------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/docs-en/12-taos-sql/06-select.md b/docs-en/12-taos-sql/06-select.md index 0a5dc7645f..d9c39845f8 100644 --- a/docs-en/12-taos-sql/06-select.md +++ b/docs-en/12-taos-sql/06-select.md @@ -96,7 +96,7 @@ Query OK, 1 row(s) in set (0.000849s) ## Tags -Starting from version 2.0.14, tag columns can be selected together with data columns when querying sub tables. Please be noted that, however, wildcard \* doesn't represent any tag column, that means tag columns must be specified explicitly like below example. +Starting from version 2.0.14, tag columns can be selected together with data columns when querying sub tables. Please note that, however, wildcard \* doesn't represent any tag column, that means tag columns must be specified explicitly like the example below. ``` taos> SELECT location, groupid, current FROM d1001 LIMIT 2; @@ -109,7 +109,7 @@ Query OK, 2 row(s) in set (0.003112s) ## Get distinct values -`DISTINCT` keyword can be used to get all the unique values of tag columns from a super table, it can also be used to get all the unique values of data columns from a table or sub table. +`DISTINCT` keyword can be used to get all the unique values of tag columns from a super table, it can also be used to get all the unique values of data columns from a table or subtable. ```sql SELECT DISTINCT tag_name [, tag_name ...] FROM stb_name; @@ -120,7 +120,7 @@ SELECT DISTINCT col_name [, col_name ...] FROM tb_name; 1. Configuration parameter `maxNumOfDistinctRes` in `taos.cfg` is used to control the number of rows to output. The minimum configurable value is 100,000, the maximum configurable value is 100,000,000, the default value is 1000,000. If the actual number of rows exceeds the value of this parameter, only the number of rows specified by this parameter will be output. 2. It can't be guaranteed that the results selected by using `DISTINCT` on columns of `FLOAT` or `DOUBLE` are exactly unique because of the precision nature of floating numbers. -3. `DISTINCT` can't be used in the sub-query of a nested query statement, and can't be used together with aggregate functions, `GROUP BY` or `JOIN` in same SQL statement. +3. `DISTINCT` can't be used in the sub-query of a nested query statement, and can't be used together with aggregate functions, `GROUP BY` or `JOIN` in the same SQL statement. ::: @@ -197,7 +197,7 @@ taos> SELECT SERVER_VERSION(); Query OK, 1 row(s) in set (0.000077s) ``` -Below statement is used to check the server status. One integer, like `1`, is returned if the server status is OK, otherwise an error code is returned. This way is compatible with the status check for TDengine from connection pool or 3rd party tools, and can avoid the problem of losing connection from connection pool when using wrong heartbeat checking SQL statement. +Below statement is used to check the server status. One integer, like `1`, is returned if the server status is OK, otherwise an error code is returned. This is compatible with the status check for TDengine from connection pool or 3rd party tools, and can avoid the problem of losing the connection from a connection pool when using the wrong heartbeat checking SQL statement. ``` taos> SELECT SERVER_STATUS(); @@ -248,12 +248,12 @@ summary: ## Special Keywords in TAOS SQL -- `TBNAME`: it is treated as a special tag when selecting on a super table, representing the name of sub-tables in that super table. +- `TBNAME`: it is treated as a special tag when selecting on a super table, representing the name of subtables in that super table. - `_c0`: represents the first column of a table or super table. ## Tips -To get all the sub tables and corresponding tag values from a super table: +To get all the subtables and corresponding tag values from a super table: ```SQL SELECT TBNAME, location FROM meters; @@ -271,8 +271,8 @@ Only filter on `TAGS` are allowed in the `where` clause for above two query stat taos> SELECT TBNAME, location FROM meters; tbname | location | ================================================================== - d1004 | California.LoSangeles | - d1003 | California.LoSangeles | + d1004 | California.LosAngeles | + d1003 | California.LosAngeles | d1002 | California.SanFrancisco | d1001 | California.SanFrancisco | Query OK, 4 row(s) in set (0.000881s) @@ -285,10 +285,10 @@ Query OK, 1 row(s) in set (0.001091s) ``` - Wildcard \* can be used to get all columns, or specific column names can be specified. Arithmetic operation can be performed on columns of number types, columns can be renamed in the result set. -- Arithmetic operation on columns can't be used in where clause. For example, `where a*2>6;` is not allowed but `where a>6/2;` can be used instead for same purpose. +- Arithmetic operation on columns can't be used in where clause. For example, `where a*2>6;` is not allowed but `where a>6/2;` can be used instead for the same purpose. - Arithmetic operation on columns can't be used as the objectives of select statement. For example, `select min(2*a) from t;` is not allowed but `select 2*min(a) from t;` can be used instead. - Logical operation can be used in `WHERE` clause to filter numeric values, wildcard can be used to filter string values. -- Result set are arranged in ascending order of the first column, i.e. timestamp, but it can be controlled to output as descending order of timestamp. If `order by` is used on other columns, the result may be not as expected. By the way, \_c0 is used to represent the first column, i.e. timestamp. +- Result sets are arranged in ascending order of the first column, i.e. timestamp, but it can be controlled to output as descending order of timestamp. If `order by` is used on other columns, the result may not be as expected. By the way, \_c0 is used to represent the first column, i.e. timestamp. - `LIMIT` parameter is used to control the number of rows to output. `OFFSET` parameter is used to specify from which row to output. `LIMIT` and `OFFSET` are executed after `ORDER BY` in the query execution. A simple tip is that `LIMIT 5 OFFSET 2` can be abbreviated as `LIMIT 2, 5`. - What is controlled by `LIMIT` is the number of rows in each group when `GROUP BY` is used. - `SLIMIT` parameter is used to control the number of groups when `GROUP BY` is used. Similar to `LIMIT`, `SLIMIT 5 OFFSET 2` can be abbreviated as `SLIMIT 2, 5`. @@ -296,7 +296,7 @@ Query OK, 1 row(s) in set (0.001091s) ## Where -Logical operations in below table can be used in `where` clause to filter the resulting rows. +Logical operations in below table can be used in the `where` clause to filter the resulting rows. | **Operation** | **Note** | **Applicable Data Types** | | ------------- | ------------------------ | ----------------------------------------- | @@ -314,7 +314,7 @@ Logical operations in below table can be used in `where` clause to filter the re **Explanations**: -- Operator `<\>` is equal to `!=`, please be noted that this operator can't be used on the first column of any table, i.e.timestamp column. +- Operator `<\>` is equal to `!=`, please note that this operator can't be used on the first column of any table, i.e.timestamp column. - Operator `like` is used together with wildcards to match strings - '%' matches 0 or any number of characters, '\_' matches any single ASCII character. - `\_` is used to match the \_ in the string. @@ -323,8 +323,8 @@ Logical operations in below table can be used in `where` clause to filter the re - For timestamp column, only one condition can be used; for other columns or tags, `OR` keyword can be used to combine multiple logical operators. For example, `((value > 20 AND value < 30) OR (value < 12))`. - From version 2.3.0.0, multiple conditions can be used on timestamp column, but the result set can only contain single time range. - From version 2.0.17.0, operator `BETWEEN AND` can be used in where clause, for example `WHERE col2 BETWEEN 1.5 AND 3.25` means the filter condition is equal to "1.5 ≤ col2 ≤ 3.25". -- From version 2.1.4.0, operator `IN` can be used in where clause. For example, `WHERE city IN ('California.SanFrancisco', 'California.SanDieo')`. For bool type, both `{true, false}` and `{0, 1}` are allowed, but integers other than 0 or 1 are not allowed. FLOAT and DOUBLE types are impacted by floating precision, only values that match the condition within the tolerance will be selected. Non-primary key column of timestamp type can be used with `IN`. -- From version 2.3.0.0, regular expression is supported in where clause with keyword `match` or `nmatch`, the regular expression is case insensitive. +- From version 2.1.4.0, operator `IN` can be used in the where clause. For example, `WHERE city IN ('California.SanFrancisco', 'California.SanDiego')`. For bool type, both `{true, false}` and `{0, 1}` are allowed, but integers other than 0 or 1 are not allowed. FLOAT and DOUBLE types are impacted by floating precision, only values that match the condition within the tolerance will be selected. Non-primary key column of timestamp type can be used with `IN`. +- From version 2.3.0.0, regular expression is supported in the where clause with keyword `match` or `nmatch`, the regular expression is case insensitive. ## Regular Expression @@ -342,11 +342,11 @@ The regular expression being used must be compliant with POSIX specification, pl Regular expression can be used against only table names, i.e. `tbname`, and tags of binary/nchar types, but can't be used against data columns. -The maximum length of regular expression string is 128 bytes. Configuration parameter `maxRegexStringLen` can be used to set the maximum allowed regular expression. It's a configuration parameter on client side, and will take in effect after restarting the client. +The maximum length of regular expression string is 128 bytes. Configuration parameter `maxRegexStringLen` can be used to set the maximum allowed regular expression. It's a configuration parameter on the client side, and will take effect after restarting the client. ## JOIN -From version 2.2.0.0, inner join is fully supported in TDengine. More specifically, the inner join between table and table, that between STable and STable, and that between sub query and sub query are supported. +From version 2.2.0.0, inner join is fully supported in TDengine. More specifically, the inner join between table and table, between STable and STable, and between sub query and sub query are supported. Only primary key, i.e. timestamp, can be used in the join operation between table and table. For example: @@ -369,7 +369,7 @@ Similary, join operation can be performed on the result set of multiple sub quer :::note Restrictions on join operation: -- The number of tables or STables in single join operation can't exceed 10. +- The number of tables or STables in a single join operation can't exceed 10. - `FILL` is not allowed in the query statement that includes JOIN operation. - Arithmetic operation is not allowed on the result set of join operation. - `GROUP BY` is not allowed on a part of tables that participate in join operation. @@ -382,7 +382,7 @@ Restrictions on join operation: Nested query is also called sub query, that means in a single SQL statement the result of inner query can be used as the data source of the outer query. -From 2.2.0.0, unassociated sub query can be used in the `FROM` clause. unassociated means the sub query doesn't use the parameters in the parent query. More specifically, in the `tb_name_list` of `SELECT` statement, an independent SELECT statement can be used. So a complete nested query looks like: +From 2.2.0.0, unassociated sub query can be used in the `FROM` clause. Unassociated means the sub query doesn't use the parameters in the parent query. More specifically, in the `tb_name_list` of `SELECT` statement, an independent SELECT statement can be used. So a complete nested query looks like: ```SQL SELECT ... FROM (SELECT ... FROM ...) ...; @@ -414,7 +414,7 @@ UNION ALL SELECT ... [UNION ALL SELECT ...] ``` -`UNION ALL` operator can be used to combine the result set from multiple select statements as long as the result set of these select statements have exactly same columns. `UNION ALL` doesn't remove redundant rows from multiple result sets. In single SQL statement, at most 100 `UNION ALL` can be supported. +`UNION ALL` operator can be used to combine the result set from multiple select statements as long as the result set of these select statements have exactly the same columns. `UNION ALL` doesn't remove redundant rows from multiple result sets. In a single SQL statement, at most 100 `UNION ALL` can be supported. ### Examples From cc820359c45281325a5cf482edbfa3bb549f7438 Mon Sep 17 00:00:00 2001 From: Sean Ely <105326513+sean-tdengine@users.noreply.github.com> Date: Wed, 25 May 2022 13:20:15 -0700 Subject: [PATCH 58/63] docs: grammar: sql functions Minor grammar and formatting updates to SQL > Functions page --- docs-en/12-taos-sql/07-function.md | 102 ++++++++++++++--------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/docs-en/12-taos-sql/07-function.md b/docs-en/12-taos-sql/07-function.md index 9db5f36f92..0d6e7f2564 100644 --- a/docs-en/12-taos-sql/07-function.md +++ b/docs-en/12-taos-sql/07-function.md @@ -4,7 +4,7 @@ title: Functions ## Aggregate Functions -Aggregate query is supported in TDengine by following aggregate functions and selection functions. +Aggregate queries are supported in TDengine by the following aggregate functions and selection functions. ### COUNT @@ -12,11 +12,11 @@ Aggregate query is supported in TDengine by following aggregate functions and se SELECT COUNT([*|field_name]) FROM tb_name [WHERE clause]; ``` -**Description**:Get the number of rows or the number of non-null values in a table or a super table. +**Description**: Get the number of rows or the number of non-null values in a table or a super table. -**Return value type**:Long integer INT64 +**Return value type**: Long integer INT64 -**Applicable column types**:All +**Applicable column types**: All **Applicable table types**: table, super table, sub table @@ -47,13 +47,13 @@ Query OK, 1 row(s) in set (0.001075s) SELECT AVG(field_name) FROM tb_name [WHERE clause]; ``` -**Description**:Get the average value of a column in a table or STable +**Description**: Get the average value of a column in a table or STable -**Return value type**:Double precision floating number +**Return value type**: Double precision floating number -**Applicable column types**:Data types except for timestamp, binary, nchar and bool +**Applicable column types**: Data types except for timestamp, binary, nchar and bool -**Applicable table types**:table, STable +**Applicable table types**: table, STable **Examples**: @@ -77,13 +77,13 @@ Query OK, 1 row(s) in set (0.000943s) SELECT TWA(field_name) FROM tb_name WHERE clause; ``` -**Description**:Time weighted average on a specific column within a time range +**Description**: Time weighted average on a specific column within a time range -**Return value type**:Double precision floating number +**Return value type**: Double precision floating number -**Applicable column types**:Data types except for timestamp, binary, nchar and bool +**Applicable column types**: Data types except for timestamp, binary, nchar and bool -**Applicable table types**:table, STable +**Applicable table types**: table, STable **More explanations**: @@ -95,13 +95,13 @@ SELECT TWA(field_name) FROM tb_name WHERE clause; SELECT IRATE(field_name) FROM tb_name WHERE clause; ``` -**Description**:instantaneous rate on a specific column. The last two samples in the specified time range are used to calculate instantaneous rate. If the last sample value is smaller, then only the last sample value is used instead of the difference between the last two sample values. +**Description**: instantaneous rate on a specific column. The last two samples in the specified time range are used to calculate instantaneous rate. If the last sample value is smaller, then only the last sample value is used instead of the difference between the last two sample values. -**Return value type**:Double precision floating number +**Return value type**: Double precision floating number -**Applicable column types**:Data types except for timestamp, binary, nchar and bool +**Applicable column types**: Data types except for timestamp, binary, nchar and bool -**Applicable table types**:table, STable +**Applicable table types**: table, STable **More explanations**: @@ -113,13 +113,13 @@ SELECT IRATE(field_name) FROM tb_name WHERE clause; SELECT SUM(field_name) FROM tb_name [WHERE clause]; ``` -**Description**:The sum of a specific column in a table or STable +**Description**: The sum of a specific column in a table or STable -**Return value type**:Double precision floating number or long integer +**Return value type**: Double precision floating number or long integer -**Applicable column types**:Data types except for timestamp, binary, nchar and bool +**Applicable column types**: Data types except for timestamp, binary, nchar and bool -**Applicable table types**:table, STable +**Applicable table types**: table, STable **Examples**: @@ -143,13 +143,13 @@ Query OK, 1 row(s) in set (0.000980s) SELECT STDDEV(field_name) FROM tb_name [WHERE clause]; ``` -**Description**:Standard deviation of a specific column in a table or STable +**Description**: Standard deviation of a specific column in a table or STable -**Return value type**:Double precision floating number +**Return value type**: Double precision floating number -**Applicable column types**:Data types except for timestamp, binary, nchar and bool +**Applicable column types**: Data types except for timestamp, binary, nchar and bool -**Applicable table types**:table, STable (starting from version 2.0.15.1) +**Applicable table types**: table, STable (starting from version 2.0.15.1) **Examples**: @@ -261,7 +261,7 @@ Query OK, 1 row(s) in set (0.008388s) ## Selection Functions -When any selective function is used, timestamp column or tag columns including `tbname` can be specified to show that the selected value are from which rows. +When any select function is used, timestamp column or tag columns including `tbname` can be specified to show that the selected value are from which rows. ### MIN @@ -269,13 +269,13 @@ When any selective function is used, timestamp column or tag columns including ` SELECT MIN(field_name) FROM {tb_name | stb_name} [WHERE clause]; ``` -**Description**:The minimum value of a specific column in a table or STable +**Description**: The minimum value of a specific column in a table or STable -**Return value type**:Same as the data type of the column being operated +**Return value type**: Same as the data type of the column being operated -**Applicable column types**:Data types except for timestamp, binary, nchar and bool +**Applicable column types**: Data types except for timestamp, binary, nchar and bool -**Applicable table types**:table, STable +**Applicable table types**: table, STable **Examples**: @@ -299,13 +299,13 @@ Query OK, 1 row(s) in set (0.000950s) SELECT MAX(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**:The maximum value of a specific column of a table or STable +**Description**: The maximum value of a specific column of a table or STable -**Return value type**:Same as the data type of the column being operated +**Return value type**: Same as the data type of the column being operated -**Applicable column types**:Data types except for timestamp, binary, nchar and bool +**Applicable column types**: Data types except for timestamp, binary, nchar and bool -**Applicable table types**:table, STable +**Applicable table types**: table, STable **Examples**: @@ -329,13 +329,13 @@ Query OK, 1 row(s) in set (0.000987s) SELECT FIRST(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**:The first non-null value of a specific column in a table or STable +**Description**: The first non-null value of a specific column in a table or STable -**Return value type**:Same as the column being operated +**Return value type**: Same as the column being operated -**Applicable column types**:Any data type +**Applicable column types**: Any data type -**Applicable table types**:table, STable +**Applicable table types**: table, STable **More explanations**: @@ -365,13 +365,13 @@ Query OK, 1 row(s) in set (0.001023s) SELECT LAST(field_name) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**:The last non-NULL value of a specific column in a table or STable +**Description**: The last non-NULL value of a specific column in a table or STable -**Return value type**:Same as the column being operated +**Return value type**: Same as the column being operated -**Applicable column types**:Any data type +**Applicable column types**: Any data type -**Applicable table types**:table, STable +**Applicable table types**: table, STable **More explanations**: @@ -403,11 +403,11 @@ SELECT TOP(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; **Description**: The greatest _k_ values of a specific column in a table or STable. If a value has multiple occurrences in the column but counting all of them in will exceed the upper limit _k_, then a part of them will be returned randomly. -**Return value type**:Same as the column being operated +**Return value type**: Same as the column being operated -**Applicable column types**:Data types except for timestamp, binary, nchar and bool +**Applicable column types**: Data types except for timestamp, binary, nchar and bool -**Applicable table types**:table, STable +**Applicable table types**: table, STable **More explanations**: @@ -440,9 +440,9 @@ Query OK, 2 row(s) in set (0.000810s) SELECT BOTTOM(field_name, K) FROM { tb_name | stb_name } [WHERE clause]; ``` -**Description**:The least _k_ values of a specific column in a table or STable. If a value has multiple occurrences in the column but counting all of them in will exceed the upper limit _k_, then a part of them will be returned randomly. +**Description**: The least _k_ values of a specific column in a table or STable. If a value has multiple occurrences in the column but counting all of them in will exceed the upper limit _k_, then a part of them will be returned randomly. -**Return value type**:Same as the column being operated +**Return value type**: Same as the column being operated **Applicable column types**: Data types except for timestamp, binary, nchar and bool @@ -584,7 +584,7 @@ SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] [ **Description**: The value that matches the specified timestamp range is returned, if existing; or an interpolation value is returned. -**Return value type**: same as the column being operated +**Return value type**: Same as the column being operated **Applicable column types**: Numeric data types @@ -608,7 +608,7 @@ SELECT INTERP(field_name) FROM { tb_name | stb_name } [WHERE where_condition] [ taos> SELECT INTERP(current) FROM t1 RANGE('2017-7-14 18:40:00','2017-7-14 18:40:00') FILL(LINEAR); ``` -- Get an original data every 5 seconds, no interpolation, between "2017-07-14 18:00:00" and "2017-07-14 19:00:00: +- Get original data every 5 seconds, no interpolation, between "2017-07-14 18:00:00" and "2017-07-14 19:00:00: ``` taos> SELECT INTERP(current) FROM t1 RANGE('2017-7-14 18:00:00','2017-7-14 19:00:00') EVERY(5s); @@ -662,7 +662,7 @@ SELECT INTERP(field_name) FROM { tb_name | stb_name } WHERE ts='timestamp' [FILL Query OK, 1 row(s) in set (0.002652s) ``` -If there is not any data corresponding to the specified timestamp, an interpolation value is returned if interpolation policy is specified by `FILL` parameter; or nothing is returned\ +If there is no data corresponding to the specified timestamp, an interpolation value is returned if interpolation policy is specified by `FILL` parameter; or nothing is returned. ``` taos> SELECT INTERP(*) FROM meters WHERE tbname IN ('d636') AND ts='2017-7-14 18:40:00.005'; @@ -819,7 +819,7 @@ SELECT DERIVATIVE(field_name, time_interval, ignore_negative) FROM tb_name [WHER **More explanations**: -- It is available from version 2.1.3.0, the number of result rows is the number of total rows in the time range subtracted by one, no output for the first row.\ +- It is available from version 2.1.3.0, the number of result rows is the number of total rows in the time range subtracted by one, no output for the first row. - It can be used together with `GROUP BY tbname` against a STable. **Examples**: @@ -882,7 +882,7 @@ SELECT CEIL(field_name) FROM { tb_name | stb_name } [WHERE clause]; **Applicable table types**: table, STable -**Applicable nested query**: inner query and outer query +**Applicable nested query**: Inner query and outer query **More explanations**: From 8fdaa3e8e7af15436addcfbe7a30fde6423c38f6 Mon Sep 17 00:00:00 2001 From: Sean Ely <105326513+sean-tdengine@users.noreply.github.com> Date: Wed, 25 May 2022 15:02:49 -0700 Subject: [PATCH 59/63] docs: grammar: sql interval Grammar updates to the SQL > Interval page. --- docs-en/12-taos-sql/08-interval.md | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/docs-en/12-taos-sql/08-interval.md b/docs-en/12-taos-sql/08-interval.md index 2044ff4f61..bf0904458c 100644 --- a/docs-en/12-taos-sql/08-interval.md +++ b/docs-en/12-taos-sql/08-interval.md @@ -8,11 +8,11 @@ Window related clauses are used to divide the data set to be queried into subset ## Time Window -`INTERVAL` clause is used to generate time windows of same time interval, `SLIDING` is used to specify the time step for which the time window moves forward. The query is performed on one time window each time, and the time window moves forward with time. When defining continuous query both the size of time window and the step of forward sliding time need to be specified. As shown in the figure blow, [t0s, t0e] ,[t1s , t1e], [t2s, t2e] are respectively the time range of three time windows on which continuous queries are executed. The time step for which time window moves forward is marked by `sliding time`. Query, filter and aggregate operations are executed on each time window respectively. When the time step specified by `SLIDING` is same as the time interval specified by `INTERVAL`, the sliding time window is actually a flip time window. +`INTERVAL` clause is used to generate time windows of the same time interval, `SLIDING` is used to specify the time step for which the time window moves forward. The query is performed on one time window each time, and the time window moves forward with time. When defining continuous query both the size of time window and the step of forward sliding time need to be specified. As shown in the figure blow, [t0s, t0e] ,[t1s , t1e], [t2s, t2e] are respectively the time ranges of three time windows on which continuous queries are executed. The time step for which time window moves forward is marked by `sliding time`. Query, filter and aggregate operations are executed on each time window respectively. When the time step specified by `SLIDING` is same as the time interval specified by `INTERVAL`, the sliding time window is actually a flip time window. ![Time Window](./timewindow-1.webp) -`INTERVAL` and `SLIDING` should be used with aggregate functions and selection functions. Below SQL statement is illegal because no aggregate or selection function is used with `INTERVAL`. +`INTERVAL` and `SLIDING` should be used with aggregate functions and select functions. Below SQL statement is illegal because no aggregate or selection function is used with `INTERVAL`. ``` SELECT * FROM temp_tb_1 INTERVAL(1m); @@ -24,11 +24,11 @@ The time step specified by `SLIDING` can't exceed the time interval specified by SELECT COUNT(*) FROM temp_tb_1 INTERVAL(1m) SLIDING(2m); ``` -When the time length specified by `SLIDING` is same as that specified by `INTERVAL`, sliding window is actually flip window. The minimum time range specified by `INTERVAL` is 10 milliseconds (10a) prior to version 2.1.5.0. From version 2.1.5.0, the minimum time range by `INTERVAL` can be 1 microsecond (1u). However, if the DB precision is millisecond, the minimum time range is 1 millisecond (1a). Please be noted that the `timezone` parameter should be configured to same value in the `taos.cfg` configuration file on client side and server side. +When the time length specified by `SLIDING` is the same as that specified by `INTERVAL`, the sliding window is actually a flip window. The minimum time range specified by `INTERVAL` is 10 milliseconds (10a) prior to version 2.1.5.0. From version 2.1.5.0, the minimum time range by `INTERVAL` can be 1 microsecond (1u). However, if the DB precision is millisecond, the minimum time range is 1 millisecond (1a). Please note that the `timezone` parameter should be configured to be the same value in the `taos.cfg` configuration file on client side and server side. ## Status Window -In case of using integer, bool, or string to represent the device status at a moment, the continuous rows with same status belong to same status window. Once the status changes, the status window closes. As shown in the following figure,there are two status windows according to status, [2019-04-28 14:22:07,2019-04-28 14:22:10] and [2019-04-28 14:22:11,2019-04-28 14:22:12]. Status window is not applicable to STable for now. +In case of using integer, bool, or string to represent the device status at a moment, the continuous rows with same status belong to same status window. Once the status changes, the status window closes. As shown in the following figure, there are two status windows according to status, [2019-04-28 14:22:07,2019-04-28 14:22:10] and [2019-04-28 14:22:11,2019-04-28 14:22:12]. Status window is not applicable to STable for now. ![Status Window](./timewindow-3.webp) @@ -44,7 +44,7 @@ SELECT COUNT(*), FIRST(ts), status FROM temp_tb_1 STATE_WINDOW(status); SELECT COUNT(*), FIRST(ts) FROM temp_tb_1 SESSION(ts, tol_val); ``` -The primary key, i.e. timestamp, is used to determine which session window the row belongs to. If the time interval between two adjacent rows is within the time range specified by `tol_val`, they belong to same session window; otherwise they belong to two different time windows. As shown in the figure below, if the limit of time interval for session window is specified as 12 seconds, then the 6 rows in the figure constitutes 2 time windows, [2019-04-28 14:22:10,2019-04-28 14:22:30] and [2019-04-28 14:23:10,2019-04-28 14:23:30], because the time difference between 2019-04-28 14:22:30 and 2019-04-28 14:23:10 is 40 seconds, which exceeds the time interval limit of 12 seconds. +The primary key, i.e. timestamp, is used to determine which session window the row belongs to. If the time interval between two adjacent rows is within the time range specified by `tol_val`, they belong to the same session window; otherwise they belong to two different time windows. As shown in the figure below, if the limit of time interval for the session window is specified as 12 seconds, then the 6 rows in the figure constitutes 2 time windows, [2019-04-28 14:22:10,2019-04-28 14:22:30] and [2019-04-28 14:23:10,2019-04-28 14:23:30], because the time difference between 2019-04-28 14:22:30 and 2019-04-28 14:23:10 is 40 seconds, which exceeds the time interval limit of 12 seconds. ![Session Window](./timewindow-2.webp) @@ -54,7 +54,7 @@ If the time interval between two continuous rows are within the time interval sp ### Syntax -The full syntax of aggregate by window is as following: +The full syntax of aggregate by window is as follows: ```sql SELECT function_list FROM tb_name @@ -73,11 +73,11 @@ SELECT function_list FROM stb_name ### Restrictions -- Aggregate functions and selection functions can be used in `function_list`, with each function having only one output, for example COUNT, AVG, SUM, STDDEV, LEASTSQUARES, PERCENTILE, MIN, MAX, FIRST, LAST. Functions having multiple output can't be used, for example DIFF or arithmetic operations. +- Aggregate functions and select functions can be used in `function_list`, with each function having only one output, for example COUNT, AVG, SUM, STDDEV, LEASTSQUARES, PERCENTILE, MIN, MAX, FIRST, LAST. Functions having multiple output can't be used, for example DIFF or arithmetic operations. - `LAST_ROW` can't be used together with window aggregate. - Scalar functions, like CEIL/FLOOR, can't be used with window aggregate. - `WHERE` clause can be used to specify the starting and ending time and other filter conditions -- `FILL` clause is used to specify how to fill when there is data missing in any window, including: \ +- `FILL` clause is used to specify how to fill when there is data missing in any window, including: 1. NONE: No fill (the default fill mode) 2. VALUE:Fill with a fixed value, which should be specified together, for example `FILL(VALUE, 1.23)` 3. PREV:Fill with the previous non-NULL value, `FILL(PREV)` @@ -88,21 +88,22 @@ SELECT function_list FROM stb_name :::info 1. Huge volume of interpolation output may be returned using `FILL`, so it's recommended to specify the time range when using `FILL`. The maximum interpolation values that can be returned in single query is 10,000,000. -2. The result set is in the ascending order of timestamp in aggregate by time window aggregate. +2. The result set is in ascending order of timestamp in aggregate by time window aggregate. 3. If aggregate by window is used on STable, the aggregate function is performed on all the rows matching the filter conditions. If `GROUP BY` is not used in the query, the result set will be returned in ascending order of timestamp; otherwise the result set is not exactly in the order of ascending timestamp in each group. - ::: + +::: Aggregate by time window is also used in continuous query, please refer to [Continuous Query](/develop/continuous-query). ## Examples -The table of intelligent meters can be created like below SQL statement: +The table of intelligent meters can be created by the SQL statement below: ```sql CREATE TABLE meters (ts TIMESTAMP, current FLOAT, voltage INT, phase FLOAT) TAGS (location BINARY(64), groupId INT); ``` -The average current, maximum current and median of current in every 10 minutes of the past 24 hours can be calculated using below SQL statement, with missing value filled with the previous non-NULL value. +The average current, maximum current and median of current in every 10 minutes for the past 24 hours can be calculated using the below SQL statement, with missing values filled with the previous non-NULL values. ``` SELECT AVG(current), MAX(current), APERCENTILE(current, 50) FROM meters From 0fee6f2a0bbd49686fe049da44da95e3813ce4e5 Mon Sep 17 00:00:00 2001 From: Sean Ely <105326513+sean-tdengine@users.noreply.github.com> Date: Wed, 25 May 2022 15:16:57 -0700 Subject: [PATCH 60/63] docs: grammar: sql limits Minor grammar edits to SQL > Limits page --- docs-en/12-taos-sql/09-limit.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs-en/12-taos-sql/09-limit.md b/docs-en/12-taos-sql/09-limit.md index 873e484fbb..b987cbcb78 100644 --- a/docs-en/12-taos-sql/09-limit.md +++ b/docs-en/12-taos-sql/09-limit.md @@ -5,8 +5,8 @@ title: Limits & Restrictions ## Naming Rules 1. Only English characters, digits and underscore are allowed -2. Can't be started with digits -3. Case Insensitive without escape character "\`" +2. Can't start with a digit +3. Case insensitive without escape character "\`" 4. Identifier with escape character "\`" To support more flexible table or column names, a new escape character "\`" is introduced. For more details please refer to [escape](/taos-sql/escape). @@ -18,7 +18,7 @@ The legal character set is `[a-zA-Z0-9!?$%^&*()_–+={[}]:;@~#|<,>.?/]`. - Maximum length of database name is 32 bytes - Maximum length of table name is 192 bytes, excluding the database name prefix and the separator -- Maximum length of each data row is 48K bytes from version 2.1.7.0 , before which the limit is 16K bytes. Please be noted that the upper limit includes the extra 2 bytes consumed by each column of BINARY/NCHAR type. +- Maximum length of each data row is 48K bytes from version 2.1.7.0 , before which the limit is 16K bytes. Please note that the upper limit includes the extra 2 bytes consumed by each column of BINARY/NCHAR type. - Maximum of column name is 64. - Maximum number of columns is 4096. There must be at least 2 columns, and the first column must be timestamp. - Maximum length of tag name is 64. @@ -26,7 +26,7 @@ The legal character set is `[a-zA-Z0-9!?$%^&*()_–+={[}]:;@~#|<,>.?/]`. - Maximum length of singe SQL statement is 1048576, i.e. 1 MB bytes. It can be configured in the parameter `maxSQLLength` in the client side, the applicable range is [65480, 1048576]. - At most 4096 columns (or 1024 prior to 2.1.7.0) can be returned by `SELECT`, functions in the query statement may constitute columns. Error will be returned if the limit is exceeded. - Maximum numbers of databases, STables, tables are only depending on the system resources. -- Maximum of database name is 32 bytes, can't include "." and special characters. +- Maximum of database name is 32 bytes, and it can't include "." or special characters. - Maximum replica number of database is 3 - Maximum length of user name is 23 bytes - Maximum length of password is 15 bytes @@ -37,7 +37,7 @@ The legal character set is `[a-zA-Z0-9!?$%^&*()_–+={[}]:;@~#|<,>.?/]`. ## Restrictions of `GROUP BY` -`GROUP BY` can be performed on tags and `TBNAME`. It can be performed on data columns too, with one restriction that only one column and the number of unique values on that column is lower than 100,000. Please be noted that `GROUP BY` can't be performed on float or double type. +`GROUP BY` can be performed on tags and `TBNAME`. It can be performed on data columns too, with one restriction that only one column and the number of unique values on that column is lower than 100,000. Please note that `GROUP BY` can't be performed on float or double types. ## Restrictions of `IS NOT NULL` @@ -45,7 +45,7 @@ The legal character set is `[a-zA-Z0-9!?$%^&*()_–+={[}]:;@~#|<,>.?/]`. ## Restrictions of `ORDER BY` -- Only one `order by` is allowed for normal table and sub table. +- Only one `order by` is allowed for normal table and subtable. - At most two `order by` are allowed for STable, and the second one must be `ts`. - `order by tag` must be used with `group by tag` on same tag, this rule is also applicable to `tbname`. - `order by column` must be used with `group by column` or `top/bottom` on same column. This rule is applicable to table and STable. @@ -56,11 +56,11 @@ The legal character set is `[a-zA-Z0-9!?$%^&*()_–+={[}]:;@~#|<,>.?/]`. ### Name Restrictions of Table/Column -The name of a table or column can only be composed of ASCII characters, digits and underscore, while digit can't be used as the beginning. The maximum length is 192 bytes. Names are case insensitive. The name mentioned in this rule doesn't include the database name prefix and the separator. +The name of a table or column can only be composed of ASCII characters, digits and underscore, while it can't start with a digit. The maximum length is 192 bytes. Names are case insensitive. The name mentioned in this rule doesn't include the database name prefix and the separator. ### Name Restrictions After Escaping -To support more flexible table or column names, new escape character "`" is introduced in TDengine to avoid the conflict between table name and keywords and break the above restrictions for table name. The escape character is not counted in the length of table name. +To support more flexible table or column names, new escape character "\`" is introduced in TDengine to avoid the conflict between table name and keywords and break the above restrictions for table names. The escape character is not counted in the length of table name. With escaping, the string inside escape characters are case sensitive, i.e. will not be converted to lower case internally. From 15b9d1a88a803668641e6f29fb5ffa18fc38cd98 Mon Sep 17 00:00:00 2001 From: Sean Ely <105326513+sean-tdengine@users.noreply.github.com> Date: Wed, 25 May 2022 15:28:31 -0700 Subject: [PATCH 61/63] docs: grammar: sql json Minor grammar updates to SQL > JSON page --- docs-en/12-taos-sql/10-json.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs-en/12-taos-sql/10-json.md b/docs-en/12-taos-sql/10-json.md index 60468f1e0f..abe6649330 100644 --- a/docs-en/12-taos-sql/10-json.md +++ b/docs-en/12-taos-sql/10-json.md @@ -52,13 +52,13 @@ title: JSON Type 4. Tag Operations - The value of JSON tag can be altered. Please be noted that the full JSON will be override when doing this. + The value of JSON tag can be altered. Please note that the full JSON will be overriden when doing this. The name of JSON tag can be altered. A tag of JSON type can't be added or removed. The column length of a JSON tag can't be changed. ## Other Restrictions -- JSON type can only be used for tag. There can be only one tag of JSON type, and it's exclusive to any other types of tag. +- JSON type can only be used for a tag. There can be only one tag of JSON type, and it's exclusive to any other types of tags. - The maximum length of keys in JSON is 256 bytes, and key must be printable ASCII characters. The maximum total length of a JSON is 4,096 bytes. @@ -74,7 +74,7 @@ title: JSON Type - If a tag of JSON is the result of inner query, it can't be parsed and queried in the outer query. -For example, below SQL statements are not supported. +For example, the below SQL statements are not supported. ```sql; select jtag->'key' from (select jtag from STable); From 74be10c361627c2ec250f60620381392eff8c9fc Mon Sep 17 00:00:00 2001 From: Sean Ely <105326513+sean-tdengine@users.noreply.github.com> Date: Wed, 25 May 2022 15:48:54 -0700 Subject: [PATCH 62/63] docs: grammar: admin install Minor grammar updates and formatting for Admin > Install & Uninstall page --- docs-en/13-operation/01-pkg-install.md | 29 +++++++++++++------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/docs-en/13-operation/01-pkg-install.md b/docs-en/13-operation/01-pkg-install.md index a1aad1c3c9..8dd6de3428 100644 --- a/docs-en/13-operation/01-pkg-install.md +++ b/docs-en/13-operation/01-pkg-install.md @@ -6,7 +6,7 @@ description: Install, Uninstall, Start, Stop and Upgrade import Tabs from "@theme/Tabs"; import TabItem from "@theme/TabItem"; -TDengine community version provides dev and rpm package for users to choose based on the system environment. deb supports Debian, Ubuntu and systems derived from them. rpm supports CentOS, RHEL, SUSE and systems derived from them. Furthermore, tar.gz package is provided for enterprise customers. +TDengine community version provides dev and rpm packages for users to choose based on the system environment. deb supports Debian, Ubuntu and systems derived from them. rpm supports CentOS, RHEL, SUSE and systems derived from them. Furthermore, tar.gz package is provided for enterprise customers. ## Install @@ -14,7 +14,7 @@ TDengine community version provides dev and rpm package for users to choose base 1. Download deb package from official website, for example TDengine-server-2.4.0.7-Linux-x64.deb -2. In the directory where the package is located, execute below command +2. In the directory where the package is located, execute the command below ```bash $ sudo dpkg -i TDengine-server-2.4.0.7-Linux-x64.deb @@ -46,7 +46,7 @@ TDengine is installed successfully! 1. Download rpm package from official website, for example TDengine-server-2.4.0.7-Linux-x64.rpm; -2. In the directory where the package is located, execute below command +2. In the directory where the package is located, execute the command below ``` $ sudo rpm -ivh TDengine-server-2.4.0.7-Linux-x64.rpm @@ -77,7 +77,7 @@ TDengine is installed successfully! 1. Download the tar.gz package, for example TDengine-server-2.4.0.7-Linux-x64.tar.gz; - 2、In the directory where the package is located, firstly decompress the file, then switch to the sub-directory generated in decompressing, i.e. "TDengine-enterprise-server-2.4.0.7/" in this example, and execute the `install.sh` script. +2. In the directory where the package is located, first decompress the file, then switch to the sub-directory generated in decompressing, i.e. "TDengine-enterprise-server-2.4.0.7/" in this example, and execute the `install.sh` script. ```bash $ tar xvzf TDengine-enterprise-server-2.4.0.7-Linux-x64.tar.gz @@ -132,7 +132,7 @@ Some configuration will be prompted for users to provide when install.sh is exec :::note -When installing on the first node in the cluster, when "Enter FQDN:" is prompted, nothing needs to be provided. When installing on following nodes, when "Enter FQDN:" is prompted, the end point of the first dnode in the cluster can be input if it has been already up; or just ignore it and configure later after installation is done. +When installing on the first node in the cluster, when "Enter FQDN:" is prompted, nothing needs to be provided. When installing on following nodes, when "Enter FQDN:" is prompted, the end point of the first dnode in the cluster can be input if it is already up; or just ignore it and configure later after installation is done. ::: @@ -181,14 +181,14 @@ taosKeeper is removed successfully! :::note -- It's strongly suggested not to use multiple kinds of installation packages on single host TDengine -- After deb package is installed, if the installation directory is removed manually so that uninstall or reinstall can't succeed, it can be resolved by cleaning up TDengine package information as below command and then reinstalling. +- It's strongly suggested not to use multiple kinds of installation packages on a single host TDengine +- After deb package is installed, if the installation directory is removed manually so that uninstall or reinstall can't succeed, it can be resolved by cleaning up TDengine package information as in the command below and then reinstalling. ```bash $ sudo rm -f /var/lib/dpkg/info/tdengine* ``` -- After rpm package is installed, if the installation directory is removed manually so that uninstall or reinstall can't succeed, it can be resolved by cleaning up TDengine package information as below command and then reinstalling. +- After rpm package is installed, if the installation directory is removed manually so that uninstall or reinstall can't succeed, it can be resolved by cleaning up TDengine package information as in the command below and then reinstalling. ```bash $ sudo rpm -e --noscripts tdengine @@ -228,14 +228,14 @@ During the installation process: :::note -- When TDengine is uninstalled, the configuration /etc/taos/taos.cfg, data directory /var/lib/taos, log directory /var/log/taos are kept. They can be deleted manually with caution because data can't be recovered once +- When TDengine is uninstalled, the configuration /etc/taos/taos.cfg, data directory /var/lib/taos, log directory /var/log/taos are kept. They can be deleted manually with caution because data can't be recovered - When reinstalling TDengine, if the default configuration file /etc/taos/taos.cfg exists, it will be kept and the configuration file in the installation package will be renamed to taos.cfg.orig and stored at /usr/local/taos/cfg to be used as configuration sample. Otherwise the configuration file in the installation package will be installed to /etc/taos/taos.cfg and used. ## Start and Stop -Linux system services `systemd`, `systemctl` or `service` is used to start, stop and restart TDengine. The server process of TDengine is `taosd`, which is started automatically after the Linux system is started. System operator can use `systemd`, `systemctl` or `service` to start, stop or restart TDengine server. +Linux system services `systemd`, `systemctl` or `service` are used to start, stop and restart TDengine. The server process of TDengine is `taosd`, which is started automatically after the Linux system is started. System operators can use `systemd`, `systemctl` or `service` to start, stop or restart TDengine server. -For example, if using `systemctl` , the commands to start, stop, restart and check TDengine server are as below: +For example, if using `systemctl` , the commands to start, stop, restart and check TDengine server are below: - Start server:`systemctl start taosd` @@ -263,12 +263,12 @@ Active: inactive (dead) There are two aspects in upgrade operation: upgrade installation package and upgrade a running server. -Upgrading package should follow the steps mentioned previously to firstly uninstall old version then install new version. +Upgrading package should follow the steps mentioned previously to first uninstall the old version then install the new version. -Upgrading a running server is much more complex. Firstly please check the version number of old version and new version. The version number of TDengine consists of 4 sections, only the first 3 section match can the old version be upgraded to the new version. The steps of upgrading a running server are as below: +Upgrading a running server is much more complex. First please check the version number of the old version and the new version. The version number of TDengine consists of 4 sections, only if the first 3 section match can the old version be upgraded to the new version. The steps of upgrading a running server are as below: - Stop inserting data -- Make sure all data persisted into disk +- Make sure all data are persisted into disk - Stop the cluster of TDengine - Uninstall old version and install new version - Start the cluster of TDengine @@ -277,6 +277,7 @@ Upgrading a running server is much more complex. Firstly please check the versio - Restore business data :::warning + TDengine doesn't guarantee any lower version is compatible with the data generated by a higher version, so it's never recommended to downgrade the version. ::: From 72ce88e97256123981c78b2ef58323b8f1eb1013 Mon Sep 17 00:00:00 2001 From: Sean Ely <105326513+sean-tdengine@users.noreply.github.com> Date: Wed, 25 May 2022 16:19:12 -0700 Subject: [PATCH 63/63] docs: grammar: resource planning Minor grammar edits to the Resource Planning page --- docs-en/13-operation/02-planning.mdx | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/docs-en/13-operation/02-planning.mdx b/docs-en/13-operation/02-planning.mdx index 35a34aebc0..4b8ed1f1b8 100644 --- a/docs-en/13-operation/02-planning.mdx +++ b/docs-en/13-operation/02-planning.mdx @@ -6,7 +6,7 @@ The computing and storage resources need to be planned if using TDengine to buil ## Memory Requirement of Server Side -The number of vgroups created for each database is same as the number of CPU cores by default and can be configured by parameter `maxVgroupsPerDb`, each vnode in a vgroup stores one replica. Each vnode consumes fixed size of memory, i.e. `blocks` \* `cache`. Besides, some memory is required for tag values associated with each table. A fixed amount of memory is required for each cluster. So, the memory required for each DB can be calculated using below formula: +The number of vgroups created for each database is the same as the number of CPU cores by default and can be configured by parameter `maxVgroupsPerDb`, each vnode in a vgroup stores one replica. Each vnode consumes a fixed size of memory, i.e. `blocks` \* `cache`. Besides, some memory is required for tag values associated with each table. A fixed amount of memory is required for each cluster. So, the memory required for each DB can be calculated using the formula below: ``` Database Memory Size = maxVgroupsPerDb * replica * (blocks * cache + 10MB) + numOfTables * (tagSizePerTable + 0.5KB) @@ -14,7 +14,7 @@ Database Memory Size = maxVgroupsPerDb * replica * (blocks * cache + 10MB) + num For example, assuming the default value of `maxVgroupPerDB` is 64, the default value of `cache` 16M, the default value of `blocks` is 6, there are 100,000 tables in a DB, the replica number is 1, total length of tag values is 256 bytes, the total memory required for this DB is: 64 \* 1 \* (16 \* 6 + 10) + 100000 \* (0.25 + 0.5) / 1000 = 6792M. -In real operation of TDengine, we are more concerned about the memory used by each TDengine server process `taosd`. +In the real operation of TDengine, we are more concerned about the memory used by each TDengine server process `taosd`. ``` taosd_memory = vnode_memory + mnode_memory + query_memory @@ -25,26 +25,26 @@ In the above formula: 1. "vnode_memory" of a `taosd` process is the memory used by all vnodes hosted by this `taosd` process. It can be roughly calculated by firstly adding up the total memory of all DBs whose memory usage can be derived according to the formula mentioned previously then dividing by number of dnodes and multiplying the number of replicas. ``` - vnode_memory = sum(Database memory) / number_of_dnodes \* replica + vnode_memory = sum(Database memory) / number_of_dnodes * replica ``` 2. "mnode_memory" of a `taosd` process is the memory consumed by a mnode. If there is one (and only one) mnode hosted in a `taosd` process, the memory consumed by "mnode" is "0.2KB \* the total number of tables in the cluster". 3. "query_memory" is the memory used when processing query requests. Each ongoing query consumes at least "0.2 KB \* total number of involved tables". -Please be noted that the above formulas can only be used to estimate the minimum memory requirement, instead of maximum memory usage. In a real production environment, it's better to preserve some redundance beyond the estimated minimum memory requirement. If memory is abundant, it's suggested to increase the value of parameter `blocks` to speed up data insertion and data query. +Please note that the above formulas can only be used to estimate the minimum memory requirement, instead of maximum memory usage. In a real production environment, it's better to reserve some redundance beyond the estimated minimum memory requirement. If memory is abundant, it's suggested to increase the value of parameter `blocks` to speed up data insertion and data query. ## Memory Requirement of Client Side -The client programs use TDengine client driver `taosc` to connect to the server side, there is also memory requirement for a client program. +For the client programs using TDengine client driver `taosc` to connect to the server side there is a memory requirement as well. -The memory consumed by a client program is mainly about the SQL statements for data insertion, caching of table metadata, and some internal use. Assuming maximum number of tables is N (the memory consumed by the metadata of each table is 256 bytes), maximum number of threads for parallel insertion is T, maximum length of a SQL statement is S (normally 1 MB), the memory required by a client program can be estimated using below formula: +The memory consumed by a client program is mainly about the SQL statements for data insertion, caching of table metadata, and some internal use. Assuming maximum number of tables is N (the memory consumed by the metadata of each table is 256 bytes), maximum number of threads for parallel insertion is T, maximum length of a SQL statement is S (normally 1 MB), the memory required by a client program can be estimated using the below formula: ``` M = (T * S * 3 + (N / 4096) + 100) ``` -For example, if the number of parallel data insertion threads is 100, total number of tables is 10,000,000, then minimum memory requirement of a client program is: +For example, if the number of parallel data insertion threads is 100, total number of tables is 10,000,000, then the minimum memory requirement of a client program is: ``` 100 * 3 + (10000000 / 4096) + 100 = 2741 (MBytes) @@ -56,10 +56,10 @@ So, at least 3GB needs to be reserved for such a client. The CPU resources required depend on two aspects: -- **Data Insertion** Each dnode of TDengine can process at least 10,000 insertion requests in one second, while each insertion request can have multiple rows. The computing resource consumed between inserting 1 row one time and inserting 10 rows one time is very small. So, the more the rows to insert one time, the higher the efficiency. Inserting in bach also exposes requirement for the client side which needs to cache rows and insert in batch once the cached rows reaches a threshold. +- **Data Insertion** Each dnode of TDengine can process at least 10,000 insertion requests in one second, while each insertion request can have multiple rows. The computing resource consumed between inserting 1 row one time and inserting 10 rows one time is very small. So, the more the rows to insert one time, the higher the efficiency. Inserting in bach also exposes requirements for the client side which needs to cache rows and insert in batch once the cached rows reaches a threshold. - **Data Query** High efficiency query is provided in TDengine, but it's hard to estimate the CPU resource required because the queries used in different use cases and the frequency of queries vary significantly. It can only be verified with the query statements, query frequency, data size to be queried, etc provided by user. -In short words, the CPU resource required for data insertion can be estimated but it's hard to do so for query use cases. In real operation, it's suggested to control CPU usage below 50%. If this threshold is exceeded, it's a reminder for system operator to add more nodes in the cluster to expand resources. +In short, the CPU resource required for data insertion can be estimated but it's hard to do so for query use cases. In real operation, it's suggested to control CPU usage below 50%. If this threshold is exceeded, it's a reminder for system operator to add more nodes in the cluster to expand resources. ## Disk Requirement @@ -69,14 +69,14 @@ The compression ratio in TDengine is much higher than that in RDBMS. In most cas Raw DataSize = numOfTables * rowSizePerTable * rowsPerTable ``` -For example, there are 10,000,000 meters, while each meter collects data every 15 minutes and the data size of each collection si 128 bytes, so the raw data size of one year is: 10000000 \* 128 \* 24 \* 60 / 15 \* 365 = 44.8512(TB). Assuming compression ratio is 5, the actual disk size is: 44.851 / 5 = 8.97024(TB). +For example, there are 10,000,000 meters, while each meter collects data every 15 minutes and the data size of each collection is 128 bytes, so the raw data size of one year is: 10000000 \* 128 \* 24 \* 60 / 15 \* 365 = 44.8512(TB). Assuming compression ratio is 5, the actual disk size is: 44.851 / 5 = 8.97024(TB). Parameter `keep` can be used to set how long the data will be kept on disk. To further reduce storage cost, multiple storage levels can be enabled in TDengine, with the coldest data stored on the cheapest storage device, and this is transparent to application programs. -To increase the performance, multiple disks can be setup for parallel data reading or data inserting. Please be noted that expensive disk array is not necessary because replications are used in TDengine to provide high availability. +To increase the performance, multiple disks can be setup for parallel data reading or data inserting. Please note that an expensive disk array is not necessary because replications are used in TDengine to provide high availability. ## Number of Hosts -A host can be either physical or virtual. The total memory, total CPU, total disk required can be estimated according to the formulas mentioned previously. Then, according to the system resources that a single host can provide, assuming all hosts are same in resources, the number of hosts can be derived easily. +A host can be either physical or virtual. The total memory, total CPU, total disk required can be estimated according to the formulas mentioned previously. Then, according to the system resources that a single host can provide, assuming all hosts have the same resources, the number of hosts can be derived easily. **Quick Estimation for CPU, Memory and Disk** Please refer to [Resource Estimate](https://www.taosdata.com/config/config.html).