From 61b351a14f14a1b4f27e0596c78541d66f4b8181 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Sat, 12 Mar 2022 18:02:56 +0800 Subject: [PATCH 01/38] [td-13039] refactor. --- source/libs/executor/inc/executorimpl.h | 8 +- source/libs/executor/src/executorimpl.c | 125 +++++++++++------------- 2 files changed, 62 insertions(+), 71 deletions(-) diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index ee841e3ce9..5368b2397a 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -240,12 +240,12 @@ typedef struct STaskAttr { SArray* pUdfInfo; // no need to free } STaskAttr; -typedef int32_t (*__optr_open_fn_t)(void* param); -typedef SSDataBlock* (*__optr_fn_t)(void* param, bool* newgroup); -typedef void (*__optr_close_fn_t)(void* param, int32_t num); - struct SOperatorInfo; +typedef int32_t (*__optr_open_fn_t)(struct SOperatorInfo* param); +typedef SSDataBlock* (*__optr_fn_t)(struct SOperatorInfo* param, bool* newgroup); +typedef void (*__optr_close_fn_t)(void* param, int32_t num); + typedef struct STaskIdInfo { uint64_t queryId; // this is also a request id uint64_t subplanId; diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 420d70233c..f472d1e00c 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -227,8 +227,7 @@ static void doSetOperatorCompleted(SOperatorInfo* pOperator) { #define OPTR_IS_OPENED(_optr) (((_optr)->status & OP_OPENED) == OP_OPENED) #define OPTR_SET_OPENED(_optr) ((_optr)->status |= OP_OPENED) -static int32_t operatorDummyOpenFn(void* param) { - SOperatorInfo* pOperator = (SOperatorInfo*) param; +static int32_t operatorDummyOpenFn(SOperatorInfo *pOperator) { OPTR_SET_OPENED(pOperator); return TSDB_CODE_SUCCESS; } @@ -4681,9 +4680,7 @@ static void doCloseAllTimeWindow(STaskRuntimeEnv* pRuntimeEnv) { } } -static SSDataBlock* doTableScanImpl(void* param, bool* newgroup) { - SOperatorInfo *pOperator = (SOperatorInfo*) param; - +static SSDataBlock* doTableScanImpl(SOperatorInfo *pOperator, bool* newgroup) { STableScanInfo *pTableScanInfo = pOperator->info; SExecTaskInfo *pTaskInfo = pOperator->pTaskInfo; @@ -4731,9 +4728,7 @@ static SSDataBlock* doTableScanImpl(void* param, bool* newgroup) { return NULL; } -static SSDataBlock* doTableScan(void* param, bool *newgroup) { - SOperatorInfo* pOperator = (SOperatorInfo*) param; - +static SSDataBlock* doTableScan(SOperatorInfo *pOperator, bool *newgroup) { STableScanInfo *pTableScanInfo = pOperator->info; SExecTaskInfo *pTaskInfo = pOperator->pTaskInfo; @@ -4804,8 +4799,7 @@ static SSDataBlock* doTableScan(void* param, bool *newgroup) { return p; } -static SSDataBlock* doBlockInfoScan(void* param, bool* newgroup) { - SOperatorInfo *pOperator = (SOperatorInfo*)param; +static SSDataBlock* doBlockInfoScan(SOperatorInfo *pOperator, bool* newgroup) { if (pOperator->status == OP_EXEC_DONE) { return NULL; } @@ -4852,9 +4846,7 @@ static SSDataBlock* doBlockInfoScan(void* param, bool* newgroup) { #endif } -static SSDataBlock* doStreamBlockScan(void* param, bool* newgroup) { - SOperatorInfo* pOperator = (SOperatorInfo*)param; - +static SSDataBlock* doStreamBlockScan(SOperatorInfo *pOperator, bool* newgroup) { // NOTE: this operator never check if current status is done or not SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SStreamBlockScanInfo* pInfo = pOperator->info; @@ -5170,8 +5162,7 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo *pOperator) { } } -static int32_t prepareLoadRemoteData(void* param) { - SOperatorInfo *pOperator = (SOperatorInfo*) param; +static int32_t prepareLoadRemoteData(SOperatorInfo *pOperator) { if (OPTR_IS_OPENED(pOperator)) { return TSDB_CODE_SUCCESS; } @@ -5190,9 +5181,7 @@ static int32_t prepareLoadRemoteData(void* param) { return TSDB_CODE_SUCCESS; } -static SSDataBlock* doLoadRemoteData(void* param, bool* newgroup) { - SOperatorInfo *pOperator = (SOperatorInfo*) param; - +static SSDataBlock* doLoadRemoteData(SOperatorInfo *pOperator, bool* newgroup) { SExchangeInfo *pExchangeInfo = pOperator->info; SExecTaskInfo *pTaskInfo = pOperator->pTaskInfo; @@ -5418,7 +5407,7 @@ SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntim pOperator->info = pInfo; pOperator->numOfOutput = pRuntimeEnv->pQueryAttr->numOfCols; pOperator->pRuntimeEnv = pRuntimeEnv; - pOperator->getNextFn = doTableScanImpl; + pOperator->getNextFn = doTableScanImpl; return pOperator; } @@ -5497,9 +5486,8 @@ static int32_t loadSysTableContentCb(void* param, const SDataBuf* pMsg, int32_t tsem_post(&pSourceDataInfo->pEx->ready); } -static SSDataBlock* doSysTableScan(void* param, bool* newgroup) { +static SSDataBlock* doSysTableScan(SOperatorInfo *pOperator, bool* newgroup) { // build message and send to mnode to fetch the content of system tables. - SOperatorInfo* pOperator = (SOperatorInfo*) param; SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; SSysTableScanInfo* pInfo = pOperator->info; @@ -5989,8 +5977,7 @@ static SSDataBlock* doMerge(SOperatorInfo* pOperator) { return (pInfo->binfo.pRes->info.rows > 0)? pInfo->binfo.pRes:NULL; } -static SSDataBlock* doSortedMerge(void* param, bool* newgroup) { - SOperatorInfo* pOperator = (SOperatorInfo*) param; +static SSDataBlock* doSortedMerge(SOperatorInfo *pOperator, bool* newgroup) { if (pOperator->status == OP_EXEC_DONE) { return NULL; } @@ -6160,8 +6147,7 @@ SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t return NULL; } -static SSDataBlock* doSort(void* param, bool* newgroup) { - SOperatorInfo* pOperator = (SOperatorInfo*) param; +static SSDataBlock* doSort(SOperatorInfo *pOperator, bool* newgroup) { if (pOperator->status == OP_EXEC_DONE) { return NULL; } @@ -6247,46 +6233,63 @@ static int32_t getTableScanOrder(STableScanInfo* pTableScanInfo) { } // this is a blocking operator -static SSDataBlock* doAggregate(void* param, bool* newgroup) { - SOperatorInfo* pOperator = (SOperatorInfo*) param; - if (pOperator->status == OP_EXEC_DONE) { - return NULL; +static int32_t doOpenAggregateOptr(SOperatorInfo *pOperator) { + if (OPTR_IS_OPENED(pOperator)) { + return TSDB_CODE_SUCCESS; } SAggOperatorInfo* pAggInfo = pOperator->info; - SOptrBasicInfo* pInfo = &pAggInfo->binfo; + SOptrBasicInfo* pInfo = &pAggInfo->binfo; - int32_t order = TSDB_ORDER_ASC; + int32_t order = TSDB_ORDER_ASC; SOperatorInfo* downstream = pOperator->pDownstream[0]; - while(1) { + bool newgroup = true; + while (1) { publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC); - SSDataBlock* pBlock = downstream->getNextFn(downstream, newgroup); + SSDataBlock* pBlock = downstream->getNextFn(downstream, &newgroup); publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC); if (pBlock == NULL) { break; } -// if (pAggInfo->current != NULL) { -// setTagValue(pOperator, pAggInfo->current->pTable, pInfo->pCtx, pOperator->numOfOutput); -// } + // if (pAggInfo->current != NULL) { + // setTagValue(pOperator, pAggInfo->current->pTable, pInfo->pCtx, pOperator->numOfOutput); + // } // the pDataBlock are always the same one, no need to call this again setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order); doAggregateImpl(pOperator, 0, pInfo->pCtx); } - doSetOperatorCompleted(pOperator); - finalizeQueryResult(pOperator, pInfo->pCtx, &pInfo->resultRowInfo, pInfo->rowCellInfoOffset); + + OPTR_SET_OPENED(pOperator); + return TSDB_CODE_SUCCESS; +} + +static SSDataBlock* getAggregateResult(SOperatorInfo *pOperator, bool* newgroup) { + SAggOperatorInfo *pAggInfo = pOperator->info; + SOptrBasicInfo* pInfo = &pAggInfo->binfo; + + if (pOperator->status == OP_EXEC_DONE) { + return NULL; + } + + SExecTaskInfo *pTaskInfo = pOperator->pTaskInfo; + pTaskInfo->code = pOperator->_openFn(pOperator); + if (pTaskInfo->code != TSDB_CODE_SUCCESS) { + return NULL; + } + getNumOfResult(pInfo->pCtx, pOperator->numOfOutput, pInfo->pRes); + doSetOperatorCompleted(pOperator); return (blockDataGetNumOfRows(pInfo->pRes) != 0)? pInfo->pRes:NULL; } -static SSDataBlock* doMultiTableAggregate(void* param, bool* newgroup) { - SOperatorInfo* pOperator = (SOperatorInfo*) param; +static SSDataBlock* doMultiTableAggregate(SOperatorInfo *pOperator, bool* newgroup) { if (pOperator->status == OP_EXEC_DONE) { return NULL; } @@ -6354,9 +6357,7 @@ static SSDataBlock* doMultiTableAggregate(void* param, bool* newgroup) { return pInfo->pRes; } -static SSDataBlock* doProjectOperation(void* param, bool* newgroup) { - SOperatorInfo* pOperator = (SOperatorInfo*) param; - +static SSDataBlock* doProjectOperation(SOperatorInfo *pOperator, bool* newgroup) { SProjectOperatorInfo* pProjectInfo = pOperator->info; STaskRuntimeEnv* pRuntimeEnv = pOperator->pRuntimeEnv; SOptrBasicInfo *pInfo = &pProjectInfo->binfo; @@ -6443,8 +6444,7 @@ static SSDataBlock* doProjectOperation(void* param, bool* newgroup) { return (pInfo->pRes->info.rows > 0)? pInfo->pRes:NULL; } -static SSDataBlock* doLimit(void* param, bool* newgroup) { - SOperatorInfo* pOperator = (SOperatorInfo*)param; +static SSDataBlock* doLimit(SOperatorInfo *pOperator, bool* newgroup) { if (pOperator->status == OP_EXEC_DONE) { return NULL; } @@ -6526,8 +6526,7 @@ static SSDataBlock* doFilter(void* param, bool* newgroup) { return NULL; } -static SSDataBlock* doIntervalAgg(void* param, bool* newgroup) { - SOperatorInfo* pOperator = (SOperatorInfo*) param; +static SSDataBlock* doIntervalAgg(SOperatorInfo *pOperator, bool* newgroup) { if (pOperator->status == OP_EXEC_DONE) { return NULL; } @@ -6582,8 +6581,7 @@ static SSDataBlock* doIntervalAgg(void* param, bool* newgroup) { return pInfo->binfo.pRes->info.rows == 0? NULL:pInfo->binfo.pRes; } -static SSDataBlock* doAllIntervalAgg(void* param, bool* newgroup) { - SOperatorInfo* pOperator = (SOperatorInfo*) param; +static SSDataBlock* doAllIntervalAgg(SOperatorInfo *pOperator, bool* newgroup) { if (pOperator->status == OP_EXEC_DONE) { return NULL; } @@ -6642,8 +6640,7 @@ static SSDataBlock* doAllIntervalAgg(void* param, bool* newgroup) { return pIntervalInfo->binfo.pRes->info.rows == 0? NULL:pIntervalInfo->binfo.pRes; } -static SSDataBlock* doSTableIntervalAgg(void* param, bool* newgroup) { - SOperatorInfo* pOperator = (SOperatorInfo*) param; +static SSDataBlock* doSTableIntervalAgg(SOperatorInfo *pOperator, bool* newgroup) { if (pOperator->status == OP_EXEC_DONE) { return NULL; } @@ -6702,8 +6699,7 @@ static SSDataBlock* doSTableIntervalAgg(void* param, bool* newgroup) { return pIntervalInfo->binfo.pRes; } -static SSDataBlock* doAllSTableIntervalAgg(void* param, bool* newgroup) { - SOperatorInfo* pOperator = (SOperatorInfo*) param; +static SSDataBlock* doAllSTableIntervalAgg(SOperatorInfo *pOperator, bool* newgroup) { if (pOperator->status == OP_EXEC_DONE) { return NULL; } @@ -6836,8 +6832,7 @@ static void doStateWindowAggImpl(SOperatorInfo* pOperator, SStateWindowOperatorI // pSDataBlock->info.rows, pOperator->numOfOutput); } -static SSDataBlock* doStateWindowAgg(void *param, bool* newgroup) { - SOperatorInfo* pOperator = (SOperatorInfo*) param; +static SSDataBlock* doStateWindowAgg(SOperatorInfo *pOperator, bool* newgroup) { if (pOperator->status == OP_EXEC_DONE) { return NULL; } @@ -6894,8 +6889,7 @@ static SSDataBlock* doStateWindowAgg(void *param, bool* newgroup) { return pBInfo->pRes->info.rows == 0? NULL:pBInfo->pRes; } -static SSDataBlock* doSessionWindowAgg(void* param, bool* newgroup) { - SOperatorInfo* pOperator = (SOperatorInfo*) param; +static SSDataBlock* doSessionWindowAgg(SOperatorInfo *pOperator, bool* newgroup) { if (pOperator->status == OP_EXEC_DONE) { return NULL; } @@ -6954,8 +6948,7 @@ static SSDataBlock* doSessionWindowAgg(void* param, bool* newgroup) { return pBInfo->pRes->info.rows == 0? NULL:pBInfo->pRes; } -static SSDataBlock* hashGroupbyAggregate(void* param, bool* newgroup) { - SOperatorInfo* pOperator = (SOperatorInfo*) param; +static SSDataBlock* hashGroupbyAggregate(SOperatorInfo *pOperator, bool* newgroup) { if (pOperator->status == OP_EXEC_DONE) { return NULL; } @@ -7044,9 +7037,7 @@ static void doHandleRemainBlockFromNewGroup(SFillOperatorInfo *pInfo, STaskRunti } } -static SSDataBlock* doFill(void* param, bool* newgroup) { - SOperatorInfo* pOperator = (SOperatorInfo*) param; - +static SSDataBlock* doFill(SOperatorInfo *pOperator, bool* newgroup) { SFillOperatorInfo *pInfo = pOperator->info; pInfo->pRes->info.rows = 0; @@ -7225,7 +7216,8 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SArray* pE pOperator->numOfOutput = taosArrayGetSize(pExprInfo); pOperator->pTaskInfo = pTaskInfo; - pOperator->getNextFn = doAggregate; + pOperator->_openFn = doOpenAggregateOptr; + pOperator->getNextFn = getAggregateResult; pOperator->closeFn = destroyAggOperatorInfo; int32_t code = appendDownstream(pOperator, &downstream, 1); @@ -7364,7 +7356,7 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SArray* pExp SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); pOperator->name = "ProjectOperator"; - // pOperator->operatorType = OP_Project; + pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_PROJECT; pOperator->blockingOptr = false; pOperator->status = OP_NOT_OPENED; pOperator->info = pInfo; @@ -7704,7 +7696,7 @@ SOperatorInfo* createSLimitOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorI return pOperator; } -static SSDataBlock* doTagScan(void* param, bool* newgroup) { +static SSDataBlock* doTagScan(SOperatorInfo *pOperator, bool* newgroup) { #if 0 SOperatorInfo* pOperator = (SOperatorInfo*) param; if (pOperator->status == OP_EXEC_DONE) { @@ -7909,8 +7901,7 @@ static void buildMultiDistinctKey(SDistinctOperatorInfo *pInfo, SSDataBlock *pBl } } -static SSDataBlock* hashDistinct(void* param, bool* newgroup) { - SOperatorInfo* pOperator = (SOperatorInfo*) param; +static SSDataBlock* hashDistinct(SOperatorInfo *pOperator, bool* newgroup) { if (pOperator->status == OP_EXEC_DONE) { return NULL; } From 0271413aff518d7c33ce1ec360973219f1b8f41a Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Sat, 12 Mar 2022 22:59:12 +0800 Subject: [PATCH 02/38] [td-13039] refactor. --- include/libs/function/function.h | 11 - source/libs/executor/inc/executorimpl.h | 19 +- source/libs/executor/src/executorimpl.c | 209 +++++----- source/libs/executor/test/executorTests.cpp | 6 +- source/libs/function/inc/taggfunction.h | 12 - source/libs/function/src/tfunction.c | 415 -------------------- 6 files changed, 115 insertions(+), 557 deletions(-) delete mode 100644 source/libs/function/src/tfunction.c diff --git a/include/libs/function/function.h b/include/libs/function/function.h index c01e267c42..1abdca465e 100644 --- a/include/libs/function/function.h +++ b/include/libs/function/function.h @@ -295,19 +295,8 @@ typedef struct SMultiFunctionsDesc { int32_t getResultDataInfo(int32_t dataType, int32_t dataBytes, int32_t functionId, int32_t param, SResultDataInfo* pInfo, int16_t extLength, bool isSuperTable); -/** - * If the given name is a valid built-in sql function, the value of true will be returned. - * @param name - * @param len - * @return - */ -int32_t qIsBuiltinFunction(const char* name, int32_t len, bool* scalarFunction); - bool qIsValidUdf(SArray* pUdfInfo, const char* name, int32_t len, int32_t* functionId); -bool qIsAggregateFunction(const char* functionName); -bool qIsSelectivityFunction(const char* functionName); - tExprNode* exprTreeFromBinary(const void* data, size_t size); void extractFunctionDesc(SArray* pFunctionIdList, SMultiFunctionsDesc* pDesc); diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 5368b2397a..e8a11f8c1c 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -328,7 +328,7 @@ typedef struct SOperatorInfo { char* name; // name, used to show the query execution plan void* info; // extension attribution SExprInfo* pExpr; - STaskRuntimeEnv* pRuntimeEnv; // todo remove it + STaskRuntimeEnv* pRuntimeEnv; // todo remove it SExecTaskInfo* pTaskInfo; SOperatorCostInfo cost; @@ -515,7 +515,9 @@ typedef struct SAggOperatorInfo { typedef struct SProjectOperatorInfo { SOptrBasicInfo binfo; - SSDataBlock* existDataBlock; + SSDataBlock *existDataBlock; + int32_t threshold; + bool hasVarCol; } SProjectOperatorInfo; typedef struct SLimitOperatorInfo { @@ -646,16 +648,17 @@ SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfOutput, int32_t repeatTime, int32_t reverseTime, SExecTaskInfo* pTaskInfo); SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv); -SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SArray* pExprInfo, SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo); -SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SArray* pExprInfo, SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo); -SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SArray* pExprInfo, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createOrderOperatorInfo(SOperatorInfo* downstream, SArray* pExprInfo, SArray* pOrderVal, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t numOfDownstream, SArray* pExprInfo, SArray* pOrderVal, SArray* pGroupInfo, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, + SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo); +SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo); +SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t num, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo); +SOperatorInfo *createOrderOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SArray* pOrderVal, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t numOfDownstream, SExprInfo* pExprInfo, int32_t num, SArray* pOrderVal, SArray* pGroupInfo, SExecTaskInfo* pTaskInfo); SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, const SArray* pExprInfo, const SSchema* pSchema, int32_t tableType, SEpSet epset, SExecTaskInfo* pTaskInfo); SOperatorInfo* createLimitOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream); -SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SArray* pExprInfo, SInterval* pInterval, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SInterval* pInterval, SExecTaskInfo* pTaskInfo); SOperatorInfo* createLimitOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index f472d1e00c..04047c3b7c 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -1235,26 +1235,15 @@ static void doAggregateImpl(SOperatorInfo* pOperator, TSKEY startTs, SqlFunction } } -static void projectApplyFunctions(STaskRuntimeEnv *pRuntimeEnv, SqlFunctionCtx *pCtx, int32_t numOfOutput) { - STaskAttr *pQueryAttr = pRuntimeEnv->pQueryAttr; - +static void projectApplyFunctions(SqlFunctionCtx *pCtx, int32_t numOfOutput) { for (int32_t k = 0; k < numOfOutput; ++k) { - pCtx[k].startTs = pQueryAttr->window.skey; - // Always set the asc order for merge stage process if (pCtx[k].currentStage == MERGE_STAGE) { pCtx[k].order = TSDB_ORDER_ASC; } - - pCtx[k].startTs = pQueryAttr->window.skey; - - if (pCtx[k].functionId < 0) { - // load the script and exec -// SUdfInfo* pUdfInfo = pRuntimeEnv->pUdfInfo; -// doInvokeUdf(pUdfInfo, &pCtx[k], 0, TSDB_UDF_FUNC_NORMAL); -// } else { +// pCtx[k].fpSet.process(&pCtx[k]); // aAggs[pCtx[k].functionId].xFunction(&pCtx[k]); - } +// } } } @@ -2040,9 +2029,7 @@ static SqlFunctionCtx* createSqlFunctionCtx(STaskRuntimeEnv* pRuntimeEnv, SExprI return pFuncCtx; } -static SqlFunctionCtx* createSqlFunctionCtx_rv(SArray* pExprInfo, int32_t** rowCellInfoOffset) { - size_t numOfOutput = taosArrayGetSize(pExprInfo); - +static SqlFunctionCtx* createSqlFunctionCtx_rv(SExprInfo* pExprInfo, int32_t numOfOutput, int32_t** rowCellInfoOffset) { SqlFunctionCtx * pFuncCtx = (SqlFunctionCtx *)calloc(numOfOutput, sizeof(SqlFunctionCtx)); if (pFuncCtx == NULL) { return NULL; @@ -2055,7 +2042,7 @@ static SqlFunctionCtx* createSqlFunctionCtx_rv(SArray* pExprInfo, int32_t** rowC } for (int32_t i = 0; i < numOfOutput; ++i) { - SExprInfo* pExpr = taosArrayGetP(pExprInfo, i); + SExprInfo* pExpr = &pExprInfo[i]; SExprBasicInfo *pFunct = &pExpr->base; SqlFunctionCtx* pCtx = &pFuncCtx[i]; @@ -3411,11 +3398,11 @@ void copyTsColoum(SSDataBlock* pRes, SqlFunctionCtx* pCtx, int32_t numOfOutput) int32_t functionId = pCtx[i].functionId; if (functionId == FUNCTION_DIFF || functionId == FUNCTION_DERIVATIVE) { needCopyTs = true; - if (i > 0 && pCtx[i-1].functionId == FUNCTION_TS_DUMMY){ + if (i > 0 && pCtx[i-1].functionId == FUNCTION_TS_DUMMY) { SColumnInfoData* pColRes = taosArrayGet(pRes->pDataBlock, i - 1); // find ts data src = pColRes->pData; } - }else if(functionId == FUNCTION_TS_DUMMY) { + } else if(functionId == FUNCTION_TS_DUMMY) { tsNum++; } } @@ -6011,7 +5998,7 @@ static SSDataBlock* doSortedMerge(SOperatorInfo *pOperator, bool* newgroup) { return doMerge(pOperator); } -static SArray* createBlockOrder(SArray* pExprInfo, SArray* pOrderVal) { +static SArray* createBlockOrder(SExprInfo* pExprInfo, int32_t numOfCols, SArray* pOrderVal) { SArray* pOrderInfo = taosArrayInit(1, sizeof(SBlockOrderInfo)); size_t numOfOrder = taosArrayGetSize(pOrderVal); @@ -6020,8 +6007,8 @@ static SArray* createBlockOrder(SArray* pExprInfo, SArray* pOrderVal) { SOrder* pOrder = taosArrayGet(pOrderVal, j); orderInfo.order = pOrder->order; - for (int32_t i = 0; i < taosArrayGetSize(pExprInfo); ++i) { - SExprInfo* pExpr = taosArrayGet(pExprInfo, i); + for (int32_t i = 0; i < numOfCols; ++i) { + SExprInfo* pExpr = &pExprInfo[i]; if (pExpr->base.resSchema.colId == pOrder->col.colId) { orderInfo.colIndex = i; break; @@ -6034,7 +6021,7 @@ static SArray* createBlockOrder(SArray* pExprInfo, SArray* pOrderVal) { return pOrderInfo; } -static int32_t initGroupCol(SArray* pExprInfo, SArray* pGroupInfo, SSortedMergeOperatorInfo* pInfo) { +static int32_t initGroupCol(SExprInfo* pExprInfo, int32_t numOfCols, SArray* pGroupInfo, SSortedMergeOperatorInfo* pInfo) { if (pGroupInfo == NULL || taosArrayGetSize(pGroupInfo) == 0) { return 0; } @@ -6050,8 +6037,8 @@ static int32_t initGroupCol(SArray* pExprInfo, SArray* pGroupInfo, SSortedMergeO size_t numOfGroupCol = taosArrayGetSize(pInfo->groupInfo); for(int32_t i = 0; i < numOfGroupCol; ++i) { SColumn* pCol = taosArrayGet(pGroupInfo, i); - for(int32_t j = 0; j < taosArrayGetSize(pExprInfo); ++j) { - SExprInfo* pe = taosArrayGet(pExprInfo, j); + for(int32_t j = 0; j < numOfCols; ++j) { + SExprInfo* pe = &pExprInfo[j]; if (pe->base.resSchema.colId == pCol->colId) { taosArrayPush(plist, pCol); taosArrayPush(pInfo->groupInfo, &j); @@ -6082,29 +6069,27 @@ static int32_t initGroupCol(SArray* pExprInfo, SArray* pGroupInfo, SSortedMergeO return TSDB_CODE_SUCCESS; } -SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t numOfDownstream, SArray* pExprInfo, SArray* pOrderVal, SArray* pGroupInfo, SExecTaskInfo* pTaskInfo) { +SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t numOfDownstream, SExprInfo* pExprInfo, int32_t num, SArray* pOrderVal, SArray* pGroupInfo, SExecTaskInfo* pTaskInfo) { SSortedMergeOperatorInfo* pInfo = calloc(1, sizeof(SSortedMergeOperatorInfo)); SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { goto _error; } - int32_t numOfOutput = taosArrayGetSize(pExprInfo); - pInfo->binfo.pCtx = createSqlFunctionCtx_rv(pExprInfo, &pInfo->binfo.rowCellInfoOffset); - pInfo->binfo.pRes = createOutputBuf_rv(pExprInfo, pInfo->binfo.capacity); + pInfo->binfo.pCtx = createSqlFunctionCtx_rv(pExprInfo, num, &pInfo->binfo.rowCellInfoOffset); initResultRowInfo(&pInfo->binfo.resultRowInfo, (int32_t)1); if (pInfo->binfo.pCtx == NULL || pInfo->binfo.pRes == NULL) { goto _error; } - int32_t code = doInitAggInfoSup(&pInfo->aggSup, pInfo->binfo.pCtx, numOfOutput); + int32_t code = doInitAggInfoSup(&pInfo->aggSup, pInfo->binfo.pCtx, num); if (code != TSDB_CODE_SUCCESS) { goto _error; } setFunctionResultOutput(&pInfo->binfo, &pInfo->aggSup, MAIN_SCAN, pTaskInfo); - code = initGroupCol(pExprInfo, pGroupInfo, pInfo); + code = initGroupCol(pExprInfo, num, pGroupInfo, pInfo); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -6113,7 +6098,7 @@ SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t // pRuntimeEnv->pQueryAttr->topBotQuery, false)); pInfo->sortBufSize = 1024 * 16; // 1MB pInfo->bufPageSize = 1024; - pInfo->orderInfo = createBlockOrder(pExprInfo, pOrderVal); + pInfo->orderInfo = createBlockOrder(pExprInfo, num, pOrderVal); pInfo->binfo.capacity = blockDataGetCapacityInRow(pInfo->binfo.pRes, pInfo->bufPageSize); @@ -6122,12 +6107,12 @@ SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t pOperator->blockingOptr = true; pOperator->status = OP_NOT_OPENED; pOperator->info = pInfo; - pOperator->numOfOutput = numOfOutput; - pOperator->pExpr = exprArrayDup(pExprInfo); + pOperator->numOfOutput = num; + pOperator->pExpr = pExprInfo; pOperator->pTaskInfo = pTaskInfo; - pOperator->getNextFn = doSortedMerge; - pOperator->closeFn = destroySortedMergeOperatorInfo; + pOperator->getNextFn = doSortedMerge; + pOperator->closeFn = destroySortedMergeOperatorInfo; code = appendDownstream(pOperator, downstream, numOfDownstream); if (code != TSDB_CODE_SUCCESS) { @@ -6138,7 +6123,7 @@ SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t _error: if (pInfo != NULL) { - destroySortedMergeOperatorInfo(pInfo, numOfOutput); + destroySortedMergeOperatorInfo(pInfo, num); } tfree(pInfo); @@ -6180,7 +6165,7 @@ static SSDataBlock* doSort(SOperatorInfo *pOperator, bool* newgroup) { return getSortedBlockData(pInfo->pSortHandle, pInfo->pDataBlock, pInfo->hasVarCol, pInfo->numOfRowsInRes); } -SOperatorInfo *createOrderOperatorInfo(SOperatorInfo* downstream, SArray* pExprInfo, SArray* pOrderVal, SExecTaskInfo* pTaskInfo) { +SOperatorInfo *createOrderOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SArray* pOrderVal, SExecTaskInfo* pTaskInfo) { SOrderOperatorInfo* pInfo = calloc(1, sizeof(SOrderOperatorInfo)); SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { @@ -6194,12 +6179,10 @@ SOperatorInfo *createOrderOperatorInfo(SOperatorInfo* downstream, SArray* pExprI pInfo->bufPageSize = 1024; pInfo->numOfRowsInRes = 1024; - pInfo->pDataBlock = createOutputBuf_rv(pExprInfo, pInfo->numOfRowsInRes); - pInfo->orderInfo = createBlockOrder(pExprInfo, pOrderVal); + pInfo->orderInfo = createBlockOrder(pExprInfo, numOfCols, pOrderVal); - for(int32_t i = 0; i < taosArrayGetSize(pExprInfo); ++i) { - SExprInfo* pExpr = taosArrayGetP(pExprInfo, i); - if (IS_VAR_DATA_TYPE(pExpr->base.resSchema.type)) { + for(int32_t i = 0; i < numOfCols; ++i) { + if (IS_VAR_DATA_TYPE(pExprInfo[i].base.resSchema.type)) { pInfo->hasVarCol = true; break; } @@ -6207,7 +6190,7 @@ SOperatorInfo *createOrderOperatorInfo(SOperatorInfo* downstream, SArray* pExprI if (pInfo->orderInfo == NULL || pInfo->pDataBlock == NULL) { tfree(pOperator); - destroyOrderOperatorInfo(pInfo, taosArrayGetSize(pExprInfo)); + destroyOrderOperatorInfo(pInfo, numOfCols); tfree(pInfo); terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; @@ -6359,51 +6342,48 @@ static SSDataBlock* doMultiTableAggregate(SOperatorInfo *pOperator, bool* newgro static SSDataBlock* doProjectOperation(SOperatorInfo *pOperator, bool* newgroup) { SProjectOperatorInfo* pProjectInfo = pOperator->info; - STaskRuntimeEnv* pRuntimeEnv = pOperator->pRuntimeEnv; SOptrBasicInfo *pInfo = &pProjectInfo->binfo; SSDataBlock* pRes = pInfo->pRes; - int32_t order = pRuntimeEnv->pQueryAttr->order.order; - - pRes->info.rows = 0; + blockDataClearup(pRes, pProjectInfo->hasVarCol); if (pProjectInfo->existDataBlock) { // TODO refactor - STableQueryInfo* pTableQueryInfo = pRuntimeEnv->current; - +// STableQueryInfo* pTableQueryInfo = pRuntimeEnv->current; SSDataBlock* pBlock = pProjectInfo->existDataBlock; pProjectInfo->existDataBlock = NULL; *newgroup = true; // todo dynamic set tags - if (pTableQueryInfo != NULL) { +// if (pTableQueryInfo != NULL) { // setTagValue(pOperator, pTableQueryInfo->pTable, pInfo->pCtx, pOperator->numOfOutput); - } +// } // the pDataBlock are always the same one, no need to call this again - setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order); + setInputDataBlock(pOperator, pInfo->pCtx, pBlock, TSDB_ORDER_ASC); updateOutputBuf(pInfo, &pInfo->capacity, pBlock->info.rows); - projectApplyFunctions(pRuntimeEnv, pInfo->pCtx, pOperator->numOfOutput); + projectApplyFunctions(pInfo->pCtx, pOperator->numOfOutput); pRes->info.rows = getNumOfResult(pInfo->pCtx, pOperator->numOfOutput, NULL); - if (pRes->info.rows >= pRuntimeEnv->resultInfo.threshold) { + if (pRes->info.rows >= pProjectInfo->threshold) { copyTsColoum(pRes, pInfo->pCtx, pOperator->numOfOutput); resetResultRowEntryResult(pInfo->pCtx, pOperator->numOfOutput); return pRes; } } + SOperatorInfo* downstream = pOperator->pDownstream[0]; + while(1) { bool prevVal = *newgroup; // The downstream exec may change the value of the newgroup, so use a local variable instead. - publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_BEFORE_OPERATOR_EXEC); - SSDataBlock* pBlock = pOperator->pDownstream[0]->getNextFn(pOperator->pDownstream[0], newgroup); - publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_AFTER_OPERATOR_EXEC); + publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC); + SSDataBlock* pBlock = downstream->getNextFn(downstream, newgroup); + publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC); if (pBlock == NULL) { assert(*newgroup == false); - *newgroup = prevVal; setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED); break; @@ -6422,25 +6402,26 @@ static SSDataBlock* doProjectOperation(SOperatorInfo *pOperator, bool* newgroup) } } - STableQueryInfo* pTableQueryInfo = pRuntimeEnv->current; - // todo dynamic set tags - if (pTableQueryInfo != NULL) { -// setTagValue(pOperator, pTableQueryInfo->pTable, pInfo->pCtx, pOperator->numOfOutput); - } + + // STableQueryInfo* pTableQueryInfo = pRuntimeEnv->current; + // if (pTableQueryInfo != NULL) { + // setTagValue(pOperator, pTableQueryInfo->pTable, pInfo->pCtx, pOperator->numOfOutput); + // } // the pDataBlock are always the same one, no need to call this again - setInputDataBlock(pOperator, pInfo->pCtx, pBlock, order); + setInputDataBlock(pOperator, pInfo->pCtx, pBlock, TSDB_ORDER_ASC); updateOutputBuf(pInfo, &pInfo->capacity, pBlock->info.rows); - projectApplyFunctions(pRuntimeEnv, pInfo->pCtx, pOperator->numOfOutput); - pRes->info.rows = getNumOfResult(pInfo->pCtx, pOperator->numOfOutput, NULL); - if (pRes->info.rows >= 1000/*pRuntimeEnv->resultInfo.threshold*/) { + projectApplyFunctions(pInfo->pCtx, pOperator->numOfOutput); +// pRes->info.rows = getNumOfResult(pInfo->pCtx, pOperator->numOfOutput, pRes); + if (pRes->info.rows >= pProjectInfo->threshold) { break; } } + copyTsColoum(pRes, pInfo->pCtx, pOperator->numOfOutput); - resetResultRowEntryResult(pInfo->pCtx, pOperator->numOfOutput); +// resetResultRowEntryResult(pInfo->pCtx, pOperator->numOfOutput); return (pInfo->pRes->info.rows > 0)? pInfo->pRes:NULL; } @@ -7169,12 +7150,12 @@ static void clearupAggSup(SAggSupporter* pAggSup) { destroyResultRowPool(pAggSup->pool); } -static int32_t initAggInfo(SAggOperatorInfo* pInfo, SArray* pExprInfo, int32_t numOfRows, SSDataBlock* pResultBlock, const STableGroupInfo* pTableGroupInfo) { - pInfo->binfo.pCtx = createSqlFunctionCtx_rv(pExprInfo, &pInfo->binfo.rowCellInfoOffset); +static int32_t initAggInfo(SAggOperatorInfo* pInfo, SExprInfo* pExprInfo, int32_t numOfCols, int32_t numOfRows, SSDataBlock* pResultBlock, const STableGroupInfo* pTableGroupInfo) { + pInfo->binfo.pCtx = createSqlFunctionCtx_rv(pExprInfo, numOfCols, &pInfo->binfo.rowCellInfoOffset); pInfo->binfo.pRes = pResultBlock; pInfo->binfo.capacity = numOfRows; - doInitAggInfoSup(&pInfo->aggSup, pInfo->binfo.pCtx, taosArrayGetSize(pExprInfo)); + doInitAggInfoSup(&pInfo->aggSup, pInfo->binfo.pCtx, numOfCols); pInfo->pTableQueryInfo = calloc(pTableGroupInfo->numOfTables, sizeof(STableQueryInfo)); int32_t index = 0; @@ -7196,14 +7177,14 @@ static int32_t initAggInfo(SAggOperatorInfo* pInfo, SArray* pExprInfo, int32_t n return TSDB_CODE_SUCCESS; } -SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SArray* pExprInfo, SSDataBlock* pResultBlock, +SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo) { SAggOperatorInfo* pInfo = calloc(1, sizeof(SAggOperatorInfo)); int32_t numOfRows = 1; //(int32_t)(getRowNumForMultioutput(pQueryAttr, pQueryAttr->topBotQuery, pQueryAttr->stableQuery)); - initAggInfo(pInfo, pExprInfo, numOfRows, pResultBlock, pTableGroupInfo); + initAggInfo(pInfo, pExprInfo, numOfCols, numOfRows, pResultBlock, pTableGroupInfo); setFunctionResultOutput(&pInfo->binfo, &pInfo->aggSup, MAIN_SCAN, pTaskInfo); SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); @@ -7212,8 +7193,8 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SArray* pE pOperator->blockingOptr = true; pOperator->status = OP_NOT_OPENED; pOperator->info = pInfo; - pOperator->pExpr = exprArrayDup(pExprInfo); - pOperator->numOfOutput = taosArrayGetSize(pExprInfo); + pOperator->pExpr = pExprInfo; + pOperator->numOfOutput = numOfCols; pOperator->pTaskInfo = pTaskInfo; pOperator->_openFn = doOpenAggregateOptr; @@ -7317,12 +7298,11 @@ void destroyExchangeOperatorInfo(void* param, int32_t numOfOutput) { tsem_destroy(&pExInfo->ready); } -SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SArray* pExprInfo, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo) { +SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo) { SAggOperatorInfo* pInfo = calloc(1, sizeof(SAggOperatorInfo)); int32_t numOfRows = 1; - size_t numOfOutput = taosArrayGetSize(pExprInfo); - initAggInfo(pInfo, pExprInfo, numOfRows, pResBlock, pTableGroupInfo); + initAggInfo(pInfo, pExprInfo, numOfCols, numOfRows, pResBlock, pTableGroupInfo); size_t tableGroup = taosArrayGetSize(pTableGroupInfo->pGroupList); initResultRowInfo(&pInfo->binfo.resultRowInfo, (int32_t)tableGroup); @@ -7333,8 +7313,8 @@ SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SArray pOperator->blockingOptr = true; pOperator->status = OP_NOT_OPENED; pOperator->info = pInfo; - pOperator->pExpr = exprArrayDup(pExprInfo); - pOperator->numOfOutput = numOfOutput; + pOperator->pExpr = pExprInfo; + pOperator->numOfOutput = numOfCols; pOperator->pTaskInfo = pTaskInfo; pOperator->getNextFn = doMultiTableAggregate; @@ -7344,12 +7324,11 @@ SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SArray return pOperator; } -SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SArray* pExprInfo, SExecTaskInfo* pTaskInfo) { +SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t num, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo) { SProjectOperatorInfo* pInfo = calloc(1, sizeof(SProjectOperatorInfo)); - int32_t numOfRows = 4096; - pInfo->binfo.pRes = createOutputBuf_rv(pExprInfo, numOfRows); - pInfo->binfo.pCtx = createSqlFunctionCtx_rv(pExprInfo, &pInfo->binfo.rowCellInfoOffset); + pInfo->binfo.pRes = pResBlock; + pInfo->binfo.pCtx = createSqlFunctionCtx_rv(pExprInfo, num, &pInfo->binfo.rowCellInfoOffset); // initResultRowInfo(&pBInfo->resultRowInfo, 8); // setFunctionResultOutput(pBInfo, MAIN_SCAN); @@ -7360,11 +7339,14 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SArray* pExp pOperator->blockingOptr = false; pOperator->status = OP_NOT_OPENED; pOperator->info = pInfo; - pOperator->pExpr = exprArrayDup(pExprInfo); - pOperator->numOfOutput = taosArrayGetSize(pExprInfo); + pOperator->pExpr = pExprInfo; + pOperator->numOfOutput = num; - pOperator->getNextFn = doProjectOperation; + pOperator->_openFn = operatorDummyOpenFn; + pOperator->getNextFn = doProjectOperation; pOperator->closeFn = destroyProjectOperatorInfo; + + pOperator->pTaskInfo = pTaskInfo; int32_t code = appendDownstream(pOperator, &downstream, 1); return pOperator; @@ -7421,11 +7403,10 @@ SOperatorInfo* createLimitOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorIn return pOperator; } -SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SArray* pExprInfo, SInterval* pInterval, SExecTaskInfo* pTaskInfo) { +SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SInterval* pInterval, SExecTaskInfo* pTaskInfo) { STableIntervalOperatorInfo* pInfo = calloc(1, sizeof(STableIntervalOperatorInfo)); - size_t numOfOutput = taosArrayGetSize(pExprInfo); - doInitAggInfoSup(&pInfo->aggSup, pInfo->binfo.pCtx, numOfOutput); + doInitAggInfoSup(&pInfo->aggSup, pInfo->binfo.pCtx, numOfCols); pInfo->order = TSDB_ORDER_ASC; pInfo->precision = TSDB_TIME_PRECISION_MICRO; @@ -7434,8 +7415,7 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SArray* pEx int32_t code = createDiskbasedBuf(&pInfo->pResultBuf, 4096, 4096 * 256, pTaskInfo->id.str, "/tmp/"); - pInfo->binfo.pCtx = createSqlFunctionCtx_rv(pExprInfo, &pInfo->binfo.rowCellInfoOffset); - pInfo->binfo.pRes = createOutputBuf_rv(pExprInfo, pInfo->binfo.capacity); + pInfo->binfo.pCtx = createSqlFunctionCtx_rv(pExprInfo, numOfCols, &pInfo->binfo.rowCellInfoOffset); initResultRowInfo(&pInfo->binfo.resultRowInfo, (int32_t)1); @@ -7445,10 +7425,10 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SArray* pEx // pOperator->operatorType = OP_TimeWindow; pOperator->blockingOptr = true; pOperator->status = OP_NOT_OPENED; - pOperator->pExpr = exprArrayDup(pExprInfo); + pOperator->pExpr = pExprInfo; pOperator->pTaskInfo = pTaskInfo; - pOperator->numOfOutput = taosArrayGetSize(pExprInfo); + pOperator->numOfOutput = numOfCols; pOperator->info = pInfo; pOperator->getNextFn = doIntervalAgg; pOperator->closeFn = destroyBasicOperatorInfo; @@ -8104,12 +8084,14 @@ static SResSchema createResSchema(int32_t type, int32_t bytes, int32_t slotId, i return s; } -SArray* createExprInfo(SAggPhysiNode* pPhyNode) { - int32_t numOfAggFuncs = LIST_LENGTH(pPhyNode->pAggFuncs); +SExprInfo* createExprInfo(SNodeList* pNodeList, int32_t* numOfExprs) { + int32_t numOfFuncs = LIST_LENGTH(pNodeList); - SArray* pArray = taosArrayInit(numOfAggFuncs, POINTER_BYTES); - for(int32_t i = 0; i < numOfAggFuncs; ++i) { - SExprInfo* pExp = calloc(1, sizeof(SExprInfo)); + *numOfExprs = numOfFuncs; + SExprInfo* pExprs = calloc(numOfFuncs, sizeof(SExprInfo)); + + for(int32_t i = 0; i < numOfFuncs; ++i) { + SExprInfo* pExp = &pExprs[i]; pExp->pExpr = calloc(1, sizeof(tExprNode)); pExp->pExpr->_function.num = 1; @@ -8120,7 +8102,7 @@ SArray* createExprInfo(SAggPhysiNode* pPhyNode) { pExp->base.pParam[0].pCol = calloc(1, sizeof(SColumn)); SColumn* pCol = pExp->base.pParam[0].pCol; - STargetNode* pTargetNode = (STargetNode*) nodesListGetNode(pPhyNode->pAggFuncs, i); + STargetNode* pTargetNode = (STargetNode*) nodesListGetNode(pNodeList, i); ASSERT(pTargetNode->slotId == i); SFunctionNode* pFuncNode = (SFunctionNode*)pTargetNode->pExpr; @@ -8145,10 +8127,9 @@ SArray* createExprInfo(SAggPhysiNode* pPhyNode) { pCol->precision = pcn->node.resType.precision; pCol->dataBlockId = pcn->dataBlockId; } - taosArrayPush(pArray, &pExp); } - return pArray; + return pExprs; } static SExecTaskInfo* createExecTaskInfo(uint64_t queryId, uint64_t taskId) { @@ -8208,7 +8189,7 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa } } - if (QUERY_NODE_PHYSICAL_PLAN_AGG == nodeType(pPhyNode)) { + if (QUERY_NODE_PHYSICAL_PLAN_PROJECT == nodeType(pPhyNode)) { size_t size = LIST_LENGTH(pPhyNode->pChildren); assert(size == 1); @@ -8216,9 +8197,23 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, i); SOperatorInfo* op = doCreateOperatorTreeNode(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo); - SArray* pExprInfo = createExprInfo((SAggPhysiNode*)pPhyNode); + int32_t num = 0; + SExprInfo* pExprInfo = createExprInfo(((SProjectPhysiNode*)pPhyNode)->pProjections, &num); SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); - return createAggregateOperatorInfo(op, pExprInfo, pResBlock, pTaskInfo, pTableGroupInfo); + return createProjectOperatorInfo(op, pExprInfo, num, pResBlock, pTaskInfo); + } + } else if (QUERY_NODE_PHYSICAL_PLAN_AGG == nodeType(pPhyNode)) { + size_t size = LIST_LENGTH(pPhyNode->pChildren); + assert(size == 1); + + for (int32_t i = 0; i < size; ++i) { + SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, i); + SOperatorInfo* op = doCreateOperatorTreeNode(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo); + + int32_t num = 0; + SExprInfo* pExprInfo = createExprInfo(((SAggPhysiNode*)pPhyNode)->pAggFuncs, &num); + SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); + return createAggregateOperatorInfo(op, pExprInfo, num, pResBlock, pTaskInfo, pTableGroupInfo); } } /*else if (pPhyNode->info.type == OP_MultiTableAggregate) { size_t size = taosArrayGetSize(pPhyNode->pChildren); diff --git a/source/libs/executor/test/executorTests.cpp b/source/libs/executor/test/executorTests.cpp index cb42827198..eaaf710ee0 100644 --- a/source/libs/executor/test/executorTests.cpp +++ b/source/libs/executor/test/executorTests.cpp @@ -55,8 +55,7 @@ typedef struct SDummyInputInfo { SSDataBlock* pBlock; } SDummyInputInfo; -SSDataBlock* getDummyBlock(void* param, bool* newgroup) { - SOperatorInfo* pOperator = static_cast(param); +SSDataBlock* getDummyBlock(SOperatorInfo* pOperator, bool* newgroup) { SDummyInputInfo* pInfo = static_cast(pOperator->info); if (pInfo->current >= pInfo->totalPages) { return NULL; @@ -122,8 +121,7 @@ SSDataBlock* getDummyBlock(void* param, bool* newgroup) { return pBlock; } -SSDataBlock* get2ColsDummyBlock(void* param, bool* newgroup) { - SOperatorInfo* pOperator = static_cast(param); +SSDataBlock* get2ColsDummyBlock(SOperatorInfo* pOperator, bool* newgroup) { SDummyInputInfo* pInfo = static_cast(pOperator->info); if (pInfo->current >= pInfo->totalPages) { return NULL; diff --git a/source/libs/function/inc/taggfunction.h b/source/libs/function/inc/taggfunction.h index d71ff789ba..906d4f63fb 100644 --- a/source/libs/function/inc/taggfunction.h +++ b/source/libs/function/inc/taggfunction.h @@ -46,13 +46,6 @@ extern SAggFunctionInfo aggFunc[35]; #define DATA_SET_FLAG ',' // to denote the output area has data, not null value #define DATA_SET_FLAG_SIZE sizeof(DATA_SET_FLAG) -#define TOP_BOTTOM_QUERY_LIMIT 100 - -#define QUERY_IS_STABLE_QUERY(type) (((type)&TSDB_QUERY_TYPE_STABLE_QUERY) != 0) -#define QUERY_IS_JOIN_QUERY(type) (TSDB_QUERY_HAS_TYPE(type, TSDB_QUERY_TYPE_JOIN_QUERY)) -#define QUERY_IS_PROJECTION_QUERY(type) (((type)&TSDB_QUERY_TYPE_PROJECTION_QUERY) != 0) -#define QUERY_IS_FREE_RESOURCE(type) (((type)&TSDB_QUERY_TYPE_FREE_RESOURCE) != 0) - typedef struct SInterpInfoDetail { TSKEY ts; // interp specified timestamp int8_t type; @@ -61,9 +54,6 @@ typedef struct SInterpInfoDetail { #define GET_ROWCELL_INTERBUF(_c) ((void*) ((char*)(_c) + sizeof(SResultRowEntryInfo))) -#define IS_STREAM_QUERY_VALID(x) (((x)&TSDB_FUNCSTATE_STREAM) != 0) -#define IS_MULTIOUTPUT(x) (((x)&TSDB_FUNCSTATE_MO) != 0) - typedef struct STwaInfo { int8_t hasResult; // flag to denote has value double dOutput; @@ -71,8 +61,6 @@ typedef struct STwaInfo { STimeWindow win; } STwaInfo; -extern int32_t functionCompatList[]; // compatible check array list - bool topbot_datablock_filter(SqlFunctionCtx *pCtx, const char *minval, const char *maxval); /** diff --git a/source/libs/function/src/tfunction.c b/source/libs/function/src/tfunction.c deleted file mode 100644 index e302643c32..0000000000 --- a/source/libs/function/src/tfunction.c +++ /dev/null @@ -1,415 +0,0 @@ -#include "os.h" -#include "tarray.h" -#include "function.h" -#include "thash.h" -#include "taggfunction.h" - -static SHashObj* functionHashTable = NULL; -static SHashObj* udfHashTable = NULL; - -static void doInitFunctionHashTable() { - int numOfEntries = tListLen(aggFunc); - functionHashTable = taosHashInit(numOfEntries, MurmurHash3_32, false, false); - for (int32_t i = 0; i < numOfEntries; i++) { - int32_t len = (uint32_t)strlen(aggFunc[i].name); - - SAggFunctionInfo* ptr = &aggFunc[i]; - taosHashPut(functionHashTable, aggFunc[i].name, len, (void*)&ptr, POINTER_BYTES); - } - -/* - numOfEntries = tListLen(scalarFunc); - for(int32_t i = 0; i < numOfEntries; ++i) { - int32_t len = (int32_t) strlen(scalarFunc[i].name); - SScalarFunctionInfo* ptr = &scalarFunc[i]; - taosHashPut(functionHashTable, scalarFunc[i].name, len, (void*)&ptr, POINTER_BYTES); - } -*/ - - udfHashTable = taosHashInit(numOfEntries, MurmurHash3_32, true, true); -} - -static pthread_once_t functionHashTableInit = PTHREAD_ONCE_INIT; - -int32_t qIsBuiltinFunction(const char* name, int32_t len, bool* scalarFunction) { - pthread_once(&functionHashTableInit, doInitFunctionHashTable); - - SAggFunctionInfo** pInfo = taosHashGet(functionHashTable, name, len); - if (pInfo != NULL) { - *scalarFunction = ((*pInfo)->type == FUNCTION_TYPE_SCALAR); - return (*pInfo)->functionId; - } else { - return -1; - } -} - -bool qIsValidUdf(SArray* pUdfInfo, const char* name, int32_t len, int32_t* functionId) { - return true; -} - -bool qIsAggregateFunction(const char* functionName) { - assert(functionName != NULL); - bool scalarfunc = false; - qIsBuiltinFunction(functionName, strlen(functionName), &scalarfunc); - - return !scalarfunc; -} - -bool qIsSelectivityFunction(const char* functionName) { - assert(functionName != NULL); - pthread_once(&functionHashTableInit, doInitFunctionHashTable); - - size_t len = strlen(functionName); - SAggFunctionInfo** pInfo = taosHashGet(functionHashTable, functionName, len); - if (pInfo != NULL) { - return ((*pInfo)->status | FUNCSTATE_SELECTIVITY) != 0; - } - - return false; -} - -SAggFunctionInfo* qGetFunctionInfo(const char* name, int32_t len) { - pthread_once(&functionHashTableInit, doInitFunctionHashTable); - - SAggFunctionInfo** pInfo = taosHashGet(functionHashTable, name, len); - if (pInfo != NULL) { - return (*pInfo); - } else { - return NULL; - } -} - -void qAddUdfInfo(uint64_t id, SUdfInfo* pUdfInfo) { - int32_t len = (uint32_t)strlen(pUdfInfo->name); - taosHashPut(udfHashTable, pUdfInfo->name, len, (void*)&pUdfInfo, POINTER_BYTES); -} - -void qRemoveUdfInfo(uint64_t id, SUdfInfo* pUdfInfo) { - int32_t len = (uint32_t)strlen(pUdfInfo->name); - taosHashRemove(udfHashTable, pUdfInfo->name, len); -} - -bool isTagsQuery(SArray* pFunctionIdList) { - int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList); - for (int32_t i = 0; i < num; ++i) { - char* f = *(char**) taosArrayGet(pFunctionIdList, i); - - // todo handle count(tbname) query - if (strcmp(f, "project") != 0 && strcmp(f, "count") != 0) { - return false; - } - - // "select count(tbname)" query -// if (functId == FUNCTION_COUNT && pExpr->base.colpDesc->colId == TSDB_TBNAME_COLUMN_INDEX) { -// continue; -// } - } - - return true; -} - -//bool tscMultiRoundQuery(SArray* pFunctionIdList, int32_t index) { -// if (!UTIL_TABLE_IS_SUPER_TABLE(pQueryInfo->pTableMetaInfo[index])) { -// return false; -// } -// -// size_t numOfExprs = (int32_t) getNumOfExprs(pQueryInfo); -// for(int32_t i = 0; i < numOfExprs; ++i) { -// SExprInfo* pExpr = getExprInfo(pQueryInfo, i); -// if (pExpr->base.functionId == FUNCTION_STDDEV_DST) { -// return true; -// } -// } -// -// return false; -//} - -bool isProjectionQuery(SArray* pFunctionIdList) { - int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList); - for (int32_t i = 0; i < num; ++i) { - char* f = *(char**) taosArrayGet(pFunctionIdList, i); - if (strcmp(f, "project") == 0) { - return true; - } - } - - return false; -} - -bool isDiffDerivativeQuery(SArray* pFunctionIdList) { - int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList); - for (int32_t i = 0; i < num; ++i) { - int32_t f = *(int16_t*) taosArrayGet(pFunctionIdList, i); - if (f == FUNCTION_TS_DUMMY) { - continue; - } - - if (f == FUNCTION_DIFF || f == FUNCTION_DERIVATIVE) { - return true; - } - } - - return false; -} - -bool isInterpQuery(SArray* pFunctionIdList) { - int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList); - for (int32_t i = 0; i < num; ++i) { - int32_t f = *(int16_t*) taosArrayGet(pFunctionIdList, i); - if (f == FUNCTION_TAG || f == FUNCTION_TS) { - continue; - } - - if (f != FUNCTION_INTERP) { - return false; - } - } - - return true; -} - -bool isArithmeticQueryOnAggResult(SArray* pFunctionIdList) { - if (isProjectionQuery(pFunctionIdList)) { - return false; - } - - assert(0); - -// size_t numOfOutput = getNumOfFields(pQueryInfo); -// for(int32_t i = 0; i < numOfOutput; ++i) { -// SExprInfo* pExprInfo = tscFieldInfoGetInternalField(&pQueryInfo->fieldsInfo, i)->pExpr; -// if (pExprInfo->pExpr != NULL) { -// return true; -// } -// } - - return false; -} - -bool isGroupbyColumn(SGroupbyExpr* pGroupby) { - return !pGroupby->groupbyTag; -} - -bool isTopBotQuery(SArray* pFunctionIdList) { - int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList); - for (int32_t i = 0; i < num; ++i) { - char* f = *(char**) taosArrayGet(pFunctionIdList, i); - if (strcmp(f, "project") == 0) { - continue; - } - - if (strcmp(f, "top") == 0 || strcmp(f, "bottom") == 0) { - return true; - } - } - - return false; -} - -bool isTsCompQuery(SArray* pFunctionIdList) { - int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList); - if (num != 1) { - return false; - } - - int32_t f = *(int16_t*) taosArrayGet(pFunctionIdList, 0); - return f == FUNCTION_TS_COMP; -} - -bool isTWAQuery(SArray* pFunctionIdList) { - int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList); - for (int32_t i = 0; i < num; ++i) { - int32_t f = *(int16_t*) taosArrayGet(pFunctionIdList, i); - if (f == FUNCTION_TWA) { - return true; - } - } - - return false; -} - -bool isIrateQuery(SArray* pFunctionIdList) { - int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList); - for (int32_t i = 0; i < num; ++i) { - int32_t f = *(int16_t*) taosArrayGet(pFunctionIdList, i); - if (f == FUNCTION_IRATE) { - return true; - } - } - - return false; -} - -bool isStabledev(SArray* pFunctionIdList) { - int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList); - for (int32_t i = 0; i < num; ++i) { - int32_t f = *(int16_t*) taosArrayGet(pFunctionIdList, i); - if (f == FUNCTION_STDDEV_DST) { - return true; - } - } - - return false; -} - -bool needReverseScan(SArray* pFunctionIdList) { - assert(0); - int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList); - for (int32_t i = 0; i < num; ++i) { - int32_t f = *(int16_t*) taosArrayGet(pFunctionIdList, i); - if (f == FUNCTION_TS || f == FUNCTION_TS_DUMMY || f == FUNCTION_TAG) { - continue; - } - -// if ((f == FUNCTION_FIRST || f == FUNCTION_FIRST_DST) && pQueryInfo->order.order == TSDB_ORDER_DESC) { -// return true; -// } - - if (f == FUNCTION_LAST || f == FUNCTION_LAST_DST) { - // the scan order to acquire the last result of the specified column -// int32_t order = (int32_t)pExpr->base.param[0].i64; -// if (order != pQueryInfo->order.order) { -// return true; -// } - } - } - - return false; -} - -bool isAgg(SArray* pFunctionIdList) { - size_t size = taosArrayGetSize(pFunctionIdList); - for (int32_t i = 0; i < size; ++i) { - char* f = *(char**) taosArrayGet(pFunctionIdList, i); - if (strcmp(f, "project") == 0) { - return false; - } - - if (qIsAggregateFunction(f)) { - return true; - } - } - - return false; -} - -bool isBlockDistQuery(SArray* pFunctionIdList) { - int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList); - char* f = *(char**) taosArrayGet(pFunctionIdList, 0); - return (num == 1 && strcmp(f, "block_dist") == 0); -} - -bool isTwoStageSTableQuery(SArray* pFunctionIdList, int32_t tableIndex) { -// if (pQueryInfo == NULL) { -// return false; -// } -// -// STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, tableIndex); -// if (pTableMetaInfo == NULL) { -// return false; -// } -// -// if ((pQueryInfo->type & TSDB_QUERY_TYPE_FREE_RESOURCE) == TSDB_QUERY_TYPE_FREE_RESOURCE) { -// return false; -// } -// -// // for ordered projection query, iterate all qualified vnodes sequentially -// if (tscNonOrderedProjectionQueryOnSTable(pQueryInfo, tableIndex)) { -// return false; -// } -// -// if (!TSDB_QUERY_HAS_TYPE(pQueryInfo->type, TSDB_QUERY_TYPE_STABLE_SUBQUERY) && pQueryInfo->command == TSDB_SQL_SELECT) { -// return UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo); -// } - - return false; -} - -bool isProjectionQueryOnSTable(SArray* pFunctionIdList, int32_t tableIndex) { -// STableMetaInfo* pTableMetaInfo = tscGetMetaInfo(pQueryInfo, tableIndex); -// -// /* -// * In following cases, return false for non ordered project query on super table -// * 1. failed to get tableMeta from server; 2. not a super table; 3. limitation is 0; -// * 4. show queries, instead of a select query -// */ -// size_t numOfExprs = getNumOfExprs(pQueryInfo); -// if (pTableMetaInfo == NULL || !UTIL_TABLE_IS_SUPER_TABLE(pTableMetaInfo) || -// pQueryInfo->command == TSDB_SQL_RETRIEVE_EMPTY_RESULT || numOfExprs == 0) { -// return false; -// } -// -// for (int32_t i = 0; i < numOfExprs; ++i) { -// int32_t functionId = getExprInfo(pQueryInfo, i)->base.functionId; -// -// if (functionId < 0) { -// SUdfInfo* pUdfInfo = taosArrayGet(pQueryInfo->pUdfInfo, -1 * functionId - 1); -// if (pUdfInfo->funcType == TSDB_FUNC_TYPE_AGGREGATE) { -// return false; -// } -// -// continue; -// } -// -// if (functionId != FUNCTION_PRJ && -// functionId != FUNCTION_TAGPRJ && -// functionId != FUNCTION_TAG && -// functionId != FUNCTION_TS && -// functionId != FUNCTION_ARITHM && -// functionId != FUNCTION_TS_COMP && -// functionId != FUNCTION_DIFF && -// functionId != FUNCTION_DERIVATIVE && -// functionId != FUNCTION_TS_DUMMY && -// functionId != FUNCTION_TID_TAG) { -// return false; -// } -// } - - return true; -} - -bool hasTagValOutput(SArray* pFunctionIdList) { - size_t size = taosArrayGetSize(pFunctionIdList); - - // if (numOfExprs == 1 && pExpr1->base.functionId == FUNCTION_TS_COMP) { -// return true; -// } - - for (int32_t i = 0; i < size; ++i) { - int32_t functionId = *(int16_t*) taosArrayGet(pFunctionIdList, i); - - // ts_comp column required the tag value for join filter - if (functionId == FUNCTION_TAG || functionId == FUNCTION_TAGPRJ) { - return true; - } - } - - return false; -} - -//bool timeWindowInterpoRequired(SArray* pFunctionIdList) { -// int32_t num = (int32_t) taosArrayGetSize(pFunctionIdList); -// for (int32_t i = 0; i < num; ++i) { -// int32_t f = *(int16_t*) taosArrayGet(pFunctionIdList, i); -// if (f == FUNCTION_TWA || f == FUNCTION_INTERP) { -// return true; -// } -// } -// -// return false; -//} - -void extractFunctionDesc(SArray* pFunctionIdList, SMultiFunctionsDesc* pDesc) { - assert(pFunctionIdList != NULL); - - pDesc->blockDistribution = isBlockDistQuery(pFunctionIdList); - if (pDesc->blockDistribution) { - return; - } - -// pDesc->projectionQuery = isProjectionQuery(pFunctionIdList); -// pDesc->onlyTagQuery = isTagsQuery(pFunctionIdList); - pDesc->interpQuery = isInterpQuery(pFunctionIdList); - pDesc->topbotQuery = isTopBotQuery(pFunctionIdList); - pDesc->agg = isAgg(pFunctionIdList); -} From e30eb2e4333ec27748cda1916a5d9ae75fd0798c Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Sat, 12 Mar 2022 23:40:04 +0800 Subject: [PATCH 03/38] [td-13039] refactor. --- source/libs/executor/inc/executorimpl.h | 22 +++--- source/libs/executor/src/executorimpl.c | 97 ++++++++++++------------- 2 files changed, 56 insertions(+), 63 deletions(-) diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index e8a11f8c1c..646477855b 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -521,8 +521,9 @@ typedef struct SProjectOperatorInfo { } SProjectOperatorInfo; typedef struct SLimitOperatorInfo { - int64_t limit; - int64_t total; + SLimit limit; + int64_t currentOffset; + int64_t currentRows; } SLimitOperatorInfo; typedef struct SSLimitOperatorInfo { @@ -565,14 +566,15 @@ typedef struct SGroupbyOperatorInfo { char* prevData; // previous group by value } SGroupbyOperatorInfo; -typedef struct SSWindowOperatorInfo { +typedef struct SSessionAggOperatorInfo { SOptrBasicInfo binfo; + SAggSupporter aggSup; STimeWindow curWindow; // current time window TSKEY prevTs; // previous timestamp int32_t numOfRows; // number of rows int32_t start; // start row index bool reptScan; // next round scan -} SSWindowOperatorInfo; +} SSessionAggOperatorInfo; typedef struct SStateWindowOperatorInfo { SOptrBasicInfo binfo; @@ -647,25 +649,23 @@ typedef struct SOrderOperatorInfo { SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo); SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfOutput, int32_t repeatTime, int32_t reverseTime, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv); SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo); SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo); SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t num, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo); -SOperatorInfo *createOrderOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SArray* pOrderVal, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createOrderOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SArray* pOrderVal, SExecTaskInfo* pTaskInfo); SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t numOfDownstream, SExprInfo* pExprInfo, int32_t num, SArray* pOrderVal, SArray* pGroupInfo, SExecTaskInfo* pTaskInfo); SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, const SArray* pExprInfo, const SSchema* pSchema, int32_t tableType, SEpSet epset, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createLimitOperatorInfo(SOperatorInfo* downstream, SLimit* pLimit, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createLimitOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream); SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SInterval* pInterval, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createLimitOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream); - +SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv); SOperatorInfo* createAllTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfOutput); -SOperatorInfo* createSWindowOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr, - int32_t numOfOutput); + SOperatorInfo* createFillOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfOutput, bool multigroupResult); SOperatorInfo* createGroupbyOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr, diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 04047c3b7c..6db16193f5 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -1692,7 +1692,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SGroupbyOperatorInfo *pIn tfree(pInfo->prevData); } -static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSWindowOperatorInfo *pInfo, SSDataBlock *pSDataBlock) { +static void doSessionWindowAggImpl(SOperatorInfo* pOperator, SSessionAggOperatorInfo *pInfo, SSDataBlock *pSDataBlock) { STaskRuntimeEnv* pRuntimeEnv = pOperator->pRuntimeEnv; STableQueryInfo* item = pRuntimeEnv->current; @@ -5613,7 +5613,7 @@ void setTableScanFilterOperatorInfo(STableScanInfo* pTableScanInfo, SOperatorInf pTableScanInfo->pResultRowInfo = &pInfo->binfo.resultRowInfo; pTableScanInfo->rowCellInfoOffset = pInfo->binfo.rowCellInfoOffset; } else if (pDownstream->operatorType == OP_SessionWindow) { - SSWindowOperatorInfo* pInfo = pDownstream->info; + SSessionAggOperatorInfo* pInfo = pDownstream->info; pTableScanInfo->pCtx = pInfo->binfo.pCtx; pTableScanInfo->pResultRowInfo = &pInfo->binfo.resultRowInfo; @@ -6431,46 +6431,47 @@ static SSDataBlock* doLimit(SOperatorInfo *pOperator, bool* newgroup) { } SLimitOperatorInfo* pInfo = pOperator->info; - STaskRuntimeEnv* pRuntimeEnv = pOperator->pRuntimeEnv; SSDataBlock* pBlock = NULL; + SOperatorInfo* pDownstream = pOperator->pDownstream[0]; + while (1) { - publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_BEFORE_OPERATOR_EXEC); - pBlock = pOperator->pDownstream[0]->getNextFn(pOperator->pDownstream[0], newgroup); - publishOperatorProfEvent(pOperator->pDownstream[0], QUERY_PROF_AFTER_OPERATOR_EXEC); + publishOperatorProfEvent(pDownstream, QUERY_PROF_BEFORE_OPERATOR_EXEC); + pBlock = pDownstream->getNextFn(pDownstream, newgroup); + publishOperatorProfEvent(pDownstream, QUERY_PROF_AFTER_OPERATOR_EXEC); if (pBlock == NULL) { doSetOperatorCompleted(pOperator); return NULL; } - if (pRuntimeEnv->currentOffset == 0) { + if (pInfo->currentOffset == 0) { break; - } else if (pRuntimeEnv->currentOffset >= pBlock->info.rows) { - pRuntimeEnv->currentOffset -= pBlock->info.rows; - } else { - int32_t remain = (int32_t)(pBlock->info.rows - pRuntimeEnv->currentOffset); + } else if (pInfo->currentOffset >= pBlock->info.rows) { + pInfo->currentOffset -= pBlock->info.rows; + } else { // TODO handle the data movement + int32_t remain = (int32_t)(pBlock->info.rows - pInfo->currentOffset); pBlock->info.rows = remain; for (int32_t i = 0; i < pBlock->info.numOfCols; ++i) { SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, i); int16_t bytes = pColInfoData->info.bytes; - memmove(pColInfoData->pData, pColInfoData->pData + bytes * pRuntimeEnv->currentOffset, remain * bytes); + memmove(pColInfoData->pData, pColInfoData->pData + bytes * pInfo->currentOffset, remain * bytes); } - pRuntimeEnv->currentOffset = 0; + pInfo->currentOffset = 0; break; } } - if (pInfo->total + pBlock->info.rows >= pInfo->limit) { - pBlock->info.rows = (int32_t)(pInfo->limit - pInfo->total); - pInfo->total = pInfo->limit; + if (pInfo->currentRows + pBlock->info.rows >= pInfo->limit.limit) { + pBlock->info.rows = (int32_t)(pInfo->limit.limit - pInfo->currentRows); + pInfo->currentRows = pInfo->limit.limit; doSetOperatorCompleted(pOperator); } else { - pInfo->total += pBlock->info.rows; + pInfo->currentRows += pBlock->info.rows; } return pBlock; @@ -6875,26 +6876,19 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo *pOperator, bool* newgroup) return NULL; } - SSWindowOperatorInfo* pWindowInfo = pOperator->info; + SSessionAggOperatorInfo* pWindowInfo = pOperator->info; SOptrBasicInfo* pBInfo = &pWindowInfo->binfo; - - STaskRuntimeEnv* pRuntimeEnv = pOperator->pRuntimeEnv; if (pOperator->status == OP_RES_TO_RETURN) { // toSDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pBInfo->pRes); - - if (pBInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pRuntimeEnv->groupResInfo)) { + if (pBInfo->pRes->info.rows == 0/* || !hasRemainDataInCurrentGroup(&pRuntimeEnv->groupResInfo)*/) { pOperator->status = OP_EXEC_DONE; } return pBInfo->pRes; } - STaskAttr* pQueryAttr = pRuntimeEnv->pQueryAttr; - //pQueryAttr->order.order = TSDB_ORDER_ASC; - int32_t order = pQueryAttr->order.order; - STimeWindow win = pQueryAttr->window; - + int32_t order = TSDB_ORDER_ASC; SOperatorInfo* downstream = pOperator->pDownstream[0]; while(1) { @@ -6906,23 +6900,19 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo *pOperator, bool* newgroup) } // the pDataBlock are always the same one, no need to call this again - setInputDataBlock(pOperator, pBInfo->pCtx, pBlock, pQueryAttr->order.order); + setInputDataBlock(pOperator, pBInfo->pCtx, pBlock, order); doSessionWindowAggImpl(pOperator, pWindowInfo, pBlock); } // restore the value - pQueryAttr->order.order = order; - pQueryAttr->window = win; - pOperator->status = OP_RES_TO_RETURN; closeAllResultRows(&pBInfo->resultRowInfo); // setTaskStatus(pOperator->pTaskInfo, QUERY_COMPLETED); finalizeQueryResult(pOperator, pBInfo->pCtx, &pBInfo->resultRowInfo, pBInfo->rowCellInfoOffset); - initGroupResInfo(&pRuntimeEnv->groupResInfo, &pBInfo->resultRowInfo); +// initGroupResInfo(&pBInfo->groupResInfo, &pBInfo->resultRowInfo); // toSDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pBInfo->pRes); - - if (pBInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pRuntimeEnv->groupResInfo)) { + if (pBInfo->pRes->info.rows == 0/* || !hasRemainDataInCurrentGroup(&pRuntimeEnv->groupResInfo)*/) { pOperator->status = OP_EXEC_DONE; } @@ -7230,7 +7220,7 @@ static void destroyAggOperatorInfo(void* param, int32_t numOfOutput) { } static void destroySWindowOperatorInfo(void* param, int32_t numOfOutput) { - SSWindowOperatorInfo* pInfo = (SSWindowOperatorInfo*) param; + SSessionAggOperatorInfo* pInfo = (SSessionAggOperatorInfo*) param; doDestroyBasicInfo(&pInfo->binfo, numOfOutput); } @@ -7385,19 +7375,20 @@ SColumnInfo* extractColumnFilterInfo(SExprInfo* pExpr, int32_t numOfOutput, int3 return 0; } -SOperatorInfo* createLimitOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream) { +SOperatorInfo* createLimitOperatorInfo(SOperatorInfo* downstream, SLimit* pLimit, SExecTaskInfo* pTaskInfo) { SLimitOperatorInfo* pInfo = calloc(1, sizeof(SLimitOperatorInfo)); - pInfo->limit = pRuntimeEnv->pQueryAttr->limit.limit; + pInfo->limit = *pLimit; + pInfo->currentOffset = pLimit->offset; SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); pOperator->name = "LimitOperator"; -// pOperator->operatorType = OP_Limit; +// pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_LIMIT; pOperator->blockingOptr = false; pOperator->status = OP_NOT_OPENED; - pOperator->getNextFn = doLimit; + pOperator->getNextFn = doLimit; pOperator->info = pInfo; - pOperator->pRuntimeEnv = pRuntimeEnv; + pOperator->pTaskInfo = pTaskInfo; int32_t code = appendDownstream(pOperator, &downstream, 1); return pOperator; @@ -7481,14 +7472,15 @@ SOperatorInfo* createStatewindowOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOper pOperator->getNextFn = doStateWindowAgg; pOperator->closeFn = destroyStateWindowOperatorInfo; - int32_t code = appendDownstream(pOperator, &downstream, 1); + int32_t code = appendDownstream(pOperator, &downstream, 1); return pOperator; } -SOperatorInfo* createSWindowOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfOutput) { - SSWindowOperatorInfo* pInfo = calloc(1, sizeof(SSWindowOperatorInfo)); - pInfo->binfo.pCtx = createSqlFunctionCtx(pRuntimeEnv, pExpr, numOfOutput, &pInfo->binfo.rowCellInfoOffset); - pInfo->binfo.pRes = createOutputBuf(pExpr, numOfOutput, pRuntimeEnv->resultInfo.capacity); +SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo) { + SSessionAggOperatorInfo* pInfo = calloc(1, sizeof(SSessionAggOperatorInfo)); + + doInitAggInfoSup(&pInfo->aggSup, pInfo->binfo.pCtx, numOfCols); + pInfo->binfo.pRes = pResBlock; initResultRowInfo(&pInfo->binfo.resultRowInfo, 8); pInfo->prevTs = INT64_MIN; @@ -7499,14 +7491,15 @@ SOperatorInfo* createSWindowOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperator // pOperator->operatorType = OP_SessionWindow; pOperator->blockingOptr = true; pOperator->status = OP_NOT_OPENED; - pOperator->pExpr = pExpr; - pOperator->numOfOutput = numOfOutput; - pOperator->info = pInfo; - pOperator->pRuntimeEnv = pRuntimeEnv; - pOperator->getNextFn = doSessionWindowAgg; - pOperator->closeFn = destroySWindowOperatorInfo; + pOperator->pExpr = pExprInfo; + pOperator->numOfOutput = numOfCols; - int32_t code = appendDownstream(pOperator, &downstream, 1); + pOperator->info = pInfo; + pOperator->getNextFn = doSessionWindowAgg; + pOperator->closeFn = destroySWindowOperatorInfo; + pOperator->pTaskInfo = pTaskInfo; + + int32_t code = appendDownstream(pOperator, &downstream, 1); return pOperator; } From 7778f9a7fde414956927780091c04ffffd34815f Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 14 Mar 2022 14:15:26 +0800 Subject: [PATCH 04/38] [td-13039] refactor. --- source/libs/executor/inc/executorimpl.h | 2 +- source/libs/executor/src/executorimpl.c | 167 ++++++++++++++++-------- 2 files changed, 115 insertions(+), 54 deletions(-) diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 646477855b..99a42d6ad6 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -657,7 +657,7 @@ SOperatorInfo* createOrderOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t numOfDownstream, SExprInfo* pExprInfo, int32_t num, SArray* pOrderVal, SArray* pGroupInfo, SExecTaskInfo* pTaskInfo); SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, const SArray* pExprInfo, const SSchema* pSchema, int32_t tableType, SEpSet epset, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createLimitOperatorInfo(SOperatorInfo* downstream, SLimit* pLimit, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createLimitOperatorInfo(SOperatorInfo* downstream, int32_t numOfDownstream, SLimit* pLimit, SExecTaskInfo* pTaskInfo); SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SInterval* pInterval, SExecTaskInfo* pTaskInfo); SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 6db16193f5..88542eabfd 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -211,6 +211,7 @@ static void destroyOrderOperatorInfo(void* param, int32_t numOfOutput); static void destroySWindowOperatorInfo(void* param, int32_t numOfOutput); static void destroyStateWindowOperatorInfo(void* param, int32_t numOfOutput); static void destroyAggOperatorInfo(void* param, int32_t numOfOutput); +static void destroyIntervalOperatorInfo(void* param, int32_t numOfOutput); static void destroyExchangeOperatorInfo(void* param, int32_t numOfOutput); static void destroyConditionOperatorInfo(void* param, int32_t numOfOutput); @@ -5224,9 +5225,8 @@ static int32_t initDataSource(int32_t numOfSources, SExchangeInfo* pInfo) { return TSDB_CODE_SUCCESS; } -// TODO handle the error SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo) { - SExchangeInfo* pInfo = calloc(1, sizeof(SExchangeInfo)); + SExchangeInfo* pInfo = calloc(1, sizeof(SExchangeInfo)); SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { @@ -5235,11 +5235,9 @@ SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock size_t numOfSources = LIST_LENGTH(pSources); pInfo->pSources = taosArrayInit(numOfSources, sizeof(SDownstreamSourceNode)); - if (pInfo->pSources == NULL) { - tfree(pInfo); - tfree(pOperator); - terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; - return NULL; + pInfo->pSourceDataInfo = taosArrayInit(numOfSources, sizeof(SSourceDataInfo)); + if (pInfo->pSourceDataInfo == NULL || pInfo->pSources == NULL) { + goto _error; } for(int32_t i = 0; i < numOfSources; ++i) { @@ -5247,16 +5245,6 @@ SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock taosArrayPush(pInfo->pSources, pNode); } - pInfo->pSourceDataInfo = taosArrayInit(numOfSources, sizeof(SSourceDataInfo)); - if (pInfo->pSourceDataInfo == NULL || pInfo->pSources == NULL) { - tfree(pInfo); - tfree(pOperator); - taosArrayDestroy(pInfo->pSources); - taosArrayDestroy(pInfo->pSourceDataInfo); - terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; - return NULL; - } - int32_t code = initDataSource(numOfSources, pInfo); if (code != TSDB_CODE_SUCCESS) { goto _error; @@ -5307,12 +5295,12 @@ SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock _error: if (pInfo != NULL) { - destroyExchangeOperatorInfo(pInfo, 0); + destroyExchangeOperatorInfo(pInfo, numOfSources); } tfree(pInfo); tfree(pOperator); - terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; + pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; return NULL; } @@ -5351,7 +5339,7 @@ SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, tfree(pInfo); tfree(pOperator); - terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; + pTaskInfo->code = TSDB_CODE_QRY_OUT_OF_MEMORY; return NULL; } @@ -5706,7 +5694,7 @@ SArray* getResultGroupCheckColumns(STaskAttr* pQuery) { } static int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx *pCtx, int32_t numOfOutput); -static void clearupAggSup(SAggSupporter* pAggSup); +static void cleanupAggSup(SAggSupporter* pAggSup); static void destroySortedMergeOperatorInfo(void* param, int32_t numOfOutput) { SSortedMergeOperatorInfo* pInfo = (SSortedMergeOperatorInfo*) param; @@ -5718,7 +5706,7 @@ static void destroySortedMergeOperatorInfo(void* param, int32_t numOfOutput) { } blockDataDestroy(pInfo->binfo.pRes); - clearupAggSup(&pInfo->aggSup); + cleanupAggSup(&pInfo->aggSup); } static void destroySlimitOperatorInfo(void* param, int32_t numOfOutput) { @@ -6170,7 +6158,7 @@ SOperatorInfo *createOrderOperatorInfo(SOperatorInfo* downstream, SExprInfo* pEx SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { tfree(pInfo); - + tfree(pOperator); terrno = TSDB_CODE_QRY_OUT_OF_MEMORY; return NULL; } @@ -7132,7 +7120,7 @@ int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx *pCtx, int32_t n return TSDB_CODE_SUCCESS; } -static void clearupAggSup(SAggSupporter* pAggSup) { +static void cleanupAggSup(SAggSupporter* pAggSup) { tfree(pAggSup->keyBuf); taosHashCleanup(pAggSup->pResultRowHashTable); taosHashCleanup(pAggSup->pResultRowListSet); @@ -7147,6 +7135,9 @@ static int32_t initAggInfo(SAggOperatorInfo* pInfo, SExprInfo* pExprInfo, int32_ doInitAggInfoSup(&pInfo->aggSup, pInfo->binfo.pCtx, numOfCols); pInfo->pTableQueryInfo = calloc(pTableGroupInfo->numOfTables, sizeof(STableQueryInfo)); + if (pInfo->pTableQueryInfo == NULL) { + return TSDB_CODE_OUT_OF_MEMORY; + } int32_t index = 0; for(int32_t i = 0; i < taosArrayGetSize(pTableGroupInfo->pGroupList); ++i) { @@ -7170,14 +7161,20 @@ static int32_t initAggInfo(SAggOperatorInfo* pInfo, SExprInfo* pExprInfo, int32_ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, SExecTaskInfo* pTaskInfo, const STableGroupInfo* pTableGroupInfo) { SAggOperatorInfo* pInfo = calloc(1, sizeof(SAggOperatorInfo)); + SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); + if (pInfo == NULL || pOperator == NULL) { + goto _error; + } - int32_t numOfRows = 1; //(int32_t)(getRowNumForMultioutput(pQueryAttr, pQueryAttr->topBotQuery, pQueryAttr->stableQuery)); + int32_t numOfRows = 1; + int32_t code = initAggInfo(pInfo, pExprInfo, numOfCols, numOfRows, pResultBlock, pTableGroupInfo); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } - initAggInfo(pInfo, pExprInfo, numOfCols, numOfRows, pResultBlock, pTableGroupInfo); setFunctionResultOutput(&pInfo->binfo, &pInfo->aggSup, MAIN_SCAN, pTaskInfo); - SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); pOperator->name = "TableAggregate"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_AGG; pOperator->blockingOptr = true; @@ -7190,9 +7187,19 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pOperator->_openFn = doOpenAggregateOptr; pOperator->getNextFn = getAggregateResult; pOperator->closeFn = destroyAggOperatorInfo; - int32_t code = appendDownstream(pOperator, &downstream, 1); + + code = appendDownstream(pOperator, &downstream, 1); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } return pOperator; + _error: + destroyAggOperatorInfo(pInfo, numOfCols); + tfree(pInfo); + tfree(pOperator); + pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; + return NULL; } static void doDestroyBasicInfo(SOptrBasicInfo* pInfo, int32_t numOfOutput) { @@ -7205,33 +7212,42 @@ static void doDestroyBasicInfo(SOptrBasicInfo* pInfo, int32_t numOfOutput) { pInfo->pRes = blockDataDestroy(pInfo->pRes); } -static void destroyBasicOperatorInfo(void* param, int32_t numOfOutput) { +void destroyBasicOperatorInfo(void* param, int32_t numOfOutput) { SOptrBasicInfo* pInfo = (SOptrBasicInfo*) param; doDestroyBasicInfo(pInfo, numOfOutput); } -static void destroyStateWindowOperatorInfo(void* param, int32_t numOfOutput) { + +void destroyStateWindowOperatorInfo(void* param, int32_t numOfOutput) { SStateWindowOperatorInfo* pInfo = (SStateWindowOperatorInfo*) param; doDestroyBasicInfo(&pInfo->binfo, numOfOutput); tfree(pInfo->prevData); } -static void destroyAggOperatorInfo(void* param, int32_t numOfOutput) { + +void destroyAggOperatorInfo(void* param, int32_t numOfOutput) { SAggOperatorInfo* pInfo = (SAggOperatorInfo*) param; doDestroyBasicInfo(&pInfo->binfo, numOfOutput); } -static void destroySWindowOperatorInfo(void* param, int32_t numOfOutput) { +void destroyIntervalOperatorInfo(void* param, int32_t numOfOutput) { + STableIntervalOperatorInfo* pInfo = (STableIntervalOperatorInfo*) param; + doDestroyBasicInfo(&pInfo->binfo, numOfOutput); + cleanupAggSup(&pInfo->aggSup); + destroyDiskbasedBuf(pInfo->pResultBuf); +} + +void destroySWindowOperatorInfo(void* param, int32_t numOfOutput) { SSessionAggOperatorInfo* pInfo = (SSessionAggOperatorInfo*) param; doDestroyBasicInfo(&pInfo->binfo, numOfOutput); } -static void destroySFillOperatorInfo(void* param, int32_t numOfOutput) { +void destroySFillOperatorInfo(void* param, int32_t numOfOutput) { SFillOperatorInfo* pInfo = (SFillOperatorInfo*) param; pInfo->pFillInfo = taosDestroyFillInfo(pInfo->pFillInfo); pInfo->pRes = blockDataDestroy(pInfo->pRes); tfree(pInfo->p); } -static void destroyGroupbyOperatorInfo(void* param, int32_t numOfOutput) { +void destroyGroupbyOperatorInfo(void* param, int32_t numOfOutput) { SGroupbyOperatorInfo* pInfo = (SGroupbyOperatorInfo*) param; doDestroyBasicInfo(&pInfo->binfo, numOfOutput); tfree(pInfo->prevData); @@ -7316,14 +7332,20 @@ SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SExprI SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t num, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo) { SProjectOperatorInfo* pInfo = calloc(1, sizeof(SProjectOperatorInfo)); + SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); + if (pInfo == NULL || pOperator == NULL) { + goto _error; + } pInfo->binfo.pRes = pResBlock; pInfo->binfo.pCtx = createSqlFunctionCtx_rv(pExprInfo, num, &pInfo->binfo.rowCellInfoOffset); + if (pInfo->binfo.pCtx == NULL) { + goto _error; + } // initResultRowInfo(&pBInfo->resultRowInfo, 8); // setFunctionResultOutput(pBInfo, MAIN_SCAN); - SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); pOperator->name = "ProjectOperator"; pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_PROJECT; pOperator->blockingOptr = false; @@ -7338,8 +7360,15 @@ SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* p pOperator->pTaskInfo = pTaskInfo; int32_t code = appendDownstream(pOperator, &downstream, 1); + if (code != TSDB_CODE_OUT_OF_MEMORY) { + goto _error; + } return pOperator; + + _error: + pTaskInfo->code = TSDB_CODE_OUT_OF_MEMORY; + return NULL; } SColumnInfo* extractColumnFilterInfo(SExprInfo* pExpr, int32_t numOfOutput, int32_t* numOfFilterCols) { @@ -7375,43 +7404,51 @@ SColumnInfo* extractColumnFilterInfo(SExprInfo* pExpr, int32_t numOfOutput, int3 return 0; } -SOperatorInfo* createLimitOperatorInfo(SOperatorInfo* downstream, SLimit* pLimit, SExecTaskInfo* pTaskInfo) { +SOperatorInfo* createLimitOperatorInfo(SOperatorInfo* downstream, int32_t numOfDownstream, SLimit* pLimit, SExecTaskInfo* pTaskInfo) { + ASSERT(numOfDownstream == 1); SLimitOperatorInfo* pInfo = calloc(1, sizeof(SLimitOperatorInfo)); - pInfo->limit = *pLimit; - pInfo->currentOffset = pLimit->offset; - SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); + if (pInfo == NULL || pOperator == NULL) { + goto _error; + } + + pInfo->limit = *pLimit; + pInfo->currentOffset = pLimit->offset; pOperator->name = "LimitOperator"; // pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_LIMIT; pOperator->blockingOptr = false; pOperator->status = OP_NOT_OPENED; + pOperator->_openFn = operatorDummyOpenFn; pOperator->getNextFn = doLimit; pOperator->info = pInfo; pOperator->pTaskInfo = pTaskInfo; int32_t code = appendDownstream(pOperator, &downstream, 1); return pOperator; + _error: + tfree(pInfo); + tfree(pOperator); + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; } SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SInterval* pInterval, SExecTaskInfo* pTaskInfo) { STableIntervalOperatorInfo* pInfo = calloc(1, sizeof(STableIntervalOperatorInfo)); - - doInitAggInfoSup(&pInfo->aggSup, pInfo->binfo.pCtx, numOfCols); + SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); pInfo->order = TSDB_ORDER_ASC; pInfo->precision = TSDB_TIME_PRECISION_MICRO; pInfo->win = pTaskInfo->window; pInfo->interval = *pInterval; - int32_t code = createDiskbasedBuf(&pInfo->pResultBuf, 4096, 4096 * 256, pTaskInfo->id.str, "/tmp/"); + int32_t code = doInitAggInfoSup(&pInfo->aggSup, pInfo->binfo.pCtx, numOfCols); + code = createDiskbasedBuf(&pInfo->pResultBuf, 4096, 4096 * 256, pTaskInfo->id.str, "/tmp/"); pInfo->binfo.pCtx = createSqlFunctionCtx_rv(pExprInfo, numOfCols, &pInfo->binfo.rowCellInfoOffset); initResultRowInfo(&pInfo->binfo.resultRowInfo, (int32_t)1); - SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); - pOperator->name = "TimeIntervalAggOperator"; // pOperator->operatorType = OP_TimeWindow; pOperator->blockingOptr = true; @@ -7421,11 +7458,19 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pOperator->pTaskInfo = pTaskInfo; pOperator->numOfOutput = numOfCols; pOperator->info = pInfo; - pOperator->getNextFn = doIntervalAgg; - pOperator->closeFn = destroyBasicOperatorInfo; + pOperator->_openFn = operatorDummyOpenFn; + pOperator->getNextFn = doIntervalAgg; + pOperator->closeFn = destroyIntervalOperatorInfo; code = appendDownstream(pOperator, &downstream, 1); return pOperator; + + _error: + destroyIntervalOperatorInfo(pInfo, numOfCols); + tfree(pInfo); + tfree(pOperator); + pTaskInfo->code = code; + return NULL; } SOperatorInfo* createAllTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfOutput) { @@ -7478,15 +7523,21 @@ SOperatorInfo* createStatewindowOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOper SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo) { SSessionAggOperatorInfo* pInfo = calloc(1, sizeof(SSessionAggOperatorInfo)); + SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); + if (pInfo == NULL || pOperator == NULL) { + goto _error; + } + + int32_t code = doInitAggInfoSup(&pInfo->aggSup, pInfo->binfo.pCtx, numOfCols); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } - doInitAggInfoSup(&pInfo->aggSup, pInfo->binfo.pCtx, numOfCols); - pInfo->binfo.pRes = pResBlock; initResultRowInfo(&pInfo->binfo.resultRowInfo, 8); - pInfo->prevTs = INT64_MIN; - pInfo->reptScan = false; - SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); - + pInfo->binfo.pRes = pResBlock; + pInfo->prevTs = INT64_MIN; + pInfo->reptScan = false; pOperator->name = "SessionWindowAggOperator"; // pOperator->operatorType = OP_SessionWindow; pOperator->blockingOptr = true; @@ -7499,8 +7550,18 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo pOperator->closeFn = destroySWindowOperatorInfo; pOperator->pTaskInfo = pTaskInfo; - int32_t code = appendDownstream(pOperator, &downstream, 1); + code = appendDownstream(pOperator, &downstream, 1); return pOperator; + + _error: + if (pInfo != NULL) { + destroySWindowOperatorInfo(pInfo, numOfCols); + } + + tfree(pInfo); + tfree(pOperator); + pTaskInfo->code = code; + return NULL; } SOperatorInfo* createMultiTableTimeIntervalOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfOutput) { From a853c6ddf5d941a9350c9c1329c108e2bb1fb2a5 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Mon, 14 Mar 2022 16:09:26 +0800 Subject: [PATCH 05/38] [td-13039] refactor. --- include/libs/nodes/plannodes.h | 12 +- source/libs/executor/inc/executorimpl.h | 233 +++++++++------------ source/libs/executor/src/executorimpl.c | 98 ++++++--- source/libs/nodes/src/nodesCodeFuncs.c | 17 ++ source/libs/planner/src/planPhysiCreater.c | 3 + 5 files changed, 200 insertions(+), 163 deletions(-) diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index c028c4a1b9..8871bae4e9 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -93,6 +93,8 @@ typedef struct SWindowLogicNode { int64_t interval; int64_t offset; int64_t sliding; + int8_t intervalUnit; + int8_t slidingUnit; SFillNode* pFill; } SWindowLogicNode; @@ -203,7 +205,7 @@ typedef struct SDownstreamSourceNode { typedef struct SExchangePhysiNode { SPhysiNode node; - int32_t srcGroupId; // group id of datasource suplans + int32_t srcGroupId; // group id of datasource suplans SNodeList* pSrcEndPoints; // element is SDownstreamSource, scheduler fill by calling qSetSuplanExecutionNode } SExchangePhysiNode; @@ -211,9 +213,11 @@ typedef struct SIntervalPhysiNode { SPhysiNode node; SNodeList* pExprs; // these are expression list of parameter expression of function SNodeList* pFuncs; - int64_t interval; - int64_t offset; - int64_t sliding; + int64_t interval; + int64_t offset; + int64_t sliding; + int8_t intervalUnit; + int8_t slidingUnit; SFillNode* pFill; } SIntervalPhysiNode; diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 99a42d6ad6..351903dfdc 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -275,36 +275,36 @@ typedef struct SExecTaskInfo { } SExecTaskInfo; typedef struct STaskRuntimeEnv { - jmp_buf env; - STaskAttr* pQueryAttr; - uint32_t status; // query status - void* qinfo; - uint8_t scanFlag; // denotes reversed scan of data or not - void* pTsdbReadHandle; + jmp_buf env; + STaskAttr* pQueryAttr; + uint32_t status; // query status + void* qinfo; + uint8_t scanFlag; // denotes reversed scan of data or not + void* pTsdbReadHandle; - int32_t prevGroupId; // previous executed group id - bool enableGroupData; - SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file - SHashObj* pResultRowHashTable; // quick locate the window object for each result - SHashObj* pResultRowListSet; // used to check if current ResultRowInfo has ResultRow object or not - SArray* pResultRowArrayList; // The array list that contains the Result rows - char* keyBuf; // window key buffer + int32_t prevGroupId; // previous executed group id + bool enableGroupData; + SDiskbasedBuf* pResultBuf; // query result buffer based on blocked-wised disk file + SHashObj* pResultRowHashTable; // quick locate the window object for each result + SHashObj* pResultRowListSet; // used to check if current ResultRowInfo has ResultRow object or not + SArray* pResultRowArrayList; // The array list that contains the Result rows + char* keyBuf; // window key buffer // The window result objects pool, all the resultRow Objects are allocated and managed by this object. - char** prevRow; + char** prevRow; SResultRowPool* pool; - SArray* prevResult; // intermediate result, SArray - STSBuf* pTsBuf; // timestamp filter list - STSCursor cur; + SArray* prevResult; // intermediate result, SArray + STSBuf* pTsBuf; // timestamp filter list + STSCursor cur; - char* tagVal; // tag value of current data block + char* tagVal; // tag value of current data block struct SScalarFunctionSupport* scalarSup; SSDataBlock* outputBuf; STableGroupInfo tableqinfoGroupInfo; // this is a group array list, including SArray structure struct SOperatorInfo* proot; - SGroupResInfo groupResInfo; - int64_t currentOffset; // dynamic offset value + SGroupResInfo groupResInfo; + int64_t currentOffset; // dynamic offset value STableQueryInfo* current; SRspResultInfo resultInfo; @@ -365,28 +365,6 @@ typedef struct SQInfo { STaskCostInfo summary; } SQInfo; -typedef struct STaskParam { - char* sql; - char* tagCond; - char* colCond; - char* tbnameCond; - char* prevResult; - SArray* pTableIdList; - SExprBasicInfo** pExpr; - SExprBasicInfo** pSecExpr; - SExprInfo* pExprs; - SExprInfo* pSecExprs; - - SFilterInfo* pFilters; - - SColIndex* pGroupColIndex; - SColumnInfo* pTagColumnInfo; - SGroupbyExpr* pGroupbyExpr; - int32_t tableScanOperator; - SArray* pOperator; - struct SUdfInfo* pUdfInfo; -} STaskParam; - enum { EX_SOURCE_DATA_NOT_READY = 0x1, EX_SOURCE_DATA_READY = 0x2, @@ -472,78 +450,76 @@ typedef struct SSysTableScanInfo { } SSysTableScanInfo; typedef struct SOptrBasicInfo { - SResultRowInfo resultRowInfo; - int32_t* rowCellInfoOffset; // offset value for each row result cell info - SqlFunctionCtx* pCtx; - SSDataBlock* pRes; - int32_t capacity; + SResultRowInfo resultRowInfo; + int32_t* rowCellInfoOffset; // offset value for each row result cell info + SqlFunctionCtx* pCtx; + SSDataBlock* pRes; + int32_t capacity; } SOptrBasicInfo; //TODO move the resultrowsiz together with SOptrBasicInfo:rowCellInfoOffset typedef struct SAggSupporter { - SHashObj* pResultRowHashTable; // quick locate the window object for each result - SHashObj* pResultRowListSet; // used to check if current ResultRowInfo has ResultRow object or not - SArray* pResultRowArrayList; // The array list that contains the Result rows - char* keyBuf; // window key buffer - SResultRowPool *pool; // The window result objects pool, all the resultRow Objects are allocated and managed by this object. - int32_t resultRowSize; // the result buffer size for each result row, with the meta data size for each row + SHashObj* pResultRowHashTable; // quick locate the window object for each result + SHashObj* pResultRowListSet; // used to check if current ResultRowInfo has ResultRow object or not + SArray* pResultRowArrayList; // The array list that contains the Result rows + char* keyBuf; // window key buffer + SResultRowPool *pool; // The window result objects pool, all the resultRow Objects are allocated and managed by this object. + int32_t resultRowSize; // the result buffer size for each result row, with the meta data size for each row } SAggSupporter; typedef struct STableIntervalOperatorInfo { - SOptrBasicInfo binfo; - SDiskbasedBuf *pResultBuf; // query result buffer based on blocked-wised disk file - SGroupResInfo groupResInfo; - SInterval interval; - STimeWindow win; - int32_t precision; - bool timeWindowInterpo; - char **pRow; - SAggSupporter aggSup; - STableQueryInfo *pCurrent; - int32_t order; + SOptrBasicInfo binfo; + SDiskbasedBuf *pResultBuf; // query result buffer based on blocked-wised disk file + SGroupResInfo groupResInfo; + SInterval interval; + STimeWindow win; + int32_t precision; + bool timeWindowInterpo; + char **pRow; + SAggSupporter aggSup; + STableQueryInfo *pCurrent; + int32_t order; } STableIntervalOperatorInfo; typedef struct SAggOperatorInfo { - SOptrBasicInfo binfo; - SDiskbasedBuf *pResultBuf; // query result buffer based on blocked-wised disk file - SAggSupporter aggSup; - STableQueryInfo *current; - uint32_t groupId; - SGroupResInfo groupResInfo; - STableQueryInfo *pTableQueryInfo; + SOptrBasicInfo binfo; + SDiskbasedBuf *pResultBuf; // query result buffer based on blocked-wised disk file + SAggSupporter aggSup; + STableQueryInfo *current; + uint32_t groupId; + SGroupResInfo groupResInfo; + STableQueryInfo *pTableQueryInfo; } SAggOperatorInfo; typedef struct SProjectOperatorInfo { - SOptrBasicInfo binfo; - SSDataBlock *existDataBlock; - int32_t threshold; - bool hasVarCol; + SOptrBasicInfo binfo; + SSDataBlock *existDataBlock; + int32_t threshold; + bool hasVarCol; } SProjectOperatorInfo; typedef struct SLimitOperatorInfo { - SLimit limit; - int64_t currentOffset; - int64_t currentRows; + SLimit limit; + int64_t currentOffset; + int64_t currentRows; } SLimitOperatorInfo; typedef struct SSLimitOperatorInfo { - int64_t groupTotal; - int64_t currentGroupOffset; - - int64_t rowsTotal; - int64_t currentOffset; - SLimit limit; - SLimit slimit; - - char** prevRow; - SArray* orderColumnList; - bool hasPrev; - bool ignoreCurrentGroup; - bool multigroupResult; - SSDataBlock* pRes; // result buffer - SSDataBlock* pPrevBlock; - int64_t capacity; - int64_t threshold; + int64_t groupTotal; + int64_t currentGroupOffset; + int64_t rowsTotal; + int64_t currentOffset; + SLimit limit; + SLimit slimit; + char** prevRow; + SArray* orderColumnList; + bool hasPrev; + bool ignoreCurrentGroup; + bool multigroupResult; + SSDataBlock* pRes; // result buffer + SSDataBlock* pPrevBlock; + int64_t capacity; + int64_t threshold; } SSLimitOperatorInfo; typedef struct SFilterOperatorInfo { @@ -586,23 +562,6 @@ typedef struct SStateWindowOperatorInfo { bool reptScan; } SStateWindowOperatorInfo; -typedef struct SDistinctDataInfo { - int32_t index; - int32_t type; - int32_t bytes; -} SDistinctDataInfo; - -typedef struct SDistinctOperatorInfo { - SHashObj* pSet; - SSDataBlock* pRes; - bool recordNullVal; // has already record the null value, no need to try again - int64_t threshold; - int64_t outputCapacity; - int32_t totalBytes; - char* buf; - SArray* pDistinctDataInfo; -} SDistinctOperatorInfo; - typedef struct SSortedMergeOperatorInfo { SOptrBasicInfo binfo; bool hasVarCol; @@ -628,24 +587,40 @@ typedef struct SSortedMergeOperatorInfo { } SSortedMergeOperatorInfo; typedef struct SOrderOperatorInfo { - uint32_t sortBufSize; // max buffer size for in-memory sort - SSDataBlock *pDataBlock; - bool hasVarCol; // has variable length column, such as binary/varchar/nchar - SArray *orderInfo; - bool nullFirst; - SSortHandle *pSortHandle; - - int32_t bufPageSize; - int32_t numOfRowsInRes; + uint32_t sortBufSize; // max buffer size for in-memory sort + SSDataBlock *pDataBlock; + bool hasVarCol; // has variable length column, such as binary/varchar/nchar + SArray *orderInfo; + bool nullFirst; + SSortHandle *pSortHandle; + int32_t bufPageSize; + int32_t numOfRowsInRes; // 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. + uint64_t totalSize; // total load bytes from remote + uint64_t totalRows; // total number of rows + uint64_t totalElapsed; // total elapsed time } SOrderOperatorInfo; +typedef struct SDistinctDataInfo { + int32_t index; + int32_t type; + int32_t bytes; +} SDistinctDataInfo; + +typedef struct SDistinctOperatorInfo { + SHashObj* pSet; + SSDataBlock* pRes; + bool recordNullVal; // has already record the null value, no need to try again + int64_t threshold; + int64_t outputCapacity; + int32_t totalBytes; + char* buf; + SArray* pDistinctDataInfo; +} SDistinctOperatorInfo; + SOperatorInfo* createExchangeOperatorInfo(const SNodeList* pSources, SSDataBlock* pBlock, SExecTaskInfo* pTaskInfo); SOperatorInfo* createTableScanOperatorInfo(void* pTsdbReadHandle, int32_t order, int32_t numOfOutput, int32_t repeatTime, int32_t reverseTime, SExecTaskInfo* pTaskInfo); @@ -659,7 +634,8 @@ SOperatorInfo* createSysTableScanOperatorInfo(void* pSysTableReadHandle, const S int32_t tableType, SEpSet epset, SExecTaskInfo* pTaskInfo); SOperatorInfo* createLimitOperatorInfo(SOperatorInfo* downstream, int32_t numOfDownstream, SLimit* pLimit, SExecTaskInfo* pTaskInfo); -SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SInterval* pInterval, SExecTaskInfo* pTaskInfo); +SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SInterval* pInterval, + const STableGroupInfo* pTableGroupInfo, SExecTaskInfo* pTaskInfo); SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo); SOperatorInfo* createTableSeqScanOperatorInfo(void* pTsdbReadHandle, STaskRuntimeEnv* pRuntimeEnv); @@ -709,9 +685,6 @@ void copyTsColoum(SSDataBlock* pRes, SqlFunctionCtx* pCtx, int32_t numOfOutput); int32_t createQueryFilter(char* data, uint16_t len, SFilterInfo** pFilters); -int32_t initQInfo(STsBufInfo* pTsBufInfo, void* tsdb, void* sourceOptr, SQInfo* pQInfo, STaskParam* param, char* start, - int32_t prevResultLen, void* merger); - int32_t createFilterInfo(STaskAttr* pQueryAttr, uint64_t qId); void freeColumnFilterInfo(SColumnFilterInfo* pFilter, int32_t numOfFilters); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 356375c7ca..9d3a80d7b4 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -7128,15 +7128,19 @@ static void cleanupAggSup(SAggSupporter* pAggSup) { destroyResultRowPool(pAggSup->pool); } -static int32_t initAggInfo(SAggOperatorInfo* pInfo, SExprInfo* pExprInfo, int32_t numOfCols, int32_t numOfRows, SSDataBlock* pResultBlock, const STableGroupInfo* pTableGroupInfo) { - pInfo->binfo.pCtx = createSqlFunctionCtx_rv(pExprInfo, numOfCols, &pInfo->binfo.rowCellInfoOffset); - pInfo->binfo.pRes = pResultBlock; - pInfo->binfo.capacity = numOfRows; +static int32_t initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, + int32_t numOfRows, SSDataBlock* pResultBlock) { + pBasicInfo->pCtx = createSqlFunctionCtx_rv(pExprInfo, numOfCols, &pBasicInfo->rowCellInfoOffset); + pBasicInfo->pRes = pResultBlock; + pBasicInfo->capacity = numOfRows; - doInitAggInfoSup(&pInfo->aggSup, pInfo->binfo.pCtx, numOfCols); - pInfo->pTableQueryInfo = calloc(pTableGroupInfo->numOfTables, sizeof(STableQueryInfo)); - if (pInfo->pTableQueryInfo == NULL) { - return TSDB_CODE_OUT_OF_MEMORY; + doInitAggInfoSup(pAggSup, pBasicInfo->pCtx, numOfCols); +} + +static STableQueryInfo* initTableQueryInfo(const STableGroupInfo* pTableGroupInfo) { + STableQueryInfo* pTableQueryInfo = calloc(pTableGroupInfo->numOfTables, sizeof(STableQueryInfo)); + if (pTableQueryInfo == NULL) { + return NULL; } int32_t index = 0; @@ -7145,7 +7149,7 @@ static int32_t initAggInfo(SAggOperatorInfo* pInfo, SExprInfo* pExprInfo, int32_ for(int32_t j = 0; j < taosArrayGetSize(pa); ++j) { STableKeyInfo* pk = taosArrayGet(pa, j); - STableQueryInfo* pTQueryInfo = &pInfo->pTableQueryInfo[index++]; + STableQueryInfo* pTQueryInfo = &pTableQueryInfo[index++]; pTQueryInfo->uid = pk->uid; pTQueryInfo->lastKey = pk->lastKey; pTQueryInfo->groupIndex = i; @@ -7153,9 +7157,8 @@ static int32_t initAggInfo(SAggOperatorInfo* pInfo, SExprInfo* pExprInfo, int32_ } STimeWindow win = {0, INT64_MAX}; - createTableQueryInfo(pInfo->pTableQueryInfo, false, win); - - return TSDB_CODE_SUCCESS; + createTableQueryInfo(pTableQueryInfo, false, win); + return pTableQueryInfo; } SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResultBlock, @@ -7168,8 +7171,9 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* //(int32_t)(getRowNumForMultioutput(pQueryAttr, pQueryAttr->topBotQuery, pQueryAttr->stableQuery)); int32_t numOfRows = 1; - int32_t code = initAggInfo(pInfo, pExprInfo, numOfCols, numOfRows, pResultBlock, pTableGroupInfo); - if (code != TSDB_CODE_SUCCESS) { + int32_t code = initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResultBlock); + pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo); + if (code != TSDB_CODE_SUCCESS || pInfo->pTableQueryInfo == NULL) { goto _error; } @@ -7308,7 +7312,11 @@ SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SExprI SAggOperatorInfo* pInfo = calloc(1, sizeof(SAggOperatorInfo)); int32_t numOfRows = 1; - initAggInfo(pInfo, pExprInfo, numOfCols, numOfRows, pResBlock, pTableGroupInfo); + int32_t code = initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResBlock); + pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo); + if (code != TSDB_CODE_SUCCESS || pInfo->pTableQueryInfo == NULL) { + goto _error; + } size_t tableGroup = taosArrayGetSize(pTableGroupInfo->pGroupList); initResultRowInfo(&pInfo->binfo.resultRowInfo, (int32_t)tableGroup); @@ -7325,9 +7333,15 @@ SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SExprI pOperator->getNextFn = doMultiTableAggregate; pOperator->closeFn = destroyAggOperatorInfo; - int32_t code = appendDownstream(pOperator, &downstream, 1); + code = appendDownstream(pOperator, &downstream, 1); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } return pOperator; + +_error: + return NULL; } SOperatorInfo* createProjectOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t num, SSDataBlock* pResBlock, SExecTaskInfo* pTaskInfo) { @@ -7433,24 +7447,35 @@ SOperatorInfo* createLimitOperatorInfo(SOperatorInfo* downstream, int32_t numOfD return NULL; } -SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SInterval* pInterval, SExecTaskInfo* pTaskInfo) { +SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SInterval* pInterval, +const STableGroupInfo* pTableGroupInfo, SExecTaskInfo* pTaskInfo) { STableIntervalOperatorInfo* pInfo = calloc(1, sizeof(STableIntervalOperatorInfo)); SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); + if (pInfo == NULL || pOperator == NULL) { + goto _error; + } pInfo->order = TSDB_ORDER_ASC; pInfo->precision = TSDB_TIME_PRECISION_MICRO; pInfo->win = pTaskInfo->window; pInfo->interval = *pInterval; - int32_t code = doInitAggInfoSup(&pInfo->aggSup, pInfo->binfo.pCtx, numOfCols); + int32_t numOfRows = 1; + int32_t code = initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResBlock); +// pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo); + if (code != TSDB_CODE_SUCCESS/* || pInfo->pTableQueryInfo == NULL*/) { + goto _error; + } code = createDiskbasedBuf(&pInfo->pResultBuf, 4096, 4096 * 256, pTaskInfo->id.str, "/tmp/"); - pInfo->binfo.pCtx = createSqlFunctionCtx_rv(pExprInfo, numOfCols, &pInfo->binfo.rowCellInfoOffset); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } initResultRowInfo(&pInfo->binfo.resultRowInfo, (int32_t)1); pOperator->name = "TimeIntervalAggOperator"; - // pOperator->operatorType = OP_TimeWindow; + pOperator->operatorType = QUERY_NODE_PHYSICAL_PLAN_INTERVAL; pOperator->blockingOptr = true; pOperator->status = OP_NOT_OPENED; pOperator->pExpr = pExprInfo; @@ -7463,6 +7488,10 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pOperator->closeFn = destroyIntervalOperatorInfo; code = appendDownstream(pOperator, &downstream, 1); + if (code != TSDB_CODE_SUCCESS) { + goto _error; + } + return pOperator; _error: @@ -7686,15 +7715,13 @@ SOperatorInfo* createFillOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInf SOperatorInfo* createSLimitOperatorInfo(STaskRuntimeEnv* pRuntimeEnv, SOperatorInfo* downstream, SExprInfo* pExpr, int32_t numOfOutput, void* pMerger, bool multigroupResult) { SSLimitOperatorInfo* pInfo = calloc(1, sizeof(SSLimitOperatorInfo)); - STaskAttr* pQueryAttr = pRuntimeEnv->pQueryAttr; - - pInfo->orderColumnList = getResultGroupCheckColumns(pQueryAttr); - pInfo->slimit = pQueryAttr->slimit; - pInfo->limit = pQueryAttr->limit; - pInfo->capacity = pRuntimeEnv->resultInfo.capacity; - pInfo->threshold = (int64_t)(pInfo->capacity * 0.8); - pInfo->currentOffset = pQueryAttr->limit.offset; - pInfo->currentGroupOffset = pQueryAttr->slimit.offset; +// pInfo->orderColumnList = getResultGroupCheckColumns(pQueryAttr); +// pInfo->slimit = pQueryAttr->slimit; +// pInfo->limit = pQueryAttr->limit; +// pInfo->capacity = pRuntimeEnv->resultInfo.capacity; +// pInfo->threshold = (int64_t)(pInfo->capacity * 0.8); +// pInfo->currentOffset = pQueryAttr->limit.offset; +// pInfo->currentGroupOffset = pQueryAttr->slimit.offset; pInfo->multigroupResult= multigroupResult; // TODO refactor @@ -8269,6 +8296,19 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); return createAggregateOperatorInfo(op, pExprInfo, num, pResBlock, pTaskInfo, pTableGroupInfo); } + } else if (QUERY_NODE_PHYSICAL_PLAN_INTERVAL == nodeType(pPhyNode)) { + size_t size = LIST_LENGTH(pPhyNode->pChildren); + assert(size == 1); + + for (int32_t i = 0; i < size; ++i) { + SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, i); + SOperatorInfo* op = doCreateOperatorTreeNode(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo); + + int32_t num = 0; + SExprInfo* pExprInfo = createExprInfo(((SIntervalPhysiNode*)pPhyNode)->pFuncs, &num); + SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); + return createIntervalOperatorInfo(op, pExprInfo, num, pResBlock, NULL, pTableGroupInfo, pTaskInfo); + } } /*else if (pPhyNode->info.type == OP_MultiTableAggregate) { size_t size = taosArrayGetSize(pPhyNode->pChildren); assert(size == 1); diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 57ebc2c4b6..4c0acb9412 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -580,6 +580,8 @@ static const char* jkIntervalPhysiPlanFuncs = "Funcs"; static const char* jkIntervalPhysiPlanInterval = "Interval"; static const char* jkIntervalPhysiPlanOffset = "Offset"; static const char* jkIntervalPhysiPlanSliding = "Sliding"; +static const char* jkIntervalPhysiPlanIntervalUnit = "intervalUnit"; +static const char* jkIntervalPhysiPlanSlidingUnit = "slidingUnit"; static const char* jkIntervalPhysiPlanFill = "Fill"; static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) { @@ -601,6 +603,12 @@ static int32_t physiIntervalNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddIntegerToObject(pJson, jkIntervalPhysiPlanSliding, pNode->sliding); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkIntervalPhysiPlanIntervalUnit, pNode->intervalUnit); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkIntervalPhysiPlanSlidingUnit, pNode->slidingUnit); + } if (TSDB_CODE_SUCCESS == code) { code = tjsonAddObject(pJson, jkIntervalPhysiPlanFill, nodeToJson, pNode->pFill); } @@ -627,6 +635,12 @@ static int32_t jsonToPhysiIntervalNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = tjsonGetBigIntValue(pJson, jkIntervalPhysiPlanSliding, &pNode->sliding); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetTinyIntValue(pJson, jkIntervalPhysiPlanIntervalUnit, &pNode->intervalUnit); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetTinyIntValue(pJson, jkIntervalPhysiPlanSlidingUnit, &pNode->slidingUnit); + } if (TSDB_CODE_SUCCESS == code) { code = jsonToNodeObject(pJson, jkIntervalPhysiPlanFill, (SNode**)&pNode->pFill); } @@ -1644,7 +1658,10 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { return jsonToSubplan(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN: return jsonToPlan(pJson, pObj); + case QUERY_NODE_PHYSICAL_PLAN_INTERVAL: + return jsonToPhysiIntervalNode(pJson, pObj); default: + assert(0); break; } nodesWarn("jsonToSpecificNode unknown node = %s", nodesNodeName(nodeType(pObj))); diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 7b7dd26df1..0affd93f4d 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -480,6 +480,9 @@ static SPhysiNode* createIntervalPhysiNode(SPhysiPlanContext* pCxt, SNodeList* p pInterval->interval = pWindowLogicNode->interval; pInterval->offset = pWindowLogicNode->offset; pInterval->sliding = pWindowLogicNode->sliding; + pInterval->intervalUnit = pWindowLogicNode->intervalUnit; + pInterval->slidingUnit = pWindowLogicNode->slidingUnit; + pInterval->pFill = nodesCloneNode(pWindowLogicNode->pFill); SNodeList* pPrecalcExprs = NULL; From 15cfd98449914304d8491eb40f9f6d5eea04a014 Mon Sep 17 00:00:00 2001 From: tangfangzhi Date: Tue, 15 Mar 2022 12:44:38 +0800 Subject: [PATCH 06/38] extend 3.0 ci to 4 machines --- Jenkinsfile2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile2 b/Jenkinsfile2 index ad62fa7044..bea254d046 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -35,6 +35,7 @@ def abort_previous(){ def pre_test(){ sh'hostname' sh ''' + date sudo rmtaos || echo "taosd has not installed" ''' sh ''' @@ -98,7 +99,7 @@ pipeline { } stages { stage('pre_build'){ - agent{label 'slave3_0'} + agent{label " slave3_0 || slave15 || slave16 || slave17 "} options { skipDefaultCheckout() } when { changeRequest() From e06cdb087242721bcb8d81af999bce47efd23af4 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 15 Mar 2022 14:37:26 +0800 Subject: [PATCH 07/38] [td-13039] enable interval query on ordinary table. --- include/common/tcommon.h | 18 +- include/common/tdatablock.h | 2 +- source/common/src/tdatablock.c | 6 +- source/libs/executor/inc/executil.h | 20 +- source/libs/executor/inc/executorimpl.h | 6 +- source/libs/executor/src/executil.c | 147 +-------- source/libs/executor/src/executorimpl.c | 340 ++++++++++++--------- source/libs/executor/src/tsort.c | 13 +- source/libs/function/src/builtinsimpl.c | 4 - source/libs/planner/src/planLogicCreater.c | 7 +- 10 files changed, 236 insertions(+), 327 deletions(-) diff --git a/include/common/tcommon.h b/include/common/tcommon.h index b5bd088006..579b1bc46d 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -54,10 +54,11 @@ typedef struct SColumnDataAgg { } SColumnDataAgg; typedef struct SDataBlockInfo { - STimeWindow window; - int32_t rows; - int32_t rowSize; - int32_t numOfCols; + STimeWindow window; + int32_t rows; + int32_t rowSize; + int16_t numOfCols; + int16_t hasVarCol; union {int64_t uid; int64_t blockId;}; } SDataBlockInfo; @@ -96,13 +97,15 @@ typedef struct SColumnInfoData { static FORCE_INLINE int32_t tEncodeDataBlock(void** buf, const SSDataBlock* pBlock) { int64_t tbUid = pBlock->info.uid; - int32_t numOfCols = pBlock->info.numOfCols; + int16_t numOfCols = pBlock->info.numOfCols; + int16_t hasVarCol = pBlock->info.hasVarCol; int32_t rows = pBlock->info.rows; int32_t sz = taosArrayGetSize(pBlock->pDataBlock); int32_t tlen = 0; tlen += taosEncodeFixedI64(buf, tbUid); - tlen += taosEncodeFixedI32(buf, numOfCols); + tlen += taosEncodeFixedI16(buf, numOfCols); + tlen += taosEncodeFixedI16(buf, hasVarCol); tlen += taosEncodeFixedI32(buf, rows); tlen += taosEncodeFixedI32(buf, sz); for (int32_t i = 0; i < sz; i++) { @@ -120,7 +123,8 @@ static FORCE_INLINE void* tDecodeDataBlock(const void* buf, SSDataBlock* pBlock) int32_t sz; buf = taosDecodeFixedI64(buf, &pBlock->info.uid); - buf = taosDecodeFixedI32(buf, &pBlock->info.numOfCols); + buf = taosDecodeFixedI16(buf, &pBlock->info.numOfCols); + buf = taosDecodeFixedI16(buf, &pBlock->info.hasVarCol); buf = taosDecodeFixedI32(buf, &pBlock->info.rows); buf = taosDecodeFixedI32(buf, &sz); pBlock->pDataBlock = taosArrayInit(sz, sizeof(SColumnInfoData)); diff --git a/include/common/tdatablock.h b/include/common/tdatablock.h index c2249f408a..7e60013aa1 100644 --- a/include/common/tdatablock.h +++ b/include/common/tdatablock.h @@ -117,7 +117,7 @@ int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullF int32_t blockDataEnsureColumnCapacity(SColumnInfoData* pColumn, uint32_t numOfRows); int32_t blockDataEnsureCapacity(SSDataBlock* pDataBlock, uint32_t numOfRows); -void blockDataClearup(SSDataBlock* pDataBlock, bool hasVarCol); +void blockDataClearup(SSDataBlock* pDataBlock); SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock); size_t blockDataGetCapacityInRow(const SSDataBlock* pBlock, size_t pageSize); void* blockDataDestroy(SSDataBlock* pBlock); diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 4070224ab8..7e4f1d9025 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -1059,10 +1059,10 @@ int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullF // destroyTupleIndex(index); } -void blockDataClearup(SSDataBlock* pDataBlock, bool hasVarCol) { +void blockDataClearup(SSDataBlock* pDataBlock) { pDataBlock->info.rows = 0; - if (hasVarCol) { + if (pDataBlock->info.hasVarCol) { for (int32_t i = 0; i < pDataBlock->info.numOfCols; ++i) { SColumnInfoData* p = taosArrayGet(pDataBlock->pDataBlock, i); @@ -1148,7 +1148,9 @@ SSDataBlock* createOneDataBlock(const SSDataBlock* pDataBlock) { SSDataBlock* pBlock = calloc(1, sizeof(SSDataBlock)); pBlock->pDataBlock = taosArrayInit(numOfCols, sizeof(SColumnInfoData)); + pBlock->info.numOfCols = numOfCols; + pBlock->info.hasVarCol = pDataBlock->info.hasVarCol; for(int32_t i = 0; i < numOfCols; ++i) { SColumnInfoData colInfo = {0}; diff --git a/source/libs/executor/inc/executil.h b/source/libs/executor/inc/executil.h index b34067ba4e..bcbfeb7015 100644 --- a/source/libs/executor/inc/executil.h +++ b/source/libs/executor/inc/executil.h @@ -50,7 +50,7 @@ typedef struct SGroupResInfo { int32_t totalGroup; int32_t currentGroup; int32_t index; - SArray* pRows; // SArray + SArray* pRows; // SArray bool ordered; int32_t position; } SGroupResInfo; @@ -67,10 +67,15 @@ typedef struct SResultRow { char *key; // start key of current result row } SResultRow; +typedef struct SResultRowPosition { + int32_t pageId; + int32_t offset; +} SResultRowPosition; + typedef struct SResultRowInfo { - SList* pRows; - SResultRow** pResult; // result list -// int16_t type:8; // data type for hash key + SList *pRows; + SResultRowPosition *pPosition; + SResultRow **pResult; // result list int32_t size; // number of result set int32_t capacity; // max capacity int32_t curPos; // current active result row index of pResult list @@ -131,7 +136,7 @@ static FORCE_INLINE char* getPosInResultPage_rv(SFilePage* page, int32_t rowOffs assert(rowOffset >= 0); int32_t numOfRows = 1;//(int32_t)getRowNumForMultioutput(pQueryAttr, pQueryAttr->topBotQuery, pQueryAttr->stableQuery); - return ((char *)page->data) + rowOffset + offset * numOfRows; + return (char*) page + rowOffset + offset * numOfRows; } //bool isNullOperator(SColumnFilterElem *pFilter, const char* minval, const char* maxval, int16_t type); @@ -139,12 +144,7 @@ static FORCE_INLINE char* getPosInResultPage_rv(SFilePage* page, int32_t rowOffs __filter_func_t getFilterOperator(int32_t lowerOptr, int32_t upperOptr); -SResultRowPool* initResultRowPool(size_t size); SResultRow* getNewResultRow(SResultRowPool* p); -int64_t getResultRowPoolMemSize(SResultRowPool* p); -void* destroyResultRowPool(SResultRowPool* p); -int32_t getNumOfAllocatedResultRows(SResultRowPool* p); -int32_t getNumOfUsedResultRows(SResultRowPool* p); typedef struct { SArray* pResult; // SArray diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 351903dfdc..97a51a46ce 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -463,7 +463,7 @@ typedef struct SAggSupporter { SHashObj* pResultRowListSet; // used to check if current ResultRowInfo has ResultRow object or not SArray* pResultRowArrayList; // The array list that contains the Result rows char* keyBuf; // window key buffer - SResultRowPool *pool; // The window result objects pool, all the resultRow Objects are allocated and managed by this object. +// SResultRowPool *pool; // The window result objects pool, all the resultRow Objects are allocated and managed by this object. int32_t resultRowSize; // the result buffer size for each result row, with the meta data size for each row } SAggSupporter; @@ -678,8 +678,8 @@ SSDataBlock* createOutputBuf(SExprInfo* pExpr, int32_t numOfOutput, int32_t numO void* doDestroyFilterInfo(SSingleColumnFilterInfo* pFilterInfo, int32_t numOfFilterCols); void setInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SSDataBlock* pBlock, int32_t order); -void finalizeQueryResult(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SResultRowInfo* pResultRowInfo, - int32_t* rowCellInfoOffset); +void finalizeQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput); + void clearOutputBuf(SOptrBasicInfo* pBInfo, int32_t* bufCapacity); void copyTsColoum(SSDataBlock* pRes, SqlFunctionCtx* pCtx, int32_t numOfOutput); diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 9d77e23d38..a04a10ef95 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -59,7 +59,8 @@ int32_t initResultRowInfo(SResultRowInfo *pResultRowInfo, int32_t size) { pResultRowInfo->capacity = size; pResultRowInfo->pResult = calloc(pResultRowInfo->capacity, POINTER_BYTES); - if (pResultRowInfo->pResult == NULL) { + pResultRowInfo->pPosition = calloc(pResultRowInfo->capacity, sizeof(SResultRowPosition)); + if (pResultRowInfo->pResult == NULL || pResultRowInfo->pPosition == NULL) { return TSDB_CODE_QRY_OUT_OF_MEMORY; } @@ -182,22 +183,6 @@ size_t getResultRowSize(SqlFunctionCtx* pCtx, int32_t numOfOutput) { return rowSize; } -SResultRowPool* initResultRowPool(size_t size) { - SResultRowPool* p = calloc(1, sizeof(SResultRowPool)); - if (p == NULL) { - return NULL; - } - - p->numOfElemPerBlock = 128; - - p->elemSize = (int32_t) size; - p->blockSize = p->numOfElemPerBlock * p->elemSize; - p->position.pos = 0; - - p->pData = taosArrayInit(8, POINTER_BYTES); - return p; -} - SResultRow* getNewResultRow(SResultRowPool* p) { if (p == NULL) { return NULL; @@ -221,132 +206,6 @@ SResultRow* getNewResultRow(SResultRowPool* p) { return ptr; } -int64_t getResultRowPoolMemSize(SResultRowPool* p) { - if (p == NULL) { - return 0; - } - - return taosArrayGetSize(p->pData) * p->blockSize; -} - -int32_t getNumOfAllocatedResultRows(SResultRowPool* p) { - return (int32_t) taosArrayGetSize(p->pData) * p->numOfElemPerBlock; -} - -int32_t getNumOfUsedResultRows(SResultRowPool* p) { - return getNumOfAllocatedResultRows(p) - p->numOfElemPerBlock + p->position.pos; -} - -void* destroyResultRowPool(SResultRowPool* p) { - if (p == NULL) { - return NULL; - } - - size_t size = taosArrayGetSize(p->pData); - for(int32_t i = 0; i < size; ++i) { - void** ptr = taosArrayGet(p->pData, i); - tfree(*ptr); - } - - taosArrayDestroy(p->pData); - - tfree(p); - return NULL; -} - -void interResToBinary(SBufferWriter* bw, SArray* pRes, int32_t tagLen) { - uint32_t numOfGroup = (uint32_t) taosArrayGetSize(pRes); - tbufWriteUint32(bw, numOfGroup); - tbufWriteUint16(bw, tagLen); - - for(int32_t i = 0; i < numOfGroup; ++i) { - SInterResult* pOne = taosArrayGet(pRes, i); - if (tagLen > 0) { - tbufWriteBinary(bw, pOne->tags, tagLen); - } - - uint32_t numOfCols = (uint32_t) taosArrayGetSize(pOne->pResult); - tbufWriteUint32(bw, numOfCols); - for(int32_t j = 0; j < numOfCols; ++j) { - SStddevInterResult* p = taosArrayGet(pOne->pResult, j); - uint32_t numOfRows = (uint32_t) taosArrayGetSize(p->pResult); - - tbufWriteUint16(bw, p->colId); - tbufWriteUint32(bw, numOfRows); - - for(int32_t k = 0; k < numOfRows; ++k) { -// SResPair v = *(SResPair*) taosArrayGet(p->pResult, k); -// tbufWriteDouble(bw, v.avg); -// tbufWriteInt64(bw, v.key); - } - } - } -} - -SArray* interResFromBinary(const char* data, int32_t len) { - SBufferReader br = tbufInitReader(data, len, false); - uint32_t numOfGroup = tbufReadUint32(&br); - uint16_t tagLen = tbufReadUint16(&br); - - char* tag = NULL; - if (tagLen > 0) { - tag = calloc(1, tagLen); - } - - SArray* pResult = taosArrayInit(4, sizeof(SInterResult)); - - for(int32_t i = 0; i < numOfGroup; ++i) { - if (tagLen > 0) { - memset(tag, 0, tagLen); - tbufReadToBinary(&br, tag, tagLen); - } - - uint32_t numOfCols = tbufReadUint32(&br); - - SArray* p = taosArrayInit(numOfCols, sizeof(SStddevInterResult)); - for(int32_t j = 0; j < numOfCols; ++j) { -// int16_t colId = tbufReadUint16(&br); - int32_t numOfRows = tbufReadUint32(&br); - -// SStddevInterResult interRes = {.colId = colId, .pResult = taosArrayInit(4, sizeof(struct SResPair)),}; - for(int32_t k = 0; k < numOfRows; ++k) { -// SResPair px = {0}; -// px.avg = tbufReadDouble(&br); -// px.key = tbufReadInt64(&br); -// -// taosArrayPush(interRes.pResult, &px); - } - -// taosArrayPush(p, &interRes); - } - - char* p1 = NULL; - if (tagLen > 0) { - p1 = malloc(tagLen); - memcpy(p1, tag, tagLen); - } - - SInterResult d = {.pResult = p, .tags = p1,}; - taosArrayPush(pResult, &d); - } - - tfree(tag); - return pResult; -} - -void freeInterResult(void* param) { - SInterResult* pResult = (SInterResult*) param; - tfree(pResult->tags); - - int32_t numOfCols = (int32_t) taosArrayGetSize(pResult->pResult); - for(int32_t i = 0; i < numOfCols; ++i) { - SStddevInterResult *p = taosArrayGet(pResult->pResult, i); - taosArrayDestroy(p->pResult); - } - - taosArrayDestroy(pResult->pResult); -} - void cleanupGroupResInfo(SGroupResInfo* pGroupResInfo) { assert(pGroupResInfo != NULL); @@ -360,7 +219,7 @@ void initGroupResInfo(SGroupResInfo* pGroupResInfo, SResultRowInfo* pResultInfo) taosArrayDestroy(pGroupResInfo->pRows); } - pGroupResInfo->pRows = taosArrayFromList(pResultInfo->pResult, pResultInfo->size, POINTER_BYTES); + pGroupResInfo->pRows = taosArrayFromList(pResultInfo->pPosition, pResultInfo->size, sizeof(SResultRowPosition)); pGroupResInfo->index = 0; assert(pGroupResInfo->index <= getNumOfTotalRes(pGroupResInfo)); } diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 9d3a80d7b4..ef2dbea4fd 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -26,15 +26,16 @@ #include "tsort.h" #include "ttime.h" +#include "../../function/inc/taggfunction.h" #include "executorimpl.h" #include "function.h" +#include "query.h" #include "tcompare.h" #include "tcompression.h" #include "thash.h" -#include "ttypes.h" -#include "query.h" -#include "vnode.h" #include "tsdb.h" +#include "ttypes.h" +#include "vnode.h" #define IS_MAIN_SCAN(runtime) ((runtime)->scanFlag == MAIN_SCAN) #define IS_REVERSE_SCAN(runtime) ((runtime)->scanFlag == REVERSE_SCAN) @@ -235,7 +236,7 @@ static int32_t operatorDummyOpenFn(SOperatorInfo *pOperator) { static void operatorDummyCloseFn(void* param, int32_t numOfCols) {} -static int32_t doCopyToSDataBlock(SDiskbasedBuf *pBuf, SGroupResInfo* pGroupResInfo, int32_t orderType, SSDataBlock* pBlock, int32_t rowCapacity); +static int32_t doCopyToSDataBlock(SDiskbasedBuf *pBuf, SGroupResInfo* pGroupResInfo, int32_t orderType, SSDataBlock* pBlock, int32_t rowCapacity, int32_t* rowCellOffset); static int32_t getGroupbyColumnIndex(SGroupbyExpr *pGroupbyExpr, SSDataBlock* pDataBlock); static int32_t setGroupResultOutputBuf(STaskRuntimeEnv *pRuntimeEnv, SOptrBasicInfo *binf, int32_t numOfCols, char *pData, int16_t type, int16_t bytes, int32_t groupIndex); @@ -444,10 +445,12 @@ static void prepareResultListBuffer(SResultRowInfo* pResultRowInfo, jmp_buf env) longjmp(env, TSDB_CODE_QRY_OUT_OF_MEMORY); } + pResultRowInfo->pPosition = realloc(pResultRowInfo->pPosition, newCapacity * sizeof(SResultRowPosition)); pResultRowInfo->pResult = (SResultRow **)t; int32_t inc = (int32_t)newCapacity - pResultRowInfo->capacity; memset(&pResultRowInfo->pResult[pResultRowInfo->capacity], 0, POINTER_BYTES * inc); + memset(&pResultRowInfo->pPosition[pResultRowInfo->capacity], 0, sizeof(SResultRowPosition)); pResultRowInfo->capacity = (int32_t)newCapacity; } @@ -564,7 +567,47 @@ static SResultRow* doSetResultOutBufByKey(STaskRuntimeEnv* pRuntimeEnv, SResultR return pResultRowInfo->pResult[pResultRowInfo->curPos]; } -static SResultRow* doSetResultOutBufByKey_rv(SResultRowInfo* pResultRowInfo, int64_t tid, char* pData, int16_t bytes, +SResultRow* getNewResultRow_rv(SDiskbasedBuf* pResultBuf, int64_t tableGroupId, int32_t interBufSize) { + SFilePage *pData = NULL; + + // in the first scan, new space needed for results + int32_t pageId = -1; + SIDList list = getDataBufPagesIdList(pResultBuf, tableGroupId); + + if (taosArrayGetSize(list) == 0) { + pData = getNewBufPage(pResultBuf, tableGroupId, &pageId); + pData->num = sizeof(SFilePage); + } else { + SPageInfo* pi = getLastPageInfo(list); + pData = getBufPage(pResultBuf, getPageId(pi)); + pageId = getPageId(pi); + + if (pData->num + interBufSize + sizeof(SResultRow) > getBufPageSize(pResultBuf)) { + // release current page first, and prepare the next one + releaseBufPageInfo(pResultBuf, pi); + + pData = getNewBufPage(pResultBuf, tableGroupId, &pageId); + if (pData != NULL) { + pData->num = sizeof(SFilePage); + } + } + } + + if (pData == NULL) { + return NULL; + } + + // set the number of rows in current disk page + SResultRow* pResultRow = (SResultRow*)((char*)pData + pData->num); + pResultRow->pageId = pageId; + pResultRow->offset = (int32_t)pData->num; + + pData->num += interBufSize + sizeof(SResultRow); + + return pResultRow; +} + +static SResultRow* doSetResultOutBufByKey_rv(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo, int64_t tid, char* pData, int16_t bytes, bool masterscan, uint64_t tableGroupId, SExecTaskInfo* pTaskInfo, bool isIntervalQuery, SAggSupporter* pSup) { bool existed = false; SET_RES_WINDOW_KEY(pSup->keyBuf, pData, bytes, tableGroupId); @@ -608,7 +651,7 @@ static SResultRow* doSetResultOutBufByKey_rv(SResultRowInfo* pResultRowInfo, int SResultRow *pResult = NULL; if (p1 == NULL) { - pResult = getNewResultRow(pSup->pool); + pResult = getNewResultRow_rv(pResultBuf, tableGroupId, pSup->resultRowSize); int32_t ret = initResultRow(pResult); if (ret != TSDB_CODE_SUCCESS) { longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); @@ -623,6 +666,7 @@ static SResultRow* doSetResultOutBufByKey_rv(SResultRowInfo* pResultRowInfo, int } pResultRowInfo->curPos = pResultRowInfo->size; + pResultRowInfo->pPosition[pResultRowInfo->size] = (SResultRowPosition) {.pageId = pResult->pageId, .offset = pResult->offset}; pResultRowInfo->pResult[pResultRowInfo->size++] = pResult; int64_t index = pResultRowInfo->curPos; @@ -742,6 +786,7 @@ static int32_t addNewWindowResultBuf(SResultRow *pWindowRes, SDiskbasedBuf *pRes if (taosArrayGetSize(list) == 0) { pData = getNewBufPage(pResultBuf, tid, &pageId); + pData->num = sizeof(SFilePage); } else { SPageInfo* pi = getLastPageInfo(list); pData = getBufPage(pResultBuf, getPageId(pi)); @@ -750,9 +795,10 @@ static int32_t addNewWindowResultBuf(SResultRow *pWindowRes, SDiskbasedBuf *pRes if (pData->num + size > getBufPageSize(pResultBuf)) { // release current page first, and prepare the next one releaseBufPageInfo(pResultBuf, pi); + pData = getNewBufPage(pResultBuf, tid, &pageId); if (pData != NULL) { - assert(pData->num == 0); // number of elements must be 0 for new allocated buffer + pData->num = sizeof(SFilePage); } } } @@ -814,7 +860,7 @@ static int32_t setResultOutputBufByKey_rv(SResultRowInfo *pResultRowInfo, int64_ bool masterscan, SResultRow **pResult, int64_t tableGroupId, SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowCellInfoOffset, SDiskbasedBuf *pBuf, SAggSupporter *pAggSup, SExecTaskInfo* pTaskInfo) { assert(win->skey <= win->ekey); - SResultRow *pResultRow = doSetResultOutBufByKey_rv(pResultRowInfo, id, (char *)&win->skey, TSDB_KEYSIZE, masterscan, tableGroupId, + SResultRow *pResultRow = doSetResultOutBufByKey_rv(pBuf, pResultRowInfo, id, (char *)&win->skey, TSDB_KEYSIZE, masterscan, tableGroupId, pTaskInfo, true, pAggSup); if (pResultRow == NULL) { @@ -822,19 +868,10 @@ static int32_t setResultOutputBufByKey_rv(SResultRowInfo *pResultRowInfo, int64_ return TSDB_CODE_SUCCESS; } - // not assign result buffer yet, add new result buffer - if (pResultRow->pageId == -1) { // todo intermediate result size - int32_t ret = addNewWindowResultBuf(pResultRow, pBuf, (int32_t) tableGroupId, 0); - if (ret != TSDB_CODE_SUCCESS) { - return -1; - } - } - // set time window for current result pResultRow->win = (*win); *pResult = pResultRow; setResultRowOutputBufInitCtx_rv(pBuf, pResultRow, pCtx, numOfOutput, rowCellInfoOffset); - return TSDB_CODE_SUCCESS; } @@ -988,17 +1025,18 @@ static int32_t getNumOfRowsInTimeWindow(SDataBlockInfo *pDataBlockInfo, TSKEY *p } static void doApplyFunctions(SqlFunctionCtx* pCtx, STimeWindow* pWin, int32_t offset, int32_t forwardStep, TSKEY* tsCol, - int32_t numOfTotal, int32_t numOfOutput, int32_t order) { + int32_t numOfTotal, int32_t numOfOutput, int32_t order) { for (int32_t k = 0; k < numOfOutput; ++k) { - pCtx[k].size = forwardStep; pCtx[k].startTs = pWin->skey; // keep it temporarialy - int32_t startOffset = pCtx[k].startRow; - bool hasAgg = pCtx[k].isAggSet; + int32_t startOffset = pCtx[k].input.startRowIndex; + bool hasAgg = pCtx[k].input.colDataAggIsSet; + int32_t numOfRows = pCtx[k].input.numOfRows; int32_t pos = (order == TSDB_ORDER_ASC) ? offset : offset - (forwardStep - 1); - pCtx[k].startRow = pos; + pCtx[k].input.startRowIndex = pos; + pCtx[k].input.numOfRows = forwardStep; if (tsCol != NULL) { pCtx[k].ptsList = &tsCol[pos]; @@ -1011,12 +1049,13 @@ static void doApplyFunctions(SqlFunctionCtx* pCtx, STimeWindow* pWin, int32_t of } if (functionNeedToExecute(&pCtx[k])) { -// pCtx[k].fpSet.process(&pCtx[k]); + pCtx[k].fpSet.process(&pCtx[k]); } // restore it - pCtx[k].isAggSet = hasAgg; - pCtx[k].startRow = startOffset; + pCtx[k].input.colDataAggIsSet = hasAgg; + pCtx[k].input.startRowIndex = startOffset; + pCtx[k].input.numOfRows = numOfRows; } } @@ -1440,8 +1479,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul if (pSDataBlock->pDataBlock != NULL) { SColumnInfoData* pColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, 0); tsCols = (int64_t*) pColDataInfo->pData; - assert(tsCols[0] == pSDataBlock->info.window.skey && - tsCols[pSDataBlock->info.rows - 1] == pSDataBlock->info.window.ekey); + assert(tsCols[0] == pSDataBlock->info.window.skey && tsCols[pSDataBlock->info.rows - 1] == pSDataBlock->info.window.ekey); } int32_t startPos = ascQuery? 0 : (pSDataBlock->info.rows - 1); @@ -1533,7 +1571,6 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul // updateResultRowInfoActiveIndex(pResultRowInfo, &pInfo->win, pRuntimeEnv->current->lastKey, true, false); } - static void hashAllIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResultRowInfo, SSDataBlock* pSDataBlock, int32_t tableGroupId) { STableIntervalOperatorInfo* pInfo = (STableIntervalOperatorInfo*) pOperatorInfo->info; @@ -3276,10 +3313,9 @@ void switchCtxOrder(SqlFunctionCtx* pCtx, int32_t numOfOutput) { } } +// TODO fix this bug. int32_t initResultRow(SResultRow *pResultRow) { pResultRow->pEntryInfo = (struct SResultRowEntryInfo*)((char*)pResultRow + sizeof(SResultRow)); - pResultRow->pageId = -1; - pResultRow->offset = -1; return TSDB_CODE_SUCCESS; } @@ -3335,7 +3371,7 @@ void setFunctionResultOutput(SOptrBasicInfo* pInfo, SAggSupporter* pSup, int32_t int64_t tid = 0; int64_t groupId = 0; - SResultRow* pRow = doSetResultOutBufByKey_rv(pResultRowInfo, tid, (char *)&tid, sizeof(tid), true, groupId, pTaskInfo, false, pSup); + SResultRow* pRow = doSetResultOutBufByKey_rv(NULL, pResultRowInfo, tid, (char *)&tid, sizeof(tid), true, groupId, pTaskInfo, false, pSup); for (int32_t i = 0; i < pDataBlock->info.numOfCols; ++i) { SColumnInfoData* pData = taosArrayGet(pDataBlock->pDataBlock, i); @@ -3476,48 +3512,44 @@ static void setupEnvForReverseScan(STableScanInfo *pTableScanInfo, SqlFunctionCt pTableScanInfo->reverseTimes = 0; } -void finalizeQueryResult(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, SResultRowInfo* pResultRowInfo, int32_t* rowCellInfoOffset) { - int32_t numOfOutput = pOperator->numOfOutput; -// if (pQueryAttr->groupbyColumn || QUERY_IS_INTERVAL_QUERY(pQueryAttr) || pQueryAttr->sw.gap > 0 || pQueryAttr->stateWindow) { -// // for each group result, call the finalize function for each column -// if (pQueryAttr->groupbyColumn) { -// closeAllResultRows(pResultRowInfo); -// } -// -// for (int32_t i = 0; i < pResultRowInfo->size; ++i) { -// SResultRow *buf = pResultRowInfo->pResult[i]; -// if (!isResultRowClosed(pResultRowInfo, i)) { -// continue; -// } -// -// setResultOutputBuf(pRuntimeEnv, buf, pCtx, numOfOutput, rowCellInfoOffset); -// -// for (int32_t j = 0; j < numOfOutput; ++j) { -//// pCtx[j].startTs = buf->win.skey; -//// if (pCtx[j].functionId < 0) { -//// doInvokeUdf(pRuntimeEnv->pUdfInfo, &pCtx[j], 0, TSDB_UDF_FUNC_FINALIZE); -//// } else { -//// aAggs[pCtx[j].functionId].xFinalize(&pCtx[j]); -//// } -// } -// -// -// /* -// * set the number of output results for group by normal columns, the number of output rows usually is 1 except -// * the top and bottom query -// */ -// buf->numOfRows = (uint16_t)getNumOfResult(pCtx, numOfOutput); -// } -// -// } else { - for (int32_t j = 0; j < numOfOutput; ++j) { -// if (pCtx[j].functionId < 0) { -// doInvokeUdf(pRuntimeEnv->pUdfInfo, &pCtx[j], 0, TSDB_UDF_FUNC_FINALIZE); -// } else { - pCtx[j].fpSet.finalize(&pCtx[j]); -// } +void finalizeQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput) { + for (int32_t j = 0; j < numOfOutput; ++j) { + pCtx[j].fpSet.finalize(&pCtx[j]); + } +} + +void finalizeMultiTupleQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SDiskbasedBuf *pBuf, SResultRowInfo* pResultRowInfo, int32_t* rowCellInfoOffset) { + for (int32_t i = 0; i < pResultRowInfo->size; ++i) { + SResultRowPosition* pPos = &pResultRowInfo->pPosition[i]; + + SFilePage* bufPage = getBufPage(pBuf, pPos->pageId); + SResultRow* pRow = (SResultRow*)((char*)bufPage + pPos->offset); + if (!isResultRowClosed(pResultRowInfo, i)) { + continue; } -// } + + for (int32_t j = 0; j < numOfOutput; ++j) { + pCtx[j].resultInfo = getResultCell(pRow, j, rowCellInfoOffset); + + struct SResultRowEntryInfo* pResInfo = pCtx[i].resultInfo; + if (isRowEntryCompleted(pResInfo) && isRowEntryInitialized(pResInfo)) { + continue; + } + + pCtx[j].fpSet.finalize(&pCtx[j]); + + if (pRow->numOfRows < pResInfo->numOfRes) { + pRow->numOfRows = pResInfo->numOfRes; + } + } + + releaseBufPage(pBuf, bufPage); + /* + * set the number of output results for group by normal columns, the number of output rows usually is 1 except + * the top and bottom query + */ +// buf->numOfRows = (uint16_t)getNumOfResult(pCtx, numOfOutput); + } } static bool hasMainOutput(STaskAttr *pQueryAttr) { @@ -3612,31 +3644,29 @@ void setResultRowOutputBufInitCtx_rv(SDiskbasedBuf * pBuf, SResultRow *pResult, // Note: pResult->pos[i]->num == 0, there is only fixed number of results for each group SFilePage* bufPage = getBufPage(pBuf, pResult->pageId); - int32_t offset = 0; +// int32_t offset = 0; for (int32_t i = 0; i < numOfOutput; ++i) { pCtx[i].resultInfo = getResultCell(pResult, i, rowCellInfoOffset); struct SResultRowEntryInfo* pResInfo = pCtx[i].resultInfo; if (isRowEntryCompleted(pResInfo) && isRowEntryInitialized(pResInfo)) { - offset += pCtx[i].resDataInfo.bytes; +// offset += pCtx[i].resDataInfo.bytes; continue; } - pCtx[i].pOutput = getPosInResultPage_rv(bufPage, pResult->offset, offset); - offset += pCtx[i].resDataInfo.bytes; +// offset += pCtx[i].resDataInfo.bytes; - int32_t functionId = pCtx[i].functionId; - if (functionId < 0) { - continue; +// int32_t functionId = pCtx[i].functionId; +// if (functionId < 0) { +// continue; +// } +// if (functionId == FUNCTION_TOP || functionId == FUNCTION_BOTTOM || functionId == FUNCTION_DIFF) { +// if (i > 0) pCtx[i].ptsOutputBuf = pCtx[i - 1].pOutput; +// } + + if (!pResInfo->initialized) { + pCtx[i].fpSet.init(&pCtx[i], pResInfo); } - - if (functionId == FUNCTION_TOP || functionId == FUNCTION_BOTTOM || functionId == FUNCTION_DIFF) { - if (i > 0) pCtx[i].ptsOutputBuf = pCtx[i - 1].pOutput; - } - - // if (!pResInfo->initialized) { - // aAggs[functionId].init(&pCtx[i], pResInfo); - // } } } @@ -3650,7 +3680,7 @@ void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, i int32_t* rowCellInfoOffset = pAggInfo->binfo.rowCellInfoOffset; SResultRow* pResultRow = - doSetResultOutBufByKey_rv(pResultRowInfo, tid, (char*)&tableGroupId, sizeof(tableGroupId), true, uid, pTaskInfo, false, &pAggInfo->aggSup); + doSetResultOutBufByKey_rv(pAggInfo->pResultBuf, pResultRowInfo, tid, (char*)&tableGroupId, sizeof(tableGroupId), true, uid, pTaskInfo, false, &pAggInfo->aggSup); assert (pResultRow != NULL); /* @@ -3891,8 +3921,7 @@ void setIntervalQueryRange(STaskRuntimeEnv *pRuntimeEnv, TSKEY key) { * @param pQInfo * @param result */ - -static int32_t doCopyToSDataBlock(SDiskbasedBuf *pBuf, SGroupResInfo* pGroupResInfo, int32_t orderType, SSDataBlock* pBlock, int32_t rowCapacity) { +static int32_t doCopyToSDataBlock(SDiskbasedBuf *pBuf, SGroupResInfo* pGroupResInfo, int32_t orderType, SSDataBlock* pBlock, int32_t rowCapacity, int32_t* rowCellOffset) { int32_t numOfRows = getNumOfTotalRes(pGroupResInfo); int32_t numOfResult = pBlock->info.rows; // there are already exists result rows @@ -3910,13 +3939,19 @@ static int32_t doCopyToSDataBlock(SDiskbasedBuf *pBuf, SGroupResInfo* pGroupResI step = -1; } + int32_t nrows = pBlock->info.rows; + for (int32_t i = start; (i < numOfRows) && (i >= 0); i += step) { - SResultRow* pRow = taosArrayGetP(pGroupResInfo->pRows, i); + SResultRowPosition* pPos = taosArrayGet(pGroupResInfo->pRows, i); + SFilePage *page = getBufPage(pBuf, pPos->pageId); + + SResultRow* pRow = (SResultRow*)((char*)page + pPos->offset); if (pRow->numOfRows == 0) { pGroupResInfo->index += 1; continue; } + // TODO copy multiple rows? int32_t numOfRowsToCopy = pRow->numOfRows; if (numOfResult + numOfRowsToCopy >= rowCapacity) { break; @@ -3924,20 +3959,17 @@ static int32_t doCopyToSDataBlock(SDiskbasedBuf *pBuf, SGroupResInfo* pGroupResI pGroupResInfo->index += 1; - SFilePage *page = getBufPage(pBuf, pRow->pageId); - - int32_t offset = 0; for (int32_t j = 0; j < pBlock->info.numOfCols; ++j) { SColumnInfoData* pColInfoData = taosArrayGet(pBlock->pDataBlock, j); - int32_t bytes = pColInfoData->info.bytes; + SResultRowEntryInfo* pEntryInfo = getResultCell(pRow, j, rowCellOffset); - char *out = pColInfoData->pData + numOfResult * bytes; - char *in = getPosInResultPage_rv(page, pRow->offset, offset); - memcpy(out, in, bytes * numOfRowsToCopy); - - offset += bytes; + char* in = GET_ROWCELL_INTERBUF(pEntryInfo); + colDataAppend(pColInfoData, nrows, in, pEntryInfo->numOfRes == 0); } + releaseBufPage(pBuf, page); + nrows += 1; + numOfResult += numOfRowsToCopy; if (numOfResult == rowCapacity) { // output buffer is full break; @@ -3949,16 +3981,16 @@ static int32_t doCopyToSDataBlock(SDiskbasedBuf *pBuf, SGroupResInfo* pGroupResI return 0; } -static void toSDatablock(SGroupResInfo *pGroupResInfo, SDiskbasedBuf* pBuf, SSDataBlock* pBlock, int32_t rowCapacity) { +static void toSDatablock(SGroupResInfo *pGroupResInfo, SDiskbasedBuf* pBuf, SSDataBlock* pBlock, int32_t rowCapacity, int32_t* rowCellOffset) { assert(pGroupResInfo->currentGroup <= pGroupResInfo->totalGroup); - pBlock->info.rows = 0; + blockDataClearup(pBlock); if (!hasRemainDataInCurrentGroup(pGroupResInfo)) { return; } int32_t orderType = TSDB_ORDER_ASC;//(pQueryAttr->pGroupbyExpr != NULL) ? pQueryAttr->pGroupbyExpr->orderType : TSDB_ORDER_ASC; - doCopyToSDataBlock(pBuf, pGroupResInfo, orderType, pBlock, rowCapacity); + doCopyToSDataBlock(pBuf, pGroupResInfo, orderType, pBlock, rowCapacity, rowCellOffset); // add condition (pBlock->info.rows >= 1) just to runtime happy blockDataUpdateTsWindow(pBlock); @@ -5173,9 +5205,8 @@ static SSDataBlock* doLoadRemoteData(SOperatorInfo *pOperator, bool* newgroup) { SExchangeInfo *pExchangeInfo = pOperator->info; SExecTaskInfo *pTaskInfo = pOperator->pTaskInfo; - int32_t code = pOperator->_openFn(pOperator); - if (code != TSDB_CODE_SUCCESS) { - pTaskInfo->code = code; + pTaskInfo->code = pOperator->_openFn(pOperator); + if (pTaskInfo->code != TSDB_CODE_SUCCESS) { return NULL; } @@ -5761,7 +5792,7 @@ static void appendOneRowToDataBlock(SSDataBlock *pBlock, STupleHandle* pTupleHan } static SSDataBlock* getSortedBlockData(SSortHandle* pHandle, SSDataBlock* pDataBlock, bool hasVarCol, int32_t capacity) { - blockDataClearup(pDataBlock, hasVarCol); + blockDataClearup(pDataBlock); while(1) { STupleHandle* pTupleHandle = tsortNextTuple(pHandle); @@ -5917,7 +5948,7 @@ static SSDataBlock* doMerge(SOperatorInfo* pOperator) { while(1) { - blockDataClearup(pDataBlock, pInfo->hasVarCol); + blockDataClearup(pDataBlock); while (1) { STupleHandle* pTupleHandle = tsortNextTuple(pHandle); if (pTupleHandle == NULL) { @@ -6234,7 +6265,7 @@ static int32_t doOpenAggregateOptr(SOperatorInfo *pOperator) { doAggregateImpl(pOperator, 0, pInfo->pCtx); } - finalizeQueryResult(pOperator, pInfo->pCtx, &pInfo->resultRowInfo, pInfo->rowCellInfoOffset); + finalizeQueryResult(pInfo->pCtx, pOperator->numOfOutput); OPTR_SET_OPENED(pOperator); return TSDB_CODE_SUCCESS; @@ -6270,7 +6301,7 @@ static SSDataBlock* doMultiTableAggregate(SOperatorInfo *pOperator, bool* newgro SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; if (pOperator->status == OP_RES_TO_RETURN) { - toSDatablock(&pAggInfo->groupResInfo, pAggInfo->pResultBuf, pInfo->pRes, pAggInfo->binfo.capacity); + toSDatablock(&pAggInfo->groupResInfo, pAggInfo->pResultBuf, pInfo->pRes, pAggInfo->binfo.capacity, pAggInfo->binfo.rowCellInfoOffset); if (pInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pAggInfo->groupResInfo)) { pOperator->status = OP_EXEC_DONE; @@ -6319,7 +6350,7 @@ static SSDataBlock* doMultiTableAggregate(SOperatorInfo *pOperator, bool* newgro updateNumOfRowsInResultRows(pInfo->pCtx, pOperator->numOfOutput, &pInfo->resultRowInfo, pInfo->rowCellInfoOffset); initGroupResInfo(&pAggInfo->groupResInfo, &pInfo->resultRowInfo); - toSDatablock(&pAggInfo->groupResInfo, pAggInfo->pResultBuf, pInfo->pRes, pAggInfo->binfo.capacity); + toSDatablock(&pAggInfo->groupResInfo, pAggInfo->pResultBuf, pInfo->pRes, pAggInfo->binfo.capacity, pAggInfo->binfo.rowCellInfoOffset); if (pInfo->pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pAggInfo->groupResInfo)) { doSetOperatorCompleted(pOperator); @@ -6333,7 +6364,7 @@ static SSDataBlock* doProjectOperation(SOperatorInfo *pOperator, bool* newgroup) SOptrBasicInfo *pInfo = &pProjectInfo->binfo; SSDataBlock* pRes = pInfo->pRes; - blockDataClearup(pRes, pProjectInfo->hasVarCol); + blockDataClearup(pRes); if (pProjectInfo->existDataBlock) { // TODO refactor // STableQueryInfo* pTableQueryInfo = pRuntimeEnv->current; @@ -6496,53 +6527,57 @@ static SSDataBlock* doFilter(void* param, bool* newgroup) { return NULL; } -static SSDataBlock* doIntervalAgg(SOperatorInfo *pOperator, bool* newgroup) { - if (pOperator->status == OP_EXEC_DONE) { - return NULL; +static int32_t doOpenIntervalAgg(SOperatorInfo *pOperator) { + if (OPTR_IS_OPENED(pOperator)) { + return TSDB_CODE_SUCCESS; } STableIntervalOperatorInfo* pInfo = pOperator->info; - if (pOperator->status == OP_RES_TO_RETURN) { -// toSDatablock(pAggInfo->pGroupResInfo, pAggInfo->pResultBuf, pInfo->pRes, pAggInfo->binfo.capacity); - if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) { - doSetOperatorCompleted(pOperator); - } - - return pInfo->binfo.pRes; - } - -// int32_t order = pQueryAttr->order.order; -// STimeWindow win = pQueryAttr->window; + // int32_t order = pQueryAttr->order.order; + // STimeWindow win = pQueryAttr->window; + bool newgroup = false; SOperatorInfo* downstream = pOperator->pDownstream[0]; - while(1) { + while (1) { publishOperatorProfEvent(downstream, QUERY_PROF_BEFORE_OPERATOR_EXEC); - SSDataBlock* pBlock = downstream->getNextFn(downstream, newgroup); + SSDataBlock* pBlock = downstream->getNextFn(downstream, &newgroup); publishOperatorProfEvent(downstream, QUERY_PROF_AFTER_OPERATOR_EXEC); if (pBlock == NULL) { break; } -// setTagValue(pOperator, pRuntimeEnv->current->pTable, pInfo->pCtx, pOperator->numOfOutput); + // setTagValue(pOperator, pRuntimeEnv->current->pTable, pInfo->pCtx, pOperator->numOfOutput); // the pDataBlock are always the same one, no need to call this again setInputDataBlock(pOperator, pInfo->binfo.pCtx, pBlock, TSDB_ORDER_ASC); hashIntervalAgg(pOperator, &pInfo->binfo.resultRowInfo, pBlock, 0); } - // restore the value -// pQueryAttr->order.order = order; -// pQueryAttr->window = win; - - pOperator->status = OP_RES_TO_RETURN; closeAllResultRows(&pInfo->binfo.resultRowInfo); - setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED); - finalizeQueryResult(pOperator, pInfo->binfo.pCtx, &pInfo->binfo.resultRowInfo, pInfo->binfo.rowCellInfoOffset); + finalizeMultiTupleQueryResult(pInfo->binfo.pCtx, pOperator->numOfOutput, pInfo->pResultBuf, &pInfo->binfo.resultRowInfo, pInfo->binfo.rowCellInfoOffset); initGroupResInfo(&pInfo->groupResInfo, &pInfo->binfo.resultRowInfo); - toSDatablock(&pInfo->groupResInfo, pInfo->pResultBuf, pInfo->binfo.pRes, pInfo->binfo.capacity); + OPTR_SET_OPENED(pOperator); + return TSDB_CODE_SUCCESS; +} + +static SSDataBlock* doIntervalAgg(SOperatorInfo *pOperator, bool* newgroup) { + STableIntervalOperatorInfo* pInfo = pOperator->info; + SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo; + + if (pOperator->status == OP_EXEC_DONE) { + return NULL; + } + + pTaskInfo->code = pOperator->_openFn(pOperator); + if (pTaskInfo->code != TSDB_CODE_SUCCESS) { + return NULL; + } + + blockDataEnsureCapacity(pInfo->binfo.pRes, pInfo->binfo.capacity); + toSDatablock(&pInfo->groupResInfo, pInfo->pResultBuf, pInfo->binfo.pRes, pInfo->binfo.capacity, pInfo->binfo.rowCellInfoOffset); if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) { doSetOperatorCompleted(pOperator); @@ -6598,7 +6633,7 @@ static SSDataBlock* doAllIntervalAgg(SOperatorInfo *pOperator, bool* newgroup) { pOperator->status = OP_RES_TO_RETURN; closeAllResultRows(&pIntervalInfo->binfo.resultRowInfo); setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED); - finalizeQueryResult(pOperator, pIntervalInfo->binfo.pCtx, &pIntervalInfo->binfo.resultRowInfo, pIntervalInfo->binfo.rowCellInfoOffset); + finalizeQueryResult(pIntervalInfo->binfo.pCtx, pOperator->numOfOutput); initGroupResInfo(&pRuntimeEnv->groupResInfo, &pIntervalInfo->binfo.resultRowInfo); // toSDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pIntervalInfo->pRes); @@ -6847,7 +6882,7 @@ static SSDataBlock* doStateWindowAgg(SOperatorInfo *pOperator, bool* newgroup) { pOperator->status = OP_RES_TO_RETURN; closeAllResultRows(&pBInfo->resultRowInfo); setTaskStatus(pOperator->pTaskInfo, TASK_COMPLETED); - finalizeQueryResult(pOperator, pBInfo->pCtx, &pBInfo->resultRowInfo, pBInfo->rowCellInfoOffset); + finalizeQueryResult(pBInfo->pCtx, pOperator->numOfOutput); initGroupResInfo(&pRuntimeEnv->groupResInfo, &pBInfo->resultRowInfo); // toSDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pBInfo->pRes); @@ -6896,7 +6931,7 @@ static SSDataBlock* doSessionWindowAgg(SOperatorInfo *pOperator, bool* newgroup) pOperator->status = OP_RES_TO_RETURN; closeAllResultRows(&pBInfo->resultRowInfo); // setTaskStatus(pOperator->pTaskInfo, QUERY_COMPLETED); - finalizeQueryResult(pOperator, pBInfo->pCtx, &pBInfo->resultRowInfo, pBInfo->rowCellInfoOffset); + finalizeQueryResult(pBInfo->pCtx, pOperator->numOfOutput); // initGroupResInfo(&pBInfo->groupResInfo, &pBInfo->resultRowInfo); // toSDatablock(&pRuntimeEnv->groupResInfo, pRuntimeEnv, pBInfo->pRes); @@ -6950,7 +6985,7 @@ static SSDataBlock* hashGroupbyAggregate(SOperatorInfo *pOperator, bool* newgrou // setTaskStatus(pOperator->pTaskInfo, QUERY_COMPLETED); if (!pRuntimeEnv->pQueryAttr->stableQuery) { // finalize include the update of result rows - finalizeQueryResult(pOperator, pInfo->binfo.pCtx, &pInfo->binfo.resultRowInfo, pInfo->binfo.rowCellInfoOffset); + finalizeQueryResult(pInfo->binfo.pCtx, pOperator->numOfOutput); } else { updateNumOfRowsInResultRows(pInfo->binfo.pCtx, pOperator->numOfOutput, &pInfo->binfo.resultRowInfo, pInfo->binfo.rowCellInfoOffset); } @@ -7109,11 +7144,11 @@ int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx *pCtx, int32_t n pAggSup->keyBuf = calloc(1, sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES); pAggSup->pResultRowHashTable = taosHashInit(10, hashFn, true, HASH_NO_LOCK); pAggSup->pResultRowListSet = taosHashInit(100, hashFn, false, HASH_NO_LOCK); - pAggSup->pool = initResultRowPool(pAggSup->resultRowSize); +// pAggSup->pool = initResultRowPool(pAggSup->resultRowSize); pAggSup->pResultRowArrayList = taosArrayInit(10, sizeof(SResultRowCell)); if (pAggSup->keyBuf == NULL || pAggSup->pResultRowArrayList == NULL || pAggSup->pResultRowListSet == NULL || - pAggSup->pResultRowHashTable == NULL || pAggSup->pool == NULL) { + pAggSup->pResultRowHashTable == NULL) { return TSDB_CODE_OUT_OF_MEMORY; } @@ -7125,7 +7160,7 @@ static void cleanupAggSup(SAggSupporter* pAggSup) { taosHashCleanup(pAggSup->pResultRowHashTable); taosHashCleanup(pAggSup->pResultRowListSet); taosArrayDestroy(pAggSup->pResultRowArrayList); - destroyResultRowPool(pAggSup->pool); +// destroyResultRowPool(pAggSup->pool); } static int32_t initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, @@ -7448,7 +7483,7 @@ SOperatorInfo* createLimitOperatorInfo(SOperatorInfo* downstream, int32_t numOfD } SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pExprInfo, int32_t numOfCols, SSDataBlock* pResBlock, SInterval* pInterval, -const STableGroupInfo* pTableGroupInfo, SExecTaskInfo* pTaskInfo) { + const STableGroupInfo* pTableGroupInfo, SExecTaskInfo* pTaskInfo) { STableIntervalOperatorInfo* pInfo = calloc(1, sizeof(STableIntervalOperatorInfo)); SOperatorInfo* pOperator = calloc(1, sizeof(SOperatorInfo)); if (pInfo == NULL || pOperator == NULL) { @@ -7460,7 +7495,10 @@ const STableGroupInfo* pTableGroupInfo, SExecTaskInfo* pTaskInfo) { pInfo->win = pTaskInfo->window; pInfo->interval = *pInterval; - int32_t numOfRows = 1; + pInfo->win.skey = INT64_MIN; + pInfo->win.ekey = INT64_MAX; + + int32_t numOfRows = 4096; int32_t code = initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResBlock); // pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo); if (code != TSDB_CODE_SUCCESS/* || pInfo->pTableQueryInfo == NULL*/) { @@ -7483,7 +7521,7 @@ const STableGroupInfo* pTableGroupInfo, SExecTaskInfo* pTaskInfo) { pOperator->pTaskInfo = pTaskInfo; pOperator->numOfOutput = numOfCols; pOperator->info = pInfo; - pOperator->_openFn = operatorDummyOpenFn; + pOperator->_openFn = doOpenIntervalAgg; pOperator->getNextFn = doIntervalAgg; pOperator->closeFn = destroyIntervalOperatorInfo; @@ -8304,10 +8342,14 @@ SOperatorInfo* doCreateOperatorTreeNode(SPhysiNode* pPhyNode, SExecTaskInfo* pTa SPhysiNode* pChildNode = (SPhysiNode*)nodesListGetNode(pPhyNode->pChildren, i); SOperatorInfo* op = doCreateOperatorTreeNode(pChildNode, pTaskInfo, pHandle, queryId, taskId, pTableGroupInfo); + SIntervalPhysiNode* pIntervalPhyNode = (SIntervalPhysiNode*)pPhyNode; + int32_t num = 0; - SExprInfo* pExprInfo = createExprInfo(((SIntervalPhysiNode*)pPhyNode)->pFuncs, &num); + SExprInfo* pExprInfo = createExprInfo(pIntervalPhyNode->pFuncs, &num); SSDataBlock* pResBlock = createOutputBuf_rv1(pPhyNode->pOutputDataBlockDesc); - return createIntervalOperatorInfo(op, pExprInfo, num, pResBlock, NULL, pTableGroupInfo, pTaskInfo); + + SInterval interval = {.interval = pIntervalPhyNode->interval, .sliding = pIntervalPhyNode->sliding, .intervalUnit = 'a', .slidingUnit = 'a'}; + return createIntervalOperatorInfo(op, pExprInfo, num, pResBlock, &interval, pTableGroupInfo, pTaskInfo); } } /*else if (pPhyNode->info.type == OP_MultiTableAggregate) { size_t size = taosArrayGetSize(pPhyNode->pChildren); diff --git a/source/libs/executor/src/tsort.c b/source/libs/executor/src/tsort.c index 34dd248ba7..08bab762be 100644 --- a/source/libs/executor/src/tsort.c +++ b/source/libs/executor/src/tsort.c @@ -37,7 +37,6 @@ typedef struct SSortHandle { SArray *pOrderInfo; bool nullFirst; - bool hasVarCol; SArray *pOrderedSource; _sort_fetch_block_fn_t fetchfp; @@ -77,6 +76,10 @@ static SSDataBlock* createDataBlock_rv(SSchema* pSchema, int32_t numOfCols) { colInfo.info.bytes = pSchema[i].bytes; colInfo.info.colId = pSchema[i].colId; taosArrayPush(pBlock->pDataBlock, &colInfo); + + if (IS_VAR_DATA_TYPE(colInfo.info.type)) { + pBlock->info.hasVarCol = true; + } } return pBlock; @@ -155,7 +158,7 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) { while(start < pDataBlock->info.rows) { int32_t stop = 0; - blockDataSplitRows(pDataBlock, pHandle->hasVarCol, start, &stop, pHandle->pageSize); + blockDataSplitRows(pDataBlock, pDataBlock->info.hasVarCol, start, &stop, pHandle->pageSize); SSDataBlock* p = blockDataExtractBlock(pDataBlock, start, stop - start + 1); if (p == NULL) { return terrno; @@ -179,7 +182,7 @@ static int32_t doAddToBuf(SSDataBlock* pDataBlock, SSortHandle* pHandle) { start = stop + 1; } - blockDataClearup(pDataBlock, pHandle->hasVarCol); + blockDataClearup(pDataBlock); SSDataBlock* pBlock = createOneDataBlock(pDataBlock); int32_t code = doAddNewExternalMemSource(pHandle->pBuf, pHandle->pOrderedSource, pBlock, &pHandle->sourceId); @@ -309,7 +312,7 @@ static int32_t adjustMergeTreeForNextTuple(SExternalMemSource *pSource, SMultiwa } static SSDataBlock* getSortedBlockData(SSortHandle* pHandle, SMsortComparParam* cmpParam, int32_t capacity) { - blockDataClearup(pHandle->pDataBlock, pHandle->hasVarCol); + blockDataClearup(pHandle->pDataBlock); while(1) { if (cmpParam->numOfSources == pHandle->numOfCompletedSources) { @@ -475,7 +478,7 @@ static int32_t doInternalMergeSort(SSortHandle* pHandle) { setBufPageDirty(pPage, true); releaseBufPage(pHandle->pBuf, pPage); - blockDataClearup(pDataBlock, pHandle->hasVarCol); + blockDataClearup(pDataBlock); } tMergeTreeDestroy(pHandle->pMergeTree); diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index aaaee6d56c..78e0e9f8e7 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -52,10 +52,6 @@ static void doFinalizer(SResultRowEntryInfo* pResInfo) { cleanupResultRowEntry(p void functionFinalizer(SqlFunctionCtx *pCtx) { SResultRowEntryInfo* pResInfo = GET_RES_INFO(pCtx); - if (pResInfo->hasResult != DATA_SET_FLAG) { -// setNull(pCtx->pOutput, pCtx->resDataInfo.type, pCtx->resDataInfo.bytes); - } - doFinalizer(pResInfo); } diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 7520ea3c9e..3fae580de9 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -310,9 +310,12 @@ static SLogicNode* createWindowLogicNodeByInterval(SLogicPlanContext* pCxt, SInt pWindow->node.id = pCxt->planNodeId++; pWindow->winType = WINDOW_TYPE_INTERVAL; - pWindow->interval = ((SValueNode*)pInterval->pInterval)->datum.i; + SValueNode* pIntervalNode = (SValueNode*)((SRawExprNode*)(pInterval->pInterval))->pNode; + + pWindow->interval = pIntervalNode->datum.i; pWindow->offset = (NULL != pInterval->pOffset ? ((SValueNode*)pInterval->pOffset)->datum.i : 0); - pWindow->sliding = (NULL != pInterval->pSliding ? ((SValueNode*)pInterval->pSliding)->datum.i : 0); + pWindow->sliding = (NULL != pInterval->pSliding ? ((SValueNode*)pInterval->pSliding)->datum.i : pWindow->interval); + if (NULL != pInterval->pFill) { pWindow->pFill = nodesCloneNode(pInterval->pFill); CHECK_ALLOC(pWindow->pFill, (SLogicNode*)pWindow); From 2bcc139443e6e9ae9d9caffb1d0e051e97feff32 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Tue, 15 Mar 2022 14:56:33 +0800 Subject: [PATCH 08/38] add stream msg routing --- include/common/tmsg.h | 5 ++- include/dnode/snode/snode.h | 3 ++ source/dnode/mgmt/impl/src/dndSnode.c | 45 ++++++++++++++++++++++----- source/dnode/snode/inc/sndInt.h | 19 +++++------ 4 files changed, 54 insertions(+), 18 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 5a60761f11..221cf28f23 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -187,7 +187,10 @@ typedef struct SEp { typedef struct { int32_t contLen; - int32_t vgId; + union { + int32_t vgId; + int32_t streamTaskId; + }; } SMsgHead; // Submit message for one table diff --git a/include/dnode/snode/snode.h b/include/dnode/snode/snode.h index 21a93532e0..9dcd58a05f 100644 --- a/include/dnode/snode/snode.h +++ b/include/dnode/snode/snode.h @@ -23,6 +23,9 @@ extern "C" { #endif +#define SND_UNIQUE_THREAD_NUM 2 +#define SND_SHARED_THREAD_NUM 2 + /* ------------------------ TYPES EXPOSED ------------------------ */ typedef struct SDnode SDnode; typedef struct SSnode SSnode; diff --git a/source/dnode/mgmt/impl/src/dndSnode.c b/source/dnode/mgmt/impl/src/dndSnode.c index b27a25680a..5ea8a841d2 100644 --- a/source/dnode/mgmt/impl/src/dndSnode.c +++ b/source/dnode/mgmt/impl/src/dndSnode.c @@ -166,7 +166,7 @@ static int32_t dndWriteSnodeFile(SDnode *pDnode) { static int32_t dndStartSnodeWorker(SDnode *pDnode) { SSnodeMgmt *pMgmt = &pDnode->smgmt; pMgmt->uniqueWorkers = taosArrayInit(0, sizeof(void *)); - for (int32_t i = 0; i < 2; i++) { + for (int32_t i = 0; i < SND_UNIQUE_THREAD_NUM; i++) { SDnodeWorker *pUniqueWorker = malloc(sizeof(SDnodeWorker)); if (pUniqueWorker == NULL) { return -1; @@ -177,8 +177,8 @@ static int32_t dndStartSnodeWorker(SDnode *pDnode) { } taosArrayPush(pMgmt->uniqueWorkers, &pUniqueWorker); } - if (dndInitWorker(pDnode, &pMgmt->sharedWorker, DND_WORKER_SINGLE, "snode-shared", 4, 4, - dndProcessSnodeSharedQueue)) { + if (dndInitWorker(pDnode, &pMgmt->sharedWorker, DND_WORKER_SINGLE, "snode-shared", SND_SHARED_THREAD_NUM, + SND_SHARED_THREAD_NUM, dndProcessSnodeSharedQueue)) { dError("failed to start snode shared worker since %s", terrstr()); return -1; } @@ -369,13 +369,39 @@ static void dndProcessSnodeSharedQueue(SDnode *pDnode, SRpcMsg *pMsg) { taosFreeQitem(pMsg); } -static void dndWriteSnodeMsgToRandomWorker(SDnode *pDnode, SRpcMsg *pMsg) { +static FORCE_INLINE int32_t dndGetSWIdFromMsg(SRpcMsg *pMsg) { + SMsgHead *pHead = pMsg->pCont; + pHead->streamTaskId = htonl(pHead->streamTaskId); + return pHead->streamTaskId % SND_UNIQUE_THREAD_NUM; +} + +static void dndWriteSnodeMsgToWorkerByMsg(SDnode *pDnode, SRpcMsg *pMsg) { int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED; SSnode *pSnode = dndAcquireSnode(pDnode); if (pSnode != NULL) { - int32_t index = (pDnode->smgmt.uniqueWorkerInUse + 1) % taosArrayGetSize(pDnode->smgmt.uniqueWorkers); - SDnodeWorker *pWorker = taosArrayGet(pDnode->smgmt.uniqueWorkers, index); + int32_t index = dndGetSWIdFromMsg(pMsg); + SDnodeWorker *pWorker = taosArrayGetP(pDnode->smgmt.uniqueWorkers, index); + code = dndWriteMsgToWorker(pWorker, pMsg, sizeof(SRpcMsg)); + } + + dndReleaseSnode(pDnode, pSnode); + + if (code != 0) { + if (pMsg->msgType & 1u) { + SRpcMsg rsp = {.handle = pMsg->handle, .ahandle = pMsg->ahandle, .code = code}; + rpcSendResponse(&rsp); + } + rpcFreeCont(pMsg->pCont); + } +} + +static void dndWriteSnodeMsgToMgmtWorker(SDnode *pDnode, SRpcMsg *pMsg) { + int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED; + + SSnode *pSnode = dndAcquireSnode(pDnode); + if (pSnode != NULL) { + SDnodeWorker *pWorker = taosArrayGet(pDnode->smgmt.uniqueWorkers, 0); code = dndWriteMsgToWorker(pWorker, pMsg, sizeof(SRpcMsg)); } dndReleaseSnode(pDnode, pSnode); @@ -407,9 +433,12 @@ static void dndWriteSnodeMsgToWorker(SDnode *pDnode, SDnodeWorker *pWorker, SRpc } } +void dndProcessSnodeMgmtMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) { + dndWriteSnodeMsgToMgmtWorker(pDnode, pMsg); +} + void dndProcessSnodeUniqueMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) { - // judge from msg to write to unique queue - dndWriteSnodeMsgToRandomWorker(pDnode, pMsg); + dndWriteSnodeMsgToWorkerByMsg(pDnode, pMsg); } void dndProcessSnodeSharedMsg(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) { diff --git a/source/dnode/snode/inc/sndInt.h b/source/dnode/snode/inc/sndInt.h index 5851e18478..5c792c840d 100644 --- a/source/dnode/snode/inc/sndInt.h +++ b/source/dnode/snode/inc/sndInt.h @@ -30,21 +30,26 @@ extern "C" { #endif enum { - STREAM_STATUS__READY = 1, + STREAM_STATUS__RUNNING = 1, STREAM_STATUS__STOPPED, STREAM_STATUS__CREATING, STREAM_STATUS__STOPING, - STREAM_STATUS__RESUMING, + STREAM_STATUS__RESTORING, STREAM_STATUS__DELETING, }; enum { - STREAM_RUNNER__RUNNING = 1, - STREAM_RUNNER__STOP, + STREAM_TASK_STATUS__RUNNING = 1, + STREAM_TASK_STATUS__STOP, }; +typedef struct { + SHashObj* pHash; // taskId -> streamTask +} SStreamMeta; + typedef struct SSnode { - SSnodeOpt cfg; + SStreamMeta* pMeta; + SSnodeOpt cfg; } SSnode; typedef struct { @@ -62,10 +67,6 @@ typedef struct { // storage handle } SStreamRunner; -typedef struct { - SHashObj* pHash; -} SStreamMeta; - int32_t sndCreateStream(); int32_t sndDropStream(); From ec1b600176aa8dfbf38da2688f1e9cb6485689b5 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 15 Mar 2022 14:56:40 +0800 Subject: [PATCH 09/38] [td-13039] fix compiler error. --- source/libs/executor/test/executorTests.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/libs/executor/test/executorTests.cpp b/source/libs/executor/test/executorTests.cpp index 76485363c0..6737f57bbf 100644 --- a/source/libs/executor/test/executorTests.cpp +++ b/source/libs/executor/test/executorTests.cpp @@ -86,7 +86,7 @@ SSDataBlock* getDummyBlock(SOperatorInfo* pOperator, bool* newgroup) { // // taosArrayPush(pInfo->pBlock->pDataBlock, &colInfo1); } else { - blockDataClearup(pInfo->pBlock, true); + blockDataClearup(pInfo->pBlock); } SSDataBlock* pBlock = pInfo->pBlock; @@ -151,7 +151,7 @@ SSDataBlock* get2ColsDummyBlock(SOperatorInfo* pOperator, bool* newgroup) { taosArrayPush(pInfo->pBlock->pDataBlock, &colInfo1); } else { - blockDataClearup(pInfo->pBlock, false); + blockDataClearup(pInfo->pBlock); } SSDataBlock* pBlock = pInfo->pBlock; From b71cea74bc859208ff84c2d205fde4d0539f7a4e Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Tue, 15 Mar 2022 15:14:01 +0800 Subject: [PATCH 10/38] [add insert and select case] --- tests/script/tsim/insert/basic0.sim | 334 ++++++++++++++++++++++++++++ 1 file changed, 334 insertions(+) create mode 100644 tests/script/tsim/insert/basic0.sim diff --git a/tests/script/tsim/insert/basic0.sim b/tests/script/tsim/insert/basic0.sim new file mode 100644 index 0000000000..eb4780caac --- /dev/null +++ b/tests/script/tsim/insert/basic0.sim @@ -0,0 +1,334 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sleep 50 +sql connect + +print =============== create database +sql create database d0 +sql show databases +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 + +sql use d0 + +print =============== create super table, include column type for count/sum/min/max/first +sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 double) tags (t1 int unsigned) + +sql show stables +if $rows != 1 then + return -1 +endi + +print =============== create child table +sql create table ct1 using stb tags(1000) +sql create table ct2 using stb tags(2000) + +sql show tables +if $rows != 2 then + return -1 +endi + + +print =============== insert data, mode1: one row one table in sql +print =============== insert data, mode1: mulit rows one table in sql +print =============== insert data, mode1: one rows mulit table in sql +print =============== insert data, mode1: mulit rows mulit table in sql +sql insert into ct1 values(now+0s, 10, 2.0, 3.0) +sql insert into ct1 values(now+1s, 11, 2.1, 3.1)(now+2s, 12, 2.2, 3.2)(now+3s, 13, 2.3, 3.3) +sql insert into ct2 values(now+0s, 10, 2.0, 3.0) +sql insert into ct2 values(now+1s, 11, 2.1, 3.1)(now+2s, 12, 2.2, 3.2)(now+3s, 13, 2.3, 3.3) +# after fix bug, modify sql_error to sql +sql_error insert into ct1 values(now+4s, -14, -2.4, -3.4) ct2 values(now+4s, -14, -2.4, -3.4) +sql_error insert into ct1 values(now+5s, -15, -2.5, -3.5)(now+6s, -16, -2.6, -3.6) ct2 values(now+5s, -15, -2.5, -3.5)(now+6s, -16, -2.6, -3.6) + +#=================================================================== +#=================================================================== +print =============== query data from child table +sql select * from ct1 +if $rows != 4 then # after fix bug, modify 4 to 7 + return -1 +endi +if $data01 != 10 then + return -1 +endi +if $data02 != 2.00000 then + return -1 +endi +if $data03 != 3.000000000 then + return -1 +endi +#if $data41 != -14 then +# return -1 +#endi +#if $data42 != -2.40000 then +# return -1 +#endi +#if $data43 != -3.400000000 then +# return -1 +#endi + + +print =============== select count(*) from child table +sql select count(*) from ct1 +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 +if $data00 != 4 then + return -1 +endi + +print =============== select count(column) from child table +sql select count(ts), count(c1), count(c2), count(c3) from ct1 +print $data00 $data01 $data02 $data03 +if $data00 != 4 then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +#print =============== select first(*)/first(column) from child table +#sql select first(*) from ct1 +#sql select first(ts), first(c1), first(c2), first(c3) from ct1 + +print =============== select min(column) from child table +sql select min(c1), min(c2), min(c3) from ct1 +print $data00 $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data00 != 10 then + return -1 +endi +if $data01 != 2.00000 then + return -1 +endi +if $data02 != 3.000000000 then + return -1 +endi + +print =============== select max(column) from child table +sql select max(c1), max(c2), max(c3) from ct1 +print $data00 $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data00 != 13 then + return -1 +endi +if $data01 != 2.30000 then + return -1 +endi +if $data02 != 3.300000000 then + return -1 +endi + +print =============== select sum(column) from child table +sql select sum(c1), sum(c2), sum(c3) from ct1 +print $data00 $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data00 != 46 then + return -1 +endi +if $data01 != 8.599999905 then + return -1 +endi +if $data02 != 12.600000000 then + return -1 +endi + +print =============== select column, from child table +sql select c1, c2, c3 from ct1 +print $data00 $data01 $data02 +#if $rows != 4 then +# return -1 +#endi +#if $data00 != 10 then +# return -1 +#endi +#if $data01 != 2.00000 then +# return -1 +#endi +#if $data02 != 3.000000000 then +# return -1 +#endi +#if $data10 != 11 then +# return -1 +#endi +#if $data11 != 2.10000 then +# return -1 +#endi +#if $data12 != 3.100000000 then +# return -1 +#endi +#if $data30 != 13 then +# return -1 +#endi +#if $data31 != 2.30000 then +# return -1 +#endi +#if $data32 != 3.300000000 then +# return -1 +#endi +#=================================================================== +#=================================================================== + +#print =============== query data from stb +#sql select * from stb +#if $rows != 4 then +# return -1 +#endi +#print =============== select count(*) from supter table +#sql select count(*) from stb +#if $rows != 1 then +# return -1 +#endi +# +#print $data00 $data01 $data02 +#if $data00 != 8 then +# return -1 +#endi +# +#print =============== select count(column) from supter table +#sql select count(ts), count(c1), count(c2), count(c3) from stb +#print $data00 $data01 $data02 $data03 +#if $data00 != 8 then +# return -1 +#endi +#if $data01 != 8 then +# return -1 +#endi +#if $data02 != 8 then +# return -1 +#endi +#if $data03 != 8 then +# return -1 +#endi + + +#=================================================================== +#=================================================================== + +print =============== stop and restart taosd, then again do query above +system sh/exec.sh -n dnode1 -s stop -x SIGINT +system sh/exec.sh -n dnode1 -s start + +sleep 2000 +sql select * from ct1 +if $rows != 4 then # after fix bug, modify 4 to 7 + return -1 +endi +if $data01 != 10 then + return -1 +endi +if $data02 != 2.00000 then + return -1 +endi +if $data03 != 3.000000000 then + return -1 +endi +#if $data41 != -14 then +# return -1 +#endi +#if $data42 != -2.40000 then +# return -1 +#endi +#if $data43 != -3.400000000 then +# return -1 +#endi + + +print =============== select count(*) from child table +sql select count(*) from ct1 +if $rows != 1 then + return -1 +endi + +print $data00 $data01 $data02 +if $data00 != 4 then + return -1 +endi + +print =============== select count(column) from child table +sql select count(ts), count(c1), count(c2), count(c3) from ct1 +print $data00 $data01 $data02 $data03 +if $data00 != 4 then + return -1 +endi +if $data01 != 4 then + return -1 +endi +if $data02 != 4 then + return -1 +endi +if $data03 != 4 then + return -1 +endi + +#print =============== select first(*)/first(column) from child table +#sql select first(*) from ct1 +#sql select first(ts), first(c1), first(c2), first(c3) from ct1 + +print =============== select min(column) from child table +sql select min(c1), min(c2), min(c3) from ct1 +print $data00 $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data00 != 10 then + return -1 +endi +if $data01 != 2.00000 then + return -1 +endi +if $data02 != 3.000000000 then + return -1 +endi + +print =============== select max(column) from child table +sql select max(c1), max(c2), max(c3) from ct1 +print $data00 $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data00 != 13 then + return -1 +endi +if $data01 != 2.30000 then + return -1 +endi +if $data02 != 3.300000000 then + return -1 +endi + +print =============== select sum(column) from child table +sql select sum(c1), sum(c2), sum(c3) from ct1 +print $data00 $data01 $data02 $data03 +if $rows != 1 then + return -1 +endi +if $data00 != 46 then + return -1 +endi +if $data01 != 8.599999905 then + return -1 +endi +if $data02 != 12.600000000 then + return -1 +endi + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT From b710e0a7d5a48cbea76d6d6e0b06f8a5dc0eb4fd Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Tue, 15 Mar 2022 15:18:46 +0800 Subject: [PATCH 11/38] [add cases] --- tests/script/jenkins/basic.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index b934272806..cafca76761 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -16,4 +16,6 @@ # ---- dnode ./test.sh -f tsim/dnode/basic1.sim +# ---- insert +./test.sh -f tsim/insert/basic0.sim #======================b1-end=============== From eced27c4f2297e8781c95c23a0e466c746a0e9e7 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Tue, 15 Mar 2022 15:54:32 +0800 Subject: [PATCH 12/38] add uuid --- include/util/tuuid.h | 39 ++ source/dnode/snode/inc/sndInt.h | 14 +- source/dnode/snode/src/snode.c | 11 + source/libs/scheduler/src/scheduler.c | 681 +++++++++++++------------- source/util/src/tuuid.c | 59 +++ 5 files changed, 451 insertions(+), 353 deletions(-) create mode 100644 include/util/tuuid.h create mode 100644 source/util/src/tuuid.c diff --git a/include/util/tuuid.h b/include/util/tuuid.h new file mode 100644 index 0000000000..315c2ad497 --- /dev/null +++ b/include/util/tuuid.h @@ -0,0 +1,39 @@ +/* + * 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 "os.h" +#include "taoserror.h" +#include "thash.h" + +/** + * Generate an non-negative signed 32bit id + *+------------+-----+-----------+---------------+ + *| uid|localIp| PId | timestamp | serial number | + *+------------+-----+-----------+---------------+ + *| 6bit |6bit | 12bit | 8bit | + *+------------+-----+-----------+---------------+ + * @return + */ +int32_t tGenIdPI32(void); + +/** + * Generate an non-negative signed 64bit id + *+------------+-----+-----------+---------------+ + *| uid|localIp| PId | timestamp | serial number | + *+------------+-----+-----------+---------------+ + *| 12bit |12bit|24bit |16bit | + *+------------+-----+-----------+---------------+ + * @return + */ +int64_t tGenIdPI64(void); diff --git a/source/dnode/snode/inc/sndInt.h b/source/dnode/snode/inc/sndInt.h index 5c792c840d..ffe691aeb4 100644 --- a/source/dnode/snode/inc/sndInt.h +++ b/source/dnode/snode/inc/sndInt.h @@ -54,18 +54,18 @@ typedef struct SSnode { typedef struct { int64_t streamId; + int32_t taskId; int32_t IdxInLevel; int32_t level; -} SStreamInfo; +} SStreamTaskInfo; typedef struct { - SStreamInfo meta; - int8_t status; - void* executor; - STaosQueue* queue; - void* stateStore; + SStreamTaskInfo meta; + int8_t status; + void* executor; + void* stateStore; // storage handle -} SStreamRunner; +} SStreamTask; int32_t sndCreateStream(); int32_t sndDropStream(); diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c index 91008dd03a..74e41d45c5 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -14,6 +14,7 @@ */ #include "sndInt.h" +#include "tuuid.h" SSnode *sndOpen(const char *path, const SSnodeOpt *pOption) { SSnode *pSnode = calloc(1, sizeof(SSnode)); @@ -32,6 +33,16 @@ int32_t sndProcessMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { void sndDestroy(const char *path) {} +static int32_t sndDeployTask(SSnode *pSnode, SRpcMsg *pMsg) { + SStreamTask *task = malloc(sizeof(SStreamTask)); + if (task == NULL) { + return -1; + } + task->meta.taskId = tGenIdPI32(); + taosHashPut(pSnode->pMeta->pHash, &task->meta.taskId, sizeof(int32_t), &task, sizeof(void *)); + return 0; +} + int32_t sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg) { // stream deployment // stream stop/resume diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index ebe70ca401..6b1ca25d93 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -13,26 +13,21 @@ * along with this program. If not, see . */ +#include "catalog.h" +#include "query.h" #include "schedulerInt.h" #include "tmsg.h" -#include "query.h" -#include "catalog.h" #include "tref.h" SSchedulerMgmt schMgmt = {0}; -FORCE_INLINE SSchJob *schAcquireJob(int64_t refId) { - return (SSchJob *)taosAcquireRef(schMgmt.jobRef, refId); -} +FORCE_INLINE SSchJob *schAcquireJob(int64_t refId) { return (SSchJob *)taosAcquireRef(schMgmt.jobRef, refId); } -FORCE_INLINE int32_t schReleaseJob(int64_t refId) { - return taosReleaseRef(schMgmt.jobRef, refId); -} +FORCE_INLINE int32_t schReleaseJob(int64_t refId) { return taosReleaseRef(schMgmt.jobRef, refId); } -uint64_t schGenTaskId(void) { - return atomic_add_fetch_64(&schMgmt.taskId, 1); -} +uint64_t schGenTaskId(void) { return atomic_add_fetch_64(&schMgmt.taskId, 1); } +#if 0 uint64_t schGenUUID(void) { static uint64_t hashId = 0; static int32_t requestSerialId = 0; @@ -54,11 +49,11 @@ uint64_t schGenUUID(void) { uint64_t id = ((hashId & 0x0FFF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF); return id; } +#endif - -int32_t schInitTask(SSchJob* pJob, SSchTask *pTask, SSubplan* pPlan, SSchLevel *pLevel) { - pTask->plan = pPlan; - pTask->level = pLevel; +int32_t schInitTask(SSchJob *pJob, SSchTask *pTask, SSubplan *pPlan, SSchLevel *pLevel) { + pTask->plan = pPlan; + pTask->level = pLevel; SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_NOT_START); pTask->taskId = schGenTaskId(); pTask->execAddrs = taosArrayInit(SCH_MAX_CANDIDATE_EP_NUM, sizeof(SQueryNodeAddr)); @@ -70,7 +65,7 @@ int32_t schInitTask(SSchJob* pJob, SSchTask *pTask, SSubplan* pPlan, SSchLevel * return TSDB_CODE_SUCCESS; } -void schFreeTask(SSchTask* pTask) { +void schFreeTask(SSchTask *pTask) { if (pTask->candidateAddrs) { taosArrayDestroy(pTask->candidateAddrs); } @@ -90,22 +85,20 @@ void schFreeTask(SSchTask* pTask) { } } - static FORCE_INLINE bool schJobNeedToStop(SSchJob *pJob, int8_t *pStatus) { int8_t status = SCH_GET_JOB_STATUS(pJob); if (pStatus) { *pStatus = status; } - return (status == JOB_TASK_STATUS_FAILED || status == JOB_TASK_STATUS_CANCELLED - || status == JOB_TASK_STATUS_CANCELLING || status == JOB_TASK_STATUS_DROPPING - || status == JOB_TASK_STATUS_SUCCEED); + return (status == JOB_TASK_STATUS_FAILED || status == JOB_TASK_STATUS_CANCELLED || + status == JOB_TASK_STATUS_CANCELLING || status == JOB_TASK_STATUS_DROPPING || + status == JOB_TASK_STATUS_SUCCEED); } - int32_t schValidateTaskReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t msgType) { int32_t lastMsgType = SCH_GET_TASK_LASTMSG_TYPE(pTask); - + switch (msgType) { case TDMT_VND_CREATE_TABLE_RSP: case TDMT_VND_SUBMIT_RSP: @@ -114,19 +107,22 @@ int32_t schValidateTaskReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t m case TDMT_VND_FETCH_RSP: case TDMT_VND_DROP_TASK: if (lastMsgType != (msgType - 1)) { - SCH_TASK_ELOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", TMSG_INFO(lastMsgType), TMSG_INFO(msgType)); + SCH_TASK_ELOG("rsp msg type mis-match, last sent msgType:%s, rspType:%s", TMSG_INFO(lastMsgType), + TMSG_INFO(msgType)); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } - if (SCH_GET_TASK_STATUS(pTask) != JOB_TASK_STATUS_EXECUTING && SCH_GET_TASK_STATUS(pTask) != JOB_TASK_STATUS_PARTIAL_SUCCEED) { - SCH_TASK_ELOG("rsp msg conflicted with task status, status:%d, rspType:%s", SCH_GET_TASK_STATUS(pTask), TMSG_INFO(msgType)); + if (SCH_GET_TASK_STATUS(pTask) != JOB_TASK_STATUS_EXECUTING && + SCH_GET_TASK_STATUS(pTask) != JOB_TASK_STATUS_PARTIAL_SUCCEED) { + SCH_TASK_ELOG("rsp msg conflicted with task status, status:%d, rspType:%s", SCH_GET_TASK_STATUS(pTask), + TMSG_INFO(msgType)); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } break; default: SCH_TASK_ELOG("unknown rsp msg, type:%s, status:%d", TMSG_INFO(msgType), SCH_GET_TASK_STATUS(pTask)); - + SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } @@ -135,7 +131,6 @@ int32_t schValidateTaskReceivedMsgType(SSchJob *pJob, SSchTask *pTask, int32_t m return TSDB_CODE_SUCCESS; } - int32_t schCheckAndUpdateJobStatus(SSchJob *pJob, int8_t newStatus) { int32_t code = 0; @@ -147,37 +142,34 @@ int32_t schCheckAndUpdateJobStatus(SSchJob *pJob, int8_t newStatus) { if (oriStatus == newStatus) { SCH_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); } - + switch (oriStatus) { case JOB_TASK_STATUS_NULL: if (newStatus != JOB_TASK_STATUS_NOT_START) { SCH_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); } - + break; case JOB_TASK_STATUS_NOT_START: if (newStatus != JOB_TASK_STATUS_EXECUTING) { SCH_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); } - + break; case JOB_TASK_STATUS_EXECUTING: - if (newStatus != JOB_TASK_STATUS_PARTIAL_SUCCEED - && newStatus != JOB_TASK_STATUS_FAILED - && newStatus != JOB_TASK_STATUS_CANCELLING - && newStatus != JOB_TASK_STATUS_CANCELLED - && newStatus != JOB_TASK_STATUS_DROPPING) { + if (newStatus != JOB_TASK_STATUS_PARTIAL_SUCCEED && newStatus != JOB_TASK_STATUS_FAILED && + newStatus != JOB_TASK_STATUS_CANCELLING && newStatus != JOB_TASK_STATUS_CANCELLED && + newStatus != JOB_TASK_STATUS_DROPPING) { SCH_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); } - + break; case JOB_TASK_STATUS_PARTIAL_SUCCEED: - if (newStatus != JOB_TASK_STATUS_FAILED - && newStatus != JOB_TASK_STATUS_SUCCEED - && newStatus != JOB_TASK_STATUS_DROPPING) { + if (newStatus != JOB_TASK_STATUS_FAILED && newStatus != JOB_TASK_STATUS_SUCCEED && + newStatus != JOB_TASK_STATUS_DROPPING) { SCH_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); } - + break; case JOB_TASK_STATUS_SUCCEED: case JOB_TASK_STATUS_FAILED: @@ -185,13 +177,13 @@ int32_t schCheckAndUpdateJobStatus(SSchJob *pJob, int8_t newStatus) { if (newStatus != JOB_TASK_STATUS_DROPPING) { SCH_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); } - + break; case JOB_TASK_STATUS_CANCELLED: case JOB_TASK_STATUS_DROPPING: SCH_ERR_JRET(TSDB_CODE_QRY_JOB_FREED); break; - + default: SCH_JOB_ELOG("invalid job status:%d", oriStatus); SCH_ERR_JRET(TSDB_CODE_QRY_APP_ERROR); @@ -211,27 +203,26 @@ int32_t schCheckAndUpdateJobStatus(SSchJob *pJob, int8_t newStatus) { _return: SCH_JOB_ELOG("invalid job status update, from %d to %d", oriStatus, newStatus); - + SCH_ERR_RET(code); } - int32_t schBuildTaskRalation(SSchJob *pJob, SHashObj *planToTask) { for (int32_t i = 0; i < pJob->levelNum; ++i) { SSchLevel *pLevel = taosArrayGet(pJob->levels, i); - + for (int32_t m = 0; m < pLevel->taskNum; ++m) { SSchTask *pTask = taosArrayGet(pLevel->subTasks, m); SSubplan *pPlan = pTask->plan; - int32_t childNum = pPlan->pChildren ? (int32_t)LIST_LENGTH(pPlan->pChildren) : 0; - int32_t parentNum = pPlan->pParents ? (int32_t)LIST_LENGTH(pPlan->pParents) : 0; + int32_t childNum = pPlan->pChildren ? (int32_t)LIST_LENGTH(pPlan->pChildren) : 0; + int32_t parentNum = pPlan->pParents ? (int32_t)LIST_LENGTH(pPlan->pParents) : 0; if (childNum > 0) { if (pJob->levelIdx == pLevel->level) { SCH_JOB_ELOG("invalid query plan, lowest level, childNum:%d", childNum); SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR); } - + pTask->children = taosArrayInit(childNum, POINTER_BYTES); if (NULL == pTask->children) { SCH_TASK_ELOG("taosArrayInit %d children failed", childNum); @@ -240,7 +231,7 @@ int32_t schBuildTaskRalation(SSchJob *pJob, SHashObj *planToTask) { } for (int32_t n = 0; n < childNum; ++n) { - SSubplan *child = (SSubplan*)nodesListGetNode(pPlan->pChildren, n); + SSubplan *child = (SSubplan *)nodesListGetNode(pPlan->pChildren, n); SSchTask **childTask = taosHashGet(planToTask, &child, POINTER_BYTES); if (NULL == childTask || NULL == *childTask) { SCH_TASK_ELOG("subplan children relationship error, level:%d, taskIdx:%d, childIdx:%d", i, m, n); @@ -258,7 +249,7 @@ int32_t schBuildTaskRalation(SSchJob *pJob, SHashObj *planToTask) { SCH_TASK_ELOG("invalid task info, level:0, parentNum:%d", parentNum); SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR); } - + pTask->parents = taosArrayInit(parentNum, POINTER_BYTES); if (NULL == pTask->parents) { SCH_TASK_ELOG("taosArrayInit %d parents failed", parentNum); @@ -272,7 +263,7 @@ int32_t schBuildTaskRalation(SSchJob *pJob, SHashObj *planToTask) { } for (int32_t n = 0; n < parentNum; ++n) { - SSubplan *parent = (SSubplan*)nodesListGetNode(pPlan->pParents, n); + SSubplan *parent = (SSubplan *)nodesListGetNode(pPlan->pParents, n); SSchTask **parentTask = taosHashGet(planToTask, &parent, POINTER_BYTES); if (NULL == parentTask || NULL == *parentTask) { SCH_TASK_ELOG("subplan parent relationship error, level:%d, taskIdx:%d, childIdx:%d", i, m, n); @@ -283,7 +274,7 @@ int32_t schBuildTaskRalation(SSchJob *pJob, SHashObj *planToTask) { SCH_TASK_ELOG("taosArrayPush parentTask failed, level:%d, taskIdx:%d, childIdx:%d", i, m, n); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - } + } SCH_TASK_DLOG("level:%d, parentNum:%d, childNum:%d", i, parentNum, childNum); } @@ -298,11 +289,11 @@ int32_t schBuildTaskRalation(SSchJob *pJob, SHashObj *planToTask) { return TSDB_CODE_SUCCESS; } - int32_t schRecordTaskSucceedNode(SSchJob *pJob, SSchTask *pTask) { SQueryNodeAddr *addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx); if (NULL == addr) { - SCH_TASK_ELOG("taosArrayGet candidate addr failed, idx:%d, size:%d", pTask->candidateIdx, (int32_t)taosArrayGetSize(pTask->candidateAddrs)); + SCH_TASK_ELOG("taosArrayGet candidate addr failed, idx:%d, size:%d", pTask->candidateIdx, + (int32_t)taosArrayGetSize(pTask->candidateAddrs)); SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR); } @@ -311,7 +302,6 @@ int32_t schRecordTaskSucceedNode(SSchJob *pJob, SSchTask *pTask) { return TSDB_CODE_SUCCESS; } - int32_t schRecordTaskExecNode(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr) { if (NULL == taosArrayPush(pTask->execAddrs, addr)) { SCH_TASK_ELOG("taosArrayPush addr to execAddr list failed, errno:%d", errno); @@ -321,23 +311,25 @@ int32_t schRecordTaskExecNode(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *ad return TSDB_CODE_SUCCESS; } - int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { int32_t code = 0; pJob->queryId = pDag->queryId; - + if (pDag->numOfSubplans <= 0) { SCH_JOB_ELOG("invalid subplan num:%d", pDag->numOfSubplans); SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } - + int32_t levelNum = (int32_t)LIST_LENGTH(pDag->pSubplans); if (levelNum <= 0) { SCH_JOB_ELOG("invalid level num:%d", levelNum); SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } - SHashObj *planToTask = taosHashInit(SCHEDULE_DEFAULT_MAX_TASK_NUM, taosGetDefaultHashFunction(POINTER_BYTES == sizeof(int64_t) ? TSDB_DATA_TYPE_BIGINT : TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); + SHashObj *planToTask = taosHashInit( + SCHEDULE_DEFAULT_MAX_TASK_NUM, + taosGetDefaultHashFunction(POINTER_BYTES == sizeof(int64_t) ? TSDB_DATA_TYPE_BIGINT : TSDB_DATA_TYPE_INT), false, + HASH_NO_LOCK); if (NULL == planToTask) { SCH_JOB_ELOG("taosHashInit %d failed", SCHEDULE_DEFAULT_MAX_TASK_NUM); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); @@ -354,10 +346,10 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { pJob->subPlans = pDag->pSubplans; - SSchLevel level = {0}; + SSchLevel level = {0}; SNodeListNode *plans = NULL; - int32_t taskNum = 0; - SSchLevel *pLevel = NULL; + int32_t taskNum = 0; + SSchLevel *pLevel = NULL; level.status = JOB_TASK_STATUS_NOT_START; @@ -369,8 +361,8 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { pLevel = taosArrayGet(pJob->levels, i); pLevel->level = i; - - plans = (SNodeListNode*)nodesListGetNode(pDag->pSubplans, i); + + plans = (SNodeListNode *)nodesListGetNode(pDag->pSubplans, i); if (NULL == plans) { SCH_JOB_ELOG("empty level plan, level:%d", i); SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); @@ -383,15 +375,15 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { } pLevel->taskNum = taskNum; - + pLevel->subTasks = taosArrayInit(taskNum, sizeof(SSchTask)); if (NULL == pLevel->subTasks) { SCH_JOB_ELOG("taosArrayInit %d failed", taskNum); SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - + for (int32_t n = 0; n < taskNum; ++n) { - SSubplan *plan = (SSubplan*)nodesListGetNode(plans->pNodeList, n); + SSubplan *plan = (SSubplan *)nodesListGetNode(plans->pNodeList, n); SCH_SET_JOB_TYPE(pJob, plan->subplanType); @@ -399,13 +391,13 @@ int32_t schValidateAndBuildJob(SQueryPlan *pDag, SSchJob *pJob) { SSchTask *pTask = &task; SCH_ERR_JRET(schInitTask(pJob, &task, plan, pLevel)); - + void *p = taosArrayPush(pLevel->subTasks, &task); if (NULL == p) { SCH_TASK_ELOG("taosArrayPush task to level failed, level:%d, taskIdx:%d", pLevel->level, n); SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - + if (0 != taosHashPut(planToTask, &plan, POINTER_BYTES, &p, POINTER_BYTES)) { SCH_TASK_ELOG("taosHashPut to planToTaks failed, taskIdx:%d", n); SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); @@ -452,10 +444,10 @@ int32_t schSetTaskCandidateAddrs(SSchJob *pJob, SSchTask *pTask) { int32_t nodeNum = 0; if (pJob->nodeList) { nodeNum = taosArrayGetSize(pJob->nodeList); - + for (int32_t i = 0; i < nodeNum && addNum < SCH_MAX_CANDIDATE_EP_NUM; ++i) { SQueryNodeAddr *naddr = taosArrayGet(pJob->nodeList, i); - + if (NULL == taosArrayPush(pTask->candidateAddrs, naddr)) { SCH_TASK_ELOG("taosArrayPush execNode to candidate addrs failed, addNum:%d, errno:%d", addNum, errno); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); @@ -470,14 +462,14 @@ int32_t schSetTaskCandidateAddrs(SSchJob *pJob, SSchTask *pTask) { return TSDB_CODE_QRY_INVALID_INPUT; } -/* - for (int32_t i = 0; i < job->dataSrcEps.numOfEps && addNum < SCH_MAX_CANDIDATE_EP_NUM; ++i) { - strncpy(epSet->fqdn[epSet->numOfEps], job->dataSrcEps.fqdn[i], sizeof(job->dataSrcEps.fqdn[i])); - epSet->port[epSet->numOfEps] = job->dataSrcEps.port[i]; - - ++epSet->numOfEps; - } -*/ + /* + for (int32_t i = 0; i < job->dataSrcEps.numOfEps && addNum < SCH_MAX_CANDIDATE_EP_NUM; ++i) { + strncpy(epSet->fqdn[epSet->numOfEps], job->dataSrcEps.fqdn[i], sizeof(job->dataSrcEps.fqdn[i])); + epSet->port[epSet->numOfEps] = job->dataSrcEps.port[i]; + + ++epSet->numOfEps; + } + */ return TSDB_CODE_SUCCESS; } @@ -489,7 +481,7 @@ int32_t schPushTaskToExecList(SSchJob *pJob, SSchTask *pTask) { SCH_TASK_ELOG("task already in execTask list, code:%x", code); SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR); } - + SCH_TASK_ELOG("taosHashPut task to execTask list failed, errno:%d", errno); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } @@ -510,11 +502,11 @@ int32_t schMoveTaskToSuccList(SSchJob *pJob, SSchTask *pTask, bool *moved) { if (0 != code) { if (HASH_NODE_EXIST(code)) { *moved = true; - + SCH_TASK_ELOG("task already in succTask list, status:%d", SCH_GET_TASK_STATUS(pTask)); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } - + SCH_TASK_ELOG("taosHashPut task to succTask list failed, errno:%d", errno); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } @@ -522,13 +514,13 @@ int32_t schMoveTaskToSuccList(SSchJob *pJob, SSchTask *pTask, bool *moved) { *moved = true; SCH_TASK_DLOG("task moved to succTask list, numOfTasks:%d", taosHashGetSize(pJob->succTasks)); - + return TSDB_CODE_SUCCESS; } int32_t schMoveTaskToFailList(SSchJob *pJob, SSchTask *pTask, bool *moved) { *moved = false; - + if (0 != taosHashRemove(pJob->execTasks, &pTask->taskId, sizeof(pTask->taskId))) { SCH_TASK_WLOG("remove task from execTask list failed, may not exist, status:%d", SCH_GET_TASK_STATUS(pTask)); } @@ -537,11 +529,11 @@ int32_t schMoveTaskToFailList(SSchJob *pJob, SSchTask *pTask, bool *moved) { if (0 != code) { if (HASH_NODE_EXIST(code)) { *moved = true; - + SCH_TASK_WLOG("task already in failTask list, status:%d", SCH_GET_TASK_STATUS(pTask)); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } - + SCH_TASK_ELOG("taosHashPut task to failTask list failed, errno:%d", errno); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } @@ -549,11 +541,10 @@ int32_t schMoveTaskToFailList(SSchJob *pJob, SSchTask *pTask, bool *moved) { *moved = true; SCH_TASK_DLOG("task moved to failTask list, numOfTasks:%d", taosHashGetSize(pJob->failTasks)); - + return TSDB_CODE_SUCCESS; } - int32_t schMoveTaskToExecList(SSchJob *pJob, SSchTask *pTask, bool *moved) { if (0 != taosHashRemove(pJob->succTasks, &pTask->taskId, sizeof(pTask->taskId))) { SCH_TASK_WLOG("remove task from succTask list failed, may not exist, status:%d", SCH_GET_TASK_STATUS(pTask)); @@ -563,11 +554,11 @@ int32_t schMoveTaskToExecList(SSchJob *pJob, SSchTask *pTask, bool *moved) { if (0 != code) { if (HASH_NODE_EXIST(code)) { *moved = true; - + SCH_TASK_ELOG("task already in execTask list, status:%d", SCH_GET_TASK_STATUS(pTask)); SCH_ERR_RET(TSDB_CODE_SCH_STATUS_ERROR); } - + SCH_TASK_ELOG("taosHashPut task to execTask list failed, errno:%d", errno); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } @@ -575,11 +566,10 @@ int32_t schMoveTaskToExecList(SSchJob *pJob, SSchTask *pTask, bool *moved) { *moved = true; SCH_TASK_DLOG("task moved to execTask list, numOfTasks:%d", taosHashGetSize(pJob->execTasks)); - + return TSDB_CODE_SUCCESS; } - int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bool *needRetry) { // TODO set retry or not based on task type/errCode/retry times/job status/available eps... @@ -587,20 +577,17 @@ int32_t schTaskCheckSetRetry(SSchJob *pJob, SSchTask *pTask, int32_t errCode, bo return TSDB_CODE_SUCCESS; - //TODO CHECK epList/condidateList + // TODO CHECK epList/condidateList if (SCH_IS_DATA_SRC_TASK(pTask)) { - } else { int32_t candidateNum = taosArrayGetSize(pTask->candidateAddrs); - + if ((pTask->candidateIdx + 1) >= candidateNum) { return TSDB_CODE_SUCCESS; } ++pTask->candidateIdx; } - - } int32_t schHandleTaskRetry(SSchJob *pJob, SSchTask *pTask) { @@ -623,9 +610,9 @@ int32_t schHandleTaskRetry(SSchJob *pJob, SSchTask *pTask) { } int32_t schUpdateHbConnection(SQueryNodeEpId *epId, SSchHbTrans *trans) { - int32_t code = 0; + int32_t code = 0; SSchHbTrans *hb = NULL; - + while (true) { hb = taosHashGet(schMgmt.hbConnections, epId, sizeof(SQueryNodeEpId)); if (NULL == hb) { @@ -639,9 +626,11 @@ int32_t schUpdateHbConnection(SQueryNodeEpId *epId, SSchHbTrans *trans) { SCH_ERR_RET(code); } - qDebug("hb connection updated, seqId:%" PRIx64 ", sId:%" PRIx64 ", nodeId:%d, fqdn:%s, port:%d, instance:%p, connection:%p", - trans->seqId, schMgmt.sId, epId->nodeId, epId->ep.fqdn, epId->ep.port, trans->trans.transInst, trans->trans.transHandle); - + qDebug("hb connection updated, seqId:%" PRIx64 ", sId:%" PRIx64 + ", nodeId:%d, fqdn:%s, port:%d, instance:%p, connection:%p", + trans->seqId, schMgmt.sId, epId->nodeId, epId->ep.fqdn, epId->ep.port, trans->trans.transInst, + trans->trans.transHandle); + return TSDB_CODE_SUCCESS; } @@ -649,11 +638,11 @@ int32_t schUpdateHbConnection(SQueryNodeEpId *epId, SSchHbTrans *trans) { } SCH_LOCK(SCH_WRITE, &hb->lock); - + if (hb->seqId >= trans->seqId) { - qDebug("hb trans seqId is old, seqId:%" PRId64 ", currentId:%" PRId64 ", nodeId:%d, fqdn:%s, port:%d", - trans->seqId, hb->seqId, epId->nodeId, epId->ep.fqdn, epId->ep.port); - + qDebug("hb trans seqId is old, seqId:%" PRId64 ", currentId:%" PRId64 ", nodeId:%d, fqdn:%s, port:%d", trans->seqId, + hb->seqId, epId->nodeId, epId->ep.fqdn, epId->ep.port); + SCH_UNLOCK(SCH_WRITE, &hb->lock); return TSDB_CODE_SUCCESS; } @@ -663,16 +652,18 @@ int32_t schUpdateHbConnection(SQueryNodeEpId *epId, SSchHbTrans *trans) { SCH_UNLOCK(SCH_WRITE, &hb->lock); - qDebug("hb connection updated, seqId:%" PRIx64 ", sId:%" PRIx64 ", nodeId:%d, fqdn:%s, port:%d, instance:%p, connection:%p", - trans->seqId, schMgmt.sId, epId->nodeId, epId->ep.fqdn, epId->ep.port, trans->trans.transInst, trans->trans.transHandle); - + qDebug("hb connection updated, seqId:%" PRIx64 ", sId:%" PRIx64 + ", nodeId:%d, fqdn:%s, port:%d, instance:%p, connection:%p", + trans->seqId, schMgmt.sId, epId->nodeId, epId->ep.fqdn, epId->ep.port, trans->trans.transInst, + trans->trans.transHandle); + return TSDB_CODE_SUCCESS; } int32_t schProcessOnJobFailureImpl(SSchJob *pJob, int32_t status, int32_t errCode) { // if already FAILED, no more processing SCH_ERR_RET(schCheckAndUpdateJobStatus(pJob, status)); - + if (errCode) { atomic_store_32(&pJob->errCode, errCode); } @@ -684,11 +675,10 @@ int32_t schProcessOnJobFailureImpl(SSchJob *pJob, int32_t status, int32_t errCod int32_t code = atomic_load_32(&pJob->errCode); SCH_JOB_DLOG("job failed with error: %s", tstrerror(code)); - + SCH_RET(code); } - // Note: no more task error processing, handled in function internal int32_t schProcessOnJobFailure(SSchJob *pJob, int32_t errCode) { SCH_RET(schProcessOnJobFailureImpl(pJob, JOB_TASK_STATUS_FAILED, errCode)); @@ -699,18 +689,16 @@ int32_t schProcessOnJobDropped(SSchJob *pJob, int32_t errCode) { SCH_RET(schProcessOnJobFailureImpl(pJob, JOB_TASK_STATUS_DROPPING, errCode)); } - - // Note: no more task error processing, handled in function internal int32_t schProcessOnJobPartialSuccess(SSchJob *pJob) { int32_t code = 0; - + SCH_ERR_RET(schCheckAndUpdateJobStatus(pJob, JOB_TASK_STATUS_PARTIAL_SUCCEED)); if (pJob->attr.syncSchedule) { tsem_post(&pJob->rspSem); } - + if (atomic_load_8(&pJob->userFetch)) { SCH_ERR_JRET(schFetchFromRemote(pJob)); } @@ -730,22 +718,22 @@ int32_t schProcessOnDataFetched(SSchJob *job) { // Note: no more task error processing, handled in function internal int32_t schProcessOnTaskFailure(SSchJob *pJob, SSchTask *pTask, int32_t errCode) { int8_t status = 0; - + if (schJobNeedToStop(pJob, &status)) { SCH_TASK_DLOG("task failed not processed cause of job status, job status:%d", status); - + SCH_RET(atomic_load_32(&pJob->errCode)); } - bool needRetry = false; - bool moved = false; + bool needRetry = false; + bool moved = false; int32_t taskDone = 0; int32_t code = 0; SCH_TASK_DLOG("taskOnFailure, code:%s", tstrerror(errCode)); - + SCH_ERR_JRET(schTaskCheckSetRetry(pJob, pTask, errCode, &needRetry)); - + if (!needRetry) { SCH_TASK_ELOG("task failed and no more retry, code:%s", tstrerror(errCode)); @@ -757,7 +745,7 @@ int32_t schProcessOnTaskFailure(SSchJob *pJob, SSchTask *pTask, int32_t errCode) } SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_FAILED); - + if (SCH_TASK_NEED_WAIT_ALL(pTask)) { SCH_LOCK(SCH_WRITE, &pTask->level->lock); pTask->level->taskFailed++; @@ -765,7 +753,7 @@ int32_t schProcessOnTaskFailure(SSchJob *pJob, SSchTask *pTask, int32_t errCode) SCH_UNLOCK(SCH_WRITE, &pTask->level->lock); atomic_store_32(&pJob->errCode, errCode); - + if (taskDone < pTask->level->taskNum) { SCH_TASK_DLOG("not all tasks done, done:%d, all:%d", taskDone, pTask->level->taskNum); SCH_ERR_RET(errCode); @@ -773,7 +761,7 @@ int32_t schProcessOnTaskFailure(SSchJob *pJob, SSchTask *pTask, int32_t errCode) } } else { SCH_ERR_JRET(schHandleTaskRetry(pJob, pTask)); - + return TSDB_CODE_SUCCESS; } @@ -784,7 +772,7 @@ _return: // Note: no more task error processing, handled in function internal int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) { - bool moved = false; + bool moved = false; int32_t code = 0; SCH_TASK_DLOG("taskOnSuccess, status:%d", SCH_GET_TASK_STATUS(pTask)); @@ -796,17 +784,17 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) { SCH_ERR_JRET(schRecordTaskSucceedNode(pJob, pTask)); SCH_ERR_JRET(schLaunchTasksInFlowCtrlList(pJob, pTask)); - + int32_t parentNum = pTask->parents ? (int32_t)taosArrayGetSize(pTask->parents) : 0; if (parentNum == 0) { int32_t taskDone = 0; - + if (SCH_TASK_NEED_WAIT_ALL(pTask)) { SCH_LOCK(SCH_WRITE, &pTask->level->lock); pTask->level->taskSucceed++; taskDone = pTask->level->taskSucceed + pTask->level->taskFailed; SCH_UNLOCK(SCH_WRITE, &pTask->level->lock); - + if (taskDone < pTask->level->taskNum) { SCH_TASK_DLOG("wait all tasks, done:%d, all:%d", taskDone, pTask->level->taskNum); return TSDB_CODE_SUCCESS; @@ -826,28 +814,31 @@ int32_t schProcessOnTaskSuccess(SSchJob *pJob, SSchTask *pTask) { pJob->fetchTask = pTask; SCH_ERR_JRET(schMoveTaskToExecList(pJob, pTask, &moved)); - + SCH_RET(schProcessOnJobPartialSuccess(pJob)); } -/* - if (SCH_IS_DATA_SRC_TASK(task) && job->dataSrcEps.numOfEps < SCH_MAX_CANDIDATE_EP_NUM) { - strncpy(job->dataSrcEps.fqdn[job->dataSrcEps.numOfEps], task->execAddr.fqdn, sizeof(task->execAddr.fqdn)); - job->dataSrcEps.port[job->dataSrcEps.numOfEps] = task->execAddr.port; + /* + if (SCH_IS_DATA_SRC_TASK(task) && job->dataSrcEps.numOfEps < SCH_MAX_CANDIDATE_EP_NUM) { + strncpy(job->dataSrcEps.fqdn[job->dataSrcEps.numOfEps], task->execAddr.fqdn, sizeof(task->execAddr.fqdn)); + job->dataSrcEps.port[job->dataSrcEps.numOfEps] = task->execAddr.port; - ++job->dataSrcEps.numOfEps; - } -*/ + ++job->dataSrcEps.numOfEps; + } + */ for (int32_t i = 0; i < parentNum; ++i) { SSchTask *par = *(SSchTask **)taosArrayGet(pTask->parents, i); - int32_t readyNum = atomic_add_fetch_32(&par->childReady, 1); + int32_t readyNum = atomic_add_fetch_32(&par->childReady, 1); SCH_LOCK(SCH_WRITE, &par->lock); - SDownstreamSourceNode source = {.type = QUERY_NODE_DOWNSTREAM_SOURCE, .taskId = pTask->taskId, .schedId = schMgmt.sId, .addr = pTask->succeedAddr}; + SDownstreamSourceNode source = {.type = QUERY_NODE_DOWNSTREAM_SOURCE, + .taskId = pTask->taskId, + .schedId = schMgmt.sId, + .addr = pTask->succeedAddr}; qSetSubplanExecutionNode(par->plan, pTask->plan->id.groupId, &source); SCH_UNLOCK(SCH_WRITE, &par->lock); - + if (SCH_TASK_READY_TO_LUNCH(readyNum, par)) { SCH_ERR_RET(schLaunchTaskImpl(pJob, par)); } @@ -860,11 +851,10 @@ _return: SCH_RET(schProcessOnJobFailure(pJob, code)); } - // Note: no more error processing, handled in function internal int32_t schFetchFromRemote(SSchJob *pJob) { int32_t code = 0; - + if (atomic_val_compare_exchange_32(&pJob->remoteFetch, 0, 1) != 0) { SCH_JOB_ELOG("prior fetching not finished, remoteFetch:%d", atomic_load_32(&pJob->remoteFetch)); return TSDB_CODE_SUCCESS; @@ -881,7 +871,7 @@ int32_t schFetchFromRemote(SSchJob *pJob) { SCH_ERR_JRET(schBuildAndSendMsg(pJob, pJob->fetchTask, &pJob->resNode, TDMT_VND_FETCH)); return TSDB_CODE_SUCCESS; - + _return: atomic_val_compare_exchange_32(&pJob->remoteFetch, 1, 0); @@ -889,15 +879,15 @@ _return: SCH_RET(schProcessOnTaskFailure(pJob, pJob->fetchTask, code)); } - // Note: no more task error processing, handled in function internal -int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, char *msg, int32_t msgSize, int32_t rspCode) { +int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, char *msg, int32_t msgSize, + int32_t rspCode) { int32_t code = 0; - int8_t status = 0; - + int8_t status = 0; + if (schJobNeedToStop(pJob, &status)) { SCH_TASK_ELOG("rsp not processed cause of job status, job status:%d", status); - + SCH_RET(atomic_load_32(&pJob->errCode)); } @@ -905,13 +895,13 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch switch (msgType) { case TDMT_VND_CREATE_TABLE_RSP: { - SCH_ERR_JRET(rspCode); - SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask)); + SCH_ERR_JRET(rspCode); + SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask)); - break; - } + break; + } case TDMT_VND_SUBMIT_RSP: { - #if 0 //TODO OPEN THIS +#if 0 // TODO OPEN THIS SShellSubmitRspMsg *rsp = (SShellSubmitRspMsg *)msg; if (rspCode != TSDB_CODE_SUCCESS || NULL == msg || rsp->code != TSDB_CODE_SUCCESS) { @@ -919,77 +909,77 @@ int32_t schHandleResponseMsg(SSchJob *pJob, SSchTask *pTask, int32_t msgType, ch } pJob->resNumOfRows += rsp->affectedRows; - #else - SCH_ERR_JRET(rspCode); +#else + SCH_ERR_JRET(rspCode); - SSubmitRsp *rsp = (SSubmitRsp *)msg; - if (rsp) { - pJob->resNumOfRows += rsp->affectedRows; - } - #endif - - SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask)); - - break; + SSubmitRsp *rsp = (SSubmitRsp *)msg; + if (rsp) { + pJob->resNumOfRows += rsp->affectedRows; } +#endif + + SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask)); + + break; + } case TDMT_VND_QUERY_RSP: { - SQueryTableRsp *rsp = (SQueryTableRsp *)msg; - - SCH_ERR_JRET(rspCode); - if (NULL == msg) { - SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); - } - SCH_ERR_JRET(rsp->code); - - SCH_ERR_JRET(schBuildAndSendMsg(pJob, pTask, NULL, TDMT_VND_RES_READY)); - - break; + SQueryTableRsp *rsp = (SQueryTableRsp *)msg; + + SCH_ERR_JRET(rspCode); + if (NULL == msg) { + SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); } + SCH_ERR_JRET(rsp->code); + + SCH_ERR_JRET(schBuildAndSendMsg(pJob, pTask, NULL, TDMT_VND_RES_READY)); + + break; + } case TDMT_VND_RES_READY_RSP: { - SResReadyRsp *rsp = (SResReadyRsp *)msg; - - SCH_ERR_JRET(rspCode); - if (NULL == msg) { - SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); - } - SCH_ERR_JRET(rsp->code); - - SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask)); - - break; + SResReadyRsp *rsp = (SResReadyRsp *)msg; + + SCH_ERR_JRET(rspCode); + if (NULL == msg) { + SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); } + SCH_ERR_JRET(rsp->code); + + SCH_ERR_RET(schProcessOnTaskSuccess(pJob, pTask)); + + break; + } case TDMT_VND_FETCH_RSP: { - SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)msg; + SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)msg; - SCH_ERR_JRET(rspCode); - if (NULL == msg) { - SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); - } - - if (pJob->res) { - SCH_TASK_ELOG("got fetch rsp while res already exists, res:%p", pJob->res); - tfree(rsp); - SCH_ERR_JRET(TSDB_CODE_SCH_STATUS_ERROR); - } - - atomic_store_ptr(&pJob->res, rsp); - atomic_add_fetch_32(&pJob->resNumOfRows, htonl(rsp->numOfRows)); - - if (rsp->completed) { - SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_SUCCEED); - } - - SCH_TASK_DLOG("got fetch rsp, rows:%d, complete:%d", htonl(rsp->numOfRows), rsp->completed); - - schProcessOnDataFetched(pJob); - break; + SCH_ERR_JRET(rspCode); + if (NULL == msg) { + SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); } + + if (pJob->res) { + SCH_TASK_ELOG("got fetch rsp while res already exists, res:%p", pJob->res); + tfree(rsp); + SCH_ERR_JRET(TSDB_CODE_SCH_STATUS_ERROR); + } + + atomic_store_ptr(&pJob->res, rsp); + atomic_add_fetch_32(&pJob->resNumOfRows, htonl(rsp->numOfRows)); + + if (rsp->completed) { + SCH_SET_TASK_STATUS(pTask, JOB_TASK_STATUS_SUCCEED); + } + + SCH_TASK_DLOG("got fetch rsp, rows:%d, complete:%d", htonl(rsp->numOfRows), rsp->completed); + + schProcessOnDataFetched(pJob); + break; + } case TDMT_VND_DROP_TASK_RSP: { - // SHOULD NEVER REACH HERE - SCH_TASK_ELOG("invalid status to handle drop task rsp, refId:%" PRIx64, pJob->refId); - SCH_ERR_JRET(TSDB_CODE_SCH_INTERNAL_ERROR); - break; - } + // SHOULD NEVER REACH HERE + SCH_TASK_ELOG("invalid status to handle drop task rsp, refId:%" PRIx64, pJob->refId); + SCH_ERR_JRET(TSDB_CODE_SCH_INTERNAL_ERROR); + break; + } default: SCH_TASK_ELOG("unknown rsp msg, type:%d, status:%d", msgType, SCH_GET_TASK_STATUS(pTask)); SCH_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); @@ -1002,15 +992,15 @@ _return: SCH_RET(schProcessOnTaskFailure(pJob, pTask, code)); } - -int32_t schHandleCallback(void* param, const SDataBuf* pMsg, int32_t msgType, int32_t rspCode) { - int32_t code = 0; +int32_t schHandleCallback(void *param, const SDataBuf *pMsg, int32_t msgType, int32_t rspCode) { + int32_t code = 0; SSchCallbackParam *pParam = (SSchCallbackParam *)param; - SSchTask *pTask = NULL; - + SSchTask *pTask = NULL; + SSchJob *pJob = schAcquireJob(pParam->refId); if (NULL == pJob) { - qError("QID:0x%" PRIx64 ",TID:0x%" PRIx64 "taosAcquireRef job failed, may be dropped, refId:%" PRIx64, pParam->queryId, pParam->taskId, pParam->refId); + qError("QID:0x%" PRIx64 ",TID:0x%" PRIx64 "taosAcquireRef job failed, may be dropped, refId:%" PRIx64, + pParam->queryId, pParam->taskId, pParam->refId); SCH_ERR_JRET(TSDB_CODE_QRY_JOB_FREED); } @@ -1028,8 +1018,8 @@ int32_t schHandleCallback(void* param, const SDataBuf* pMsg, int32_t msgType, in pTask = *task; SCH_TASK_DLOG("rsp msg received, type:%s, code:%s", TMSG_INFO(msgType), tstrerror(rspCode)); - - pTask->handle = pMsg->handle; + + pTask->handle = pMsg->handle; SCH_ERR_JRET(schHandleResponseMsg(pJob, pTask, msgType, pMsg->pData, pMsg->len, rspCode)); _return: @@ -1042,42 +1032,41 @@ _return: SCH_RET(code); } -int32_t schHandleSubmitCallback(void* param, const SDataBuf* pMsg, int32_t code) { +int32_t schHandleSubmitCallback(void *param, const SDataBuf *pMsg, int32_t code) { return schHandleCallback(param, pMsg, TDMT_VND_SUBMIT_RSP, code); } -int32_t schHandleCreateTableCallback(void* param, const SDataBuf* pMsg, int32_t code) { +int32_t schHandleCreateTableCallback(void *param, const SDataBuf *pMsg, int32_t code) { return schHandleCallback(param, pMsg, TDMT_VND_CREATE_TABLE_RSP, code); } -int32_t schHandleQueryCallback(void* param, const SDataBuf* pMsg, int32_t code) { +int32_t schHandleQueryCallback(void *param, const SDataBuf *pMsg, int32_t code) { return schHandleCallback(param, pMsg, TDMT_VND_QUERY_RSP, code); } -int32_t schHandleFetchCallback(void* param, const SDataBuf* pMsg, int32_t code) { +int32_t schHandleFetchCallback(void *param, const SDataBuf *pMsg, int32_t code) { return schHandleCallback(param, pMsg, TDMT_VND_FETCH_RSP, code); } -int32_t schHandleReadyCallback(void* param, const SDataBuf* pMsg, int32_t code) { +int32_t schHandleReadyCallback(void *param, const SDataBuf *pMsg, int32_t code) { return schHandleCallback(param, pMsg, TDMT_VND_RES_READY_RSP, code); } -int32_t schHandleDropCallback(void* param, const SDataBuf* pMsg, int32_t code) { +int32_t schHandleDropCallback(void *param, const SDataBuf *pMsg, int32_t code) { SSchCallbackParam *pParam = (SSchCallbackParam *)param; - qDebug("QID:%"PRIx64",TID:%"PRIx64" drop task rsp received, code:%x", pParam->queryId, pParam->taskId, code); + qDebug("QID:%" PRIx64 ",TID:%" PRIx64 " drop task rsp received, code:%x", pParam->queryId, pParam->taskId, code); } - -int32_t schHandleHbCallback(void* param, const SDataBuf* pMsg, int32_t code) { +int32_t schHandleHbCallback(void *param, const SDataBuf *pMsg, int32_t code) { if (code) { qError("hb rsp error:%s", tstrerror(code)); SCH_ERR_RET(code); } - + SSchedulerHbRsp rsp = {0}; SSchCallbackParam *pParam = (SSchCallbackParam *)param; - + if (tDeserializeSSchedulerHbRsp(pMsg->pData, pMsg->len, &rsp)) { qError("invalid hb rsp msg, size:%d", pMsg->len); SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); @@ -1088,21 +1077,22 @@ int32_t schHandleHbCallback(void* param, const SDataBuf* pMsg, int32_t code) { trans.seqId = rsp.seqId; trans.trans.transInst = pParam->transport; trans.trans.transHandle = pMsg->handle; - + SCH_RET(schUpdateHbConnection(&rsp.epId, &trans)); } int32_t taskNum = (int32_t)taosArrayGetSize(rsp.taskStatus); for (int32_t i = 0; i < taskNum; ++i) { STaskStatus *taskStatus = taosArrayGet(rsp.taskStatus, i); - + SSchJob *pJob = schAcquireJob(taskStatus->refId); if (NULL == pJob) { - qWarn("job not found, refId:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64, taskStatus->refId, taskStatus->queryId, taskStatus->taskId); - //TODO DROP TASK FROM SERVER!!!! + qWarn("job not found, refId:0x%" PRIx64 ",QID:0x%" PRIx64 ",TID:0x%" PRIx64, taskStatus->refId, + taskStatus->queryId, taskStatus->taskId); + // TODO DROP TASK FROM SERVER!!!! continue; } - + // TODO schReleaseJob(taskStatus->refId); @@ -1115,22 +1105,21 @@ _return: SCH_RET(code); } - int32_t schGetCallbackFp(int32_t msgType, __async_send_cb_fn_t *fp) { switch (msgType) { case TDMT_VND_CREATE_TABLE: *fp = schHandleCreateTableCallback; break; - case TDMT_VND_SUBMIT: + case TDMT_VND_SUBMIT: *fp = schHandleSubmitCallback; break; - case TDMT_VND_QUERY: + case TDMT_VND_QUERY: *fp = schHandleQueryCallback; break; - case TDMT_VND_RES_READY: + case TDMT_VND_RES_READY: *fp = schHandleReadyCallback; break; - case TDMT_VND_FETCH: + case TDMT_VND_FETCH: *fp = schHandleFetchCallback; break; case TDMT_VND_DROP_TASK: @@ -1147,13 +1136,13 @@ int32_t schGetCallbackFp(int32_t msgType, __async_send_cb_fn_t *fp) { return TSDB_CODE_SUCCESS; } - -int32_t schAsyncSendMsg(SSchJob *pJob, SSchTask *pTask, void *transport, SEpSet* epSet, int32_t msgType, void *msg, uint32_t msgSize) { +int32_t schAsyncSendMsg(SSchJob *pJob, SSchTask *pTask, void *transport, SEpSet *epSet, int32_t msgType, void *msg, + uint32_t msgSize) { int32_t code = 0; SSchTrans *trans = (SSchTrans *)transport; - SMsgSendInfo* pMsgSendInfo = calloc(1, sizeof(SMsgSendInfo)); + SMsgSendInfo *pMsgSendInfo = calloc(1, sizeof(SMsgSendInfo)); if (NULL == pMsgSendInfo) { SCH_TASK_ELOG("calloc %d failed", (int32_t)sizeof(SMsgSendInfo)); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); @@ -1173,15 +1162,14 @@ int32_t schAsyncSendMsg(SSchJob *pJob, SSchTask *pTask, void *transport, SEpSet* param->taskId = SCH_TASK_ID(pTask); param->transport = trans->transInst; - pMsgSendInfo->param = param; pMsgSendInfo->msgInfo.pData = msg; pMsgSendInfo->msgInfo.len = msgSize; - pMsgSendInfo->msgInfo.handle = trans->transHandle; + pMsgSendInfo->msgInfo.handle = trans->transHandle; pMsgSendInfo->msgType = msgType; pMsgSendInfo->fp = fp; - - int64_t transporterId = 0; + + int64_t transporterId = 0; code = asyncSendMsgToServer(trans->transInst, epSet, &transporterId, pMsgSendInfo); if (code) { SCH_ERR_JRET(code); @@ -1191,7 +1179,7 @@ int32_t schAsyncSendMsg(SSchJob *pJob, SSchTask *pTask, void *transport, SEpSet* return TSDB_CODE_SUCCESS; _return: - + tfree(param); tfree(pMsgSendInfo); SCH_RET(code); @@ -1199,9 +1187,9 @@ _return: int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, int32_t msgType) { uint32_t msgSize = 0; - void *msg = NULL; - int32_t code = 0; - bool isCandidateAddr = false; + void *msg = NULL; + int32_t code = 0; + bool isCandidateAddr = false; if (NULL == addr) { addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx); isCandidateAddr = true; @@ -1235,13 +1223,13 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, SSubQueryMsg *pMsg = msg; pMsg->header.vgId = htonl(addr->nodeId); - pMsg->sId = htobe64(schMgmt.sId); - pMsg->queryId = htobe64(pJob->queryId); - pMsg->taskId = htobe64(pTask->taskId); - pMsg->refId = htobe64(pJob->refId); - pMsg->taskType = TASK_TYPE_TEMP; - pMsg->phyLen = htonl(pTask->msgLen); - pMsg->sqlLen = htonl(len); + pMsg->sId = htobe64(schMgmt.sId); + pMsg->queryId = htobe64(pJob->queryId); + pMsg->taskId = htobe64(pTask->taskId); + pMsg->refId = htobe64(pJob->refId); + pMsg->taskType = TASK_TYPE_TEMP; + pMsg->phyLen = htonl(pTask->msgLen); + pMsg->sqlLen = htonl(len); memcpy(pMsg->msg, pJob->sql, len); memcpy(pMsg->msg + len, pTask->msg, pTask->msgLen); @@ -1257,12 +1245,12 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, } SResReadyReq *pMsg = msg; - - pMsg->header.vgId = htonl(addr->nodeId); - - pMsg->sId = htobe64(schMgmt.sId); + + pMsg->header.vgId = htonl(addr->nodeId); + + pMsg->sId = htobe64(schMgmt.sId); pMsg->queryId = htobe64(pJob->queryId); - pMsg->taskId = htobe64(pTask->taskId); + pMsg->taskId = htobe64(pTask->taskId); break; } case TDMT_VND_FETCH: { @@ -1272,32 +1260,32 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, SCH_TASK_ELOG("calloc %d failed", msgSize); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - + SResFetchReq *pMsg = msg; - - pMsg->header.vgId = htonl(addr->nodeId); - - pMsg->sId = htobe64(schMgmt.sId); + + pMsg->header.vgId = htonl(addr->nodeId); + + pMsg->sId = htobe64(schMgmt.sId); pMsg->queryId = htobe64(pJob->queryId); - pMsg->taskId = htobe64(pTask->taskId); + pMsg->taskId = htobe64(pTask->taskId); break; } - case TDMT_VND_DROP_TASK:{ + case TDMT_VND_DROP_TASK: { msgSize = sizeof(STaskDropReq); msg = calloc(1, msgSize); if (NULL == msg) { SCH_TASK_ELOG("calloc %d failed", msgSize); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - + STaskDropReq *pMsg = msg; - - pMsg->header.vgId = htonl(addr->nodeId); - - pMsg->sId = htobe64(schMgmt.sId); + + pMsg->header.vgId = htonl(addr->nodeId); + + pMsg->sId = htobe64(schMgmt.sId); pMsg->queryId = htobe64(pJob->queryId); - pMsg->taskId = htobe64(pTask->taskId); - pMsg->refId = htobe64(pJob->refId); + pMsg->taskId = htobe64(pTask->taskId); + pMsg->refId = htobe64(pJob->refId); break; } case TDMT_VND_QUERY_HEARTBEAT: { @@ -1337,24 +1325,24 @@ int32_t schBuildAndSendMsg(SSchJob *pJob, SSchTask *pTask, SQueryNodeAddr *addr, if (isCandidateAddr) { SCH_ERR_RET(schRecordTaskExecNode(pJob, pTask, addr)); } - + return TSDB_CODE_SUCCESS; _return: SCH_SET_TASK_LASTMSG_TYPE(pTask, -1); - + tfree(msg); SCH_RET(code); } int32_t schEnsureHbConnection(SSchJob *pJob, SSchTask *pTask) { SQueryNodeAddr *addr = taosArrayGet(pTask->candidateAddrs, pTask->candidateIdx); - SQueryNodeEpId epId = {0}; + SQueryNodeEpId epId = {0}; epId.nodeId = addr->nodeId; memcpy(&epId.ep, SCH_GET_CUR_EP(addr), sizeof(SEp)); - + SSchHbTrans *hb = taosHashGet(schMgmt.hbConnections, &epId, sizeof(SQueryNodeEpId)); if (NULL == hb) { SCH_ERR_RET(schBuildAndSendMsg(pJob, NULL, addr, TDMT_VND_QUERY_HEARTBEAT)); @@ -1364,29 +1352,30 @@ int32_t schEnsureHbConnection(SSchJob *pJob, SSchTask *pTask) { } int32_t schLaunchTaskImpl(SSchJob *pJob, SSchTask *pTask) { - int8_t status = 0; + int8_t status = 0; int32_t code = 0; atomic_add_fetch_32(&pTask->level->taskLaunchedNum, 1); - + if (schJobNeedToStop(pJob, &status)) { SCH_TASK_DLOG("no need to launch task cause of job status, job status:%d", status); - + SCH_RET(atomic_load_32(&pJob->errCode)); } - + SSubplan *plan = pTask->plan; - if (NULL == pTask->msg) { // TODO add more detailed reason for failure + if (NULL == pTask->msg) { // TODO add more detailed reason for failure code = qSubPlanToString(plan, &pTask->msg, &pTask->msgLen); if (TSDB_CODE_SUCCESS != code) { - SCH_TASK_ELOG("failed to create physical plan, code:%s, msg:%p, len:%d", tstrerror(code), pTask->msg, pTask->msgLen); + SCH_TASK_ELOG("failed to create physical plan, code:%s, msg:%p, len:%d", tstrerror(code), pTask->msg, + pTask->msgLen); SCH_ERR_RET(code); } else { SCH_TASK_DLOG("physical plan len:%d, %s", pTask->msgLen, pTask->msg); } } - + SCH_ERR_RET(schSetTaskCandidateAddrs(pJob, pTask)); // NOTE: race condition: the task should be put into the hash table before send msg to server @@ -1398,15 +1387,15 @@ int32_t schLaunchTaskImpl(SSchJob *pJob, SSchTask *pTask) { if (SCH_IS_QUERY_JOB(pJob)) { SCH_ERR_RET(schEnsureHbConnection(pJob, pTask)); } - + SCH_ERR_RET(schBuildAndSendMsg(pJob, pTask, NULL, plan->msgType)); - + return TSDB_CODE_SUCCESS; } // Note: no more error processing, handled in function internal int32_t schLaunchTask(SSchJob *pJob, SSchTask *pTask) { - bool enough = false; + bool enough = false; int32_t code = 0; if (SCH_TASK_NEED_FLOW_CTRL(pJob, pTask)) { @@ -1436,11 +1425,9 @@ int32_t schLaunchLevelTasks(SSchJob *pJob, SSchLevel *level) { return TSDB_CODE_SUCCESS; } - - int32_t schLaunchJob(SSchJob *pJob) { SSchLevel *level = taosArrayGet(pJob->levels, pJob->levelIdx); - + SCH_ERR_RET(schCheckAndUpdateJobStatus(pJob, JOB_TASK_STATUS_EXECUTING)); SCH_ERR_RET(schCheckJobNeedFlowCtrl(pJob, level)); @@ -1457,7 +1444,7 @@ void schDropTaskOnExecutedNode(SSchJob *pJob, SSchTask *pTask) { } int32_t size = (int32_t)taosArrayGetSize(pTask->execAddrs); - + if (size <= 0) { SCH_TASK_DLOG("task has no exec address, no need to drop it, status:%d", SCH_GET_TASK_STATUS(pTask)); return; @@ -1481,9 +1468,9 @@ void schDropTaskInHashList(SSchJob *pJob, SHashObj *list) { if (!SCH_TASK_NO_NEED_DROP(pTask)) { schDropTaskOnExecutedNode(pJob, pTask); } - + pIter = taosHashIterate(list, pIter); - } + } } void schDropJobAllTasks(SSchJob *pJob) { @@ -1493,10 +1480,9 @@ void schDropJobAllTasks(SSchJob *pJob) { } int32_t schCancelJob(SSchJob *pJob) { - //TODO - - //TODO MOVE ALL TASKS FROM EXEC LIST TO FAIL LIST + // TODO + // TODO MOVE ALL TASKS FROM EXEC LIST TO FAIL LIST } void schFreeJobImpl(void *job) { @@ -1506,7 +1492,7 @@ void schFreeJobImpl(void *job) { SSchJob *pJob = job; uint64_t queryId = pJob->queryId; - int64_t refId = pJob->refId; + int64_t refId = pJob->refId; if (pJob->status == JOB_TASK_STATUS_EXECUTING) { schCancelJob(pJob); @@ -1514,55 +1500,55 @@ void schFreeJobImpl(void *job) { schDropJobAllTasks(pJob); - pJob->subPlans = NULL; // it is a reference to pDag->pSubplans - + pJob->subPlans = NULL; // it is a reference to pDag->pSubplans + int32_t numOfLevels = taosArrayGetSize(pJob->levels); - for(int32_t i = 0; i < numOfLevels; ++i) { + for (int32_t i = 0; i < numOfLevels; ++i) { SSchLevel *pLevel = taosArrayGet(pJob->levels, i); schFreeFlowCtrl(pLevel); - + int32_t numOfTasks = taosArrayGetSize(pLevel->subTasks); - for(int32_t j = 0; j < numOfTasks; ++j) { - SSchTask* pTask = taosArrayGet(pLevel->subTasks, j); + for (int32_t j = 0; j < numOfTasks; ++j) { + SSchTask *pTask = taosArrayGet(pLevel->subTasks, j); schFreeTask(pTask); } taosArrayDestroy(pLevel->subTasks); } - + taosHashCleanup(pJob->execTasks); taosHashCleanup(pJob->failTasks); taosHashCleanup(pJob->succTasks); - + taosArrayDestroy(pJob->levels); taosArrayDestroy(pJob->nodeList); tfree(pJob->res); - + tfree(pJob); - qDebug("QID:0x%"PRIx64" job freed, refId:%" PRIx64 ", pointer:%p", queryId, refId, pJob); + qDebug("QID:0x%" PRIx64 " job freed, refId:%" PRIx64 ", pointer:%p", queryId, refId, pJob); } - -static int32_t schExecJobImpl(void *transport, SArray *pNodeList, SQueryPlan* pDag, int64_t *job, const char* sql, bool syncSchedule) { - qDebug("QID:0x%"PRIx64" job started", pDag->queryId); +static int32_t schExecJobImpl(void *transport, SArray *pNodeList, SQueryPlan *pDag, int64_t *job, const char *sql, + bool syncSchedule) { + qDebug("QID:0x%" PRIx64 " job started", pDag->queryId); if (pNodeList == NULL || (pNodeList && taosArrayGetSize(pNodeList) <= 0)) { - qDebug("QID:0x%"PRIx64" input exec nodeList is empty", pDag->queryId); + qDebug("QID:0x%" PRIx64 " input exec nodeList is empty", pDag->queryId); } - int32_t code = 0; + int32_t code = 0; SSchJob *pJob = calloc(1, sizeof(SSchJob)); if (NULL == pJob) { - qError("QID:%"PRIx64" calloc %d failed", pDag->queryId, (int32_t)sizeof(SSchJob)); + qError("QID:%" PRIx64 " calloc %d failed", pDag->queryId, (int32_t)sizeof(SSchJob)); SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } pJob->attr.syncSchedule = syncSchedule; pJob->transport = transport; - pJob->sql = sql; + pJob->sql = sql; if (pNodeList != NULL) { pJob->nodeList = taosArrayDup(pNodeList); @@ -1570,19 +1556,22 @@ static int32_t schExecJobImpl(void *transport, SArray *pNodeList, SQueryPlan* pD SCH_ERR_JRET(schValidateAndBuildJob(pDag, pJob)); - pJob->execTasks = taosHashInit(pDag->numOfSubplans, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_ENTRY_LOCK); + pJob->execTasks = + taosHashInit(pDag->numOfSubplans, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_ENTRY_LOCK); if (NULL == pJob->execTasks) { SCH_JOB_ELOG("taosHashInit %d execTasks failed", pDag->numOfSubplans); SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - pJob->succTasks = taosHashInit(pDag->numOfSubplans, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_ENTRY_LOCK); + pJob->succTasks = + taosHashInit(pDag->numOfSubplans, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_ENTRY_LOCK); if (NULL == pJob->succTasks) { SCH_JOB_ELOG("taosHashInit %d succTasks failed", pDag->numOfSubplans); SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); } - pJob->failTasks = taosHashInit(pDag->numOfSubplans, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_ENTRY_LOCK); + pJob->failTasks = + taosHashInit(pDag->numOfSubplans, taosGetDefaultHashFunction(TSDB_DATA_TYPE_UBIGINT), false, HASH_ENTRY_LOCK); if (NULL == pJob->failTasks) { SCH_JOB_ELOG("taosHashInit %d failTasks failed", pDag->numOfSubplans); SCH_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); @@ -1602,9 +1591,9 @@ static int32_t schExecJobImpl(void *transport, SArray *pNodeList, SQueryPlan* pD SCH_ERR_JRET(schLaunchJob(pJob)); schAcquireJob(pJob->refId); - + *job = pJob->refId; - + if (syncSchedule) { SCH_JOB_DLOG("will wait for rsp now, job status:%d", SCH_GET_JOB_STATUS(pJob)); tsem_wait(&pJob->rspSem); @@ -1613,7 +1602,7 @@ static int32_t schExecJobImpl(void *transport, SArray *pNodeList, SQueryPlan* pD SCH_JOB_DLOG("job exec done, job status:%d", SCH_GET_JOB_STATUS(pJob)); schReleaseJob(pJob->refId); - + return TSDB_CODE_SUCCESS; _return: @@ -1622,7 +1611,6 @@ _return: SCH_RET(code); } - int32_t schedulerInit(SSchedulerCfg *cfg) { if (schMgmt.jobRef) { qError("scheduler already initialized"); @@ -1631,7 +1619,7 @@ int32_t schedulerInit(SSchedulerCfg *cfg) { if (cfg) { schMgmt.cfg = *cfg; - + if (schMgmt.cfg.maxJobNum == 0) { schMgmt.cfg.maxJobNum = SCHEDULE_DEFAULT_MAX_JOB_NUM; } @@ -1642,7 +1630,7 @@ int32_t schedulerInit(SSchedulerCfg *cfg) { schMgmt.cfg.maxJobNum = SCHEDULE_DEFAULT_MAX_JOB_NUM; schMgmt.cfg.maxNodeTableNum = SCHEDULE_DEFAULT_MAX_NODE_TABLE_NUM; } - + schMgmt.jobRef = taosOpenRef(schMgmt.cfg.maxJobNum, schFreeJobImpl); if (schMgmt.jobRef < 0) { qError("init schduler jobRef failed, num:%u", schMgmt.cfg.maxJobNum); @@ -1660,12 +1648,13 @@ int32_t schedulerInit(SSchedulerCfg *cfg) { SCH_ERR_RET(TSDB_CODE_QRY_SYS_ERROR); } - qInfo("scheduler %"PRIx64" initizlized, maxJob:%u", schMgmt.sId, schMgmt.cfg.maxJobNum); - + qInfo("scheduler %" PRIx64 " initizlized, maxJob:%u", schMgmt.sId, schMgmt.cfg.maxJobNum); + return TSDB_CODE_SUCCESS; } -int32_t schedulerExecJob(void *transport, SArray *nodeList, SQueryPlan* pDag, int64_t *pJob, const char* sql, SQueryResult *pRes) { +int32_t schedulerExecJob(void *transport, SArray *nodeList, SQueryPlan *pDag, int64_t *pJob, const char *sql, + SQueryResult *pRes) { if (NULL == transport || NULL == pDag || NULL == pDag->pSubplans || NULL == pJob || NULL == pRes) { SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } @@ -1676,20 +1665,21 @@ int32_t schedulerExecJob(void *transport, SArray *nodeList, SQueryPlan* pDag, in pRes->code = atomic_load_32(&job->errCode); pRes->numOfRows = job->resNumOfRows; schReleaseJob(*pJob); - + return TSDB_CODE_SUCCESS; } -int32_t schedulerAsyncExecJob(void *transport, SArray *pNodeList, SQueryPlan* pDag, const char* sql, int64_t *pJob) { +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); } SCH_ERR_RET(schExecJobImpl(transport, pNodeList, pDag, pJob, sql, false)); - + return TSDB_CODE_SUCCESS; } +#if 0 int32_t schedulerConvertDagToTaskList(SQueryPlan* pDag, SArray **pTasks) { if (NULL == pDag || pDag->numOfSubplans <= 0 || LIST_LENGTH(pDag->pSubplans) == 0) { SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); @@ -1810,14 +1800,14 @@ _return: SCH_RET(code); } +#endif - -int32_t schedulerFetchRows(int64_t job, void** pData) { +int32_t schedulerFetchRows(int64_t job, void **pData) { if (NULL == pData) { SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } - int32_t code = 0; + int32_t code = 0; SSchJob *pJob = schAcquireJob(job); if (NULL == pJob) { qError("acquire job from jobRef list failed, may be dropped, refId:%" PRIx64, job); @@ -1861,12 +1851,11 @@ int32_t schedulerFetchRows(int64_t job, void** pData) { SCH_JOB_ELOG("job failed or dropping, status:%d", status); SCH_ERR_JRET(atomic_load_32(&pJob->errCode)); } - + if (pJob->res && ((SRetrieveTableRsp *)pJob->res)->completed) { SCH_ERR_JRET(schCheckAndUpdateJobStatus(pJob, JOB_TASK_STATUS_SUCCEED)); } - while (true) { *pData = atomic_load_ptr(&pJob->res); if (*pData != atomic_val_compare_exchange_ptr(&pJob->res, *pData, NULL)) { @@ -1891,7 +1880,7 @@ int32_t schedulerFetchRows(int64_t job, void** pData) { _return: atomic_val_compare_exchange_8(&pJob->userFetch, 1, 0); - + schReleaseJob(job); SCH_RET(code); @@ -1944,17 +1933,17 @@ void schedulerFreeTaskList(SArray *taskList) { taosArrayDestroy(taskList); } - + void schedulerDestroy(void) { if (schMgmt.jobRef) { SSchJob *pJob = taosIterateRef(schMgmt.jobRef, 0); - + while (pJob) { taosRemoveRef(schMgmt.jobRef, pJob->refId); - + pJob = taosIterateRef(schMgmt.jobRef, pJob->refId); } - + taosCloseRef(schMgmt.jobRef); schMgmt.jobRef = 0; } diff --git a/source/util/src/tuuid.c b/source/util/src/tuuid.c new file mode 100644 index 0000000000..0405403220 --- /dev/null +++ b/source/util/src/tuuid.c @@ -0,0 +1,59 @@ +/* + * 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 "tuuid.h" + +static int64_t hashId = 0; +static int32_t SerialNo = 0; + +int32_t tGenIdPI32(void) { + if (hashId == 0) { + char uid[64]; + int32_t code = taosGetSystemUUID(uid, tListLen(uid)); + if (code != TSDB_CODE_SUCCESS) { + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } else { + hashId = MurmurHash3_32(uid, strlen(uid)); + } + } + + int64_t ts = taosGetTimestampMs(); + uint64_t pid = taosGetPId(); + int32_t val = atomic_add_fetch_32(&SerialNo, 1); + + int32_t id = ((hashId & 0x1F) << 26) | ((pid & 0x3F) << 20) | ((ts & 0xFFF) << 8) | (val & 0xFF); + return id; +} + +int64_t tGenIdPI64(void) { + if (hashId == 0) { + char uid[64]; + int32_t code = taosGetSystemUUID(uid, tListLen(uid)); + if (code != TSDB_CODE_SUCCESS) { + terrno = TAOS_SYSTEM_ERROR(errno); + return -1; + } else { + hashId = MurmurHash3_32(uid, strlen(uid)); + } + } + + int64_t ts = taosGetTimestampMs(); + uint64_t pid = taosGetPId(); + int32_t val = atomic_add_fetch_32(&SerialNo, 1); + + int64_t id = ((hashId & 0x07FF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF); + return id; +} From eae2d7b661c71ed64f16a4b56d949e3bbb71d77d Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Tue, 15 Mar 2022 04:00:09 -0400 Subject: [PATCH 13/38] TD-13675 create sma index grammar --- include/common/tmsg.h | 16 +- include/common/ttime.h | 11 + include/common/ttokendef.h | 101 +- include/libs/nodes/cmdnodes.h | 28 +- include/libs/nodes/nodes.h | 7 + include/libs/nodes/querynodes.h | 1 + include/util/tjson.h | 1 + source/libs/nodes/src/nodesCodeFuncs.c | 56 +- source/libs/nodes/src/nodesUtilFuncs.c | 8 + source/libs/parser/inc/parAst.h | 16 +- source/libs/parser/inc/sql.y | 32 +- source/libs/parser/src/parAstCreater.c | 67 +- source/libs/parser/src/parTokenizer.c | 3 +- source/libs/parser/src/parTranslater.c | 93 +- source/libs/parser/src/sql.c | 2686 +++++++++++---------- source/libs/parser/test/parserAstTest.cpp | 7 + source/util/src/tjson.c | 8 + 17 files changed, 1723 insertions(+), 1418 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 5975bf0a29..863f29637e 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1914,11 +1914,12 @@ typedef struct { int8_t slidingUnit; char indexName[TSDB_INDEX_NAME_LEN]; char timezone[TD_TIMEZONE_LEN]; // sma data is invalid if timezone change. - uint16_t exprLen; - uint16_t tagsFilterLen; + int32_t exprLen; + int32_t tagsFilterLen; int64_t indexUid; tb_uid_t tableUid; // super/child/common table uid int64_t interval; + int64_t offset; int64_t sliding; char* expr; // sma expression char* tagsFilter; @@ -2020,11 +2021,12 @@ static FORCE_INLINE int32_t tEncodeTSma(void** buf, const STSma* pSma) { tlen += taosEncodeFixedI8(buf, pSma->slidingUnit); tlen += taosEncodeString(buf, pSma->indexName); tlen += taosEncodeString(buf, pSma->timezone); - tlen += taosEncodeFixedU16(buf, pSma->exprLen); - tlen += taosEncodeFixedU16(buf, pSma->tagsFilterLen); + tlen += taosEncodeFixedI32(buf, pSma->exprLen); + tlen += taosEncodeFixedI32(buf, pSma->tagsFilterLen); tlen += taosEncodeFixedI64(buf, pSma->indexUid); tlen += taosEncodeFixedI64(buf, pSma->tableUid); tlen += taosEncodeFixedI64(buf, pSma->interval); + tlen += taosEncodeFixedI64(buf, pSma->offset); tlen += taosEncodeFixedI64(buf, pSma->sliding); if (pSma->exprLen > 0) { @@ -2054,14 +2056,14 @@ static FORCE_INLINE void* tDecodeTSma(void* buf, STSma* pSma) { buf = taosDecodeFixedI8(buf, &pSma->slidingUnit); buf = taosDecodeStringTo(buf, pSma->indexName); buf = taosDecodeStringTo(buf, pSma->timezone); - buf = taosDecodeFixedU16(buf, &pSma->exprLen); - buf = taosDecodeFixedU16(buf, &pSma->tagsFilterLen); + buf = taosDecodeFixedI32(buf, &pSma->exprLen); + buf = taosDecodeFixedI32(buf, &pSma->tagsFilterLen); buf = taosDecodeFixedI64(buf, &pSma->indexUid); buf = taosDecodeFixedI64(buf, &pSma->tableUid); buf = taosDecodeFixedI64(buf, &pSma->interval); + buf = taosDecodeFixedI64(buf, &pSma->offset); buf = taosDecodeFixedI64(buf, &pSma->sliding); - if (pSma->exprLen > 0) { pSma->expr = (char*)calloc(pSma->exprLen, 1); if (pSma->expr != NULL) { diff --git a/include/common/ttime.h b/include/common/ttime.h index b71426e312..57af24e635 100644 --- a/include/common/ttime.h +++ b/include/common/ttime.h @@ -25,6 +25,17 @@ extern "C" { #define TIME_IS_VAR_DURATION(_t) ((_t) == 'n' || (_t) == 'y' || (_t) == 'N' || (_t) == 'Y') +#define TIME_UNIT_NANOSECOND 'b' +#define TIME_UNIT_MICROSECOND 'u' +#define TIME_UNIT_MILLISECOND 'a' +#define TIME_UNIT_SECOND 's' +#define TIME_UNIT_MINUTE 'm' +#define TIME_UNIT_HOUR 'h' +#define TIME_UNIT_DAY 'd' +#define TIME_UNIT_WEEK 'w' +#define TIME_UNIT_MONTH 'n' +#define TIME_UNIT_YEAR 'y' + /* * @return timestamp decided by global conf variable, tsTimePrecision * if precision == TSDB_TIME_PRECISION_MICRO, it returns timestamp in microsecond. diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 2121b3175a..6745b80ac0 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -101,55 +101,58 @@ #define TK_VARBINARY 83 #define TK_DECIMAL 84 #define TK_SMA 85 -#define TK_MNODES 86 -#define TK_NK_FLOAT 87 -#define TK_NK_BOOL 88 -#define TK_NK_VARIABLE 89 -#define TK_BETWEEN 90 -#define TK_IS 91 -#define TK_NULL 92 -#define TK_NK_LT 93 -#define TK_NK_GT 94 -#define TK_NK_LE 95 -#define TK_NK_GE 96 -#define TK_NK_NE 97 -#define TK_NK_EQ 98 -#define TK_LIKE 99 -#define TK_MATCH 100 -#define TK_NMATCH 101 -#define TK_IN 102 -#define TK_FROM 103 -#define TK_AS 104 -#define TK_JOIN 105 -#define TK_ON 106 -#define TK_INNER 107 -#define TK_SELECT 108 -#define TK_DISTINCT 109 -#define TK_WHERE 110 -#define TK_PARTITION 111 -#define TK_BY 112 -#define TK_SESSION 113 -#define TK_STATE_WINDOW 114 -#define TK_INTERVAL 115 -#define TK_SLIDING 116 -#define TK_FILL 117 -#define TK_VALUE 118 -#define TK_NONE 119 -#define TK_PREV 120 -#define TK_LINEAR 121 -#define TK_NEXT 122 -#define TK_GROUP 123 -#define TK_HAVING 124 -#define TK_ORDER 125 -#define TK_SLIMIT 126 -#define TK_SOFFSET 127 -#define TK_LIMIT 128 -#define TK_OFFSET 129 -#define TK_ASC 130 -#define TK_DESC 131 -#define TK_NULLS 132 -#define TK_FIRST 133 -#define TK_LAST 134 +#define TK_INDEX 86 +#define TK_ON 87 +#define TK_FULLTEXT 88 +#define TK_FUNCTION 89 +#define TK_INTERVAL 90 +#define TK_MNODES 91 +#define TK_NK_FLOAT 92 +#define TK_NK_BOOL 93 +#define TK_NK_VARIABLE 94 +#define TK_BETWEEN 95 +#define TK_IS 96 +#define TK_NULL 97 +#define TK_NK_LT 98 +#define TK_NK_GT 99 +#define TK_NK_LE 100 +#define TK_NK_GE 101 +#define TK_NK_NE 102 +#define TK_NK_EQ 103 +#define TK_LIKE 104 +#define TK_MATCH 105 +#define TK_NMATCH 106 +#define TK_IN 107 +#define TK_FROM 108 +#define TK_AS 109 +#define TK_JOIN 110 +#define TK_INNER 111 +#define TK_SELECT 112 +#define TK_DISTINCT 113 +#define TK_WHERE 114 +#define TK_PARTITION 115 +#define TK_BY 116 +#define TK_SESSION 117 +#define TK_STATE_WINDOW 118 +#define TK_SLIDING 119 +#define TK_FILL 120 +#define TK_VALUE 121 +#define TK_NONE 122 +#define TK_PREV 123 +#define TK_LINEAR 124 +#define TK_NEXT 125 +#define TK_GROUP 126 +#define TK_HAVING 127 +#define TK_ORDER 128 +#define TK_SLIMIT 129 +#define TK_SOFFSET 130 +#define TK_LIMIT 131 +#define TK_OFFSET 132 +#define TK_ASC 133 +#define TK_DESC 134 +#define TK_NULLS 135 +#define TK_FIRST 136 +#define TK_LAST 137 #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 084258e48f..aa539667e4 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -23,6 +23,7 @@ extern "C" { #include "querynodes.h" typedef struct SDatabaseOptions { + ENodeType type; int32_t numOfBlocks; int32_t cacheBlockSize; int8_t cachelast; @@ -46,7 +47,7 @@ typedef struct SCreateDatabaseStmt { ENodeType type; char dbName[TSDB_DB_NAME_LEN]; bool ignoreExists; - SDatabaseOptions options; + SDatabaseOptions* pOptions; } SCreateDatabaseStmt; typedef struct SUseDatabaseStmt { @@ -61,6 +62,7 @@ typedef struct SDropDatabaseStmt { } SDropDatabaseStmt; typedef struct STableOptions { + ENodeType type; int32_t keep; int32_t ttl; char comments[TSDB_STB_COMMENT_LEN]; @@ -81,7 +83,7 @@ typedef struct SCreateTableStmt { bool ignoreExists; SNodeList* pCols; SNodeList* pTags; - STableOptions options; + STableOptions* pOptions; } SCreateTableStmt; typedef struct SCreateSubTableClause { @@ -155,6 +157,28 @@ typedef struct SShowStmt { char dbName[TSDB_DB_NAME_LEN]; } SShowStmt; +typedef enum EIndexType { + INDEX_TYPE_SMA = 1, + INDEX_TYPE_FULLTEXT +} EIndexType; + +typedef struct SIndexOptions { + ENodeType type; + SNodeList* pFuncs; + SNode* pInterval; + SNode* pOffset; + SNode* pSliding; +} SIndexOptions; + +typedef struct SCreateIndexStmt { + ENodeType type; + EIndexType indexType; + char indexName[TSDB_INDEX_NAME_LEN]; + char tableName[TSDB_TABLE_NAME_LEN]; + SNodeList* pCols; + SIndexOptions* pOptions; +} SCreateIndexStmt; + #ifdef __cplusplus } #endif diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 3a9dd3c713..46b89416b7 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -67,6 +67,9 @@ typedef enum ENodeType { QUERY_NODE_SLOT_DESC, QUERY_NODE_COLUMN_DEF, QUERY_NODE_DOWNSTREAM_SOURCE, + QUERY_NODE_DATABASE_OPTIONS, + QUERY_NODE_TABLE_OPTIONS, + QUERY_NODE_INDEX_OPTIONS, // Statement nodes are used in parser and planner module. QUERY_NODE_SET_OPERATOR, @@ -93,6 +96,7 @@ typedef enum ENodeType { QUERY_NODE_SHOW_DNODES_STMT, QUERY_NODE_SHOW_VGROUPS_STMT, QUERY_NODE_SHOW_MNODES_STMT, + QUERY_NODE_CREATE_INDEX_STMT, // logic plan node QUERY_NODE_LOGIC_PLAN_SCAN, @@ -185,6 +189,9 @@ const char* nodesNodeName(ENodeType type); int32_t nodesNodeToString(const SNodeptr pNode, bool format, char** pStr, int32_t* pLen); int32_t nodesStringToNode(const char* pStr, SNode** pNode); +int32_t nodesListToString(const SNodeList* pList, bool format, char** pStr, int32_t* pLen); +int32_t nodesStringToList(const char* pStr, SNodeList** pList); + #ifdef __cplusplus } #endif diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 6a6d508096..fe44d8666b 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -82,6 +82,7 @@ typedef struct SValueNode { double d; char* p; } datum; + char unit; } SValueNode; typedef struct SOperatorNode { diff --git a/include/util/tjson.h b/include/util/tjson.h index 335ff0d4ba..1218caae35 100644 --- a/include/util/tjson.h +++ b/include/util/tjson.h @@ -25,6 +25,7 @@ extern "C" { typedef void SJson; SJson* tjsonCreateObject(); +SJson* tjsonCreateArray(); void tjsonDelete(SJson* pJson); SJson* tjsonAddArrayToObject(SJson* pJson, const char* pName); diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 57ebc2c4b6..2a4c98d894 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -151,8 +151,7 @@ static int32_t nodeListToJson(SJson* pJson, const char* pName, const SNodeList* return TSDB_CODE_SUCCESS; } -static int32_t jsonToNodeList(const SJson* pJson, const char* pName, SNodeList** pList) { - const SJson* pJsonArray = tjsonGetObjectItem(pJson, pName); +static int32_t jsonToNodeListImpl(const SJson* pJsonArray, SNodeList** pList) { int32_t size = (NULL == pJsonArray ? 0 : tjsonGetArraySize(pJsonArray)); if (size > 0) { *pList = nodesMakeList(); @@ -176,6 +175,10 @@ static int32_t jsonToNodeList(const SJson* pJson, const char* pName, SNodeList** return code; } +static int32_t jsonToNodeList(const SJson* pJson, const char* pName, SNodeList** pList) { + return jsonToNodeListImpl(tjsonGetObjectItem(pJson, pName), pList); +} + static const char* jkTableMetaUid = "TableMetaUid"; static const char* jkTableMetaSuid = "TableMetaSuid"; @@ -1750,3 +1753,52 @@ int32_t nodesStringToNode(const char* pStr, SNode** pNode) { } return TSDB_CODE_SUCCESS; } + +int32_t nodesListToString(const SNodeList* pList, bool format, char** pStr, int32_t* pLen) { + if (NULL == pList || NULL == pStr || NULL == pLen) { + terrno = TSDB_CODE_FAILED; + return TSDB_CODE_FAILED; + } + + if (0 == LIST_LENGTH(pList)) { + return TSDB_CODE_SUCCESS; + } + + SJson* pJson = tjsonCreateArray(); + if (NULL == pJson) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; + } + + SNode* pNode; + FOREACH(pNode, pList) { + int32_t code = tjsonAddItem(pJson, nodeToJson, pNode); + if (TSDB_CODE_SUCCESS != code) { + terrno = code; + return code; + } + } + + *pStr = format ? tjsonToString(pJson) : tjsonToUnformattedString(pJson); + tjsonDelete(pJson); + + *pLen = strlen(*pStr) + 1; + return TSDB_CODE_SUCCESS; +} + +int32_t nodesStringToList(const char* pStr, SNodeList** pList) { + if (NULL == pStr || NULL == pList) { + return TSDB_CODE_SUCCESS; + } + SJson* pJson = tjsonParse(pStr); + if (NULL == pJson) { + return TSDB_CODE_FAILED; + } + int32_t code = jsonToNodeListImpl(pJson, pList); + if (TSDB_CODE_SUCCESS != code) { + nodesDestroyList(*pList); + terrno = code; + return code; + } + return TSDB_CODE_SUCCESS; +} diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 0adbf8cb2f..cc99387095 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -76,6 +76,12 @@ SNodeptr nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SColumnDefNode)); case QUERY_NODE_DOWNSTREAM_SOURCE: return makeNode(type, sizeof(SDownstreamSourceNode)); + case QUERY_NODE_DATABASE_OPTIONS: + return makeNode(type, sizeof(SDatabaseOptions)); + case QUERY_NODE_TABLE_OPTIONS: + return makeNode(type, sizeof(STableOptions)); + case QUERY_NODE_INDEX_OPTIONS: + return makeNode(type, sizeof(SIndexOptions)); case QUERY_NODE_SET_OPERATOR: return makeNode(type, sizeof(SSetOperator)); case QUERY_NODE_SELECT_STMT: @@ -122,6 +128,8 @@ SNodeptr nodesMakeNode(ENodeType type) { case QUERY_NODE_SHOW_VGROUPS_STMT: case QUERY_NODE_SHOW_MNODES_STMT: return makeNode(type, sizeof(SShowStmt)); + case QUERY_NODE_CREATE_INDEX_STMT: + return makeNode(type, sizeof(SCreateIndexStmt)); case QUERY_NODE_LOGIC_PLAN_SCAN: return makeNode(type, sizeof(SScanLogicNode)); case QUERY_NODE_LOGIC_PLAN_JOIN: diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 11c56ddf3c..bb22e5703d 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -109,17 +109,17 @@ SNode* addLimitClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pLimit); SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pProjectionList, SNode* pTable); SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode* pLeft, SNode* pRight); -SDatabaseOptions* createDefaultDatabaseOptions(SAstCreateContext* pCxt); -SDatabaseOptions* setDatabaseOption(SAstCreateContext* pCxt, SDatabaseOptions* pOptions, EDatabaseOptionType type, const SToken* pVal); -SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pDbName, SDatabaseOptions* pOptions); +SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt); +SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, const SToken* pVal); +SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pDbName, SNode* pOptions); SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pDbName); -STableOptions* createDefaultTableOptions(SAstCreateContext* pCxt); -STableOptions* setTableOption(SAstCreateContext* pCxt, STableOptions* pOptions, ETableOptionType type, const SToken* pVal); -STableOptions* setTableSmaOption(SAstCreateContext* pCxt, STableOptions* pOptions, SNodeList* pSma); +SNode* createDefaultTableOptions(SAstCreateContext* pCxt); +SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, const SToken* pVal); +SNode* setTableSmaOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pSma); SNode* createColumnDefNode(SAstCreateContext* pCxt, const SToken* pColName, SDataType dataType, const SToken* pComment); SDataType createDataType(uint8_t type); SDataType createVarLenDataType(uint8_t type, const SToken* pLen); -SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNodeList* pCols, SNodeList* pTags, STableOptions* pOptions); +SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNodeList* pCols, SNodeList* pTags, SNode* pOptions); SNode* createCreateSubTableClause(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNode* pUseRealTable, SNodeList* pSpecificTags, SNodeList* pValsOfTags); SNode* createCreateMultiTableStmt(SAstCreateContext* pCxt, SNodeList* pSubTables); SNode* createDropTableClause(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable); @@ -132,6 +132,8 @@ SNode* createAlterUserStmt(SAstCreateContext* pCxt, const SToken* pUserName, int SNode* createDropUserStmt(SAstCreateContext* pCxt, const SToken* pUserName); SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SToken* pPort); SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode); +SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, const SToken* pIndexName, const SToken* pTableName, SNodeList* pCols, SNode* pOptions); +SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding); #ifdef __cplusplus } diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index f4ed3d8597..7515466b47 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -80,8 +80,6 @@ not_exists_opt(A) ::= . exists_opt(A) ::= IF EXISTS. { A = true; } exists_opt(A) ::= . { A = false; } -%type db_options { SDatabaseOptions* } -%destructor db_options { tfree($$); } db_options(A) ::= . { A = createDefaultDatabaseOptions(pCxt); } db_options(A) ::= db_options(B) BLOCKS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_BLOCKS, &C); } db_options(A) ::= db_options(B) CACHE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_CACHE, &C); } @@ -179,8 +177,6 @@ tags_def_opt(A) ::= tags_def(B). %destructor tags_def { nodesDestroyList($$); } tags_def(A) ::= TAGS NK_LP column_def_list(B) NK_RP. { A = B; } -%type table_options { STableOptions* } -%destructor table_options { tfree($$); } table_options(A) ::= . { A = createDefaultTableOptions(pCxt);} table_options(A) ::= table_options(B) COMMENT NK_STRING(C). { A = setTableOption(pCxt, B, TABLE_OPTION_COMMENT, &C); } table_options(A) ::= table_options(B) KEEP NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_KEEP, &C); } @@ -194,6 +190,24 @@ col_name_list(A) ::= col_name_list(B) NK_COMMA col_name(C). col_name(A) ::= column_name(B). { A = createColumnNode(pCxt, NULL, &B); } +/************************************************ create index ********************************************************/ +cmd ::= CREATE SMA INDEX index_name(A) ON table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &A, &B, NULL, C); } +cmd ::= CREATE FULLTEXT INDEX + index_name(A) ON table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &A, &B, C, NULL); } + +index_options(A) ::= . { A = NULL; } +index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL + NK_LP duration_literal(C) NK_RP sliding_opt(D). { A = createIndexOption(pCxt, B, C, NULL, D); } +index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL + NK_LP duration_literal(C) NK_COMMA duration_literal(D) NK_RP sliding_opt(E). { A = createIndexOption(pCxt, B, C, D, E); } + +%type func_list { SNodeList* } +%destructor func_list { nodesDestroyList($$); } +func_list(A) ::= func(B). { A = createNodeList(pCxt, B); } +func_list(A) ::= func_list(B) NK_COMMA func(C). { A = addNodeToList(pCxt, B, C); } + +func(A) ::= function_name(B) NK_LP expression_list(C) NK_RP. { A = createFunctionNode(pCxt, &B, C); } + /************************************************ show vgroups ********************************************************/ cmd ::= SHOW VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, NULL); } cmd ::= SHOW db_name(B) NK_DOT VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &B); } @@ -248,6 +262,10 @@ column_alias(A) ::= NK_ID(B). %destructor user_name { } user_name(A) ::= NK_ID(B). { A = B; } +%type index_name { SToken } +%destructor index_name { } +index_name(A) ::= NK_ID(B). { A = B; } + /************************************************ expression **********************************************************/ expression(A) ::= literal(B). { A = B; } //expression(A) ::= NK_QUESTION(B). { A = B; } @@ -463,13 +481,13 @@ twindow_clause_opt(A) ::= SESSION NK_LP column_reference(B) NK_COMMA NK_INTEGER(C) NK_RP. { A = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, B), &C); } twindow_clause_opt(A) ::= STATE_WINDOW NK_LP column_reference(B) NK_RP. { A = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, B)); } twindow_clause_opt(A) ::= - INTERVAL NK_LP duration_literal(B) NK_RP sliding_opt(C) fill_opt(D). { A = createIntervalWindowNode(pCxt, B, NULL, C, D); } + INTERVAL NK_LP duration_literal(B) NK_RP sliding_opt(C) fill_opt(D). { A = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, B), NULL, C, D); } twindow_clause_opt(A) ::= INTERVAL NK_LP duration_literal(B) NK_COMMA duration_literal(C) NK_RP - sliding_opt(D) fill_opt(E). { A = createIntervalWindowNode(pCxt, B, C, D, E); } + sliding_opt(D) fill_opt(E). { A = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C), D, E); } sliding_opt(A) ::= . { A = NULL; } -sliding_opt(A) ::= SLIDING NK_LP duration_literal(B) NK_RP. { A = B; } +sliding_opt(A) ::= SLIDING NK_LP duration_literal(B) NK_RP. { A = releaseRawExprNode(pCxt, B); } fill_opt(A) ::= . { A = NULL; } fill_opt(A) ::= FILL NK_LP fill_mode(B) NK_RP. { A = createFillNode(pCxt, B, NULL); } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index f21db0f133..994ca53a0f 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -420,6 +420,14 @@ static bool checkColumnName(SAstCreateContext* pCxt, const SToken* pColumnName) return pCxt->valid; } +static bool checkIndexName(SAstCreateContext* pCxt, const SToken* pIndexName) { + if (NULL == pIndexName) { + return false; + } + pCxt->valid = pIndexName->n < TSDB_INDEX_NAME_LEN ? true : false; + return pCxt->valid; +} + SNode* createRawExprNode(SAstCreateContext* pCxt, const SToken* pToken, SNode* pNode) { SRawExprNode* target = (SRawExprNode*)nodesMakeNode(QUERY_NODE_RAW_EXPR); CHECK_OUT_OF_MEM(target); @@ -741,8 +749,8 @@ SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode* return (SNode*)setOp; } -SDatabaseOptions* createDefaultDatabaseOptions(SAstCreateContext* pCxt) { - SDatabaseOptions* pOptions = calloc(1, sizeof(SDatabaseOptions)); +SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt) { + SDatabaseOptions* pOptions = nodesMakeNode(QUERY_NODE_DATABASE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->numOfBlocks = TSDB_DEFAULT_TOTAL_BLOCKS; pOptions->cacheBlockSize = TSDB_DEFAULT_CACHE_BLOCK_SIZE; @@ -761,14 +769,14 @@ SDatabaseOptions* createDefaultDatabaseOptions(SAstCreateContext* pCxt) { pOptions->numOfVgroups = TSDB_DEFAULT_VN_PER_DB; pOptions->singleStable = TSDB_DEFAULT_DB_SINGLE_STABLE_OPTION; pOptions->streamMode = TSDB_DEFAULT_DB_STREAM_MODE_OPTION; - return pOptions; + return (SNode*)pOptions; } -SDatabaseOptions* setDatabaseOption(SAstCreateContext* pCxt, SDatabaseOptions* pOptions, EDatabaseOptionType type, const SToken* pVal) { - return setDbOptionFuncs[type](pCxt, pOptions, pVal); +SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, const SToken* pVal) { + return (SNode*)setDbOptionFuncs[type](pCxt, (SDatabaseOptions*)pOptions, pVal); } -SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pDbName, SDatabaseOptions* pOptions) { +SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pDbName, SNode* pOptions) { if (!checkDbName(pCxt, pDbName)) { return NULL; } @@ -776,8 +784,7 @@ SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, cons CHECK_OUT_OF_MEM(pStmt); strncpy(pStmt->dbName, pDbName->z, pDbName->n); pStmt->ignoreExists = ignoreExists; - pStmt->options = *pOptions; - tfree(pOptions); + pStmt->pOptions = (SDatabaseOptions*)pOptions; return (SNode*)pStmt; } @@ -792,20 +799,20 @@ SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, con return (SNode*)pStmt; } -STableOptions* createDefaultTableOptions(SAstCreateContext* pCxt) { - STableOptions* pOptions = calloc(1, sizeof(STableOptions)); +SNode* createDefaultTableOptions(SAstCreateContext* pCxt) { + STableOptions* pOptions = nodesMakeNode(QUERY_NODE_TABLE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->keep = TSDB_DEFAULT_KEEP; pOptions->ttl = TSDB_DEFAULT_DB_TTL_OPTION; - return pOptions; + return (SNode*)pOptions; } -STableOptions* setTableOption(SAstCreateContext* pCxt, STableOptions* pOptions, ETableOptionType type, const SToken* pVal) { - return setTableOptionFuncs[type](pCxt, pOptions, pVal); +SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, const SToken* pVal) { + return (SNode*)setTableOptionFuncs[type](pCxt, (STableOptions*)pOptions, pVal); } -STableOptions* setTableSmaOption(SAstCreateContext* pCxt, STableOptions* pOptions, SNodeList* pSma) { - pOptions->pSma = pSma; +SNode* setTableSmaOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pSma) { + ((STableOptions*)pOptions)->pSma = pSma; return pOptions; } @@ -831,7 +838,7 @@ SDataType createVarLenDataType(uint8_t type, const SToken* pLen) { } SNode* createCreateTableStmt(SAstCreateContext* pCxt, - bool ignoreExists, SNode* pRealTable, SNodeList* pCols, SNodeList* pTags, STableOptions* pOptions) { + bool ignoreExists, SNode* pRealTable, SNodeList* pCols, SNodeList* pTags, SNode* pOptions) { SCreateTableStmt* pStmt = (SCreateTableStmt*)nodesMakeNode(QUERY_NODE_CREATE_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName); @@ -839,9 +846,7 @@ SNode* createCreateTableStmt(SAstCreateContext* pCxt, pStmt->ignoreExists = ignoreExists; pStmt->pCols = pCols; pStmt->pTags = pTags; - pStmt->options = *pOptions; - nodesDestroyList(pOptions->pSma); - tfree(pOptions); + pStmt->pOptions = (STableOptions*)pOptions; nodesDestroyNode(pRealTable); return (SNode*)pStmt; } @@ -992,3 +997,27 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode) { } return (SNode*)pStmt; } + +SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, const SToken* pIndexName, const SToken* pTableName, SNodeList* pCols, SNode* pOptions) { + if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName)) { + return NULL; + } + SCreateIndexStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_INDEX_STMT); + CHECK_OUT_OF_MEM(pStmt); + pStmt->indexType = type; + strncpy(pStmt->indexName, pIndexName->z, pIndexName->n); + strncpy(pStmt->tableName, pTableName->z, pTableName->n); + pStmt->pCols = pCols; + pStmt->pOptions = (SIndexOptions*)pOptions; + return (SNode*)pStmt; +} + +SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding) { + SIndexOptions* pOptions = nodesMakeNode(QUERY_NODE_INDEX_OPTIONS); + CHECK_OUT_OF_MEM(pOptions); + pOptions->pFuncs = pFuncs; + pOptions->pInterval = pInterval; + pOptions->pOffset = pOffset; + pOptions->pSliding = pSliding; + return (SNode*)pOptions; +} diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index eefa99dae0..57ff6d53a4 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -59,11 +59,13 @@ static SKeyword keywordTable[] = { {"FLOAT", TK_FLOAT}, {"FROM", TK_FROM}, {"FSYNC", TK_FSYNC}, + {"FUNCTION", TK_FUNCTION}, {"GROUP", TK_GROUP}, {"HAVING", TK_HAVING}, {"IF", TK_IF}, {"IMPORT", TK_IMPORT}, {"IN", TK_IN}, + {"INDEX", TK_INDEX}, {"INNER", TK_INNER}, {"INT", TK_INT}, {"INSERT", TK_INSERT}, @@ -230,7 +232,6 @@ static SKeyword keywordTable[] = { // {"TOPICS", TK_TOPICS}, // {"COMPACT", TK_COMPACT}, // {"MODIFY", TK_MODIFY}, - // {"FUNCTION", TK_FUNCTION}, // {"FUNCTIONS", TK_FUNCTIONS}, // {"OUTPUTTYPE", TK_OUTPUTTYPE}, // {"AGGREGATE", TK_AGGREGATE}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index c1ba59dd84..3fff4fa4ca 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -254,8 +254,7 @@ static int32_t trimStringWithVarFormat(const char* src, int32_t len, bool format static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) { if (pVal->isDuration) { - char unit = 0; - if (parseAbsoluteDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &unit, pVal->node.resType.precision) != TSDB_CODE_SUCCESS) { + if (parseAbsoluteDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &pVal->unit, pVal->node.resType.precision) != TSDB_CODE_SUCCESS) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal); } } else { @@ -768,26 +767,26 @@ static void buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pStmt SName name = {0}; tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); tNameGetFullDbName(&name, pReq->db); - pReq->numOfVgroups = pStmt->options.numOfVgroups; - pReq->cacheBlockSize = pStmt->options.cacheBlockSize; - pReq->totalBlocks = pStmt->options.numOfBlocks; - pReq->daysPerFile = pStmt->options.daysPerFile; - pReq->daysToKeep0 = pStmt->options.keep; + pReq->numOfVgroups = pStmt->pOptions->numOfVgroups; + pReq->cacheBlockSize = pStmt->pOptions->cacheBlockSize; + pReq->totalBlocks = pStmt->pOptions->numOfBlocks; + pReq->daysPerFile = pStmt->pOptions->daysPerFile; + pReq->daysToKeep0 = pStmt->pOptions->keep; pReq->daysToKeep1 = -1; pReq->daysToKeep2 = -1; - pReq->minRows = pStmt->options.minRowsPerBlock; - pReq->maxRows = pStmt->options.maxRowsPerBlock; + pReq->minRows = pStmt->pOptions->minRowsPerBlock; + pReq->maxRows = pStmt->pOptions->maxRowsPerBlock; pReq->commitTime = -1; - pReq->fsyncPeriod = pStmt->options.fsyncPeriod; - pReq->walLevel = pStmt->options.walLevel; - pReq->precision = pStmt->options.precision; - pReq->compression = pStmt->options.compressionLevel; - pReq->replications = pStmt->options.replica; - pReq->quorum = pStmt->options.quorum; + pReq->fsyncPeriod = pStmt->pOptions->fsyncPeriod; + pReq->walLevel = pStmt->pOptions->walLevel; + pReq->precision = pStmt->pOptions->precision; + pReq->compression = pStmt->pOptions->compressionLevel; + pReq->replications = pStmt->pOptions->replica; + pReq->quorum = pStmt->pOptions->quorum; pReq->update = -1; - pReq->cacheLastRow = pStmt->options.cachelast; + pReq->cacheLastRow = pStmt->pOptions->cachelast; pReq->ignoreExist = pStmt->ignoreExists; - pReq->streamMode = pStmt->options.streamMode; + pReq->streamMode = pStmt->pOptions->streamMode; return; } @@ -1141,6 +1140,63 @@ static int32_t translateShowTables(STranslateContext* pCxt) { return TSDB_CODE_SUCCESS; } +static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) { + SVCreateTSmaReq createSmaReq = {0}; + + if (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pInterval) || + (NULL != pStmt->pOptions->pOffset && DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pOffset)) || + (NULL != pStmt->pOptions->pSliding && DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pSliding))) { + return pCxt->errCode; + } + + createSmaReq.tSma.intervalUnit = ((SValueNode*)pStmt->pOptions->pInterval)->unit; + createSmaReq.tSma.slidingUnit = (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->unit : 0); + strcpy(createSmaReq.tSma.indexName, pStmt->indexName); + + SName name; + name.type = TSDB_TABLE_NAME_T; + name.acctId = pCxt->pParseCxt->acctId; + strcpy(name.dbname, pCxt->pParseCxt->db); + strcpy(name.tname, pStmt->tableName); + STableMeta* pMeta = NULL; + int32_t code = catalogGetTableMeta(pCxt->pParseCxt->pCatalog, pCxt->pParseCxt->pTransporter, &pCxt->pParseCxt->mgmtEpSet, &name, &pMeta); + if (TSDB_CODE_SUCCESS != code) { + return code; + } + + createSmaReq.tSma.tableUid = pMeta->uid; + createSmaReq.tSma.interval = ((SValueNode*)pStmt->pOptions->pInterval)->datum.i; + createSmaReq.tSma.sliding = (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->datum.i : 0); + code = nodesListToString(pStmt->pCols, false, &createSmaReq.tSma.expr, &createSmaReq.tSma.exprLen); + if (TSDB_CODE_SUCCESS != code) { + return code; + } + + pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); + if (NULL== pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_VND_CREATE_SMA; + pCxt->pCmdMsg->msgLen = tSerializeSVCreateTSmaReq(NULL, &createSmaReq); + pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); + if (NULL== pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + tSerializeSVCreateTSmaReq(pCxt->pCmdMsg->pMsg, &createSmaReq); + + return TSDB_CODE_SUCCESS; +} + +static int32_t translateCreateIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) { + if (INDEX_TYPE_SMA == pStmt->indexType) { + return translateCreateSmaIndex(pCxt, pStmt); + } else { + // todo fulltext index + return TSDB_CODE_FAILED; + } +} + static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pNode)) { @@ -1191,6 +1247,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_SHOW_TABLES_STMT: code = translateShowTables(pCxt); break; + case QUERY_NODE_CREATE_INDEX_STMT: + code = translateCreateIndex(pCxt, (SCreateIndexStmt*)pNode); + break; default: break; } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index c54bbd41cc..ae20ecdd7e 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -99,24 +99,22 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned char -#define YYNOCODE 209 +#define YYNOCODE 216 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SNodeList* yy46; - SDataType yy70; - SToken yy129; - ENullOrder yy147; - bool yy185; - EOrder yy202; - SNode* yy256; - EJoinType yy266; - EOperatorType yy326; - STableOptions* yy340; - EFillMode yy360; - SDatabaseOptions* yy391; + EOrder yy2; + EJoinType yy36; + SToken yy209; + ENullOrder yy217; + EOperatorType yy236; + SNodeList* yy280; + bool yy281; + SDataType yy304; + EFillMode yy342; + SNode* yy344; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -131,17 +129,17 @@ typedef union { #define ParseCTX_PARAM #define ParseCTX_FETCH #define ParseCTX_STORE -#define YYNSTATE 279 -#define YYNRULE 237 -#define YYNTOKEN 135 -#define YY_MAX_SHIFT 278 -#define YY_MIN_SHIFTREDUCE 439 -#define YY_MAX_SHIFTREDUCE 675 -#define YY_ERROR_ACTION 676 -#define YY_ACCEPT_ACTION 677 -#define YY_NO_ACTION 678 -#define YY_MIN_REDUCE 679 -#define YY_MAX_REDUCE 915 +#define YYNSTATE 308 +#define YYNRULE 246 +#define YYNTOKEN 138 +#define YY_MAX_SHIFT 307 +#define YY_MIN_SHIFTREDUCE 475 +#define YY_MAX_SHIFTREDUCE 720 +#define YY_ERROR_ACTION 721 +#define YY_ACCEPT_ACTION 722 +#define YY_NO_ACTION 723 +#define YY_MIN_REDUCE 724 +#define YY_MAX_REDUCE 969 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -208,285 +206,318 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (905) +#define YY_ACTTAB_COUNT (1037) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 137, 149, 23, 95, 772, 721, 770, 247, 150, 784, - /* 10 */ 782, 148, 30, 28, 26, 25, 24, 784, 782, 194, - /* 20 */ 177, 808, 201, 735, 66, 30, 28, 26, 25, 24, - /* 30 */ 692, 166, 194, 222, 808, 60, 208, 132, 793, 782, - /* 40 */ 195, 209, 222, 54, 794, 730, 797, 833, 733, 58, - /* 50 */ 132, 139, 829, 906, 19, 785, 782, 733, 558, 73, - /* 60 */ 840, 841, 867, 845, 30, 28, 26, 25, 24, 271, - /* 70 */ 270, 269, 268, 267, 266, 265, 264, 263, 262, 261, - /* 80 */ 260, 259, 258, 257, 256, 255, 26, 25, 24, 550, - /* 90 */ 22, 141, 171, 576, 577, 578, 579, 580, 581, 582, - /* 100 */ 584, 585, 586, 22, 141, 617, 576, 577, 578, 579, - /* 110 */ 580, 581, 582, 584, 585, 586, 275, 274, 499, 245, - /* 120 */ 244, 243, 503, 242, 505, 506, 241, 508, 238, 41, - /* 130 */ 514, 235, 516, 517, 232, 229, 194, 194, 808, 808, - /* 140 */ 729, 184, 793, 782, 195, 77, 45, 53, 794, 170, - /* 150 */ 797, 833, 194, 719, 808, 131, 829, 726, 793, 782, - /* 160 */ 195, 104, 93, 125, 794, 145, 797, 894, 153, 78, - /* 170 */ 221, 772, 180, 770, 808, 103, 736, 66, 793, 782, - /* 180 */ 195, 76, 209, 54, 794, 892, 797, 833, 194, 254, - /* 190 */ 808, 139, 829, 71, 793, 782, 195, 221, 42, 54, - /* 200 */ 794, 101, 797, 833, 772, 94, 771, 139, 829, 906, - /* 210 */ 616, 156, 860, 894, 180, 254, 808, 551, 890, 50, - /* 220 */ 793, 782, 195, 10, 47, 54, 794, 893, 797, 833, - /* 230 */ 194, 892, 808, 139, 829, 71, 793, 782, 195, 29, - /* 240 */ 27, 54, 794, 677, 797, 833, 41, 187, 539, 139, - /* 250 */ 829, 906, 114, 61, 861, 763, 537, 728, 146, 221, - /* 260 */ 851, 29, 27, 618, 11, 194, 182, 808, 196, 548, - /* 270 */ 539, 793, 782, 195, 77, 639, 121, 794, 537, 797, - /* 280 */ 146, 194, 56, 808, 1, 10, 11, 793, 782, 195, - /* 290 */ 79, 51, 55, 794, 894, 797, 833, 9, 8, 62, - /* 300 */ 832, 829, 725, 223, 222, 449, 1, 219, 76, 173, - /* 310 */ 248, 152, 892, 212, 538, 540, 543, 720, 191, 733, - /* 320 */ 194, 573, 808, 735, 66, 223, 793, 782, 195, 6, - /* 330 */ 613, 125, 794, 157, 797, 77, 538, 540, 543, 194, - /* 340 */ 222, 808, 96, 220, 184, 793, 782, 195, 29, 27, - /* 350 */ 119, 794, 163, 797, 594, 733, 847, 539, 172, 167, - /* 360 */ 165, 88, 29, 27, 251, 537, 188, 146, 250, 186, - /* 370 */ 894, 539, 222, 11, 844, 109, 847, 177, 852, 537, - /* 380 */ 613, 146, 192, 252, 76, 863, 154, 733, 892, 194, - /* 390 */ 177, 808, 60, 1, 843, 793, 782, 195, 735, 66, - /* 400 */ 55, 794, 249, 797, 833, 60, 58, 7, 181, 829, - /* 410 */ 184, 449, 223, 9, 8, 179, 72, 840, 841, 58, - /* 420 */ 845, 450, 451, 538, 540, 543, 223, 85, 189, 91, - /* 430 */ 840, 176, 625, 175, 82, 847, 894, 538, 540, 543, - /* 440 */ 178, 98, 29, 27, 183, 222, 29, 27, 155, 548, - /* 450 */ 76, 539, 809, 842, 892, 539, 674, 675, 77, 537, - /* 460 */ 733, 146, 194, 537, 808, 146, 20, 2, 793, 782, - /* 470 */ 195, 29, 27, 55, 794, 583, 797, 833, 587, 211, - /* 480 */ 539, 217, 830, 551, 215, 642, 539, 7, 537, 588, - /* 490 */ 146, 1, 864, 194, 537, 808, 31, 164, 161, 793, - /* 500 */ 782, 195, 555, 874, 68, 794, 223, 797, 80, 31, - /* 510 */ 223, 162, 640, 641, 643, 644, 7, 538, 540, 543, - /* 520 */ 789, 538, 540, 543, 106, 543, 194, 787, 808, 492, - /* 530 */ 159, 63, 793, 782, 195, 223, 64, 125, 794, 140, - /* 540 */ 797, 223, 873, 185, 907, 718, 538, 540, 543, 194, - /* 550 */ 160, 808, 538, 540, 543, 793, 782, 195, 487, 84, - /* 560 */ 68, 794, 138, 797, 194, 56, 808, 5, 854, 174, - /* 570 */ 793, 782, 195, 520, 70, 120, 794, 524, 797, 194, - /* 580 */ 227, 808, 4, 87, 63, 793, 782, 195, 158, 613, - /* 590 */ 122, 794, 251, 797, 89, 194, 250, 808, 529, 547, - /* 600 */ 908, 793, 782, 195, 59, 64, 117, 794, 65, 797, - /* 610 */ 194, 252, 808, 550, 848, 63, 793, 782, 195, 32, - /* 620 */ 16, 123, 794, 142, 797, 194, 815, 808, 90, 909, - /* 630 */ 249, 793, 782, 195, 193, 891, 118, 794, 194, 797, - /* 640 */ 808, 97, 546, 190, 793, 782, 195, 197, 210, 124, - /* 650 */ 794, 194, 797, 808, 40, 102, 552, 793, 782, 195, - /* 660 */ 734, 213, 805, 794, 147, 797, 194, 46, 808, 113, - /* 670 */ 44, 225, 793, 782, 195, 115, 110, 804, 794, 194, - /* 680 */ 797, 808, 278, 3, 128, 793, 782, 195, 129, 116, - /* 690 */ 803, 794, 31, 797, 194, 14, 808, 81, 636, 83, - /* 700 */ 793, 782, 195, 35, 638, 135, 794, 194, 797, 808, - /* 710 */ 69, 86, 37, 793, 782, 195, 632, 631, 134, 794, - /* 720 */ 194, 797, 808, 168, 38, 169, 793, 782, 195, 787, - /* 730 */ 610, 136, 794, 18, 797, 194, 15, 808, 609, 92, - /* 740 */ 207, 793, 782, 195, 206, 546, 133, 794, 205, 797, - /* 750 */ 33, 194, 34, 808, 75, 8, 574, 793, 782, 195, - /* 760 */ 556, 665, 126, 794, 17, 797, 177, 202, 12, 39, - /* 770 */ 660, 659, 143, 664, 204, 203, 30, 28, 26, 25, - /* 780 */ 24, 60, 99, 663, 130, 144, 13, 776, 218, 695, - /* 790 */ 127, 67, 775, 774, 112, 58, 200, 773, 199, 724, - /* 800 */ 198, 100, 57, 21, 723, 74, 840, 841, 111, 845, - /* 810 */ 694, 688, 683, 30, 28, 26, 25, 24, 30, 28, - /* 820 */ 26, 25, 24, 722, 458, 693, 30, 28, 26, 25, - /* 830 */ 24, 52, 687, 686, 107, 682, 681, 214, 680, 216, - /* 840 */ 105, 43, 47, 786, 226, 108, 224, 541, 36, 151, - /* 850 */ 513, 230, 521, 228, 512, 511, 518, 231, 233, 236, - /* 860 */ 515, 509, 234, 239, 558, 237, 510, 507, 498, 528, - /* 870 */ 240, 527, 526, 246, 77, 456, 48, 477, 253, 476, - /* 880 */ 470, 49, 475, 474, 473, 472, 471, 469, 685, 468, - /* 890 */ 467, 466, 465, 464, 671, 672, 463, 462, 461, 272, - /* 900 */ 273, 684, 679, 276, 277, + /* 0 */ 152, 235, 276, 862, 835, 251, 251, 167, 185, 775, + /* 10 */ 838, 835, 31, 29, 27, 26, 25, 837, 835, 208, + /* 20 */ 778, 778, 165, 178, 837, 31, 29, 27, 26, 25, + /* 30 */ 737, 39, 9, 8, 780, 70, 151, 145, 61, 817, + /* 40 */ 250, 815, 773, 235, 251, 862, 235, 248, 862, 164, + /* 50 */ 145, 835, 823, 238, 237, 24, 109, 847, 603, 778, + /* 60 */ 58, 848, 851, 887, 212, 662, 10, 886, 883, 300, + /* 70 */ 299, 298, 297, 296, 295, 294, 293, 292, 291, 290, + /* 80 */ 289, 288, 287, 286, 285, 284, 304, 303, 250, 639, + /* 90 */ 31, 29, 27, 26, 25, 23, 159, 592, 621, 622, + /* 100 */ 623, 624, 625, 626, 627, 629, 630, 631, 23, 159, + /* 110 */ 186, 621, 622, 623, 624, 625, 626, 627, 629, 630, + /* 120 */ 631, 31, 29, 27, 26, 25, 535, 274, 273, 272, + /* 130 */ 539, 271, 541, 542, 270, 544, 267, 20, 550, 264, + /* 140 */ 552, 553, 261, 258, 235, 87, 862, 31, 29, 27, + /* 150 */ 26, 25, 835, 75, 766, 237, 213, 223, 847, 86, + /* 160 */ 82, 56, 848, 851, 887, 54, 948, 603, 144, 883, + /* 170 */ 250, 130, 219, 65, 661, 195, 770, 134, 71, 947, + /* 180 */ 948, 593, 40, 946, 222, 84, 862, 64, 83, 764, + /* 190 */ 186, 583, 835, 81, 39, 237, 10, 946, 847, 581, + /* 200 */ 223, 57, 848, 851, 887, 774, 62, 207, 154, 883, + /* 210 */ 76, 716, 717, 27, 26, 25, 102, 894, 218, 485, + /* 220 */ 217, 166, 105, 948, 817, 283, 815, 189, 200, 914, + /* 230 */ 222, 125, 862, 283, 214, 209, 81, 594, 835, 60, + /* 240 */ 946, 237, 485, 277, 847, 124, 252, 57, 848, 851, + /* 250 */ 887, 82, 486, 487, 154, 883, 76, 251, 226, 235, + /* 260 */ 249, 862, 582, 584, 587, 82, 251, 835, 55, 122, + /* 270 */ 237, 120, 778, 847, 106, 915, 57, 848, 851, 887, + /* 280 */ 169, 778, 205, 154, 883, 960, 99, 235, 251, 862, + /* 290 */ 722, 172, 780, 70, 921, 835, 171, 247, 237, 127, + /* 300 */ 199, 847, 808, 778, 57, 848, 851, 887, 780, 70, + /* 310 */ 595, 154, 883, 960, 48, 104, 235, 188, 862, 21, + /* 320 */ 30, 28, 944, 173, 835, 771, 220, 237, 628, 583, + /* 330 */ 847, 632, 230, 57, 848, 851, 887, 581, 765, 161, + /* 340 */ 154, 883, 960, 6, 901, 12, 948, 30, 28, 663, + /* 350 */ 170, 905, 901, 817, 863, 815, 583, 917, 901, 81, + /* 360 */ 235, 898, 862, 946, 581, 1, 161, 658, 835, 897, + /* 370 */ 234, 237, 12, 223, 847, 896, 670, 133, 848, 851, + /* 380 */ 227, 824, 238, 225, 252, 280, 30, 28, 91, 279, + /* 390 */ 781, 70, 1, 592, 108, 583, 948, 30, 28, 231, + /* 400 */ 582, 584, 587, 581, 281, 161, 583, 174, 817, 81, + /* 410 */ 816, 252, 194, 946, 581, 192, 161, 906, 658, 196, + /* 420 */ 82, 2, 12, 278, 590, 684, 68, 582, 584, 587, + /* 430 */ 618, 7, 59, 96, 633, 235, 763, 862, 9, 8, + /* 440 */ 94, 32, 1, 835, 600, 228, 237, 719, 720, 847, + /* 450 */ 252, 32, 58, 848, 851, 887, 30, 28, 236, 233, + /* 460 */ 883, 252, 842, 30, 28, 583, 582, 584, 587, 840, + /* 470 */ 38, 53, 583, 581, 576, 161, 50, 582, 584, 587, + /* 480 */ 581, 32, 161, 280, 187, 85, 82, 279, 30, 28, + /* 490 */ 190, 184, 235, 596, 862, 183, 590, 583, 150, 182, + /* 500 */ 835, 7, 281, 237, 197, 581, 847, 161, 7, 72, + /* 510 */ 848, 851, 114, 591, 206, 219, 243, 119, 179, 112, + /* 520 */ 252, 278, 528, 66, 67, 181, 180, 252, 523, 68, + /* 530 */ 64, 597, 556, 1, 198, 59, 582, 584, 587, 256, + /* 540 */ 595, 560, 918, 582, 584, 587, 224, 961, 67, 62, + /* 550 */ 565, 928, 252, 241, 92, 69, 175, 68, 221, 77, + /* 560 */ 894, 895, 67, 899, 235, 587, 862, 203, 582, 584, + /* 570 */ 587, 95, 835, 927, 153, 237, 5, 98, 847, 908, + /* 580 */ 74, 58, 848, 851, 887, 100, 235, 687, 862, 884, + /* 590 */ 202, 4, 216, 63, 835, 658, 594, 237, 160, 902, + /* 600 */ 847, 945, 33, 138, 848, 851, 101, 155, 235, 232, + /* 610 */ 862, 204, 685, 686, 688, 689, 835, 963, 229, 237, + /* 620 */ 201, 107, 847, 17, 869, 138, 848, 851, 822, 239, + /* 630 */ 244, 235, 126, 862, 240, 49, 821, 47, 123, 835, + /* 640 */ 307, 254, 237, 245, 116, 847, 163, 128, 137, 848, + /* 650 */ 851, 235, 142, 862, 246, 129, 779, 143, 829, 835, + /* 660 */ 176, 177, 237, 740, 235, 847, 862, 828, 72, 848, + /* 670 */ 851, 827, 835, 494, 738, 237, 158, 191, 847, 215, + /* 680 */ 826, 138, 848, 851, 769, 768, 235, 739, 862, 31, + /* 690 */ 29, 27, 26, 25, 835, 88, 193, 237, 162, 733, + /* 700 */ 847, 728, 767, 138, 848, 851, 962, 732, 731, 727, + /* 710 */ 726, 235, 219, 862, 725, 819, 41, 89, 90, 835, + /* 720 */ 3, 14, 237, 93, 683, 847, 32, 64, 136, 848, + /* 730 */ 851, 235, 210, 862, 36, 73, 97, 211, 42, 835, + /* 740 */ 677, 676, 237, 43, 15, 847, 62, 34, 139, 848, + /* 750 */ 851, 655, 840, 235, 19, 862, 78, 894, 895, 35, + /* 760 */ 899, 835, 654, 16, 237, 11, 705, 847, 44, 103, + /* 770 */ 131, 848, 851, 704, 710, 235, 80, 862, 156, 709, + /* 780 */ 708, 157, 8, 835, 601, 110, 237, 619, 13, 847, + /* 790 */ 18, 113, 140, 848, 851, 818, 111, 681, 235, 115, + /* 800 */ 862, 242, 45, 46, 117, 118, 835, 839, 585, 237, + /* 810 */ 50, 121, 847, 37, 255, 132, 848, 851, 235, 557, + /* 820 */ 862, 253, 168, 257, 534, 554, 835, 259, 260, 237, + /* 830 */ 551, 235, 847, 862, 262, 141, 848, 851, 263, 835, + /* 840 */ 545, 265, 237, 266, 268, 847, 543, 269, 859, 848, + /* 850 */ 851, 549, 548, 235, 547, 862, 546, 275, 51, 52, + /* 860 */ 564, 835, 563, 562, 237, 506, 492, 847, 513, 512, + /* 870 */ 858, 848, 851, 282, 511, 510, 509, 508, 235, 507, + /* 880 */ 862, 505, 504, 503, 502, 501, 835, 500, 499, 237, + /* 890 */ 498, 497, 847, 730, 301, 857, 848, 851, 235, 302, + /* 900 */ 862, 729, 724, 305, 306, 723, 835, 723, 723, 237, + /* 910 */ 723, 723, 847, 723, 723, 148, 848, 851, 723, 723, + /* 920 */ 235, 723, 862, 723, 723, 723, 723, 723, 835, 723, + /* 930 */ 723, 237, 723, 723, 847, 723, 723, 147, 848, 851, + /* 940 */ 723, 723, 235, 723, 862, 723, 723, 723, 723, 723, + /* 950 */ 835, 723, 723, 237, 723, 723, 847, 723, 723, 149, + /* 960 */ 848, 851, 723, 723, 723, 235, 723, 862, 723, 723, + /* 970 */ 723, 723, 723, 835, 723, 219, 237, 723, 723, 847, + /* 980 */ 723, 723, 146, 848, 851, 235, 723, 862, 723, 723, + /* 990 */ 64, 723, 723, 835, 723, 723, 237, 723, 723, 847, + /* 1000 */ 723, 723, 135, 848, 851, 723, 723, 723, 723, 62, + /* 1010 */ 723, 723, 723, 723, 723, 723, 723, 723, 723, 79, + /* 1020 */ 894, 895, 22, 899, 723, 723, 723, 723, 723, 723, + /* 1030 */ 723, 723, 31, 29, 27, 26, 25, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 152, 154, 171, 172, 157, 0, 159, 158, 152, 161, - /* 10 */ 162, 144, 12, 13, 14, 15, 16, 161, 162, 155, - /* 20 */ 140, 157, 140, 156, 157, 12, 13, 14, 15, 16, - /* 30 */ 0, 167, 155, 140, 157, 155, 143, 37, 161, 162, - /* 40 */ 163, 36, 140, 166, 167, 143, 169, 170, 155, 169, - /* 50 */ 37, 174, 175, 176, 2, 161, 162, 155, 58, 179, - /* 60 */ 180, 181, 185, 183, 12, 13, 14, 15, 16, 39, + /* 0 */ 155, 158, 161, 160, 166, 143, 143, 155, 146, 146, + /* 10 */ 172, 166, 12, 13, 14, 15, 16, 172, 166, 176, + /* 20 */ 158, 158, 147, 143, 172, 12, 13, 14, 15, 16, + /* 30 */ 0, 145, 1, 2, 159, 160, 157, 37, 152, 160, + /* 40 */ 31, 162, 156, 158, 143, 160, 158, 146, 160, 165, + /* 50 */ 37, 166, 168, 169, 169, 179, 180, 172, 58, 158, + /* 60 */ 175, 176, 177, 178, 176, 4, 57, 182, 183, 39, /* 70 */ 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - /* 80 */ 50, 51, 52, 53, 54, 55, 14, 15, 16, 31, - /* 90 */ 90, 91, 31, 93, 94, 95, 96, 97, 98, 99, - /* 100 */ 100, 101, 102, 90, 91, 4, 93, 94, 95, 96, - /* 110 */ 97, 98, 99, 100, 101, 102, 137, 138, 67, 68, - /* 120 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 142, - /* 130 */ 79, 80, 81, 82, 83, 84, 155, 155, 157, 157, - /* 140 */ 153, 160, 161, 162, 163, 108, 139, 166, 167, 167, - /* 150 */ 169, 170, 155, 0, 157, 174, 175, 150, 161, 162, - /* 160 */ 163, 19, 104, 166, 167, 168, 169, 186, 154, 27, - /* 170 */ 31, 157, 155, 159, 157, 33, 156, 157, 161, 162, - /* 180 */ 163, 200, 36, 166, 167, 204, 169, 170, 155, 36, - /* 190 */ 157, 174, 175, 176, 161, 162, 163, 31, 56, 166, - /* 200 */ 167, 59, 169, 170, 157, 188, 159, 174, 175, 176, - /* 210 */ 109, 194, 195, 186, 155, 36, 157, 31, 185, 57, - /* 220 */ 161, 162, 163, 57, 62, 166, 167, 200, 169, 170, - /* 230 */ 155, 204, 157, 174, 175, 176, 161, 162, 163, 12, - /* 240 */ 13, 166, 167, 135, 169, 170, 142, 3, 21, 174, - /* 250 */ 175, 176, 145, 149, 195, 148, 29, 153, 31, 31, - /* 260 */ 185, 12, 13, 14, 37, 155, 37, 157, 160, 31, - /* 270 */ 21, 161, 162, 163, 108, 58, 166, 167, 29, 169, - /* 280 */ 31, 155, 65, 157, 57, 57, 37, 161, 162, 163, - /* 290 */ 104, 139, 166, 167, 186, 169, 170, 1, 2, 147, - /* 300 */ 174, 175, 150, 76, 140, 21, 57, 143, 200, 199, - /* 310 */ 63, 144, 204, 29, 87, 88, 89, 0, 65, 155, - /* 320 */ 155, 92, 157, 156, 157, 76, 161, 162, 163, 106, - /* 330 */ 107, 166, 167, 168, 169, 108, 87, 88, 89, 155, - /* 340 */ 140, 157, 207, 143, 160, 161, 162, 163, 12, 13, - /* 350 */ 166, 167, 198, 169, 58, 155, 164, 21, 113, 114, - /* 360 */ 115, 191, 12, 13, 47, 29, 65, 31, 51, 125, - /* 370 */ 186, 21, 140, 37, 182, 143, 164, 140, 105, 29, - /* 380 */ 107, 31, 129, 66, 200, 165, 144, 155, 204, 155, - /* 390 */ 140, 157, 155, 57, 182, 161, 162, 163, 156, 157, - /* 400 */ 166, 167, 85, 169, 170, 155, 169, 57, 174, 175, - /* 410 */ 160, 21, 76, 1, 2, 178, 179, 180, 181, 169, - /* 420 */ 183, 31, 32, 87, 88, 89, 76, 58, 127, 179, - /* 430 */ 180, 181, 14, 183, 65, 164, 186, 87, 88, 89, - /* 440 */ 184, 201, 12, 13, 14, 140, 12, 13, 143, 31, - /* 450 */ 200, 21, 157, 182, 204, 21, 133, 134, 108, 29, - /* 460 */ 155, 31, 155, 29, 157, 31, 90, 187, 161, 162, - /* 470 */ 163, 12, 13, 166, 167, 99, 169, 170, 102, 137, - /* 480 */ 21, 20, 175, 31, 23, 92, 21, 57, 29, 58, - /* 490 */ 31, 57, 165, 155, 29, 157, 65, 117, 116, 161, - /* 500 */ 162, 163, 58, 197, 166, 167, 76, 169, 196, 65, - /* 510 */ 76, 118, 119, 120, 121, 122, 57, 87, 88, 89, - /* 520 */ 57, 87, 88, 89, 58, 89, 155, 64, 157, 58, - /* 530 */ 162, 65, 161, 162, 163, 76, 65, 166, 167, 168, - /* 540 */ 169, 76, 197, 205, 206, 0, 87, 88, 89, 155, - /* 550 */ 162, 157, 87, 88, 89, 161, 162, 163, 58, 196, - /* 560 */ 166, 167, 162, 169, 155, 65, 157, 124, 193, 123, - /* 570 */ 161, 162, 163, 58, 190, 166, 167, 58, 169, 155, - /* 580 */ 65, 157, 110, 192, 65, 161, 162, 163, 111, 107, - /* 590 */ 166, 167, 47, 169, 189, 155, 51, 157, 58, 31, - /* 600 */ 206, 161, 162, 163, 155, 65, 166, 167, 58, 169, - /* 610 */ 155, 66, 157, 31, 164, 65, 161, 162, 163, 103, - /* 620 */ 57, 166, 167, 132, 169, 155, 173, 157, 177, 208, - /* 630 */ 85, 161, 162, 163, 128, 203, 166, 167, 155, 169, - /* 640 */ 157, 202, 31, 126, 161, 162, 163, 140, 140, 166, - /* 650 */ 167, 155, 169, 157, 142, 142, 31, 161, 162, 163, - /* 660 */ 155, 136, 166, 167, 136, 169, 155, 57, 157, 148, - /* 670 */ 139, 151, 161, 162, 163, 140, 139, 166, 167, 155, - /* 680 */ 169, 157, 136, 65, 146, 161, 162, 163, 146, 141, - /* 690 */ 166, 167, 65, 169, 155, 112, 157, 58, 58, 57, - /* 700 */ 161, 162, 163, 65, 58, 166, 167, 155, 169, 157, - /* 710 */ 57, 57, 57, 161, 162, 163, 58, 58, 166, 167, - /* 720 */ 155, 169, 157, 29, 57, 65, 161, 162, 163, 64, - /* 730 */ 58, 166, 167, 65, 169, 155, 112, 157, 58, 64, - /* 740 */ 26, 161, 162, 163, 30, 31, 166, 167, 34, 169, - /* 750 */ 105, 155, 65, 157, 64, 2, 92, 161, 162, 163, - /* 760 */ 58, 58, 166, 167, 65, 169, 140, 53, 112, 4, - /* 770 */ 29, 29, 29, 29, 60, 61, 12, 13, 14, 15, - /* 780 */ 16, 155, 64, 29, 18, 29, 57, 0, 22, 0, - /* 790 */ 24, 25, 0, 0, 19, 169, 64, 0, 53, 0, - /* 800 */ 86, 35, 27, 2, 0, 179, 180, 181, 33, 183, - /* 810 */ 0, 0, 0, 12, 13, 14, 15, 16, 12, 13, - /* 820 */ 14, 15, 16, 0, 38, 0, 12, 13, 14, 15, - /* 830 */ 16, 56, 0, 0, 59, 0, 0, 21, 0, 21, - /* 840 */ 19, 57, 62, 64, 29, 64, 63, 21, 57, 29, - /* 850 */ 78, 29, 58, 57, 78, 78, 58, 57, 29, 29, - /* 860 */ 58, 58, 57, 29, 58, 57, 78, 58, 21, 29, - /* 870 */ 57, 29, 21, 66, 108, 38, 57, 29, 37, 29, - /* 880 */ 21, 57, 29, 29, 29, 29, 29, 29, 0, 29, - /* 890 */ 29, 29, 29, 29, 130, 131, 29, 29, 29, 29, - /* 900 */ 28, 0, 0, 21, 20, 209, 209, 209, 209, 209, - /* 910 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 920 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 930 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 940 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 950 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 960 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 970 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 980 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 990 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 1000 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 1010 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 1020 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 1030 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, + /* 80 */ 50, 51, 52, 53, 54, 55, 140, 141, 31, 58, + /* 90 */ 12, 13, 14, 15, 16, 95, 96, 31, 98, 99, + /* 100 */ 100, 101, 102, 103, 104, 105, 106, 107, 95, 96, + /* 110 */ 36, 98, 99, 100, 101, 102, 103, 104, 105, 106, + /* 120 */ 107, 12, 13, 14, 15, 16, 67, 68, 69, 70, + /* 130 */ 71, 72, 73, 74, 75, 76, 77, 2, 79, 80, + /* 140 */ 81, 82, 83, 84, 158, 19, 160, 12, 13, 14, + /* 150 */ 15, 16, 166, 27, 0, 169, 31, 171, 172, 33, + /* 160 */ 112, 175, 176, 177, 178, 142, 194, 58, 182, 183, + /* 170 */ 31, 18, 143, 150, 113, 22, 153, 24, 25, 207, + /* 180 */ 194, 31, 56, 211, 158, 59, 160, 158, 35, 0, + /* 190 */ 36, 21, 166, 207, 145, 169, 57, 211, 172, 29, + /* 200 */ 171, 175, 176, 177, 178, 156, 177, 90, 182, 183, + /* 210 */ 184, 133, 134, 14, 15, 16, 187, 188, 189, 21, + /* 220 */ 191, 157, 196, 194, 160, 36, 162, 29, 202, 203, + /* 230 */ 158, 19, 160, 36, 117, 118, 207, 31, 166, 27, + /* 240 */ 211, 169, 21, 63, 172, 33, 76, 175, 176, 177, + /* 250 */ 178, 112, 31, 32, 182, 183, 184, 143, 3, 158, + /* 260 */ 146, 160, 92, 93, 94, 112, 143, 166, 56, 146, + /* 270 */ 169, 59, 158, 172, 214, 203, 175, 176, 177, 178, + /* 280 */ 147, 158, 205, 182, 183, 184, 199, 158, 143, 160, + /* 290 */ 138, 146, 159, 160, 193, 166, 147, 85, 169, 148, + /* 300 */ 88, 172, 151, 158, 175, 176, 177, 178, 159, 160, + /* 310 */ 31, 182, 183, 184, 142, 109, 158, 140, 160, 95, + /* 320 */ 12, 13, 193, 171, 166, 153, 192, 169, 104, 21, + /* 330 */ 172, 107, 65, 175, 176, 177, 178, 29, 0, 31, + /* 340 */ 182, 183, 184, 87, 173, 37, 194, 12, 13, 14, + /* 350 */ 157, 193, 173, 160, 160, 162, 21, 174, 173, 207, + /* 360 */ 158, 190, 160, 211, 29, 57, 31, 111, 166, 190, + /* 370 */ 37, 169, 37, 171, 172, 190, 14, 175, 176, 177, + /* 380 */ 65, 168, 169, 128, 76, 47, 12, 13, 109, 51, + /* 390 */ 159, 160, 57, 31, 208, 21, 194, 12, 13, 132, + /* 400 */ 92, 93, 94, 29, 66, 31, 21, 143, 160, 207, + /* 410 */ 162, 76, 20, 211, 29, 23, 31, 110, 111, 58, + /* 420 */ 112, 195, 37, 85, 31, 58, 65, 92, 93, 94, + /* 430 */ 97, 57, 65, 58, 58, 158, 0, 160, 1, 2, + /* 440 */ 65, 65, 57, 166, 58, 130, 169, 136, 137, 172, + /* 450 */ 76, 65, 175, 176, 177, 178, 12, 13, 14, 182, + /* 460 */ 183, 76, 57, 12, 13, 21, 92, 93, 94, 64, + /* 470 */ 145, 57, 21, 29, 58, 31, 62, 92, 93, 94, + /* 480 */ 29, 65, 31, 47, 143, 145, 112, 51, 12, 13, + /* 490 */ 139, 26, 158, 31, 160, 30, 31, 21, 139, 34, + /* 500 */ 166, 57, 66, 169, 158, 29, 172, 31, 57, 175, + /* 510 */ 176, 177, 58, 31, 120, 143, 58, 58, 53, 65, + /* 520 */ 76, 85, 58, 65, 65, 60, 61, 76, 58, 65, + /* 530 */ 158, 31, 58, 57, 163, 65, 92, 93, 94, 65, + /* 540 */ 31, 58, 174, 92, 93, 94, 212, 213, 65, 177, + /* 550 */ 58, 204, 76, 119, 167, 58, 91, 65, 186, 187, + /* 560 */ 188, 189, 65, 191, 158, 94, 160, 166, 92, 93, + /* 570 */ 94, 167, 166, 204, 166, 169, 127, 200, 172, 201, + /* 580 */ 198, 175, 176, 177, 178, 197, 158, 97, 160, 183, + /* 590 */ 115, 114, 126, 158, 166, 111, 31, 169, 170, 173, + /* 600 */ 172, 210, 108, 175, 176, 177, 185, 135, 158, 131, + /* 610 */ 160, 121, 122, 123, 124, 125, 166, 215, 129, 169, + /* 620 */ 170, 209, 172, 57, 181, 175, 176, 177, 167, 166, + /* 630 */ 89, 158, 151, 160, 166, 57, 167, 142, 142, 166, + /* 640 */ 139, 154, 169, 164, 158, 172, 166, 143, 175, 176, + /* 650 */ 177, 158, 149, 160, 163, 144, 158, 149, 0, 166, + /* 660 */ 53, 64, 169, 0, 158, 172, 160, 0, 175, 176, + /* 670 */ 177, 0, 166, 38, 0, 169, 170, 21, 172, 206, + /* 680 */ 0, 175, 176, 177, 0, 0, 158, 0, 160, 12, + /* 690 */ 13, 14, 15, 16, 166, 19, 21, 169, 170, 0, + /* 700 */ 172, 0, 0, 175, 176, 177, 213, 0, 0, 0, + /* 710 */ 0, 158, 143, 160, 0, 0, 57, 87, 86, 166, + /* 720 */ 65, 116, 169, 58, 58, 172, 65, 158, 175, 176, + /* 730 */ 177, 158, 29, 160, 65, 57, 57, 65, 57, 166, + /* 740 */ 58, 58, 169, 57, 116, 172, 177, 110, 175, 176, + /* 750 */ 177, 58, 64, 158, 65, 160, 187, 188, 189, 65, + /* 760 */ 191, 166, 58, 65, 169, 116, 29, 172, 4, 64, + /* 770 */ 175, 176, 177, 29, 58, 158, 64, 160, 29, 29, + /* 780 */ 29, 29, 2, 166, 58, 64, 169, 97, 57, 172, + /* 790 */ 57, 57, 175, 176, 177, 0, 58, 58, 158, 57, + /* 800 */ 160, 90, 57, 57, 87, 86, 166, 64, 21, 169, + /* 810 */ 62, 64, 172, 57, 29, 175, 176, 177, 158, 58, + /* 820 */ 160, 63, 29, 57, 21, 58, 166, 29, 57, 169, + /* 830 */ 58, 158, 172, 160, 29, 175, 176, 177, 57, 166, + /* 840 */ 58, 29, 169, 57, 29, 172, 58, 57, 175, 176, + /* 850 */ 177, 78, 78, 158, 78, 160, 78, 66, 57, 57, + /* 860 */ 29, 166, 29, 21, 169, 21, 38, 172, 29, 29, + /* 870 */ 175, 176, 177, 37, 29, 29, 29, 29, 158, 29, + /* 880 */ 160, 29, 29, 29, 29, 29, 166, 29, 29, 169, + /* 890 */ 29, 29, 172, 0, 29, 175, 176, 177, 158, 28, + /* 900 */ 160, 0, 0, 21, 20, 216, 166, 216, 216, 169, + /* 910 */ 216, 216, 172, 216, 216, 175, 176, 177, 216, 216, + /* 920 */ 158, 216, 160, 216, 216, 216, 216, 216, 166, 216, + /* 930 */ 216, 169, 216, 216, 172, 216, 216, 175, 176, 177, + /* 940 */ 216, 216, 158, 216, 160, 216, 216, 216, 216, 216, + /* 950 */ 166, 216, 216, 169, 216, 216, 172, 216, 216, 175, + /* 960 */ 176, 177, 216, 216, 216, 158, 216, 160, 216, 216, + /* 970 */ 216, 216, 216, 166, 216, 143, 169, 216, 216, 172, + /* 980 */ 216, 216, 175, 176, 177, 158, 216, 160, 216, 216, + /* 990 */ 158, 216, 216, 166, 216, 216, 169, 216, 216, 172, + /* 1000 */ 216, 216, 175, 176, 177, 216, 216, 216, 216, 177, + /* 1010 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 187, + /* 1020 */ 188, 189, 2, 191, 216, 216, 216, 216, 216, 216, + /* 1030 */ 216, 216, 12, 13, 14, 15, 16, 216, 216, 216, + /* 1040 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1050 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1060 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1070 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1080 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1090 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1100 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1110 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1120 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1130 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1140 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1150 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1160 */ 216, }; -#define YY_SHIFT_COUNT (278) +#define YY_SHIFT_COUNT (307) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (902) +#define YY_SHIFT_MAX (1020) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 766, 227, 249, 336, 336, 336, 336, 350, 336, 336, - /* 10 */ 166, 434, 459, 430, 459, 459, 459, 459, 459, 459, - /* 20 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 459, - /* 30 */ 459, 459, 228, 228, 228, 465, 465, 61, 61, 37, - /* 40 */ 139, 139, 146, 238, 139, 139, 238, 139, 238, 238, - /* 50 */ 238, 139, 179, 0, 13, 13, 465, 390, 58, 58, - /* 60 */ 58, 5, 153, 238, 238, 247, 51, 714, 764, 393, - /* 70 */ 245, 186, 273, 223, 273, 418, 244, 101, 284, 452, - /* 80 */ 380, 382, 436, 436, 380, 382, 436, 443, 446, 477, - /* 90 */ 472, 482, 568, 582, 516, 563, 491, 506, 517, 238, - /* 100 */ 611, 146, 611, 146, 625, 625, 247, 179, 568, 610, - /* 110 */ 611, 179, 625, 905, 905, 905, 30, 52, 801, 806, - /* 120 */ 814, 814, 814, 814, 814, 814, 814, 142, 317, 545, - /* 130 */ 775, 296, 376, 72, 72, 72, 72, 217, 369, 412, - /* 140 */ 431, 229, 323, 301, 253, 444, 463, 461, 466, 471, - /* 150 */ 500, 515, 519, 540, 550, 162, 618, 627, 583, 639, - /* 160 */ 640, 642, 638, 646, 653, 654, 658, 655, 659, 694, - /* 170 */ 660, 665, 667, 668, 624, 672, 680, 675, 645, 687, - /* 180 */ 690, 753, 664, 702, 703, 699, 656, 765, 741, 742, - /* 190 */ 743, 744, 754, 756, 718, 729, 787, 789, 792, 793, - /* 200 */ 745, 732, 797, 799, 804, 810, 811, 812, 823, 786, - /* 210 */ 825, 832, 833, 835, 836, 816, 838, 818, 821, 784, - /* 220 */ 780, 779, 781, 826, 791, 783, 794, 815, 820, 796, - /* 230 */ 798, 822, 800, 802, 829, 805, 803, 830, 808, 809, - /* 240 */ 834, 813, 772, 776, 777, 788, 847, 807, 819, 824, - /* 250 */ 840, 842, 851, 837, 841, 848, 850, 853, 854, 855, - /* 260 */ 856, 857, 859, 858, 860, 861, 862, 863, 864, 867, - /* 270 */ 868, 869, 888, 870, 872, 901, 902, 882, 884, + /* 0 */ 153, 308, 335, 385, 385, 385, 385, 374, 385, 385, + /* 10 */ 139, 451, 476, 444, 451, 451, 451, 451, 451, 451, + /* 20 */ 451, 451, 451, 451, 451, 451, 451, 451, 451, 451, + /* 30 */ 451, 451, 451, 9, 9, 9, 170, 170, 57, 57, + /* 40 */ 74, 66, 125, 125, 48, 150, 66, 57, 57, 66, + /* 50 */ 57, 66, 66, 66, 57, 197, 0, 13, 13, 170, + /* 60 */ 221, 154, 206, 206, 206, 189, 150, 66, 66, 180, + /* 70 */ 59, 465, 78, 490, 117, 198, 279, 307, 256, 307, + /* 80 */ 362, 255, 61, 393, 74, 393, 74, 462, 462, 482, + /* 90 */ 500, 509, 394, 434, 471, 394, 434, 471, 449, 466, + /* 100 */ 475, 477, 484, 482, 565, 494, 472, 478, 489, 566, + /* 110 */ 66, 434, 471, 471, 434, 471, 541, 482, 500, 180, + /* 120 */ 197, 482, 578, 393, 197, 462, 1037, 1037, 1037, 30, + /* 130 */ 212, 135, 1020, 109, 126, 677, 677, 677, 677, 677, + /* 140 */ 677, 677, 338, 436, 31, 224, 199, 199, 199, 199, + /* 150 */ 392, 361, 367, 375, 437, 311, 315, 267, 376, 333, + /* 160 */ 386, 405, 416, 454, 458, 459, 464, 470, 474, 483, + /* 170 */ 492, 497, 414, 658, 663, 667, 671, 607, 597, 680, + /* 180 */ 684, 685, 687, 699, 701, 702, 635, 674, 707, 708, + /* 190 */ 709, 710, 656, 714, 675, 676, 715, 659, 630, 632, + /* 200 */ 655, 661, 605, 665, 669, 666, 678, 679, 682, 681, + /* 210 */ 683, 703, 672, 688, 686, 689, 628, 693, 704, 705, + /* 220 */ 637, 694, 712, 716, 698, 649, 764, 737, 744, 749, + /* 230 */ 750, 751, 752, 780, 690, 721, 726, 731, 733, 738, + /* 240 */ 739, 734, 742, 711, 745, 795, 717, 719, 746, 748, + /* 250 */ 743, 747, 787, 756, 758, 761, 785, 793, 766, 767, + /* 260 */ 798, 771, 772, 805, 781, 782, 812, 786, 788, 815, + /* 270 */ 790, 773, 774, 776, 778, 803, 791, 801, 802, 831, + /* 280 */ 833, 842, 828, 836, 839, 840, 845, 846, 847, 848, + /* 290 */ 850, 844, 852, 853, 854, 855, 856, 858, 859, 861, + /* 300 */ 862, 893, 865, 871, 901, 902, 882, 884, }; -#define YY_REDUCE_COUNT (115) -#define YY_REDUCE_MIN (-169) -#define YY_REDUCE_MAX (626) +#define YY_REDUCE_COUNT (128) +#define YY_REDUCE_MIN (-162) +#define YY_REDUCE_MAX (832) static const short yy_reduce_ofst[] = { - /* 0 */ 108, -19, 17, 59, -123, 33, 75, 184, 126, 234, - /* 10 */ 250, 307, 338, -3, 165, 110, 371, 394, 409, 424, - /* 20 */ 440, 455, 470, 483, 496, 511, 524, 539, 552, 565, - /* 30 */ 580, 596, 237, -120, 626, -152, -144, -136, -18, 27, - /* 40 */ -107, -98, 104, -133, 164, 200, -153, 232, 167, 14, - /* 50 */ 242, 305, 152, -169, -169, -169, -106, -21, 192, 212, - /* 60 */ 271, -13, 7, 20, 47, 107, -151, -118, 135, 154, - /* 70 */ 170, 220, 256, 256, 256, 295, 240, 280, 342, 327, - /* 80 */ 306, 312, 368, 388, 345, 363, 400, 375, 391, 384, - /* 90 */ 405, 256, 449, 450, 451, 453, 421, 432, 439, 295, - /* 100 */ 507, 512, 508, 513, 525, 528, 521, 531, 505, 520, - /* 110 */ 535, 537, 546, 538, 542, 548, + /* 0 */ 152, -14, 26, 72, 101, 129, 158, 202, -115, 277, + /* 10 */ 29, 334, 406, 428, 450, 473, 493, 506, 528, 553, + /* 20 */ 573, 595, 617, 640, 660, 673, 695, 720, 740, 762, + /* 30 */ 784, 807, 827, 372, 569, 832, -155, -148, -138, -137, + /* 40 */ -114, -121, -157, -112, -28, -116, -125, -99, 114, 64, + /* 50 */ 123, 133, 193, 149, 145, 23, -124, -124, -124, -162, + /* 60 */ -54, 49, 171, 179, 185, 172, 213, 231, 248, 151, + /* 70 */ -159, -120, 60, 77, 87, 177, 183, 134, 134, 134, + /* 80 */ 194, 186, 226, 264, 325, 341, 340, 351, 359, 346, + /* 90 */ 371, 368, 347, 387, 401, 369, 404, 408, 378, 377, + /* 100 */ 382, 388, 134, 435, 426, 421, 402, 391, 412, 443, + /* 110 */ 194, 461, 463, 468, 469, 480, 479, 486, 491, 481, + /* 120 */ 495, 498, 487, 504, 496, 501, 503, 508, 511, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - /* 10 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - /* 20 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - /* 30 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - /* 40 */ 676, 676, 699, 676, 676, 676, 676, 676, 676, 676, - /* 50 */ 676, 676, 697, 676, 835, 676, 676, 676, 846, 846, - /* 60 */ 846, 699, 697, 676, 676, 762, 676, 676, 910, 676, - /* 70 */ 870, 862, 838, 852, 839, 676, 895, 855, 676, 676, - /* 80 */ 877, 875, 676, 676, 877, 875, 676, 889, 885, 868, - /* 90 */ 866, 852, 676, 676, 676, 676, 913, 901, 897, 676, - /* 100 */ 676, 699, 676, 699, 676, 676, 676, 697, 676, 731, - /* 110 */ 676, 697, 676, 765, 765, 700, 676, 676, 676, 676, - /* 120 */ 888, 887, 812, 811, 810, 806, 807, 676, 676, 676, - /* 130 */ 676, 676, 676, 801, 802, 800, 799, 676, 676, 836, - /* 140 */ 676, 676, 676, 898, 902, 676, 788, 676, 676, 676, - /* 150 */ 676, 676, 676, 676, 676, 676, 859, 869, 676, 676, - /* 160 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - /* 170 */ 676, 788, 676, 886, 676, 845, 841, 676, 676, 837, - /* 180 */ 676, 831, 676, 676, 676, 896, 676, 676, 676, 676, - /* 190 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - /* 200 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - /* 210 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - /* 220 */ 676, 787, 676, 676, 676, 676, 676, 676, 676, 759, - /* 230 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - /* 240 */ 676, 676, 744, 742, 741, 740, 676, 737, 676, 676, - /* 250 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - /* 260 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - /* 270 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, + /* 0 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 10 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 20 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 30 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 40 */ 744, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 50 */ 721, 721, 721, 721, 721, 742, 721, 889, 721, 721, + /* 60 */ 721, 744, 900, 900, 900, 742, 721, 721, 721, 807, + /* 70 */ 721, 721, 964, 721, 924, 721, 916, 892, 906, 893, + /* 80 */ 721, 949, 909, 721, 744, 721, 744, 721, 721, 721, + /* 90 */ 721, 721, 931, 929, 721, 931, 929, 721, 943, 939, + /* 100 */ 922, 920, 906, 721, 721, 721, 967, 955, 951, 721, + /* 110 */ 721, 929, 721, 721, 929, 721, 820, 721, 721, 721, + /* 120 */ 742, 721, 776, 721, 742, 721, 810, 810, 745, 721, + /* 130 */ 721, 721, 721, 721, 721, 861, 942, 941, 860, 866, + /* 140 */ 865, 864, 721, 721, 721, 721, 855, 856, 854, 853, + /* 150 */ 721, 721, 721, 721, 890, 721, 952, 956, 721, 721, + /* 160 */ 721, 841, 721, 721, 721, 721, 721, 721, 721, 721, + /* 170 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 180 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 190 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 200 */ 913, 923, 721, 721, 721, 721, 721, 721, 721, 721, + /* 210 */ 721, 721, 721, 841, 721, 940, 721, 899, 895, 721, + /* 220 */ 721, 891, 721, 721, 950, 721, 721, 721, 721, 721, + /* 230 */ 721, 721, 721, 885, 721, 721, 721, 721, 721, 721, + /* 240 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 250 */ 840, 721, 721, 721, 721, 721, 721, 721, 804, 721, + /* 260 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 270 */ 721, 789, 787, 786, 785, 721, 782, 721, 721, 721, + /* 280 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 290 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 300 */ 721, 721, 721, 721, 721, 721, 721, 721, }; /********** End of lemon-generated parsing tables *****************************/ @@ -679,129 +710,136 @@ static const char *const yyTokenName[] = { /* 83 */ "VARBINARY", /* 84 */ "DECIMAL", /* 85 */ "SMA", - /* 86 */ "MNODES", - /* 87 */ "NK_FLOAT", - /* 88 */ "NK_BOOL", - /* 89 */ "NK_VARIABLE", - /* 90 */ "BETWEEN", - /* 91 */ "IS", - /* 92 */ "NULL", - /* 93 */ "NK_LT", - /* 94 */ "NK_GT", - /* 95 */ "NK_LE", - /* 96 */ "NK_GE", - /* 97 */ "NK_NE", - /* 98 */ "NK_EQ", - /* 99 */ "LIKE", - /* 100 */ "MATCH", - /* 101 */ "NMATCH", - /* 102 */ "IN", - /* 103 */ "FROM", - /* 104 */ "AS", - /* 105 */ "JOIN", - /* 106 */ "ON", - /* 107 */ "INNER", - /* 108 */ "SELECT", - /* 109 */ "DISTINCT", - /* 110 */ "WHERE", - /* 111 */ "PARTITION", - /* 112 */ "BY", - /* 113 */ "SESSION", - /* 114 */ "STATE_WINDOW", - /* 115 */ "INTERVAL", - /* 116 */ "SLIDING", - /* 117 */ "FILL", - /* 118 */ "VALUE", - /* 119 */ "NONE", - /* 120 */ "PREV", - /* 121 */ "LINEAR", - /* 122 */ "NEXT", - /* 123 */ "GROUP", - /* 124 */ "HAVING", - /* 125 */ "ORDER", - /* 126 */ "SLIMIT", - /* 127 */ "SOFFSET", - /* 128 */ "LIMIT", - /* 129 */ "OFFSET", - /* 130 */ "ASC", - /* 131 */ "DESC", - /* 132 */ "NULLS", - /* 133 */ "FIRST", - /* 134 */ "LAST", - /* 135 */ "cmd", - /* 136 */ "user_name", - /* 137 */ "dnode_endpoint", - /* 138 */ "dnode_host_name", - /* 139 */ "not_exists_opt", - /* 140 */ "db_name", - /* 141 */ "db_options", - /* 142 */ "exists_opt", - /* 143 */ "full_table_name", - /* 144 */ "column_def_list", - /* 145 */ "tags_def_opt", - /* 146 */ "table_options", - /* 147 */ "multi_create_clause", - /* 148 */ "tags_def", - /* 149 */ "multi_drop_clause", - /* 150 */ "create_subtable_clause", - /* 151 */ "specific_tags_opt", - /* 152 */ "literal_list", - /* 153 */ "drop_table_clause", - /* 154 */ "col_name_list", - /* 155 */ "table_name", - /* 156 */ "column_def", - /* 157 */ "column_name", - /* 158 */ "type_name", - /* 159 */ "col_name", - /* 160 */ "query_expression", - /* 161 */ "literal", - /* 162 */ "duration_literal", - /* 163 */ "function_name", - /* 164 */ "table_alias", - /* 165 */ "column_alias", - /* 166 */ "expression", - /* 167 */ "column_reference", - /* 168 */ "expression_list", - /* 169 */ "subquery", - /* 170 */ "predicate", - /* 171 */ "compare_op", - /* 172 */ "in_op", - /* 173 */ "in_predicate_value", - /* 174 */ "boolean_value_expression", - /* 175 */ "boolean_primary", - /* 176 */ "common_expression", - /* 177 */ "from_clause", - /* 178 */ "table_reference_list", - /* 179 */ "table_reference", - /* 180 */ "table_primary", - /* 181 */ "joined_table", - /* 182 */ "alias_opt", - /* 183 */ "parenthesized_joined_table", - /* 184 */ "join_type", - /* 185 */ "search_condition", - /* 186 */ "query_specification", - /* 187 */ "set_quantifier_opt", - /* 188 */ "select_list", - /* 189 */ "where_clause_opt", - /* 190 */ "partition_by_clause_opt", - /* 191 */ "twindow_clause_opt", - /* 192 */ "group_by_clause_opt", - /* 193 */ "having_clause_opt", - /* 194 */ "select_sublist", - /* 195 */ "select_item", - /* 196 */ "sliding_opt", - /* 197 */ "fill_opt", - /* 198 */ "fill_mode", - /* 199 */ "group_by_list", - /* 200 */ "query_expression_body", - /* 201 */ "order_by_clause_opt", - /* 202 */ "slimit_clause_opt", - /* 203 */ "limit_clause_opt", - /* 204 */ "query_primary", - /* 205 */ "sort_specification_list", - /* 206 */ "sort_specification", - /* 207 */ "ordering_specification_opt", - /* 208 */ "null_ordering_opt", + /* 86 */ "INDEX", + /* 87 */ "ON", + /* 88 */ "FULLTEXT", + /* 89 */ "FUNCTION", + /* 90 */ "INTERVAL", + /* 91 */ "MNODES", + /* 92 */ "NK_FLOAT", + /* 93 */ "NK_BOOL", + /* 94 */ "NK_VARIABLE", + /* 95 */ "BETWEEN", + /* 96 */ "IS", + /* 97 */ "NULL", + /* 98 */ "NK_LT", + /* 99 */ "NK_GT", + /* 100 */ "NK_LE", + /* 101 */ "NK_GE", + /* 102 */ "NK_NE", + /* 103 */ "NK_EQ", + /* 104 */ "LIKE", + /* 105 */ "MATCH", + /* 106 */ "NMATCH", + /* 107 */ "IN", + /* 108 */ "FROM", + /* 109 */ "AS", + /* 110 */ "JOIN", + /* 111 */ "INNER", + /* 112 */ "SELECT", + /* 113 */ "DISTINCT", + /* 114 */ "WHERE", + /* 115 */ "PARTITION", + /* 116 */ "BY", + /* 117 */ "SESSION", + /* 118 */ "STATE_WINDOW", + /* 119 */ "SLIDING", + /* 120 */ "FILL", + /* 121 */ "VALUE", + /* 122 */ "NONE", + /* 123 */ "PREV", + /* 124 */ "LINEAR", + /* 125 */ "NEXT", + /* 126 */ "GROUP", + /* 127 */ "HAVING", + /* 128 */ "ORDER", + /* 129 */ "SLIMIT", + /* 130 */ "SOFFSET", + /* 131 */ "LIMIT", + /* 132 */ "OFFSET", + /* 133 */ "ASC", + /* 134 */ "DESC", + /* 135 */ "NULLS", + /* 136 */ "FIRST", + /* 137 */ "LAST", + /* 138 */ "cmd", + /* 139 */ "user_name", + /* 140 */ "dnode_endpoint", + /* 141 */ "dnode_host_name", + /* 142 */ "not_exists_opt", + /* 143 */ "db_name", + /* 144 */ "db_options", + /* 145 */ "exists_opt", + /* 146 */ "full_table_name", + /* 147 */ "column_def_list", + /* 148 */ "tags_def_opt", + /* 149 */ "table_options", + /* 150 */ "multi_create_clause", + /* 151 */ "tags_def", + /* 152 */ "multi_drop_clause", + /* 153 */ "create_subtable_clause", + /* 154 */ "specific_tags_opt", + /* 155 */ "literal_list", + /* 156 */ "drop_table_clause", + /* 157 */ "col_name_list", + /* 158 */ "table_name", + /* 159 */ "column_def", + /* 160 */ "column_name", + /* 161 */ "type_name", + /* 162 */ "col_name", + /* 163 */ "index_name", + /* 164 */ "index_options", + /* 165 */ "func_list", + /* 166 */ "duration_literal", + /* 167 */ "sliding_opt", + /* 168 */ "func", + /* 169 */ "function_name", + /* 170 */ "expression_list", + /* 171 */ "query_expression", + /* 172 */ "literal", + /* 173 */ "table_alias", + /* 174 */ "column_alias", + /* 175 */ "expression", + /* 176 */ "column_reference", + /* 177 */ "subquery", + /* 178 */ "predicate", + /* 179 */ "compare_op", + /* 180 */ "in_op", + /* 181 */ "in_predicate_value", + /* 182 */ "boolean_value_expression", + /* 183 */ "boolean_primary", + /* 184 */ "common_expression", + /* 185 */ "from_clause", + /* 186 */ "table_reference_list", + /* 187 */ "table_reference", + /* 188 */ "table_primary", + /* 189 */ "joined_table", + /* 190 */ "alias_opt", + /* 191 */ "parenthesized_joined_table", + /* 192 */ "join_type", + /* 193 */ "search_condition", + /* 194 */ "query_specification", + /* 195 */ "set_quantifier_opt", + /* 196 */ "select_list", + /* 197 */ "where_clause_opt", + /* 198 */ "partition_by_clause_opt", + /* 199 */ "twindow_clause_opt", + /* 200 */ "group_by_clause_opt", + /* 201 */ "having_clause_opt", + /* 202 */ "select_sublist", + /* 203 */ "select_item", + /* 204 */ "fill_opt", + /* 205 */ "fill_mode", + /* 206 */ "group_by_list", + /* 207 */ "query_expression_body", + /* 208 */ "order_by_clause_opt", + /* 209 */ "slimit_clause_opt", + /* 210 */ "limit_clause_opt", + /* 211 */ "query_primary", + /* 212 */ "sort_specification_list", + /* 213 */ "sort_specification", + /* 214 */ "ordering_specification_opt", + /* 215 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -903,149 +941,158 @@ static const char *const yyRuleName[] = { /* 91 */ "col_name_list ::= col_name", /* 92 */ "col_name_list ::= col_name_list NK_COMMA col_name", /* 93 */ "col_name ::= column_name", - /* 94 */ "cmd ::= SHOW VGROUPS", - /* 95 */ "cmd ::= SHOW db_name NK_DOT VGROUPS", - /* 96 */ "cmd ::= SHOW MNODES", - /* 97 */ "cmd ::= query_expression", - /* 98 */ "literal ::= NK_INTEGER", - /* 99 */ "literal ::= NK_FLOAT", - /* 100 */ "literal ::= NK_STRING", - /* 101 */ "literal ::= NK_BOOL", - /* 102 */ "literal ::= TIMESTAMP NK_STRING", - /* 103 */ "literal ::= duration_literal", - /* 104 */ "duration_literal ::= NK_VARIABLE", - /* 105 */ "literal_list ::= literal", - /* 106 */ "literal_list ::= literal_list NK_COMMA literal", - /* 107 */ "db_name ::= NK_ID", - /* 108 */ "table_name ::= NK_ID", - /* 109 */ "column_name ::= NK_ID", - /* 110 */ "function_name ::= NK_ID", - /* 111 */ "table_alias ::= NK_ID", - /* 112 */ "column_alias ::= NK_ID", - /* 113 */ "user_name ::= NK_ID", - /* 114 */ "expression ::= literal", - /* 115 */ "expression ::= column_reference", - /* 116 */ "expression ::= function_name NK_LP expression_list NK_RP", - /* 117 */ "expression ::= function_name NK_LP NK_STAR NK_RP", - /* 118 */ "expression ::= subquery", - /* 119 */ "expression ::= NK_LP expression NK_RP", - /* 120 */ "expression ::= NK_PLUS expression", - /* 121 */ "expression ::= NK_MINUS expression", - /* 122 */ "expression ::= expression NK_PLUS expression", - /* 123 */ "expression ::= expression NK_MINUS expression", - /* 124 */ "expression ::= expression NK_STAR expression", - /* 125 */ "expression ::= expression NK_SLASH expression", - /* 126 */ "expression ::= expression NK_REM expression", - /* 127 */ "expression_list ::= expression", - /* 128 */ "expression_list ::= expression_list NK_COMMA expression", - /* 129 */ "column_reference ::= column_name", - /* 130 */ "column_reference ::= table_name NK_DOT column_name", - /* 131 */ "predicate ::= expression compare_op expression", - /* 132 */ "predicate ::= expression BETWEEN expression AND expression", - /* 133 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 134 */ "predicate ::= expression IS NULL", - /* 135 */ "predicate ::= expression IS NOT NULL", - /* 136 */ "predicate ::= expression in_op in_predicate_value", - /* 137 */ "compare_op ::= NK_LT", - /* 138 */ "compare_op ::= NK_GT", - /* 139 */ "compare_op ::= NK_LE", - /* 140 */ "compare_op ::= NK_GE", - /* 141 */ "compare_op ::= NK_NE", - /* 142 */ "compare_op ::= NK_EQ", - /* 143 */ "compare_op ::= LIKE", - /* 144 */ "compare_op ::= NOT LIKE", - /* 145 */ "compare_op ::= MATCH", - /* 146 */ "compare_op ::= NMATCH", - /* 147 */ "in_op ::= IN", - /* 148 */ "in_op ::= NOT IN", - /* 149 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 150 */ "boolean_value_expression ::= boolean_primary", - /* 151 */ "boolean_value_expression ::= NOT boolean_primary", - /* 152 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 153 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 154 */ "boolean_primary ::= predicate", - /* 155 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 156 */ "common_expression ::= expression", - /* 157 */ "common_expression ::= boolean_value_expression", - /* 158 */ "from_clause ::= FROM table_reference_list", - /* 159 */ "table_reference_list ::= table_reference", - /* 160 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 161 */ "table_reference ::= table_primary", - /* 162 */ "table_reference ::= joined_table", - /* 163 */ "table_primary ::= table_name alias_opt", - /* 164 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 165 */ "table_primary ::= subquery alias_opt", - /* 166 */ "table_primary ::= parenthesized_joined_table", - /* 167 */ "alias_opt ::=", - /* 168 */ "alias_opt ::= table_alias", - /* 169 */ "alias_opt ::= AS table_alias", - /* 170 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 171 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 172 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 173 */ "join_type ::=", - /* 174 */ "join_type ::= INNER", - /* 175 */ "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", - /* 176 */ "set_quantifier_opt ::=", - /* 177 */ "set_quantifier_opt ::= DISTINCT", - /* 178 */ "set_quantifier_opt ::= ALL", - /* 179 */ "select_list ::= NK_STAR", - /* 180 */ "select_list ::= select_sublist", - /* 181 */ "select_sublist ::= select_item", - /* 182 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 183 */ "select_item ::= common_expression", - /* 184 */ "select_item ::= common_expression column_alias", - /* 185 */ "select_item ::= common_expression AS column_alias", - /* 186 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 187 */ "where_clause_opt ::=", - /* 188 */ "where_clause_opt ::= WHERE search_condition", - /* 189 */ "partition_by_clause_opt ::=", - /* 190 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 191 */ "twindow_clause_opt ::=", - /* 192 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP", - /* 193 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", - /* 194 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 195 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 196 */ "sliding_opt ::=", - /* 197 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 198 */ "fill_opt ::=", - /* 199 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 200 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 201 */ "fill_mode ::= NONE", - /* 202 */ "fill_mode ::= PREV", - /* 203 */ "fill_mode ::= NULL", - /* 204 */ "fill_mode ::= LINEAR", - /* 205 */ "fill_mode ::= NEXT", - /* 206 */ "group_by_clause_opt ::=", - /* 207 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 208 */ "group_by_list ::= expression", - /* 209 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 210 */ "having_clause_opt ::=", - /* 211 */ "having_clause_opt ::= HAVING search_condition", - /* 212 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 213 */ "query_expression_body ::= query_primary", - /* 214 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 215 */ "query_primary ::= query_specification", - /* 216 */ "order_by_clause_opt ::=", - /* 217 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 218 */ "slimit_clause_opt ::=", - /* 219 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 220 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 221 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 222 */ "limit_clause_opt ::=", - /* 223 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 224 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 225 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 226 */ "subquery ::= NK_LP query_expression NK_RP", - /* 227 */ "search_condition ::= common_expression", - /* 228 */ "sort_specification_list ::= sort_specification", - /* 229 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 230 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 231 */ "ordering_specification_opt ::=", - /* 232 */ "ordering_specification_opt ::= ASC", - /* 233 */ "ordering_specification_opt ::= DESC", - /* 234 */ "null_ordering_opt ::=", - /* 235 */ "null_ordering_opt ::= NULLS FIRST", - /* 236 */ "null_ordering_opt ::= NULLS LAST", + /* 94 */ "cmd ::= CREATE SMA INDEX index_name ON table_name index_options", + /* 95 */ "cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP", + /* 96 */ "index_options ::=", + /* 97 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", + /* 98 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", + /* 99 */ "func_list ::= func", + /* 100 */ "func_list ::= func_list NK_COMMA func", + /* 101 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 102 */ "cmd ::= SHOW VGROUPS", + /* 103 */ "cmd ::= SHOW db_name NK_DOT VGROUPS", + /* 104 */ "cmd ::= SHOW MNODES", + /* 105 */ "cmd ::= query_expression", + /* 106 */ "literal ::= NK_INTEGER", + /* 107 */ "literal ::= NK_FLOAT", + /* 108 */ "literal ::= NK_STRING", + /* 109 */ "literal ::= NK_BOOL", + /* 110 */ "literal ::= TIMESTAMP NK_STRING", + /* 111 */ "literal ::= duration_literal", + /* 112 */ "duration_literal ::= NK_VARIABLE", + /* 113 */ "literal_list ::= literal", + /* 114 */ "literal_list ::= literal_list NK_COMMA literal", + /* 115 */ "db_name ::= NK_ID", + /* 116 */ "table_name ::= NK_ID", + /* 117 */ "column_name ::= NK_ID", + /* 118 */ "function_name ::= NK_ID", + /* 119 */ "table_alias ::= NK_ID", + /* 120 */ "column_alias ::= NK_ID", + /* 121 */ "user_name ::= NK_ID", + /* 122 */ "index_name ::= NK_ID", + /* 123 */ "expression ::= literal", + /* 124 */ "expression ::= column_reference", + /* 125 */ "expression ::= function_name NK_LP expression_list NK_RP", + /* 126 */ "expression ::= function_name NK_LP NK_STAR NK_RP", + /* 127 */ "expression ::= subquery", + /* 128 */ "expression ::= NK_LP expression NK_RP", + /* 129 */ "expression ::= NK_PLUS expression", + /* 130 */ "expression ::= NK_MINUS expression", + /* 131 */ "expression ::= expression NK_PLUS expression", + /* 132 */ "expression ::= expression NK_MINUS expression", + /* 133 */ "expression ::= expression NK_STAR expression", + /* 134 */ "expression ::= expression NK_SLASH expression", + /* 135 */ "expression ::= expression NK_REM expression", + /* 136 */ "expression_list ::= expression", + /* 137 */ "expression_list ::= expression_list NK_COMMA expression", + /* 138 */ "column_reference ::= column_name", + /* 139 */ "column_reference ::= table_name NK_DOT column_name", + /* 140 */ "predicate ::= expression compare_op expression", + /* 141 */ "predicate ::= expression BETWEEN expression AND expression", + /* 142 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 143 */ "predicate ::= expression IS NULL", + /* 144 */ "predicate ::= expression IS NOT NULL", + /* 145 */ "predicate ::= expression in_op in_predicate_value", + /* 146 */ "compare_op ::= NK_LT", + /* 147 */ "compare_op ::= NK_GT", + /* 148 */ "compare_op ::= NK_LE", + /* 149 */ "compare_op ::= NK_GE", + /* 150 */ "compare_op ::= NK_NE", + /* 151 */ "compare_op ::= NK_EQ", + /* 152 */ "compare_op ::= LIKE", + /* 153 */ "compare_op ::= NOT LIKE", + /* 154 */ "compare_op ::= MATCH", + /* 155 */ "compare_op ::= NMATCH", + /* 156 */ "in_op ::= IN", + /* 157 */ "in_op ::= NOT IN", + /* 158 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 159 */ "boolean_value_expression ::= boolean_primary", + /* 160 */ "boolean_value_expression ::= NOT boolean_primary", + /* 161 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 162 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 163 */ "boolean_primary ::= predicate", + /* 164 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 165 */ "common_expression ::= expression", + /* 166 */ "common_expression ::= boolean_value_expression", + /* 167 */ "from_clause ::= FROM table_reference_list", + /* 168 */ "table_reference_list ::= table_reference", + /* 169 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 170 */ "table_reference ::= table_primary", + /* 171 */ "table_reference ::= joined_table", + /* 172 */ "table_primary ::= table_name alias_opt", + /* 173 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 174 */ "table_primary ::= subquery alias_opt", + /* 175 */ "table_primary ::= parenthesized_joined_table", + /* 176 */ "alias_opt ::=", + /* 177 */ "alias_opt ::= table_alias", + /* 178 */ "alias_opt ::= AS table_alias", + /* 179 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 180 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 181 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 182 */ "join_type ::=", + /* 183 */ "join_type ::= INNER", + /* 184 */ "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", + /* 185 */ "set_quantifier_opt ::=", + /* 186 */ "set_quantifier_opt ::= DISTINCT", + /* 187 */ "set_quantifier_opt ::= ALL", + /* 188 */ "select_list ::= NK_STAR", + /* 189 */ "select_list ::= select_sublist", + /* 190 */ "select_sublist ::= select_item", + /* 191 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 192 */ "select_item ::= common_expression", + /* 193 */ "select_item ::= common_expression column_alias", + /* 194 */ "select_item ::= common_expression AS column_alias", + /* 195 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 196 */ "where_clause_opt ::=", + /* 197 */ "where_clause_opt ::= WHERE search_condition", + /* 198 */ "partition_by_clause_opt ::=", + /* 199 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 200 */ "twindow_clause_opt ::=", + /* 201 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP", + /* 202 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", + /* 203 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 204 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 205 */ "sliding_opt ::=", + /* 206 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 207 */ "fill_opt ::=", + /* 208 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 209 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 210 */ "fill_mode ::= NONE", + /* 211 */ "fill_mode ::= PREV", + /* 212 */ "fill_mode ::= NULL", + /* 213 */ "fill_mode ::= LINEAR", + /* 214 */ "fill_mode ::= NEXT", + /* 215 */ "group_by_clause_opt ::=", + /* 216 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 217 */ "group_by_list ::= expression", + /* 218 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 219 */ "having_clause_opt ::=", + /* 220 */ "having_clause_opt ::= HAVING search_condition", + /* 221 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 222 */ "query_expression_body ::= query_primary", + /* 223 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 224 */ "query_primary ::= query_specification", + /* 225 */ "order_by_clause_opt ::=", + /* 226 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 227 */ "slimit_clause_opt ::=", + /* 228 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 229 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 230 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 231 */ "limit_clause_opt ::=", + /* 232 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 233 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 234 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 235 */ "subquery ::= NK_LP query_expression NK_RP", + /* 236 */ "search_condition ::= common_expression", + /* 237 */ "sort_specification_list ::= sort_specification", + /* 238 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 239 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 240 */ "ordering_specification_opt ::=", + /* 241 */ "ordering_specification_opt ::= ASC", + /* 242 */ "ordering_specification_opt ::= DESC", + /* 243 */ "null_ordering_opt ::=", + /* 244 */ "null_ordering_opt ::= NULLS FIRST", + /* 245 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -1172,124 +1219,120 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 135: /* cmd */ - case 143: /* full_table_name */ - case 150: /* create_subtable_clause */ - case 153: /* drop_table_clause */ - case 156: /* column_def */ - case 159: /* col_name */ - case 160: /* query_expression */ - case 161: /* literal */ - case 162: /* duration_literal */ - case 166: /* expression */ - case 167: /* column_reference */ - case 169: /* subquery */ - case 170: /* predicate */ - case 173: /* in_predicate_value */ - case 174: /* boolean_value_expression */ - case 175: /* boolean_primary */ - case 176: /* common_expression */ - case 177: /* from_clause */ - case 178: /* table_reference_list */ - case 179: /* table_reference */ - case 180: /* table_primary */ - case 181: /* joined_table */ - case 183: /* parenthesized_joined_table */ - case 185: /* search_condition */ - case 186: /* query_specification */ - case 189: /* where_clause_opt */ - case 191: /* twindow_clause_opt */ - case 193: /* having_clause_opt */ - case 195: /* select_item */ - case 196: /* sliding_opt */ - case 197: /* fill_opt */ - case 200: /* query_expression_body */ - case 202: /* slimit_clause_opt */ - case 203: /* limit_clause_opt */ - case 204: /* query_primary */ - case 206: /* sort_specification */ + case 138: /* cmd */ + case 144: /* db_options */ + case 146: /* full_table_name */ + case 149: /* table_options */ + case 153: /* create_subtable_clause */ + case 156: /* drop_table_clause */ + case 159: /* column_def */ + case 162: /* col_name */ + case 164: /* index_options */ + case 166: /* duration_literal */ + case 167: /* sliding_opt */ + case 168: /* func */ + case 171: /* query_expression */ + case 172: /* literal */ + case 175: /* expression */ + case 176: /* column_reference */ + case 177: /* subquery */ + case 178: /* predicate */ + case 181: /* in_predicate_value */ + case 182: /* boolean_value_expression */ + case 183: /* boolean_primary */ + case 184: /* common_expression */ + case 185: /* from_clause */ + case 186: /* table_reference_list */ + case 187: /* table_reference */ + case 188: /* table_primary */ + case 189: /* joined_table */ + case 191: /* parenthesized_joined_table */ + case 193: /* search_condition */ + case 194: /* query_specification */ + case 197: /* where_clause_opt */ + case 199: /* twindow_clause_opt */ + case 201: /* having_clause_opt */ + case 203: /* select_item */ + case 204: /* fill_opt */ + case 207: /* query_expression_body */ + case 209: /* slimit_clause_opt */ + case 210: /* limit_clause_opt */ + case 211: /* query_primary */ + case 213: /* sort_specification */ { - nodesDestroyNode((yypminor->yy256)); + nodesDestroyNode((yypminor->yy344)); } break; - case 136: /* user_name */ - case 137: /* dnode_endpoint */ - case 138: /* dnode_host_name */ - case 140: /* db_name */ - case 155: /* table_name */ - case 157: /* column_name */ - case 163: /* function_name */ - case 164: /* table_alias */ - case 165: /* column_alias */ - case 182: /* alias_opt */ + case 139: /* user_name */ + case 140: /* dnode_endpoint */ + case 141: /* dnode_host_name */ + case 143: /* db_name */ + case 158: /* table_name */ + case 160: /* column_name */ + case 163: /* index_name */ + case 169: /* function_name */ + case 173: /* table_alias */ + case 174: /* column_alias */ + case 190: /* alias_opt */ { } break; - case 139: /* not_exists_opt */ - case 142: /* exists_opt */ - case 187: /* set_quantifier_opt */ + case 142: /* not_exists_opt */ + case 145: /* exists_opt */ + case 195: /* set_quantifier_opt */ { } break; - case 141: /* db_options */ + case 147: /* column_def_list */ + case 148: /* tags_def_opt */ + case 150: /* multi_create_clause */ + case 151: /* tags_def */ + case 152: /* multi_drop_clause */ + case 154: /* specific_tags_opt */ + case 155: /* literal_list */ + case 157: /* col_name_list */ + case 165: /* func_list */ + case 170: /* expression_list */ + case 196: /* select_list */ + case 198: /* partition_by_clause_opt */ + case 200: /* group_by_clause_opt */ + case 202: /* select_sublist */ + case 206: /* group_by_list */ + case 208: /* order_by_clause_opt */ + case 212: /* sort_specification_list */ { - tfree((yypminor->yy391)); + nodesDestroyList((yypminor->yy280)); } break; - case 144: /* column_def_list */ - case 145: /* tags_def_opt */ - case 147: /* multi_create_clause */ - case 148: /* tags_def */ - case 149: /* multi_drop_clause */ - case 151: /* specific_tags_opt */ - case 152: /* literal_list */ - case 154: /* col_name_list */ - case 168: /* expression_list */ - case 188: /* select_list */ - case 190: /* partition_by_clause_opt */ - case 192: /* group_by_clause_opt */ - case 194: /* select_sublist */ - case 199: /* group_by_list */ - case 201: /* order_by_clause_opt */ - case 205: /* sort_specification_list */ -{ - nodesDestroyList((yypminor->yy46)); -} - break; - case 146: /* table_options */ -{ - tfree((yypminor->yy340)); -} - break; - case 158: /* type_name */ + case 161: /* type_name */ { } break; - case 171: /* compare_op */ - case 172: /* in_op */ + case 179: /* compare_op */ + case 180: /* in_op */ { } break; - case 184: /* join_type */ + case 192: /* join_type */ { } break; - case 198: /* fill_mode */ + case 205: /* fill_mode */ { } break; - case 207: /* ordering_specification_opt */ + case 214: /* ordering_specification_opt */ { } break; - case 208: /* null_ordering_opt */ + case 215: /* null_ordering_opt */ { } @@ -1588,243 +1631,252 @@ 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[] = { - { 135, -5 }, /* (0) cmd ::= CREATE USER user_name PASS NK_STRING */ - { 135, -5 }, /* (1) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 135, -5 }, /* (2) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ - { 135, -3 }, /* (3) cmd ::= DROP USER user_name */ - { 135, -2 }, /* (4) cmd ::= SHOW USERS */ - { 135, -3 }, /* (5) cmd ::= CREATE DNODE dnode_endpoint */ - { 135, -5 }, /* (6) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ - { 135, -3 }, /* (7) cmd ::= DROP DNODE NK_INTEGER */ - { 135, -3 }, /* (8) cmd ::= DROP DNODE dnode_endpoint */ - { 135, -2 }, /* (9) cmd ::= SHOW DNODES */ - { 137, -1 }, /* (10) dnode_endpoint ::= NK_STRING */ - { 138, -1 }, /* (11) dnode_host_name ::= NK_ID */ - { 138, -1 }, /* (12) dnode_host_name ::= NK_IPTOKEN */ - { 135, -5 }, /* (13) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 135, -4 }, /* (14) cmd ::= DROP DATABASE exists_opt db_name */ - { 135, -2 }, /* (15) cmd ::= SHOW DATABASES */ - { 135, -2 }, /* (16) cmd ::= USE db_name */ - { 139, -3 }, /* (17) not_exists_opt ::= IF NOT EXISTS */ - { 139, 0 }, /* (18) not_exists_opt ::= */ - { 142, -2 }, /* (19) exists_opt ::= IF EXISTS */ - { 142, 0 }, /* (20) exists_opt ::= */ - { 141, 0 }, /* (21) db_options ::= */ - { 141, -3 }, /* (22) db_options ::= db_options BLOCKS NK_INTEGER */ - { 141, -3 }, /* (23) db_options ::= db_options CACHE NK_INTEGER */ - { 141, -3 }, /* (24) db_options ::= db_options CACHELAST NK_INTEGER */ - { 141, -3 }, /* (25) db_options ::= db_options COMP NK_INTEGER */ - { 141, -3 }, /* (26) db_options ::= db_options DAYS NK_INTEGER */ - { 141, -3 }, /* (27) db_options ::= db_options FSYNC NK_INTEGER */ - { 141, -3 }, /* (28) db_options ::= db_options MAXROWS NK_INTEGER */ - { 141, -3 }, /* (29) db_options ::= db_options MINROWS NK_INTEGER */ - { 141, -3 }, /* (30) db_options ::= db_options KEEP NK_INTEGER */ - { 141, -3 }, /* (31) db_options ::= db_options PRECISION NK_STRING */ - { 141, -3 }, /* (32) db_options ::= db_options QUORUM NK_INTEGER */ - { 141, -3 }, /* (33) db_options ::= db_options REPLICA NK_INTEGER */ - { 141, -3 }, /* (34) db_options ::= db_options TTL NK_INTEGER */ - { 141, -3 }, /* (35) db_options ::= db_options WAL NK_INTEGER */ - { 141, -3 }, /* (36) db_options ::= db_options VGROUPS NK_INTEGER */ - { 141, -3 }, /* (37) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 141, -3 }, /* (38) db_options ::= db_options STREAM_MODE NK_INTEGER */ - { 135, -9 }, /* (39) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 135, -3 }, /* (40) cmd ::= CREATE TABLE multi_create_clause */ - { 135, -9 }, /* (41) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 135, -3 }, /* (42) cmd ::= DROP TABLE multi_drop_clause */ - { 135, -4 }, /* (43) cmd ::= DROP STABLE exists_opt full_table_name */ - { 135, -2 }, /* (44) cmd ::= SHOW TABLES */ - { 135, -2 }, /* (45) cmd ::= SHOW STABLES */ - { 147, -1 }, /* (46) multi_create_clause ::= create_subtable_clause */ - { 147, -2 }, /* (47) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 150, -9 }, /* (48) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ - { 149, -1 }, /* (49) multi_drop_clause ::= drop_table_clause */ - { 149, -2 }, /* (50) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 153, -2 }, /* (51) drop_table_clause ::= exists_opt full_table_name */ - { 151, 0 }, /* (52) specific_tags_opt ::= */ - { 151, -3 }, /* (53) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - { 143, -1 }, /* (54) full_table_name ::= table_name */ - { 143, -3 }, /* (55) full_table_name ::= db_name NK_DOT table_name */ - { 144, -1 }, /* (56) column_def_list ::= column_def */ - { 144, -3 }, /* (57) column_def_list ::= column_def_list NK_COMMA column_def */ - { 156, -2 }, /* (58) column_def ::= column_name type_name */ - { 156, -4 }, /* (59) column_def ::= column_name type_name COMMENT NK_STRING */ - { 158, -1 }, /* (60) type_name ::= BOOL */ - { 158, -1 }, /* (61) type_name ::= TINYINT */ - { 158, -1 }, /* (62) type_name ::= SMALLINT */ - { 158, -1 }, /* (63) type_name ::= INT */ - { 158, -1 }, /* (64) type_name ::= INTEGER */ - { 158, -1 }, /* (65) type_name ::= BIGINT */ - { 158, -1 }, /* (66) type_name ::= FLOAT */ - { 158, -1 }, /* (67) type_name ::= DOUBLE */ - { 158, -4 }, /* (68) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 158, -1 }, /* (69) type_name ::= TIMESTAMP */ - { 158, -4 }, /* (70) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 158, -2 }, /* (71) type_name ::= TINYINT UNSIGNED */ - { 158, -2 }, /* (72) type_name ::= SMALLINT UNSIGNED */ - { 158, -2 }, /* (73) type_name ::= INT UNSIGNED */ - { 158, -2 }, /* (74) type_name ::= BIGINT UNSIGNED */ - { 158, -1 }, /* (75) type_name ::= JSON */ - { 158, -4 }, /* (76) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 158, -1 }, /* (77) type_name ::= MEDIUMBLOB */ - { 158, -1 }, /* (78) type_name ::= BLOB */ - { 158, -4 }, /* (79) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 158, -1 }, /* (80) type_name ::= DECIMAL */ - { 158, -4 }, /* (81) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 158, -6 }, /* (82) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 145, 0 }, /* (83) tags_def_opt ::= */ - { 145, -1 }, /* (84) tags_def_opt ::= tags_def */ - { 148, -4 }, /* (85) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 146, 0 }, /* (86) table_options ::= */ - { 146, -3 }, /* (87) table_options ::= table_options COMMENT NK_STRING */ - { 146, -3 }, /* (88) table_options ::= table_options KEEP NK_INTEGER */ - { 146, -3 }, /* (89) table_options ::= table_options TTL NK_INTEGER */ - { 146, -5 }, /* (90) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 154, -1 }, /* (91) col_name_list ::= col_name */ - { 154, -3 }, /* (92) col_name_list ::= col_name_list NK_COMMA col_name */ - { 159, -1 }, /* (93) col_name ::= column_name */ - { 135, -2 }, /* (94) cmd ::= SHOW VGROUPS */ - { 135, -4 }, /* (95) cmd ::= SHOW db_name NK_DOT VGROUPS */ - { 135, -2 }, /* (96) cmd ::= SHOW MNODES */ - { 135, -1 }, /* (97) cmd ::= query_expression */ - { 161, -1 }, /* (98) literal ::= NK_INTEGER */ - { 161, -1 }, /* (99) literal ::= NK_FLOAT */ - { 161, -1 }, /* (100) literal ::= NK_STRING */ - { 161, -1 }, /* (101) literal ::= NK_BOOL */ - { 161, -2 }, /* (102) literal ::= TIMESTAMP NK_STRING */ - { 161, -1 }, /* (103) literal ::= duration_literal */ - { 162, -1 }, /* (104) duration_literal ::= NK_VARIABLE */ - { 152, -1 }, /* (105) literal_list ::= literal */ - { 152, -3 }, /* (106) literal_list ::= literal_list NK_COMMA literal */ - { 140, -1 }, /* (107) db_name ::= NK_ID */ - { 155, -1 }, /* (108) table_name ::= NK_ID */ - { 157, -1 }, /* (109) column_name ::= NK_ID */ - { 163, -1 }, /* (110) function_name ::= NK_ID */ - { 164, -1 }, /* (111) table_alias ::= NK_ID */ - { 165, -1 }, /* (112) column_alias ::= NK_ID */ - { 136, -1 }, /* (113) user_name ::= NK_ID */ - { 166, -1 }, /* (114) expression ::= literal */ - { 166, -1 }, /* (115) expression ::= column_reference */ - { 166, -4 }, /* (116) expression ::= function_name NK_LP expression_list NK_RP */ - { 166, -4 }, /* (117) expression ::= function_name NK_LP NK_STAR NK_RP */ - { 166, -1 }, /* (118) expression ::= subquery */ - { 166, -3 }, /* (119) expression ::= NK_LP expression NK_RP */ - { 166, -2 }, /* (120) expression ::= NK_PLUS expression */ - { 166, -2 }, /* (121) expression ::= NK_MINUS expression */ - { 166, -3 }, /* (122) expression ::= expression NK_PLUS expression */ - { 166, -3 }, /* (123) expression ::= expression NK_MINUS expression */ - { 166, -3 }, /* (124) expression ::= expression NK_STAR expression */ - { 166, -3 }, /* (125) expression ::= expression NK_SLASH expression */ - { 166, -3 }, /* (126) expression ::= expression NK_REM expression */ - { 168, -1 }, /* (127) expression_list ::= expression */ - { 168, -3 }, /* (128) expression_list ::= expression_list NK_COMMA expression */ - { 167, -1 }, /* (129) column_reference ::= column_name */ - { 167, -3 }, /* (130) column_reference ::= table_name NK_DOT column_name */ - { 170, -3 }, /* (131) predicate ::= expression compare_op expression */ - { 170, -5 }, /* (132) predicate ::= expression BETWEEN expression AND expression */ - { 170, -6 }, /* (133) predicate ::= expression NOT BETWEEN expression AND expression */ - { 170, -3 }, /* (134) predicate ::= expression IS NULL */ - { 170, -4 }, /* (135) predicate ::= expression IS NOT NULL */ - { 170, -3 }, /* (136) predicate ::= expression in_op in_predicate_value */ - { 171, -1 }, /* (137) compare_op ::= NK_LT */ - { 171, -1 }, /* (138) compare_op ::= NK_GT */ - { 171, -1 }, /* (139) compare_op ::= NK_LE */ - { 171, -1 }, /* (140) compare_op ::= NK_GE */ - { 171, -1 }, /* (141) compare_op ::= NK_NE */ - { 171, -1 }, /* (142) compare_op ::= NK_EQ */ - { 171, -1 }, /* (143) compare_op ::= LIKE */ - { 171, -2 }, /* (144) compare_op ::= NOT LIKE */ - { 171, -1 }, /* (145) compare_op ::= MATCH */ - { 171, -1 }, /* (146) compare_op ::= NMATCH */ - { 172, -1 }, /* (147) in_op ::= IN */ - { 172, -2 }, /* (148) in_op ::= NOT IN */ - { 173, -3 }, /* (149) in_predicate_value ::= NK_LP expression_list NK_RP */ - { 174, -1 }, /* (150) boolean_value_expression ::= boolean_primary */ - { 174, -2 }, /* (151) boolean_value_expression ::= NOT boolean_primary */ - { 174, -3 }, /* (152) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 174, -3 }, /* (153) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 175, -1 }, /* (154) boolean_primary ::= predicate */ - { 175, -3 }, /* (155) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 176, -1 }, /* (156) common_expression ::= expression */ - { 176, -1 }, /* (157) common_expression ::= boolean_value_expression */ - { 177, -2 }, /* (158) from_clause ::= FROM table_reference_list */ - { 178, -1 }, /* (159) table_reference_list ::= table_reference */ - { 178, -3 }, /* (160) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 179, -1 }, /* (161) table_reference ::= table_primary */ - { 179, -1 }, /* (162) table_reference ::= joined_table */ - { 180, -2 }, /* (163) table_primary ::= table_name alias_opt */ - { 180, -4 }, /* (164) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 180, -2 }, /* (165) table_primary ::= subquery alias_opt */ - { 180, -1 }, /* (166) table_primary ::= parenthesized_joined_table */ - { 182, 0 }, /* (167) alias_opt ::= */ - { 182, -1 }, /* (168) alias_opt ::= table_alias */ - { 182, -2 }, /* (169) alias_opt ::= AS table_alias */ - { 183, -3 }, /* (170) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 183, -3 }, /* (171) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 181, -6 }, /* (172) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 184, 0 }, /* (173) join_type ::= */ - { 184, -1 }, /* (174) join_type ::= INNER */ - { 186, -9 }, /* (175) 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 */ - { 187, 0 }, /* (176) set_quantifier_opt ::= */ - { 187, -1 }, /* (177) set_quantifier_opt ::= DISTINCT */ - { 187, -1 }, /* (178) set_quantifier_opt ::= ALL */ - { 188, -1 }, /* (179) select_list ::= NK_STAR */ - { 188, -1 }, /* (180) select_list ::= select_sublist */ - { 194, -1 }, /* (181) select_sublist ::= select_item */ - { 194, -3 }, /* (182) select_sublist ::= select_sublist NK_COMMA select_item */ - { 195, -1 }, /* (183) select_item ::= common_expression */ - { 195, -2 }, /* (184) select_item ::= common_expression column_alias */ - { 195, -3 }, /* (185) select_item ::= common_expression AS column_alias */ - { 195, -3 }, /* (186) select_item ::= table_name NK_DOT NK_STAR */ - { 189, 0 }, /* (187) where_clause_opt ::= */ - { 189, -2 }, /* (188) where_clause_opt ::= WHERE search_condition */ - { 190, 0 }, /* (189) partition_by_clause_opt ::= */ - { 190, -3 }, /* (190) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 191, 0 }, /* (191) twindow_clause_opt ::= */ - { 191, -6 }, /* (192) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ - { 191, -4 }, /* (193) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ - { 191, -6 }, /* (194) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 191, -8 }, /* (195) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 196, 0 }, /* (196) sliding_opt ::= */ - { 196, -4 }, /* (197) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 197, 0 }, /* (198) fill_opt ::= */ - { 197, -4 }, /* (199) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 197, -6 }, /* (200) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 198, -1 }, /* (201) fill_mode ::= NONE */ - { 198, -1 }, /* (202) fill_mode ::= PREV */ - { 198, -1 }, /* (203) fill_mode ::= NULL */ - { 198, -1 }, /* (204) fill_mode ::= LINEAR */ - { 198, -1 }, /* (205) fill_mode ::= NEXT */ - { 192, 0 }, /* (206) group_by_clause_opt ::= */ - { 192, -3 }, /* (207) group_by_clause_opt ::= GROUP BY group_by_list */ - { 199, -1 }, /* (208) group_by_list ::= expression */ - { 199, -3 }, /* (209) group_by_list ::= group_by_list NK_COMMA expression */ - { 193, 0 }, /* (210) having_clause_opt ::= */ - { 193, -2 }, /* (211) having_clause_opt ::= HAVING search_condition */ - { 160, -4 }, /* (212) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 200, -1 }, /* (213) query_expression_body ::= query_primary */ - { 200, -4 }, /* (214) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 204, -1 }, /* (215) query_primary ::= query_specification */ - { 201, 0 }, /* (216) order_by_clause_opt ::= */ - { 201, -3 }, /* (217) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 202, 0 }, /* (218) slimit_clause_opt ::= */ - { 202, -2 }, /* (219) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 202, -4 }, /* (220) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 202, -4 }, /* (221) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 203, 0 }, /* (222) limit_clause_opt ::= */ - { 203, -2 }, /* (223) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 203, -4 }, /* (224) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 203, -4 }, /* (225) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 169, -3 }, /* (226) subquery ::= NK_LP query_expression NK_RP */ - { 185, -1 }, /* (227) search_condition ::= common_expression */ - { 205, -1 }, /* (228) sort_specification_list ::= sort_specification */ - { 205, -3 }, /* (229) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 206, -3 }, /* (230) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 207, 0 }, /* (231) ordering_specification_opt ::= */ - { 207, -1 }, /* (232) ordering_specification_opt ::= ASC */ - { 207, -1 }, /* (233) ordering_specification_opt ::= DESC */ - { 208, 0 }, /* (234) null_ordering_opt ::= */ - { 208, -2 }, /* (235) null_ordering_opt ::= NULLS FIRST */ - { 208, -2 }, /* (236) null_ordering_opt ::= NULLS LAST */ + { 138, -5 }, /* (0) cmd ::= CREATE USER user_name PASS NK_STRING */ + { 138, -5 }, /* (1) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 138, -5 }, /* (2) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ + { 138, -3 }, /* (3) cmd ::= DROP USER user_name */ + { 138, -2 }, /* (4) cmd ::= SHOW USERS */ + { 138, -3 }, /* (5) cmd ::= CREATE DNODE dnode_endpoint */ + { 138, -5 }, /* (6) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ + { 138, -3 }, /* (7) cmd ::= DROP DNODE NK_INTEGER */ + { 138, -3 }, /* (8) cmd ::= DROP DNODE dnode_endpoint */ + { 138, -2 }, /* (9) cmd ::= SHOW DNODES */ + { 140, -1 }, /* (10) dnode_endpoint ::= NK_STRING */ + { 141, -1 }, /* (11) dnode_host_name ::= NK_ID */ + { 141, -1 }, /* (12) dnode_host_name ::= NK_IPTOKEN */ + { 138, -5 }, /* (13) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 138, -4 }, /* (14) cmd ::= DROP DATABASE exists_opt db_name */ + { 138, -2 }, /* (15) cmd ::= SHOW DATABASES */ + { 138, -2 }, /* (16) cmd ::= USE db_name */ + { 142, -3 }, /* (17) not_exists_opt ::= IF NOT EXISTS */ + { 142, 0 }, /* (18) not_exists_opt ::= */ + { 145, -2 }, /* (19) exists_opt ::= IF EXISTS */ + { 145, 0 }, /* (20) exists_opt ::= */ + { 144, 0 }, /* (21) db_options ::= */ + { 144, -3 }, /* (22) db_options ::= db_options BLOCKS NK_INTEGER */ + { 144, -3 }, /* (23) db_options ::= db_options CACHE NK_INTEGER */ + { 144, -3 }, /* (24) db_options ::= db_options CACHELAST NK_INTEGER */ + { 144, -3 }, /* (25) db_options ::= db_options COMP NK_INTEGER */ + { 144, -3 }, /* (26) db_options ::= db_options DAYS NK_INTEGER */ + { 144, -3 }, /* (27) db_options ::= db_options FSYNC NK_INTEGER */ + { 144, -3 }, /* (28) db_options ::= db_options MAXROWS NK_INTEGER */ + { 144, -3 }, /* (29) db_options ::= db_options MINROWS NK_INTEGER */ + { 144, -3 }, /* (30) db_options ::= db_options KEEP NK_INTEGER */ + { 144, -3 }, /* (31) db_options ::= db_options PRECISION NK_STRING */ + { 144, -3 }, /* (32) db_options ::= db_options QUORUM NK_INTEGER */ + { 144, -3 }, /* (33) db_options ::= db_options REPLICA NK_INTEGER */ + { 144, -3 }, /* (34) db_options ::= db_options TTL NK_INTEGER */ + { 144, -3 }, /* (35) db_options ::= db_options WAL NK_INTEGER */ + { 144, -3 }, /* (36) db_options ::= db_options VGROUPS NK_INTEGER */ + { 144, -3 }, /* (37) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 144, -3 }, /* (38) db_options ::= db_options STREAM_MODE NK_INTEGER */ + { 138, -9 }, /* (39) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 138, -3 }, /* (40) cmd ::= CREATE TABLE multi_create_clause */ + { 138, -9 }, /* (41) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 138, -3 }, /* (42) cmd ::= DROP TABLE multi_drop_clause */ + { 138, -4 }, /* (43) cmd ::= DROP STABLE exists_opt full_table_name */ + { 138, -2 }, /* (44) cmd ::= SHOW TABLES */ + { 138, -2 }, /* (45) cmd ::= SHOW STABLES */ + { 150, -1 }, /* (46) multi_create_clause ::= create_subtable_clause */ + { 150, -2 }, /* (47) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 153, -9 }, /* (48) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ + { 152, -1 }, /* (49) multi_drop_clause ::= drop_table_clause */ + { 152, -2 }, /* (50) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 156, -2 }, /* (51) drop_table_clause ::= exists_opt full_table_name */ + { 154, 0 }, /* (52) specific_tags_opt ::= */ + { 154, -3 }, /* (53) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + { 146, -1 }, /* (54) full_table_name ::= table_name */ + { 146, -3 }, /* (55) full_table_name ::= db_name NK_DOT table_name */ + { 147, -1 }, /* (56) column_def_list ::= column_def */ + { 147, -3 }, /* (57) column_def_list ::= column_def_list NK_COMMA column_def */ + { 159, -2 }, /* (58) column_def ::= column_name type_name */ + { 159, -4 }, /* (59) column_def ::= column_name type_name COMMENT NK_STRING */ + { 161, -1 }, /* (60) type_name ::= BOOL */ + { 161, -1 }, /* (61) type_name ::= TINYINT */ + { 161, -1 }, /* (62) type_name ::= SMALLINT */ + { 161, -1 }, /* (63) type_name ::= INT */ + { 161, -1 }, /* (64) type_name ::= INTEGER */ + { 161, -1 }, /* (65) type_name ::= BIGINT */ + { 161, -1 }, /* (66) type_name ::= FLOAT */ + { 161, -1 }, /* (67) type_name ::= DOUBLE */ + { 161, -4 }, /* (68) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 161, -1 }, /* (69) type_name ::= TIMESTAMP */ + { 161, -4 }, /* (70) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 161, -2 }, /* (71) type_name ::= TINYINT UNSIGNED */ + { 161, -2 }, /* (72) type_name ::= SMALLINT UNSIGNED */ + { 161, -2 }, /* (73) type_name ::= INT UNSIGNED */ + { 161, -2 }, /* (74) type_name ::= BIGINT UNSIGNED */ + { 161, -1 }, /* (75) type_name ::= JSON */ + { 161, -4 }, /* (76) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 161, -1 }, /* (77) type_name ::= MEDIUMBLOB */ + { 161, -1 }, /* (78) type_name ::= BLOB */ + { 161, -4 }, /* (79) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 161, -1 }, /* (80) type_name ::= DECIMAL */ + { 161, -4 }, /* (81) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 161, -6 }, /* (82) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 148, 0 }, /* (83) tags_def_opt ::= */ + { 148, -1 }, /* (84) tags_def_opt ::= tags_def */ + { 151, -4 }, /* (85) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 149, 0 }, /* (86) table_options ::= */ + { 149, -3 }, /* (87) table_options ::= table_options COMMENT NK_STRING */ + { 149, -3 }, /* (88) table_options ::= table_options KEEP NK_INTEGER */ + { 149, -3 }, /* (89) table_options ::= table_options TTL NK_INTEGER */ + { 149, -5 }, /* (90) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 157, -1 }, /* (91) col_name_list ::= col_name */ + { 157, -3 }, /* (92) col_name_list ::= col_name_list NK_COMMA col_name */ + { 162, -1 }, /* (93) col_name ::= column_name */ + { 138, -7 }, /* (94) cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ + { 138, -9 }, /* (95) cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ + { 164, 0 }, /* (96) index_options ::= */ + { 164, -9 }, /* (97) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ + { 164, -11 }, /* (98) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ + { 165, -1 }, /* (99) func_list ::= func */ + { 165, -3 }, /* (100) func_list ::= func_list NK_COMMA func */ + { 168, -4 }, /* (101) func ::= function_name NK_LP expression_list NK_RP */ + { 138, -2 }, /* (102) cmd ::= SHOW VGROUPS */ + { 138, -4 }, /* (103) cmd ::= SHOW db_name NK_DOT VGROUPS */ + { 138, -2 }, /* (104) cmd ::= SHOW MNODES */ + { 138, -1 }, /* (105) cmd ::= query_expression */ + { 172, -1 }, /* (106) literal ::= NK_INTEGER */ + { 172, -1 }, /* (107) literal ::= NK_FLOAT */ + { 172, -1 }, /* (108) literal ::= NK_STRING */ + { 172, -1 }, /* (109) literal ::= NK_BOOL */ + { 172, -2 }, /* (110) literal ::= TIMESTAMP NK_STRING */ + { 172, -1 }, /* (111) literal ::= duration_literal */ + { 166, -1 }, /* (112) duration_literal ::= NK_VARIABLE */ + { 155, -1 }, /* (113) literal_list ::= literal */ + { 155, -3 }, /* (114) literal_list ::= literal_list NK_COMMA literal */ + { 143, -1 }, /* (115) db_name ::= NK_ID */ + { 158, -1 }, /* (116) table_name ::= NK_ID */ + { 160, -1 }, /* (117) column_name ::= NK_ID */ + { 169, -1 }, /* (118) function_name ::= NK_ID */ + { 173, -1 }, /* (119) table_alias ::= NK_ID */ + { 174, -1 }, /* (120) column_alias ::= NK_ID */ + { 139, -1 }, /* (121) user_name ::= NK_ID */ + { 163, -1 }, /* (122) index_name ::= NK_ID */ + { 175, -1 }, /* (123) expression ::= literal */ + { 175, -1 }, /* (124) expression ::= column_reference */ + { 175, -4 }, /* (125) expression ::= function_name NK_LP expression_list NK_RP */ + { 175, -4 }, /* (126) expression ::= function_name NK_LP NK_STAR NK_RP */ + { 175, -1 }, /* (127) expression ::= subquery */ + { 175, -3 }, /* (128) expression ::= NK_LP expression NK_RP */ + { 175, -2 }, /* (129) expression ::= NK_PLUS expression */ + { 175, -2 }, /* (130) expression ::= NK_MINUS expression */ + { 175, -3 }, /* (131) expression ::= expression NK_PLUS expression */ + { 175, -3 }, /* (132) expression ::= expression NK_MINUS expression */ + { 175, -3 }, /* (133) expression ::= expression NK_STAR expression */ + { 175, -3 }, /* (134) expression ::= expression NK_SLASH expression */ + { 175, -3 }, /* (135) expression ::= expression NK_REM expression */ + { 170, -1 }, /* (136) expression_list ::= expression */ + { 170, -3 }, /* (137) expression_list ::= expression_list NK_COMMA expression */ + { 176, -1 }, /* (138) column_reference ::= column_name */ + { 176, -3 }, /* (139) column_reference ::= table_name NK_DOT column_name */ + { 178, -3 }, /* (140) predicate ::= expression compare_op expression */ + { 178, -5 }, /* (141) predicate ::= expression BETWEEN expression AND expression */ + { 178, -6 }, /* (142) predicate ::= expression NOT BETWEEN expression AND expression */ + { 178, -3 }, /* (143) predicate ::= expression IS NULL */ + { 178, -4 }, /* (144) predicate ::= expression IS NOT NULL */ + { 178, -3 }, /* (145) predicate ::= expression in_op in_predicate_value */ + { 179, -1 }, /* (146) compare_op ::= NK_LT */ + { 179, -1 }, /* (147) compare_op ::= NK_GT */ + { 179, -1 }, /* (148) compare_op ::= NK_LE */ + { 179, -1 }, /* (149) compare_op ::= NK_GE */ + { 179, -1 }, /* (150) compare_op ::= NK_NE */ + { 179, -1 }, /* (151) compare_op ::= NK_EQ */ + { 179, -1 }, /* (152) compare_op ::= LIKE */ + { 179, -2 }, /* (153) compare_op ::= NOT LIKE */ + { 179, -1 }, /* (154) compare_op ::= MATCH */ + { 179, -1 }, /* (155) compare_op ::= NMATCH */ + { 180, -1 }, /* (156) in_op ::= IN */ + { 180, -2 }, /* (157) in_op ::= NOT IN */ + { 181, -3 }, /* (158) in_predicate_value ::= NK_LP expression_list NK_RP */ + { 182, -1 }, /* (159) boolean_value_expression ::= boolean_primary */ + { 182, -2 }, /* (160) boolean_value_expression ::= NOT boolean_primary */ + { 182, -3 }, /* (161) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 182, -3 }, /* (162) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 183, -1 }, /* (163) boolean_primary ::= predicate */ + { 183, -3 }, /* (164) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 184, -1 }, /* (165) common_expression ::= expression */ + { 184, -1 }, /* (166) common_expression ::= boolean_value_expression */ + { 185, -2 }, /* (167) from_clause ::= FROM table_reference_list */ + { 186, -1 }, /* (168) table_reference_list ::= table_reference */ + { 186, -3 }, /* (169) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 187, -1 }, /* (170) table_reference ::= table_primary */ + { 187, -1 }, /* (171) table_reference ::= joined_table */ + { 188, -2 }, /* (172) table_primary ::= table_name alias_opt */ + { 188, -4 }, /* (173) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 188, -2 }, /* (174) table_primary ::= subquery alias_opt */ + { 188, -1 }, /* (175) table_primary ::= parenthesized_joined_table */ + { 190, 0 }, /* (176) alias_opt ::= */ + { 190, -1 }, /* (177) alias_opt ::= table_alias */ + { 190, -2 }, /* (178) alias_opt ::= AS table_alias */ + { 191, -3 }, /* (179) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 191, -3 }, /* (180) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 189, -6 }, /* (181) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 192, 0 }, /* (182) join_type ::= */ + { 192, -1 }, /* (183) join_type ::= INNER */ + { 194, -9 }, /* (184) 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 */ + { 195, 0 }, /* (185) set_quantifier_opt ::= */ + { 195, -1 }, /* (186) set_quantifier_opt ::= DISTINCT */ + { 195, -1 }, /* (187) set_quantifier_opt ::= ALL */ + { 196, -1 }, /* (188) select_list ::= NK_STAR */ + { 196, -1 }, /* (189) select_list ::= select_sublist */ + { 202, -1 }, /* (190) select_sublist ::= select_item */ + { 202, -3 }, /* (191) select_sublist ::= select_sublist NK_COMMA select_item */ + { 203, -1 }, /* (192) select_item ::= common_expression */ + { 203, -2 }, /* (193) select_item ::= common_expression column_alias */ + { 203, -3 }, /* (194) select_item ::= common_expression AS column_alias */ + { 203, -3 }, /* (195) select_item ::= table_name NK_DOT NK_STAR */ + { 197, 0 }, /* (196) where_clause_opt ::= */ + { 197, -2 }, /* (197) where_clause_opt ::= WHERE search_condition */ + { 198, 0 }, /* (198) partition_by_clause_opt ::= */ + { 198, -3 }, /* (199) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 199, 0 }, /* (200) twindow_clause_opt ::= */ + { 199, -6 }, /* (201) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ + { 199, -4 }, /* (202) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ + { 199, -6 }, /* (203) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 199, -8 }, /* (204) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 167, 0 }, /* (205) sliding_opt ::= */ + { 167, -4 }, /* (206) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 204, 0 }, /* (207) fill_opt ::= */ + { 204, -4 }, /* (208) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 204, -6 }, /* (209) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 205, -1 }, /* (210) fill_mode ::= NONE */ + { 205, -1 }, /* (211) fill_mode ::= PREV */ + { 205, -1 }, /* (212) fill_mode ::= NULL */ + { 205, -1 }, /* (213) fill_mode ::= LINEAR */ + { 205, -1 }, /* (214) fill_mode ::= NEXT */ + { 200, 0 }, /* (215) group_by_clause_opt ::= */ + { 200, -3 }, /* (216) group_by_clause_opt ::= GROUP BY group_by_list */ + { 206, -1 }, /* (217) group_by_list ::= expression */ + { 206, -3 }, /* (218) group_by_list ::= group_by_list NK_COMMA expression */ + { 201, 0 }, /* (219) having_clause_opt ::= */ + { 201, -2 }, /* (220) having_clause_opt ::= HAVING search_condition */ + { 171, -4 }, /* (221) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 207, -1 }, /* (222) query_expression_body ::= query_primary */ + { 207, -4 }, /* (223) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 211, -1 }, /* (224) query_primary ::= query_specification */ + { 208, 0 }, /* (225) order_by_clause_opt ::= */ + { 208, -3 }, /* (226) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 209, 0 }, /* (227) slimit_clause_opt ::= */ + { 209, -2 }, /* (228) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 209, -4 }, /* (229) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 209, -4 }, /* (230) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 210, 0 }, /* (231) limit_clause_opt ::= */ + { 210, -2 }, /* (232) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 210, -4 }, /* (233) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 210, -4 }, /* (234) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 177, -3 }, /* (235) subquery ::= NK_LP query_expression NK_RP */ + { 193, -1 }, /* (236) search_condition ::= common_expression */ + { 212, -1 }, /* (237) sort_specification_list ::= sort_specification */ + { 212, -3 }, /* (238) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 213, -3 }, /* (239) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 214, 0 }, /* (240) ordering_specification_opt ::= */ + { 214, -1 }, /* (241) ordering_specification_opt ::= ASC */ + { 214, -1 }, /* (242) ordering_specification_opt ::= DESC */ + { 215, 0 }, /* (243) null_ordering_opt ::= */ + { 215, -2 }, /* (244) null_ordering_opt ::= NULLS FIRST */ + { 215, -2 }, /* (245) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -1912,31 +1964,31 @@ static YYACTIONTYPE yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0);} break; case 1: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy129, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy209, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0);} break; case 2: /* cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy129, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy209, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0);} break; case 3: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy129); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy209); } break; case 4: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL); } break; case 5: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy129, NULL);} +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy209, NULL);} break; case 6: /* cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0);} break; case 7: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0);} break; case 8: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy129);} +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy209);} break; case 9: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL); } @@ -1944,122 +1996,123 @@ static YYACTIONTYPE yy_reduce( case 10: /* dnode_endpoint ::= NK_STRING */ case 11: /* dnode_host_name ::= NK_ID */ yytestcase(yyruleno==11); case 12: /* dnode_host_name ::= NK_IPTOKEN */ yytestcase(yyruleno==12); - case 107: /* db_name ::= NK_ID */ yytestcase(yyruleno==107); - case 108: /* table_name ::= NK_ID */ yytestcase(yyruleno==108); - case 109: /* column_name ::= NK_ID */ yytestcase(yyruleno==109); - case 110: /* function_name ::= NK_ID */ yytestcase(yyruleno==110); - case 111: /* table_alias ::= NK_ID */ yytestcase(yyruleno==111); - case 112: /* column_alias ::= NK_ID */ yytestcase(yyruleno==112); - case 113: /* user_name ::= NK_ID */ yytestcase(yyruleno==113); -{ yylhsminor.yy129 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy129 = yylhsminor.yy129; + case 115: /* db_name ::= NK_ID */ yytestcase(yyruleno==115); + case 116: /* table_name ::= NK_ID */ yytestcase(yyruleno==116); + case 117: /* column_name ::= NK_ID */ yytestcase(yyruleno==117); + case 118: /* function_name ::= NK_ID */ yytestcase(yyruleno==118); + case 119: /* table_alias ::= NK_ID */ yytestcase(yyruleno==119); + case 120: /* column_alias ::= NK_ID */ yytestcase(yyruleno==120); + case 121: /* user_name ::= NK_ID */ yytestcase(yyruleno==121); + case 122: /* index_name ::= NK_ID */ yytestcase(yyruleno==122); +{ yylhsminor.yy209 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy209 = yylhsminor.yy209; break; case 13: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy185, &yymsp[-1].minor.yy129, yymsp[0].minor.yy391);} +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy281, &yymsp[-1].minor.yy209, yymsp[0].minor.yy344);} break; case 14: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy185, &yymsp[0].minor.yy129); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy281, &yymsp[0].minor.yy209); } break; case 15: /* cmd ::= SHOW DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL); } break; case 16: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy129);} +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy209);} break; case 17: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy185 = true; } +{ yymsp[-2].minor.yy281 = true; } break; case 18: /* not_exists_opt ::= */ case 20: /* exists_opt ::= */ yytestcase(yyruleno==20); - case 176: /* set_quantifier_opt ::= */ yytestcase(yyruleno==176); -{ yymsp[1].minor.yy185 = false; } + case 185: /* set_quantifier_opt ::= */ yytestcase(yyruleno==185); +{ yymsp[1].minor.yy281 = false; } break; case 19: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy185 = true; } +{ yymsp[-1].minor.yy281 = true; } break; case 21: /* db_options ::= */ -{ yymsp[1].minor.yy391 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy344 = createDefaultDatabaseOptions(pCxt); } break; case 22: /* db_options ::= db_options BLOCKS NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 23: /* db_options ::= db_options CACHE NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 24: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 25: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 26: /* db_options ::= db_options DAYS NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 27: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 28: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 29: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 30: /* db_options ::= db_options KEEP NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_KEEP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 31: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 32: /* db_options ::= db_options QUORUM NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 33: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 34: /* db_options ::= db_options TTL NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 35: /* db_options ::= db_options WAL NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 36: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 37: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_SINGLESTABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_SINGLESTABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 38: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_STREAMMODE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_STREAMMODE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 39: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ case 41: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==41); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy185, yymsp[-5].minor.yy256, yymsp[-3].minor.yy46, yymsp[-1].minor.yy46, yymsp[0].minor.yy340);} +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy281, yymsp[-5].minor.yy344, yymsp[-3].minor.yy280, yymsp[-1].minor.yy280, yymsp[0].minor.yy344);} break; case 40: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy46);} +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy280);} break; case 42: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy46); } +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy280); } break; case 43: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy185, yymsp[0].minor.yy256); } +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy281, yymsp[0].minor.yy344); } break; case 44: /* cmd ::= SHOW TABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, NULL); } @@ -2071,589 +2124,608 @@ static YYACTIONTYPE yy_reduce( case 49: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==49); case 56: /* column_def_list ::= column_def */ yytestcase(yyruleno==56); case 91: /* col_name_list ::= col_name */ yytestcase(yyruleno==91); - case 181: /* select_sublist ::= select_item */ yytestcase(yyruleno==181); - case 228: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==228); -{ yylhsminor.yy46 = createNodeList(pCxt, yymsp[0].minor.yy256); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 99: /* func_list ::= func */ yytestcase(yyruleno==99); + case 190: /* select_sublist ::= select_item */ yytestcase(yyruleno==190); + case 237: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==237); +{ yylhsminor.yy280 = createNodeList(pCxt, yymsp[0].minor.yy344); } + yymsp[0].minor.yy280 = yylhsminor.yy280; break; case 47: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ case 50: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==50); -{ yylhsminor.yy46 = addNodeToList(pCxt, yymsp[-1].minor.yy46, yymsp[0].minor.yy256); } - yymsp[-1].minor.yy46 = yylhsminor.yy46; +{ yylhsminor.yy280 = addNodeToList(pCxt, yymsp[-1].minor.yy280, yymsp[0].minor.yy344); } + yymsp[-1].minor.yy280 = yylhsminor.yy280; break; case 48: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ -{ yylhsminor.yy256 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy185, yymsp[-7].minor.yy256, yymsp[-5].minor.yy256, yymsp[-4].minor.yy46, yymsp[-1].minor.yy46); } - yymsp[-8].minor.yy256 = yylhsminor.yy256; +{ yylhsminor.yy344 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy281, yymsp[-7].minor.yy344, yymsp[-5].minor.yy344, yymsp[-4].minor.yy280, yymsp[-1].minor.yy280); } + yymsp[-8].minor.yy344 = yylhsminor.yy344; break; case 51: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy256 = createDropTableClause(pCxt, yymsp[-1].minor.yy185, yymsp[0].minor.yy256); } - yymsp[-1].minor.yy256 = yylhsminor.yy256; +{ yylhsminor.yy344 = createDropTableClause(pCxt, yymsp[-1].minor.yy281, yymsp[0].minor.yy344); } + yymsp[-1].minor.yy344 = yylhsminor.yy344; break; case 52: /* specific_tags_opt ::= */ case 83: /* tags_def_opt ::= */ yytestcase(yyruleno==83); - case 189: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==189); - case 206: /* group_by_clause_opt ::= */ yytestcase(yyruleno==206); - case 216: /* order_by_clause_opt ::= */ yytestcase(yyruleno==216); -{ yymsp[1].minor.yy46 = NULL; } + case 198: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==198); + case 215: /* group_by_clause_opt ::= */ yytestcase(yyruleno==215); + case 225: /* order_by_clause_opt ::= */ yytestcase(yyruleno==225); +{ yymsp[1].minor.yy280 = NULL; } break; case 53: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy46 = yymsp[-1].minor.yy46; } +{ yymsp[-2].minor.yy280 = yymsp[-1].minor.yy280; } break; case 54: /* full_table_name ::= table_name */ -{ yylhsminor.yy256 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy129, NULL); } - yymsp[0].minor.yy256 = yylhsminor.yy256; +{ yylhsminor.yy344 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy209, NULL); } + yymsp[0].minor.yy344 = yylhsminor.yy344; break; case 55: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy256 = createRealTableNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129, NULL); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; +{ yylhsminor.yy344 = createRealTableNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209, NULL); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 57: /* column_def_list ::= column_def_list NK_COMMA column_def */ case 92: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==92); - case 182: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==182); - case 229: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==229); -{ yylhsminor.yy46 = addNodeToList(pCxt, yymsp[-2].minor.yy46, yymsp[0].minor.yy256); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + case 100: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==100); + case 191: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==191); + case 238: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==238); +{ yylhsminor.yy280 = addNodeToList(pCxt, yymsp[-2].minor.yy280, yymsp[0].minor.yy344); } + yymsp[-2].minor.yy280 = yylhsminor.yy280; break; case 58: /* column_def ::= column_name type_name */ -{ yylhsminor.yy256 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy129, yymsp[0].minor.yy70, NULL); } - yymsp[-1].minor.yy256 = yylhsminor.yy256; +{ yylhsminor.yy344 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy209, yymsp[0].minor.yy304, NULL); } + yymsp[-1].minor.yy344 = yylhsminor.yy344; break; case 59: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy256 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-2].minor.yy70, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy256 = yylhsminor.yy256; +{ yylhsminor.yy344 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-2].minor.yy304, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy344 = yylhsminor.yy344; break; case 60: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_BOOL); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_BOOL); } break; case 61: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_TINYINT); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; case 62: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; case 63: /* type_name ::= INT */ case 64: /* type_name ::= INTEGER */ yytestcase(yyruleno==64); -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_INT); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_INT); } break; case 65: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_BIGINT); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; case 66: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_FLOAT); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; case 67: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; case 68: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy70 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; case 69: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; case 70: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy70 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; case 71: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy70 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; case 72: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy70 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; case 73: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy70 = createDataType(TSDB_DATA_TYPE_UINT); } +{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_UINT); } break; case 74: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy70 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; case 75: /* type_name ::= JSON */ -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_JSON); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_JSON); } break; case 76: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy70 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; case 77: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; case 78: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_BLOB); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_BLOB); } break; case 79: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy70 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; case 80: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 81: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy70 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-3].minor.yy304 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 82: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy70 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-5].minor.yy304 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 84: /* tags_def_opt ::= tags_def */ - case 180: /* select_list ::= select_sublist */ yytestcase(yyruleno==180); -{ yylhsminor.yy46 = yymsp[0].minor.yy46; } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 189: /* select_list ::= select_sublist */ yytestcase(yyruleno==189); +{ yylhsminor.yy280 = yymsp[0].minor.yy280; } + yymsp[0].minor.yy280 = yylhsminor.yy280; break; case 85: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy46 = yymsp[-1].minor.yy46; } +{ yymsp[-3].minor.yy280 = yymsp[-1].minor.yy280; } break; case 86: /* table_options ::= */ -{ yymsp[1].minor.yy340 = createDefaultTableOptions(pCxt);} +{ yymsp[1].minor.yy344 = createDefaultTableOptions(pCxt);} break; case 87: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy340 = setTableOption(pCxt, yymsp[-2].minor.yy340, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy340 = yylhsminor.yy340; +{ yylhsminor.yy344 = setTableOption(pCxt, yymsp[-2].minor.yy344, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 88: /* table_options ::= table_options KEEP NK_INTEGER */ -{ yylhsminor.yy340 = setTableOption(pCxt, yymsp[-2].minor.yy340, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy340 = yylhsminor.yy340; +{ yylhsminor.yy344 = setTableOption(pCxt, yymsp[-2].minor.yy344, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 89: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy340 = setTableOption(pCxt, yymsp[-2].minor.yy340, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy340 = yylhsminor.yy340; +{ yylhsminor.yy344 = setTableOption(pCxt, yymsp[-2].minor.yy344, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 90: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy340 = setTableSmaOption(pCxt, yymsp[-4].minor.yy340, yymsp[-1].minor.yy46); } - yymsp[-4].minor.yy340 = yylhsminor.yy340; +{ yylhsminor.yy344 = setTableSmaOption(pCxt, yymsp[-4].minor.yy344, yymsp[-1].minor.yy280); } + yymsp[-4].minor.yy344 = yylhsminor.yy344; break; case 93: /* col_name ::= column_name */ -{ yylhsminor.yy256 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy129); } - yymsp[0].minor.yy256 = yylhsminor.yy256; +{ yylhsminor.yy344 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy209); } + yymsp[0].minor.yy344 = yylhsminor.yy344; break; - case 94: /* cmd ::= SHOW VGROUPS */ + case 94: /* cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &yymsp[-3].minor.yy209, &yymsp[-1].minor.yy209, NULL, yymsp[0].minor.yy344); } + break; + case 95: /* cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &yymsp[-5].minor.yy209, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy280, NULL); } + break; + case 96: /* index_options ::= */ + case 196: /* where_clause_opt ::= */ yytestcase(yyruleno==196); + case 200: /* twindow_clause_opt ::= */ yytestcase(yyruleno==200); + case 205: /* sliding_opt ::= */ yytestcase(yyruleno==205); + case 207: /* fill_opt ::= */ yytestcase(yyruleno==207); + case 219: /* having_clause_opt ::= */ yytestcase(yyruleno==219); + case 227: /* slimit_clause_opt ::= */ yytestcase(yyruleno==227); + case 231: /* limit_clause_opt ::= */ yytestcase(yyruleno==231); +{ yymsp[1].minor.yy344 = NULL; } + break; + case 97: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ +{ yymsp[-8].minor.yy344 = createIndexOption(pCxt, yymsp[-6].minor.yy280, yymsp[-2].minor.yy344, NULL, yymsp[0].minor.yy344); } + break; + case 98: /* 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.yy344 = createIndexOption(pCxt, yymsp[-8].minor.yy280, yymsp[-4].minor.yy344, yymsp[-2].minor.yy344, yymsp[0].minor.yy344); } + break; + case 101: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy344 = createFunctionNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy280); } + yymsp[-3].minor.yy344 = yylhsminor.yy344; + break; + case 102: /* cmd ::= SHOW VGROUPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, NULL); } break; - case 95: /* cmd ::= SHOW db_name NK_DOT VGROUPS */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &yymsp[-2].minor.yy129); } + case 103: /* cmd ::= SHOW db_name NK_DOT VGROUPS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &yymsp[-2].minor.yy209); } break; - case 96: /* cmd ::= SHOW MNODES */ + case 104: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL); } break; - case 97: /* cmd ::= query_expression */ -{ pCxt->pRootNode = yymsp[0].minor.yy256; } + case 105: /* cmd ::= query_expression */ +{ pCxt->pRootNode = yymsp[0].minor.yy344; } break; - case 98: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy256 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy256 = yylhsminor.yy256; + case 106: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy344 = yylhsminor.yy344; break; - case 99: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy256 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy256 = yylhsminor.yy256; + case 107: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy344 = yylhsminor.yy344; break; - case 100: /* literal ::= NK_STRING */ -{ yylhsminor.yy256 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy256 = yylhsminor.yy256; + case 108: /* literal ::= NK_STRING */ +{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy344 = yylhsminor.yy344; break; - case 101: /* literal ::= NK_BOOL */ -{ yylhsminor.yy256 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy256 = yylhsminor.yy256; + case 109: /* literal ::= NK_BOOL */ +{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy344 = yylhsminor.yy344; break; - case 102: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy256 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy256 = yylhsminor.yy256; + case 110: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy344 = yylhsminor.yy344; break; - case 103: /* literal ::= duration_literal */ - case 114: /* expression ::= literal */ yytestcase(yyruleno==114); - case 115: /* expression ::= column_reference */ yytestcase(yyruleno==115); - case 118: /* expression ::= subquery */ yytestcase(yyruleno==118); - case 150: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==150); - case 154: /* boolean_primary ::= predicate */ yytestcase(yyruleno==154); - case 156: /* common_expression ::= expression */ yytestcase(yyruleno==156); - case 157: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==157); - case 159: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==159); - case 161: /* table_reference ::= table_primary */ yytestcase(yyruleno==161); - case 162: /* table_reference ::= joined_table */ yytestcase(yyruleno==162); - case 166: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==166); - case 213: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==213); - case 215: /* query_primary ::= query_specification */ yytestcase(yyruleno==215); -{ yylhsminor.yy256 = yymsp[0].minor.yy256; } - yymsp[0].minor.yy256 = yylhsminor.yy256; + case 111: /* literal ::= duration_literal */ + case 123: /* expression ::= literal */ yytestcase(yyruleno==123); + case 124: /* expression ::= column_reference */ yytestcase(yyruleno==124); + case 127: /* expression ::= subquery */ yytestcase(yyruleno==127); + case 159: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==159); + case 163: /* boolean_primary ::= predicate */ yytestcase(yyruleno==163); + case 165: /* common_expression ::= expression */ yytestcase(yyruleno==165); + case 166: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==166); + case 168: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==168); + case 170: /* table_reference ::= table_primary */ yytestcase(yyruleno==170); + case 171: /* table_reference ::= joined_table */ yytestcase(yyruleno==171); + case 175: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==175); + case 222: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==222); + case 224: /* query_primary ::= query_specification */ yytestcase(yyruleno==224); +{ yylhsminor.yy344 = yymsp[0].minor.yy344; } + yymsp[0].minor.yy344 = yylhsminor.yy344; break; - case 104: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy256 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy256 = yylhsminor.yy256; + case 112: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy344 = yylhsminor.yy344; break; - case 105: /* literal_list ::= literal */ - case 127: /* expression_list ::= expression */ yytestcase(yyruleno==127); -{ yylhsminor.yy46 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy256)); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 113: /* literal_list ::= literal */ + case 136: /* expression_list ::= expression */ yytestcase(yyruleno==136); +{ yylhsminor.yy280 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy344)); } + yymsp[0].minor.yy280 = yylhsminor.yy280; break; - case 106: /* literal_list ::= literal_list NK_COMMA literal */ - case 128: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==128); -{ yylhsminor.yy46 = addNodeToList(pCxt, yymsp[-2].minor.yy46, releaseRawExprNode(pCxt, yymsp[0].minor.yy256)); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + case 114: /* literal_list ::= literal_list NK_COMMA literal */ + case 137: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==137); +{ yylhsminor.yy280 = addNodeToList(pCxt, yymsp[-2].minor.yy280, releaseRawExprNode(pCxt, yymsp[0].minor.yy344)); } + yymsp[-2].minor.yy280 = yylhsminor.yy280; break; - case 116: /* expression ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy256 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy129, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy46)); } - yymsp[-3].minor.yy256 = yylhsminor.yy256; + case 125: /* expression ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy209, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy280)); } + yymsp[-3].minor.yy344 = yylhsminor.yy344; break; - case 117: /* expression ::= function_name NK_LP NK_STAR NK_RP */ -{ yylhsminor.yy256 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy129, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy129, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } - yymsp[-3].minor.yy256 = yylhsminor.yy256; + case 126: /* expression ::= function_name NK_LP NK_STAR NK_RP */ +{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy209, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy209, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } + yymsp[-3].minor.yy344 = yylhsminor.yy344; break; - case 119: /* expression ::= NK_LP expression NK_RP */ - case 155: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==155); -{ yylhsminor.yy256 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy256)); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + case 128: /* expression ::= NK_LP expression NK_RP */ + case 164: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==164); +{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy344)); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 120: /* expression ::= NK_PLUS expression */ + case 129: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy256)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy344)); } - yymsp[-1].minor.yy256 = yylhsminor.yy256; + yymsp[-1].minor.yy344 = yylhsminor.yy344; break; - case 121: /* expression ::= NK_MINUS expression */ + case 130: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy256), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy344), NULL)); } - yymsp[-1].minor.yy256 = yylhsminor.yy256; + yymsp[-1].minor.yy344 = yylhsminor.yy344; break; - case 122: /* expression ::= expression NK_PLUS expression */ + case 131: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy256); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 123: /* expression ::= expression NK_MINUS expression */ + case 132: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy256); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 124: /* expression ::= expression NK_STAR expression */ + case 133: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy256); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 125: /* expression ::= expression NK_SLASH expression */ + case 134: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy256); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 126: /* expression ::= expression NK_REM expression */ + case 135: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy256); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 129: /* column_reference ::= column_name */ -{ yylhsminor.yy256 = createRawExprNode(pCxt, &yymsp[0].minor.yy129, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy129)); } - yymsp[0].minor.yy256 = yylhsminor.yy256; + case 138: /* column_reference ::= column_name */ +{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy209, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy209)); } + yymsp[0].minor.yy344 = yylhsminor.yy344; break; - case 130: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy256 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129, createColumnNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129)); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + case 139: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209, createColumnNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209)); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 131: /* predicate ::= expression compare_op expression */ - case 136: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==136); + case 140: /* predicate ::= expression compare_op expression */ + case 145: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==145); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy256); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy326, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy236, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 132: /* predicate ::= expression BETWEEN expression AND expression */ + case 141: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy256); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy256), releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy344); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy344), releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[-4].minor.yy256 = yylhsminor.yy256; + yymsp[-4].minor.yy344 = yylhsminor.yy344; break; - case 133: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 142: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy256); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), releaseRawExprNode(pCxt, yymsp[-5].minor.yy256), releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy344); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[-5].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[-5].minor.yy256 = yylhsminor.yy256; + yymsp[-5].minor.yy344 = yylhsminor.yy344; break; - case 134: /* predicate ::= expression IS NULL */ + case 143: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), NULL)); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 135: /* predicate ::= expression IS NOT NULL */ + case 144: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy256), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy344), NULL)); } - yymsp[-3].minor.yy256 = yylhsminor.yy256; + yymsp[-3].minor.yy344 = yylhsminor.yy344; break; - case 137: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy326 = OP_TYPE_LOWER_THAN; } + case 146: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy236 = OP_TYPE_LOWER_THAN; } break; - case 138: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy326 = OP_TYPE_GREATER_THAN; } + case 147: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy236 = OP_TYPE_GREATER_THAN; } break; - case 139: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy326 = OP_TYPE_LOWER_EQUAL; } + case 148: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy236 = OP_TYPE_LOWER_EQUAL; } break; - case 140: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy326 = OP_TYPE_GREATER_EQUAL; } + case 149: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy236 = OP_TYPE_GREATER_EQUAL; } break; - case 141: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy326 = OP_TYPE_NOT_EQUAL; } + case 150: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy236 = OP_TYPE_NOT_EQUAL; } break; - case 142: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy326 = OP_TYPE_EQUAL; } + case 151: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy236 = OP_TYPE_EQUAL; } break; - case 143: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy326 = OP_TYPE_LIKE; } + case 152: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy236 = OP_TYPE_LIKE; } break; - case 144: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy326 = OP_TYPE_NOT_LIKE; } + case 153: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy236 = OP_TYPE_NOT_LIKE; } break; - case 145: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy326 = OP_TYPE_MATCH; } + case 154: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy236 = OP_TYPE_MATCH; } break; - case 146: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy326 = OP_TYPE_NMATCH; } + case 155: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy236 = OP_TYPE_NMATCH; } break; - case 147: /* in_op ::= IN */ -{ yymsp[0].minor.yy326 = OP_TYPE_IN; } + case 156: /* in_op ::= IN */ +{ yymsp[0].minor.yy236 = OP_TYPE_IN; } break; - case 148: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy326 = OP_TYPE_NOT_IN; } + case 157: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy236 = OP_TYPE_NOT_IN; } break; - case 149: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy256 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy46)); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + case 158: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy280)); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 151: /* boolean_value_expression ::= NOT boolean_primary */ + case 160: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy256), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy344), NULL)); } - yymsp[-1].minor.yy256 = yylhsminor.yy256; + yymsp[-1].minor.yy344 = yylhsminor.yy344; break; - case 152: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 161: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy256); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 153: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 162: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy256); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 158: /* from_clause ::= FROM table_reference_list */ - case 188: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==188); - case 211: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==211); -{ yymsp[-1].minor.yy256 = yymsp[0].minor.yy256; } + case 167: /* from_clause ::= FROM table_reference_list */ + case 197: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==197); + case 220: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==220); +{ yymsp[-1].minor.yy344 = yymsp[0].minor.yy344; } break; - case 160: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy256 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy256, yymsp[0].minor.yy256, NULL); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + case 169: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy344 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy344, yymsp[0].minor.yy344, NULL); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 163: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy256 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy129, &yymsp[0].minor.yy129); } - yymsp[-1].minor.yy256 = yylhsminor.yy256; + case 172: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy344 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy209, &yymsp[0].minor.yy209); } + yymsp[-1].minor.yy344 = yylhsminor.yy344; break; - case 164: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy256 = createRealTableNode(pCxt, &yymsp[-3].minor.yy129, &yymsp[-1].minor.yy129, &yymsp[0].minor.yy129); } - yymsp[-3].minor.yy256 = yylhsminor.yy256; + case 173: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy344 = createRealTableNode(pCxt, &yymsp[-3].minor.yy209, &yymsp[-1].minor.yy209, &yymsp[0].minor.yy209); } + yymsp[-3].minor.yy344 = yylhsminor.yy344; break; - case 165: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy256 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy256), &yymsp[0].minor.yy129); } - yymsp[-1].minor.yy256 = yylhsminor.yy256; + case 174: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy344 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy344), &yymsp[0].minor.yy209); } + yymsp[-1].minor.yy344 = yylhsminor.yy344; break; - case 167: /* alias_opt ::= */ -{ yymsp[1].minor.yy129 = nil_token; } + case 176: /* alias_opt ::= */ +{ yymsp[1].minor.yy209 = nil_token; } break; - case 168: /* alias_opt ::= table_alias */ -{ yylhsminor.yy129 = yymsp[0].minor.yy129; } - yymsp[0].minor.yy129 = yylhsminor.yy129; + case 177: /* alias_opt ::= table_alias */ +{ yylhsminor.yy209 = yymsp[0].minor.yy209; } + yymsp[0].minor.yy209 = yylhsminor.yy209; break; - case 169: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy129 = yymsp[0].minor.yy129; } + case 178: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy209 = yymsp[0].minor.yy209; } break; - case 170: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 171: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==171); -{ yymsp[-2].minor.yy256 = yymsp[-1].minor.yy256; } + case 179: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 180: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==180); +{ yymsp[-2].minor.yy344 = yymsp[-1].minor.yy344; } break; - case 172: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy256 = createJoinTableNode(pCxt, yymsp[-4].minor.yy266, yymsp[-5].minor.yy256, yymsp[-2].minor.yy256, yymsp[0].minor.yy256); } - yymsp[-5].minor.yy256 = yylhsminor.yy256; + case 181: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy344 = createJoinTableNode(pCxt, yymsp[-4].minor.yy36, yymsp[-5].minor.yy344, yymsp[-2].minor.yy344, yymsp[0].minor.yy344); } + yymsp[-5].minor.yy344 = yylhsminor.yy344; break; - case 173: /* join_type ::= */ -{ yymsp[1].minor.yy266 = JOIN_TYPE_INNER; } + case 182: /* join_type ::= */ +{ yymsp[1].minor.yy36 = JOIN_TYPE_INNER; } break; - case 174: /* join_type ::= INNER */ -{ yymsp[0].minor.yy266 = JOIN_TYPE_INNER; } + case 183: /* join_type ::= INNER */ +{ yymsp[0].minor.yy36 = JOIN_TYPE_INNER; } break; - case 175: /* 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 184: /* 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.yy256 = createSelectStmt(pCxt, yymsp[-7].minor.yy185, yymsp[-6].minor.yy46, yymsp[-5].minor.yy256); - yymsp[-8].minor.yy256 = addWhereClause(pCxt, yymsp[-8].minor.yy256, yymsp[-4].minor.yy256); - yymsp[-8].minor.yy256 = addPartitionByClause(pCxt, yymsp[-8].minor.yy256, yymsp[-3].minor.yy46); - yymsp[-8].minor.yy256 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy256, yymsp[-2].minor.yy256); - yymsp[-8].minor.yy256 = addGroupByClause(pCxt, yymsp[-8].minor.yy256, yymsp[-1].minor.yy46); - yymsp[-8].minor.yy256 = addHavingClause(pCxt, yymsp[-8].minor.yy256, yymsp[0].minor.yy256); + yymsp[-8].minor.yy344 = createSelectStmt(pCxt, yymsp[-7].minor.yy281, yymsp[-6].minor.yy280, yymsp[-5].minor.yy344); + yymsp[-8].minor.yy344 = addWhereClause(pCxt, yymsp[-8].minor.yy344, yymsp[-4].minor.yy344); + yymsp[-8].minor.yy344 = addPartitionByClause(pCxt, yymsp[-8].minor.yy344, yymsp[-3].minor.yy280); + yymsp[-8].minor.yy344 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy344, yymsp[-2].minor.yy344); + yymsp[-8].minor.yy344 = addGroupByClause(pCxt, yymsp[-8].minor.yy344, yymsp[-1].minor.yy280); + yymsp[-8].minor.yy344 = addHavingClause(pCxt, yymsp[-8].minor.yy344, yymsp[0].minor.yy344); } break; - case 177: /* set_quantifier_opt ::= DISTINCT */ -{ yymsp[0].minor.yy185 = true; } + case 186: /* set_quantifier_opt ::= DISTINCT */ +{ yymsp[0].minor.yy281 = true; } break; - case 178: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy185 = false; } + case 187: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy281 = false; } break; - case 179: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy46 = NULL; } + case 188: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy280 = NULL; } break; - case 183: /* select_item ::= common_expression */ + case 192: /* select_item ::= common_expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy256), &t); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy344), &t); } - yymsp[0].minor.yy256 = yylhsminor.yy256; + yymsp[0].minor.yy344 = yylhsminor.yy344; break; - case 184: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy256 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy256), &yymsp[0].minor.yy129); } - yymsp[-1].minor.yy256 = yylhsminor.yy256; + case 193: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy344 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy344), &yymsp[0].minor.yy209); } + yymsp[-1].minor.yy344 = yylhsminor.yy344; break; - case 185: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy256 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), &yymsp[0].minor.yy129); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + case 194: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy344 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), &yymsp[0].minor.yy209); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 186: /* select_item ::= table_name NK_DOT NK_STAR */ -{ yylhsminor.yy256 = createColumnNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + case 195: /* select_item ::= table_name NK_DOT NK_STAR */ +{ yylhsminor.yy344 = createColumnNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 187: /* where_clause_opt ::= */ - case 191: /* twindow_clause_opt ::= */ yytestcase(yyruleno==191); - case 196: /* sliding_opt ::= */ yytestcase(yyruleno==196); - case 198: /* fill_opt ::= */ yytestcase(yyruleno==198); - case 210: /* having_clause_opt ::= */ yytestcase(yyruleno==210); - case 218: /* slimit_clause_opt ::= */ yytestcase(yyruleno==218); - case 222: /* limit_clause_opt ::= */ yytestcase(yyruleno==222); -{ yymsp[1].minor.yy256 = NULL; } + case 199: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 216: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==216); + case 226: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==226); +{ yymsp[-2].minor.yy280 = yymsp[0].minor.yy280; } break; - case 190: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 207: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==207); - case 217: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==217); -{ yymsp[-2].minor.yy46 = yymsp[0].minor.yy46; } + case 201: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy344 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy344), &yymsp[-1].minor.yy0); } break; - case 192: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy256 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy256), &yymsp[-1].minor.yy0); } + case 202: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ +{ yymsp[-3].minor.yy344 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy344)); } break; - case 193: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ -{ yymsp[-3].minor.yy256 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy256)); } + case 203: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy344 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy344), NULL, yymsp[-1].minor.yy344, yymsp[0].minor.yy344); } break; - case 194: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy256 = createIntervalWindowNode(pCxt, yymsp[-3].minor.yy256, NULL, yymsp[-1].minor.yy256, yymsp[0].minor.yy256); } + case 204: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy344 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy344), releaseRawExprNode(pCxt, yymsp[-3].minor.yy344), yymsp[-1].minor.yy344, yymsp[0].minor.yy344); } break; - case 195: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy256 = createIntervalWindowNode(pCxt, yymsp[-5].minor.yy256, yymsp[-3].minor.yy256, yymsp[-1].minor.yy256, yymsp[0].minor.yy256); } + case 206: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ +{ yymsp[-3].minor.yy344 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy344); } break; - case 197: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ -{ yymsp[-3].minor.yy256 = yymsp[-1].minor.yy256; } + case 208: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy344 = createFillNode(pCxt, yymsp[-1].minor.yy342, NULL); } break; - case 199: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy256 = createFillNode(pCxt, yymsp[-1].minor.yy360, NULL); } + case 209: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy344 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy280)); } break; - case 200: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy256 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy46)); } + case 210: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy342 = FILL_MODE_NONE; } break; - case 201: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy360 = FILL_MODE_NONE; } + case 211: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy342 = FILL_MODE_PREV; } break; - case 202: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy360 = FILL_MODE_PREV; } + case 212: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy342 = FILL_MODE_NULL; } break; - case 203: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy360 = FILL_MODE_NULL; } + case 213: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy342 = FILL_MODE_LINEAR; } break; - case 204: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy360 = FILL_MODE_LINEAR; } + case 214: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy342 = FILL_MODE_NEXT; } break; - case 205: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy360 = FILL_MODE_NEXT; } + case 217: /* group_by_list ::= expression */ +{ yylhsminor.yy280 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } + yymsp[0].minor.yy280 = yylhsminor.yy280; break; - case 208: /* group_by_list ::= expression */ -{ yylhsminor.yy46 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 218: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy280 = addNodeToList(pCxt, yymsp[-2].minor.yy280, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } + yymsp[-2].minor.yy280 = yylhsminor.yy280; break; - case 209: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy46 = addNodeToList(pCxt, yymsp[-2].minor.yy46, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; - break; - case 212: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 221: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy256 = addOrderByClause(pCxt, yymsp[-3].minor.yy256, yymsp[-2].minor.yy46); - yylhsminor.yy256 = addSlimitClause(pCxt, yylhsminor.yy256, yymsp[-1].minor.yy256); - yylhsminor.yy256 = addLimitClause(pCxt, yylhsminor.yy256, yymsp[0].minor.yy256); + yylhsminor.yy344 = addOrderByClause(pCxt, yymsp[-3].minor.yy344, yymsp[-2].minor.yy280); + yylhsminor.yy344 = addSlimitClause(pCxt, yylhsminor.yy344, yymsp[-1].minor.yy344); + yylhsminor.yy344 = addLimitClause(pCxt, yylhsminor.yy344, yymsp[0].minor.yy344); } - yymsp[-3].minor.yy256 = yylhsminor.yy256; + yymsp[-3].minor.yy344 = yylhsminor.yy344; break; - case 214: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy256 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy256, yymsp[0].minor.yy256); } - yymsp[-3].minor.yy256 = yylhsminor.yy256; + case 223: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy344 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy344, yymsp[0].minor.yy344); } + yymsp[-3].minor.yy344 = yylhsminor.yy344; break; - case 219: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 223: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==223); -{ yymsp[-1].minor.yy256 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 228: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 232: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==232); +{ yymsp[-1].minor.yy344 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 220: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 224: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==224); -{ yymsp[-3].minor.yy256 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 229: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 233: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==233); +{ yymsp[-3].minor.yy344 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 221: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 225: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==225); -{ yymsp[-3].minor.yy256 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 230: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 234: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==234); +{ yymsp[-3].minor.yy344 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 226: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy256 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy256); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + case 235: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy344); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 227: /* search_condition ::= common_expression */ -{ yylhsminor.yy256 = releaseRawExprNode(pCxt, yymsp[0].minor.yy256); } - yymsp[0].minor.yy256 = yylhsminor.yy256; + case 236: /* search_condition ::= common_expression */ +{ yylhsminor.yy344 = releaseRawExprNode(pCxt, yymsp[0].minor.yy344); } + yymsp[0].minor.yy344 = yylhsminor.yy344; break; - case 230: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy256 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), yymsp[-1].minor.yy202, yymsp[0].minor.yy147); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + case 239: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy344 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), yymsp[-1].minor.yy2, yymsp[0].minor.yy217); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 231: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy202 = ORDER_ASC; } + case 240: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy2 = ORDER_ASC; } break; - case 232: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy202 = ORDER_ASC; } + case 241: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy2 = ORDER_ASC; } break; - case 233: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy202 = ORDER_DESC; } + case 242: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy2 = ORDER_DESC; } break; - case 234: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy147 = NULL_ORDER_DEFAULT; } + case 243: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy217 = NULL_ORDER_DEFAULT; } break; - case 235: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy147 = NULL_ORDER_FIRST; } + case 244: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy217 = NULL_ORDER_FIRST; } break; - case 236: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy147 = NULL_ORDER_LAST; } + case 245: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy217 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/parserAstTest.cpp b/source/libs/parser/test/parserAstTest.cpp index d30c21cc21..cf889c0f3c 100644 --- a/source/libs/parser/test/parserAstTest.cpp +++ b/source/libs/parser/test/parserAstTest.cpp @@ -398,3 +398,10 @@ TEST_F(ParserTest, createTable) { ); ASSERT_TRUE(run()); } + +TEST_F(ParserTest, createSmaIndex) { + setDatabase("root", "test"); + + bind("create sma index index1 on t1 function(max(c1), min(c3 + 10), sum(c4))"); + ASSERT_TRUE(run()); +} diff --git a/source/util/src/tjson.c b/source/util/src/tjson.c index 634cfcb026..0a4a1a07a6 100644 --- a/source/util/src/tjson.c +++ b/source/util/src/tjson.c @@ -26,6 +26,14 @@ SJson* tjsonCreateObject() { return pJson; } +SJson* tjsonCreateArray() { + SJson* pJson = cJSON_CreateArray(); + if (pJson == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + } + return pJson; +} + void tjsonDelete(SJson* pJson) { if (pJson != NULL) { cJSON_Delete((cJSON*)pJson); From f9997a122ba4bc0b591366668969d916a5fc4a7c Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 15 Mar 2022 16:51:50 +0800 Subject: [PATCH 14/38] [td-13039] refactor and fix bug. --- contrib/CMakeLists.txt | 2 +- source/libs/executor/inc/executorimpl.h | 3 +- source/libs/executor/src/dataDispatcher.c | 3 +- source/libs/executor/src/executorimpl.c | 60 +++++++++++------------ source/libs/function/src/builtinsimpl.c | 2 +- source/libs/transport/CMakeLists.txt | 2 +- 6 files changed, 36 insertions(+), 36 deletions(-) diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 5e2bfc52e1..3b7b1f3c10 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -128,7 +128,7 @@ target_include_directories( set(CMAKE_PROJECT_INCLUDE_BEFORE "${CMAKE_SUPPORT_DIR}/EnableCMP0048.txt.in") add_subdirectory(zlib) target_include_directories( - zlib + zlibstatic PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/zlib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/zlib ) diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index 97a51a46ce..833ac13226 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -463,13 +463,12 @@ typedef struct SAggSupporter { SHashObj* pResultRowListSet; // used to check if current ResultRowInfo has ResultRow object or not SArray* pResultRowArrayList; // The array list that contains the Result rows char* keyBuf; // window key buffer -// SResultRowPool *pool; // The window result objects pool, all the resultRow Objects are allocated and managed by this object. + SDiskbasedBuf *pResultBuf; // query result buffer based on blocked-wised disk file int32_t resultRowSize; // the result buffer size for each result row, with the meta data size for each row } SAggSupporter; typedef struct STableIntervalOperatorInfo { SOptrBasicInfo binfo; - SDiskbasedBuf *pResultBuf; // query result buffer based on blocked-wised disk file SGroupResInfo groupResInfo; SInterval interval; STimeWindow win; diff --git a/source/libs/executor/src/dataDispatcher.c b/source/libs/executor/src/dataDispatcher.c index a2e526c2bd..a0ee048d82 100644 --- a/source/libs/executor/src/dataDispatcher.c +++ b/source/libs/executor/src/dataDispatcher.c @@ -115,7 +115,8 @@ static bool allocBuf(SDataDispatchHandle* pDispatcher, const SInputData* pInput, return false; } - pBuf->allocSize = sizeof(SRetrieveTableRsp) + pDispatcher->pSchema->resultRowSize * pInput->pData->info.rows; + // struct size + data payload + length for each column + pBuf->allocSize = sizeof(SRetrieveTableRsp) + pDispatcher->pSchema->resultRowSize * pInput->pData->info.rows + pInput->pData->info.numOfCols * sizeof(int32_t); pBuf->pData = malloc(pBuf->allocSize); if (pBuf->pData == NULL) { qError("SinkNode failed to malloc memory, size:%d, code:%d", pBuf->allocSize, TAOS_SYSTEM_ERROR(errno)); diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index ef2dbea4fd..947fb08ff9 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -858,9 +858,9 @@ static void setResultRowOutputBufInitCtx_rv(SDiskbasedBuf * pBuf, SResultRow *pR static int32_t setResultOutputBufByKey_rv(SResultRowInfo *pResultRowInfo, int64_t id, STimeWindow *win, bool masterscan, SResultRow **pResult, int64_t tableGroupId, SqlFunctionCtx* pCtx, - int32_t numOfOutput, int32_t* rowCellInfoOffset, SDiskbasedBuf *pBuf, SAggSupporter *pAggSup, SExecTaskInfo* pTaskInfo) { + int32_t numOfOutput, int32_t* rowCellInfoOffset, SAggSupporter *pAggSup, SExecTaskInfo* pTaskInfo) { assert(win->skey <= win->ekey); - SResultRow *pResultRow = doSetResultOutBufByKey_rv(pBuf, pResultRowInfo, id, (char *)&win->skey, TSDB_KEYSIZE, masterscan, tableGroupId, + SResultRow *pResultRow = doSetResultOutBufByKey_rv(pAggSup->pResultBuf, pResultRowInfo, id, (char *)&win->skey, TSDB_KEYSIZE, masterscan, tableGroupId, pTaskInfo, true, pAggSup); if (pResultRow == NULL) { @@ -871,7 +871,7 @@ static int32_t setResultOutputBufByKey_rv(SResultRowInfo *pResultRowInfo, int64_ // set time window for current result pResultRow->win = (*win); *pResult = pResultRow; - setResultRowOutputBufInitCtx_rv(pBuf, pResultRow, pCtx, numOfOutput, rowCellInfoOffset); + setResultRowOutputBufInitCtx_rv(pAggSup->pResultBuf, pResultRow, pCtx, numOfOutput, rowCellInfoOffset); return TSDB_CODE_SUCCESS; } @@ -1039,7 +1039,7 @@ static void doApplyFunctions(SqlFunctionCtx* pCtx, STimeWindow* pWin, int32_t of pCtx[k].input.numOfRows = forwardStep; if (tsCol != NULL) { - pCtx[k].ptsList = &tsCol[pos]; + pCtx[k].ptsList = tsCol; } // not a whole block involved in query processing, statistics data can not be used @@ -1490,7 +1490,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul SResultRow* pResult = NULL; int32_t ret = setResultOutputBufByKey_rv(pResultRowInfo, pSDataBlock->info.uid, &win, masterScan, &pResult, tableGroupId, pInfo->binfo.pCtx, - numOfOutput, pInfo->binfo.rowCellInfoOffset, pInfo->pResultBuf, &pInfo->aggSup, pTaskInfo); + numOfOutput, pInfo->binfo.rowCellInfoOffset, &pInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS || pResult == NULL) { longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); } @@ -1512,7 +1512,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul STimeWindow w = pRes->win; ret = setResultOutputBufByKey_rv(pResultRowInfo, pSDataBlock->info.uid, &w, masterScan, &pResult, - tableGroupId, pInfo->binfo.pCtx, numOfOutput, pInfo->binfo.rowCellInfoOffset, pInfo->pResultBuf, &pInfo->aggSup, pTaskInfo); + tableGroupId, pInfo->binfo.pCtx, numOfOutput, pInfo->binfo.rowCellInfoOffset, &pInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS) { longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); } @@ -1530,7 +1530,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul // restore current time window ret = setResultOutputBufByKey_rv(pResultRowInfo, pSDataBlock->info.uid, &win, masterScan, &pResult, tableGroupId, pInfo->binfo.pCtx, - numOfOutput, pInfo->binfo.rowCellInfoOffset, pInfo->pResultBuf, &pInfo->aggSup, pTaskInfo); + numOfOutput, pInfo->binfo.rowCellInfoOffset, &pInfo->aggSup, pTaskInfo); if (ret != TSDB_CODE_SUCCESS) { longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); } @@ -1550,7 +1550,7 @@ static void hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pResul // null data, failed to allocate more memory buffer int32_t code = setResultOutputBufByKey_rv(pResultRowInfo, pSDataBlock->info.uid, &nextWin, masterScan, &pResult, tableGroupId, - pInfo->binfo.pCtx, numOfOutput, pInfo->binfo.rowCellInfoOffset, pInfo->pResultBuf, &pInfo->aggSup, pTaskInfo); + pInfo->binfo.pCtx, numOfOutput, pInfo->binfo.rowCellInfoOffset, &pInfo->aggSup, pTaskInfo); if (code != TSDB_CODE_SUCCESS || pResult == NULL) { longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); } @@ -2897,6 +2897,8 @@ int32_t loadDataBlock(SExecTaskInfo *pTaskInfo, STableScanInfo* pTableScanInfo, pCost->totalCheckedRows += pBlock->info.rows; pCost->loadBlocks += 1; + *status = BLK_DATA_ALL_NEEDED; + pBlock->pDataBlock = tsdbRetrieveDataBlock(pTableScanInfo->pTsdbReadHandle, NULL); if (pBlock->pDataBlock == NULL) { return terrno; @@ -3371,7 +3373,7 @@ void setFunctionResultOutput(SOptrBasicInfo* pInfo, SAggSupporter* pSup, int32_t int64_t tid = 0; int64_t groupId = 0; - SResultRow* pRow = doSetResultOutBufByKey_rv(NULL, pResultRowInfo, tid, (char *)&tid, sizeof(tid), true, groupId, pTaskInfo, false, pSup); + SResultRow* pRow = doSetResultOutBufByKey_rv(pSup->pResultBuf, pResultRowInfo, tid, (char *)&tid, sizeof(tid), true, groupId, pTaskInfo, false, pSup); for (int32_t i = 0; i < pDataBlock->info.numOfCols; ++i) { SColumnInfoData* pData = taosArrayGet(pDataBlock->pDataBlock, i); @@ -3531,7 +3533,7 @@ void finalizeMultiTupleQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SD for (int32_t j = 0; j < numOfOutput; ++j) { pCtx[j].resultInfo = getResultCell(pRow, j, rowCellInfoOffset); - struct SResultRowEntryInfo* pResInfo = pCtx[i].resultInfo; + struct SResultRowEntryInfo* pResInfo = pCtx[j].resultInfo; if (isRowEntryCompleted(pResInfo) && isRowEntryInitialized(pResInfo)) { continue; } @@ -4730,7 +4732,7 @@ static SSDataBlock* doTableScanImpl(SOperatorInfo *pOperator, bool* newgroup) { // } // this function never returns error? - uint32_t status; + uint32_t status = BLK_DATA_ALL_NEEDED; int32_t code = loadDataBlock(pTaskInfo, pTableScanInfo, pBlock, &status); // int32_t code = loadDataBlockOnDemand(pOperator->pRuntimeEnv, pTableScanInfo, pBlock, &status); if (code != TSDB_CODE_SUCCESS) { @@ -5724,7 +5726,7 @@ SArray* getResultGroupCheckColumns(STaskAttr* pQuery) { return pOrderColumns; } -static int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx *pCtx, int32_t numOfOutput); +static int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx *pCtx, int32_t numOfOutput, const char* pKey); static void cleanupAggSup(SAggSupporter* pAggSup); static void destroySortedMergeOperatorInfo(void* param, int32_t numOfOutput) { @@ -6102,7 +6104,7 @@ SOperatorInfo* createSortedMergeOperatorInfo(SOperatorInfo** downstream, int32_t goto _error; } - int32_t code = doInitAggInfoSup(&pInfo->aggSup, pInfo->binfo.pCtx, num); + int32_t code = doInitAggInfoSup(&pInfo->aggSup, pInfo->binfo.pCtx, num, pTaskInfo->id.str); if (code != TSDB_CODE_SUCCESS) { goto _error; } @@ -6556,7 +6558,7 @@ static int32_t doOpenIntervalAgg(SOperatorInfo *pOperator) { } closeAllResultRows(&pInfo->binfo.resultRowInfo); - finalizeMultiTupleQueryResult(pInfo->binfo.pCtx, pOperator->numOfOutput, pInfo->pResultBuf, &pInfo->binfo.resultRowInfo, pInfo->binfo.rowCellInfoOffset); + finalizeMultiTupleQueryResult(pInfo->binfo.pCtx, pOperator->numOfOutput, pInfo->aggSup.pResultBuf, &pInfo->binfo.resultRowInfo, pInfo->binfo.rowCellInfoOffset); initGroupResInfo(&pInfo->groupResInfo, &pInfo->binfo.resultRowInfo); OPTR_SET_OPENED(pOperator); @@ -6577,7 +6579,7 @@ static SSDataBlock* doIntervalAgg(SOperatorInfo *pOperator, bool* newgroup) { } blockDataEnsureCapacity(pInfo->binfo.pRes, pInfo->binfo.capacity); - toSDatablock(&pInfo->groupResInfo, pInfo->pResultBuf, pInfo->binfo.pRes, pInfo->binfo.capacity, pInfo->binfo.rowCellInfoOffset); + toSDatablock(&pInfo->groupResInfo, pInfo->aggSup.pResultBuf, pInfo->binfo.pRes, pInfo->binfo.capacity, pInfo->binfo.rowCellInfoOffset); if (pInfo->binfo.pRes->info.rows == 0 || !hasRemainDataInCurrentGroup(&pInfo->groupResInfo)) { doSetOperatorCompleted(pOperator); @@ -7137,14 +7139,13 @@ static void destroyOperatorInfo(SOperatorInfo* pOperator) { tfree(pOperator); } -int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx *pCtx, int32_t numOfOutput) { +int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx *pCtx, int32_t numOfOutput, const char* pKey) { _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); pAggSup->resultRowSize = getResultRowSize(pCtx, numOfOutput); pAggSup->keyBuf = calloc(1, sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES); pAggSup->pResultRowHashTable = taosHashInit(10, hashFn, true, HASH_NO_LOCK); pAggSup->pResultRowListSet = taosHashInit(100, hashFn, false, HASH_NO_LOCK); -// pAggSup->pool = initResultRowPool(pAggSup->resultRowSize); pAggSup->pResultRowArrayList = taosArrayInit(10, sizeof(SResultRowCell)); if (pAggSup->keyBuf == NULL || pAggSup->pResultRowArrayList == NULL || pAggSup->pResultRowListSet == NULL || @@ -7152,6 +7153,11 @@ int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx *pCtx, int32_t n return TSDB_CODE_OUT_OF_MEMORY; } + int32_t code = createDiskbasedBuf(&pAggSup->pResultBuf, 4096, 4096 * 256, pKey, "/tmp/"); + if (code != TSDB_CODE_SUCCESS) { + return code; + } + return TSDB_CODE_SUCCESS; } @@ -7160,16 +7166,16 @@ static void cleanupAggSup(SAggSupporter* pAggSup) { taosHashCleanup(pAggSup->pResultRowHashTable); taosHashCleanup(pAggSup->pResultRowListSet); taosArrayDestroy(pAggSup->pResultRowArrayList); -// destroyResultRowPool(pAggSup->pool); + destroyDiskbasedBuf(pAggSup->pResultBuf); } static int32_t initAggInfo(SOptrBasicInfo* pBasicInfo, SAggSupporter* pAggSup, SExprInfo* pExprInfo, int32_t numOfCols, - int32_t numOfRows, SSDataBlock* pResultBlock) { + int32_t numOfRows, SSDataBlock* pResultBlock, const char* pkey) { pBasicInfo->pCtx = createSqlFunctionCtx_rv(pExprInfo, numOfCols, &pBasicInfo->rowCellInfoOffset); pBasicInfo->pRes = pResultBlock; pBasicInfo->capacity = numOfRows; - doInitAggInfoSup(pAggSup, pBasicInfo->pCtx, numOfCols); + doInitAggInfoSup(pAggSup, pBasicInfo->pCtx, numOfCols, pkey); } static STableQueryInfo* initTableQueryInfo(const STableGroupInfo* pTableGroupInfo) { @@ -7206,7 +7212,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SExprInfo* //(int32_t)(getRowNumForMultioutput(pQueryAttr, pQueryAttr->topBotQuery, pQueryAttr->stableQuery)); int32_t numOfRows = 1; - int32_t code = initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResultBlock); + int32_t code = initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResultBlock, pTaskInfo->id.str); pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo); if (code != TSDB_CODE_SUCCESS || pInfo->pTableQueryInfo == NULL) { goto _error; @@ -7271,7 +7277,6 @@ void destroyIntervalOperatorInfo(void* param, int32_t numOfOutput) { STableIntervalOperatorInfo* pInfo = (STableIntervalOperatorInfo*) param; doDestroyBasicInfo(&pInfo->binfo, numOfOutput); cleanupAggSup(&pInfo->aggSup); - destroyDiskbasedBuf(pInfo->pResultBuf); } void destroySWindowOperatorInfo(void* param, int32_t numOfOutput) { @@ -7347,7 +7352,7 @@ SOperatorInfo* createMultiTableAggOperatorInfo(SOperatorInfo* downstream, SExprI SAggOperatorInfo* pInfo = calloc(1, sizeof(SAggOperatorInfo)); int32_t numOfRows = 1; - int32_t code = initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResBlock); + int32_t code = initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResBlock, pTaskInfo->id.str); pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo); if (code != TSDB_CODE_SUCCESS || pInfo->pTableQueryInfo == NULL) { goto _error; @@ -7499,17 +7504,12 @@ SOperatorInfo* createIntervalOperatorInfo(SOperatorInfo* downstream, SExprInfo* pInfo->win.ekey = INT64_MAX; int32_t numOfRows = 4096; - int32_t code = initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResBlock); + int32_t code = initAggInfo(&pInfo->binfo, &pInfo->aggSup, pExprInfo, numOfCols, numOfRows, pResBlock, pTaskInfo->id.str); // pInfo->pTableQueryInfo = initTableQueryInfo(pTableGroupInfo); if (code != TSDB_CODE_SUCCESS/* || pInfo->pTableQueryInfo == NULL*/) { goto _error; } - code = createDiskbasedBuf(&pInfo->pResultBuf, 4096, 4096 * 256, pTaskInfo->id.str, "/tmp/"); - if (code != TSDB_CODE_SUCCESS) { - goto _error; - } - initResultRowInfo(&pInfo->binfo.resultRowInfo, (int32_t)1); pOperator->name = "TimeIntervalAggOperator"; @@ -7595,7 +7595,7 @@ SOperatorInfo* createSessionAggOperatorInfo(SOperatorInfo* downstream, SExprInfo goto _error; } - int32_t code = doInitAggInfoSup(&pInfo->aggSup, pInfo->binfo.pCtx, numOfCols); + int32_t code = doInitAggInfoSup(&pInfo->aggSup, pInfo->binfo.pCtx, numOfCols, pTaskInfo->id.str); if (code != TSDB_CODE_SUCCESS) { goto _error; } diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 78e0e9f8e7..f0f00434f0 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -394,7 +394,7 @@ int32_t doMinMaxHelper(SqlFunctionCtx *pCtx, int32_t isMinFunc) { int32_t *pData = (int32_t*)pCol->pData; int32_t *val = (int32_t*) buf; - for (int32_t i = 0; i < pCtx->size; ++i) { + for (int32_t i = start; i < start + numOfRows; ++i) { if ((pCol->hasNull) && colDataIsNull_f(pCol->nullbitmap, i)) { continue; } diff --git a/source/libs/transport/CMakeLists.txt b/source/libs/transport/CMakeLists.txt index 5cc436cf32..20dd3f7ad2 100644 --- a/source/libs/transport/CMakeLists.txt +++ b/source/libs/transport/CMakeLists.txt @@ -12,7 +12,7 @@ target_link_libraries( PUBLIC os PUBLIC util PUBLIC common - PUBLIC zlib + PUBLIC zlibstatic ) if (${BUILD_WITH_UV_TRANS}) if (${BUILD_WITH_UV}) From acd60dcc85e0fa91605ba38e5521d9763e78e65e Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 15 Mar 2022 17:40:49 +0800 Subject: [PATCH 15/38] [td-14048] do hide the update attribute of the databases. --- source/dnode/mnode/impl/src/mndDb.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index a17a45d46a..6625c7f104 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -1292,11 +1292,11 @@ static int32_t mndGetDbMeta(SMnodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMe pSchema[cols].bytes = pShow->bytes[cols]; cols++; - pShow->bytes[cols] = 1; - pSchema[cols].type = TSDB_DATA_TYPE_TINYINT; - strcpy(pSchema[cols].name, "update"); - pSchema[cols].bytes = pShow->bytes[cols]; - cols++; +// pShow->bytes[cols] = 1; +// pSchema[cols].type = TSDB_DATA_TYPE_TINYINT; +// strcpy(pSchema[cols].name, "update"); +// pSchema[cols].bytes = pShow->bytes[cols]; +// cols++; pMeta->numOfColumns = cols; pShow->numOfColumns = cols; @@ -1432,9 +1432,9 @@ static int32_t mndRetrieveDbs(SMnodeMsg *pReq, SShowObj *pShow, char *data, int3 STR_WITH_SIZE_TO_VARSTR(pWrite, prec, 2); cols++; - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int8_t *)pWrite = pDb->cfg.update; - cols++; +// pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; +// *(int8_t *)pWrite = pDb->cfg.update; +// cols++; numOfRows++; sdbRelease(pSdb, pDb); From 0299126dfe0d96492a3e88d28e06db4339cff116 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 15 Mar 2022 17:50:20 +0800 Subject: [PATCH 16/38] [td-13039] fix compiler error. --- contrib/CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 3b7b1f3c10..575a0e6274 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -128,7 +128,12 @@ target_include_directories( set(CMAKE_PROJECT_INCLUDE_BEFORE "${CMAKE_SUPPORT_DIR}/EnableCMP0048.txt.in") add_subdirectory(zlib) target_include_directories( - zlibstatic + zlibstatic + PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/zlib + PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/zlib +) +target_include_directories( + zlib PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/zlib PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/zlib ) From 085475acc4a21fb06e0cbd760819cfbd5a5a753c Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 15 Mar 2022 18:14:42 +0800 Subject: [PATCH 17/38] [td-13039] update sim. --- tests/script/tsim/table/basic1.sim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/script/tsim/table/basic1.sim b/tests/script/tsim/table/basic1.sim index 09e6ede77d..257c264159 100644 --- a/tests/script/tsim/table/basic1.sim +++ b/tests/script/tsim/table/basic1.sim @@ -253,7 +253,8 @@ endi print =============== query data from normal table after restart dnode sql use ndb sql select * from nt1 -if $rows != 3 then +if $rows != 3 then + print expect 3, actual: $rows return -1 endi From 5fca3e47dadf41096e0ab2eae1a967afb26465b8 Mon Sep 17 00:00:00 2001 From: Haojun Liao Date: Tue, 15 Mar 2022 18:29:37 +0800 Subject: [PATCH 18/38] [td-13039] update the mnode unit test. --- source/dnode/mnode/impl/test/db/db.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/dnode/mnode/impl/test/db/db.cpp b/source/dnode/mnode/impl/test/db/db.cpp index 9dbc1be4e9..0282663b17 100644 --- a/source/dnode/mnode/impl/test/db/db.cpp +++ b/source/dnode/mnode/impl/test/db/db.cpp @@ -27,7 +27,7 @@ Testbase MndTestDb::test; TEST_F(MndTestDb, 01_ShowDb) { test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); - CHECK_META("show databases", 18); + CHECK_META("show databases", 17); CHECK_SCHEMA(0, TSDB_DATA_TYPE_BINARY, TSDB_DB_NAME_LEN - 1 + VARSTR_HEADER_SIZE, "name"); CHECK_SCHEMA(1, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time"); CHECK_SCHEMA(2, TSDB_DATA_TYPE_SMALLINT, 2, "vgroups"); @@ -45,7 +45,7 @@ TEST_F(MndTestDb, 01_ShowDb) { CHECK_SCHEMA(14, TSDB_DATA_TYPE_TINYINT, 1, "comp"); CHECK_SCHEMA(15, TSDB_DATA_TYPE_TINYINT, 1, "cachelast"); CHECK_SCHEMA(16, TSDB_DATA_TYPE_BINARY, 3 + VARSTR_HEADER_SIZE, "precision"); - CHECK_SCHEMA(17, TSDB_DATA_TYPE_TINYINT, 1, "update"); +// CHECK_SCHEMA(17, TSDB_DATA_TYPE_TINYINT, 1, "update"); test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 0); @@ -85,7 +85,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { } test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); - CHECK_META("show databases", 18); + CHECK_META("show databases", 17); test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); @@ -173,7 +173,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { test.Restart(); test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); - CHECK_META("show databases", 18); + CHECK_META("show databases", 17); test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); @@ -215,7 +215,7 @@ TEST_F(MndTestDb, 02_Create_Alter_Drop_Db) { } test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); - CHECK_META("show databases", 18); + CHECK_META("show databases", 17); test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 0); @@ -255,7 +255,7 @@ TEST_F(MndTestDb, 03_Create_Use_Restart_Use_Db) { } test.SendShowMetaReq(TSDB_MGMT_TABLE_DB, ""); - CHECK_META("show databases", 18); + CHECK_META("show databases", 17); test.SendShowRetrieveReq(); EXPECT_EQ(test.GetShowRows(), 1); From c2aebb25bf5d4c9e023cc93339bcda572637ffde Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Tue, 15 Mar 2022 06:44:38 -0400 Subject: [PATCH 19/38] TD-13675 create sma index parser implement --- include/libs/parser/parser.h | 1 + include/libs/planner/planner.h | 1 + source/client/inc/clientInt.h | 2 + source/client/src/clientImpl.c | 3 -- source/client/src/tmq.c | 14 +++--- source/libs/nodes/src/nodesUtilFuncs.c | 14 ++++++ source/libs/parser/inc/sql.y | 4 +- source/libs/parser/src/parTranslater.c | 56 ++++++++++++----------- source/libs/parser/src/sql.c | 4 +- source/libs/parser/test/parserAstTest.cpp | 2 +- 10 files changed, 58 insertions(+), 43 deletions(-) diff --git a/include/libs/parser/parser.h b/include/libs/parser/parser.h index bf0c963059..77838c705f 100644 --- a/include/libs/parser/parser.h +++ b/include/libs/parser/parser.h @@ -51,6 +51,7 @@ typedef struct SQuery { SSchema* pResSchema; SCmdMsgInfo* pCmdMsg; int32_t msgType; + bool streamQuery; } SQuery; int32_t qParseQuerySql(SParseContext* pCxt, SQuery** pQuery); diff --git a/include/libs/planner/planner.h b/include/libs/planner/planner.h index 07579e0a7d..7eb9d038a5 100644 --- a/include/libs/planner/planner.h +++ b/include/libs/planner/planner.h @@ -26,6 +26,7 @@ typedef struct SPlanContext { uint64_t queryId; int32_t acctId; SNode* pAstRoot; + bool streamQuery; } SPlanContext; // Create the physical plan for the query, according to the AST. diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 321e8ab77b..b672c9bb47 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -21,6 +21,7 @@ extern "C" { #endif #include "parser.h" +#include "planner.h" #include "query.h" #include "taos.h" #include "tcommon.h" @@ -229,6 +230,7 @@ void setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj** pRequest); int32_t parseSql(SRequestObj* pRequest, SQuery** pQuery); +int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArray* pNodeList); // --- heartbeat // global, called by mgmt diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 646b443fb7..fc97f4113c 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -1,8 +1,6 @@ #include "clientInt.h" #include "clientLog.h" -#include "parser.h" -#include "planner.h" #include "scheduler.h" #include "tdatablock.h" #include "tdef.h" @@ -211,7 +209,6 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t } } - int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList) { void* pTransporter = pRequest->pTscObj->pAppInfo->pTransporter; diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index 846329f0f4..0e4c7cdf47 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -482,21 +482,19 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i } tscDebug("start to create topic, %s", topicName); -#if 0 + CHECK_CODE_GOTO(buildRequest(pTscObj, sql, sqlLen, &pRequest), _return); CHECK_CODE_GOTO(parseSql(pRequest, &pQueryNode), _return); - SQueryStmtInfo* pQueryStmtInfo = (SQueryStmtInfo*)pQueryNode; - pQueryStmtInfo->info.continueQuery = true; + pQueryNode->streamQuery = true; // todo check for invalid sql statement and return with error code SSchema* schema = NULL; int32_t numOfCols = 0; - CHECK_CODE_GOTO(qCreateQueryDag(pQueryNode, &pRequest->body.pDag, &schema, &numOfCols, NULL, pRequest->requestId), - _return); + CHECK_CODE_GOTO(getPlan(pRequest, pQueryNode, &pRequest->body.pDag, NULL), _return); - pStr = qDagToString(pRequest->body.pDag); + pStr = qQueryPlanToString(pRequest->body.pDag); if (pStr == NULL) { goto _return; } @@ -506,7 +504,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i // The topic should be related to a database that the queried table is belonged to. SName name = {0}; char dbName[TSDB_DB_FNAME_LEN] = {0}; - tNameGetFullDbName(&((SQueryStmtInfo*)pQueryNode)->pTableMetaInfo[0]->name, dbName); + // tNameGetFullDbName(&((SQueryStmtInfo*)pQueryNode)->pTableMetaInfo[0]->name, dbName); tNameFromString(&name, dbName, T_NAME_ACCT | T_NAME_DB); tNameFromString(&name, topicName, T_NAME_TABLE); @@ -538,7 +536,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i asyncSendMsgToServer(pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo); tsem_wait(&pRequest->body.rspSem); -#endif + _return: qDestroyQuery(pQueryNode); /*if (sendInfo != NULL) {*/ diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index cc99387095..43caa25c3d 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -216,6 +216,14 @@ static EDealRes destroyNode(SNode** pNode, void* pContext) { case QUERY_NODE_NODE_LIST: nodesClearList(((SNodeListNode*)(*pNode))->pNodeList); break; + case QUERY_NODE_INDEX_OPTIONS: { + SIndexOptions* pStmt = (SIndexOptions*)*pNode; + nodesDestroyList(pStmt->pFuncs); + nodesDestroyNode(pStmt->pInterval); + nodesDestroyNode(pStmt->pOffset); + nodesDestroyNode(pStmt->pSliding); + break; + } case QUERY_NODE_SELECT_STMT: { SSelectStmt* pStmt = (SSelectStmt*)*pNode; nodesDestroyList(pStmt->pProjectionList); @@ -256,6 +264,12 @@ static EDealRes destroyNode(SNode** pNode, void* pContext) { case QUERY_NODE_CREATE_MULTI_TABLE_STMT: nodesDestroyList(((SCreateMultiTableStmt*)(*pNode))->pSubTables); break; + case QUERY_NODE_CREATE_INDEX_STMT: { + SCreateIndexStmt* pStmt = (SCreateIndexStmt*)*pNode; + nodesDestroyNode(pStmt->pOptions); + nodesDestroyList(pStmt->pCols); + break; + } default: break; } diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 7515466b47..a9fb0a9f5e 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -197,9 +197,9 @@ cmd ::= CREATE FULLTEXT INDEX index_options(A) ::= . { A = NULL; } index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL - NK_LP duration_literal(C) NK_RP sliding_opt(D). { A = createIndexOption(pCxt, B, C, NULL, D); } + NK_LP duration_literal(C) NK_RP sliding_opt(D). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), NULL, D); } index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL - NK_LP duration_literal(C) NK_COMMA duration_literal(D) NK_RP sliding_opt(E). { A = createIndexOption(pCxt, B, C, D, E); } + NK_LP duration_literal(C) NK_COMMA duration_literal(D) NK_RP sliding_opt(E). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D), E); } %type func_list { SNodeList* } %destructor func_list { nodesDestroyList($$); } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 3fff4fa4ca..dbba590620 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -795,14 +795,14 @@ static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseS buildCreateDbReq(pCxt, pStmt, &createReq); pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_DB; pCxt->pCmdMsg->msgLen = tSerializeSCreateDbReq(NULL, 0, &createReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { return TSDB_CODE_OUT_OF_MEMORY; } tSerializeSCreateDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq); @@ -818,14 +818,14 @@ static int32_t translateDropDatabase(STranslateContext* pCxt, SDropDatabaseStmt* dropReq.ignoreNotExists = pStmt->ignoreNotExists; pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; pCxt->pCmdMsg->msgType = TDMT_MND_DROP_DB; pCxt->pCmdMsg->msgLen = tSerializeSDropDbReq(NULL, 0, &dropReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { return TSDB_CODE_OUT_OF_MEMORY; } tSerializeSDropDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq); @@ -859,7 +859,7 @@ static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableSt tNameExtractFullName(&tableName, createReq.name); pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { tFreeSMCreateStbReq(&createReq); return TSDB_CODE_OUT_OF_MEMORY; } @@ -867,7 +867,7 @@ static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableSt pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_STB; pCxt->pCmdMsg->msgLen = tSerializeSMCreateStbReq(NULL, 0, &createReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { tFreeSMCreateStbReq(&createReq); return TSDB_CODE_OUT_OF_MEMORY; } @@ -883,14 +883,14 @@ static int32_t doTranslateDropSuperTable(STranslateContext* pCxt, const SName* p dropReq.igNotExists = ignoreNotExists; pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; pCxt->pCmdMsg->msgType = TDMT_MND_DROP_STB; pCxt->pCmdMsg->msgLen = tSerializeSMDropStbReq(NULL, 0, &dropReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { return TSDB_CODE_OUT_OF_MEMORY; } tSerializeSMDropStbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq); @@ -936,14 +936,14 @@ static int32_t translateUseDatabase(STranslateContext* pCxt, SUseDatabaseStmt* p catalogGetDBVgVersion(pCxt->pParseCxt->pCatalog, usedbReq.db, &usedbReq.vgVersion, &usedbReq.dbId, &usedbReq.numOfTable); pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; pCxt->pCmdMsg->msgType = TDMT_MND_USE_DB; pCxt->pCmdMsg->msgLen = tSerializeSUseDbReq(NULL, 0, &usedbReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { return TSDB_CODE_OUT_OF_MEMORY; } tSerializeSUseDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &usedbReq); @@ -959,14 +959,14 @@ static int32_t translateCreateUser(STranslateContext* pCxt, SCreateUserStmt* pSt strcpy(createReq.pass, pStmt->password); pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_USER; pCxt->pCmdMsg->msgLen = tSerializeSCreateUserReq(NULL, 0, &createReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { return TSDB_CODE_OUT_OF_MEMORY; } tSerializeSCreateUserReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq); @@ -985,14 +985,14 @@ static int32_t translateAlterUser(STranslateContext* pCxt, SAlterUserStmt* pStmt } pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; pCxt->pCmdMsg->msgType = TDMT_MND_ALTER_USER; pCxt->pCmdMsg->msgLen = tSerializeSAlterUserReq(NULL, 0, &alterReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { return TSDB_CODE_OUT_OF_MEMORY; } tSerializeSAlterUserReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &alterReq); @@ -1005,14 +1005,14 @@ static int32_t translateDropUser(STranslateContext* pCxt, SDropUserStmt* pStmt) strcpy(dropReq.user, pStmt->useName); pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; pCxt->pCmdMsg->msgType = TDMT_MND_DROP_USER; pCxt->pCmdMsg->msgLen = tSerializeSDropUserReq(NULL, 0, &dropReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { return TSDB_CODE_OUT_OF_MEMORY; } tSerializeSDropUserReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq); @@ -1026,14 +1026,14 @@ static int32_t translateCreateDnode(STranslateContext* pCxt, SCreateDnodeStmt* p createReq.port = pStmt->port; pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_DNODE; pCxt->pCmdMsg->msgLen = tSerializeSCreateDnodeReq(NULL, 0, &createReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { return TSDB_CODE_OUT_OF_MEMORY; } tSerializeSCreateDnodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq); @@ -1048,14 +1048,14 @@ static int32_t translateDropDnode(STranslateContext* pCxt, SDropDnodeStmt* pStmt dropReq.port = pStmt->port; pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; pCxt->pCmdMsg->msgType = TDMT_MND_DROP_DNODE; pCxt->pCmdMsg->msgLen = tSerializeSDropDnodeReq(NULL, 0, &dropReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { return TSDB_CODE_OUT_OF_MEMORY; } tSerializeSDropDnodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq); @@ -1093,14 +1093,14 @@ static int32_t translateShow(STranslateContext* pCxt, SShowStmt* pStmt) { } pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; pCxt->pCmdMsg->msgType = TDMT_MND_SHOW; pCxt->pCmdMsg->msgLen = tSerializeSShowReq(NULL, 0, &showReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { return TSDB_CODE_OUT_OF_MEMORY; } tSerializeSShowReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &showReq); @@ -1128,7 +1128,7 @@ static int32_t translateShowTables(STranslateContext* pCxt) { pShowReq->head.vgId = htonl(info->vgId); pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = info->epSet; @@ -1167,23 +1167,25 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt createSmaReq.tSma.tableUid = pMeta->uid; createSmaReq.tSma.interval = ((SValueNode*)pStmt->pOptions->pInterval)->datum.i; createSmaReq.tSma.sliding = (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->datum.i : 0); - code = nodesListToString(pStmt->pCols, false, &createSmaReq.tSma.expr, &createSmaReq.tSma.exprLen); + code = nodesListToString(pStmt->pOptions->pFuncs, false, &createSmaReq.tSma.expr, &createSmaReq.tSma.exprLen); if (TSDB_CODE_SUCCESS != code) { return code; } pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; pCxt->pCmdMsg->msgType = TDMT_VND_CREATE_SMA; pCxt->pCmdMsg->msgLen = tSerializeSVCreateTSmaReq(NULL, &createSmaReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { return TSDB_CODE_OUT_OF_MEMORY; } - tSerializeSVCreateTSmaReq(pCxt->pCmdMsg->pMsg, &createSmaReq); + void* pBuf = pCxt->pCmdMsg->pMsg; + tSerializeSVCreateTSmaReq(&pBuf, &createSmaReq); + // todo clear SVCreateTSmaReq return TSDB_CODE_SUCCESS; } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index ae20ecdd7e..c135d59298 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -2292,10 +2292,10 @@ static YYACTIONTYPE yy_reduce( { yymsp[1].minor.yy344 = NULL; } break; case 97: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ -{ yymsp[-8].minor.yy344 = createIndexOption(pCxt, yymsp[-6].minor.yy280, yymsp[-2].minor.yy344, NULL, yymsp[0].minor.yy344); } +{ yymsp[-8].minor.yy344 = createIndexOption(pCxt, yymsp[-6].minor.yy280, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), NULL, yymsp[0].minor.yy344); } break; case 98: /* 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.yy344 = createIndexOption(pCxt, yymsp[-8].minor.yy280, yymsp[-4].minor.yy344, yymsp[-2].minor.yy344, yymsp[0].minor.yy344); } +{ yymsp[-10].minor.yy344 = createIndexOption(pCxt, yymsp[-8].minor.yy280, releaseRawExprNode(pCxt, yymsp[-4].minor.yy344), releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), yymsp[0].minor.yy344); } break; case 101: /* func ::= function_name NK_LP expression_list NK_RP */ { yylhsminor.yy344 = createFunctionNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy280); } diff --git a/source/libs/parser/test/parserAstTest.cpp b/source/libs/parser/test/parserAstTest.cpp index cf889c0f3c..119e94dde9 100644 --- a/source/libs/parser/test/parserAstTest.cpp +++ b/source/libs/parser/test/parserAstTest.cpp @@ -402,6 +402,6 @@ TEST_F(ParserTest, createTable) { TEST_F(ParserTest, createSmaIndex) { setDatabase("root", "test"); - bind("create sma index index1 on t1 function(max(c1), min(c3 + 10), sum(c4))"); + bind("create sma index index1 on t1 function(max(c1), min(c3 + 10), sum(c4)) INTERVAL(10s)"); ASSERT_TRUE(run()); } From 607a7ac025b432a3c2722f7cb075555ef4e4b31b Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Tue, 15 Mar 2022 19:54:06 +0800 Subject: [PATCH 20/38] handle except and update UT --- include/libs/transport/trpc.h | 12 +- source/libs/transport/inc/transComm.h | 7 +- source/libs/transport/inc/transportInt.h | 1 + source/libs/transport/src/trans.c | 1 + source/libs/transport/src/transCli.c | 32 +++-- source/libs/transport/src/transSrv.c | 4 +- source/libs/transport/test/transUT.cc | 157 +++++++++++++++++++---- 7 files changed, 167 insertions(+), 47 deletions(-) diff --git a/include/libs/transport/trpc.h b/include/libs/transport/trpc.h index 8dfd736df6..231bc4af45 100644 --- a/include/libs/transport/trpc.h +++ b/include/libs/transport/trpc.h @@ -29,7 +29,6 @@ extern "C" { extern int tsRpcHeadSize; - typedef struct SRpcConnInfo { uint32_t clientIp; uint16_t clientPort; @@ -46,7 +45,6 @@ typedef struct SRpcMsg { void * ahandle; // app handle set by client } SRpcMsg; - typedef struct SRpcInit { uint16_t localPort; // local port char * label; // for debug purpose @@ -71,9 +69,11 @@ typedef struct SRpcInit { // call back to keep conn or not bool (*pfp)(void *parent, tmsg_t msgType); - // to support Send messages multiple times on a link - // - void* (*mfp)(void *parent, tmsg_t msgType); + // to support Send messages multiple times on a link + void *(*mfp)(void *parent, tmsg_t msgType); + + // call back to handle except when query/fetch in progress + void (*efp)(void *parent, tmsg_t msgType); void *parent; } SRpcInit; @@ -94,7 +94,7 @@ int rpcReportProgress(void *pConn, char *pCont, int contLen); void rpcCancelRequest(int64_t rid); // just release client conn to rpc instance, no close sock -void rpcReleaseHandle(void *handle); +void rpcReleaseHandle(void *handle); void rpcRefHandle(void *handle, int8_t type); void rpcUnrefHandle(void *handle, int8_t type); diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index 99f890d3a0..76347cdba2 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -125,9 +125,8 @@ typedef SRpcInfo STrans; typedef SRpcConnInfo STransHandleInfo; typedef struct { - SEpSet epSet; // ip list provided by app - void* ahandle; // handle provided by app - // struct SRpcConn* pConn; // pConn allocated + SEpSet epSet; // ip list provided by app + void* ahandle; // handle provided by app tmsg_t msgType; // message type uint8_t* pCont; // content provided by app int32_t contLen; // content length @@ -135,7 +134,7 @@ typedef struct { // int16_t numOfTry; // number of try for different servers // int8_t oldInUse; // server EP inUse passed by app // int8_t redirect; // flag to indicate redirect - int8_t connType; // connection type + int8_t connType; // connection type cli/srv int64_t rid; // refId returned by taosAddRef STransMsg* pRsp; // for synchronous API diff --git a/source/libs/transport/inc/transportInt.h b/source/libs/transport/inc/transportInt.h index 3924a5cf1a..e760fe1de9 100644 --- a/source/libs/transport/inc/transportInt.h +++ b/source/libs/transport/inc/transportInt.h @@ -65,6 +65,7 @@ typedef struct { int (*afp)(void* parent, char* user, char* spi, char* encrypt, char* secret, char* ckey); bool (*pfp)(void* parent, tmsg_t msgType); void* (*mfp)(void* parent, tmsg_t msgType); + void (*efp)(void* parent, tmsg_t msgType); int32_t refCount; void* parent; diff --git a/source/libs/transport/src/trans.c b/source/libs/transport/src/trans.c index 58809ee3be..213782c5bd 100644 --- a/source/libs/transport/src/trans.c +++ b/source/libs/transport/src/trans.c @@ -36,6 +36,7 @@ void* rpcOpen(const SRpcInit* pInit) { pRpc->afp = pInit->afp; pRpc->pfp = pInit->pfp; pRpc->mfp = pInit->mfp; + pRpc->efp = pInit->efp; if (pInit->connType == TAOS_CONN_SERVER) { pRpc->numOfThreads = pInit->numOfThreads > TSDB_MAX_RPC_THREADS ? TSDB_MAX_RPC_THREADS : pInit->numOfThreads; diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 2f6ff3763f..5c50ca2bc3 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -34,6 +34,10 @@ typedef struct SCliConn { // spi configure char spi; char secured; + + char* ip; + uint32_t port; + // debug and log info struct sockaddr_in addr; struct sockaddr_in locaddr; @@ -79,7 +83,7 @@ typedef struct SConnList { static void* createConnPool(int size); static void* destroyConnPool(void* pool); static SCliConn* getConnFromPool(void* pool, char* ip, uint32_t port); -static void addConnToPool(void* pool, char* ip, uint32_t port, SCliConn* conn); +static void addConnToPool(void* pool, SCliConn* conn); // register timer in each thread to clear expire conn static void cliTimeoutCb(uv_timer_t* handle); @@ -188,6 +192,12 @@ void cliHandleResp(SCliConn* conn) { conn->secured = pHead->secured; + if (pCtx == NULL && CONN_NO_PERSIST_BY_APP(conn)) { + tTrace("except, server continue send while cli ignore it"); + // transUnrefCliHandle(conn); + return; + } + if (pCtx == NULL || pCtx->pSem == NULL) { tTrace("%s cli conn %p handle resp", pTransInst->label, conn); (pTransInst->cfp)(pTransInst->parent, &transMsg, NULL); @@ -197,14 +207,13 @@ void cliHandleResp(SCliConn* conn) { tsem_post(pCtx->pSem); } - uv_read_start((uv_stream_t*)conn->stream, cliAllocRecvBufferCb, cliRecvCb); - if (CONN_NO_PERSIST_BY_APP(conn)) { - addConnToPool(pThrd->pool, pCtx->ip, pCtx->port, conn); + addConnToPool(pThrd->pool, conn); } destroyCmsg(conn->data); conn->data = NULL; + uv_read_start((uv_stream_t*)conn->stream, cliAllocRecvBufferCb, cliRecvCb); // start thread's timer of conn pool if not active if (!uv_is_active((uv_handle_t*)&pThrd->timer) && pTransInst->idleTime > 0) { // uv_timer_start((uv_timer_t*)&pThrd->timer, cliTimeoutCb, CONN_PERSIST_TIME(pRpc->idleTime) / 2, 0); @@ -317,11 +326,11 @@ static SCliConn* getConnFromPool(void* pool, char* ip, uint32_t port) { QUEUE_INIT(&conn->conn); return conn; } -static void addConnToPool(void* pool, char* ip, uint32_t port, SCliConn* conn) { +static void addConnToPool(void* pool, SCliConn* conn) { char key[128] = {0}; - tstrncpy(key, ip, strlen(ip)); - tstrncpy(key + strlen(key), (char*)(&port), sizeof(port)); + tstrncpy(key, conn->ip, strlen(conn->ip)); + tstrncpy(key + strlen(key), (char*)(&conn->port), sizeof(conn->port)); tTrace("cli conn %p added to conn pool, read buf cap: %d", conn, conn->readBuf.cap); STrans* pTransInst = ((SCliThrdObj*)conn->hostThrd)->pTransInst; @@ -395,7 +404,7 @@ static void cliDestroyConn(SCliConn* conn, bool clear) { } static void cliDestroy(uv_handle_t* handle) { SCliConn* conn = handle->data; - + free(conn->ip); free(conn->stream); tTrace("%s cli conn %p destroy successfully", CONN_GET_INST_LABEL(conn), conn); free(conn); @@ -524,11 +533,16 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) { SCliConn* conn = cliGetConn(pMsg, pThrd); if (conn != NULL) { conn->data = pMsg; + conn->hThrdIdx = pCtx->hThrdIdx; + transDestroyBuffer(&conn->readBuf); cliSend(conn); } else { conn = cliCreateConn(pThrd); conn->data = pMsg; + conn->hThrdIdx = pCtx->hThrdIdx; + conn->ip = strdup(pMsg->ctx->ip); + conn->port = pMsg->ctx->port; int ret = transSetConnOption((uv_tcp_t*)conn->stream); if (ret) { @@ -540,8 +554,6 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) { tTrace("%s cli conn %p try to connect to %s:%d", pTransInst->label, conn, pMsg->ctx->ip, pMsg->ctx->port); uv_tcp_connect(&conn->connReq, (uv_tcp_t*)(conn->stream), (const struct sockaddr*)&addr, cliConnCb); } - - conn->hThrdIdx = pCtx->hThrdIdx; } static void cliAsyncCb(uv_async_t* handle) { SAsyncItem* item = handle->data; diff --git a/source/libs/transport/src/transSrv.c b/source/libs/transport/src/transSrv.c index cb3bbaefec..a3cc6b6181 100644 --- a/source/libs/transport/src/transSrv.c +++ b/source/libs/transport/src/transSrv.c @@ -289,11 +289,13 @@ void uvOnSendCb(uv_write_t* req, int status) { if (conn->srvMsgs != NULL) { assert(taosArrayGetSize(conn->srvMsgs) >= 1); SSrvMsg* msg = taosArrayGetP(conn->srvMsgs, 0); + tTrace("server conn %p sending msg size: %d", conn, (int)taosArrayGetSize(conn->srvMsgs)); taosArrayRemove(conn->srvMsgs, 0); destroySmsg(msg); // send second data, just use for push if (taosArrayGetSize(conn->srvMsgs) > 0) { + tTrace("resent server conn %p sending msg size: %d", conn, (int)taosArrayGetSize(conn->srvMsgs)); msg = (SSrvMsg*)taosArrayGetP(conn->srvMsgs, 0); uvStartSendRespInternal(msg); } @@ -733,7 +735,7 @@ void destroyWorkThrd(SWorkThrdObj* pThrd) { } void sendQuitToWorkThrd(SWorkThrdObj* pThrd) { SSrvMsg* srvMsg = calloc(1, sizeof(SSrvMsg)); - tDebug("send quit msg to work thread"); + tDebug("server send quit msg to work thread"); transSendAsync(pThrd->asyncPool, &srvMsg->q); } diff --git a/source/libs/transport/test/transUT.cc b/source/libs/transport/test/transUT.cc index fa20327003..b0fae2f8b4 100644 --- a/source/libs/transport/test/transUT.cc +++ b/source/libs/transport/test/transUT.cc @@ -29,7 +29,29 @@ const char *ckey = "ckey"; class Server; int port = 7000; // server process + +static bool cliPersistHandle(void *parent, tmsg_t msgType) { + // client persist handle + return msgType == 2 || msgType == 4; +} + +typedef struct CbArgs { + tmsg_t msgType; +} CbArgs; + +static void *ConstructArgForSpecificMsgType(void *parent, tmsg_t msgType) { + if (msgType == 1 || msgType == 2) { + CbArgs *args = (CbArgs *)calloc(1, sizeof(CbArgs)); + args->msgType = msgType; + return args; + } + return NULL; +} +// server except +static void NotifyAppLinkBroken(void *parent, tmsg_t msgType) {} typedef void (*CB)(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet); + +static void processContinueSend(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet); static void processReq(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet); // client process; static void processResp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet); @@ -61,17 +83,17 @@ class Client { rpcInit_.cfp = cb; this->transCli = rpcOpen(&rpcInit_); } - void setPersistFP(bool (*pfp)(void *parent, tmsg_t msgType)) { + void SetPersistFP(bool (*pfp)(void *parent, tmsg_t msgType)) { rpcClose(this->transCli); rpcInit_.pfp = pfp; this->transCli = rpcOpen(&rpcInit_); } - void setConstructFP(void *(*mfp)(void *parent, tmsg_t msgType)) { + void SetConstructFP(void *(*mfp)(void *parent, tmsg_t msgType)) { rpcClose(this->transCli); rpcInit_.mfp = mfp; this->transCli = rpcOpen(&rpcInit_); } - void setPAndMFp(bool (*pfp)(void *parent, tmsg_t msgType), void *(*mfp)(void *parent, tmsg_t msgType)) { + void SetPAndMFp(bool (*pfp)(void *parent, tmsg_t msgType), void *(*mfp)(void *parent, tmsg_t msgType)) { rpcClose(this->transCli); rpcInit_.pfp = pfp; @@ -88,6 +110,7 @@ class Client { SemWait(); *resp = this->resp; } + void SendWithHandle(SRpcMsg *req, SRpcMsg *resp) {} void SemWait() { tsem_wait(&this->sem); } void SemPost() { tsem_post(&this->sem); } void Reset() {} @@ -105,19 +128,20 @@ class Client { class Server { public: Server() { - memset(&rpcInit, 0, sizeof(rpcInit)); - rpcInit.localPort = port; - rpcInit.label = (char *)label; - rpcInit.numOfThreads = 5; - rpcInit.cfp = processReq; - rpcInit.user = (char *)user; - rpcInit.secret = (char *)secret; - rpcInit.ckey = (char *)ckey; - rpcInit.spi = 1; - rpcInit.connType = TAOS_CONN_SERVER; + memset(&rpcInit_, 0, sizeof(rpcInit_)); + rpcInit_.localPort = port; + rpcInit_.label = (char *)label; + rpcInit_.numOfThreads = 5; + rpcInit_.cfp = processReq; + rpcInit_.efp = NULL; + rpcInit_.user = (char *)user; + rpcInit_.secret = (char *)secret; + rpcInit_.ckey = (char *)ckey; + rpcInit_.spi = 1; + rpcInit_.connType = TAOS_CONN_SERVER; } void Start() { - this->transSrv = rpcOpen(&this->rpcInit); + this->transSrv = rpcOpen(&this->rpcInit_); taosMsleep(1000); } void Stop() { @@ -125,6 +149,16 @@ class Server { rpcClose(this->transSrv); this->transSrv = NULL; } + void SetExceptFp(void (*efp)(void *parent, tmsg_t msgType)) { + this->Stop(); + rpcInit_.efp = efp; + this->Start(); + } + void SetSrvContinueSend(void (*cfp)(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet)) { + this->Stop(); + rpcInit_.cfp = cfp; + this->Start(); + } void Restart() { this->Stop(); this->Start(); @@ -135,7 +169,7 @@ class Server { } private: - SRpcInit rpcInit; + SRpcInit rpcInit_; void * transSrv; }; static void processReq(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { @@ -146,6 +180,20 @@ static void processReq(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { rpcMsg.code = 0; rpcSendResponse(&rpcMsg); } + +static void processContinueSend(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { + for (int i = 0; i < 9; i++) { + rpcRefHandle(pMsg->handle, TAOS_CONN_SERVER); + } + for (int i = 0; i < 10; i++) { + SRpcMsg rpcMsg = {0}; + rpcMsg.pCont = rpcMallocCont(100); + rpcMsg.contLen = 100; + rpcMsg.handle = pMsg->handle; + rpcMsg.code = 0; + rpcSendResponse(&rpcMsg); + } +} // client process; static void processResp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { Client *client = (Client *)parent; @@ -170,7 +218,7 @@ static void initEnv() { tsAsyncLog = 0; std::string path = "/tmp/transport"; - taosRemoveDir(path.c_str()); + // taosRemoveDir(path.c_str()); taosMkDir(path.c_str()); tstrncpy(tsLogDir, path.c_str(), PATH_MAX); @@ -178,6 +226,7 @@ static void initEnv() { printf("failed to init log file\n"); } } + class TransObj { public: TransObj() { @@ -188,22 +237,38 @@ class TransObj { srv->Start(); } - void RestartCli(CB cb) { cli->Restart(cb); } - void StopSrv() { srv->Stop(); } + void RestartCli(CB cb) { + // + cli->Restart(cb); + } + void StopSrv() { + // + srv->Stop(); + } void SetCliPersistFp(bool (*pfp)(void *parent, tmsg_t msgType)) { // do nothing - cli->setPersistFP(pfp); + cli->SetPersistFP(pfp); } void SetCliMFp(void *(*mfp)(void *parent, tmsg_t msgType)) { // do nothing - cli->setConstructFP(mfp); + cli->SetConstructFP(mfp); } - void SetMAndPFp(bool (*pfp)(void *parent, tmsg_t msgType), void *(*mfp)(void *parent, tmsg_t msgType)) { + void SetCliMAndPFp(bool (*pfp)(void *parent, tmsg_t msgType), void *(*mfp)(void *parent, tmsg_t msgType)) { // do nothing - cli->setPAndMFp(pfp, mfp); + cli->SetPAndMFp(pfp, mfp); + } + // call when link broken, and notify query or fetch stop + void SetSrvExceptFp(void (*efp)(void *parent, tmsg_t msgType)) { + //////// + srv->SetExceptFp(efp); + } + void SetSrvContinueSend(void (*cfp)(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet)) { + /////// + srv->SetSrvContinueSend(cfp); } void RestartSrv() { srv->Restart(); } void cliSendAndRecv(SRpcMsg *req, SRpcMsg *resp) { cli->SendAndRecv(req, resp); } + ~TransObj() { delete cli; delete srv; @@ -256,13 +321,50 @@ TEST_F(TransEnv, 02StopServer) { tr->cliSendAndRecv(&req, &resp); assert(resp.code != 0); } -TEST_F(TransEnv, clientUserDefined) {} +TEST_F(TransEnv, clientUserDefined) { + tr->RestartSrv(); + for (int i = 0; i < 10; i++) { + SRpcMsg req = {0}, resp = {0}; + req.msgType = 0; + req.pCont = rpcMallocCont(10); + req.contLen = 10; + tr->cliSendAndRecv(&req, &resp); + assert(resp.code == 0); + } + + ////////////////// +} TEST_F(TransEnv, cliPersistHandle) { - // impl late + tr->SetCliPersistFp(cliPersistHandle); + SRpcMsg resp = {0}; + for (int i = 0; i < 10; i++) { + SRpcMsg req = {.handle = resp.handle}; + req.msgType = 1; + req.pCont = rpcMallocCont(10); + req.contLen = 10; + tr->cliSendAndRecv(&req, &resp); + if (i == 5) { + std::cout << "stop server" << std::endl; + tr->StopSrv(); + } + if (i >= 6) { + EXPECT_TRUE(resp.code != 0); + } + } + + ////////////////// } -TEST_F(TransEnv, srvPersistHandle) { - // impl later +TEST_F(TransEnv, srvContinueSend) { + tr->SetSrvContinueSend(processContinueSend); + for (int i = 0; i < 10; i++) { + SRpcMsg req = {0}, resp = {0}; + req.msgType = 1; + req.pCont = rpcMallocCont(10); + req.contLen = 10; + tr->cliSendAndRecv(&req, &resp); + } + taosMsleep(2000); } TEST_F(TransEnv, srvPersisHandleExcept) { @@ -282,3 +384,6 @@ TEST_F(TransEnv, multiSrvPersisHandleExcept) { TEST_F(TransEnv, queryExcept) { // query and conn is broken } +TEST_F(TransEnv, noResp) { + // no resp +} From bd60e92f298b08914c0bcd600854bf4da80eefbe Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Tue, 15 Mar 2022 20:04:19 +0800 Subject: [PATCH 21/38] add stream scheduler --- include/dnode/snode/snode.h | 3 - include/util/tdef.h | 23 ++++--- source/client/src/tmq.c | 2 +- source/dnode/mnode/impl/inc/mndDef.h | 14 +++- source/dnode/mnode/impl/src/mndScheduler.c | 79 +++++++++++++++++++++- source/dnode/snode/inc/sndInt.h | 8 +-- source/util/src/tuuid.c | 2 - 7 files changed, 106 insertions(+), 25 deletions(-) diff --git a/include/dnode/snode/snode.h b/include/dnode/snode/snode.h index 9dcd58a05f..21a93532e0 100644 --- a/include/dnode/snode/snode.h +++ b/include/dnode/snode/snode.h @@ -23,9 +23,6 @@ extern "C" { #endif -#define SND_UNIQUE_THREAD_NUM 2 -#define SND_SHARED_THREAD_NUM 2 - /* ------------------------ TYPES EXPOSED ------------------------ */ typedef struct SDnode SDnode; typedef struct SSnode SSnode; diff --git a/include/util/tdef.h b/include/util/tdef.h index a53b81894a..41a61ceb55 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -345,19 +345,19 @@ typedef enum ELogicConditionType { #define TSDB_MAX_DB_QUORUM_OPTION 2 #define TSDB_DEFAULT_DB_QUORUM_OPTION 1 -#define TSDB_MIN_DB_TTL_OPTION 1 -#define TSDB_DEFAULT_DB_TTL_OPTION 0 +#define TSDB_MIN_DB_TTL_OPTION 1 +#define TSDB_DEFAULT_DB_TTL_OPTION 0 -#define TSDB_MIN_DB_SINGLE_STABLE_OPTION 0 -#define TSDB_MAX_DB_SINGLE_STABLE_OPTION 1 -#define TSDB_DEFAULT_DB_SINGLE_STABLE_OPTION 0 +#define TSDB_MIN_DB_SINGLE_STABLE_OPTION 0 +#define TSDB_MAX_DB_SINGLE_STABLE_OPTION 1 +#define TSDB_DEFAULT_DB_SINGLE_STABLE_OPTION 0 -#define TSDB_MIN_DB_STREAM_MODE_OPTION 0 -#define TSDB_MAX_DB_STREAM_MODE_OPTION 1 -#define TSDB_DEFAULT_DB_STREAM_MODE_OPTION 0 +#define TSDB_MIN_DB_STREAM_MODE_OPTION 0 +#define TSDB_MAX_DB_STREAM_MODE_OPTION 1 +#define TSDB_DEFAULT_DB_STREAM_MODE_OPTION 0 -#define TSDB_MAX_JOIN_TABLE_NUM 10 -#define TSDB_MAX_UNION_CLAUSE 5 +#define TSDB_MAX_JOIN_TABLE_NUM 10 +#define TSDB_MAX_UNION_CLAUSE 5 #define TSDB_MIN_DB_UPDATE 0 #define TSDB_MAX_DB_UPDATE 2 @@ -445,6 +445,9 @@ typedef struct { #define TMQ_SEPARATOR ':' +#define SND_UNIQUE_THREAD_NUM 2 +#define SND_SHARED_THREAD_NUM 2 + #ifdef __cplusplus } #endif diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index 846329f0f4..2e2c44951e 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -459,7 +459,7 @@ void tmq_conf_set_offset_commit_cb(tmq_conf_t* conf, tmq_commit_cb* cb) { conf-> TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, int sqlLen) { STscObj* pTscObj = (STscObj*)taos; SRequestObj* pRequest = NULL; - SQuery* pQueryNode = NULL; + SQuery* pQueryNode = NULL; char* pStr = NULL; terrno = TSDB_CODE_SUCCESS; diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 9ed6104140..a7116b72ff 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -679,6 +679,12 @@ static FORCE_INLINE void* tDecodeSMqConsumerObj(void* buf, SMqConsumerObj* pCons return buf; } +typedef struct { + int32_t taskId; + int32_t level; + SSubplan* plan; +} SStreamTaskMeta; + typedef struct { char name[TSDB_TOPIC_FNAME_LEN]; char db[TSDB_DB_FNAME_LEN]; @@ -687,12 +693,14 @@ typedef struct { int64_t uid; int64_t dbUid; int32_t version; + int32_t vgNum; SRWLatch lock; int8_t status; // int32_t sqlLen; - char* sql; - char* logicalPlan; - char* physicalPlan; + char* sql; + char* logicalPlan; + char* physicalPlan; + SArray* tasks; // SArray> } SStreamObj; int32_t tEncodeSStreamObj(SCoder* pEncoder, const SStreamObj* pObj); diff --git a/source/dnode/mnode/impl/src/mndScheduler.c b/source/dnode/mnode/impl/src/mndScheduler.c index e827810cc9..855e244daa 100644 --- a/source/dnode/mnode/impl/src/mndScheduler.c +++ b/source/dnode/mnode/impl/src/mndScheduler.c @@ -21,6 +21,7 @@ #include "mndOffset.h" #include "mndShow.h" #include "mndStb.h" +#include "mndStream.h" #include "mndSubscribe.h" #include "mndTopic.h" #include "mndTrans.h" @@ -28,10 +29,84 @@ #include "mndVgroup.h" #include "tcompare.h" #include "tname.h" +#include "tuuid.h" + +int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) { + SSdb* pSdb = pMnode->pSdb; + SVgObj* pVgroup = NULL; + SQueryPlan* pPlan = qStringToQueryPlan(pStream->physicalPlan); + if (pPlan == NULL) { + terrno = TSDB_CODE_QRY_INVALID_INPUT; + return -1; + } + ASSERT(pStream->vgNum == 0); + + int32_t levelNum = LIST_LENGTH(pPlan->pSubplans); + pStream->tasks = taosArrayInit(levelNum, sizeof(SArray)); + + for (int32_t i = 0; i < levelNum; i++) { + SArray* taskOneLevel = taosArrayInit(0, sizeof(SStreamTaskMeta)); + SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, i); + int32_t opNum = LIST_LENGTH(inner->pNodeList); + ASSERT(opNum == 1); + + SSubplan* plan = nodesListGetNode(inner->pNodeList, 0); + if (i == 0) { + ASSERT(plan->type == SUBPLAN_TYPE_SCAN); + void* pIter = NULL; + while (1) { + pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void**)&pVgroup); + if (pIter == NULL) break; + if (pVgroup->dbUid != pStream->dbUid) { + sdbRelease(pSdb, pVgroup); + continue; + } + + pStream->vgNum++; + plan->execNode.nodeId = pVgroup->vgId; + plan->execNode.epSet = mndGetVgroupEpset(pMnode, pVgroup); + SStreamTaskMeta task = { + .taskId = tGenIdPI32(), + .level = i, + .plan = plan, + }; + // send to vnode + taosArrayPush(taskOneLevel, &task); + } + } else if (plan->subplanType == SUBPLAN_TYPE_SCAN) { + // duplicatable + + int32_t parallel = 0; + // if no snode, parallel set to fetch thread num in vnode + + // if has snode, set to shared thread num in snode + parallel = SND_SHARED_THREAD_NUM; + + for (int32_t j = 0; j < parallel; j++) { + SStreamTaskMeta task = { + .taskId = tGenIdPI32(), + .level = i, + .plan = plan, + }; + taosArrayPush(taskOneLevel, &task); + } + } else { + // not duplicatable + SStreamTaskMeta task = { + .taskId = tGenIdPI32(), + .level = i, + .plan = plan, + }; + taosArrayPush(taskOneLevel, &task); + } + taosArrayPush(pStream->tasks, taskOneLevel); + } + return 0; +} int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscribeObj* pSub) { - SSdb* pSdb = pMnode->pSdb; - SVgObj* pVgroup = NULL; + SSdb* pSdb = pMnode->pSdb; + SVgObj* pVgroup = NULL; SQueryPlan* pPlan = qStringToQueryPlan(pTopic->physicalPlan); if (pPlan == NULL) { terrno = TSDB_CODE_QRY_INVALID_INPUT; diff --git a/source/dnode/snode/inc/sndInt.h b/source/dnode/snode/inc/sndInt.h index ffe691aeb4..3fe816845d 100644 --- a/source/dnode/snode/inc/sndInt.h +++ b/source/dnode/snode/inc/sndInt.h @@ -67,11 +67,11 @@ typedef struct { // storage handle } SStreamTask; -int32_t sndCreateStream(); -int32_t sndDropStream(); +int32_t sndCreateTask(); +int32_t sndDropTaskOfStream(int64_t streamId); -int32_t sndStopStream(); -int32_t sndResumeStream(); +int32_t sndStopTaskOfStream(int64_t streamId); +int32_t sndResumeTaskOfStream(int64_t streamId); #ifdef __cplusplus } diff --git a/source/util/src/tuuid.c b/source/util/src/tuuid.c index 0405403220..ceca33436a 100644 --- a/source/util/src/tuuid.c +++ b/source/util/src/tuuid.c @@ -24,7 +24,6 @@ int32_t tGenIdPI32(void) { int32_t code = taosGetSystemUUID(uid, tListLen(uid)); if (code != TSDB_CODE_SUCCESS) { terrno = TAOS_SYSTEM_ERROR(errno); - return -1; } else { hashId = MurmurHash3_32(uid, strlen(uid)); } @@ -44,7 +43,6 @@ int64_t tGenIdPI64(void) { int32_t code = taosGetSystemUUID(uid, tListLen(uid)); if (code != TSDB_CODE_SUCCESS) { terrno = TAOS_SYSTEM_ERROR(errno); - return -1; } else { hashId = MurmurHash3_32(uid, strlen(uid)); } From 4281664e03eafd364ec4ffd91ee163c3cea9495b Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Tue, 15 Mar 2022 08:04:52 -0400 Subject: [PATCH 22/38] TD-14068 create qnode implement --- include/common/ttokendef.h | 212 +- include/libs/nodes/cmdnodes.h | 5 + include/libs/nodes/nodes.h | 2 + source/libs/nodes/src/nodesUtilFuncs.c | 3 + source/libs/parser/inc/parAst.h | 1 + source/libs/parser/inc/sql.y | 4 + source/libs/parser/src/parAstCreater.c | 7 + source/libs/parser/src/parTokenizer.c | 2 + source/libs/parser/src/parTranslater.c | 27 +- source/libs/parser/src/sql.c | 3177 +++++++++++---------- source/libs/parser/test/parserAstTest.cpp | 7 + 11 files changed, 1753 insertions(+), 1694 deletions(-) diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 6745b80ac0..5693091bd5 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -48,111 +48,113 @@ #define TK_DNODES 30 #define TK_NK_ID 31 #define TK_NK_IPTOKEN 32 -#define TK_DATABASE 33 -#define TK_DATABASES 34 -#define TK_USE 35 -#define TK_IF 36 -#define TK_NOT 37 -#define TK_EXISTS 38 -#define TK_BLOCKS 39 -#define TK_CACHE 40 -#define TK_CACHELAST 41 -#define TK_COMP 42 -#define TK_DAYS 43 -#define TK_FSYNC 44 -#define TK_MAXROWS 45 -#define TK_MINROWS 46 -#define TK_KEEP 47 -#define TK_PRECISION 48 -#define TK_QUORUM 49 -#define TK_REPLICA 50 -#define TK_TTL 51 -#define TK_WAL 52 -#define TK_VGROUPS 53 -#define TK_SINGLE_STABLE 54 -#define TK_STREAM_MODE 55 -#define TK_TABLE 56 -#define TK_NK_LP 57 -#define TK_NK_RP 58 -#define TK_STABLE 59 -#define TK_TABLES 60 -#define TK_STABLES 61 -#define TK_USING 62 -#define TK_TAGS 63 -#define TK_NK_DOT 64 -#define TK_NK_COMMA 65 -#define TK_COMMENT 66 -#define TK_BOOL 67 -#define TK_TINYINT 68 -#define TK_SMALLINT 69 -#define TK_INT 70 -#define TK_INTEGER 71 -#define TK_BIGINT 72 -#define TK_FLOAT 73 -#define TK_DOUBLE 74 -#define TK_BINARY 75 -#define TK_TIMESTAMP 76 -#define TK_NCHAR 77 -#define TK_UNSIGNED 78 -#define TK_JSON 79 -#define TK_VARCHAR 80 -#define TK_MEDIUMBLOB 81 -#define TK_BLOB 82 -#define TK_VARBINARY 83 -#define TK_DECIMAL 84 -#define TK_SMA 85 -#define TK_INDEX 86 -#define TK_ON 87 -#define TK_FULLTEXT 88 -#define TK_FUNCTION 89 -#define TK_INTERVAL 90 -#define TK_MNODES 91 -#define TK_NK_FLOAT 92 -#define TK_NK_BOOL 93 -#define TK_NK_VARIABLE 94 -#define TK_BETWEEN 95 -#define TK_IS 96 -#define TK_NULL 97 -#define TK_NK_LT 98 -#define TK_NK_GT 99 -#define TK_NK_LE 100 -#define TK_NK_GE 101 -#define TK_NK_NE 102 -#define TK_NK_EQ 103 -#define TK_LIKE 104 -#define TK_MATCH 105 -#define TK_NMATCH 106 -#define TK_IN 107 -#define TK_FROM 108 -#define TK_AS 109 -#define TK_JOIN 110 -#define TK_INNER 111 -#define TK_SELECT 112 -#define TK_DISTINCT 113 -#define TK_WHERE 114 -#define TK_PARTITION 115 -#define TK_BY 116 -#define TK_SESSION 117 -#define TK_STATE_WINDOW 118 -#define TK_SLIDING 119 -#define TK_FILL 120 -#define TK_VALUE 121 -#define TK_NONE 122 -#define TK_PREV 123 -#define TK_LINEAR 124 -#define TK_NEXT 125 -#define TK_GROUP 126 -#define TK_HAVING 127 -#define TK_ORDER 128 -#define TK_SLIMIT 129 -#define TK_SOFFSET 130 -#define TK_LIMIT 131 -#define TK_OFFSET 132 -#define TK_ASC 133 -#define TK_DESC 134 -#define TK_NULLS 135 -#define TK_FIRST 136 -#define TK_LAST 137 +#define TK_QNODE 33 +#define TK_ON 34 +#define TK_QNODES 35 +#define TK_DATABASE 36 +#define TK_DATABASES 37 +#define TK_USE 38 +#define TK_IF 39 +#define TK_NOT 40 +#define TK_EXISTS 41 +#define TK_BLOCKS 42 +#define TK_CACHE 43 +#define TK_CACHELAST 44 +#define TK_COMP 45 +#define TK_DAYS 46 +#define TK_FSYNC 47 +#define TK_MAXROWS 48 +#define TK_MINROWS 49 +#define TK_KEEP 50 +#define TK_PRECISION 51 +#define TK_QUORUM 52 +#define TK_REPLICA 53 +#define TK_TTL 54 +#define TK_WAL 55 +#define TK_VGROUPS 56 +#define TK_SINGLE_STABLE 57 +#define TK_STREAM_MODE 58 +#define TK_TABLE 59 +#define TK_NK_LP 60 +#define TK_NK_RP 61 +#define TK_STABLE 62 +#define TK_TABLES 63 +#define TK_STABLES 64 +#define TK_USING 65 +#define TK_TAGS 66 +#define TK_NK_DOT 67 +#define TK_NK_COMMA 68 +#define TK_COMMENT 69 +#define TK_BOOL 70 +#define TK_TINYINT 71 +#define TK_SMALLINT 72 +#define TK_INT 73 +#define TK_INTEGER 74 +#define TK_BIGINT 75 +#define TK_FLOAT 76 +#define TK_DOUBLE 77 +#define TK_BINARY 78 +#define TK_TIMESTAMP 79 +#define TK_NCHAR 80 +#define TK_UNSIGNED 81 +#define TK_JSON 82 +#define TK_VARCHAR 83 +#define TK_MEDIUMBLOB 84 +#define TK_BLOB 85 +#define TK_VARBINARY 86 +#define TK_DECIMAL 87 +#define TK_SMA 88 +#define TK_INDEX 89 +#define TK_FULLTEXT 90 +#define TK_FUNCTION 91 +#define TK_INTERVAL 92 +#define TK_MNODES 93 +#define TK_NK_FLOAT 94 +#define TK_NK_BOOL 95 +#define TK_NK_VARIABLE 96 +#define TK_BETWEEN 97 +#define TK_IS 98 +#define TK_NULL 99 +#define TK_NK_LT 100 +#define TK_NK_GT 101 +#define TK_NK_LE 102 +#define TK_NK_GE 103 +#define TK_NK_NE 104 +#define TK_NK_EQ 105 +#define TK_LIKE 106 +#define TK_MATCH 107 +#define TK_NMATCH 108 +#define TK_IN 109 +#define TK_FROM 110 +#define TK_AS 111 +#define TK_JOIN 112 +#define TK_INNER 113 +#define TK_SELECT 114 +#define TK_DISTINCT 115 +#define TK_WHERE 116 +#define TK_PARTITION 117 +#define TK_BY 118 +#define TK_SESSION 119 +#define TK_STATE_WINDOW 120 +#define TK_SLIDING 121 +#define TK_FILL 122 +#define TK_VALUE 123 +#define TK_NONE 124 +#define TK_PREV 125 +#define TK_LINEAR 126 +#define TK_NEXT 127 +#define TK_GROUP 128 +#define TK_HAVING 129 +#define TK_ORDER 130 +#define TK_SLIMIT 131 +#define TK_SOFFSET 132 +#define TK_LIMIT 133 +#define TK_OFFSET 134 +#define TK_ASC 135 +#define TK_DESC 136 +#define TK_NULLS 137 +#define TK_FIRST 138 +#define TK_LAST 139 #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 aa539667e4..21d9ff83c8 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -179,6 +179,11 @@ typedef struct SCreateIndexStmt { SIndexOptions* pOptions; } SCreateIndexStmt; +typedef struct SCreateQnodeStmt { + ENodeType type; + int32_t dnodeId; +} SCreateQnodeStmt; + #ifdef __cplusplus } #endif diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 46b89416b7..cf34c6665a 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -96,7 +96,9 @@ typedef enum ENodeType { QUERY_NODE_SHOW_DNODES_STMT, QUERY_NODE_SHOW_VGROUPS_STMT, QUERY_NODE_SHOW_MNODES_STMT, + QUERY_NODE_SHOW_QNODES_STMT, QUERY_NODE_CREATE_INDEX_STMT, + QUERY_NODE_CREATE_QNODE_STMT, // logic plan node QUERY_NODE_LOGIC_PLAN_SCAN, diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 43caa25c3d..b17a4904da 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -127,9 +127,12 @@ SNodeptr nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SShowStmt)); case QUERY_NODE_SHOW_VGROUPS_STMT: case QUERY_NODE_SHOW_MNODES_STMT: + case QUERY_NODE_SHOW_QNODES_STMT: return makeNode(type, sizeof(SShowStmt)); case QUERY_NODE_CREATE_INDEX_STMT: return makeNode(type, sizeof(SCreateIndexStmt)); + case QUERY_NODE_CREATE_QNODE_STMT: + return makeNode(type, sizeof(SCreateQnodeStmt)); case QUERY_NODE_LOGIC_PLAN_SCAN: return makeNode(type, sizeof(SScanLogicNode)); case QUERY_NODE_LOGIC_PLAN_JOIN: diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index bb22e5703d..f2fcced1a9 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -134,6 +134,7 @@ SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode); SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, const SToken* pIndexName, const SToken* pTableName, SNodeList* pCols, SNode* pOptions); SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding); +SNode* createCreateQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId); #ifdef __cplusplus } diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index a9fb0a9f5e..af2fb12c52 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -64,6 +64,10 @@ dnode_endpoint(A) ::= NK_STRING(B). dnode_host_name(A) ::= NK_ID(B). { A = B; } dnode_host_name(A) ::= NK_IPTOKEN(B). { A = B; } +/************************************************ create qnode ********************************************************/ +cmd ::= CREATE QNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createCreateQnodeStmt(pCxt, &A); } +cmd ::= SHOW QNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT, NULL); } + /************************************************ create/drop/show/use database ***************************************/ cmd ::= CREATE DATABASE not_exists_opt(A) db_name(B) db_options(C). { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, A, &B, C);} cmd ::= DROP DATABASE exists_opt(A) db_name(B). { pCxt->pRootNode = createDropDatabaseStmt(pCxt, A, &B); } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 994ca53a0f..b7ecf160fd 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -1021,3 +1021,10 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt pOptions->pSliding = pSliding; return (SNode*)pOptions; } + +SNode* createCreateQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId) { + SCreateQnodeStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_QNODE_STMT); + CHECK_OUT_OF_MEM(pStmt); + pStmt->dnodeId = strtol(pDnodeId->z, NULL, 10);; + return (SNode*)pStmt; +} diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 57ff6d53a4..4d50d92d9e 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -99,6 +99,8 @@ static SKeyword keywordTable[] = { {"PRECISION", TK_PRECISION}, {"PRIVILEGE", TK_PRIVILEGE}, {"PREV", TK_PREV}, + {"QNODE", TK_QNODE}, + {"QNODES", TK_QNODES}, {"QUORUM", TK_QUORUM}, {"REPLICA", TK_REPLICA}, {"SELECT", TK_SELECT}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index dbba590620..4f89e7e703 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -1077,6 +1077,8 @@ static int32_t nodeTypeToShowType(ENodeType nt) { return TSDB_MGMT_TABLE_VGROUP; case QUERY_NODE_SHOW_MNODES_STMT: return TSDB_MGMT_TABLE_MNODE; + case QUERY_NODE_SHOW_QNODES_STMT: + return TSDB_MGMT_TABLE_QNODE; default: break; } @@ -1185,7 +1187,7 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt } void* pBuf = pCxt->pCmdMsg->pMsg; tSerializeSVCreateTSmaReq(&pBuf, &createSmaReq); - // todo clear SVCreateTSmaReq + tdDestroyTSma(&createSmaReq.tSma); return TSDB_CODE_SUCCESS; } @@ -1199,6 +1201,25 @@ static int32_t translateCreateIndex(STranslateContext* pCxt, SCreateIndexStmt* p } } +static int32_t translateCreateQnode(STranslateContext* pCxt, SCreateQnodeStmt* pStmt) { + SMCreateQnodeReq createReq = { .dnodeId = pStmt->dnodeId }; + + pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); + if (NULL == pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_DND_CREATE_QNODE; + pCxt->pCmdMsg->msgLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq); + pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); + if (NULL == pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + tSerializeSMCreateDropQSBNodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq); + + return TSDB_CODE_SUCCESS; +} + static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pNode)) { @@ -1244,6 +1265,7 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_SHOW_DNODES_STMT: case QUERY_NODE_SHOW_VGROUPS_STMT: case QUERY_NODE_SHOW_MNODES_STMT: + case QUERY_NODE_SHOW_QNODES_STMT: code = translateShow(pCxt, (SShowStmt*)pNode); break; case QUERY_NODE_SHOW_TABLES_STMT: @@ -1252,6 +1274,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_CREATE_INDEX_STMT: code = translateCreateIndex(pCxt, (SCreateIndexStmt*)pNode); break; + case QUERY_NODE_CREATE_QNODE_STMT: + code = translateCreateQnode(pCxt, (SCreateQnodeStmt*)pNode); + break; default: break; } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index c135d59298..8b46d3600b 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -99,22 +99,22 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned char -#define YYNOCODE 216 +#define YYNOCODE 218 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - EOrder yy2; - EJoinType yy36; - SToken yy209; - ENullOrder yy217; - EOperatorType yy236; - SNodeList* yy280; - bool yy281; - SDataType yy304; - EFillMode yy342; - SNode* yy344; + SToken yy5; + bool yy25; + SNodeList* yy40; + ENullOrder yy53; + EOrder yy54; + SNode* yy68; + EJoinType yy92; + EFillMode yy94; + SDataType yy372; + EOperatorType yy416; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -129,17 +129,17 @@ typedef union { #define ParseCTX_PARAM #define ParseCTX_FETCH #define ParseCTX_STORE -#define YYNSTATE 308 -#define YYNRULE 246 -#define YYNTOKEN 138 -#define YY_MAX_SHIFT 307 -#define YY_MIN_SHIFTREDUCE 475 -#define YY_MAX_SHIFTREDUCE 720 -#define YY_ERROR_ACTION 721 -#define YY_ACCEPT_ACTION 722 -#define YY_NO_ACTION 723 -#define YY_MIN_REDUCE 724 -#define YY_MAX_REDUCE 969 +#define YYNSTATE 313 +#define YYNRULE 248 +#define YYNTOKEN 140 +#define YY_MAX_SHIFT 312 +#define YY_MIN_SHIFTREDUCE 480 +#define YY_MAX_SHIFTREDUCE 727 +#define YY_ERROR_ACTION 728 +#define YY_ACCEPT_ACTION 729 +#define YY_NO_ACTION 730 +#define YY_MIN_REDUCE 731 +#define YY_MAX_REDUCE 978 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -206,318 +206,307 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (1037) +#define YY_ACTTAB_COUNT (963) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 152, 235, 276, 862, 835, 251, 251, 167, 185, 775, - /* 10 */ 838, 835, 31, 29, 27, 26, 25, 837, 835, 208, - /* 20 */ 778, 778, 165, 178, 837, 31, 29, 27, 26, 25, - /* 30 */ 737, 39, 9, 8, 780, 70, 151, 145, 61, 817, - /* 40 */ 250, 815, 773, 235, 251, 862, 235, 248, 862, 164, - /* 50 */ 145, 835, 823, 238, 237, 24, 109, 847, 603, 778, - /* 60 */ 58, 848, 851, 887, 212, 662, 10, 886, 883, 300, - /* 70 */ 299, 298, 297, 296, 295, 294, 293, 292, 291, 290, - /* 80 */ 289, 288, 287, 286, 285, 284, 304, 303, 250, 639, - /* 90 */ 31, 29, 27, 26, 25, 23, 159, 592, 621, 622, - /* 100 */ 623, 624, 625, 626, 627, 629, 630, 631, 23, 159, - /* 110 */ 186, 621, 622, 623, 624, 625, 626, 627, 629, 630, - /* 120 */ 631, 31, 29, 27, 26, 25, 535, 274, 273, 272, - /* 130 */ 539, 271, 541, 542, 270, 544, 267, 20, 550, 264, - /* 140 */ 552, 553, 261, 258, 235, 87, 862, 31, 29, 27, - /* 150 */ 26, 25, 835, 75, 766, 237, 213, 223, 847, 86, - /* 160 */ 82, 56, 848, 851, 887, 54, 948, 603, 144, 883, - /* 170 */ 250, 130, 219, 65, 661, 195, 770, 134, 71, 947, - /* 180 */ 948, 593, 40, 946, 222, 84, 862, 64, 83, 764, - /* 190 */ 186, 583, 835, 81, 39, 237, 10, 946, 847, 581, - /* 200 */ 223, 57, 848, 851, 887, 774, 62, 207, 154, 883, - /* 210 */ 76, 716, 717, 27, 26, 25, 102, 894, 218, 485, - /* 220 */ 217, 166, 105, 948, 817, 283, 815, 189, 200, 914, - /* 230 */ 222, 125, 862, 283, 214, 209, 81, 594, 835, 60, - /* 240 */ 946, 237, 485, 277, 847, 124, 252, 57, 848, 851, - /* 250 */ 887, 82, 486, 487, 154, 883, 76, 251, 226, 235, - /* 260 */ 249, 862, 582, 584, 587, 82, 251, 835, 55, 122, - /* 270 */ 237, 120, 778, 847, 106, 915, 57, 848, 851, 887, - /* 280 */ 169, 778, 205, 154, 883, 960, 99, 235, 251, 862, - /* 290 */ 722, 172, 780, 70, 921, 835, 171, 247, 237, 127, - /* 300 */ 199, 847, 808, 778, 57, 848, 851, 887, 780, 70, - /* 310 */ 595, 154, 883, 960, 48, 104, 235, 188, 862, 21, - /* 320 */ 30, 28, 944, 173, 835, 771, 220, 237, 628, 583, - /* 330 */ 847, 632, 230, 57, 848, 851, 887, 581, 765, 161, - /* 340 */ 154, 883, 960, 6, 901, 12, 948, 30, 28, 663, - /* 350 */ 170, 905, 901, 817, 863, 815, 583, 917, 901, 81, - /* 360 */ 235, 898, 862, 946, 581, 1, 161, 658, 835, 897, - /* 370 */ 234, 237, 12, 223, 847, 896, 670, 133, 848, 851, - /* 380 */ 227, 824, 238, 225, 252, 280, 30, 28, 91, 279, - /* 390 */ 781, 70, 1, 592, 108, 583, 948, 30, 28, 231, - /* 400 */ 582, 584, 587, 581, 281, 161, 583, 174, 817, 81, - /* 410 */ 816, 252, 194, 946, 581, 192, 161, 906, 658, 196, - /* 420 */ 82, 2, 12, 278, 590, 684, 68, 582, 584, 587, - /* 430 */ 618, 7, 59, 96, 633, 235, 763, 862, 9, 8, - /* 440 */ 94, 32, 1, 835, 600, 228, 237, 719, 720, 847, - /* 450 */ 252, 32, 58, 848, 851, 887, 30, 28, 236, 233, - /* 460 */ 883, 252, 842, 30, 28, 583, 582, 584, 587, 840, - /* 470 */ 38, 53, 583, 581, 576, 161, 50, 582, 584, 587, - /* 480 */ 581, 32, 161, 280, 187, 85, 82, 279, 30, 28, - /* 490 */ 190, 184, 235, 596, 862, 183, 590, 583, 150, 182, - /* 500 */ 835, 7, 281, 237, 197, 581, 847, 161, 7, 72, - /* 510 */ 848, 851, 114, 591, 206, 219, 243, 119, 179, 112, - /* 520 */ 252, 278, 528, 66, 67, 181, 180, 252, 523, 68, - /* 530 */ 64, 597, 556, 1, 198, 59, 582, 584, 587, 256, - /* 540 */ 595, 560, 918, 582, 584, 587, 224, 961, 67, 62, - /* 550 */ 565, 928, 252, 241, 92, 69, 175, 68, 221, 77, - /* 560 */ 894, 895, 67, 899, 235, 587, 862, 203, 582, 584, - /* 570 */ 587, 95, 835, 927, 153, 237, 5, 98, 847, 908, - /* 580 */ 74, 58, 848, 851, 887, 100, 235, 687, 862, 884, - /* 590 */ 202, 4, 216, 63, 835, 658, 594, 237, 160, 902, - /* 600 */ 847, 945, 33, 138, 848, 851, 101, 155, 235, 232, - /* 610 */ 862, 204, 685, 686, 688, 689, 835, 963, 229, 237, - /* 620 */ 201, 107, 847, 17, 869, 138, 848, 851, 822, 239, - /* 630 */ 244, 235, 126, 862, 240, 49, 821, 47, 123, 835, - /* 640 */ 307, 254, 237, 245, 116, 847, 163, 128, 137, 848, - /* 650 */ 851, 235, 142, 862, 246, 129, 779, 143, 829, 835, - /* 660 */ 176, 177, 237, 740, 235, 847, 862, 828, 72, 848, - /* 670 */ 851, 827, 835, 494, 738, 237, 158, 191, 847, 215, - /* 680 */ 826, 138, 848, 851, 769, 768, 235, 739, 862, 31, - /* 690 */ 29, 27, 26, 25, 835, 88, 193, 237, 162, 733, - /* 700 */ 847, 728, 767, 138, 848, 851, 962, 732, 731, 727, - /* 710 */ 726, 235, 219, 862, 725, 819, 41, 89, 90, 835, - /* 720 */ 3, 14, 237, 93, 683, 847, 32, 64, 136, 848, - /* 730 */ 851, 235, 210, 862, 36, 73, 97, 211, 42, 835, - /* 740 */ 677, 676, 237, 43, 15, 847, 62, 34, 139, 848, - /* 750 */ 851, 655, 840, 235, 19, 862, 78, 894, 895, 35, - /* 760 */ 899, 835, 654, 16, 237, 11, 705, 847, 44, 103, - /* 770 */ 131, 848, 851, 704, 710, 235, 80, 862, 156, 709, - /* 780 */ 708, 157, 8, 835, 601, 110, 237, 619, 13, 847, - /* 790 */ 18, 113, 140, 848, 851, 818, 111, 681, 235, 115, - /* 800 */ 862, 242, 45, 46, 117, 118, 835, 839, 585, 237, - /* 810 */ 50, 121, 847, 37, 255, 132, 848, 851, 235, 557, - /* 820 */ 862, 253, 168, 257, 534, 554, 835, 259, 260, 237, - /* 830 */ 551, 235, 847, 862, 262, 141, 848, 851, 263, 835, - /* 840 */ 545, 265, 237, 266, 268, 847, 543, 269, 859, 848, - /* 850 */ 851, 549, 548, 235, 547, 862, 546, 275, 51, 52, - /* 860 */ 564, 835, 563, 562, 237, 506, 492, 847, 513, 512, - /* 870 */ 858, 848, 851, 282, 511, 510, 509, 508, 235, 507, - /* 880 */ 862, 505, 504, 503, 502, 501, 835, 500, 499, 237, - /* 890 */ 498, 497, 847, 730, 301, 857, 848, 851, 235, 302, - /* 900 */ 862, 729, 724, 305, 306, 723, 835, 723, 723, 237, - /* 910 */ 723, 723, 847, 723, 723, 148, 848, 851, 723, 723, - /* 920 */ 235, 723, 862, 723, 723, 723, 723, 723, 835, 723, - /* 930 */ 723, 237, 723, 723, 847, 723, 723, 147, 848, 851, - /* 940 */ 723, 723, 235, 723, 862, 723, 723, 723, 723, 723, - /* 950 */ 835, 723, 723, 237, 723, 723, 847, 723, 723, 149, - /* 960 */ 848, 851, 723, 723, 723, 235, 723, 862, 723, 723, - /* 970 */ 723, 723, 723, 835, 723, 219, 237, 723, 723, 847, - /* 980 */ 723, 723, 146, 848, 851, 235, 723, 862, 723, 723, - /* 990 */ 64, 723, 723, 835, 723, 723, 237, 723, 723, 847, - /* 1000 */ 723, 723, 135, 848, 851, 723, 723, 723, 723, 62, - /* 1010 */ 723, 723, 723, 723, 723, 723, 723, 723, 723, 79, - /* 1020 */ 894, 895, 22, 899, 723, 723, 723, 723, 723, 723, - /* 1030 */ 723, 723, 31, 29, 27, 26, 25, + /* 0 */ 152, 236, 277, 871, 844, 252, 252, 167, 186, 784, + /* 10 */ 847, 844, 31, 29, 27, 26, 25, 846, 844, 209, + /* 20 */ 787, 787, 309, 308, 846, 31, 29, 27, 26, 25, + /* 30 */ 746, 236, 151, 871, 106, 826, 39, 824, 251, 844, + /* 40 */ 145, 957, 238, 61, 236, 856, 871, 782, 57, 857, + /* 50 */ 860, 896, 910, 145, 956, 154, 892, 969, 955, 187, + /* 60 */ 164, 610, 213, 832, 239, 166, 930, 10, 826, 907, + /* 70 */ 824, 251, 301, 300, 299, 298, 297, 296, 295, 294, + /* 80 */ 293, 292, 291, 290, 289, 288, 287, 286, 285, 599, + /* 90 */ 31, 29, 27, 26, 25, 24, 109, 23, 159, 228, + /* 100 */ 628, 629, 630, 631, 632, 633, 634, 636, 637, 638, + /* 110 */ 23, 159, 39, 628, 629, 630, 631, 632, 633, 634, + /* 120 */ 636, 637, 638, 783, 542, 275, 274, 273, 546, 272, + /* 130 */ 548, 549, 271, 551, 268, 165, 557, 265, 559, 560, + /* 140 */ 262, 259, 236, 54, 871, 694, 251, 789, 70, 252, + /* 150 */ 844, 65, 249, 238, 779, 224, 856, 208, 214, 56, + /* 160 */ 857, 860, 896, 229, 787, 601, 144, 892, 775, 205, + /* 170 */ 692, 693, 695, 696, 220, 10, 910, 82, 957, 31, + /* 180 */ 29, 27, 26, 25, 215, 210, 223, 170, 871, 64, + /* 190 */ 826, 81, 824, 906, 844, 955, 600, 238, 773, 826, + /* 200 */ 856, 825, 224, 57, 857, 860, 896, 187, 62, 910, + /* 210 */ 154, 892, 76, 723, 724, 27, 26, 25, 102, 903, + /* 220 */ 219, 220, 218, 284, 105, 957, 905, 729, 610, 82, + /* 230 */ 201, 923, 87, 223, 21, 871, 64, 284, 81, 227, + /* 240 */ 75, 844, 955, 635, 238, 104, 639, 856, 490, 86, + /* 250 */ 57, 857, 860, 896, 197, 62, 190, 154, 892, 76, + /* 260 */ 173, 68, 236, 278, 871, 78, 903, 904, 127, 908, + /* 270 */ 844, 817, 40, 238, 252, 84, 856, 250, 924, 57, + /* 280 */ 857, 860, 896, 957, 9, 8, 154, 892, 969, 787, + /* 290 */ 236, 48, 871, 178, 30, 28, 81, 953, 844, 206, + /* 300 */ 955, 238, 780, 590, 856, 833, 239, 57, 857, 860, + /* 310 */ 896, 588, 6, 161, 154, 892, 969, 30, 28, 670, + /* 320 */ 169, 99, 12, 790, 70, 914, 590, 31, 29, 27, + /* 330 */ 26, 25, 789, 70, 588, 774, 161, 189, 490, 236, + /* 340 */ 602, 871, 1, 677, 646, 12, 53, 844, 491, 492, + /* 350 */ 238, 50, 224, 856, 30, 28, 133, 857, 860, 252, + /* 360 */ 599, 253, 122, 590, 252, 1, 226, 172, 915, 665, + /* 370 */ 235, 588, 590, 161, 787, 957, 589, 591, 594, 787, + /* 380 */ 588, 171, 12, 926, 253, 281, 30, 28, 81, 280, + /* 390 */ 669, 665, 955, 789, 70, 590, 82, 9, 8, 589, + /* 400 */ 591, 594, 1, 588, 282, 161, 691, 96, 236, 195, + /* 410 */ 871, 130, 193, 59, 94, 196, 844, 134, 71, 238, + /* 420 */ 91, 253, 856, 279, 221, 58, 857, 860, 896, 625, + /* 430 */ 253, 83, 895, 892, 7, 872, 589, 591, 594, 108, + /* 440 */ 236, 2, 871, 597, 174, 589, 591, 594, 844, 772, + /* 450 */ 231, 238, 188, 253, 856, 38, 640, 58, 857, 860, + /* 460 */ 896, 726, 727, 32, 234, 892, 30, 28, 589, 591, + /* 470 */ 594, 85, 30, 28, 237, 590, 236, 603, 871, 607, + /* 480 */ 191, 590, 150, 588, 844, 161, 32, 238, 82, 588, + /* 490 */ 856, 161, 198, 72, 857, 860, 30, 28, 20, 281, + /* 500 */ 598, 668, 604, 280, 602, 590, 207, 82, 31, 29, + /* 510 */ 27, 26, 25, 588, 7, 161, 232, 199, 282, 927, + /* 520 */ 7, 851, 242, 92, 236, 937, 871, 583, 849, 594, + /* 530 */ 225, 970, 844, 253, 32, 238, 160, 279, 856, 253, + /* 540 */ 114, 138, 857, 860, 1, 204, 936, 112, 589, 591, + /* 550 */ 594, 244, 95, 119, 589, 591, 594, 236, 66, 871, + /* 560 */ 67, 5, 153, 253, 917, 844, 217, 98, 238, 203, + /* 570 */ 74, 856, 4, 63, 58, 857, 860, 896, 589, 591, + /* 580 */ 594, 665, 893, 236, 220, 871, 535, 100, 601, 530, + /* 590 */ 911, 844, 33, 68, 238, 202, 59, 856, 101, 64, + /* 600 */ 138, 857, 860, 236, 155, 871, 563, 972, 233, 567, + /* 610 */ 954, 844, 572, 257, 238, 107, 67, 856, 62, 68, + /* 620 */ 137, 857, 860, 17, 230, 236, 831, 871, 79, 903, + /* 630 */ 904, 878, 908, 844, 245, 47, 238, 49, 240, 856, + /* 640 */ 241, 69, 72, 857, 860, 236, 830, 871, 67, 163, + /* 650 */ 126, 216, 246, 844, 116, 788, 238, 158, 236, 856, + /* 660 */ 871, 255, 138, 857, 860, 247, 844, 128, 123, 238, + /* 670 */ 162, 312, 856, 125, 185, 138, 857, 860, 184, 597, + /* 680 */ 971, 60, 129, 183, 22, 182, 142, 305, 143, 838, + /* 690 */ 124, 236, 749, 871, 31, 29, 27, 26, 25, 844, + /* 700 */ 176, 177, 238, 837, 179, 856, 836, 835, 136, 857, + /* 710 */ 860, 181, 180, 55, 778, 236, 120, 871, 777, 748, + /* 720 */ 745, 740, 735, 844, 776, 501, 238, 747, 739, 856, + /* 730 */ 738, 734, 139, 857, 860, 236, 733, 871, 192, 732, + /* 740 */ 828, 175, 248, 844, 200, 41, 238, 194, 88, 856, + /* 750 */ 89, 90, 131, 857, 860, 236, 3, 871, 32, 14, + /* 760 */ 93, 36, 690, 844, 73, 97, 238, 211, 42, 856, + /* 770 */ 212, 684, 140, 857, 860, 236, 683, 871, 849, 15, + /* 780 */ 19, 34, 11, 844, 662, 43, 238, 44, 236, 856, + /* 790 */ 871, 712, 132, 857, 860, 661, 844, 711, 156, 238, + /* 800 */ 35, 716, 856, 717, 103, 141, 857, 860, 80, 715, + /* 810 */ 157, 16, 236, 8, 871, 110, 608, 13, 18, 113, + /* 820 */ 844, 111, 688, 238, 115, 236, 856, 871, 827, 868, + /* 830 */ 857, 860, 117, 844, 626, 45, 238, 243, 236, 856, + /* 840 */ 871, 118, 867, 857, 860, 46, 844, 50, 592, 238, + /* 850 */ 37, 848, 856, 121, 220, 866, 857, 860, 254, 256, + /* 860 */ 236, 564, 871, 168, 258, 260, 561, 261, 844, 64, + /* 870 */ 558, 238, 263, 236, 856, 871, 264, 148, 857, 860, + /* 880 */ 552, 844, 266, 267, 238, 550, 269, 856, 62, 270, + /* 890 */ 147, 857, 860, 236, 556, 871, 555, 222, 77, 903, + /* 900 */ 904, 844, 908, 554, 238, 541, 553, 856, 276, 51, + /* 910 */ 149, 857, 860, 236, 52, 871, 571, 570, 569, 499, + /* 920 */ 283, 844, 520, 519, 238, 518, 744, 856, 517, 516, + /* 930 */ 146, 857, 860, 236, 515, 871, 514, 513, 512, 511, + /* 940 */ 510, 844, 509, 508, 238, 303, 507, 856, 506, 505, + /* 950 */ 135, 857, 860, 504, 302, 304, 737, 306, 307, 736, + /* 960 */ 731, 310, 311, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 155, 158, 161, 160, 166, 143, 143, 155, 146, 146, - /* 10 */ 172, 166, 12, 13, 14, 15, 16, 172, 166, 176, - /* 20 */ 158, 158, 147, 143, 172, 12, 13, 14, 15, 16, - /* 30 */ 0, 145, 1, 2, 159, 160, 157, 37, 152, 160, - /* 40 */ 31, 162, 156, 158, 143, 160, 158, 146, 160, 165, - /* 50 */ 37, 166, 168, 169, 169, 179, 180, 172, 58, 158, - /* 60 */ 175, 176, 177, 178, 176, 4, 57, 182, 183, 39, - /* 70 */ 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - /* 80 */ 50, 51, 52, 53, 54, 55, 140, 141, 31, 58, - /* 90 */ 12, 13, 14, 15, 16, 95, 96, 31, 98, 99, - /* 100 */ 100, 101, 102, 103, 104, 105, 106, 107, 95, 96, - /* 110 */ 36, 98, 99, 100, 101, 102, 103, 104, 105, 106, - /* 120 */ 107, 12, 13, 14, 15, 16, 67, 68, 69, 70, - /* 130 */ 71, 72, 73, 74, 75, 76, 77, 2, 79, 80, - /* 140 */ 81, 82, 83, 84, 158, 19, 160, 12, 13, 14, - /* 150 */ 15, 16, 166, 27, 0, 169, 31, 171, 172, 33, - /* 160 */ 112, 175, 176, 177, 178, 142, 194, 58, 182, 183, - /* 170 */ 31, 18, 143, 150, 113, 22, 153, 24, 25, 207, - /* 180 */ 194, 31, 56, 211, 158, 59, 160, 158, 35, 0, - /* 190 */ 36, 21, 166, 207, 145, 169, 57, 211, 172, 29, - /* 200 */ 171, 175, 176, 177, 178, 156, 177, 90, 182, 183, - /* 210 */ 184, 133, 134, 14, 15, 16, 187, 188, 189, 21, - /* 220 */ 191, 157, 196, 194, 160, 36, 162, 29, 202, 203, - /* 230 */ 158, 19, 160, 36, 117, 118, 207, 31, 166, 27, - /* 240 */ 211, 169, 21, 63, 172, 33, 76, 175, 176, 177, - /* 250 */ 178, 112, 31, 32, 182, 183, 184, 143, 3, 158, - /* 260 */ 146, 160, 92, 93, 94, 112, 143, 166, 56, 146, - /* 270 */ 169, 59, 158, 172, 214, 203, 175, 176, 177, 178, - /* 280 */ 147, 158, 205, 182, 183, 184, 199, 158, 143, 160, - /* 290 */ 138, 146, 159, 160, 193, 166, 147, 85, 169, 148, - /* 300 */ 88, 172, 151, 158, 175, 176, 177, 178, 159, 160, - /* 310 */ 31, 182, 183, 184, 142, 109, 158, 140, 160, 95, - /* 320 */ 12, 13, 193, 171, 166, 153, 192, 169, 104, 21, - /* 330 */ 172, 107, 65, 175, 176, 177, 178, 29, 0, 31, - /* 340 */ 182, 183, 184, 87, 173, 37, 194, 12, 13, 14, - /* 350 */ 157, 193, 173, 160, 160, 162, 21, 174, 173, 207, - /* 360 */ 158, 190, 160, 211, 29, 57, 31, 111, 166, 190, - /* 370 */ 37, 169, 37, 171, 172, 190, 14, 175, 176, 177, - /* 380 */ 65, 168, 169, 128, 76, 47, 12, 13, 109, 51, - /* 390 */ 159, 160, 57, 31, 208, 21, 194, 12, 13, 132, - /* 400 */ 92, 93, 94, 29, 66, 31, 21, 143, 160, 207, - /* 410 */ 162, 76, 20, 211, 29, 23, 31, 110, 111, 58, - /* 420 */ 112, 195, 37, 85, 31, 58, 65, 92, 93, 94, - /* 430 */ 97, 57, 65, 58, 58, 158, 0, 160, 1, 2, - /* 440 */ 65, 65, 57, 166, 58, 130, 169, 136, 137, 172, - /* 450 */ 76, 65, 175, 176, 177, 178, 12, 13, 14, 182, - /* 460 */ 183, 76, 57, 12, 13, 21, 92, 93, 94, 64, - /* 470 */ 145, 57, 21, 29, 58, 31, 62, 92, 93, 94, - /* 480 */ 29, 65, 31, 47, 143, 145, 112, 51, 12, 13, - /* 490 */ 139, 26, 158, 31, 160, 30, 31, 21, 139, 34, - /* 500 */ 166, 57, 66, 169, 158, 29, 172, 31, 57, 175, - /* 510 */ 176, 177, 58, 31, 120, 143, 58, 58, 53, 65, - /* 520 */ 76, 85, 58, 65, 65, 60, 61, 76, 58, 65, - /* 530 */ 158, 31, 58, 57, 163, 65, 92, 93, 94, 65, - /* 540 */ 31, 58, 174, 92, 93, 94, 212, 213, 65, 177, - /* 550 */ 58, 204, 76, 119, 167, 58, 91, 65, 186, 187, - /* 560 */ 188, 189, 65, 191, 158, 94, 160, 166, 92, 93, - /* 570 */ 94, 167, 166, 204, 166, 169, 127, 200, 172, 201, - /* 580 */ 198, 175, 176, 177, 178, 197, 158, 97, 160, 183, - /* 590 */ 115, 114, 126, 158, 166, 111, 31, 169, 170, 173, - /* 600 */ 172, 210, 108, 175, 176, 177, 185, 135, 158, 131, - /* 610 */ 160, 121, 122, 123, 124, 125, 166, 215, 129, 169, - /* 620 */ 170, 209, 172, 57, 181, 175, 176, 177, 167, 166, - /* 630 */ 89, 158, 151, 160, 166, 57, 167, 142, 142, 166, - /* 640 */ 139, 154, 169, 164, 158, 172, 166, 143, 175, 176, - /* 650 */ 177, 158, 149, 160, 163, 144, 158, 149, 0, 166, - /* 660 */ 53, 64, 169, 0, 158, 172, 160, 0, 175, 176, - /* 670 */ 177, 0, 166, 38, 0, 169, 170, 21, 172, 206, - /* 680 */ 0, 175, 176, 177, 0, 0, 158, 0, 160, 12, - /* 690 */ 13, 14, 15, 16, 166, 19, 21, 169, 170, 0, - /* 700 */ 172, 0, 0, 175, 176, 177, 213, 0, 0, 0, - /* 710 */ 0, 158, 143, 160, 0, 0, 57, 87, 86, 166, - /* 720 */ 65, 116, 169, 58, 58, 172, 65, 158, 175, 176, - /* 730 */ 177, 158, 29, 160, 65, 57, 57, 65, 57, 166, - /* 740 */ 58, 58, 169, 57, 116, 172, 177, 110, 175, 176, - /* 750 */ 177, 58, 64, 158, 65, 160, 187, 188, 189, 65, - /* 760 */ 191, 166, 58, 65, 169, 116, 29, 172, 4, 64, - /* 770 */ 175, 176, 177, 29, 58, 158, 64, 160, 29, 29, - /* 780 */ 29, 29, 2, 166, 58, 64, 169, 97, 57, 172, - /* 790 */ 57, 57, 175, 176, 177, 0, 58, 58, 158, 57, - /* 800 */ 160, 90, 57, 57, 87, 86, 166, 64, 21, 169, - /* 810 */ 62, 64, 172, 57, 29, 175, 176, 177, 158, 58, - /* 820 */ 160, 63, 29, 57, 21, 58, 166, 29, 57, 169, - /* 830 */ 58, 158, 172, 160, 29, 175, 176, 177, 57, 166, - /* 840 */ 58, 29, 169, 57, 29, 172, 58, 57, 175, 176, - /* 850 */ 177, 78, 78, 158, 78, 160, 78, 66, 57, 57, - /* 860 */ 29, 166, 29, 21, 169, 21, 38, 172, 29, 29, - /* 870 */ 175, 176, 177, 37, 29, 29, 29, 29, 158, 29, - /* 880 */ 160, 29, 29, 29, 29, 29, 166, 29, 29, 169, - /* 890 */ 29, 29, 172, 0, 29, 175, 176, 177, 158, 28, - /* 900 */ 160, 0, 0, 21, 20, 216, 166, 216, 216, 169, - /* 910 */ 216, 216, 172, 216, 216, 175, 176, 177, 216, 216, - /* 920 */ 158, 216, 160, 216, 216, 216, 216, 216, 166, 216, - /* 930 */ 216, 169, 216, 216, 172, 216, 216, 175, 176, 177, - /* 940 */ 216, 216, 158, 216, 160, 216, 216, 216, 216, 216, - /* 950 */ 166, 216, 216, 169, 216, 216, 172, 216, 216, 175, - /* 960 */ 176, 177, 216, 216, 216, 158, 216, 160, 216, 216, - /* 970 */ 216, 216, 216, 166, 216, 143, 169, 216, 216, 172, - /* 980 */ 216, 216, 175, 176, 177, 158, 216, 160, 216, 216, - /* 990 */ 158, 216, 216, 166, 216, 216, 169, 216, 216, 172, - /* 1000 */ 216, 216, 175, 176, 177, 216, 216, 216, 216, 177, - /* 1010 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 187, - /* 1020 */ 188, 189, 2, 191, 216, 216, 216, 216, 216, 216, - /* 1030 */ 216, 216, 12, 13, 14, 15, 16, 216, 216, 216, - /* 1040 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1050 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1060 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1070 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1080 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1090 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1100 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1110 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1120 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1130 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1140 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1150 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1160 */ 216, + /* 0 */ 157, 160, 163, 162, 168, 145, 145, 157, 148, 148, + /* 10 */ 174, 168, 12, 13, 14, 15, 16, 174, 168, 178, + /* 20 */ 160, 160, 142, 143, 174, 12, 13, 14, 15, 16, + /* 30 */ 0, 160, 159, 162, 216, 162, 147, 164, 31, 168, + /* 40 */ 40, 196, 171, 154, 160, 174, 162, 158, 177, 178, + /* 50 */ 179, 180, 175, 40, 209, 184, 185, 186, 213, 39, + /* 60 */ 167, 61, 178, 170, 171, 159, 195, 60, 162, 192, + /* 70 */ 164, 31, 42, 43, 44, 45, 46, 47, 48, 49, + /* 80 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 31, + /* 90 */ 12, 13, 14, 15, 16, 181, 182, 97, 98, 68, + /* 100 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, + /* 110 */ 97, 98, 147, 100, 101, 102, 103, 104, 105, 106, + /* 120 */ 107, 108, 109, 158, 70, 71, 72, 73, 74, 75, + /* 130 */ 76, 77, 78, 79, 80, 149, 82, 83, 84, 85, + /* 140 */ 86, 87, 160, 144, 162, 99, 31, 161, 162, 145, + /* 150 */ 168, 152, 148, 171, 155, 173, 174, 92, 31, 177, + /* 160 */ 178, 179, 180, 132, 160, 31, 184, 185, 0, 123, + /* 170 */ 124, 125, 126, 127, 145, 60, 175, 114, 196, 12, + /* 180 */ 13, 14, 15, 16, 119, 120, 160, 159, 162, 160, + /* 190 */ 162, 209, 164, 192, 168, 213, 31, 171, 0, 162, + /* 200 */ 174, 164, 173, 177, 178, 179, 180, 39, 179, 175, + /* 210 */ 184, 185, 186, 135, 136, 14, 15, 16, 189, 190, + /* 220 */ 191, 145, 193, 39, 198, 196, 192, 140, 61, 114, + /* 230 */ 204, 205, 19, 160, 97, 162, 160, 39, 209, 3, + /* 240 */ 27, 168, 213, 106, 171, 111, 109, 174, 21, 36, + /* 250 */ 177, 178, 179, 180, 61, 179, 29, 184, 185, 186, + /* 260 */ 173, 68, 160, 66, 162, 189, 190, 191, 150, 193, + /* 270 */ 168, 153, 59, 171, 145, 62, 174, 148, 205, 177, + /* 280 */ 178, 179, 180, 196, 1, 2, 184, 185, 186, 160, + /* 290 */ 160, 144, 162, 145, 12, 13, 209, 195, 168, 207, + /* 300 */ 213, 171, 155, 21, 174, 170, 171, 177, 178, 179, + /* 310 */ 180, 29, 34, 31, 184, 185, 186, 12, 13, 14, + /* 320 */ 149, 201, 40, 161, 162, 195, 21, 12, 13, 14, + /* 330 */ 15, 16, 161, 162, 29, 0, 31, 142, 21, 160, + /* 340 */ 31, 162, 60, 14, 61, 40, 60, 168, 31, 32, + /* 350 */ 171, 65, 173, 174, 12, 13, 177, 178, 179, 145, + /* 360 */ 31, 79, 148, 21, 145, 60, 130, 148, 112, 113, + /* 370 */ 40, 29, 21, 31, 160, 196, 94, 95, 96, 160, + /* 380 */ 29, 149, 40, 176, 79, 50, 12, 13, 209, 54, + /* 390 */ 4, 113, 213, 161, 162, 21, 114, 1, 2, 94, + /* 400 */ 95, 96, 60, 29, 69, 31, 61, 61, 160, 20, + /* 410 */ 162, 18, 23, 68, 68, 22, 168, 24, 25, 171, + /* 420 */ 111, 79, 174, 88, 194, 177, 178, 179, 180, 99, + /* 430 */ 79, 38, 184, 185, 60, 162, 94, 95, 96, 210, + /* 440 */ 160, 197, 162, 31, 145, 94, 95, 96, 168, 0, + /* 450 */ 68, 171, 145, 79, 174, 147, 61, 177, 178, 179, + /* 460 */ 180, 138, 139, 68, 184, 185, 12, 13, 94, 95, + /* 470 */ 96, 147, 12, 13, 14, 21, 160, 31, 162, 61, + /* 480 */ 141, 21, 141, 29, 168, 31, 68, 171, 114, 29, + /* 490 */ 174, 31, 160, 177, 178, 179, 12, 13, 2, 50, + /* 500 */ 31, 115, 31, 54, 31, 21, 122, 114, 12, 13, + /* 510 */ 14, 15, 16, 29, 60, 31, 134, 165, 69, 176, + /* 520 */ 60, 60, 121, 169, 160, 206, 162, 61, 67, 96, + /* 530 */ 214, 215, 168, 79, 68, 171, 172, 88, 174, 79, + /* 540 */ 61, 177, 178, 179, 60, 168, 206, 68, 94, 95, + /* 550 */ 96, 61, 169, 61, 94, 95, 96, 160, 68, 162, + /* 560 */ 68, 129, 168, 79, 203, 168, 128, 202, 171, 117, + /* 570 */ 200, 174, 116, 160, 177, 178, 179, 180, 94, 95, + /* 580 */ 96, 113, 185, 160, 145, 162, 61, 199, 31, 61, + /* 590 */ 175, 168, 110, 68, 171, 172, 68, 174, 187, 160, + /* 600 */ 177, 178, 179, 160, 137, 162, 61, 217, 133, 61, + /* 610 */ 212, 168, 61, 68, 171, 211, 68, 174, 179, 68, + /* 620 */ 177, 178, 179, 60, 131, 160, 169, 162, 189, 190, + /* 630 */ 191, 183, 193, 168, 91, 144, 171, 60, 168, 174, + /* 640 */ 168, 61, 177, 178, 179, 160, 169, 162, 68, 168, + /* 650 */ 153, 208, 166, 168, 160, 160, 171, 172, 160, 174, + /* 660 */ 162, 156, 177, 178, 179, 165, 168, 145, 144, 171, + /* 670 */ 172, 141, 174, 19, 26, 177, 178, 179, 30, 31, + /* 680 */ 215, 27, 146, 35, 2, 37, 151, 33, 151, 0, + /* 690 */ 36, 160, 0, 162, 12, 13, 14, 15, 16, 168, + /* 700 */ 56, 67, 171, 0, 56, 174, 0, 0, 177, 178, + /* 710 */ 179, 63, 64, 59, 0, 160, 62, 162, 0, 0, + /* 720 */ 0, 0, 0, 168, 0, 41, 171, 0, 0, 174, + /* 730 */ 0, 0, 177, 178, 179, 160, 0, 162, 21, 0, + /* 740 */ 0, 93, 88, 168, 90, 60, 171, 21, 19, 174, + /* 750 */ 34, 89, 177, 178, 179, 160, 68, 162, 68, 118, + /* 760 */ 61, 68, 61, 168, 60, 60, 171, 29, 60, 174, + /* 770 */ 68, 61, 177, 178, 179, 160, 61, 162, 67, 118, + /* 780 */ 68, 112, 118, 168, 61, 60, 171, 4, 160, 174, + /* 790 */ 162, 29, 177, 178, 179, 61, 168, 29, 29, 171, + /* 800 */ 68, 29, 174, 61, 67, 177, 178, 179, 67, 29, + /* 810 */ 29, 68, 160, 2, 162, 67, 61, 60, 60, 60, + /* 820 */ 168, 61, 61, 171, 60, 160, 174, 162, 0, 177, + /* 830 */ 178, 179, 34, 168, 99, 60, 171, 92, 160, 174, + /* 840 */ 162, 89, 177, 178, 179, 60, 168, 65, 21, 171, + /* 850 */ 60, 67, 174, 67, 145, 177, 178, 179, 66, 29, + /* 860 */ 160, 61, 162, 29, 60, 29, 61, 60, 168, 160, + /* 870 */ 61, 171, 29, 160, 174, 162, 60, 177, 178, 179, + /* 880 */ 61, 168, 29, 60, 171, 61, 29, 174, 179, 60, + /* 890 */ 177, 178, 179, 160, 81, 162, 81, 188, 189, 190, + /* 900 */ 191, 168, 193, 81, 171, 21, 81, 174, 69, 60, + /* 910 */ 177, 178, 179, 160, 60, 162, 29, 29, 21, 41, + /* 920 */ 40, 168, 29, 29, 171, 29, 0, 174, 29, 29, + /* 930 */ 177, 178, 179, 160, 29, 162, 29, 21, 29, 29, + /* 940 */ 29, 168, 29, 29, 171, 27, 29, 174, 29, 29, + /* 950 */ 177, 178, 179, 29, 29, 34, 0, 29, 28, 0, + /* 960 */ 0, 21, 20, 218, 218, 218, 218, 218, 218, 218, + /* 970 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 980 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 990 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 1000 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 1010 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 1020 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 1030 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 1040 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 1050 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 1060 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 1070 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 1080 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 1090 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 1100 */ 218, 218, 218, }; -#define YY_SHIFT_COUNT (307) +#define YY_SHIFT_COUNT (312) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1020) +#define YY_SHIFT_MAX (960) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 153, 308, 335, 385, 385, 385, 385, 374, 385, 385, - /* 10 */ 139, 451, 476, 444, 451, 451, 451, 451, 451, 451, - /* 20 */ 451, 451, 451, 451, 451, 451, 451, 451, 451, 451, - /* 30 */ 451, 451, 451, 9, 9, 9, 170, 170, 57, 57, - /* 40 */ 74, 66, 125, 125, 48, 150, 66, 57, 57, 66, - /* 50 */ 57, 66, 66, 66, 57, 197, 0, 13, 13, 170, - /* 60 */ 221, 154, 206, 206, 206, 189, 150, 66, 66, 180, - /* 70 */ 59, 465, 78, 490, 117, 198, 279, 307, 256, 307, - /* 80 */ 362, 255, 61, 393, 74, 393, 74, 462, 462, 482, - /* 90 */ 500, 509, 394, 434, 471, 394, 434, 471, 449, 466, - /* 100 */ 475, 477, 484, 482, 565, 494, 472, 478, 489, 566, - /* 110 */ 66, 434, 471, 471, 434, 471, 541, 482, 500, 180, - /* 120 */ 197, 482, 578, 393, 197, 462, 1037, 1037, 1037, 30, - /* 130 */ 212, 135, 1020, 109, 126, 677, 677, 677, 677, 677, - /* 140 */ 677, 677, 338, 436, 31, 224, 199, 199, 199, 199, - /* 150 */ 392, 361, 367, 375, 437, 311, 315, 267, 376, 333, - /* 160 */ 386, 405, 416, 454, 458, 459, 464, 470, 474, 483, - /* 170 */ 492, 497, 414, 658, 663, 667, 671, 607, 597, 680, - /* 180 */ 684, 685, 687, 699, 701, 702, 635, 674, 707, 708, - /* 190 */ 709, 710, 656, 714, 675, 676, 715, 659, 630, 632, - /* 200 */ 655, 661, 605, 665, 669, 666, 678, 679, 682, 681, - /* 210 */ 683, 703, 672, 688, 686, 689, 628, 693, 704, 705, - /* 220 */ 637, 694, 712, 716, 698, 649, 764, 737, 744, 749, - /* 230 */ 750, 751, 752, 780, 690, 721, 726, 731, 733, 738, - /* 240 */ 739, 734, 742, 711, 745, 795, 717, 719, 746, 748, - /* 250 */ 743, 747, 787, 756, 758, 761, 785, 793, 766, 767, - /* 260 */ 798, 771, 772, 805, 781, 782, 812, 786, 788, 815, - /* 270 */ 790, 773, 774, 776, 778, 803, 791, 801, 802, 831, - /* 280 */ 833, 842, 828, 836, 839, 840, 845, 846, 847, 848, - /* 290 */ 850, 844, 852, 853, 854, 855, 856, 858, 859, 861, - /* 300 */ 862, 893, 865, 871, 901, 902, 882, 884, + /* 0 */ 393, 282, 305, 342, 342, 342, 342, 374, 342, 342, + /* 10 */ 115, 454, 484, 460, 454, 454, 454, 454, 454, 454, + /* 20 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, + /* 30 */ 454, 454, 454, 7, 7, 7, 351, 351, 40, 40, + /* 40 */ 20, 58, 127, 127, 63, 165, 58, 40, 40, 58, + /* 50 */ 40, 58, 58, 58, 40, 184, 0, 13, 13, 351, + /* 60 */ 317, 168, 134, 134, 134, 198, 165, 58, 58, 197, + /* 70 */ 54, 648, 78, 46, 65, 227, 309, 256, 278, 256, + /* 80 */ 329, 236, 386, 412, 20, 412, 20, 446, 446, 469, + /* 90 */ 471, 473, 384, 401, 433, 384, 401, 433, 432, 438, + /* 100 */ 452, 456, 468, 469, 557, 482, 467, 475, 493, 563, + /* 110 */ 58, 401, 433, 433, 401, 433, 543, 469, 471, 197, + /* 120 */ 184, 469, 577, 412, 184, 446, 963, 963, 963, 30, + /* 130 */ 654, 496, 682, 167, 213, 315, 315, 315, 315, 315, + /* 140 */ 315, 315, 335, 449, 283, 137, 201, 201, 201, 201, + /* 150 */ 389, 193, 345, 346, 396, 323, 31, 382, 395, 330, + /* 160 */ 418, 461, 466, 479, 490, 492, 525, 528, 545, 548, + /* 170 */ 551, 580, 286, 689, 692, 703, 706, 644, 634, 707, + /* 180 */ 714, 718, 719, 720, 721, 722, 724, 684, 727, 728, + /* 190 */ 730, 731, 736, 717, 739, 726, 729, 740, 685, 716, + /* 200 */ 662, 688, 690, 641, 699, 693, 701, 704, 705, 710, + /* 210 */ 708, 715, 738, 702, 711, 725, 712, 661, 723, 734, + /* 220 */ 737, 669, 732, 741, 742, 743, 664, 783, 762, 768, + /* 230 */ 769, 772, 780, 781, 811, 735, 748, 755, 757, 758, + /* 240 */ 760, 761, 759, 764, 745, 775, 828, 798, 752, 785, + /* 250 */ 782, 784, 786, 827, 790, 792, 800, 830, 834, 804, + /* 260 */ 805, 836, 807, 809, 843, 816, 819, 853, 823, 824, + /* 270 */ 857, 829, 813, 815, 822, 825, 884, 839, 849, 854, + /* 280 */ 887, 888, 897, 878, 880, 893, 894, 896, 899, 900, + /* 290 */ 905, 907, 916, 909, 910, 911, 913, 914, 917, 919, + /* 300 */ 920, 924, 926, 925, 918, 921, 956, 928, 930, 959, + /* 310 */ 960, 940, 942, }; #define YY_REDUCE_COUNT (128) -#define YY_REDUCE_MIN (-162) -#define YY_REDUCE_MAX (832) +#define YY_REDUCE_MIN (-182) +#define YY_REDUCE_MAX (773) static const short yy_reduce_ofst[] = { - /* 0 */ 152, -14, 26, 72, 101, 129, 158, 202, -115, 277, - /* 10 */ 29, 334, 406, 428, 450, 473, 493, 506, 528, 553, - /* 20 */ 573, 595, 617, 640, 660, 673, 695, 720, 740, 762, - /* 30 */ 784, 807, 827, 372, 569, 832, -155, -148, -138, -137, - /* 40 */ -114, -121, -157, -112, -28, -116, -125, -99, 114, 64, - /* 50 */ 123, 133, 193, 149, 145, 23, -124, -124, -124, -162, - /* 60 */ -54, 49, 171, 179, 185, 172, 213, 231, 248, 151, - /* 70 */ -159, -120, 60, 77, 87, 177, 183, 134, 134, 134, - /* 80 */ 194, 186, 226, 264, 325, 341, 340, 351, 359, 346, - /* 90 */ 371, 368, 347, 387, 401, 369, 404, 408, 378, 377, - /* 100 */ 382, 388, 134, 435, 426, 421, 402, 391, 412, 443, - /* 110 */ 194, 461, 463, 468, 469, 480, 479, 486, 491, 481, - /* 120 */ 495, 498, 487, 504, 496, 501, 503, 508, 511, + /* 0 */ 87, -18, 26, 73, -129, 102, 130, 179, 248, 280, + /* 10 */ 29, 316, 397, 364, 423, 443, 465, 485, 498, 531, + /* 20 */ 555, 575, 595, 615, 628, 652, 665, 678, 700, 713, + /* 30 */ 733, 753, 773, 709, 76, 439, -157, -150, -140, -139, + /* 40 */ -111, -127, -159, -116, -155, -107, -14, 4, 129, -94, + /* 50 */ 214, 171, 28, 232, 219, -1, -86, -86, -86, -164, + /* 60 */ -120, -35, -123, 1, 34, 147, 135, 162, 37, 118, + /* 70 */ -161, 148, -182, 92, 120, 195, 207, 230, 230, 230, + /* 80 */ 273, 229, 244, 299, 308, 307, 324, 339, 341, 332, + /* 90 */ 352, 343, 319, 354, 377, 340, 383, 394, 361, 365, + /* 100 */ 370, 388, 230, 413, 415, 411, 390, 398, 404, 448, + /* 110 */ 273, 457, 470, 472, 477, 481, 486, 494, 500, 497, + /* 120 */ 491, 495, 505, 522, 524, 530, 535, 537, 536, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 10 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 20 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 30 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 40 */ 744, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 50 */ 721, 721, 721, 721, 721, 742, 721, 889, 721, 721, - /* 60 */ 721, 744, 900, 900, 900, 742, 721, 721, 721, 807, - /* 70 */ 721, 721, 964, 721, 924, 721, 916, 892, 906, 893, - /* 80 */ 721, 949, 909, 721, 744, 721, 744, 721, 721, 721, - /* 90 */ 721, 721, 931, 929, 721, 931, 929, 721, 943, 939, - /* 100 */ 922, 920, 906, 721, 721, 721, 967, 955, 951, 721, - /* 110 */ 721, 929, 721, 721, 929, 721, 820, 721, 721, 721, - /* 120 */ 742, 721, 776, 721, 742, 721, 810, 810, 745, 721, - /* 130 */ 721, 721, 721, 721, 721, 861, 942, 941, 860, 866, - /* 140 */ 865, 864, 721, 721, 721, 721, 855, 856, 854, 853, - /* 150 */ 721, 721, 721, 721, 890, 721, 952, 956, 721, 721, - /* 160 */ 721, 841, 721, 721, 721, 721, 721, 721, 721, 721, - /* 170 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 180 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 190 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 200 */ 913, 923, 721, 721, 721, 721, 721, 721, 721, 721, - /* 210 */ 721, 721, 721, 841, 721, 940, 721, 899, 895, 721, - /* 220 */ 721, 891, 721, 721, 950, 721, 721, 721, 721, 721, - /* 230 */ 721, 721, 721, 885, 721, 721, 721, 721, 721, 721, - /* 240 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 250 */ 840, 721, 721, 721, 721, 721, 721, 721, 804, 721, - /* 260 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 270 */ 721, 789, 787, 786, 785, 721, 782, 721, 721, 721, - /* 280 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 290 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 300 */ 721, 721, 721, 721, 721, 721, 721, 721, + /* 0 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 10 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 20 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 30 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 40 */ 753, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 50 */ 728, 728, 728, 728, 728, 751, 728, 898, 728, 728, + /* 60 */ 728, 753, 909, 909, 909, 751, 728, 728, 728, 816, + /* 70 */ 728, 728, 973, 728, 933, 728, 925, 901, 915, 902, + /* 80 */ 728, 958, 918, 728, 753, 728, 753, 728, 728, 728, + /* 90 */ 728, 728, 940, 938, 728, 940, 938, 728, 952, 948, + /* 100 */ 931, 929, 915, 728, 728, 728, 976, 964, 960, 728, + /* 110 */ 728, 938, 728, 728, 938, 728, 829, 728, 728, 728, + /* 120 */ 751, 728, 785, 728, 751, 728, 819, 819, 754, 728, + /* 130 */ 728, 728, 728, 728, 728, 870, 951, 950, 869, 875, + /* 140 */ 874, 873, 728, 728, 728, 728, 864, 865, 863, 862, + /* 150 */ 728, 728, 728, 728, 899, 728, 961, 965, 728, 728, + /* 160 */ 728, 850, 728, 728, 728, 728, 728, 728, 728, 728, + /* 170 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 180 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 190 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 200 */ 728, 922, 932, 728, 728, 728, 728, 728, 728, 728, + /* 210 */ 728, 728, 728, 728, 850, 728, 949, 728, 908, 904, + /* 220 */ 728, 728, 900, 728, 728, 959, 728, 728, 728, 728, + /* 230 */ 728, 728, 728, 728, 894, 728, 728, 728, 728, 728, + /* 240 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 250 */ 728, 849, 728, 728, 728, 728, 728, 728, 728, 813, + /* 260 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 270 */ 728, 728, 798, 796, 795, 794, 728, 791, 728, 728, + /* 280 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 290 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 300 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 310 */ 728, 728, 728, }; /********** End of lemon-generated parsing tables *****************************/ @@ -657,189 +646,191 @@ static const char *const yyTokenName[] = { /* 30 */ "DNODES", /* 31 */ "NK_ID", /* 32 */ "NK_IPTOKEN", - /* 33 */ "DATABASE", - /* 34 */ "DATABASES", - /* 35 */ "USE", - /* 36 */ "IF", - /* 37 */ "NOT", - /* 38 */ "EXISTS", - /* 39 */ "BLOCKS", - /* 40 */ "CACHE", - /* 41 */ "CACHELAST", - /* 42 */ "COMP", - /* 43 */ "DAYS", - /* 44 */ "FSYNC", - /* 45 */ "MAXROWS", - /* 46 */ "MINROWS", - /* 47 */ "KEEP", - /* 48 */ "PRECISION", - /* 49 */ "QUORUM", - /* 50 */ "REPLICA", - /* 51 */ "TTL", - /* 52 */ "WAL", - /* 53 */ "VGROUPS", - /* 54 */ "SINGLE_STABLE", - /* 55 */ "STREAM_MODE", - /* 56 */ "TABLE", - /* 57 */ "NK_LP", - /* 58 */ "NK_RP", - /* 59 */ "STABLE", - /* 60 */ "TABLES", - /* 61 */ "STABLES", - /* 62 */ "USING", - /* 63 */ "TAGS", - /* 64 */ "NK_DOT", - /* 65 */ "NK_COMMA", - /* 66 */ "COMMENT", - /* 67 */ "BOOL", - /* 68 */ "TINYINT", - /* 69 */ "SMALLINT", - /* 70 */ "INT", - /* 71 */ "INTEGER", - /* 72 */ "BIGINT", - /* 73 */ "FLOAT", - /* 74 */ "DOUBLE", - /* 75 */ "BINARY", - /* 76 */ "TIMESTAMP", - /* 77 */ "NCHAR", - /* 78 */ "UNSIGNED", - /* 79 */ "JSON", - /* 80 */ "VARCHAR", - /* 81 */ "MEDIUMBLOB", - /* 82 */ "BLOB", - /* 83 */ "VARBINARY", - /* 84 */ "DECIMAL", - /* 85 */ "SMA", - /* 86 */ "INDEX", - /* 87 */ "ON", - /* 88 */ "FULLTEXT", - /* 89 */ "FUNCTION", - /* 90 */ "INTERVAL", - /* 91 */ "MNODES", - /* 92 */ "NK_FLOAT", - /* 93 */ "NK_BOOL", - /* 94 */ "NK_VARIABLE", - /* 95 */ "BETWEEN", - /* 96 */ "IS", - /* 97 */ "NULL", - /* 98 */ "NK_LT", - /* 99 */ "NK_GT", - /* 100 */ "NK_LE", - /* 101 */ "NK_GE", - /* 102 */ "NK_NE", - /* 103 */ "NK_EQ", - /* 104 */ "LIKE", - /* 105 */ "MATCH", - /* 106 */ "NMATCH", - /* 107 */ "IN", - /* 108 */ "FROM", - /* 109 */ "AS", - /* 110 */ "JOIN", - /* 111 */ "INNER", - /* 112 */ "SELECT", - /* 113 */ "DISTINCT", - /* 114 */ "WHERE", - /* 115 */ "PARTITION", - /* 116 */ "BY", - /* 117 */ "SESSION", - /* 118 */ "STATE_WINDOW", - /* 119 */ "SLIDING", - /* 120 */ "FILL", - /* 121 */ "VALUE", - /* 122 */ "NONE", - /* 123 */ "PREV", - /* 124 */ "LINEAR", - /* 125 */ "NEXT", - /* 126 */ "GROUP", - /* 127 */ "HAVING", - /* 128 */ "ORDER", - /* 129 */ "SLIMIT", - /* 130 */ "SOFFSET", - /* 131 */ "LIMIT", - /* 132 */ "OFFSET", - /* 133 */ "ASC", - /* 134 */ "DESC", - /* 135 */ "NULLS", - /* 136 */ "FIRST", - /* 137 */ "LAST", - /* 138 */ "cmd", - /* 139 */ "user_name", - /* 140 */ "dnode_endpoint", - /* 141 */ "dnode_host_name", - /* 142 */ "not_exists_opt", - /* 143 */ "db_name", - /* 144 */ "db_options", - /* 145 */ "exists_opt", - /* 146 */ "full_table_name", - /* 147 */ "column_def_list", - /* 148 */ "tags_def_opt", - /* 149 */ "table_options", - /* 150 */ "multi_create_clause", - /* 151 */ "tags_def", - /* 152 */ "multi_drop_clause", - /* 153 */ "create_subtable_clause", - /* 154 */ "specific_tags_opt", - /* 155 */ "literal_list", - /* 156 */ "drop_table_clause", - /* 157 */ "col_name_list", - /* 158 */ "table_name", - /* 159 */ "column_def", - /* 160 */ "column_name", - /* 161 */ "type_name", - /* 162 */ "col_name", - /* 163 */ "index_name", - /* 164 */ "index_options", - /* 165 */ "func_list", - /* 166 */ "duration_literal", - /* 167 */ "sliding_opt", - /* 168 */ "func", - /* 169 */ "function_name", - /* 170 */ "expression_list", - /* 171 */ "query_expression", - /* 172 */ "literal", - /* 173 */ "table_alias", - /* 174 */ "column_alias", - /* 175 */ "expression", - /* 176 */ "column_reference", - /* 177 */ "subquery", - /* 178 */ "predicate", - /* 179 */ "compare_op", - /* 180 */ "in_op", - /* 181 */ "in_predicate_value", - /* 182 */ "boolean_value_expression", - /* 183 */ "boolean_primary", - /* 184 */ "common_expression", - /* 185 */ "from_clause", - /* 186 */ "table_reference_list", - /* 187 */ "table_reference", - /* 188 */ "table_primary", - /* 189 */ "joined_table", - /* 190 */ "alias_opt", - /* 191 */ "parenthesized_joined_table", - /* 192 */ "join_type", - /* 193 */ "search_condition", - /* 194 */ "query_specification", - /* 195 */ "set_quantifier_opt", - /* 196 */ "select_list", - /* 197 */ "where_clause_opt", - /* 198 */ "partition_by_clause_opt", - /* 199 */ "twindow_clause_opt", - /* 200 */ "group_by_clause_opt", - /* 201 */ "having_clause_opt", - /* 202 */ "select_sublist", - /* 203 */ "select_item", - /* 204 */ "fill_opt", - /* 205 */ "fill_mode", - /* 206 */ "group_by_list", - /* 207 */ "query_expression_body", - /* 208 */ "order_by_clause_opt", - /* 209 */ "slimit_clause_opt", - /* 210 */ "limit_clause_opt", - /* 211 */ "query_primary", - /* 212 */ "sort_specification_list", - /* 213 */ "sort_specification", - /* 214 */ "ordering_specification_opt", - /* 215 */ "null_ordering_opt", + /* 33 */ "QNODE", + /* 34 */ "ON", + /* 35 */ "QNODES", + /* 36 */ "DATABASE", + /* 37 */ "DATABASES", + /* 38 */ "USE", + /* 39 */ "IF", + /* 40 */ "NOT", + /* 41 */ "EXISTS", + /* 42 */ "BLOCKS", + /* 43 */ "CACHE", + /* 44 */ "CACHELAST", + /* 45 */ "COMP", + /* 46 */ "DAYS", + /* 47 */ "FSYNC", + /* 48 */ "MAXROWS", + /* 49 */ "MINROWS", + /* 50 */ "KEEP", + /* 51 */ "PRECISION", + /* 52 */ "QUORUM", + /* 53 */ "REPLICA", + /* 54 */ "TTL", + /* 55 */ "WAL", + /* 56 */ "VGROUPS", + /* 57 */ "SINGLE_STABLE", + /* 58 */ "STREAM_MODE", + /* 59 */ "TABLE", + /* 60 */ "NK_LP", + /* 61 */ "NK_RP", + /* 62 */ "STABLE", + /* 63 */ "TABLES", + /* 64 */ "STABLES", + /* 65 */ "USING", + /* 66 */ "TAGS", + /* 67 */ "NK_DOT", + /* 68 */ "NK_COMMA", + /* 69 */ "COMMENT", + /* 70 */ "BOOL", + /* 71 */ "TINYINT", + /* 72 */ "SMALLINT", + /* 73 */ "INT", + /* 74 */ "INTEGER", + /* 75 */ "BIGINT", + /* 76 */ "FLOAT", + /* 77 */ "DOUBLE", + /* 78 */ "BINARY", + /* 79 */ "TIMESTAMP", + /* 80 */ "NCHAR", + /* 81 */ "UNSIGNED", + /* 82 */ "JSON", + /* 83 */ "VARCHAR", + /* 84 */ "MEDIUMBLOB", + /* 85 */ "BLOB", + /* 86 */ "VARBINARY", + /* 87 */ "DECIMAL", + /* 88 */ "SMA", + /* 89 */ "INDEX", + /* 90 */ "FULLTEXT", + /* 91 */ "FUNCTION", + /* 92 */ "INTERVAL", + /* 93 */ "MNODES", + /* 94 */ "NK_FLOAT", + /* 95 */ "NK_BOOL", + /* 96 */ "NK_VARIABLE", + /* 97 */ "BETWEEN", + /* 98 */ "IS", + /* 99 */ "NULL", + /* 100 */ "NK_LT", + /* 101 */ "NK_GT", + /* 102 */ "NK_LE", + /* 103 */ "NK_GE", + /* 104 */ "NK_NE", + /* 105 */ "NK_EQ", + /* 106 */ "LIKE", + /* 107 */ "MATCH", + /* 108 */ "NMATCH", + /* 109 */ "IN", + /* 110 */ "FROM", + /* 111 */ "AS", + /* 112 */ "JOIN", + /* 113 */ "INNER", + /* 114 */ "SELECT", + /* 115 */ "DISTINCT", + /* 116 */ "WHERE", + /* 117 */ "PARTITION", + /* 118 */ "BY", + /* 119 */ "SESSION", + /* 120 */ "STATE_WINDOW", + /* 121 */ "SLIDING", + /* 122 */ "FILL", + /* 123 */ "VALUE", + /* 124 */ "NONE", + /* 125 */ "PREV", + /* 126 */ "LINEAR", + /* 127 */ "NEXT", + /* 128 */ "GROUP", + /* 129 */ "HAVING", + /* 130 */ "ORDER", + /* 131 */ "SLIMIT", + /* 132 */ "SOFFSET", + /* 133 */ "LIMIT", + /* 134 */ "OFFSET", + /* 135 */ "ASC", + /* 136 */ "DESC", + /* 137 */ "NULLS", + /* 138 */ "FIRST", + /* 139 */ "LAST", + /* 140 */ "cmd", + /* 141 */ "user_name", + /* 142 */ "dnode_endpoint", + /* 143 */ "dnode_host_name", + /* 144 */ "not_exists_opt", + /* 145 */ "db_name", + /* 146 */ "db_options", + /* 147 */ "exists_opt", + /* 148 */ "full_table_name", + /* 149 */ "column_def_list", + /* 150 */ "tags_def_opt", + /* 151 */ "table_options", + /* 152 */ "multi_create_clause", + /* 153 */ "tags_def", + /* 154 */ "multi_drop_clause", + /* 155 */ "create_subtable_clause", + /* 156 */ "specific_tags_opt", + /* 157 */ "literal_list", + /* 158 */ "drop_table_clause", + /* 159 */ "col_name_list", + /* 160 */ "table_name", + /* 161 */ "column_def", + /* 162 */ "column_name", + /* 163 */ "type_name", + /* 164 */ "col_name", + /* 165 */ "index_name", + /* 166 */ "index_options", + /* 167 */ "func_list", + /* 168 */ "duration_literal", + /* 169 */ "sliding_opt", + /* 170 */ "func", + /* 171 */ "function_name", + /* 172 */ "expression_list", + /* 173 */ "query_expression", + /* 174 */ "literal", + /* 175 */ "table_alias", + /* 176 */ "column_alias", + /* 177 */ "expression", + /* 178 */ "column_reference", + /* 179 */ "subquery", + /* 180 */ "predicate", + /* 181 */ "compare_op", + /* 182 */ "in_op", + /* 183 */ "in_predicate_value", + /* 184 */ "boolean_value_expression", + /* 185 */ "boolean_primary", + /* 186 */ "common_expression", + /* 187 */ "from_clause", + /* 188 */ "table_reference_list", + /* 189 */ "table_reference", + /* 190 */ "table_primary", + /* 191 */ "joined_table", + /* 192 */ "alias_opt", + /* 193 */ "parenthesized_joined_table", + /* 194 */ "join_type", + /* 195 */ "search_condition", + /* 196 */ "query_specification", + /* 197 */ "set_quantifier_opt", + /* 198 */ "select_list", + /* 199 */ "where_clause_opt", + /* 200 */ "partition_by_clause_opt", + /* 201 */ "twindow_clause_opt", + /* 202 */ "group_by_clause_opt", + /* 203 */ "having_clause_opt", + /* 204 */ "select_sublist", + /* 205 */ "select_item", + /* 206 */ "fill_opt", + /* 207 */ "fill_mode", + /* 208 */ "group_by_list", + /* 209 */ "query_expression_body", + /* 210 */ "order_by_clause_opt", + /* 211 */ "slimit_clause_opt", + /* 212 */ "limit_clause_opt", + /* 213 */ "query_primary", + /* 214 */ "sort_specification_list", + /* 215 */ "sort_specification", + /* 216 */ "ordering_specification_opt", + /* 217 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -860,239 +851,241 @@ static const char *const yyRuleName[] = { /* 10 */ "dnode_endpoint ::= NK_STRING", /* 11 */ "dnode_host_name ::= NK_ID", /* 12 */ "dnode_host_name ::= NK_IPTOKEN", - /* 13 */ "cmd ::= CREATE DATABASE not_exists_opt db_name db_options", - /* 14 */ "cmd ::= DROP DATABASE exists_opt db_name", - /* 15 */ "cmd ::= SHOW DATABASES", - /* 16 */ "cmd ::= USE db_name", - /* 17 */ "not_exists_opt ::= IF NOT EXISTS", - /* 18 */ "not_exists_opt ::=", - /* 19 */ "exists_opt ::= IF EXISTS", - /* 20 */ "exists_opt ::=", - /* 21 */ "db_options ::=", - /* 22 */ "db_options ::= db_options BLOCKS NK_INTEGER", - /* 23 */ "db_options ::= db_options CACHE NK_INTEGER", - /* 24 */ "db_options ::= db_options CACHELAST NK_INTEGER", - /* 25 */ "db_options ::= db_options COMP NK_INTEGER", - /* 26 */ "db_options ::= db_options DAYS NK_INTEGER", - /* 27 */ "db_options ::= db_options FSYNC NK_INTEGER", - /* 28 */ "db_options ::= db_options MAXROWS NK_INTEGER", - /* 29 */ "db_options ::= db_options MINROWS NK_INTEGER", - /* 30 */ "db_options ::= db_options KEEP NK_INTEGER", - /* 31 */ "db_options ::= db_options PRECISION NK_STRING", - /* 32 */ "db_options ::= db_options QUORUM NK_INTEGER", - /* 33 */ "db_options ::= db_options REPLICA NK_INTEGER", - /* 34 */ "db_options ::= db_options TTL NK_INTEGER", - /* 35 */ "db_options ::= db_options WAL NK_INTEGER", - /* 36 */ "db_options ::= db_options VGROUPS NK_INTEGER", - /* 37 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", - /* 38 */ "db_options ::= db_options STREAM_MODE NK_INTEGER", - /* 39 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", - /* 40 */ "cmd ::= CREATE TABLE multi_create_clause", - /* 41 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", - /* 42 */ "cmd ::= DROP TABLE multi_drop_clause", - /* 43 */ "cmd ::= DROP STABLE exists_opt full_table_name", - /* 44 */ "cmd ::= SHOW TABLES", - /* 45 */ "cmd ::= SHOW STABLES", - /* 46 */ "multi_create_clause ::= create_subtable_clause", - /* 47 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 48 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP", - /* 49 */ "multi_drop_clause ::= drop_table_clause", - /* 50 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", - /* 51 */ "drop_table_clause ::= exists_opt full_table_name", - /* 52 */ "specific_tags_opt ::=", - /* 53 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", - /* 54 */ "full_table_name ::= table_name", - /* 55 */ "full_table_name ::= db_name NK_DOT table_name", - /* 56 */ "column_def_list ::= column_def", - /* 57 */ "column_def_list ::= column_def_list NK_COMMA column_def", - /* 58 */ "column_def ::= column_name type_name", - /* 59 */ "column_def ::= column_name type_name COMMENT NK_STRING", - /* 60 */ "type_name ::= BOOL", - /* 61 */ "type_name ::= TINYINT", - /* 62 */ "type_name ::= SMALLINT", - /* 63 */ "type_name ::= INT", - /* 64 */ "type_name ::= INTEGER", - /* 65 */ "type_name ::= BIGINT", - /* 66 */ "type_name ::= FLOAT", - /* 67 */ "type_name ::= DOUBLE", - /* 68 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 69 */ "type_name ::= TIMESTAMP", - /* 70 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 71 */ "type_name ::= TINYINT UNSIGNED", - /* 72 */ "type_name ::= SMALLINT UNSIGNED", - /* 73 */ "type_name ::= INT UNSIGNED", - /* 74 */ "type_name ::= BIGINT UNSIGNED", - /* 75 */ "type_name ::= JSON", - /* 76 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 77 */ "type_name ::= MEDIUMBLOB", - /* 78 */ "type_name ::= BLOB", - /* 79 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 80 */ "type_name ::= DECIMAL", - /* 81 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 82 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 83 */ "tags_def_opt ::=", - /* 84 */ "tags_def_opt ::= tags_def", - /* 85 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", - /* 86 */ "table_options ::=", - /* 87 */ "table_options ::= table_options COMMENT NK_STRING", - /* 88 */ "table_options ::= table_options KEEP NK_INTEGER", - /* 89 */ "table_options ::= table_options TTL NK_INTEGER", - /* 90 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 91 */ "col_name_list ::= col_name", - /* 92 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 93 */ "col_name ::= column_name", - /* 94 */ "cmd ::= CREATE SMA INDEX index_name ON table_name index_options", - /* 95 */ "cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP", - /* 96 */ "index_options ::=", - /* 97 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", - /* 98 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", - /* 99 */ "func_list ::= func", - /* 100 */ "func_list ::= func_list NK_COMMA func", - /* 101 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 102 */ "cmd ::= SHOW VGROUPS", - /* 103 */ "cmd ::= SHOW db_name NK_DOT VGROUPS", - /* 104 */ "cmd ::= SHOW MNODES", - /* 105 */ "cmd ::= query_expression", - /* 106 */ "literal ::= NK_INTEGER", - /* 107 */ "literal ::= NK_FLOAT", - /* 108 */ "literal ::= NK_STRING", - /* 109 */ "literal ::= NK_BOOL", - /* 110 */ "literal ::= TIMESTAMP NK_STRING", - /* 111 */ "literal ::= duration_literal", - /* 112 */ "duration_literal ::= NK_VARIABLE", - /* 113 */ "literal_list ::= literal", - /* 114 */ "literal_list ::= literal_list NK_COMMA literal", - /* 115 */ "db_name ::= NK_ID", - /* 116 */ "table_name ::= NK_ID", - /* 117 */ "column_name ::= NK_ID", - /* 118 */ "function_name ::= NK_ID", - /* 119 */ "table_alias ::= NK_ID", - /* 120 */ "column_alias ::= NK_ID", - /* 121 */ "user_name ::= NK_ID", - /* 122 */ "index_name ::= NK_ID", - /* 123 */ "expression ::= literal", - /* 124 */ "expression ::= column_reference", - /* 125 */ "expression ::= function_name NK_LP expression_list NK_RP", - /* 126 */ "expression ::= function_name NK_LP NK_STAR NK_RP", - /* 127 */ "expression ::= subquery", - /* 128 */ "expression ::= NK_LP expression NK_RP", - /* 129 */ "expression ::= NK_PLUS expression", - /* 130 */ "expression ::= NK_MINUS expression", - /* 131 */ "expression ::= expression NK_PLUS expression", - /* 132 */ "expression ::= expression NK_MINUS expression", - /* 133 */ "expression ::= expression NK_STAR expression", - /* 134 */ "expression ::= expression NK_SLASH expression", - /* 135 */ "expression ::= expression NK_REM expression", - /* 136 */ "expression_list ::= expression", - /* 137 */ "expression_list ::= expression_list NK_COMMA expression", - /* 138 */ "column_reference ::= column_name", - /* 139 */ "column_reference ::= table_name NK_DOT column_name", - /* 140 */ "predicate ::= expression compare_op expression", - /* 141 */ "predicate ::= expression BETWEEN expression AND expression", - /* 142 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 143 */ "predicate ::= expression IS NULL", - /* 144 */ "predicate ::= expression IS NOT NULL", - /* 145 */ "predicate ::= expression in_op in_predicate_value", - /* 146 */ "compare_op ::= NK_LT", - /* 147 */ "compare_op ::= NK_GT", - /* 148 */ "compare_op ::= NK_LE", - /* 149 */ "compare_op ::= NK_GE", - /* 150 */ "compare_op ::= NK_NE", - /* 151 */ "compare_op ::= NK_EQ", - /* 152 */ "compare_op ::= LIKE", - /* 153 */ "compare_op ::= NOT LIKE", - /* 154 */ "compare_op ::= MATCH", - /* 155 */ "compare_op ::= NMATCH", - /* 156 */ "in_op ::= IN", - /* 157 */ "in_op ::= NOT IN", - /* 158 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 159 */ "boolean_value_expression ::= boolean_primary", - /* 160 */ "boolean_value_expression ::= NOT boolean_primary", - /* 161 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 162 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 163 */ "boolean_primary ::= predicate", - /* 164 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 165 */ "common_expression ::= expression", - /* 166 */ "common_expression ::= boolean_value_expression", - /* 167 */ "from_clause ::= FROM table_reference_list", - /* 168 */ "table_reference_list ::= table_reference", - /* 169 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 170 */ "table_reference ::= table_primary", - /* 171 */ "table_reference ::= joined_table", - /* 172 */ "table_primary ::= table_name alias_opt", - /* 173 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 174 */ "table_primary ::= subquery alias_opt", - /* 175 */ "table_primary ::= parenthesized_joined_table", - /* 176 */ "alias_opt ::=", - /* 177 */ "alias_opt ::= table_alias", - /* 178 */ "alias_opt ::= AS table_alias", - /* 179 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 180 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 181 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 182 */ "join_type ::=", - /* 183 */ "join_type ::= INNER", - /* 184 */ "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", - /* 185 */ "set_quantifier_opt ::=", - /* 186 */ "set_quantifier_opt ::= DISTINCT", - /* 187 */ "set_quantifier_opt ::= ALL", - /* 188 */ "select_list ::= NK_STAR", - /* 189 */ "select_list ::= select_sublist", - /* 190 */ "select_sublist ::= select_item", - /* 191 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 192 */ "select_item ::= common_expression", - /* 193 */ "select_item ::= common_expression column_alias", - /* 194 */ "select_item ::= common_expression AS column_alias", - /* 195 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 196 */ "where_clause_opt ::=", - /* 197 */ "where_clause_opt ::= WHERE search_condition", - /* 198 */ "partition_by_clause_opt ::=", - /* 199 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 200 */ "twindow_clause_opt ::=", - /* 201 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP", - /* 202 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", - /* 203 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 204 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 205 */ "sliding_opt ::=", - /* 206 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 207 */ "fill_opt ::=", - /* 208 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 209 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 210 */ "fill_mode ::= NONE", - /* 211 */ "fill_mode ::= PREV", - /* 212 */ "fill_mode ::= NULL", - /* 213 */ "fill_mode ::= LINEAR", - /* 214 */ "fill_mode ::= NEXT", - /* 215 */ "group_by_clause_opt ::=", - /* 216 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 217 */ "group_by_list ::= expression", - /* 218 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 219 */ "having_clause_opt ::=", - /* 220 */ "having_clause_opt ::= HAVING search_condition", - /* 221 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 222 */ "query_expression_body ::= query_primary", - /* 223 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 224 */ "query_primary ::= query_specification", - /* 225 */ "order_by_clause_opt ::=", - /* 226 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 227 */ "slimit_clause_opt ::=", - /* 228 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 229 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 230 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 231 */ "limit_clause_opt ::=", - /* 232 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 233 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 234 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 235 */ "subquery ::= NK_LP query_expression NK_RP", - /* 236 */ "search_condition ::= common_expression", - /* 237 */ "sort_specification_list ::= sort_specification", - /* 238 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 239 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 240 */ "ordering_specification_opt ::=", - /* 241 */ "ordering_specification_opt ::= ASC", - /* 242 */ "ordering_specification_opt ::= DESC", - /* 243 */ "null_ordering_opt ::=", - /* 244 */ "null_ordering_opt ::= NULLS FIRST", - /* 245 */ "null_ordering_opt ::= NULLS LAST", + /* 13 */ "cmd ::= CREATE QNODE ON DNODE NK_INTEGER", + /* 14 */ "cmd ::= SHOW QNODES", + /* 15 */ "cmd ::= CREATE DATABASE not_exists_opt db_name db_options", + /* 16 */ "cmd ::= DROP DATABASE exists_opt db_name", + /* 17 */ "cmd ::= SHOW DATABASES", + /* 18 */ "cmd ::= USE db_name", + /* 19 */ "not_exists_opt ::= IF NOT EXISTS", + /* 20 */ "not_exists_opt ::=", + /* 21 */ "exists_opt ::= IF EXISTS", + /* 22 */ "exists_opt ::=", + /* 23 */ "db_options ::=", + /* 24 */ "db_options ::= db_options BLOCKS NK_INTEGER", + /* 25 */ "db_options ::= db_options CACHE NK_INTEGER", + /* 26 */ "db_options ::= db_options CACHELAST NK_INTEGER", + /* 27 */ "db_options ::= db_options COMP NK_INTEGER", + /* 28 */ "db_options ::= db_options DAYS NK_INTEGER", + /* 29 */ "db_options ::= db_options FSYNC NK_INTEGER", + /* 30 */ "db_options ::= db_options MAXROWS NK_INTEGER", + /* 31 */ "db_options ::= db_options MINROWS NK_INTEGER", + /* 32 */ "db_options ::= db_options KEEP NK_INTEGER", + /* 33 */ "db_options ::= db_options PRECISION NK_STRING", + /* 34 */ "db_options ::= db_options QUORUM NK_INTEGER", + /* 35 */ "db_options ::= db_options REPLICA NK_INTEGER", + /* 36 */ "db_options ::= db_options TTL NK_INTEGER", + /* 37 */ "db_options ::= db_options WAL NK_INTEGER", + /* 38 */ "db_options ::= db_options VGROUPS NK_INTEGER", + /* 39 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", + /* 40 */ "db_options ::= db_options STREAM_MODE NK_INTEGER", + /* 41 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", + /* 42 */ "cmd ::= CREATE TABLE multi_create_clause", + /* 43 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", + /* 44 */ "cmd ::= DROP TABLE multi_drop_clause", + /* 45 */ "cmd ::= DROP STABLE exists_opt full_table_name", + /* 46 */ "cmd ::= SHOW TABLES", + /* 47 */ "cmd ::= SHOW STABLES", + /* 48 */ "multi_create_clause ::= create_subtable_clause", + /* 49 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", + /* 50 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP", + /* 51 */ "multi_drop_clause ::= drop_table_clause", + /* 52 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", + /* 53 */ "drop_table_clause ::= exists_opt full_table_name", + /* 54 */ "specific_tags_opt ::=", + /* 55 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", + /* 56 */ "full_table_name ::= table_name", + /* 57 */ "full_table_name ::= db_name NK_DOT table_name", + /* 58 */ "column_def_list ::= column_def", + /* 59 */ "column_def_list ::= column_def_list NK_COMMA column_def", + /* 60 */ "column_def ::= column_name type_name", + /* 61 */ "column_def ::= column_name type_name COMMENT NK_STRING", + /* 62 */ "type_name ::= BOOL", + /* 63 */ "type_name ::= TINYINT", + /* 64 */ "type_name ::= SMALLINT", + /* 65 */ "type_name ::= INT", + /* 66 */ "type_name ::= INTEGER", + /* 67 */ "type_name ::= BIGINT", + /* 68 */ "type_name ::= FLOAT", + /* 69 */ "type_name ::= DOUBLE", + /* 70 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", + /* 71 */ "type_name ::= TIMESTAMP", + /* 72 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", + /* 73 */ "type_name ::= TINYINT UNSIGNED", + /* 74 */ "type_name ::= SMALLINT UNSIGNED", + /* 75 */ "type_name ::= INT UNSIGNED", + /* 76 */ "type_name ::= BIGINT UNSIGNED", + /* 77 */ "type_name ::= JSON", + /* 78 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", + /* 79 */ "type_name ::= MEDIUMBLOB", + /* 80 */ "type_name ::= BLOB", + /* 81 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", + /* 82 */ "type_name ::= DECIMAL", + /* 83 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", + /* 84 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 85 */ "tags_def_opt ::=", + /* 86 */ "tags_def_opt ::= tags_def", + /* 87 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", + /* 88 */ "table_options ::=", + /* 89 */ "table_options ::= table_options COMMENT NK_STRING", + /* 90 */ "table_options ::= table_options KEEP NK_INTEGER", + /* 91 */ "table_options ::= table_options TTL NK_INTEGER", + /* 92 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 93 */ "col_name_list ::= col_name", + /* 94 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 95 */ "col_name ::= column_name", + /* 96 */ "cmd ::= CREATE SMA INDEX index_name ON table_name index_options", + /* 97 */ "cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP", + /* 98 */ "index_options ::=", + /* 99 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", + /* 100 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", + /* 101 */ "func_list ::= func", + /* 102 */ "func_list ::= func_list NK_COMMA func", + /* 103 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 104 */ "cmd ::= SHOW VGROUPS", + /* 105 */ "cmd ::= SHOW db_name NK_DOT VGROUPS", + /* 106 */ "cmd ::= SHOW MNODES", + /* 107 */ "cmd ::= query_expression", + /* 108 */ "literal ::= NK_INTEGER", + /* 109 */ "literal ::= NK_FLOAT", + /* 110 */ "literal ::= NK_STRING", + /* 111 */ "literal ::= NK_BOOL", + /* 112 */ "literal ::= TIMESTAMP NK_STRING", + /* 113 */ "literal ::= duration_literal", + /* 114 */ "duration_literal ::= NK_VARIABLE", + /* 115 */ "literal_list ::= literal", + /* 116 */ "literal_list ::= literal_list NK_COMMA literal", + /* 117 */ "db_name ::= NK_ID", + /* 118 */ "table_name ::= NK_ID", + /* 119 */ "column_name ::= NK_ID", + /* 120 */ "function_name ::= NK_ID", + /* 121 */ "table_alias ::= NK_ID", + /* 122 */ "column_alias ::= NK_ID", + /* 123 */ "user_name ::= NK_ID", + /* 124 */ "index_name ::= NK_ID", + /* 125 */ "expression ::= literal", + /* 126 */ "expression ::= column_reference", + /* 127 */ "expression ::= function_name NK_LP expression_list NK_RP", + /* 128 */ "expression ::= function_name NK_LP NK_STAR NK_RP", + /* 129 */ "expression ::= subquery", + /* 130 */ "expression ::= NK_LP expression NK_RP", + /* 131 */ "expression ::= NK_PLUS expression", + /* 132 */ "expression ::= NK_MINUS expression", + /* 133 */ "expression ::= expression NK_PLUS expression", + /* 134 */ "expression ::= expression NK_MINUS expression", + /* 135 */ "expression ::= expression NK_STAR expression", + /* 136 */ "expression ::= expression NK_SLASH expression", + /* 137 */ "expression ::= expression NK_REM expression", + /* 138 */ "expression_list ::= expression", + /* 139 */ "expression_list ::= expression_list NK_COMMA expression", + /* 140 */ "column_reference ::= column_name", + /* 141 */ "column_reference ::= table_name NK_DOT column_name", + /* 142 */ "predicate ::= expression compare_op expression", + /* 143 */ "predicate ::= expression BETWEEN expression AND expression", + /* 144 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 145 */ "predicate ::= expression IS NULL", + /* 146 */ "predicate ::= expression IS NOT NULL", + /* 147 */ "predicate ::= expression in_op in_predicate_value", + /* 148 */ "compare_op ::= NK_LT", + /* 149 */ "compare_op ::= NK_GT", + /* 150 */ "compare_op ::= NK_LE", + /* 151 */ "compare_op ::= NK_GE", + /* 152 */ "compare_op ::= NK_NE", + /* 153 */ "compare_op ::= NK_EQ", + /* 154 */ "compare_op ::= LIKE", + /* 155 */ "compare_op ::= NOT LIKE", + /* 156 */ "compare_op ::= MATCH", + /* 157 */ "compare_op ::= NMATCH", + /* 158 */ "in_op ::= IN", + /* 159 */ "in_op ::= NOT IN", + /* 160 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 161 */ "boolean_value_expression ::= boolean_primary", + /* 162 */ "boolean_value_expression ::= NOT boolean_primary", + /* 163 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 164 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 165 */ "boolean_primary ::= predicate", + /* 166 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 167 */ "common_expression ::= expression", + /* 168 */ "common_expression ::= boolean_value_expression", + /* 169 */ "from_clause ::= FROM table_reference_list", + /* 170 */ "table_reference_list ::= table_reference", + /* 171 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 172 */ "table_reference ::= table_primary", + /* 173 */ "table_reference ::= joined_table", + /* 174 */ "table_primary ::= table_name alias_opt", + /* 175 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 176 */ "table_primary ::= subquery alias_opt", + /* 177 */ "table_primary ::= parenthesized_joined_table", + /* 178 */ "alias_opt ::=", + /* 179 */ "alias_opt ::= table_alias", + /* 180 */ "alias_opt ::= AS table_alias", + /* 181 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 182 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 183 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 184 */ "join_type ::=", + /* 185 */ "join_type ::= INNER", + /* 186 */ "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", + /* 187 */ "set_quantifier_opt ::=", + /* 188 */ "set_quantifier_opt ::= DISTINCT", + /* 189 */ "set_quantifier_opt ::= ALL", + /* 190 */ "select_list ::= NK_STAR", + /* 191 */ "select_list ::= select_sublist", + /* 192 */ "select_sublist ::= select_item", + /* 193 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 194 */ "select_item ::= common_expression", + /* 195 */ "select_item ::= common_expression column_alias", + /* 196 */ "select_item ::= common_expression AS column_alias", + /* 197 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 198 */ "where_clause_opt ::=", + /* 199 */ "where_clause_opt ::= WHERE search_condition", + /* 200 */ "partition_by_clause_opt ::=", + /* 201 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 202 */ "twindow_clause_opt ::=", + /* 203 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP", + /* 204 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", + /* 205 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 206 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 207 */ "sliding_opt ::=", + /* 208 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 209 */ "fill_opt ::=", + /* 210 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 211 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 212 */ "fill_mode ::= NONE", + /* 213 */ "fill_mode ::= PREV", + /* 214 */ "fill_mode ::= NULL", + /* 215 */ "fill_mode ::= LINEAR", + /* 216 */ "fill_mode ::= NEXT", + /* 217 */ "group_by_clause_opt ::=", + /* 218 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 219 */ "group_by_list ::= expression", + /* 220 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 221 */ "having_clause_opt ::=", + /* 222 */ "having_clause_opt ::= HAVING search_condition", + /* 223 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 224 */ "query_expression_body ::= query_primary", + /* 225 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 226 */ "query_primary ::= query_specification", + /* 227 */ "order_by_clause_opt ::=", + /* 228 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 229 */ "slimit_clause_opt ::=", + /* 230 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 231 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 232 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 233 */ "limit_clause_opt ::=", + /* 234 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 235 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 236 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 237 */ "subquery ::= NK_LP query_expression NK_RP", + /* 238 */ "search_condition ::= common_expression", + /* 239 */ "sort_specification_list ::= sort_specification", + /* 240 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 241 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 242 */ "ordering_specification_opt ::=", + /* 243 */ "ordering_specification_opt ::= ASC", + /* 244 */ "ordering_specification_opt ::= DESC", + /* 245 */ "null_ordering_opt ::=", + /* 246 */ "null_ordering_opt ::= NULLS FIRST", + /* 247 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -1219,120 +1212,120 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 138: /* cmd */ - case 144: /* db_options */ - case 146: /* full_table_name */ - case 149: /* table_options */ - case 153: /* create_subtable_clause */ - case 156: /* drop_table_clause */ - case 159: /* column_def */ - case 162: /* col_name */ - case 164: /* index_options */ - case 166: /* duration_literal */ - case 167: /* sliding_opt */ - case 168: /* func */ - case 171: /* query_expression */ - case 172: /* literal */ - case 175: /* expression */ - case 176: /* column_reference */ - case 177: /* subquery */ - case 178: /* predicate */ - case 181: /* in_predicate_value */ - case 182: /* boolean_value_expression */ - case 183: /* boolean_primary */ - case 184: /* common_expression */ - case 185: /* from_clause */ - case 186: /* table_reference_list */ - case 187: /* table_reference */ - case 188: /* table_primary */ - case 189: /* joined_table */ - case 191: /* parenthesized_joined_table */ - case 193: /* search_condition */ - case 194: /* query_specification */ - case 197: /* where_clause_opt */ - case 199: /* twindow_clause_opt */ - case 201: /* having_clause_opt */ - case 203: /* select_item */ - case 204: /* fill_opt */ - case 207: /* query_expression_body */ - case 209: /* slimit_clause_opt */ - case 210: /* limit_clause_opt */ - case 211: /* query_primary */ - case 213: /* sort_specification */ + case 140: /* cmd */ + case 146: /* db_options */ + case 148: /* full_table_name */ + case 151: /* table_options */ + case 155: /* create_subtable_clause */ + case 158: /* drop_table_clause */ + case 161: /* column_def */ + case 164: /* col_name */ + case 166: /* index_options */ + case 168: /* duration_literal */ + case 169: /* sliding_opt */ + case 170: /* func */ + case 173: /* query_expression */ + case 174: /* literal */ + case 177: /* expression */ + case 178: /* column_reference */ + case 179: /* subquery */ + case 180: /* predicate */ + case 183: /* in_predicate_value */ + case 184: /* boolean_value_expression */ + case 185: /* boolean_primary */ + case 186: /* common_expression */ + case 187: /* from_clause */ + case 188: /* table_reference_list */ + case 189: /* table_reference */ + case 190: /* table_primary */ + case 191: /* joined_table */ + case 193: /* parenthesized_joined_table */ + case 195: /* search_condition */ + case 196: /* query_specification */ + case 199: /* where_clause_opt */ + case 201: /* twindow_clause_opt */ + case 203: /* having_clause_opt */ + case 205: /* select_item */ + case 206: /* fill_opt */ + case 209: /* query_expression_body */ + case 211: /* slimit_clause_opt */ + case 212: /* limit_clause_opt */ + case 213: /* query_primary */ + case 215: /* sort_specification */ { - nodesDestroyNode((yypminor->yy344)); + nodesDestroyNode((yypminor->yy68)); } break; - case 139: /* user_name */ - case 140: /* dnode_endpoint */ - case 141: /* dnode_host_name */ - case 143: /* db_name */ - case 158: /* table_name */ - case 160: /* column_name */ - case 163: /* index_name */ - case 169: /* function_name */ - case 173: /* table_alias */ - case 174: /* column_alias */ - case 190: /* alias_opt */ + case 141: /* user_name */ + case 142: /* dnode_endpoint */ + case 143: /* dnode_host_name */ + case 145: /* db_name */ + case 160: /* table_name */ + case 162: /* column_name */ + case 165: /* index_name */ + case 171: /* function_name */ + case 175: /* table_alias */ + case 176: /* column_alias */ + case 192: /* alias_opt */ { } break; - case 142: /* not_exists_opt */ - case 145: /* exists_opt */ - case 195: /* set_quantifier_opt */ + case 144: /* not_exists_opt */ + case 147: /* exists_opt */ + case 197: /* set_quantifier_opt */ { } break; - case 147: /* column_def_list */ - case 148: /* tags_def_opt */ - case 150: /* multi_create_clause */ - case 151: /* tags_def */ - case 152: /* multi_drop_clause */ - case 154: /* specific_tags_opt */ - case 155: /* literal_list */ - case 157: /* col_name_list */ - case 165: /* func_list */ - case 170: /* expression_list */ - case 196: /* select_list */ - case 198: /* partition_by_clause_opt */ - case 200: /* group_by_clause_opt */ - case 202: /* select_sublist */ - case 206: /* group_by_list */ - case 208: /* order_by_clause_opt */ - case 212: /* sort_specification_list */ + case 149: /* column_def_list */ + case 150: /* tags_def_opt */ + case 152: /* multi_create_clause */ + case 153: /* tags_def */ + case 154: /* multi_drop_clause */ + case 156: /* specific_tags_opt */ + case 157: /* literal_list */ + case 159: /* col_name_list */ + case 167: /* func_list */ + case 172: /* expression_list */ + case 198: /* select_list */ + case 200: /* partition_by_clause_opt */ + case 202: /* group_by_clause_opt */ + case 204: /* select_sublist */ + case 208: /* group_by_list */ + case 210: /* order_by_clause_opt */ + case 214: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy280)); + nodesDestroyList((yypminor->yy40)); } break; - case 161: /* type_name */ + case 163: /* type_name */ { } break; - case 179: /* compare_op */ - case 180: /* in_op */ + case 181: /* compare_op */ + case 182: /* in_op */ { } break; - case 192: /* join_type */ + case 194: /* join_type */ { } break; - case 205: /* fill_mode */ + case 207: /* fill_mode */ { } break; - case 214: /* ordering_specification_opt */ + case 216: /* ordering_specification_opt */ { } break; - case 215: /* null_ordering_opt */ + case 217: /* null_ordering_opt */ { } @@ -1631,252 +1624,254 @@ 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[] = { - { 138, -5 }, /* (0) cmd ::= CREATE USER user_name PASS NK_STRING */ - { 138, -5 }, /* (1) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 138, -5 }, /* (2) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ - { 138, -3 }, /* (3) cmd ::= DROP USER user_name */ - { 138, -2 }, /* (4) cmd ::= SHOW USERS */ - { 138, -3 }, /* (5) cmd ::= CREATE DNODE dnode_endpoint */ - { 138, -5 }, /* (6) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ - { 138, -3 }, /* (7) cmd ::= DROP DNODE NK_INTEGER */ - { 138, -3 }, /* (8) cmd ::= DROP DNODE dnode_endpoint */ - { 138, -2 }, /* (9) cmd ::= SHOW DNODES */ - { 140, -1 }, /* (10) dnode_endpoint ::= NK_STRING */ - { 141, -1 }, /* (11) dnode_host_name ::= NK_ID */ - { 141, -1 }, /* (12) dnode_host_name ::= NK_IPTOKEN */ - { 138, -5 }, /* (13) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 138, -4 }, /* (14) cmd ::= DROP DATABASE exists_opt db_name */ - { 138, -2 }, /* (15) cmd ::= SHOW DATABASES */ - { 138, -2 }, /* (16) cmd ::= USE db_name */ - { 142, -3 }, /* (17) not_exists_opt ::= IF NOT EXISTS */ - { 142, 0 }, /* (18) not_exists_opt ::= */ - { 145, -2 }, /* (19) exists_opt ::= IF EXISTS */ - { 145, 0 }, /* (20) exists_opt ::= */ - { 144, 0 }, /* (21) db_options ::= */ - { 144, -3 }, /* (22) db_options ::= db_options BLOCKS NK_INTEGER */ - { 144, -3 }, /* (23) db_options ::= db_options CACHE NK_INTEGER */ - { 144, -3 }, /* (24) db_options ::= db_options CACHELAST NK_INTEGER */ - { 144, -3 }, /* (25) db_options ::= db_options COMP NK_INTEGER */ - { 144, -3 }, /* (26) db_options ::= db_options DAYS NK_INTEGER */ - { 144, -3 }, /* (27) db_options ::= db_options FSYNC NK_INTEGER */ - { 144, -3 }, /* (28) db_options ::= db_options MAXROWS NK_INTEGER */ - { 144, -3 }, /* (29) db_options ::= db_options MINROWS NK_INTEGER */ - { 144, -3 }, /* (30) db_options ::= db_options KEEP NK_INTEGER */ - { 144, -3 }, /* (31) db_options ::= db_options PRECISION NK_STRING */ - { 144, -3 }, /* (32) db_options ::= db_options QUORUM NK_INTEGER */ - { 144, -3 }, /* (33) db_options ::= db_options REPLICA NK_INTEGER */ - { 144, -3 }, /* (34) db_options ::= db_options TTL NK_INTEGER */ - { 144, -3 }, /* (35) db_options ::= db_options WAL NK_INTEGER */ - { 144, -3 }, /* (36) db_options ::= db_options VGROUPS NK_INTEGER */ - { 144, -3 }, /* (37) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 144, -3 }, /* (38) db_options ::= db_options STREAM_MODE NK_INTEGER */ - { 138, -9 }, /* (39) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 138, -3 }, /* (40) cmd ::= CREATE TABLE multi_create_clause */ - { 138, -9 }, /* (41) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 138, -3 }, /* (42) cmd ::= DROP TABLE multi_drop_clause */ - { 138, -4 }, /* (43) cmd ::= DROP STABLE exists_opt full_table_name */ - { 138, -2 }, /* (44) cmd ::= SHOW TABLES */ - { 138, -2 }, /* (45) cmd ::= SHOW STABLES */ - { 150, -1 }, /* (46) multi_create_clause ::= create_subtable_clause */ - { 150, -2 }, /* (47) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 153, -9 }, /* (48) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ - { 152, -1 }, /* (49) multi_drop_clause ::= drop_table_clause */ - { 152, -2 }, /* (50) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 156, -2 }, /* (51) drop_table_clause ::= exists_opt full_table_name */ - { 154, 0 }, /* (52) specific_tags_opt ::= */ - { 154, -3 }, /* (53) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - { 146, -1 }, /* (54) full_table_name ::= table_name */ - { 146, -3 }, /* (55) full_table_name ::= db_name NK_DOT table_name */ - { 147, -1 }, /* (56) column_def_list ::= column_def */ - { 147, -3 }, /* (57) column_def_list ::= column_def_list NK_COMMA column_def */ - { 159, -2 }, /* (58) column_def ::= column_name type_name */ - { 159, -4 }, /* (59) column_def ::= column_name type_name COMMENT NK_STRING */ - { 161, -1 }, /* (60) type_name ::= BOOL */ - { 161, -1 }, /* (61) type_name ::= TINYINT */ - { 161, -1 }, /* (62) type_name ::= SMALLINT */ - { 161, -1 }, /* (63) type_name ::= INT */ - { 161, -1 }, /* (64) type_name ::= INTEGER */ - { 161, -1 }, /* (65) type_name ::= BIGINT */ - { 161, -1 }, /* (66) type_name ::= FLOAT */ - { 161, -1 }, /* (67) type_name ::= DOUBLE */ - { 161, -4 }, /* (68) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 161, -1 }, /* (69) type_name ::= TIMESTAMP */ - { 161, -4 }, /* (70) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 161, -2 }, /* (71) type_name ::= TINYINT UNSIGNED */ - { 161, -2 }, /* (72) type_name ::= SMALLINT UNSIGNED */ - { 161, -2 }, /* (73) type_name ::= INT UNSIGNED */ - { 161, -2 }, /* (74) type_name ::= BIGINT UNSIGNED */ - { 161, -1 }, /* (75) type_name ::= JSON */ - { 161, -4 }, /* (76) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 161, -1 }, /* (77) type_name ::= MEDIUMBLOB */ - { 161, -1 }, /* (78) type_name ::= BLOB */ - { 161, -4 }, /* (79) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 161, -1 }, /* (80) type_name ::= DECIMAL */ - { 161, -4 }, /* (81) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 161, -6 }, /* (82) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 148, 0 }, /* (83) tags_def_opt ::= */ - { 148, -1 }, /* (84) tags_def_opt ::= tags_def */ - { 151, -4 }, /* (85) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 149, 0 }, /* (86) table_options ::= */ - { 149, -3 }, /* (87) table_options ::= table_options COMMENT NK_STRING */ - { 149, -3 }, /* (88) table_options ::= table_options KEEP NK_INTEGER */ - { 149, -3 }, /* (89) table_options ::= table_options TTL NK_INTEGER */ - { 149, -5 }, /* (90) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 157, -1 }, /* (91) col_name_list ::= col_name */ - { 157, -3 }, /* (92) col_name_list ::= col_name_list NK_COMMA col_name */ - { 162, -1 }, /* (93) col_name ::= column_name */ - { 138, -7 }, /* (94) cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ - { 138, -9 }, /* (95) cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ - { 164, 0 }, /* (96) index_options ::= */ - { 164, -9 }, /* (97) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ - { 164, -11 }, /* (98) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ - { 165, -1 }, /* (99) func_list ::= func */ - { 165, -3 }, /* (100) func_list ::= func_list NK_COMMA func */ - { 168, -4 }, /* (101) func ::= function_name NK_LP expression_list NK_RP */ - { 138, -2 }, /* (102) cmd ::= SHOW VGROUPS */ - { 138, -4 }, /* (103) cmd ::= SHOW db_name NK_DOT VGROUPS */ - { 138, -2 }, /* (104) cmd ::= SHOW MNODES */ - { 138, -1 }, /* (105) cmd ::= query_expression */ - { 172, -1 }, /* (106) literal ::= NK_INTEGER */ - { 172, -1 }, /* (107) literal ::= NK_FLOAT */ - { 172, -1 }, /* (108) literal ::= NK_STRING */ - { 172, -1 }, /* (109) literal ::= NK_BOOL */ - { 172, -2 }, /* (110) literal ::= TIMESTAMP NK_STRING */ - { 172, -1 }, /* (111) literal ::= duration_literal */ - { 166, -1 }, /* (112) duration_literal ::= NK_VARIABLE */ - { 155, -1 }, /* (113) literal_list ::= literal */ - { 155, -3 }, /* (114) literal_list ::= literal_list NK_COMMA literal */ - { 143, -1 }, /* (115) db_name ::= NK_ID */ - { 158, -1 }, /* (116) table_name ::= NK_ID */ - { 160, -1 }, /* (117) column_name ::= NK_ID */ - { 169, -1 }, /* (118) function_name ::= NK_ID */ - { 173, -1 }, /* (119) table_alias ::= NK_ID */ - { 174, -1 }, /* (120) column_alias ::= NK_ID */ - { 139, -1 }, /* (121) user_name ::= NK_ID */ - { 163, -1 }, /* (122) index_name ::= NK_ID */ - { 175, -1 }, /* (123) expression ::= literal */ - { 175, -1 }, /* (124) expression ::= column_reference */ - { 175, -4 }, /* (125) expression ::= function_name NK_LP expression_list NK_RP */ - { 175, -4 }, /* (126) expression ::= function_name NK_LP NK_STAR NK_RP */ - { 175, -1 }, /* (127) expression ::= subquery */ - { 175, -3 }, /* (128) expression ::= NK_LP expression NK_RP */ - { 175, -2 }, /* (129) expression ::= NK_PLUS expression */ - { 175, -2 }, /* (130) expression ::= NK_MINUS expression */ - { 175, -3 }, /* (131) expression ::= expression NK_PLUS expression */ - { 175, -3 }, /* (132) expression ::= expression NK_MINUS expression */ - { 175, -3 }, /* (133) expression ::= expression NK_STAR expression */ - { 175, -3 }, /* (134) expression ::= expression NK_SLASH expression */ - { 175, -3 }, /* (135) expression ::= expression NK_REM expression */ - { 170, -1 }, /* (136) expression_list ::= expression */ - { 170, -3 }, /* (137) expression_list ::= expression_list NK_COMMA expression */ - { 176, -1 }, /* (138) column_reference ::= column_name */ - { 176, -3 }, /* (139) column_reference ::= table_name NK_DOT column_name */ - { 178, -3 }, /* (140) predicate ::= expression compare_op expression */ - { 178, -5 }, /* (141) predicate ::= expression BETWEEN expression AND expression */ - { 178, -6 }, /* (142) predicate ::= expression NOT BETWEEN expression AND expression */ - { 178, -3 }, /* (143) predicate ::= expression IS NULL */ - { 178, -4 }, /* (144) predicate ::= expression IS NOT NULL */ - { 178, -3 }, /* (145) predicate ::= expression in_op in_predicate_value */ - { 179, -1 }, /* (146) compare_op ::= NK_LT */ - { 179, -1 }, /* (147) compare_op ::= NK_GT */ - { 179, -1 }, /* (148) compare_op ::= NK_LE */ - { 179, -1 }, /* (149) compare_op ::= NK_GE */ - { 179, -1 }, /* (150) compare_op ::= NK_NE */ - { 179, -1 }, /* (151) compare_op ::= NK_EQ */ - { 179, -1 }, /* (152) compare_op ::= LIKE */ - { 179, -2 }, /* (153) compare_op ::= NOT LIKE */ - { 179, -1 }, /* (154) compare_op ::= MATCH */ - { 179, -1 }, /* (155) compare_op ::= NMATCH */ - { 180, -1 }, /* (156) in_op ::= IN */ - { 180, -2 }, /* (157) in_op ::= NOT IN */ - { 181, -3 }, /* (158) in_predicate_value ::= NK_LP expression_list NK_RP */ - { 182, -1 }, /* (159) boolean_value_expression ::= boolean_primary */ - { 182, -2 }, /* (160) boolean_value_expression ::= NOT boolean_primary */ - { 182, -3 }, /* (161) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 182, -3 }, /* (162) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 183, -1 }, /* (163) boolean_primary ::= predicate */ - { 183, -3 }, /* (164) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 184, -1 }, /* (165) common_expression ::= expression */ - { 184, -1 }, /* (166) common_expression ::= boolean_value_expression */ - { 185, -2 }, /* (167) from_clause ::= FROM table_reference_list */ - { 186, -1 }, /* (168) table_reference_list ::= table_reference */ - { 186, -3 }, /* (169) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 187, -1 }, /* (170) table_reference ::= table_primary */ - { 187, -1 }, /* (171) table_reference ::= joined_table */ - { 188, -2 }, /* (172) table_primary ::= table_name alias_opt */ - { 188, -4 }, /* (173) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 188, -2 }, /* (174) table_primary ::= subquery alias_opt */ - { 188, -1 }, /* (175) table_primary ::= parenthesized_joined_table */ - { 190, 0 }, /* (176) alias_opt ::= */ - { 190, -1 }, /* (177) alias_opt ::= table_alias */ - { 190, -2 }, /* (178) alias_opt ::= AS table_alias */ - { 191, -3 }, /* (179) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 191, -3 }, /* (180) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 189, -6 }, /* (181) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 192, 0 }, /* (182) join_type ::= */ - { 192, -1 }, /* (183) join_type ::= INNER */ - { 194, -9 }, /* (184) 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 */ - { 195, 0 }, /* (185) set_quantifier_opt ::= */ - { 195, -1 }, /* (186) set_quantifier_opt ::= DISTINCT */ - { 195, -1 }, /* (187) set_quantifier_opt ::= ALL */ - { 196, -1 }, /* (188) select_list ::= NK_STAR */ - { 196, -1 }, /* (189) select_list ::= select_sublist */ - { 202, -1 }, /* (190) select_sublist ::= select_item */ - { 202, -3 }, /* (191) select_sublist ::= select_sublist NK_COMMA select_item */ - { 203, -1 }, /* (192) select_item ::= common_expression */ - { 203, -2 }, /* (193) select_item ::= common_expression column_alias */ - { 203, -3 }, /* (194) select_item ::= common_expression AS column_alias */ - { 203, -3 }, /* (195) select_item ::= table_name NK_DOT NK_STAR */ - { 197, 0 }, /* (196) where_clause_opt ::= */ - { 197, -2 }, /* (197) where_clause_opt ::= WHERE search_condition */ - { 198, 0 }, /* (198) partition_by_clause_opt ::= */ - { 198, -3 }, /* (199) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 199, 0 }, /* (200) twindow_clause_opt ::= */ - { 199, -6 }, /* (201) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ - { 199, -4 }, /* (202) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ - { 199, -6 }, /* (203) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 199, -8 }, /* (204) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 167, 0 }, /* (205) sliding_opt ::= */ - { 167, -4 }, /* (206) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 204, 0 }, /* (207) fill_opt ::= */ - { 204, -4 }, /* (208) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 204, -6 }, /* (209) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 205, -1 }, /* (210) fill_mode ::= NONE */ - { 205, -1 }, /* (211) fill_mode ::= PREV */ - { 205, -1 }, /* (212) fill_mode ::= NULL */ - { 205, -1 }, /* (213) fill_mode ::= LINEAR */ - { 205, -1 }, /* (214) fill_mode ::= NEXT */ - { 200, 0 }, /* (215) group_by_clause_opt ::= */ - { 200, -3 }, /* (216) group_by_clause_opt ::= GROUP BY group_by_list */ - { 206, -1 }, /* (217) group_by_list ::= expression */ - { 206, -3 }, /* (218) group_by_list ::= group_by_list NK_COMMA expression */ - { 201, 0 }, /* (219) having_clause_opt ::= */ - { 201, -2 }, /* (220) having_clause_opt ::= HAVING search_condition */ - { 171, -4 }, /* (221) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 207, -1 }, /* (222) query_expression_body ::= query_primary */ - { 207, -4 }, /* (223) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 211, -1 }, /* (224) query_primary ::= query_specification */ - { 208, 0 }, /* (225) order_by_clause_opt ::= */ - { 208, -3 }, /* (226) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 209, 0 }, /* (227) slimit_clause_opt ::= */ - { 209, -2 }, /* (228) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 209, -4 }, /* (229) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 209, -4 }, /* (230) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 210, 0 }, /* (231) limit_clause_opt ::= */ - { 210, -2 }, /* (232) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 210, -4 }, /* (233) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 210, -4 }, /* (234) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 177, -3 }, /* (235) subquery ::= NK_LP query_expression NK_RP */ - { 193, -1 }, /* (236) search_condition ::= common_expression */ - { 212, -1 }, /* (237) sort_specification_list ::= sort_specification */ - { 212, -3 }, /* (238) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 213, -3 }, /* (239) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 214, 0 }, /* (240) ordering_specification_opt ::= */ - { 214, -1 }, /* (241) ordering_specification_opt ::= ASC */ - { 214, -1 }, /* (242) ordering_specification_opt ::= DESC */ - { 215, 0 }, /* (243) null_ordering_opt ::= */ - { 215, -2 }, /* (244) null_ordering_opt ::= NULLS FIRST */ - { 215, -2 }, /* (245) null_ordering_opt ::= NULLS LAST */ + { 140, -5 }, /* (0) cmd ::= CREATE USER user_name PASS NK_STRING */ + { 140, -5 }, /* (1) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 140, -5 }, /* (2) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ + { 140, -3 }, /* (3) cmd ::= DROP USER user_name */ + { 140, -2 }, /* (4) cmd ::= SHOW USERS */ + { 140, -3 }, /* (5) cmd ::= CREATE DNODE dnode_endpoint */ + { 140, -5 }, /* (6) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ + { 140, -3 }, /* (7) cmd ::= DROP DNODE NK_INTEGER */ + { 140, -3 }, /* (8) cmd ::= DROP DNODE dnode_endpoint */ + { 140, -2 }, /* (9) cmd ::= SHOW DNODES */ + { 142, -1 }, /* (10) dnode_endpoint ::= NK_STRING */ + { 143, -1 }, /* (11) dnode_host_name ::= NK_ID */ + { 143, -1 }, /* (12) dnode_host_name ::= NK_IPTOKEN */ + { 140, -5 }, /* (13) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 140, -2 }, /* (14) cmd ::= SHOW QNODES */ + { 140, -5 }, /* (15) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 140, -4 }, /* (16) cmd ::= DROP DATABASE exists_opt db_name */ + { 140, -2 }, /* (17) cmd ::= SHOW DATABASES */ + { 140, -2 }, /* (18) cmd ::= USE db_name */ + { 144, -3 }, /* (19) not_exists_opt ::= IF NOT EXISTS */ + { 144, 0 }, /* (20) not_exists_opt ::= */ + { 147, -2 }, /* (21) exists_opt ::= IF EXISTS */ + { 147, 0 }, /* (22) exists_opt ::= */ + { 146, 0 }, /* (23) db_options ::= */ + { 146, -3 }, /* (24) db_options ::= db_options BLOCKS NK_INTEGER */ + { 146, -3 }, /* (25) db_options ::= db_options CACHE NK_INTEGER */ + { 146, -3 }, /* (26) db_options ::= db_options CACHELAST NK_INTEGER */ + { 146, -3 }, /* (27) db_options ::= db_options COMP NK_INTEGER */ + { 146, -3 }, /* (28) db_options ::= db_options DAYS NK_INTEGER */ + { 146, -3 }, /* (29) db_options ::= db_options FSYNC NK_INTEGER */ + { 146, -3 }, /* (30) db_options ::= db_options MAXROWS NK_INTEGER */ + { 146, -3 }, /* (31) db_options ::= db_options MINROWS NK_INTEGER */ + { 146, -3 }, /* (32) db_options ::= db_options KEEP NK_INTEGER */ + { 146, -3 }, /* (33) db_options ::= db_options PRECISION NK_STRING */ + { 146, -3 }, /* (34) db_options ::= db_options QUORUM NK_INTEGER */ + { 146, -3 }, /* (35) db_options ::= db_options REPLICA NK_INTEGER */ + { 146, -3 }, /* (36) db_options ::= db_options TTL NK_INTEGER */ + { 146, -3 }, /* (37) db_options ::= db_options WAL NK_INTEGER */ + { 146, -3 }, /* (38) db_options ::= db_options VGROUPS NK_INTEGER */ + { 146, -3 }, /* (39) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 146, -3 }, /* (40) db_options ::= db_options STREAM_MODE NK_INTEGER */ + { 140, -9 }, /* (41) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 140, -3 }, /* (42) cmd ::= CREATE TABLE multi_create_clause */ + { 140, -9 }, /* (43) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 140, -3 }, /* (44) cmd ::= DROP TABLE multi_drop_clause */ + { 140, -4 }, /* (45) cmd ::= DROP STABLE exists_opt full_table_name */ + { 140, -2 }, /* (46) cmd ::= SHOW TABLES */ + { 140, -2 }, /* (47) cmd ::= SHOW STABLES */ + { 152, -1 }, /* (48) multi_create_clause ::= create_subtable_clause */ + { 152, -2 }, /* (49) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 155, -9 }, /* (50) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ + { 154, -1 }, /* (51) multi_drop_clause ::= drop_table_clause */ + { 154, -2 }, /* (52) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 158, -2 }, /* (53) drop_table_clause ::= exists_opt full_table_name */ + { 156, 0 }, /* (54) specific_tags_opt ::= */ + { 156, -3 }, /* (55) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + { 148, -1 }, /* (56) full_table_name ::= table_name */ + { 148, -3 }, /* (57) full_table_name ::= db_name NK_DOT table_name */ + { 149, -1 }, /* (58) column_def_list ::= column_def */ + { 149, -3 }, /* (59) column_def_list ::= column_def_list NK_COMMA column_def */ + { 161, -2 }, /* (60) column_def ::= column_name type_name */ + { 161, -4 }, /* (61) column_def ::= column_name type_name COMMENT NK_STRING */ + { 163, -1 }, /* (62) type_name ::= BOOL */ + { 163, -1 }, /* (63) type_name ::= TINYINT */ + { 163, -1 }, /* (64) type_name ::= SMALLINT */ + { 163, -1 }, /* (65) type_name ::= INT */ + { 163, -1 }, /* (66) type_name ::= INTEGER */ + { 163, -1 }, /* (67) type_name ::= BIGINT */ + { 163, -1 }, /* (68) type_name ::= FLOAT */ + { 163, -1 }, /* (69) type_name ::= DOUBLE */ + { 163, -4 }, /* (70) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 163, -1 }, /* (71) type_name ::= TIMESTAMP */ + { 163, -4 }, /* (72) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 163, -2 }, /* (73) type_name ::= TINYINT UNSIGNED */ + { 163, -2 }, /* (74) type_name ::= SMALLINT UNSIGNED */ + { 163, -2 }, /* (75) type_name ::= INT UNSIGNED */ + { 163, -2 }, /* (76) type_name ::= BIGINT UNSIGNED */ + { 163, -1 }, /* (77) type_name ::= JSON */ + { 163, -4 }, /* (78) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 163, -1 }, /* (79) type_name ::= MEDIUMBLOB */ + { 163, -1 }, /* (80) type_name ::= BLOB */ + { 163, -4 }, /* (81) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 163, -1 }, /* (82) type_name ::= DECIMAL */ + { 163, -4 }, /* (83) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 163, -6 }, /* (84) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 150, 0 }, /* (85) tags_def_opt ::= */ + { 150, -1 }, /* (86) tags_def_opt ::= tags_def */ + { 153, -4 }, /* (87) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 151, 0 }, /* (88) table_options ::= */ + { 151, -3 }, /* (89) table_options ::= table_options COMMENT NK_STRING */ + { 151, -3 }, /* (90) table_options ::= table_options KEEP NK_INTEGER */ + { 151, -3 }, /* (91) table_options ::= table_options TTL NK_INTEGER */ + { 151, -5 }, /* (92) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 159, -1 }, /* (93) col_name_list ::= col_name */ + { 159, -3 }, /* (94) col_name_list ::= col_name_list NK_COMMA col_name */ + { 164, -1 }, /* (95) col_name ::= column_name */ + { 140, -7 }, /* (96) cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ + { 140, -9 }, /* (97) cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ + { 166, 0 }, /* (98) index_options ::= */ + { 166, -9 }, /* (99) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ + { 166, -11 }, /* (100) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ + { 167, -1 }, /* (101) func_list ::= func */ + { 167, -3 }, /* (102) func_list ::= func_list NK_COMMA func */ + { 170, -4 }, /* (103) func ::= function_name NK_LP expression_list NK_RP */ + { 140, -2 }, /* (104) cmd ::= SHOW VGROUPS */ + { 140, -4 }, /* (105) cmd ::= SHOW db_name NK_DOT VGROUPS */ + { 140, -2 }, /* (106) cmd ::= SHOW MNODES */ + { 140, -1 }, /* (107) cmd ::= query_expression */ + { 174, -1 }, /* (108) literal ::= NK_INTEGER */ + { 174, -1 }, /* (109) literal ::= NK_FLOAT */ + { 174, -1 }, /* (110) literal ::= NK_STRING */ + { 174, -1 }, /* (111) literal ::= NK_BOOL */ + { 174, -2 }, /* (112) literal ::= TIMESTAMP NK_STRING */ + { 174, -1 }, /* (113) literal ::= duration_literal */ + { 168, -1 }, /* (114) duration_literal ::= NK_VARIABLE */ + { 157, -1 }, /* (115) literal_list ::= literal */ + { 157, -3 }, /* (116) literal_list ::= literal_list NK_COMMA literal */ + { 145, -1 }, /* (117) db_name ::= NK_ID */ + { 160, -1 }, /* (118) table_name ::= NK_ID */ + { 162, -1 }, /* (119) column_name ::= NK_ID */ + { 171, -1 }, /* (120) function_name ::= NK_ID */ + { 175, -1 }, /* (121) table_alias ::= NK_ID */ + { 176, -1 }, /* (122) column_alias ::= NK_ID */ + { 141, -1 }, /* (123) user_name ::= NK_ID */ + { 165, -1 }, /* (124) index_name ::= NK_ID */ + { 177, -1 }, /* (125) expression ::= literal */ + { 177, -1 }, /* (126) expression ::= column_reference */ + { 177, -4 }, /* (127) expression ::= function_name NK_LP expression_list NK_RP */ + { 177, -4 }, /* (128) expression ::= function_name NK_LP NK_STAR NK_RP */ + { 177, -1 }, /* (129) expression ::= subquery */ + { 177, -3 }, /* (130) expression ::= NK_LP expression NK_RP */ + { 177, -2 }, /* (131) expression ::= NK_PLUS expression */ + { 177, -2 }, /* (132) expression ::= NK_MINUS expression */ + { 177, -3 }, /* (133) expression ::= expression NK_PLUS expression */ + { 177, -3 }, /* (134) expression ::= expression NK_MINUS expression */ + { 177, -3 }, /* (135) expression ::= expression NK_STAR expression */ + { 177, -3 }, /* (136) expression ::= expression NK_SLASH expression */ + { 177, -3 }, /* (137) expression ::= expression NK_REM expression */ + { 172, -1 }, /* (138) expression_list ::= expression */ + { 172, -3 }, /* (139) expression_list ::= expression_list NK_COMMA expression */ + { 178, -1 }, /* (140) column_reference ::= column_name */ + { 178, -3 }, /* (141) column_reference ::= table_name NK_DOT column_name */ + { 180, -3 }, /* (142) predicate ::= expression compare_op expression */ + { 180, -5 }, /* (143) predicate ::= expression BETWEEN expression AND expression */ + { 180, -6 }, /* (144) predicate ::= expression NOT BETWEEN expression AND expression */ + { 180, -3 }, /* (145) predicate ::= expression IS NULL */ + { 180, -4 }, /* (146) predicate ::= expression IS NOT NULL */ + { 180, -3 }, /* (147) predicate ::= expression in_op in_predicate_value */ + { 181, -1 }, /* (148) compare_op ::= NK_LT */ + { 181, -1 }, /* (149) compare_op ::= NK_GT */ + { 181, -1 }, /* (150) compare_op ::= NK_LE */ + { 181, -1 }, /* (151) compare_op ::= NK_GE */ + { 181, -1 }, /* (152) compare_op ::= NK_NE */ + { 181, -1 }, /* (153) compare_op ::= NK_EQ */ + { 181, -1 }, /* (154) compare_op ::= LIKE */ + { 181, -2 }, /* (155) compare_op ::= NOT LIKE */ + { 181, -1 }, /* (156) compare_op ::= MATCH */ + { 181, -1 }, /* (157) compare_op ::= NMATCH */ + { 182, -1 }, /* (158) in_op ::= IN */ + { 182, -2 }, /* (159) in_op ::= NOT IN */ + { 183, -3 }, /* (160) in_predicate_value ::= NK_LP expression_list NK_RP */ + { 184, -1 }, /* (161) boolean_value_expression ::= boolean_primary */ + { 184, -2 }, /* (162) boolean_value_expression ::= NOT boolean_primary */ + { 184, -3 }, /* (163) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 184, -3 }, /* (164) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 185, -1 }, /* (165) boolean_primary ::= predicate */ + { 185, -3 }, /* (166) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 186, -1 }, /* (167) common_expression ::= expression */ + { 186, -1 }, /* (168) common_expression ::= boolean_value_expression */ + { 187, -2 }, /* (169) from_clause ::= FROM table_reference_list */ + { 188, -1 }, /* (170) table_reference_list ::= table_reference */ + { 188, -3 }, /* (171) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 189, -1 }, /* (172) table_reference ::= table_primary */ + { 189, -1 }, /* (173) table_reference ::= joined_table */ + { 190, -2 }, /* (174) table_primary ::= table_name alias_opt */ + { 190, -4 }, /* (175) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 190, -2 }, /* (176) table_primary ::= subquery alias_opt */ + { 190, -1 }, /* (177) table_primary ::= parenthesized_joined_table */ + { 192, 0 }, /* (178) alias_opt ::= */ + { 192, -1 }, /* (179) alias_opt ::= table_alias */ + { 192, -2 }, /* (180) alias_opt ::= AS table_alias */ + { 193, -3 }, /* (181) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 193, -3 }, /* (182) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 191, -6 }, /* (183) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 194, 0 }, /* (184) join_type ::= */ + { 194, -1 }, /* (185) join_type ::= INNER */ + { 196, -9 }, /* (186) 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 */ + { 197, 0 }, /* (187) set_quantifier_opt ::= */ + { 197, -1 }, /* (188) set_quantifier_opt ::= DISTINCT */ + { 197, -1 }, /* (189) set_quantifier_opt ::= ALL */ + { 198, -1 }, /* (190) select_list ::= NK_STAR */ + { 198, -1 }, /* (191) select_list ::= select_sublist */ + { 204, -1 }, /* (192) select_sublist ::= select_item */ + { 204, -3 }, /* (193) select_sublist ::= select_sublist NK_COMMA select_item */ + { 205, -1 }, /* (194) select_item ::= common_expression */ + { 205, -2 }, /* (195) select_item ::= common_expression column_alias */ + { 205, -3 }, /* (196) select_item ::= common_expression AS column_alias */ + { 205, -3 }, /* (197) select_item ::= table_name NK_DOT NK_STAR */ + { 199, 0 }, /* (198) where_clause_opt ::= */ + { 199, -2 }, /* (199) where_clause_opt ::= WHERE search_condition */ + { 200, 0 }, /* (200) partition_by_clause_opt ::= */ + { 200, -3 }, /* (201) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 201, 0 }, /* (202) twindow_clause_opt ::= */ + { 201, -6 }, /* (203) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ + { 201, -4 }, /* (204) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ + { 201, -6 }, /* (205) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 201, -8 }, /* (206) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 169, 0 }, /* (207) sliding_opt ::= */ + { 169, -4 }, /* (208) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 206, 0 }, /* (209) fill_opt ::= */ + { 206, -4 }, /* (210) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 206, -6 }, /* (211) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 207, -1 }, /* (212) fill_mode ::= NONE */ + { 207, -1 }, /* (213) fill_mode ::= PREV */ + { 207, -1 }, /* (214) fill_mode ::= NULL */ + { 207, -1 }, /* (215) fill_mode ::= LINEAR */ + { 207, -1 }, /* (216) fill_mode ::= NEXT */ + { 202, 0 }, /* (217) group_by_clause_opt ::= */ + { 202, -3 }, /* (218) group_by_clause_opt ::= GROUP BY group_by_list */ + { 208, -1 }, /* (219) group_by_list ::= expression */ + { 208, -3 }, /* (220) group_by_list ::= group_by_list NK_COMMA expression */ + { 203, 0 }, /* (221) having_clause_opt ::= */ + { 203, -2 }, /* (222) having_clause_opt ::= HAVING search_condition */ + { 173, -4 }, /* (223) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 209, -1 }, /* (224) query_expression_body ::= query_primary */ + { 209, -4 }, /* (225) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 213, -1 }, /* (226) query_primary ::= query_specification */ + { 210, 0 }, /* (227) order_by_clause_opt ::= */ + { 210, -3 }, /* (228) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 211, 0 }, /* (229) slimit_clause_opt ::= */ + { 211, -2 }, /* (230) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 211, -4 }, /* (231) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 211, -4 }, /* (232) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 212, 0 }, /* (233) limit_clause_opt ::= */ + { 212, -2 }, /* (234) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 212, -4 }, /* (235) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 212, -4 }, /* (236) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 179, -3 }, /* (237) subquery ::= NK_LP query_expression NK_RP */ + { 195, -1 }, /* (238) search_condition ::= common_expression */ + { 214, -1 }, /* (239) sort_specification_list ::= sort_specification */ + { 214, -3 }, /* (240) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 215, -3 }, /* (241) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 216, 0 }, /* (242) ordering_specification_opt ::= */ + { 216, -1 }, /* (243) ordering_specification_opt ::= ASC */ + { 216, -1 }, /* (244) ordering_specification_opt ::= DESC */ + { 217, 0 }, /* (245) null_ordering_opt ::= */ + { 217, -2 }, /* (246) null_ordering_opt ::= NULLS FIRST */ + { 217, -2 }, /* (247) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -1964,31 +1959,31 @@ static YYACTIONTYPE yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy0);} break; case 1: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy209, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy5, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0);} break; case 2: /* cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy209, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy5, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0);} break; case 3: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy209); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy5); } break; case 4: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL); } break; case 5: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy209, NULL);} +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy5, NULL);} break; case 6: /* cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy0);} break; case 7: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0);} break; case 8: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy209);} +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy5);} break; case 9: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL); } @@ -1996,736 +1991,742 @@ static YYACTIONTYPE yy_reduce( case 10: /* dnode_endpoint ::= NK_STRING */ case 11: /* dnode_host_name ::= NK_ID */ yytestcase(yyruleno==11); case 12: /* dnode_host_name ::= NK_IPTOKEN */ yytestcase(yyruleno==12); - case 115: /* db_name ::= NK_ID */ yytestcase(yyruleno==115); - case 116: /* table_name ::= NK_ID */ yytestcase(yyruleno==116); - case 117: /* column_name ::= NK_ID */ yytestcase(yyruleno==117); - case 118: /* function_name ::= NK_ID */ yytestcase(yyruleno==118); - case 119: /* table_alias ::= NK_ID */ yytestcase(yyruleno==119); - case 120: /* column_alias ::= NK_ID */ yytestcase(yyruleno==120); - case 121: /* user_name ::= NK_ID */ yytestcase(yyruleno==121); - case 122: /* index_name ::= NK_ID */ yytestcase(yyruleno==122); -{ yylhsminor.yy209 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy209 = yylhsminor.yy209; + case 117: /* db_name ::= NK_ID */ yytestcase(yyruleno==117); + case 118: /* table_name ::= NK_ID */ yytestcase(yyruleno==118); + case 119: /* column_name ::= NK_ID */ yytestcase(yyruleno==119); + case 120: /* function_name ::= NK_ID */ yytestcase(yyruleno==120); + case 121: /* table_alias ::= NK_ID */ yytestcase(yyruleno==121); + case 122: /* column_alias ::= NK_ID */ yytestcase(yyruleno==122); + case 123: /* user_name ::= NK_ID */ yytestcase(yyruleno==123); + case 124: /* index_name ::= NK_ID */ yytestcase(yyruleno==124); +{ yylhsminor.yy5 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy5 = yylhsminor.yy5; break; - case 13: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy281, &yymsp[-1].minor.yy209, yymsp[0].minor.yy344);} + case 13: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ +{ pCxt->pRootNode = createCreateQnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 14: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy281, &yymsp[0].minor.yy209); } + case 14: /* cmd ::= SHOW QNODES */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT, NULL); } break; - case 15: /* cmd ::= SHOW DATABASES */ + case 15: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy25, &yymsp[-1].minor.yy5, yymsp[0].minor.yy68);} + break; + case 16: /* cmd ::= DROP DATABASE exists_opt db_name */ +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy25, &yymsp[0].minor.yy5); } + break; + case 17: /* cmd ::= SHOW DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL); } break; - case 16: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy209);} + case 18: /* cmd ::= USE db_name */ +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy5);} break; - case 17: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy281 = true; } + case 19: /* not_exists_opt ::= IF NOT EXISTS */ +{ yymsp[-2].minor.yy25 = true; } break; - case 18: /* not_exists_opt ::= */ - case 20: /* exists_opt ::= */ yytestcase(yyruleno==20); - case 185: /* set_quantifier_opt ::= */ yytestcase(yyruleno==185); -{ yymsp[1].minor.yy281 = false; } + case 20: /* not_exists_opt ::= */ + case 22: /* exists_opt ::= */ yytestcase(yyruleno==22); + case 187: /* set_quantifier_opt ::= */ yytestcase(yyruleno==187); +{ yymsp[1].minor.yy25 = false; } break; - case 19: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy281 = true; } + case 21: /* exists_opt ::= IF EXISTS */ +{ yymsp[-1].minor.yy25 = true; } break; - case 21: /* db_options ::= */ -{ yymsp[1].minor.yy344 = createDefaultDatabaseOptions(pCxt); } + case 23: /* db_options ::= */ +{ yymsp[1].minor.yy68 = createDefaultDatabaseOptions(pCxt); } break; - case 22: /* db_options ::= db_options BLOCKS NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 24: /* db_options ::= db_options BLOCKS NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 23: /* db_options ::= db_options CACHE NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 25: /* db_options ::= db_options CACHE NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 24: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 26: /* db_options ::= db_options CACHELAST NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 25: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 27: /* db_options ::= db_options COMP NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 26: /* db_options ::= db_options DAYS NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 28: /* db_options ::= db_options DAYS NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 27: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 29: /* db_options ::= db_options FSYNC NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 28: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 30: /* db_options ::= db_options MAXROWS NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 29: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 31: /* db_options ::= db_options MINROWS NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 30: /* db_options ::= db_options KEEP NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 32: /* db_options ::= db_options KEEP NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_KEEP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 31: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 33: /* db_options ::= db_options PRECISION NK_STRING */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 32: /* db_options ::= db_options QUORUM NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 34: /* db_options ::= db_options QUORUM NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 33: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 35: /* db_options ::= db_options REPLICA NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 34: /* db_options ::= db_options TTL NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 36: /* db_options ::= db_options TTL NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 35: /* db_options ::= db_options WAL NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 37: /* db_options ::= db_options WAL NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 36: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 38: /* db_options ::= db_options VGROUPS NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 37: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_SINGLESTABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 39: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_SINGLESTABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 38: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_STREAMMODE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 40: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_STREAMMODE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 39: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - case 41: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==41); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy281, yymsp[-5].minor.yy344, yymsp[-3].minor.yy280, yymsp[-1].minor.yy280, yymsp[0].minor.yy344);} + case 41: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + case 43: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==43); +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy25, yymsp[-5].minor.yy68, yymsp[-3].minor.yy40, yymsp[-1].minor.yy40, yymsp[0].minor.yy68);} break; - case 40: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy280);} + case 42: /* cmd ::= CREATE TABLE multi_create_clause */ +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy40);} break; - case 42: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy280); } + case 44: /* cmd ::= DROP TABLE multi_drop_clause */ +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy40); } break; - case 43: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy281, yymsp[0].minor.yy344); } + case 45: /* cmd ::= DROP STABLE exists_opt full_table_name */ +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy25, yymsp[0].minor.yy68); } break; - case 44: /* cmd ::= SHOW TABLES */ + case 46: /* cmd ::= SHOW TABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, NULL); } break; - case 45: /* cmd ::= SHOW STABLES */ + case 47: /* cmd ::= SHOW STABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, NULL); } break; - case 46: /* multi_create_clause ::= create_subtable_clause */ - case 49: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==49); - case 56: /* column_def_list ::= column_def */ yytestcase(yyruleno==56); - case 91: /* col_name_list ::= col_name */ yytestcase(yyruleno==91); - case 99: /* func_list ::= func */ yytestcase(yyruleno==99); - case 190: /* select_sublist ::= select_item */ yytestcase(yyruleno==190); - case 237: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==237); -{ yylhsminor.yy280 = createNodeList(pCxt, yymsp[0].minor.yy344); } - yymsp[0].minor.yy280 = yylhsminor.yy280; + case 48: /* multi_create_clause ::= create_subtable_clause */ + case 51: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==51); + case 58: /* column_def_list ::= column_def */ yytestcase(yyruleno==58); + case 93: /* col_name_list ::= col_name */ yytestcase(yyruleno==93); + case 101: /* func_list ::= func */ yytestcase(yyruleno==101); + case 192: /* select_sublist ::= select_item */ yytestcase(yyruleno==192); + case 239: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==239); +{ yylhsminor.yy40 = createNodeList(pCxt, yymsp[0].minor.yy68); } + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 47: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 50: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==50); -{ yylhsminor.yy280 = addNodeToList(pCxt, yymsp[-1].minor.yy280, yymsp[0].minor.yy344); } - yymsp[-1].minor.yy280 = yylhsminor.yy280; + case 49: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ + case 52: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==52); +{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-1].minor.yy40, yymsp[0].minor.yy68); } + yymsp[-1].minor.yy40 = yylhsminor.yy40; break; - case 48: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ -{ yylhsminor.yy344 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy281, yymsp[-7].minor.yy344, yymsp[-5].minor.yy344, yymsp[-4].minor.yy280, yymsp[-1].minor.yy280); } - yymsp[-8].minor.yy344 = yylhsminor.yy344; + case 50: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ +{ yylhsminor.yy68 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy25, yymsp[-7].minor.yy68, yymsp[-5].minor.yy68, yymsp[-4].minor.yy40, yymsp[-1].minor.yy40); } + yymsp[-8].minor.yy68 = yylhsminor.yy68; break; - case 51: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy344 = createDropTableClause(pCxt, yymsp[-1].minor.yy281, yymsp[0].minor.yy344); } - yymsp[-1].minor.yy344 = yylhsminor.yy344; + case 53: /* drop_table_clause ::= exists_opt full_table_name */ +{ yylhsminor.yy68 = createDropTableClause(pCxt, yymsp[-1].minor.yy25, yymsp[0].minor.yy68); } + yymsp[-1].minor.yy68 = yylhsminor.yy68; break; - case 52: /* specific_tags_opt ::= */ - case 83: /* tags_def_opt ::= */ yytestcase(yyruleno==83); - case 198: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==198); - case 215: /* group_by_clause_opt ::= */ yytestcase(yyruleno==215); - case 225: /* order_by_clause_opt ::= */ yytestcase(yyruleno==225); -{ yymsp[1].minor.yy280 = NULL; } + case 54: /* specific_tags_opt ::= */ + case 85: /* tags_def_opt ::= */ yytestcase(yyruleno==85); + case 200: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==200); + case 217: /* group_by_clause_opt ::= */ yytestcase(yyruleno==217); + case 227: /* order_by_clause_opt ::= */ yytestcase(yyruleno==227); +{ yymsp[1].minor.yy40 = NULL; } break; - case 53: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy280 = yymsp[-1].minor.yy280; } + case 55: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ +{ yymsp[-2].minor.yy40 = yymsp[-1].minor.yy40; } break; - case 54: /* full_table_name ::= table_name */ -{ yylhsminor.yy344 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy209, NULL); } - yymsp[0].minor.yy344 = yylhsminor.yy344; + case 56: /* full_table_name ::= table_name */ +{ yylhsminor.yy68 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy5, NULL); } + yymsp[0].minor.yy68 = yylhsminor.yy68; break; - case 55: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy344 = createRealTableNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209, NULL); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 57: /* full_table_name ::= db_name NK_DOT table_name */ +{ yylhsminor.yy68 = createRealTableNode(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy5, NULL); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 57: /* column_def_list ::= column_def_list NK_COMMA column_def */ - case 92: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==92); - case 100: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==100); - case 191: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==191); - case 238: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==238); -{ yylhsminor.yy280 = addNodeToList(pCxt, yymsp[-2].minor.yy280, yymsp[0].minor.yy344); } - yymsp[-2].minor.yy280 = yylhsminor.yy280; + case 59: /* column_def_list ::= column_def_list NK_COMMA column_def */ + case 94: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==94); + case 102: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==102); + case 193: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==193); + case 240: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==240); +{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-2].minor.yy40, yymsp[0].minor.yy68); } + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 58: /* column_def ::= column_name type_name */ -{ yylhsminor.yy344 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy209, yymsp[0].minor.yy304, NULL); } - yymsp[-1].minor.yy344 = yylhsminor.yy344; + case 60: /* column_def ::= column_name type_name */ +{ yylhsminor.yy68 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy5, yymsp[0].minor.yy372, NULL); } + yymsp[-1].minor.yy68 = yylhsminor.yy68; break; - case 59: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy344 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-2].minor.yy304, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy344 = yylhsminor.yy344; + case 61: /* column_def ::= column_name type_name COMMENT NK_STRING */ +{ yylhsminor.yy68 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy5, yymsp[-2].minor.yy372, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy68 = yylhsminor.yy68; break; - case 60: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_BOOL); } + case 62: /* type_name ::= BOOL */ +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_BOOL); } break; - case 61: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_TINYINT); } + case 63: /* type_name ::= TINYINT */ +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; - case 62: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_SMALLINT); } + case 64: /* type_name ::= SMALLINT */ +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; - case 63: /* type_name ::= INT */ - case 64: /* type_name ::= INTEGER */ yytestcase(yyruleno==64); -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_INT); } + case 65: /* type_name ::= INT */ + case 66: /* type_name ::= INTEGER */ yytestcase(yyruleno==66); +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_INT); } break; - case 65: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_BIGINT); } + case 67: /* type_name ::= BIGINT */ +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; - case 66: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_FLOAT); } + case 68: /* type_name ::= FLOAT */ +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; - case 67: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_DOUBLE); } + case 69: /* type_name ::= DOUBLE */ +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; - case 68: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } + case 70: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy372 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; - case 69: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } + case 71: /* type_name ::= TIMESTAMP */ +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; - case 70: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } + case 72: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy372 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; - case 71: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_UTINYINT); } + case 73: /* type_name ::= TINYINT UNSIGNED */ +{ yymsp[-1].minor.yy372 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; - case 72: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_USMALLINT); } + case 74: /* type_name ::= SMALLINT UNSIGNED */ +{ yymsp[-1].minor.yy372 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; - case 73: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_UINT); } + case 75: /* type_name ::= INT UNSIGNED */ +{ yymsp[-1].minor.yy372 = createDataType(TSDB_DATA_TYPE_UINT); } break; - case 74: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_UBIGINT); } + case 76: /* type_name ::= BIGINT UNSIGNED */ +{ yymsp[-1].minor.yy372 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; - case 75: /* type_name ::= JSON */ -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_JSON); } + case 77: /* type_name ::= JSON */ +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_JSON); } break; - case 76: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } + case 78: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy372 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; - case 77: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } + case 79: /* type_name ::= MEDIUMBLOB */ +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; - case 78: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_BLOB); } + case 80: /* type_name ::= BLOB */ +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_BLOB); } break; - case 79: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } + case 81: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy372 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; - case 80: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 82: /* type_name ::= DECIMAL */ +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 81: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy304 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 83: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy372 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 82: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy304 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 84: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy372 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 84: /* tags_def_opt ::= tags_def */ - case 189: /* select_list ::= select_sublist */ yytestcase(yyruleno==189); -{ yylhsminor.yy280 = yymsp[0].minor.yy280; } - yymsp[0].minor.yy280 = yylhsminor.yy280; + case 86: /* tags_def_opt ::= tags_def */ + case 191: /* select_list ::= select_sublist */ yytestcase(yyruleno==191); +{ yylhsminor.yy40 = yymsp[0].minor.yy40; } + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 85: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy280 = yymsp[-1].minor.yy280; } + case 87: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ +{ yymsp[-3].minor.yy40 = yymsp[-1].minor.yy40; } break; - case 86: /* table_options ::= */ -{ yymsp[1].minor.yy344 = createDefaultTableOptions(pCxt);} + case 88: /* table_options ::= */ +{ yymsp[1].minor.yy68 = createDefaultTableOptions(pCxt);} break; - case 87: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy344 = setTableOption(pCxt, yymsp[-2].minor.yy344, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 89: /* table_options ::= table_options COMMENT NK_STRING */ +{ yylhsminor.yy68 = setTableOption(pCxt, yymsp[-2].minor.yy68, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 88: /* table_options ::= table_options KEEP NK_INTEGER */ -{ yylhsminor.yy344 = setTableOption(pCxt, yymsp[-2].minor.yy344, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 90: /* table_options ::= table_options KEEP NK_INTEGER */ +{ yylhsminor.yy68 = setTableOption(pCxt, yymsp[-2].minor.yy68, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 89: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy344 = setTableOption(pCxt, yymsp[-2].minor.yy344, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 91: /* table_options ::= table_options TTL NK_INTEGER */ +{ yylhsminor.yy68 = setTableOption(pCxt, yymsp[-2].minor.yy68, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 90: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy344 = setTableSmaOption(pCxt, yymsp[-4].minor.yy344, yymsp[-1].minor.yy280); } - yymsp[-4].minor.yy344 = yylhsminor.yy344; + case 92: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ +{ yylhsminor.yy68 = setTableSmaOption(pCxt, yymsp[-4].minor.yy68, yymsp[-1].minor.yy40); } + yymsp[-4].minor.yy68 = yylhsminor.yy68; break; - case 93: /* col_name ::= column_name */ -{ yylhsminor.yy344 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy209); } - yymsp[0].minor.yy344 = yylhsminor.yy344; + case 95: /* col_name ::= column_name */ +{ yylhsminor.yy68 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy5); } + yymsp[0].minor.yy68 = yylhsminor.yy68; break; - case 94: /* cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &yymsp[-3].minor.yy209, &yymsp[-1].minor.yy209, NULL, yymsp[0].minor.yy344); } + case 96: /* cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &yymsp[-3].minor.yy5, &yymsp[-1].minor.yy5, NULL, yymsp[0].minor.yy68); } break; - case 95: /* cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &yymsp[-5].minor.yy209, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy280, NULL); } + case 97: /* cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &yymsp[-5].minor.yy5, &yymsp[-3].minor.yy5, yymsp[-1].minor.yy40, NULL); } break; - case 96: /* index_options ::= */ - case 196: /* where_clause_opt ::= */ yytestcase(yyruleno==196); - case 200: /* twindow_clause_opt ::= */ yytestcase(yyruleno==200); - case 205: /* sliding_opt ::= */ yytestcase(yyruleno==205); - case 207: /* fill_opt ::= */ yytestcase(yyruleno==207); - case 219: /* having_clause_opt ::= */ yytestcase(yyruleno==219); - case 227: /* slimit_clause_opt ::= */ yytestcase(yyruleno==227); - case 231: /* limit_clause_opt ::= */ yytestcase(yyruleno==231); -{ yymsp[1].minor.yy344 = NULL; } + case 98: /* index_options ::= */ + case 198: /* where_clause_opt ::= */ yytestcase(yyruleno==198); + case 202: /* twindow_clause_opt ::= */ yytestcase(yyruleno==202); + case 207: /* sliding_opt ::= */ yytestcase(yyruleno==207); + case 209: /* fill_opt ::= */ yytestcase(yyruleno==209); + case 221: /* having_clause_opt ::= */ yytestcase(yyruleno==221); + case 229: /* slimit_clause_opt ::= */ yytestcase(yyruleno==229); + case 233: /* limit_clause_opt ::= */ yytestcase(yyruleno==233); +{ yymsp[1].minor.yy68 = NULL; } break; - case 97: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ -{ yymsp[-8].minor.yy344 = createIndexOption(pCxt, yymsp[-6].minor.yy280, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), NULL, yymsp[0].minor.yy344); } + case 99: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ +{ yymsp[-8].minor.yy68 = createIndexOption(pCxt, yymsp[-6].minor.yy40, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), NULL, yymsp[0].minor.yy68); } break; - case 98: /* 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.yy344 = createIndexOption(pCxt, yymsp[-8].minor.yy280, releaseRawExprNode(pCxt, yymsp[-4].minor.yy344), releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), yymsp[0].minor.yy344); } + case 100: /* 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.yy68 = createIndexOption(pCxt, yymsp[-8].minor.yy40, releaseRawExprNode(pCxt, yymsp[-4].minor.yy68), releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), yymsp[0].minor.yy68); } break; - case 101: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy344 = createFunctionNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy280); } - yymsp[-3].minor.yy344 = yylhsminor.yy344; + case 103: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy68 = createFunctionNode(pCxt, &yymsp[-3].minor.yy5, yymsp[-1].minor.yy40); } + yymsp[-3].minor.yy68 = yylhsminor.yy68; break; - case 102: /* cmd ::= SHOW VGROUPS */ + case 104: /* cmd ::= SHOW VGROUPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, NULL); } break; - case 103: /* cmd ::= SHOW db_name NK_DOT VGROUPS */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &yymsp[-2].minor.yy209); } + case 105: /* cmd ::= SHOW db_name NK_DOT VGROUPS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &yymsp[-2].minor.yy5); } break; - case 104: /* cmd ::= SHOW MNODES */ + case 106: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL); } break; - case 105: /* cmd ::= query_expression */ -{ pCxt->pRootNode = yymsp[0].minor.yy344; } + case 107: /* cmd ::= query_expression */ +{ pCxt->pRootNode = yymsp[0].minor.yy68; } break; - case 106: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy344 = yylhsminor.yy344; + case 108: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy68 = yylhsminor.yy68; break; - case 107: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy344 = yylhsminor.yy344; + case 109: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy68 = yylhsminor.yy68; break; - case 108: /* literal ::= NK_STRING */ -{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy344 = yylhsminor.yy344; + case 110: /* literal ::= NK_STRING */ +{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy68 = yylhsminor.yy68; break; - case 109: /* literal ::= NK_BOOL */ -{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy344 = yylhsminor.yy344; + case 111: /* literal ::= NK_BOOL */ +{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy68 = yylhsminor.yy68; break; - case 110: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy344 = yylhsminor.yy344; + case 112: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy68 = yylhsminor.yy68; break; - case 111: /* literal ::= duration_literal */ - case 123: /* expression ::= literal */ yytestcase(yyruleno==123); - case 124: /* expression ::= column_reference */ yytestcase(yyruleno==124); - case 127: /* expression ::= subquery */ yytestcase(yyruleno==127); - case 159: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==159); - case 163: /* boolean_primary ::= predicate */ yytestcase(yyruleno==163); - case 165: /* common_expression ::= expression */ yytestcase(yyruleno==165); - case 166: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==166); - case 168: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==168); - case 170: /* table_reference ::= table_primary */ yytestcase(yyruleno==170); - case 171: /* table_reference ::= joined_table */ yytestcase(yyruleno==171); - case 175: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==175); - case 222: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==222); - case 224: /* query_primary ::= query_specification */ yytestcase(yyruleno==224); -{ yylhsminor.yy344 = yymsp[0].minor.yy344; } - yymsp[0].minor.yy344 = yylhsminor.yy344; + case 113: /* literal ::= duration_literal */ + case 125: /* expression ::= literal */ yytestcase(yyruleno==125); + case 126: /* expression ::= column_reference */ yytestcase(yyruleno==126); + case 129: /* expression ::= subquery */ yytestcase(yyruleno==129); + case 161: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==161); + case 165: /* boolean_primary ::= predicate */ yytestcase(yyruleno==165); + case 167: /* common_expression ::= expression */ yytestcase(yyruleno==167); + case 168: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==168); + case 170: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==170); + case 172: /* table_reference ::= table_primary */ yytestcase(yyruleno==172); + case 173: /* table_reference ::= joined_table */ yytestcase(yyruleno==173); + case 177: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==177); + case 224: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==224); + case 226: /* query_primary ::= query_specification */ yytestcase(yyruleno==226); +{ yylhsminor.yy68 = yymsp[0].minor.yy68; } + yymsp[0].minor.yy68 = yylhsminor.yy68; break; - case 112: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy344 = yylhsminor.yy344; + case 114: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy68 = yylhsminor.yy68; break; - case 113: /* literal_list ::= literal */ - case 136: /* expression_list ::= expression */ yytestcase(yyruleno==136); -{ yylhsminor.yy280 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy344)); } - yymsp[0].minor.yy280 = yylhsminor.yy280; + case 115: /* literal_list ::= literal */ + case 138: /* expression_list ::= expression */ yytestcase(yyruleno==138); +{ yylhsminor.yy40 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy68)); } + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 114: /* literal_list ::= literal_list NK_COMMA literal */ - case 137: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==137); -{ yylhsminor.yy280 = addNodeToList(pCxt, yymsp[-2].minor.yy280, releaseRawExprNode(pCxt, yymsp[0].minor.yy344)); } - yymsp[-2].minor.yy280 = yylhsminor.yy280; + case 116: /* literal_list ::= literal_list NK_COMMA literal */ + case 139: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==139); +{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-2].minor.yy40, releaseRawExprNode(pCxt, yymsp[0].minor.yy68)); } + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 125: /* expression ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy209, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy280)); } - yymsp[-3].minor.yy344 = yylhsminor.yy344; + case 127: /* expression ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy5, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy5, yymsp[-1].minor.yy40)); } + yymsp[-3].minor.yy68 = yylhsminor.yy68; break; - case 126: /* expression ::= function_name NK_LP NK_STAR NK_RP */ -{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy209, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy209, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } - yymsp[-3].minor.yy344 = yylhsminor.yy344; + case 128: /* expression ::= function_name NK_LP NK_STAR NK_RP */ +{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy5, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy5, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } + yymsp[-3].minor.yy68 = yylhsminor.yy68; break; - case 128: /* expression ::= NK_LP expression NK_RP */ - case 164: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==164); -{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy344)); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 130: /* expression ::= NK_LP expression NK_RP */ + case 166: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==166); +{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy68)); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 129: /* expression ::= NK_PLUS expression */ + case 131: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy344)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy68)); } - yymsp[-1].minor.yy344 = yylhsminor.yy344; + yymsp[-1].minor.yy68 = yylhsminor.yy68; break; - case 130: /* expression ::= NK_MINUS expression */ + case 132: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy344), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy68), NULL)); } - yymsp[-1].minor.yy344 = yylhsminor.yy344; + yymsp[-1].minor.yy68 = yylhsminor.yy68; break; - case 131: /* expression ::= expression NK_PLUS expression */ + case 133: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 132: /* expression ::= expression NK_MINUS expression */ + case 134: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 133: /* expression ::= expression NK_STAR expression */ + case 135: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 134: /* expression ::= expression NK_SLASH expression */ + case 136: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 135: /* expression ::= expression NK_REM expression */ + case 137: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 138: /* column_reference ::= column_name */ -{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy209, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy209)); } - yymsp[0].minor.yy344 = yylhsminor.yy344; + case 140: /* column_reference ::= column_name */ +{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy5, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy5)); } + yymsp[0].minor.yy68 = yylhsminor.yy68; break; - case 139: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209, createColumnNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209)); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 141: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy5, createColumnNode(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy5)); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 140: /* predicate ::= expression compare_op expression */ - case 145: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==145); + case 142: /* predicate ::= expression compare_op expression */ + case 147: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==147); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy236, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy416, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 141: /* predicate ::= expression BETWEEN expression AND expression */ + case 143: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy344); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy344), releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy68); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy68), releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-4].minor.yy344 = yylhsminor.yy344; + yymsp[-4].minor.yy68 = yylhsminor.yy68; break; - case 142: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 144: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy344); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[-5].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy68); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[-5].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-5].minor.yy344 = yylhsminor.yy344; + yymsp[-5].minor.yy68 = yylhsminor.yy68; break; - case 143: /* predicate ::= expression IS NULL */ + case 145: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), NULL)); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 144: /* predicate ::= expression IS NOT NULL */ + case 146: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy344), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy68), NULL)); } - yymsp[-3].minor.yy344 = yylhsminor.yy344; + yymsp[-3].minor.yy68 = yylhsminor.yy68; break; - case 146: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy236 = OP_TYPE_LOWER_THAN; } + case 148: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy416 = OP_TYPE_LOWER_THAN; } break; - case 147: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy236 = OP_TYPE_GREATER_THAN; } + case 149: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy416 = OP_TYPE_GREATER_THAN; } break; - case 148: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy236 = OP_TYPE_LOWER_EQUAL; } + case 150: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy416 = OP_TYPE_LOWER_EQUAL; } break; - case 149: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy236 = OP_TYPE_GREATER_EQUAL; } + case 151: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy416 = OP_TYPE_GREATER_EQUAL; } break; - case 150: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy236 = OP_TYPE_NOT_EQUAL; } + case 152: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy416 = OP_TYPE_NOT_EQUAL; } break; - case 151: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy236 = OP_TYPE_EQUAL; } + case 153: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy416 = OP_TYPE_EQUAL; } break; - case 152: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy236 = OP_TYPE_LIKE; } + case 154: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy416 = OP_TYPE_LIKE; } break; - case 153: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy236 = OP_TYPE_NOT_LIKE; } + case 155: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy416 = OP_TYPE_NOT_LIKE; } break; - case 154: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy236 = OP_TYPE_MATCH; } + case 156: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy416 = OP_TYPE_MATCH; } break; - case 155: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy236 = OP_TYPE_NMATCH; } + case 157: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy416 = OP_TYPE_NMATCH; } break; - case 156: /* in_op ::= IN */ -{ yymsp[0].minor.yy236 = OP_TYPE_IN; } + case 158: /* in_op ::= IN */ +{ yymsp[0].minor.yy416 = OP_TYPE_IN; } break; - case 157: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy236 = OP_TYPE_NOT_IN; } + case 159: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy416 = OP_TYPE_NOT_IN; } break; - case 158: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy280)); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 160: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy40)); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 160: /* boolean_value_expression ::= NOT boolean_primary */ + case 162: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy344), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy68), NULL)); } - yymsp[-1].minor.yy344 = yylhsminor.yy344; + yymsp[-1].minor.yy68 = yylhsminor.yy68; break; - case 161: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 163: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 162: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 164: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 167: /* from_clause ::= FROM table_reference_list */ - case 197: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==197); - case 220: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==220); -{ yymsp[-1].minor.yy344 = yymsp[0].minor.yy344; } + case 169: /* from_clause ::= FROM table_reference_list */ + case 199: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==199); + case 222: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==222); +{ yymsp[-1].minor.yy68 = yymsp[0].minor.yy68; } break; - case 169: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy344 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy344, yymsp[0].minor.yy344, NULL); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 171: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy68 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy68, yymsp[0].minor.yy68, NULL); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 172: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy344 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy209, &yymsp[0].minor.yy209); } - yymsp[-1].minor.yy344 = yylhsminor.yy344; + case 174: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy68 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy5, &yymsp[0].minor.yy5); } + yymsp[-1].minor.yy68 = yylhsminor.yy68; break; - case 173: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy344 = createRealTableNode(pCxt, &yymsp[-3].minor.yy209, &yymsp[-1].minor.yy209, &yymsp[0].minor.yy209); } - yymsp[-3].minor.yy344 = yylhsminor.yy344; + case 175: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy68 = createRealTableNode(pCxt, &yymsp[-3].minor.yy5, &yymsp[-1].minor.yy5, &yymsp[0].minor.yy5); } + yymsp[-3].minor.yy68 = yylhsminor.yy68; break; - case 174: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy344 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy344), &yymsp[0].minor.yy209); } - yymsp[-1].minor.yy344 = yylhsminor.yy344; + case 176: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy68 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy68), &yymsp[0].minor.yy5); } + yymsp[-1].minor.yy68 = yylhsminor.yy68; break; - case 176: /* alias_opt ::= */ -{ yymsp[1].minor.yy209 = nil_token; } + case 178: /* alias_opt ::= */ +{ yymsp[1].minor.yy5 = nil_token; } break; - case 177: /* alias_opt ::= table_alias */ -{ yylhsminor.yy209 = yymsp[0].minor.yy209; } - yymsp[0].minor.yy209 = yylhsminor.yy209; + case 179: /* alias_opt ::= table_alias */ +{ yylhsminor.yy5 = yymsp[0].minor.yy5; } + yymsp[0].minor.yy5 = yylhsminor.yy5; break; - case 178: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy209 = yymsp[0].minor.yy209; } + case 180: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy5 = yymsp[0].minor.yy5; } break; - case 179: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 180: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==180); -{ yymsp[-2].minor.yy344 = yymsp[-1].minor.yy344; } + case 181: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 182: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==182); +{ yymsp[-2].minor.yy68 = yymsp[-1].minor.yy68; } break; - case 181: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy344 = createJoinTableNode(pCxt, yymsp[-4].minor.yy36, yymsp[-5].minor.yy344, yymsp[-2].minor.yy344, yymsp[0].minor.yy344); } - yymsp[-5].minor.yy344 = yylhsminor.yy344; + case 183: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy68 = createJoinTableNode(pCxt, yymsp[-4].minor.yy92, yymsp[-5].minor.yy68, yymsp[-2].minor.yy68, yymsp[0].minor.yy68); } + yymsp[-5].minor.yy68 = yylhsminor.yy68; break; - case 182: /* join_type ::= */ -{ yymsp[1].minor.yy36 = JOIN_TYPE_INNER; } + case 184: /* join_type ::= */ +{ yymsp[1].minor.yy92 = JOIN_TYPE_INNER; } break; - case 183: /* join_type ::= INNER */ -{ yymsp[0].minor.yy36 = JOIN_TYPE_INNER; } + case 185: /* join_type ::= INNER */ +{ yymsp[0].minor.yy92 = JOIN_TYPE_INNER; } break; - case 184: /* 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 186: /* 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.yy344 = createSelectStmt(pCxt, yymsp[-7].minor.yy281, yymsp[-6].minor.yy280, yymsp[-5].minor.yy344); - yymsp[-8].minor.yy344 = addWhereClause(pCxt, yymsp[-8].minor.yy344, yymsp[-4].minor.yy344); - yymsp[-8].minor.yy344 = addPartitionByClause(pCxt, yymsp[-8].minor.yy344, yymsp[-3].minor.yy280); - yymsp[-8].minor.yy344 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy344, yymsp[-2].minor.yy344); - yymsp[-8].minor.yy344 = addGroupByClause(pCxt, yymsp[-8].minor.yy344, yymsp[-1].minor.yy280); - yymsp[-8].minor.yy344 = addHavingClause(pCxt, yymsp[-8].minor.yy344, yymsp[0].minor.yy344); + yymsp[-8].minor.yy68 = createSelectStmt(pCxt, yymsp[-7].minor.yy25, yymsp[-6].minor.yy40, yymsp[-5].minor.yy68); + yymsp[-8].minor.yy68 = addWhereClause(pCxt, yymsp[-8].minor.yy68, yymsp[-4].minor.yy68); + yymsp[-8].minor.yy68 = addPartitionByClause(pCxt, yymsp[-8].minor.yy68, yymsp[-3].minor.yy40); + yymsp[-8].minor.yy68 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy68, yymsp[-2].minor.yy68); + yymsp[-8].minor.yy68 = addGroupByClause(pCxt, yymsp[-8].minor.yy68, yymsp[-1].minor.yy40); + yymsp[-8].minor.yy68 = addHavingClause(pCxt, yymsp[-8].minor.yy68, yymsp[0].minor.yy68); } break; - case 186: /* set_quantifier_opt ::= DISTINCT */ -{ yymsp[0].minor.yy281 = true; } + case 188: /* set_quantifier_opt ::= DISTINCT */ +{ yymsp[0].minor.yy25 = true; } break; - case 187: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy281 = false; } + case 189: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy25 = false; } break; - case 188: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy280 = NULL; } + case 190: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy40 = NULL; } break; - case 192: /* select_item ::= common_expression */ + case 194: /* select_item ::= common_expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy344), &t); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy68), &t); } - yymsp[0].minor.yy344 = yylhsminor.yy344; + yymsp[0].minor.yy68 = yylhsminor.yy68; break; - case 193: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy344 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy344), &yymsp[0].minor.yy209); } - yymsp[-1].minor.yy344 = yylhsminor.yy344; + case 195: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy68 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy68), &yymsp[0].minor.yy5); } + yymsp[-1].minor.yy68 = yylhsminor.yy68; break; - case 194: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy344 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), &yymsp[0].minor.yy209); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 196: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy68 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), &yymsp[0].minor.yy5); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 195: /* select_item ::= table_name NK_DOT NK_STAR */ -{ yylhsminor.yy344 = createColumnNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 197: /* select_item ::= table_name NK_DOT NK_STAR */ +{ yylhsminor.yy68 = createColumnNode(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 199: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 216: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==216); - case 226: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==226); -{ yymsp[-2].minor.yy280 = yymsp[0].minor.yy280; } + case 201: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 218: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==218); + case 228: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==228); +{ yymsp[-2].minor.yy40 = yymsp[0].minor.yy40; } break; - case 201: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy344 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy344), &yymsp[-1].minor.yy0); } + case 203: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy68 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy68), &yymsp[-1].minor.yy0); } break; - case 202: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ -{ yymsp[-3].minor.yy344 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy344)); } + case 204: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ +{ yymsp[-3].minor.yy68 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy68)); } break; - case 203: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy344 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy344), NULL, yymsp[-1].minor.yy344, yymsp[0].minor.yy344); } + case 205: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy68 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy68), NULL, yymsp[-1].minor.yy68, yymsp[0].minor.yy68); } break; - case 204: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy344 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy344), releaseRawExprNode(pCxt, yymsp[-3].minor.yy344), yymsp[-1].minor.yy344, yymsp[0].minor.yy344); } + case 206: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy68 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy68), releaseRawExprNode(pCxt, yymsp[-3].minor.yy68), yymsp[-1].minor.yy68, yymsp[0].minor.yy68); } break; - case 206: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ -{ yymsp[-3].minor.yy344 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy344); } + case 208: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ +{ yymsp[-3].minor.yy68 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy68); } break; - case 208: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy344 = createFillNode(pCxt, yymsp[-1].minor.yy342, NULL); } + case 210: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy68 = createFillNode(pCxt, yymsp[-1].minor.yy94, NULL); } break; - case 209: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy344 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy280)); } + case 211: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy68 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy40)); } break; - case 210: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy342 = FILL_MODE_NONE; } + case 212: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy94 = FILL_MODE_NONE; } break; - case 211: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy342 = FILL_MODE_PREV; } + case 213: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy94 = FILL_MODE_PREV; } break; - case 212: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy342 = FILL_MODE_NULL; } + case 214: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy94 = FILL_MODE_NULL; } break; - case 213: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy342 = FILL_MODE_LINEAR; } + case 215: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy94 = FILL_MODE_LINEAR; } break; - case 214: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy342 = FILL_MODE_NEXT; } + case 216: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy94 = FILL_MODE_NEXT; } break; - case 217: /* group_by_list ::= expression */ -{ yylhsminor.yy280 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[0].minor.yy280 = yylhsminor.yy280; + case 219: /* group_by_list ::= expression */ +{ yylhsminor.yy40 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 218: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy280 = addNodeToList(pCxt, yymsp[-2].minor.yy280, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[-2].minor.yy280 = yylhsminor.yy280; + case 220: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-2].minor.yy40, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 221: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 223: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy344 = addOrderByClause(pCxt, yymsp[-3].minor.yy344, yymsp[-2].minor.yy280); - yylhsminor.yy344 = addSlimitClause(pCxt, yylhsminor.yy344, yymsp[-1].minor.yy344); - yylhsminor.yy344 = addLimitClause(pCxt, yylhsminor.yy344, yymsp[0].minor.yy344); + yylhsminor.yy68 = addOrderByClause(pCxt, yymsp[-3].minor.yy68, yymsp[-2].minor.yy40); + yylhsminor.yy68 = addSlimitClause(pCxt, yylhsminor.yy68, yymsp[-1].minor.yy68); + yylhsminor.yy68 = addLimitClause(pCxt, yylhsminor.yy68, yymsp[0].minor.yy68); } - yymsp[-3].minor.yy344 = yylhsminor.yy344; + yymsp[-3].minor.yy68 = yylhsminor.yy68; break; - case 223: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy344 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy344, yymsp[0].minor.yy344); } - yymsp[-3].minor.yy344 = yylhsminor.yy344; + case 225: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy68 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy68, yymsp[0].minor.yy68); } + yymsp[-3].minor.yy68 = yylhsminor.yy68; break; - case 228: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 232: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==232); -{ yymsp[-1].minor.yy344 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 230: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 234: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==234); +{ yymsp[-1].minor.yy68 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 229: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 233: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==233); -{ yymsp[-3].minor.yy344 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 231: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 235: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==235); +{ yymsp[-3].minor.yy68 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 230: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 234: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==234); -{ yymsp[-3].minor.yy344 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 232: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 236: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==236); +{ yymsp[-3].minor.yy68 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 235: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy344); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 237: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy68); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 236: /* search_condition ::= common_expression */ -{ yylhsminor.yy344 = releaseRawExprNode(pCxt, yymsp[0].minor.yy344); } - yymsp[0].minor.yy344 = yylhsminor.yy344; + case 238: /* search_condition ::= common_expression */ +{ yylhsminor.yy68 = releaseRawExprNode(pCxt, yymsp[0].minor.yy68); } + yymsp[0].minor.yy68 = yylhsminor.yy68; break; - case 239: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy344 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), yymsp[-1].minor.yy2, yymsp[0].minor.yy217); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 241: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy68 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), yymsp[-1].minor.yy54, yymsp[0].minor.yy53); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 240: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy2 = ORDER_ASC; } + case 242: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy54 = ORDER_ASC; } break; - case 241: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy2 = ORDER_ASC; } + case 243: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy54 = ORDER_ASC; } break; - case 242: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy2 = ORDER_DESC; } + case 244: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy54 = ORDER_DESC; } break; - case 243: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy217 = NULL_ORDER_DEFAULT; } + case 245: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy53 = NULL_ORDER_DEFAULT; } break; - case 244: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy217 = NULL_ORDER_FIRST; } + case 246: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy53 = NULL_ORDER_FIRST; } break; - case 245: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy217 = NULL_ORDER_LAST; } + case 247: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy53 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/parserAstTest.cpp b/source/libs/parser/test/parserAstTest.cpp index 119e94dde9..259c4712ba 100644 --- a/source/libs/parser/test/parserAstTest.cpp +++ b/source/libs/parser/test/parserAstTest.cpp @@ -405,3 +405,10 @@ TEST_F(ParserTest, createSmaIndex) { bind("create sma index index1 on t1 function(max(c1), min(c3 + 10), sum(c4)) INTERVAL(10s)"); ASSERT_TRUE(run()); } + +TEST_F(ParserTest, createQnode) { + setDatabase("root", "test"); + + bind("create qnode on dnode 1"); + ASSERT_TRUE(run()); +} From da65b721d6ea0efd1b0360a406f36cd3f94e9b67 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Tue, 15 Mar 2022 20:07:48 +0800 Subject: [PATCH 23/38] rename --- source/util/src/tuuid.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source/util/src/tuuid.c b/source/util/src/tuuid.c index ceca33436a..69cf7baaad 100644 --- a/source/util/src/tuuid.c +++ b/source/util/src/tuuid.c @@ -15,43 +15,43 @@ #include "tuuid.h" -static int64_t hashId = 0; -static int32_t SerialNo = 0; +static int64_t tUUIDHashId = 0; +static int32_t tUUIDSerialNo = 0; int32_t tGenIdPI32(void) { - if (hashId == 0) { + if (tUUIDHashId == 0) { char uid[64]; int32_t code = taosGetSystemUUID(uid, tListLen(uid)); if (code != TSDB_CODE_SUCCESS) { terrno = TAOS_SYSTEM_ERROR(errno); } else { - hashId = MurmurHash3_32(uid, strlen(uid)); + tUUIDHashId = MurmurHash3_32(uid, strlen(uid)); } } int64_t ts = taosGetTimestampMs(); uint64_t pid = taosGetPId(); - int32_t val = atomic_add_fetch_32(&SerialNo, 1); + int32_t val = atomic_add_fetch_32(&tUUIDSerialNo, 1); - int32_t id = ((hashId & 0x1F) << 26) | ((pid & 0x3F) << 20) | ((ts & 0xFFF) << 8) | (val & 0xFF); + int32_t id = ((tUUIDHashId & 0x1F) << 26) | ((pid & 0x3F) << 20) | ((ts & 0xFFF) << 8) | (val & 0xFF); return id; } int64_t tGenIdPI64(void) { - if (hashId == 0) { + if (tUUIDHashId == 0) { char uid[64]; int32_t code = taosGetSystemUUID(uid, tListLen(uid)); if (code != TSDB_CODE_SUCCESS) { terrno = TAOS_SYSTEM_ERROR(errno); } else { - hashId = MurmurHash3_32(uid, strlen(uid)); + tUUIDHashId = MurmurHash3_32(uid, strlen(uid)); } } int64_t ts = taosGetTimestampMs(); uint64_t pid = taosGetPId(); - int32_t val = atomic_add_fetch_32(&SerialNo, 1); + int32_t val = atomic_add_fetch_32(&tUUIDSerialNo, 1); - int64_t id = ((hashId & 0x07FF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF); + int64_t id = ((tUUIDHashId & 0x07FF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF); return id; } From 23bef711fca8a687246a42296c91467c1a14df58 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 15 Mar 2022 21:35:04 +0800 Subject: [PATCH 24/38] Feature/sangshuduo/td 13063 3.0 windows (#10720) * [TD-13063]: 3.0 on Windows * add pthread in contrib * fix linux compile * fix osSemaphore * add gnu regex for Windows * fix compile error for Windows * support arm platform * port more OS files * fix for Windows compile * port more files * fix macOS on x86_64 * port osFile * port osSemaphone.h * port osSocket.c * port tconfig.c * port ttimer.c * add couple files --- Jenkinsfile2 | 3 +- cmake/cmake.define | 11 ++- cmake/cmake.platform | 57 +++++++++---- include/os/os.h | 10 +++ include/os/osEok.h | 93 ++++++++++++++++++++++ include/os/osFile.h | 19 ++++- include/os/osSemaphore.h | 12 +-- include/os/osSocket.h | 35 +++++++- include/os/osSysinfo.h | 3 +- source/common/src/tdatablock.c | 9 ++- source/common/src/ttszip.c | 4 + source/libs/catalog/src/catalog.c | 8 +- source/libs/index/src/index.c | 1 + source/libs/index/src/index_cache.c | 3 + source/libs/index/src/index_fst.c | 6 ++ source/libs/parser/src/parInsert.c | 2 + source/libs/planner/src/planLogicCreater.c | 1 + source/libs/scalar/src/filter.c | 4 +- source/libs/scalar/src/scalar.c | 3 + source/libs/scheduler/src/schFlowCtrl.c | 4 +- source/libs/sync/src/syncRaftEntry.c | 16 ++-- source/libs/sync/src/syncVoteMgr.c | 22 ++--- source/libs/tfs/src/tfs.c | 4 +- source/libs/transport/src/transCli.c | 3 + source/libs/transport/src/transComm.c | 6 +- source/libs/transport/src/transSrv.c | 4 + source/libs/wal/src/walRead.c | 2 +- source/os/src/osFile.c | 17 ++-- source/os/src/osSocket.c | 12 ++- source/util/src/tconfig.c | 3 +- source/util/src/ttimer.c | 2 +- 31 files changed, 297 insertions(+), 82 deletions(-) create mode 100644 include/os/osEok.h diff --git a/Jenkinsfile2 b/Jenkinsfile2 index ad62fa7044..bf55e016b6 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -60,8 +60,9 @@ def pre_test(){ sh ''' cd ${WKC} git checkout 3.0 + [ -d contrib/bdb ] && cd contrib/bdb && git clean -fxd && cd ../.. ''' - } + } else{ sh ''' cd ${WKC} diff --git a/cmake/cmake.define b/cmake/cmake.define index b97c10a4b7..9c2d5dc04c 100644 --- a/cmake/cmake.define +++ b/cmake/cmake.define @@ -36,7 +36,14 @@ IF (TD_WINDOWS) ENDIF () ELSE () - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -fPIC -gdwarf-2 -msse4.2 -mfma -g3") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fPIC -gdwarf-2 -msse4.2 -mfma -g3") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -fPIC -gdwarf-2 -g3") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fPIC -gdwarf-2 -g3") + +MESSAGE("System processor ID: ${CMAKE_SYSTEM_PROCESSOR}") +IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64") + ADD_DEFINITIONS("-D_TD_ARM_") +ELSE () + ADD_DEFINITIONS("-msse4.2 -mfma") +ENDIF () ENDIF () diff --git a/cmake/cmake.platform b/cmake/cmake.platform index 7ef259ba54..0312f92a5b 100644 --- a/cmake/cmake.platform +++ b/cmake/cmake.platform @@ -7,31 +7,53 @@ SET(TD_LINUX FALSE) SET(TD_WINDOWS FALSE) SET(TD_DARWIN FALSE) -IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +MESSAGE("Compiler ID: ${CMAKE_CXX_COMPILER_ID}") +if(CMAKE_COMPILER_IS_GNUCXX MATCHES 1) + set(CXX_COMPILER_IS_GNU TRUE) +else() + set(CXX_COMPILER_IS_GNU FALSE) +endif() - SET(TD_LINUX TRUE) - SET(OSTYPE "Linux") - ADD_DEFINITIONS("-DLINUX") +MESSAGE("Current system name is ${CMAKE_SYSTEM_NAME}.") - IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8) - SET(TD_LINUX_64 TRUE) +IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + + IF (${CXX_COMPILER_IS_GNU}) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") ELSE () - SET(TD_LINUX_32 TRUE) + ADD_DEFINITIONS("-Wno-tautological-constant-out-of-range-compare -Wno-pointer-sign -Wno-unknown-warning-option") + set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -undefined dynamic_lookup") + set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -undefined dynamic_lookup") ENDIF () -ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - SET(TD_DARWIN TRUE) - SET(OSTYPE "macOS") - ADD_DEFINITIONS("-DDARWIN") - IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64") - MESSAGE("Current system arch is arm64") - SET(TD_DARWIN_64 TRUE) - ADD_DEFINITIONS("-D_TD_DARWIN_64") + SET(TD_LINUX TRUE) + SET(OSTYPE "Linux") + ADD_DEFINITIONS("-DLINUX") + + IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8) + SET(TD_LINUX_64 TRUE) + ELSE () + SET(TD_LINUX_32 TRUE) + ENDIF () + + ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + + SET(TD_DARWIN TRUE) + SET(OSTYPE "macOS") + ADD_DEFINITIONS("-DDARWIN -Wno-tautological-pointer-compare") + + MESSAGE("Current system processor is ${CMAKE_SYSTEM_PROCESSOR}.") + IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") + MESSAGE("Current system arch is arm64") + SET(TD_DARWIN_64 TRUE) + ADD_DEFINITIONS("-D_TD_DARWIN_64") + ENDIF () + + ADD_DEFINITIONS("-DHAVE_UNISTD_H") ENDIF () - ADD_DEFINITIONS("-DHAVE_UNISTD_H") - ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Windows") SET(TD_WINDOWS TRUE) @@ -45,6 +67,7 @@ ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Windows") SET(TD_WINDOWS_32 TRUE) ADD_DEFINITIONS("-D_TD_WINDOWS_32") ENDIF () + ENDIF() MESSAGE("C Compiler ID: ${CMAKE_C_COMPILER_ID}") diff --git a/include/os/os.h b/include/os/os.h index fd272b15a3..12f4e733c2 100644 --- a/include/os/os.h +++ b/include/os/os.h @@ -22,6 +22,8 @@ extern "C" { #include #include +#include +#include #if !defined(WINDOWS) #include @@ -34,7 +36,12 @@ extern "C" { #include #include #include + +#if defined(DARWIN) +#else #include +#include +#endif #endif @@ -54,9 +61,12 @@ extern "C" { #include #include #include +#include #include +#include #include #include +#include #include diff --git a/include/os/osEok.h b/include/os/osEok.h new file mode 100644 index 0000000000..3ca476f840 --- /dev/null +++ b/include/os/osEok.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef TDENGINE_OS_EOK_H +#define TDENGINE_OS_EOK_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __APPLE__ + +enum EPOLL_EVENTS + { + EPOLLIN = 0x001, +#define EPOLLIN EPOLLIN + EPOLLPRI = 0x002, +#define EPOLLPRI EPOLLPRI + EPOLLOUT = 0x004, +#define EPOLLOUT EPOLLOUT + EPOLLRDNORM = 0x040, +#define EPOLLRDNORM EPOLLRDNORM + EPOLLRDBAND = 0x080, +#define EPOLLRDBAND EPOLLRDBAND + EPOLLWRNORM = 0x100, +#define EPOLLWRNORM EPOLLWRNORM + EPOLLWRBAND = 0x200, +#define EPOLLWRBAND EPOLLWRBAND + EPOLLMSG = 0x400, +#define EPOLLMSG EPOLLMSG + EPOLLERR = 0x008, +#define EPOLLERR EPOLLERR + EPOLLHUP = 0x010, +#define EPOLLHUP EPOLLHUP + EPOLLRDHUP = 0x2000, +#define EPOLLRDHUP EPOLLRDHUP + EPOLLEXCLUSIVE = 1u << 28, +#define EPOLLEXCLUSIVE EPOLLEXCLUSIVE + EPOLLWAKEUP = 1u << 29, +#define EPOLLWAKEUP EPOLLWAKEUP + EPOLLONESHOT = 1u << 30, +#define EPOLLONESHOT EPOLLONESHOT + EPOLLET = 1u << 31 +#define EPOLLET EPOLLET + }; + +/* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */ +#define EPOLL_CTL_ADD 1 /* Add a file descriptor to the interface. */ +#define EPOLL_CTL_DEL 2 /* Remove a file descriptor from the interface. */ +#define EPOLL_CTL_MOD 3 /* Change file descriptor epoll_event structure. */ + + +typedef union epoll_data +{ + void *ptr; + int fd; + uint32_t u32; + uint64_t u64; +} epoll_data_t; + +struct epoll_event +{ + uint32_t events; /* Epoll events */ + epoll_data_t data; /* User data variable */ +}; + +int epoll_create(int size); +int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event); +int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout); +int epoll_close(int epfd); + +#endif // __APPLE__ + +#ifdef __cplusplus +} +#endif + +#endif // _eok_h_fd274616_996c_400e_9023_ae70be881fa3_ + diff --git a/include/os/osFile.h b/include/os/osFile.h index b0e97e7b54..58a9df2504 100644 --- a/include/os/osFile.h +++ b/include/os/osFile.h @@ -49,6 +49,15 @@ int64_t taosRead(FileFd fd, void *buf, int64_t count); #define PATH_MAX 256 #endif +typedef int32_t FileFd; + +typedef struct TdFile { + pthread_rwlock_t rwlock; + int refId; + FileFd fd; + FILE *fp; +} * TdFilePtr, TdFile; + typedef struct TdFile *TdFilePtr; #define TD_FILE_CTEATE 0x0001 @@ -101,8 +110,16 @@ int64_t taosCopyFile(const char *from, const char *to); int32_t taosRemoveFile(const char *path); void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath); - + +#if defined(_TD_DARWIN_64) +typedef int32_t SocketFd; + +int64_t taosSendFile(SocketFd fdDst, FileFd pFileSrc, int64_t *offset, int64_t size); +int64_t taosFSendFile(FILE *pFileOut, FILE *pFileIn, int64_t *offset, int64_t size); +#else +int64_t taosSendFile(SocketFd fdDst, TdFilePtr pFileSrc, int64_t *offset, int64_t size); int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, int64_t size); +#endif void *taosMmapReadOnlyFile(TdFilePtr pFile, int64_t length); bool taosValidFile(TdFilePtr pFile); diff --git a/include/os/osSemaphore.h b/include/os/osSemaphore.h index 9904170d61..4bac81754d 100644 --- a/include/os/osSemaphore.h +++ b/include/os/osSemaphore.h @@ -38,12 +38,12 @@ extern "C" { #endif #if defined (_TD_DARWIN_64) - #define pthread_rwlock_t pthread_mutex_t - #define pthread_rwlock_init(lock, NULL) pthread_mutex_init(lock, NULL) - #define pthread_rwlock_destroy(lock) pthread_mutex_destroy(lock) - #define pthread_rwlock_wrlock(lock) pthread_mutex_lock(lock) - #define pthread_rwlock_rdlock(lock) pthread_mutex_lock(lock) - #define pthread_rwlock_unlock(lock) pthread_mutex_unlock(lock) +// #define pthread_rwlock_t pthread_mutex_t +// #define pthread_rwlock_init(lock, NULL) pthread_mutex_init(lock, NULL) +// #define pthread_rwlock_destroy(lock) pthread_mutex_destroy(lock) +// #define pthread_rwlock_wrlock(lock) pthread_mutex_lock(lock) +// #define pthread_rwlock_rdlock(lock) pthread_mutex_lock(lock) +// #define pthread_rwlock_unlock(lock) pthread_mutex_unlock(lock) #define pthread_spinlock_t pthread_mutex_t #define pthread_spin_init(lock, NULL) pthread_mutex_init(lock, NULL) diff --git a/include/os/osSocket.h b/include/os/osSocket.h index 3faed855ba..520d3af331 100644 --- a/include/os/osSocket.h +++ b/include/os/osSocket.h @@ -33,8 +33,15 @@ #include #include #else - #include - #include + #include + #include + + #if defined(_TD_DARWIN_64) + #include + #else + #include + #include + #endif #endif #ifdef __cplusplus @@ -49,7 +56,29 @@ extern "C" { #endif #if defined(_TD_DARWIN_64) - #define htobe64 htonll +// #define htobe64 htonll + +# include + +# define htobe16(x) OSSwapHostToBigInt16(x) +# define htole16(x) OSSwapHostToLittleInt16(x) +# define be16toh(x) OSSwapBigToHostInt16(x) +# define le16toh(x) OSSwapLittleToHostInt16(x) + +# define htobe32(x) OSSwapHostToBigInt32(x) +# define htole32(x) OSSwapHostToLittleInt32(x) +# define be32toh(x) OSSwapBigToHostInt32(x) +# define le32toh(x) OSSwapLittleToHostInt32(x) + +# define htobe64(x) OSSwapHostToBigInt64(x) +# define htole64(x) OSSwapHostToLittleInt64(x) +# define be64toh(x) OSSwapBigToHostInt64(x) +# define le64toh(x) OSSwapLittleToHostInt64(x) + +# define __BYTE_ORDER BYTE_ORDER +# define __BIG_ENDIAN BIG_ENDIAN +# define __LITTLE_ENDIAN LITTLE_ENDIAN +# define __PDP_ENDIAN PDP_ENDIAN #endif #define TAOS_EPOLL_WAIT_TIME 500 diff --git a/include/os/osSysinfo.h b/include/os/osSysinfo.h index d7cf05a594..7777466973 100644 --- a/include/os/osSysinfo.h +++ b/include/os/osSysinfo.h @@ -16,6 +16,7 @@ #ifndef _TD_OS_SYSINFO_H_ #define _TD_OS_SYSINFO_H_ +#include #include "os.h" #ifdef __cplusplus @@ -52,7 +53,7 @@ int32_t taosGetSystemUUID(char *uid, int32_t uidlen); char *taosGetCmdlineByPID(int32_t pid); void taosSetCoreDump(bool enable); -#if defined(WINDOWS) +#if !defined(LINUX) #define _UTSNAME_LENGTH 65 #define _UTSNAME_MACHINE_LENGTH _UTSNAME_LENGTH diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 7e4f1d9025..0d1f762db6 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -864,7 +864,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullFirs qsort(pColInfoData->pData, pDataBlock->info.rows, pColInfoData->info.bytes, fn); int64_t p1 = taosGetTimestampUs(); - printf("sort:%ld, rows:%d\n", p1 - p0, pDataBlock->info.rows); + printf("sort:%" PRId64 ", rows:%d\n", p1 - p0, pDataBlock->info.rows); return TSDB_CODE_SUCCESS; } else { // var data type @@ -912,7 +912,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullFirs copyBackToBlock(pDataBlock, pCols); int64_t p4 = taosGetTimestampUs(); - printf("sort:%ld, create:%ld, assign:%ld, copyback:%ld, rows:%d\n", p1-p0, p2 - p1, p3 - p2, p4-p3, rows); + printf("sort:%" PRId64 ", create:%" PRId64 ", assign:%" PRId64 ", copyback:%" PRId64 ", rows:%d\n", p1-p0, p2 - p1, p3 - p2, p4-p3, rows); destroyTupleIndex(index); return TSDB_CODE_SUCCESS; @@ -1017,7 +1017,7 @@ int32_t dataBlockCompar_rv(const void* p1, const void* p2, const void* param) { } int32_t varColSort(SColumnInfoData* pColumnInfoData, SBlockOrderInfo* pOrder) { - + return 0; } int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullFirst) { @@ -1055,8 +1055,9 @@ int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullF copyBackToBlock(pDataBlock, pCols); int64_t p4 = taosGetTimestampUs(); - printf("sort:%ld, create:%ld, assign:%ld, copyback:%ld, rows:%d\n", p1 - p0, p2 - p1, p3 - p2, p4 - p3, rows); + printf("sort:%" PRId64 ", create:%" PRId64", assign:%" PRId64 ", copyback:%" PRId64 ", rows:%d\n", p1 - p0, p2 - p1, p3 - p2, p4 - p3, rows); // destroyTupleIndex(index); + return 0; } void blockDataClearup(SSDataBlock* pDataBlock) { diff --git a/source/common/src/ttszip.c b/source/common/src/ttszip.c index 464c29d287..5f0a353226 100644 --- a/source/common/src/ttszip.c +++ b/source/common/src/ttszip.c @@ -845,7 +845,11 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf) { int64_t offset = getDataStartOffset(); int32_t size = (int32_t)pSrcBuf->fileSize - (int32_t)offset; +#if defined(_TD_DARWIN_64) + int64_t written = taosFSendFile(pDestBuf->pFile->fp, pSrcBuf->pFile->fp, &offset, size); +#else int64_t written = taosFSendFile(pDestBuf->pFile, pSrcBuf->pFile, &offset, size); +#endif if (written == -1 || written != size) { return -1; diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index e1ccb03c66..80a0b3554c 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -1062,7 +1062,7 @@ int32_t ctgMetaRentInit(SCtgRentMgmt *mgmt, uint32_t rentSec, int8_t type) { int32_t ctgMetaRentAdd(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size) { - int16_t widx = abs(id % mgmt->slotNum); + int16_t widx = abs((int)(id % mgmt->slotNum)); SCtgRentSlot *slot = &mgmt->slots[widx]; int32_t code = 0; @@ -1092,11 +1092,11 @@ _return: } int32_t ctgMetaRentUpdate(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size, __compar_fn_t sortCompare, __compar_fn_t searchCompare) { - int16_t widx = abs(id % mgmt->slotNum); + int16_t widx = abs((int)(id % mgmt->slotNum)); SCtgRentSlot *slot = &mgmt->slots[widx]; int32_t code = 0; - + CTG_LOCK(CTG_WRITE, &slot->lock); if (NULL == slot->meta) { qError("empty meta slot, id:%"PRIx64", slot idx:%d, type:%d", id, widx, mgmt->type); @@ -1133,7 +1133,7 @@ _return: } int32_t ctgMetaRentRemove(SCtgRentMgmt *mgmt, int64_t id, __compar_fn_t sortCompare, __compar_fn_t searchCompare) { - int16_t widx = abs(id % mgmt->slotNum); + int16_t widx = abs((int)(id % mgmt->slotNum)); SCtgRentSlot *slot = &mgmt->slots[widx]; int32_t code = 0; diff --git a/source/libs/index/src/index.c b/source/libs/index/src/index.c index 744f6ca70b..d25fed6816 100644 --- a/source/libs/index/src/index.c +++ b/source/libs/index/src/index.c @@ -240,6 +240,7 @@ int indexRebuild(SIndex* index, SIndexOpts* opts){ #ifdef USE_INVERTED_INDEX #endif + return 0; } SIndexOpts* indexOptsCreate() { diff --git a/source/libs/index/src/index_cache.c b/source/libs/index/src/index_cache.c index b40ded9e9a..34f009dd7e 100644 --- a/source/libs/index/src/index_cache.c +++ b/source/libs/index/src/index_cache.c @@ -190,7 +190,10 @@ int indexCacheSchedToMerge(IndexCache* pCache) { schedMsg.msg = NULL; taosScheduleTask(indexQhandle, &schedMsg); + + return 0; } + static void indexCacheMakeRoomForWrite(IndexCache* cache) { while (true) { if (cache->occupiedMem * MEM_ESTIMATE_RADIO < MEM_THRESHOLD) { diff --git a/source/libs/index/src/index_fst.c b/source/libs/index/src/index_fst.c index a6cabbd439..18cde151d2 100644 --- a/source/libs/index/src/index_fst.c +++ b/source/libs/index/src/index_fst.c @@ -571,6 +571,8 @@ uint64_t fstStateFindInput(FstState* s, FstNode* node, uint8_t b, bool* null) { } fstSliceDestroy(&t); } + + return 0; } // fst node function @@ -1027,6 +1029,8 @@ Fst* fstCreate(FstSlice* slice) { FST_CREAT_FAILED: free(fst->meta); free(fst); + + return NULL; } void fstDestroy(Fst* fst) { if (fst) { @@ -1286,6 +1290,8 @@ bool streamWithStateSeekMin(StreamWithState* sws, FstBoundWithData* min) { } return false; } + + return false; } StreamWithStateResult* streamWithStateNextWith(StreamWithState* sws, StreamCallback callback) { diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 43cc308483..28f680cfbb 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -763,6 +763,8 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pTagsSchema, // todo construct payload tfree(row); + + return 0; } // pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...) diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 3fae580de9..cd9857c7f6 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -425,6 +425,7 @@ static SLogicNode* createQueryLogicNode(SLogicPlanContext* pCxt, SNode* pStmt) { default: break; } + return NULL; // to avoid compiler error } int32_t createLogicPlan(SPlanContext* pCxt, SLogicNode** pLogicNode) { diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index a7aea5a7e5..33ec8ab6ef 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -792,7 +792,7 @@ int32_t filterDetachCnfGroups(SArray* group, SArray* left, SArray* right) { } SFilterGroup *gp = NULL; - while (gp = (SFilterGroup *)taosArrayPop(right)) { + while ((gp = (SFilterGroup *)taosArrayPop(right)) != NULL) { taosArrayPush(group, gp); } @@ -801,7 +801,7 @@ int32_t filterDetachCnfGroups(SArray* group, SArray* left, SArray* right) { if (taosArrayGetSize(right) <= 0) { SFilterGroup *gp = NULL; - while (gp = (SFilterGroup *)taosArrayPop(left)) { + while ((gp = (SFilterGroup *)taosArrayPop(left)) != NULL) { taosArrayPush(group, gp); } diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index b8cdda9ed1..8e7eaa0f8c 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -239,6 +239,9 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t break; } + + default: + break; } if (param->num > *rowNum) { diff --git a/source/libs/scheduler/src/schFlowCtrl.c b/source/libs/scheduler/src/schFlowCtrl.c index 9fba6523b6..993521da87 100644 --- a/source/libs/scheduler/src/schFlowCtrl.c +++ b/source/libs/scheduler/src/schFlowCtrl.c @@ -282,8 +282,10 @@ int32_t schLaunchTasksInFlowCtrlList(SSchJob *pJob, SSchTask *pTask) { SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR); } - SCH_ERR_RET(schLaunchTasksInFlowCtrlListImpl(pJob, ctrl)); + int32_t code = schLaunchTasksInFlowCtrlListImpl(pJob, ctrl);; + SCH_ERR_RET(code); + return code; // to avoid compiler error } diff --git a/source/libs/sync/src/syncRaftEntry.c b/source/libs/sync/src/syncRaftEntry.c index f29b3022d8..7ececf285a 100644 --- a/source/libs/sync/src/syncRaftEntry.c +++ b/source/libs/sync/src/syncRaftEntry.c @@ -74,12 +74,12 @@ cJSON* syncEntry2Json(const SSyncRaftEntry* pEntry) { cJSON_AddNumberToObject(pRoot, "bytes", pEntry->bytes); cJSON_AddNumberToObject(pRoot, "msgType", pEntry->msgType); cJSON_AddNumberToObject(pRoot, "originalRpcType", pEntry->originalRpcType); - snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->seqNum); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pEntry->seqNum); cJSON_AddStringToObject(pRoot, "seqNum", u64buf); cJSON_AddNumberToObject(pRoot, "isWeak", pEntry->isWeak); - snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pEntry->term); cJSON_AddStringToObject(pRoot, "term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->index); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pEntry->index); cJSON_AddStringToObject(pRoot, "index", u64buf); cJSON_AddNumberToObject(pRoot, "dataLen", pEntry->dataLen); @@ -107,26 +107,26 @@ char* syncEntry2Str(const SSyncRaftEntry* pEntry) { // for debug ---------------------- void syncEntryPrint(const SSyncRaftEntry* pObj) { char* serialized = syncEntry2Str(pObj); - printf("syncEntryPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncEntryPrint | len:%zu | %s \n", strlen(serialized), serialized); fflush(NULL); free(serialized); } void syncEntryPrint2(char* s, const SSyncRaftEntry* pObj) { char* serialized = syncEntry2Str(pObj); - printf("syncEntryPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncEntryPrint2 | len:%zu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); free(serialized); } void syncEntryLog(const SSyncRaftEntry* pObj) { char* serialized = syncEntry2Str(pObj); - sTrace("syncEntryLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("syncEntryLog | len:%zu | %s", strlen(serialized), serialized); free(serialized); } void syncEntryLog2(char* s, const SSyncRaftEntry* pObj) { char* serialized = syncEntry2Str(pObj); - sTrace("syncEntryLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("syncEntryLog2 | len:%zu | %s | %s", strlen(serialized), s, serialized); free(serialized); -} \ No newline at end of file +} diff --git a/source/libs/sync/src/syncVoteMgr.c b/source/libs/sync/src/syncVoteMgr.c index 5c8e70979c..6cb6a28805 100644 --- a/source/libs/sync/src/syncVoteMgr.c +++ b/source/libs/sync/src/syncVoteMgr.c @@ -97,7 +97,7 @@ cJSON *voteGranted2Json(SVotesGranted *pVotesGranted) { cJSON_AddItemToObject(pRoot, "isGranted", pIsGranted); cJSON_AddNumberToObject(pRoot, "votes", pVotesGranted->votes); - snprintf(u64buf, sizeof(u64buf), "%lu", pVotesGranted->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pVotesGranted->term); cJSON_AddStringToObject(pRoot, "term", u64buf); cJSON_AddNumberToObject(pRoot, "quorum", pVotesGranted->quorum); cJSON_AddNumberToObject(pRoot, "toLeader", pVotesGranted->toLeader); @@ -122,27 +122,27 @@ char *voteGranted2Str(SVotesGranted *pVotesGranted) { // for debug ------------------- void voteGrantedPrint(SVotesGranted *pObj) { char *serialized = voteGranted2Str(pObj); - printf("voteGrantedPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("voteGrantedPrint | len:%zu | %s \n", strlen(serialized), serialized); fflush(NULL); free(serialized); } void voteGrantedPrint2(char *s, SVotesGranted *pObj) { char *serialized = voteGranted2Str(pObj); - printf("voteGrantedPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("voteGrantedPrint2 | len:%zu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); free(serialized); } void voteGrantedLog(SVotesGranted *pObj) { char *serialized = voteGranted2Str(pObj); - sTrace("voteGrantedLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("voteGrantedLog | len:%zu | %s", strlen(serialized), serialized); free(serialized); } void voteGrantedLog2(char *s, SVotesGranted *pObj) { char *serialized = voteGranted2Str(pObj); - sTrace("voteGrantedLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("voteGrantedLog2 | len:%zu | %s | %s", strlen(serialized), s, serialized); free(serialized); } @@ -222,7 +222,7 @@ cJSON *votesRespond2Json(SVotesRespond *pVotesRespond) { cJSON_AddItemToObject(pRoot, "isRespond", pIsRespond); cJSON_AddNumberToObject(pRoot, "respondNum", respondNum); - snprintf(u64buf, sizeof(u64buf), "%lu", pVotesRespond->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pVotesRespond->term); cJSON_AddStringToObject(pRoot, "term", u64buf); snprintf(u64buf, sizeof(u64buf), "%p", pVotesRespond->pSyncNode); cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); @@ -242,26 +242,26 @@ char *votesRespond2Str(SVotesRespond *pVotesRespond) { // for debug ------------------- void votesRespondPrint(SVotesRespond *pObj) { char *serialized = votesRespond2Str(pObj); - printf("votesRespondPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("votesRespondPrint | len:%zu | %s \n", strlen(serialized), serialized); fflush(NULL); free(serialized); } void votesRespondPrint2(char *s, SVotesRespond *pObj) { char *serialized = votesRespond2Str(pObj); - printf("votesRespondPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("votesRespondPrint2 | len:%zu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); free(serialized); } void votesRespondLog(SVotesRespond *pObj) { char *serialized = votesRespond2Str(pObj); - sTrace("votesRespondLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("votesRespondLog | len:%zu | %s", strlen(serialized), serialized); free(serialized); } void votesRespondLog2(char *s, SVotesRespond *pObj) { char *serialized = votesRespond2Str(pObj); - sTrace("votesRespondLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("votesRespondLog2 | len:%zu | %s | %s", strlen(serialized), s, serialized); free(serialized); -} \ No newline at end of file +} diff --git a/source/libs/tfs/src/tfs.c b/source/libs/tfs/src/tfs.c index c46989dc5d..01e9808aa6 100644 --- a/source/libs/tfs/src/tfs.c +++ b/source/libs/tfs/src/tfs.c @@ -558,4 +558,6 @@ int32_t tfsGetMonitorInfo(STfs *pTfs, SMonDiskInfo *pInfo) { } } tfsUnLock(pTfs); -} \ No newline at end of file + + return 0; +} diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 2f6ff3763f..5be1b7ea90 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -291,6 +291,7 @@ void* destroyConnPool(void* pool) { connList = taosHashIterate((SHashObj*)pool, connList); } taosHashCleanup(pool); + return NULL; } static SCliConn* getConnFromPool(void* pool, char* ip, uint32_t port) { @@ -576,6 +577,8 @@ static void* cliWorkThread(void* arg) { SCliThrdObj* pThrd = (SCliThrdObj*)arg; setThreadName("trans-cli-work"); uv_run(pThrd->loop, UV_RUN_DEFAULT); + + return NULL; } void* transInitClient(uint32_t ip, uint32_t port, char* label, int numOfThreads, void* fp, void* shandle) { diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index 367cb33fc9..7123593a33 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -155,14 +155,16 @@ bool transReadComplete(SConnBuffer* connBuf) { } return false; } -int transPackMsg(STransMsgHead* msgHead, bool sercured, bool auth) {} +int transPackMsg(STransMsgHead* msgHead, bool sercured, bool auth) {return 0;} -int transUnpackMsg(STransMsgHead* msgHead) {} +int transUnpackMsg(STransMsgHead* msgHead) {return 0;} int transDestroyBuffer(SConnBuffer* buf) { if (buf->cap > 0) { tfree(buf->buf); } transClearBuffer(buf); + + return 0; } int transSetConnOption(uv_tcp_t* stream) { diff --git a/source/libs/transport/src/transSrv.c b/source/libs/transport/src/transSrv.c index cb3bbaefec..d26c5ec0f4 100644 --- a/source/libs/transport/src/transSrv.c +++ b/source/libs/transport/src/transSrv.c @@ -538,6 +538,8 @@ void* acceptThread(void* arg) { setThreadName("trans-accept"); SServerObj* srv = (SServerObj*)arg; uv_run(srv->loop, UV_RUN_DEFAULT); + + return NULL; } static bool addHandleToWorkloop(void* arg) { SWorkThrdObj* pThrd = arg; @@ -593,6 +595,8 @@ void* workerThread(void* arg) { setThreadName("trans-worker"); SWorkThrdObj* pThrd = (SWorkThrdObj*)arg; uv_run(pThrd->loop, UV_RUN_DEFAULT); + + return NULL; } static SSrvConn* createConn(void* hThrd) { diff --git a/source/libs/wal/src/walRead.c b/source/libs/wal/src/walRead.c index 9e1ffeae7f..8d3acef9e7 100644 --- a/source/libs/wal/src/walRead.c +++ b/source/libs/wal/src/walRead.c @@ -169,7 +169,7 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) { } if (pRead->pHead->head.version != ver) { - wError("unexpected wal log version: %ld, read request version:%ld", pRead->pHead->head.version, ver); + wError("unexpected wal log version: %" PRId64 ", read request version:%" PRId64 "", pRead->pHead->head.version, ver); pRead->curVersion = -1; terrno = TSDB_CODE_WAL_FILE_CORRUPTED; return -1; diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c index 6472202bf9..bcbd95e160 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -14,6 +14,7 @@ */ #define ALLOW_FORBID_FUNC #include "os.h" +#include "osSemaphore.h" #if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) #include @@ -35,26 +36,18 @@ extern int openU(const char *, int, ...); /* MsvcLibX UTF-8 version of open */ #else #include #include -#include + +#if !defined(_TD_DARWIN_64) + #include +#endif #include #include #define LINUX_FILE_NO_TEXT_OPTION 0 #define O_TEXT LINUX_FILE_NO_TEXT_OPTION #endif -typedef int32_t FileFd; - #define FILE_WITH_LOCK 1 -typedef struct TdFile { -#if FILE_WITH_LOCK - pthread_rwlock_t rwlock; -#endif - int refId; - FileFd fd; - FILE *fp; -} * TdFilePtr, TdFile; - void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath) { #if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) const char *tdengineTmpFileNamePrefix = "tdengine-"; diff --git a/source/os/src/osSocket.c b/source/os/src/osSocket.c index 698ceded16..e3b1015d88 100644 --- a/source/os/src/osSocket.c +++ b/source/os/src/osSocket.c @@ -17,7 +17,7 @@ #define ALLOW_FORBID_FUNC #include "os.h" -#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) +#if defined(WINDOWS) #include #include #include @@ -37,8 +37,14 @@ #include #include #include -#include #include + +#if defined(DARWIN) + #include + #include "osEok.h" +#else + #include +#endif #endif typedef int32_t SocketFd; @@ -210,7 +216,7 @@ int32_t taosShutDownSocketServerRDWR(TdSocketServerPtr pSocketServer) { #endif } -#if (defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)) +#if (defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)) #if defined(_TD_GO_DLL_) uint64_t htonll(uint64_t val) { return (((uint64_t)htonl(val)) << 32) + htonl(val >> 32); } #endif diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index d4bcc27f60..404c9c8f71 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -570,6 +570,7 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) { case CFG_DTYPE_LOCALE: case CFG_DTYPE_CHARSET: case CFG_DTYPE_TIMEZONE: + case CFG_DTYPE_NONE: if (dump) { printf("%s %s %s", src, name, pItem->str); printf("\n"); @@ -655,4 +656,4 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) { int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { uInfo("load from apoll url %s", url); return 0; -} \ No newline at end of file +} diff --git a/source/util/src/ttimer.c b/source/util/src/ttimer.c index 7bdcf3cc64..46bca6e6cb 100644 --- a/source/util/src/ttimer.c +++ b/source/util/src/ttimer.c @@ -628,7 +628,7 @@ void taosTmrCleanUp(void* handle) { tmrCtrls = NULL; unusedTmrCtrl = NULL; -#if !defined(WINDOWS) +#if defined(LINUX) tmrModuleInit = PTHREAD_ONCE_INIT; // to support restart #endif } From 4f330fab1fe48f8eb925a2f57e6b9f7d71de6422 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Tue, 15 Mar 2022 23:47:37 +0800 Subject: [PATCH 25/38] handle except --- include/libs/transport/trpc.h | 2 +- source/libs/transport/inc/transComm.h | 3 ++ source/libs/transport/src/trans.c | 13 ++++-- source/libs/transport/src/transCli.c | 63 +++++++++++++++++++++++---- source/libs/transport/src/transSrv.c | 7 ++- source/libs/transport/test/transUT.cc | 53 +++++++++++++++++++++- 6 files changed, 126 insertions(+), 15 deletions(-) diff --git a/include/libs/transport/trpc.h b/include/libs/transport/trpc.h index 231bc4af45..b5b8d6ab66 100644 --- a/include/libs/transport/trpc.h +++ b/include/libs/transport/trpc.h @@ -94,7 +94,7 @@ int rpcReportProgress(void *pConn, char *pCont, int contLen); void rpcCancelRequest(int64_t rid); // just release client conn to rpc instance, no close sock -void rpcReleaseHandle(void *handle); +void rpcReleaseHandle(void *handle, int8_t type); void rpcRefHandle(void *handle, int8_t type); void rpcUnrefHandle(void *handle, int8_t type); diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index 76347cdba2..8ea65b193d 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -252,6 +252,9 @@ void transUnrefSrvHandle(void* handle); void transRefCliHandle(void* handle); void transUnrefCliHandle(void* handle); +void transReleaseCliHandle(void* handle); +void transReleaseSrvHandle(void* handle); + void transSendRequest(void* shandle, const char* ip, uint32_t port, STransMsg* pMsg); void transSendRecv(void* shandle, const char* ip, uint32_t port, STransMsg* pMsg, STransMsg* pRsp); void transSendResponse(const STransMsg* pMsg); diff --git a/source/libs/transport/src/trans.c b/source/libs/transport/src/trans.c index 213782c5bd..2cab03f133 100644 --- a/source/libs/transport/src/trans.c +++ b/source/libs/transport/src/trans.c @@ -22,6 +22,11 @@ void* (*taosInitHandle[])(uint32_t ip, uint32_t port, char* label, int numOfThre void (*taosCloseHandle[])(void* arg) = {transCloseServer, transCloseClient}; +void (*taosRefHandle[])(void* handle) = {transRefSrvHandle, transRefCliHandle}; +void (*taosUnRefHandle[])(void* handle) = {transUnrefSrvHandle, transUnrefCliHandle}; + +void (*transReleaseHandle[])(void* handle) = {transReleaseSrvHandle, transReleaseCliHandle}; + void* rpcOpen(const SRpcInit* pInit) { SRpcInfo* pRpc = calloc(1, sizeof(SRpcInfo)); if (pRpc == NULL) { @@ -127,9 +132,6 @@ void rpcSendRecv(void* shandle, SEpSet* pEpSet, SRpcMsg* pMsg, SRpcMsg* pRsp) { void rpcSendResponse(const SRpcMsg* pMsg) { transSendResponse(pMsg); } int rpcGetConnInfo(void* thandle, SRpcConnInfo* pInfo) { return transGetConnInfo((void*)thandle, pInfo); } -void (*taosRefHandle[])(void* handle) = {transRefSrvHandle, transRefCliHandle}; -void (*taosUnRefHandle[])(void* handle) = {transUnrefSrvHandle, transUnrefCliHandle}; - void rpcRefHandle(void* handle, int8_t type) { assert(type == TAOS_CONN_SERVER || type == TAOS_CONN_CLIENT); (*taosRefHandle[type])(handle); @@ -140,6 +142,11 @@ void rpcUnrefHandle(void* handle, int8_t type) { (*taosUnRefHandle[type])(handle); } +void rpcReleaseHandle(void* handle, int8_t type) { + assert(type == TAOS_CONN_SERVER || type == TAOS_CONN_CLIENT); + (*transReleaseHandle[type])(handle); +} + int32_t rpcInit() { // impl later return 0; diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 5c50ca2bc3..931f58097e 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -17,6 +17,11 @@ #include "transComm.h" +// Normal(default): send/recv msg +// Quit: quit rpc inst +// Release: release handle to rpc inst +typedef enum { Normal, Quit, Release } SCliMsgType; + typedef struct SCliConn { T_REF_DECLARE() uv_connect_t connReq; @@ -49,6 +54,7 @@ typedef struct SCliMsg { STransMsg msg; queue q; uint64_t st; + SCliMsgType type; } SCliMsg; typedef struct SCliThrdObj { @@ -108,6 +114,8 @@ static void cliHandleExcept(SCliConn* conn); // handle req from app static void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd); static void cliHandleQuit(SCliMsg* pMsg, SCliThrdObj* pThrd); +static void cliHandleRelease(SCliMsg* pMsg, SCliThrdObj* pThrd); + static void cliSendQuit(SCliThrdObj* thrd); static void destroyUserdata(STransMsg* userdata); @@ -121,8 +129,8 @@ static void destroyThrdObj(SCliThrdObj* pThrd); #define CONN_HOST_THREAD_INDEX(conn) (conn ? ((SCliConn*)conn)->hThrdIdx : -1) #define CONN_PERSIST_TIME(para) (para * 1000 * 10) - -#define CONN_GET_INST_LABEL(conn) (((STrans*)(((SCliThrdObj*)conn->hostThrd)->pTransInst))->label) +#define CONN_GET_HOST_THREAD(conn) (conn ? ((SCliConn*)conn)->hostThrd : NULL) +#define CONN_GET_INST_LABEL(conn) (((STrans*)(((SCliThrdObj*)(conn)->hostThrd)->pTransInst))->label) #define CONN_HANDLE_THREAD_QUIT(conn, thrd) \ do { \ if (thrd->quit) { \ @@ -344,6 +352,8 @@ static void addConnToPool(void* pool, SCliConn* conn) { static void cliAllocRecvBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) { SCliConn* conn = handle->data; SConnBuffer* pBuf = &conn->readBuf; + // avoid conn + QUEUE_REMOVE(&conn->conn); transAllocBuffer(pBuf, buf); } static void cliRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { @@ -506,6 +516,21 @@ static void cliHandleQuit(SCliMsg* pMsg, SCliThrdObj* pThrd) { pThrd->quit = true; uv_stop(pThrd->loop); } +static void cliHandleRelease(SCliMsg* pMsg, SCliThrdObj* pThrd) { + SCliConn* conn = pMsg->msg.handle; + tDebug("%s cli conn %p release to inst", CONN_GET_INST_LABEL(conn), conn); + + destroyCmsg(pMsg); + conn->data = NULL; + + transDestroyBuffer(&conn->readBuf); + if (conn->persist && T_REF_VAL_GET(conn) >= 2) { + transUnrefCliHandle(conn); + addConnToPool(pThrd->pool, conn); + } else { + transUnrefCliHandle(conn); + } +} SCliConn* cliGetConn(SCliMsg* pMsg, SCliThrdObj* pThrd) { SCliConn* conn = NULL; @@ -517,7 +542,9 @@ SCliConn* cliGetConn(SCliMsg* pMsg, SCliThrdObj* pThrd) { } else { STransConnCtx* pCtx = pMsg->ctx; conn = getConnFromPool(pThrd->pool, pCtx->ip, pCtx->port); - if (conn != NULL) tTrace("%s cli conn %p get from conn pool", CONN_GET_INST_LABEL(conn), conn); + if (conn != NULL) { + tTrace("%s cli conn %p get from conn pool", CONN_GET_INST_LABEL(conn), conn); + } } return conn; } @@ -572,10 +599,13 @@ static void cliAsyncCb(uv_async_t* handle) { QUEUE_REMOVE(h); SCliMsg* pMsg = QUEUE_DATA(h, SCliMsg, q); - if (pMsg->ctx == NULL) { - cliHandleQuit(pMsg, pThrd); - } else { + + if (pMsg->type == Normal) { cliHandleReq(pMsg, pThrd); + } else if (pMsg->type == Quit) { + cliHandleQuit(pMsg, pThrd); + } else if (pMsg->type == Release) { + cliHandleRelease(pMsg, pThrd); } count++; } @@ -671,8 +701,10 @@ static void transDestroyConnCtx(STransConnCtx* ctx) { void cliSendQuit(SCliThrdObj* thrd) { // cli can stop gracefully SCliMsg* msg = calloc(1, sizeof(SCliMsg)); + msg->type = Quit; transSendAsync(thrd->asyncPool, &msg->q); } + int cliRBChoseIdx(STrans* pTransInst) { int64_t index = pTransInst->index; if (pTransInst->index++ >= pTransInst->numOfThreads) { @@ -702,10 +734,25 @@ void transUnrefCliHandle(void* handle) { return; } int ref = T_REF_DEC((SCliConn*)handle); + tDebug("%s cli conn %p ref %d", CONN_GET_INST_LABEL((SCliConn*)handle), handle, ref); if (ref == 0) { cliDestroyConn((SCliConn*)handle, true); } } +void transReleaseCliHandle(void* handle) { + SCliThrdObj* thrd = CONN_GET_HOST_THREAD(handle); + if (thrd == NULL) { + return; + } + + STransMsg tmsg = {.handle = handle}; + + SCliMsg* cmsg = calloc(1, sizeof(SCliMsg)); + cmsg->type = Release; + cmsg->msg = tmsg; + + transSendAsync(thrd->asyncPool, &cmsg->q); +} void transSendRequest(void* shandle, const char* ip, uint32_t port, STransMsg* pMsg) { STrans* pTransInst = (STrans*)shandle; @@ -728,7 +775,7 @@ void transSendRequest(void* shandle, const char* ip, uint32_t port, STransMsg* p assert(pTransInst->connType == TAOS_CONN_CLIENT); // atomic or not - SCliMsg* cliMsg = malloc(sizeof(SCliMsg)); + SCliMsg* cliMsg = calloc(1, sizeof(SCliMsg)); cliMsg->ctx = pCtx; cliMsg->msg = *pMsg; cliMsg->st = taosGetTimestampUs(); @@ -753,7 +800,7 @@ void transSendRecv(void* shandle, const char* ip, uint32_t port, STransMsg* pReq pCtx->pRsp = pRsp; tsem_init(pCtx->pSem, 0, 0); - SCliMsg* cliMsg = malloc(sizeof(SCliMsg)); + SCliMsg* cliMsg = calloc(1, sizeof(SCliMsg)); cliMsg->ctx = pCtx; cliMsg->msg = *pReq; cliMsg->st = taosGetTimestampUs(); diff --git a/source/libs/transport/src/transSrv.c b/source/libs/transport/src/transSrv.c index a3cc6b6181..960e064b8f 100644 --- a/source/libs/transport/src/transSrv.c +++ b/source/libs/transport/src/transSrv.c @@ -641,7 +641,7 @@ static void uvDestroyConn(uv_handle_t* handle) { uv_timer_stop(&conn->pTimer); QUEUE_REMOVE(&conn->queue); free(conn->pTcp); - free(conn); + // free(conn); if (thrd->quit && QUEUE_IS_EMPTY(&thrd->conn)) { uv_loop_close(thrd->loop); @@ -786,6 +786,11 @@ void transUnrefSrvHandle(void* handle) { } // unref srv handle } + +void transReleaseSrvHandle(void* handle) { + // do nothing currently + // +} void transSendResponse(const STransMsg* pMsg) { if (pMsg->handle == NULL) { return; diff --git a/source/libs/transport/test/transUT.cc b/source/libs/transport/test/transUT.cc index b0fae2f8b4..46f6424b0b 100644 --- a/source/libs/transport/test/transUT.cc +++ b/source/libs/transport/test/transUT.cc @@ -110,6 +110,14 @@ class Client { SemWait(); *resp = this->resp; } + void SendAndRecvNoHandle(SRpcMsg *req, SRpcMsg *resp) { + if (req->handle != NULL) { + rpcReleaseHandle(req->handle, TAOS_CONN_CLIENT); + req->handle = NULL; + } + SendAndRecv(req, resp); + } + void SendWithHandle(SRpcMsg *req, SRpcMsg *resp) {} void SemWait() { tsem_wait(&this->sem); } void SemPost() { tsem_post(&this->sem); } @@ -268,6 +276,7 @@ class TransObj { } void RestartSrv() { srv->Restart(); } void cliSendAndRecv(SRpcMsg *req, SRpcMsg *resp) { cli->SendAndRecv(req, resp); } + void cliSendAndRecvNoHandle(SRpcMsg *req, SRpcMsg *resp) { cli->SendAndRecvNoHandle(req, resp); } ~TransObj() { delete cli; @@ -352,7 +361,47 @@ TEST_F(TransEnv, cliPersistHandle) { EXPECT_TRUE(resp.code != 0); } } + ////////////////// +} +TEST_F(TransEnv, cliReleaseHandle) { + tr->SetCliPersistFp(cliPersistHandle); + + SRpcMsg resp = {0}; + for (int i = 0; i < 10; i++) { + SRpcMsg req = {.handle = resp.handle}; + req.msgType = 1; + req.pCont = rpcMallocCont(10); + req.contLen = 10; + tr->cliSendAndRecvNoHandle(&req, &resp); + // if (i == 5) { + // std::cout << "stop server" << std::endl; + // tr->StopSrv(); + //} + // if (i >= 6) { + EXPECT_TRUE(resp.code == 0); + //} + } + ////////////////// +} +TEST_F(TransEnv, cliReleaseHandleExcept) { + tr->SetCliPersistFp(cliPersistHandle); + + SRpcMsg resp = {0}; + for (int i = 0; i < 10; i++) { + SRpcMsg req = {.handle = resp.handle}; + req.msgType = 1; + req.pCont = rpcMallocCont(10); + req.contLen = 10; + tr->cliSendAndRecvNoHandle(&req, &resp); + if (i == 5) { + std::cout << "stop server" << std::endl; + tr->StopSrv(); + } + if (i >= 6) { + EXPECT_TRUE(resp.code != 0); + } + } ////////////////// } TEST_F(TransEnv, srvContinueSend) { @@ -367,11 +416,11 @@ TEST_F(TransEnv, srvContinueSend) { taosMsleep(2000); } -TEST_F(TransEnv, srvPersisHandleExcept) { +TEST_F(TransEnv, srvPersistHandleExcept) { // conn breken // } -TEST_F(TransEnv, cliPersisHandleExcept) { +TEST_F(TransEnv, cliPersistHandleExcept) { // conn breken } From 6e9bc0cbd9c6d4bd88a572ca877b2ad8286f20bd Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 16 Mar 2022 09:08:42 +0800 Subject: [PATCH 26/38] handle except --- source/libs/transport/src/transCli.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 931f58097e..3696e86d22 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -525,6 +525,7 @@ static void cliHandleRelease(SCliMsg* pMsg, SCliThrdObj* pThrd) { transDestroyBuffer(&conn->readBuf); if (conn->persist && T_REF_VAL_GET(conn) >= 2) { + conn->persist = false; transUnrefCliHandle(conn); addConnToPool(pThrd->pool, conn); } else { @@ -746,8 +747,7 @@ void transReleaseCliHandle(void* handle) { } STransMsg tmsg = {.handle = handle}; - - SCliMsg* cmsg = calloc(1, sizeof(SCliMsg)); + SCliMsg* cmsg = calloc(1, sizeof(SCliMsg)); cmsg->type = Release; cmsg->msg = tmsg; From 3c6c518470772adbf44695d826e86347e9eff533 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Wed, 16 Mar 2022 11:37:31 +0800 Subject: [PATCH 27/38] [TD-13063]: 3.0 on windows (#10765) * [TD-13063]: 3.0 on Windows * add pthread in contrib * fix linux compile * fix osSemaphore * add gnu regex for Windows * fix compile error for Windows * support arm platform * port more OS files * fix for Windows compile * port more files * fix macOS on x86_64 * port osFile * port osSemaphone.h * port osSocket.c * port tconfig.c * port ttimer.c * add couple files * merge with 3.0 --- cmake/cmake.platform | 2 +- source/client/src/clientMsgHandler.c | 6 +-- source/dnode/mnode/impl/src/mndConsumer.c | 12 ++--- source/dnode/mnode/impl/src/mndSubscribe.c | 14 ++--- source/dnode/mnode/sdb/src/sdbFile.c | 2 +- source/libs/executor/src/dataSinkMgt.c | 1 + source/libs/executor/src/tlinearhash.c | 4 +- source/libs/sync/src/syncAppendEntriesReply.c | 2 +- source/libs/sync/src/syncEnv.c | 6 +-- source/libs/sync/src/syncMain.c | 28 +++++----- source/libs/sync/src/syncMessage.c | 54 +++++++++---------- source/libs/sync/src/syncRaftLog.c | 10 ++-- source/libs/sync/src/syncRequestVoteReply.c | 2 +- source/libs/sync/src/syncUtil.c | 4 +- 14 files changed, 76 insertions(+), 71 deletions(-) diff --git a/cmake/cmake.platform b/cmake/cmake.platform index 0312f92a5b..dfb79c0fae 100644 --- a/cmake/cmake.platform +++ b/cmake/cmake.platform @@ -42,7 +42,7 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin SET(TD_DARWIN TRUE) SET(OSTYPE "macOS") - ADD_DEFINITIONS("-DDARWIN -Wno-tautological-pointer-compare") + ADD_DEFINITIONS("-DDARWIN -Wno-tautological-pointer-compare -Wno-return-type") MESSAGE("Current system processor is ${CMAKE_SYSTEM_PROCESSOR}.") IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index 9534c11646..010f4e6c12 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -33,7 +33,7 @@ int32_t genericRspCallback(void* param, const SDataBuf* pMsg, int32_t code) { setErrno(pRequest, code); free(pMsg->pData); - sem_post(&pRequest->body.rspSem); + tsem_post(&pRequest->body.rspSem); return code; } @@ -42,7 +42,7 @@ int32_t processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) { if (code != TSDB_CODE_SUCCESS) { free(pMsg->pData); setErrno(pRequest, code); - sem_post(&pRequest->body.rspSem); + tsem_post(&pRequest->body.rspSem); return code; } @@ -78,7 +78,7 @@ int32_t processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) { pTscObj->pAppInfo->numOfConns); free(pMsg->pData); - sem_post(&pRequest->body.rspSem); + tsem_post(&pRequest->body.rspSem); return 0; } diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index 0f4b538cde..4a9d23aa15 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -96,12 +96,12 @@ SSdbRaw *mndConsumerActionEncode(SMqConsumerObj *pConsumer) { CM_ENCODE_OVER: tfree(buf); if (terrno != 0) { - mError("consumer:%ld, failed to encode to raw:%p since %s", pConsumer->consumerId, pRaw, terrstr()); + mError("consumer:%" PRId64 ", failed to encode to raw:%p since %s", pConsumer->consumerId, pRaw, terrstr()); sdbFreeRaw(pRaw); return NULL; } - mTrace("consumer:%ld, encode to raw:%p, row:%p", pConsumer->consumerId, pRaw, pConsumer); + mTrace("consumer:%" PRId64 ", encode to raw:%p, row:%p", pConsumer->consumerId, pRaw, pConsumer); return pRaw; } @@ -140,7 +140,7 @@ SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) { CM_DECODE_OVER: tfree(buf); if (terrno != TSDB_CODE_SUCCESS) { - mError("consumer:%ld, failed to decode from raw:%p since %s", pConsumer->consumerId, pRaw, terrstr()); + mError("consumer:%" PRId64 ", failed to decode from raw:%p since %s", pConsumer->consumerId, pRaw, terrstr()); tfree(pRow); return NULL; } @@ -149,17 +149,17 @@ CM_DECODE_OVER: } static int32_t mndConsumerActionInsert(SSdb *pSdb, SMqConsumerObj *pConsumer) { - mTrace("consumer:%ld, perform insert action", pConsumer->consumerId); + mTrace("consumer:%" PRId64 ", perform insert action", pConsumer->consumerId); return 0; } static int32_t mndConsumerActionDelete(SSdb *pSdb, SMqConsumerObj *pConsumer) { - mTrace("consumer:%ld, perform delete action", pConsumer->consumerId); + mTrace("consumer:%" PRId64 ", perform delete action", pConsumer->consumerId); return 0; } static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, SMqConsumerObj *pNewConsumer) { - mTrace("consumer:%ld, perform update action", pOldConsumer->consumerId); + mTrace("consumer:%" PRId64 ", perform update action", pOldConsumer->consumerId); // TODO handle update /*taosWLockLatch(&pOldConsumer->lock);*/ diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c index fa4fed59d0..1dcd07829d 100644 --- a/source/dnode/mnode/impl/src/mndSubscribe.c +++ b/source/dnode/mnode/impl/src/mndSubscribe.c @@ -448,7 +448,7 @@ static int32_t mndProcessDoRebalanceMsg(SMnodeMsg *pMsg) { for (int32_t i = 0; i < taosArrayGetSize(pRebSub->lostConsumers); i++) { int64_t lostConsumerId = *(int64_t *)taosArrayGet(pRebSub->lostConsumers, i); - mInfo("mq remove lost consumer %ld", lostConsumerId); + mInfo("mq remove lost consumer %" PRId64 "", lostConsumerId); for (int32_t j = 0; j < taosArrayGetSize(pSub->consumers); j++) { SMqSubConsumer *pSubConsumer = taosArrayGet(pSub->consumers, j); @@ -479,7 +479,7 @@ static int32_t mndProcessDoRebalanceMsg(SMnodeMsg *pMsg) { else vgThisConsumerAfterRb = vgEachConsumer; - mInfo("mq consumer:%ld, connectted vgroup number change from %d to %d", pSubConsumer->consumerId, + mInfo("mq consumer:%" PRId64 ", connectted vgroup number change from %d to %d", pSubConsumer->consumerId, vgThisConsumerBeforeRb, vgThisConsumerAfterRb); while (taosArrayGetSize(pSubConsumer->vgInfo) > vgThisConsumerAfterRb) { @@ -503,7 +503,7 @@ static int32_t mndProcessDoRebalanceMsg(SMnodeMsg *pMsg) { atomic_store_32(&pRebConsumer->status, MQ_CONSUMER_STATUS__IDLE); } - mInfo("mq consumer:%ld, status change from %d to %d", pRebConsumer->consumerId, status, pRebConsumer->status); + mInfo("mq consumer:%" PRId64 ", status change from %d to %d", pRebConsumer->consumerId, status, pRebConsumer->status); SSdbRaw *pConsumerRaw = mndConsumerActionEncode(pRebConsumer); sdbSetRawStatus(pConsumerRaw, SDB_STATUS_READY); @@ -537,13 +537,13 @@ static int32_t mndProcessDoRebalanceMsg(SMnodeMsg *pMsg) { mndSplitSubscribeKey(pSub->key, topic, cgroup); SMqTopicObj *pTopic = mndAcquireTopic(pMnode, topic); - mInfo("mq set conn: assign vgroup %d of topic %s to consumer %ld", pConsumerEp->vgId, topic, + mInfo("mq set conn: assign vgroup %d of topic %s to consumer %" PRId64 "", pConsumerEp->vgId, topic, pConsumerEp->consumerId); mndPersistMqSetConnReq(pMnode, pTrans, pTopic, cgroup, pConsumerEp); mndReleaseTopic(pMnode, pTopic); } else { - mInfo("mq rebalance: assign vgroup %d, from consumer %ld to consumer %ld", pConsumerEp->vgId, + mInfo("mq rebalance: assign vgroup %d, from consumer %" PRId64 " to consumer %" PRId64 "", pConsumerEp->vgId, pConsumerEp->oldConsumerId, pConsumerEp->consumerId); mndPersistRebalanceMsg(pMnode, pTrans, pConsumerEp); @@ -1099,7 +1099,7 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) { SMqSubscribeObj *pSub = mndAcquireSubscribe(pMnode, cgroup, newTopicName); bool createSub = false; if (pSub == NULL) { - mDebug("create new subscription by consumer %ld, group: %s, topic %s", consumerId, cgroup, newTopicName); + mDebug("create new subscription by consumer %" PRId64 ", group: %s, topic %s", consumerId, cgroup, newTopicName); pSub = mndCreateSubscription(pMnode, pTopic, cgroup); createSub = true; @@ -1118,7 +1118,7 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) { pConsumerEp->consumerId = consumerId; taosArrayPush(mqSubConsumer.vgInfo, pConsumerEp); if (pConsumerEp->oldConsumerId == -1) { - mInfo("mq set conn: assign vgroup %d of topic %s to consumer %ld", pConsumerEp->vgId, newTopicName, + mInfo("mq set conn: assign vgroup %d of topic %s to consumer %" PRId64 "", pConsumerEp->vgId, newTopicName, pConsumerEp->consumerId); mndPersistMqSetConnReq(pMnode, pTrans, pTopic, cgroup, pConsumerEp); } else { diff --git a/source/dnode/mnode/sdb/src/sdbFile.c b/source/dnode/mnode/sdb/src/sdbFile.c index a3fe4dfb14..2849da5c2e 100644 --- a/source/dnode/mnode/sdb/src/sdbFile.c +++ b/source/dnode/mnode/sdb/src/sdbFile.c @@ -196,7 +196,7 @@ int32_t sdbReadFile(SSdb *pSdb) { } int32_t totalLen = sizeof(SSdbRaw) + pRaw->dataLen + sizeof(int32_t); - if (!taosCheckChecksumWhole((const uint8_t *)pRaw, totalLen) != 0) { + if ((!taosCheckChecksumWhole((const uint8_t *)pRaw, totalLen)) != 0) { code = TSDB_CODE_CHECKSUM_ERROR; mError("failed to read file:%s since %s", file, tstrerror(code)); break; diff --git a/source/libs/executor/src/dataSinkMgt.c b/source/libs/executor/src/dataSinkMgt.c index 343b3a3c95..4e8583eb2a 100644 --- a/source/libs/executor/src/dataSinkMgt.c +++ b/source/libs/executor/src/dataSinkMgt.c @@ -23,6 +23,7 @@ static SDataSinkManager gDataSinkManager = {0}; int32_t dsDataSinkMgtInit(SDataSinkMgtCfg *cfg) { gDataSinkManager.cfg = *cfg; pthread_mutex_init(&gDataSinkManager.mutex, NULL); + return 0; // to avoid compiler eror } int32_t dsCreateDataSinker(const SDataSinkNode *pDataSink, DataSinkHandle* pHandle) { diff --git a/source/libs/executor/src/tlinearhash.c b/source/libs/executor/src/tlinearhash.c index 9f3d694c42..28319469cc 100644 --- a/source/libs/executor/src/tlinearhash.c +++ b/source/libs/executor/src/tlinearhash.c @@ -413,7 +413,7 @@ int32_t tHashRemove(SLHashObj* pHashObj, const void *key, size_t keyLen) { void tHashPrint(const SLHashObj* pHashObj, int32_t type) { printf("==================== linear hash ====================\n"); - printf("total bucket:%d, size:%ld, ratio:%.2f\n", pHashObj->numOfBuckets, pHashObj->size, LHASH_CAP_RATIO); + printf("total bucket:%d, size:%" PRId64 ", ratio:%.2f\n", pHashObj->numOfBuckets, pHashObj->size, LHASH_CAP_RATIO); dBufSetPrintInfo(pHashObj->pBuf); @@ -425,4 +425,4 @@ void tHashPrint(const SLHashObj* pHashObj, int32_t type) { } else { dBufPrintStatis(pHashObj->pBuf); } -} \ No newline at end of file +} diff --git a/source/libs/sync/src/syncAppendEntriesReply.c b/source/libs/sync/src/syncAppendEntriesReply.c index 61eb4884e2..a75e85601f 100644 --- a/source/libs/sync/src/syncAppendEntriesReply.c +++ b/source/libs/sync/src/syncAppendEntriesReply.c @@ -39,7 +39,7 @@ int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* p syncAppendEntriesReplyLog2("==syncNodeOnAppendEntriesReplyCb==", pMsg); if (pMsg->term < ths->pRaftStore->currentTerm) { - sTrace("DropStaleResponse, receive term:%lu, current term:%lu", pMsg->term, ths->pRaftStore->currentTerm); + sTrace("DropStaleResponse, receive term:%" PRIu64 ", current term:%" PRIu64 "", pMsg->term, ths->pRaftStore->currentTerm); return ret; } diff --git a/source/libs/sync/src/syncEnv.c b/source/libs/sync/src/syncEnv.c index dd7161800d..4b650ec087 100644 --- a/source/libs/sync/src/syncEnv.c +++ b/source/libs/sync/src/syncEnv.c @@ -55,7 +55,7 @@ static void syncEnvTick(void *param, void *tmrId) { if (atomic_load_64(&pSyncEnv->envTickTimerLogicClockUser) <= atomic_load_64(&pSyncEnv->envTickTimerLogicClock)) { ++(pSyncEnv->envTickTimerCounter); sTrace( - "syncEnvTick do ... envTickTimerLogicClockUser:%lu, envTickTimerLogicClock:%lu, envTickTimerCounter:%lu, " + "syncEnvTick do ... envTickTimerLogicClockUser:%" PRIu64 ", envTickTimerLogicClock:%" PRIu64 ", envTickTimerCounter:%" PRIu64 ", " "envTickTimerMS:%d, tmrId:%p", pSyncEnv->envTickTimerLogicClockUser, pSyncEnv->envTickTimerLogicClock, pSyncEnv->envTickTimerCounter, pSyncEnv->envTickTimerMS, tmrId); @@ -64,7 +64,7 @@ static void syncEnvTick(void *param, void *tmrId) { taosTmrReset(syncEnvTick, pSyncEnv->envTickTimerMS, pSyncEnv, pSyncEnv->pTimerManager, &pSyncEnv->pEnvTickTimer); } else { sTrace( - "syncEnvTick pass ... envTickTimerLogicClockUser:%lu, envTickTimerLogicClock:%lu, envTickTimerCounter:%lu, " + "syncEnvTick pass ... envTickTimerLogicClockUser:%" PRIu64 ", envTickTimerLogicClock:%" PRIu64 ", envTickTimerCounter:%" PRIu64 ", " "envTickTimerMS:%d, tmrId:%p", pSyncEnv->envTickTimerLogicClockUser, pSyncEnv->envTickTimerLogicClock, pSyncEnv->envTickTimerCounter, pSyncEnv->envTickTimerMS, tmrId); @@ -74,7 +74,7 @@ static void syncEnvTick(void *param, void *tmrId) { static SSyncEnv *doSyncEnvStart() { SSyncEnv *pSyncEnv = (SSyncEnv *)malloc(sizeof(SSyncEnv)); assert(pSyncEnv != NULL); - memset(pSyncEnv, 0, sizeof(pSyncEnv)); + memset(pSyncEnv, 0, sizeof(SSyncEnv)); pSyncEnv->envTickTimerCounter = 0; pSyncEnv->envTickTimerMS = ENV_TICK_TIMER_MS; diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index dd2c142104..b919e014a0 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -420,46 +420,46 @@ cJSON* syncNode2Json(const SSyncNode* pSyncNode) { // tla+ log vars cJSON_AddItemToObject(pRoot, "pLogStore", logStore2Json(pSyncNode->pLogStore)); - snprintf(u64buf, sizeof(u64buf), "%ld", pSyncNode->commitIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRId64 "", pSyncNode->commitIndex); cJSON_AddStringToObject(pRoot, "commitIndex", u64buf); // ping timer snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pPingTimer); cJSON_AddStringToObject(pRoot, "pPingTimer", u64buf); cJSON_AddNumberToObject(pRoot, "pingTimerMS", pSyncNode->pingTimerMS); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->pingTimerLogicClock); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->pingTimerLogicClock); cJSON_AddStringToObject(pRoot, "pingTimerLogicClock", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->pingTimerLogicClockUser); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->pingTimerLogicClockUser); cJSON_AddStringToObject(pRoot, "pingTimerLogicClockUser", u64buf); snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpPingTimerCB); cJSON_AddStringToObject(pRoot, "FpPingTimerCB", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->pingTimerCounter); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->pingTimerCounter); cJSON_AddStringToObject(pRoot, "pingTimerCounter", u64buf); // elect timer snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pElectTimer); cJSON_AddStringToObject(pRoot, "pElectTimer", u64buf); cJSON_AddNumberToObject(pRoot, "electTimerMS", pSyncNode->electTimerMS); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->electTimerLogicClock); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->electTimerLogicClock); cJSON_AddStringToObject(pRoot, "electTimerLogicClock", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->electTimerLogicClockUser); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->electTimerLogicClockUser); cJSON_AddStringToObject(pRoot, "electTimerLogicClockUser", u64buf); snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpElectTimerCB); cJSON_AddStringToObject(pRoot, "FpElectTimerCB", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->electTimerCounter); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->electTimerCounter); cJSON_AddStringToObject(pRoot, "electTimerCounter", u64buf); // heartbeat timer snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pHeartbeatTimer); cJSON_AddStringToObject(pRoot, "pHeartbeatTimer", u64buf); cJSON_AddNumberToObject(pRoot, "heartbeatTimerMS", pSyncNode->heartbeatTimerMS); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->heartbeatTimerLogicClock); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->heartbeatTimerLogicClock); cJSON_AddStringToObject(pRoot, "heartbeatTimerLogicClock", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->heartbeatTimerLogicClockUser); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->heartbeatTimerLogicClockUser); cJSON_AddStringToObject(pRoot, "heartbeatTimerLogicClockUser", u64buf); snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpHeartbeatTimerCB); cJSON_AddStringToObject(pRoot, "FpHeartbeatTimerCB", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->heartbeatTimerCounter); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->heartbeatTimerCounter); cJSON_AddStringToObject(pRoot, "heartbeatTimerCounter", u64buf); // callback @@ -634,7 +634,7 @@ static void syncNodeEqPingTimer(void* param, void* tmrId) { taosTmrReset(syncNodeEqPingTimer, pSyncNode->pingTimerMS, pSyncNode, gSyncEnv->pTimerManager, &pSyncNode->pPingTimer); } else { - sTrace("==syncNodeEqPingTimer== pingTimerLogicClock:%lu, pingTimerLogicClockUser:%lu", + sTrace("==syncNodeEqPingTimer== pingTimerLogicClock:%" PRIu64 ", pingTimerLogicClockUser:%" PRIu64 "", pSyncNode->pingTimerLogicClock, pSyncNode->pingTimerLogicClockUser); } } @@ -655,7 +655,7 @@ static void syncNodeEqElectTimer(void* param, void* tmrId) { taosTmrReset(syncNodeEqPingTimer, pSyncNode->pingTimerMS, pSyncNode, gSyncEnv->pTimerManager, &pSyncNode->pPingTimer); } else { - sTrace("==syncNodeEqElectTimer== electTimerLogicClock:%lu, electTimerLogicClockUser:%lu", + sTrace("==syncNodeEqElectTimer== electTimerLogicClock:%" PRIu64 ", electTimerLogicClockUser:%" PRIu64 "", pSyncNode->electTimerLogicClock, pSyncNode->electTimerLogicClockUser); } } @@ -676,7 +676,7 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) { taosTmrReset(syncNodeEqHeartbeatTimer, pSyncNode->heartbeatTimerMS, pSyncNode, gSyncEnv->pTimerManager, &pSyncNode->pHeartbeatTimer); } else { - sTrace("==syncNodeEqHeartbeatTimer== heartbeatTimerLogicClock:%lu, heartbeatTimerLogicClockUser:%lu", + sTrace("==syncNodeEqHeartbeatTimer== heartbeatTimerLogicClock:%" PRIu64 ", heartbeatTimerLogicClockUser:%" PRIu64 "", pSyncNode->heartbeatTimerLogicClock, pSyncNode->heartbeatTimerLogicClockUser); } } @@ -713,4 +713,4 @@ static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg } return ret; -} \ No newline at end of file +} diff --git a/source/libs/sync/src/syncMessage.c b/source/libs/sync/src/syncMessage.c index 509ede274b..e28f780831 100644 --- a/source/libs/sync/src/syncMessage.c +++ b/source/libs/sync/src/syncMessage.c @@ -218,7 +218,7 @@ cJSON* syncTimeout2Json(const SyncTimeout* pMsg) { cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON_AddNumberToObject(pRoot, "timeoutType", pMsg->timeoutType); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->logicClock); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->logicClock); cJSON_AddStringToObject(pRoot, "logicClock", u64buf); cJSON_AddNumberToObject(pRoot, "timerMS", pMsg->timerMS); snprintf(u64buf, sizeof(u64buf), "%p", pMsg->data); @@ -239,7 +239,7 @@ char* syncTimeout2Str(const SyncTimeout* pMsg) { // for debug ---------------------- void syncTimeoutPrint(const SyncTimeout* pMsg) { char* serialized = syncTimeout2Str(pMsg); - printf("syncTimeoutPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncTimeoutPrint | len:%zu | %s \n", strlen(serialized), serialized); fflush(NULL); free(serialized); } @@ -349,7 +349,7 @@ cJSON* syncPing2Json(const SyncPing* pMsg) { cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->srcId.addr); cJSON_AddStringToObject(pSrcId, "addr", u64buf); { uint64_t u64 = pMsg->srcId.addr; @@ -364,7 +364,7 @@ cJSON* syncPing2Json(const SyncPing* pMsg) { cJSON_AddItemToObject(pRoot, "srcId", pSrcId); cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->destId.addr); cJSON_AddStringToObject(pDestId, "addr", u64buf); { uint64_t u64 = pMsg->destId.addr; @@ -512,7 +512,7 @@ cJSON* syncPingReply2Json(const SyncPingReply* pMsg) { cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->srcId.addr); cJSON_AddStringToObject(pSrcId, "addr", u64buf); { uint64_t u64 = pMsg->srcId.addr; @@ -527,7 +527,7 @@ cJSON* syncPingReply2Json(const SyncPingReply* pMsg) { cJSON_AddItemToObject(pRoot, "srcId", pSrcId); cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->destId.addr); cJSON_AddStringToObject(pDestId, "addr", u64buf); { uint64_t u64 = pMsg->destId.addr; @@ -565,27 +565,27 @@ char* syncPingReply2Str(const SyncPingReply* pMsg) { // for debug ---------------------- void syncPingReplyPrint(const SyncPingReply* pMsg) { char* serialized = syncPingReply2Str(pMsg); - printf("syncPingReplyPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncPingReplyPrint | len:%zu | %s \n", strlen(serialized), serialized); fflush(NULL); free(serialized); } void syncPingReplyPrint2(char* s, const SyncPingReply* pMsg) { char* serialized = syncPingReply2Str(pMsg); - printf("syncPingReplyPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncPingReplyPrint2 | len:%zu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); free(serialized); } void syncPingReplyLog(const SyncPingReply* pMsg) { char* serialized = syncPingReply2Str(pMsg); - sTrace("syncPingReplyLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("syncPingReplyLog | len:%zu | %s", strlen(serialized), serialized); free(serialized); } void syncPingReplyLog2(char* s, const SyncPingReply* pMsg) { char* serialized = syncPingReply2Str(pMsg); - sTrace("syncPingReplyLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("syncPingReplyLog2 | len:%zu | %s | %s", strlen(serialized), s, serialized); free(serialized); } @@ -670,7 +670,7 @@ cJSON* syncClientRequest2Json(const SyncClientRequest* pMsg) { cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON_AddNumberToObject(pRoot, "originalRpcType", pMsg->originalRpcType); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->seqNum); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->seqNum); cJSON_AddStringToObject(pRoot, "seqNum", u64buf); cJSON_AddNumberToObject(pRoot, "isWeak", pMsg->isWeak); cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); @@ -792,7 +792,7 @@ cJSON* syncRequestVote2Json(const SyncRequestVote* pMsg) { cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->srcId.addr); cJSON_AddStringToObject(pSrcId, "addr", u64buf); { uint64_t u64 = pMsg->srcId.addr; @@ -820,11 +820,11 @@ cJSON* syncRequestVote2Json(const SyncRequestVote* pMsg) { cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); cJSON_AddItemToObject(pRoot, "destId", pDestId); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->term); cJSON_AddStringToObject(pRoot, "term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->lastLogIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->lastLogIndex); cJSON_AddStringToObject(pRoot, "lastLogIndex", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->lastLogTerm); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->lastLogTerm); cJSON_AddStringToObject(pRoot, "lastLogTerm", u64buf); cJSON* pJson = cJSON_CreateObject(); @@ -936,7 +936,7 @@ cJSON* syncRequestVoteReply2Json(const SyncRequestVoteReply* pMsg) { cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->srcId.addr); cJSON_AddStringToObject(pSrcId, "addr", u64buf); { uint64_t u64 = pMsg->srcId.addr; @@ -964,7 +964,7 @@ cJSON* syncRequestVoteReply2Json(const SyncRequestVoteReply* pMsg) { cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); cJSON_AddItemToObject(pRoot, "destId", pDestId); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->term); cJSON_AddStringToObject(pRoot, "term", u64buf); cJSON_AddNumberToObject(pRoot, "vote_granted", pMsg->voteGranted); @@ -1079,7 +1079,7 @@ cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) { cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->srcId.addr); cJSON_AddStringToObject(pSrcId, "addr", u64buf); { uint64_t u64 = pMsg->srcId.addr; @@ -1094,7 +1094,7 @@ cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) { cJSON_AddItemToObject(pRoot, "srcId", pSrcId); cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->destId.addr); cJSON_AddStringToObject(pDestId, "addr", u64buf); { uint64_t u64 = pMsg->destId.addr; @@ -1108,16 +1108,16 @@ cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) { cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); cJSON_AddItemToObject(pRoot, "destId", pDestId); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->term); cJSON_AddStringToObject(pRoot, "term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->prevLogIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->prevLogIndex); cJSON_AddStringToObject(pRoot, "pre_log_index", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->prevLogTerm); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->prevLogTerm); cJSON_AddStringToObject(pRoot, "pre_log_term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->commitIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->commitIndex); cJSON_AddStringToObject(pRoot, "commit_index", u64buf); cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); @@ -1238,7 +1238,7 @@ cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) { cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->srcId.addr); cJSON_AddStringToObject(pSrcId, "addr", u64buf); { uint64_t u64 = pMsg->srcId.addr; @@ -1253,7 +1253,7 @@ cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) { cJSON_AddItemToObject(pRoot, "srcId", pSrcId); cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->destId.addr); cJSON_AddStringToObject(pDestId, "addr", u64buf); { uint64_t u64 = pMsg->destId.addr; @@ -1267,10 +1267,10 @@ cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) { cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); cJSON_AddItemToObject(pRoot, "destId", pDestId); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->term); cJSON_AddStringToObject(pRoot, "term", u64buf); cJSON_AddNumberToObject(pRoot, "success", pMsg->success); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->matchIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->matchIndex); cJSON_AddStringToObject(pRoot, "matchIndex", u64buf); cJSON* pJson = cJSON_CreateObject(); diff --git a/source/libs/sync/src/syncRaftLog.c b/source/libs/sync/src/syncRaftLog.c index 6ebeba1991..3ae2fc4721 100644 --- a/source/libs/sync/src/syncRaftLog.c +++ b/source/libs/sync/src/syncRaftLog.c @@ -34,6 +34,7 @@ SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode) { pLogStore->getLastTerm = logStoreLastTerm; pLogStore->updateCommitIndex = logStoreUpdateCommitIndex; pLogStore->getCommitIndex = logStoreGetCommitIndex; + return pLogStore; // to avoid compiler error } void logStoreDestory(SSyncLogStore* pLogStore) { @@ -58,6 +59,7 @@ int32_t logStoreAppendEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry) { walFsync(pWal, true); free(serialized); + return code; // to avoid compiler error } SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) { @@ -79,6 +81,7 @@ int32_t logStoreTruncate(SSyncLogStore* pLogStore, SyncIndex fromIndex) { SSyncLogStoreData* pData = pLogStore->data; SWal* pWal = pData->pWal; walRollback(pWal, fromIndex); + return 0; // to avoid compiler error } SyncIndex logStoreLastIndex(SSyncLogStore* pLogStore) { @@ -102,6 +105,7 @@ int32_t logStoreUpdateCommitIndex(SSyncLogStore* pLogStore, SyncIndex index) { SSyncLogStoreData* pData = pLogStore->data; SWal* pWal = pData->pWal; walCommit(pWal, index); + return 0; // to avoid compiler error } SyncIndex logStoreGetCommitIndex(SSyncLogStore* pLogStore) { @@ -130,9 +134,9 @@ cJSON* logStore2Json(SSyncLogStore* pLogStore) { cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); snprintf(u64buf, sizeof(u64buf), "%p", pData->pWal); cJSON_AddStringToObject(pRoot, "pWal", u64buf); - snprintf(u64buf, sizeof(u64buf), "%ld", logStoreLastIndex(pLogStore)); + snprintf(u64buf, sizeof(u64buf), "%" PRId64 "", logStoreLastIndex(pLogStore)); cJSON_AddStringToObject(pRoot, "LastIndex", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", logStoreLastTerm(pLogStore)); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", logStoreLastTerm(pLogStore)); cJSON_AddStringToObject(pRoot, "LastTerm", u64buf); cJSON* pEntries = cJSON_CreateArray(); @@ -181,4 +185,4 @@ void logStoreLog2(char* s, SSyncLogStore* pLogStore) { char* serialized = logStore2Str(pLogStore); sTrace("logStorePrint | len:%lu | %s | %s", strlen(serialized), s, serialized); free(serialized); -} \ No newline at end of file +} diff --git a/source/libs/sync/src/syncRequestVoteReply.c b/source/libs/sync/src/syncRequestVoteReply.c index 7cdeace166..60a2c008fe 100644 --- a/source/libs/sync/src/syncRequestVoteReply.c +++ b/source/libs/sync/src/syncRequestVoteReply.c @@ -41,7 +41,7 @@ int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg) syncRequestVoteReplyLog2("==syncNodeOnRequestVoteReplyCb==", pMsg); if (pMsg->term < ths->pRaftStore->currentTerm) { - sTrace("DropStaleResponse, receive term:%lu, current term:%lu", pMsg->term, ths->pRaftStore->currentTerm); + sTrace("DropStaleResponse, receive term:%" PRIu64 ", current term:%" PRIu64 "", pMsg->term, ths->pRaftStore->currentTerm); return ret; } diff --git a/source/libs/sync/src/syncUtil.c b/source/libs/sync/src/syncUtil.c index ba8a76c190..90889a7af0 100644 --- a/source/libs/sync/src/syncUtil.c +++ b/source/libs/sync/src/syncUtil.c @@ -119,7 +119,7 @@ cJSON* syncUtilRaftId2Json(const SRaftId* p) { char u64buf[128]; cJSON* pRoot = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", p->addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", p->addr); cJSON_AddStringToObject(pRoot, "addr", u64buf); char host[128]; uint16_t port; @@ -196,4 +196,4 @@ SyncIndex syncUtilMinIndex(SyncIndex a, SyncIndex b) { SyncIndex syncUtilMaxIndex(SyncIndex a, SyncIndex b) { SyncIndex r = a > b ? a : b; return r; -} \ No newline at end of file +} From f43efb9fea446835bdd5613fa9cc2f5a867d583a Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 16 Mar 2022 13:30:03 +0800 Subject: [PATCH 28/38] handle except and update UT --- include/libs/transport/trpc.h | 2 +- source/libs/transport/inc/transportInt.h | 2 +- source/libs/transport/src/transSrv.c | 24 +++++++++--- source/libs/transport/test/transUT.cc | 47 ++++++++++++++++++------ 4 files changed, 55 insertions(+), 20 deletions(-) diff --git a/include/libs/transport/trpc.h b/include/libs/transport/trpc.h index b5b8d6ab66..5795cdd919 100644 --- a/include/libs/transport/trpc.h +++ b/include/libs/transport/trpc.h @@ -73,7 +73,7 @@ typedef struct SRpcInit { void *(*mfp)(void *parent, tmsg_t msgType); // call back to handle except when query/fetch in progress - void (*efp)(void *parent, tmsg_t msgType); + bool (*efp)(void *parent, tmsg_t msgType); void *parent; } SRpcInit; diff --git a/source/libs/transport/inc/transportInt.h b/source/libs/transport/inc/transportInt.h index e760fe1de9..e739380467 100644 --- a/source/libs/transport/inc/transportInt.h +++ b/source/libs/transport/inc/transportInt.h @@ -65,7 +65,7 @@ typedef struct { int (*afp)(void* parent, char* user, char* spi, char* encrypt, char* secret, char* ckey); bool (*pfp)(void* parent, tmsg_t msgType); void* (*mfp)(void* parent, tmsg_t msgType); - void (*efp)(void* parent, tmsg_t msgType); + bool (*efp)(void* parent, tmsg_t msgType); int32_t refCount; void* parent; diff --git a/source/libs/transport/src/transSrv.c b/source/libs/transport/src/transSrv.c index 960e064b8f..59bc85e91d 100644 --- a/source/libs/transport/src/transSrv.c +++ b/source/libs/transport/src/transSrv.c @@ -106,6 +106,8 @@ static void uvStartSendRespInternal(SSrvMsg* smsg); static void uvPrepareSendData(SSrvMsg* msg, uv_buf_t* wb); static void uvStartSendResp(SSrvMsg* msg); +static void uvNotifyLinkBrokenToApp(SSrvConn* conn); + static void destroySmsg(SSrvMsg* smsg); // check whether already read complete packet static SSrvConn* createConn(void* hThrd); @@ -233,7 +235,7 @@ static void uvHandleReq(SSrvConn* pConn) { ntohs(pConn->locaddr.sin_port), transMsg.contLen); STrans* pTransInst = (STrans*)p->shandle; - (*((STrans*)p->shandle)->cfp)(pTransInst->parent, &transMsg, NULL); + (*pTransInst->cfp)(pTransInst->parent, &transMsg, NULL); // uv_timer_start(&pConn->pTimer, uvHandleActivityTimeout, pRpc->idleTime * 10000, 0); // auth // validate msg type @@ -261,13 +263,12 @@ void uvOnRecvCb(uv_stream_t* cli, ssize_t nread, const uv_buf_t* buf) { tError("server conn %p read error: %s", conn, uv_err_name(nread)); if (nread < 0) { conn->broken = true; - transUnrefSrvHandle(conn); + uvNotifyLinkBrokenToApp(conn); - // if (conn->ref > 1) { - // conn->ref++; // ref > 1 signed that write is in progress + // STrans* pTransInst = conn->pTransInst; + // if (pTransInst->efp != NULL && (pTransInst->efp)(NULL, conn->inType)) { //} - // tError("server conn %p read error: %s", conn, uv_err_name(nread)); - // destroyConn(conn, true); + transUnrefSrvHandle(conn); } } void uvAllocConnBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) { @@ -373,6 +374,17 @@ static void uvStartSendResp(SSrvMsg* smsg) { uvStartSendRespInternal(smsg); return; } + +static void uvNotifyLinkBrokenToApp(SSrvConn* conn) { + STrans* pTransInst = conn->pTransInst; + if (pTransInst->efp != NULL && (*pTransInst->efp)(NULL, conn->inType) && T_REF_VAL_GET(conn) >= 2) { + STransMsg transMsg = {0}; + transMsg.msgType = conn->inType; + transMsg.code = TSDB_CODE_RPC_NETWORK_UNAVAIL; + // transRefSrvHandle(conn); + (*pTransInst->cfp)(pTransInst->parent, &transMsg, 0); + } +} static void destroySmsg(SSrvMsg* smsg) { if (smsg == NULL) { return; diff --git a/source/libs/transport/test/transUT.cc b/source/libs/transport/test/transUT.cc index 46f6424b0b..b3fbade050 100644 --- a/source/libs/transport/test/transUT.cc +++ b/source/libs/transport/test/transUT.cc @@ -15,6 +15,7 @@ #include #include #include +#include "rpcLog.h" #include "tdatablock.h" #include "tglobal.h" #include "tlog.h" @@ -48,7 +49,9 @@ static void *ConstructArgForSpecificMsgType(void *parent, tmsg_t msgType) { return NULL; } // server except -static void NotifyAppLinkBroken(void *parent, tmsg_t msgType) {} +static bool handleExcept(void *parent, tmsg_t msgType) { + return msgType == TDMT_VND_QUERY || msgType == TDMT_VND_FETCH_RSP || msgType == TDMT_VND_RES_READY_RSP; +} typedef void (*CB)(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet); static void processContinueSend(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet); @@ -83,6 +86,10 @@ class Client { rpcInit_.cfp = cb; this->transCli = rpcOpen(&rpcInit_); } + void Stop() { + rpcClose(this->transCli); + this->transCli = NULL; + } void SetPersistFP(bool (*pfp)(void *parent, tmsg_t msgType)) { rpcClose(this->transCli); rpcInit_.pfp = pfp; @@ -157,7 +164,7 @@ class Server { rpcClose(this->transSrv); this->transSrv = NULL; } - void SetExceptFp(void (*efp)(void *parent, tmsg_t msgType)) { + void SetExceptFp(bool (*efp)(void *parent, tmsg_t msgType)) { this->Stop(); rpcInit_.efp = efp; this->Start(); @@ -207,6 +214,7 @@ static void processResp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { Client *client = (Client *)parent; client->SetResp(pMsg); client->SemPost(); + tDebug("received resp"); } static void initEnv() { @@ -266,7 +274,7 @@ class TransObj { cli->SetPAndMFp(pfp, mfp); } // call when link broken, and notify query or fetch stop - void SetSrvExceptFp(void (*efp)(void *parent, tmsg_t msgType)) { + void SetSrvExceptFp(bool (*efp)(void *parent, tmsg_t msgType)) { //////// srv->SetExceptFp(efp); } @@ -275,6 +283,10 @@ class TransObj { srv->SetSrvContinueSend(cfp); } void RestartSrv() { srv->Restart(); } + void cliStop() { + /////// + cli->Stop(); + } void cliSendAndRecv(SRpcMsg *req, SRpcMsg *resp) { cli->SendAndRecv(req, resp); } void cliSendAndRecvNoHandle(SRpcMsg *req, SRpcMsg *resp) { cli->SendAndRecvNoHandle(req, resp); } @@ -417,20 +429,31 @@ TEST_F(TransEnv, srvContinueSend) { } TEST_F(TransEnv, srvPersistHandleExcept) { - // conn breken + tr->SetSrvContinueSend(processContinueSend); + tr->SetCliPersistFp(cliPersistHandle); + SRpcMsg resp = {0}; + for (int i = 0; i < 5; i++) { + SRpcMsg req = {.handle = resp.handle}; + req.msgType = 1; + req.pCont = rpcMallocCont(10); + req.contLen = 10; + tr->cliSendAndRecv(&req, &resp); + if (i > 2) { + tr->cliStop(); + break; + } + } + taosMsleep(2000); + // conn broken // } -TEST_F(TransEnv, cliPersistHandleExcept) { - // conn breken -} -TEST_F(TransEnv, multiCliPersisHandleExcept) { - // conn breken -} -TEST_F(TransEnv, multiSrvPersisHandleExcept) { - // conn breken +TEST_F(TransEnv, multiCliPersistHandleExcept) { + // conn broken } TEST_F(TransEnv, queryExcept) { + tr->SetSrvExceptFp(handleExcept); + // query and conn is broken } TEST_F(TransEnv, noResp) { From 8286d6efcffc13a835f185a607a4b814dd2e7957 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Wed, 16 Mar 2022 14:00:41 +0800 Subject: [PATCH 29/38] migrate TS-1278 from 2.x --- source/common/src/trow.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/common/src/trow.c b/source/common/src/trow.c index 861b4dc093..db4bc49425 100644 --- a/source/common/src/trow.c +++ b/source/common/src/trow.c @@ -353,10 +353,10 @@ static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, i for (int i = 0; i < src2->numOfCols; i++) { SCellVal sVal = {0}; ASSERT(target->cols[i].type == src2->cols[i].type); - if (src2->cols[i].len > 0 && !isNull(src2->cols[i].pData, src2->cols[i].type)) { - if (tdGetColDataOfRow(&sVal, src1->cols + i, *iter1) < 0) { - TASSERT(0); - } + if (tdGetColDataOfRow(&sVal, src2->cols + i, *iter2) < 0) { + TASSERT(0); + } + if (src2->cols[i].len > 0 && !tdValTypeIsNull(sVal.valType)) { tdAppendValToDataCol(&(target->cols[i]), sVal.valType, sVal.val, target->numOfRows, target->maxPoints); } else if (!forceSetNull && key1 == key2 && src1->cols[i].len > 0) { if (tdGetColDataOfRow(&sVal, src1->cols + i, *iter1) < 0) { From f8f7aabfd9ddf41338016a038f80cfac279204ab Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Wed, 16 Mar 2022 02:08:59 -0400 Subject: [PATCH 30/38] TD-13597 create/drop topic, alter database, drop index, drop qnode statement implement --- include/common/tmsg.h | 4 +- include/common/ttokendef.h | 95 +- include/libs/nodes/cmdnodes.h | 31 + include/libs/nodes/nodes.h | 5 + source/client/src/tmq.c | 4 +- source/common/src/tmsg.c | 41 +- source/dnode/mnode/impl/src/mndTopic.c | 27 +- source/dnode/mnode/impl/test/topic/topic.cpp | 3 +- source/libs/nodes/src/nodesCodeFuncs.c | 7 +- source/libs/nodes/src/nodesUtilFuncs.c | 10 + source/libs/parser/inc/parAst.h | 5 + source/libs/parser/inc/sql.y | 32 +- source/libs/parser/src/parAstCreater.c | 49 + source/libs/parser/src/parTokenizer.c | 2 +- source/libs/parser/src/parTranslater.c | 175 +- source/libs/parser/src/sql.c | 3099 +++++++++--------- source/libs/parser/test/parserAstTest.cpp | 57 + 17 files changed, 2024 insertions(+), 1622 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index f0718900c0..dc418147b0 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1157,8 +1157,8 @@ typedef struct { char name[TSDB_TOPIC_FNAME_LEN]; int8_t igExists; char* sql; - char* physicalPlan; - char* logicalPlan; + char* ast; + char subscribeDbName[TSDB_DB_NAME_LEN]; } SCMCreateTopicReq; int32_t tSerializeSCMCreateTopicReq(void* buf, int32_t bufLen, const SCMCreateTopicReq* pReq); diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 5693091bd5..167c72a778 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -108,53 +108,54 @@ #define TK_FULLTEXT 90 #define TK_FUNCTION 91 #define TK_INTERVAL 92 -#define TK_MNODES 93 -#define TK_NK_FLOAT 94 -#define TK_NK_BOOL 95 -#define TK_NK_VARIABLE 96 -#define TK_BETWEEN 97 -#define TK_IS 98 -#define TK_NULL 99 -#define TK_NK_LT 100 -#define TK_NK_GT 101 -#define TK_NK_LE 102 -#define TK_NK_GE 103 -#define TK_NK_NE 104 -#define TK_NK_EQ 105 -#define TK_LIKE 106 -#define TK_MATCH 107 -#define TK_NMATCH 108 -#define TK_IN 109 -#define TK_FROM 110 -#define TK_AS 111 -#define TK_JOIN 112 -#define TK_INNER 113 -#define TK_SELECT 114 -#define TK_DISTINCT 115 -#define TK_WHERE 116 -#define TK_PARTITION 117 -#define TK_BY 118 -#define TK_SESSION 119 -#define TK_STATE_WINDOW 120 -#define TK_SLIDING 121 -#define TK_FILL 122 -#define TK_VALUE 123 -#define TK_NONE 124 -#define TK_PREV 125 -#define TK_LINEAR 126 -#define TK_NEXT 127 -#define TK_GROUP 128 -#define TK_HAVING 129 -#define TK_ORDER 130 -#define TK_SLIMIT 131 -#define TK_SOFFSET 132 -#define TK_LIMIT 133 -#define TK_OFFSET 134 -#define TK_ASC 135 -#define TK_DESC 136 -#define TK_NULLS 137 -#define TK_FIRST 138 -#define TK_LAST 139 +#define TK_TOPIC 93 +#define TK_AS 94 +#define TK_MNODES 95 +#define TK_NK_FLOAT 96 +#define TK_NK_BOOL 97 +#define TK_NK_VARIABLE 98 +#define TK_BETWEEN 99 +#define TK_IS 100 +#define TK_NULL 101 +#define TK_NK_LT 102 +#define TK_NK_GT 103 +#define TK_NK_LE 104 +#define TK_NK_GE 105 +#define TK_NK_NE 106 +#define TK_NK_EQ 107 +#define TK_LIKE 108 +#define TK_MATCH 109 +#define TK_NMATCH 110 +#define TK_IN 111 +#define TK_FROM 112 +#define TK_JOIN 113 +#define TK_INNER 114 +#define TK_SELECT 115 +#define TK_DISTINCT 116 +#define TK_WHERE 117 +#define TK_PARTITION 118 +#define TK_BY 119 +#define TK_SESSION 120 +#define TK_STATE_WINDOW 121 +#define TK_SLIDING 122 +#define TK_FILL 123 +#define TK_VALUE 124 +#define TK_NONE 125 +#define TK_PREV 126 +#define TK_LINEAR 127 +#define TK_NEXT 128 +#define TK_GROUP 129 +#define TK_HAVING 130 +#define TK_ORDER 131 +#define TK_SLIMIT 132 +#define TK_SOFFSET 133 +#define TK_LIMIT 134 +#define TK_OFFSET 135 +#define TK_ASC 136 +#define TK_DESC 137 +#define TK_NULLS 138 +#define TK_FIRST 139 +#define TK_LAST 140 #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 21d9ff83c8..5d7174fc08 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -61,6 +61,12 @@ typedef struct SDropDatabaseStmt { bool ignoreNotExists; } SDropDatabaseStmt; +typedef struct SAlterDatabaseStmt { + ENodeType type; + char dbName[TSDB_DB_NAME_LEN]; + SDatabaseOptions* pOptions; +} SAlterDatabaseStmt; + typedef struct STableOptions { ENodeType type; int32_t keep; @@ -179,11 +185,36 @@ typedef struct SCreateIndexStmt { SIndexOptions* pOptions; } SCreateIndexStmt; +typedef struct SDropIndexStmt { + ENodeType type; + char indexName[TSDB_INDEX_NAME_LEN]; + char tableName[TSDB_TABLE_NAME_LEN]; +} SDropIndexStmt; + typedef struct SCreateQnodeStmt { ENodeType type; int32_t dnodeId; } SCreateQnodeStmt; +typedef struct SDropQnodeStmt { + ENodeType type; + int32_t dnodeId; +} SDropQnodeStmt; + +typedef struct SCreateTopicStmt { + ENodeType type; + char topicName[TSDB_TABLE_NAME_LEN]; + char subscribeDbName[TSDB_DB_NAME_LEN]; + bool ignoreExists; + SNode* pQuery; +} SCreateTopicStmt; + +typedef struct SDropTopicStmt { + ENodeType type; + char topicName[TSDB_TABLE_NAME_LEN]; + bool ignoreNotExists; +} SDropTopicStmt; + #ifdef __cplusplus } #endif diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index cf34c6665a..4ef70fc7ab 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -77,6 +77,7 @@ typedef enum ENodeType { QUERY_NODE_VNODE_MODIF_STMT, QUERY_NODE_CREATE_DATABASE_STMT, QUERY_NODE_DROP_DATABASE_STMT, + QUERY_NODE_ALTER_DATABASE_STMT, QUERY_NODE_SHOW_DATABASES_STMT, // temp QUERY_NODE_CREATE_TABLE_STMT, QUERY_NODE_CREATE_SUBTABLE_CLAUSE, @@ -98,7 +99,11 @@ typedef enum ENodeType { QUERY_NODE_SHOW_MNODES_STMT, QUERY_NODE_SHOW_QNODES_STMT, QUERY_NODE_CREATE_INDEX_STMT, + QUERY_NODE_DROP_INDEX_STMT, QUERY_NODE_CREATE_QNODE_STMT, + QUERY_NODE_DROP_QNODE_STMT, + QUERY_NODE_CREATE_TOPIC_STMT, + QUERY_NODE_DROP_TOPIC_STMT, // logic plan node QUERY_NODE_LOGIC_PLAN_SCAN, diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index b3f71c1075..0ddd53be08 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -482,7 +482,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i } tscDebug("start to create topic, %s", topicName); - +#if 0 CHECK_CODE_GOTO(buildRequest(pTscObj, sql, sqlLen, &pRequest), _return); CHECK_CODE_GOTO(parseSql(pRequest, &pQueryNode), _return); @@ -536,7 +536,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i asyncSendMsgToServer(pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo); tsem_wait(&pRequest->body.rspSem); - +#endif _return: qDestroyQuery(pQueryNode); /*if (sendInfo != NULL) {*/ diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index f26f19f3b2..abd341557f 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -1990,11 +1990,9 @@ int32_t tDeserializeSMDropTopicReq(void *buf, int32_t bufLen, SMDropTopicReq *pR int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTopicReq *pReq) { int32_t sqlLen = 0; - int32_t physicalPlanLen = 0; - int32_t logicalPlanLen = 0; + int32_t astLen = 0; if (pReq->sql != NULL) sqlLen = (int32_t)strlen(pReq->sql); - if (pReq->physicalPlan != NULL) physicalPlanLen = (int32_t)strlen(pReq->physicalPlan); - if (pReq->logicalPlan != NULL) logicalPlanLen = (int32_t)strlen(pReq->logicalPlan); + if (pReq->ast != NULL) astLen = (int32_t)strlen(pReq->ast); SCoder encoder = {0}; tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); @@ -2003,11 +2001,9 @@ int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTo if (tEncodeCStr(&encoder, pReq->name) < 0) return -1; if (tEncodeI8(&encoder, pReq->igExists) < 0) return -1; if (tEncodeI32(&encoder, sqlLen) < 0) return -1; - if (tEncodeI32(&encoder, physicalPlanLen) < 0) return -1; - if (tEncodeI32(&encoder, logicalPlanLen) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->sql) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->physicalPlan) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->logicalPlan) < 0) return -1; + if (tEncodeI32(&encoder, astLen) < 0) return -1; + if (sqlLen > 0 && tEncodeCStr(&encoder, pReq->sql) < 0) return -1; + if (astLen > 0 && tEncodeCStr(&encoder, pReq->ast) < 0) return -1; tEndEncode(&encoder); @@ -2018,8 +2014,7 @@ int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTo int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicReq *pReq) { int32_t sqlLen = 0; - int32_t physicalPlanLen = 0; - int32_t logicalPlanLen = 0; + int32_t astLen = 0; SCoder decoder = {0}; tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER); @@ -2028,17 +2023,20 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1; if (tDecodeI8(&decoder, &pReq->igExists) < 0) return -1; if (tDecodeI32(&decoder, &sqlLen) < 0) return -1; - if (tDecodeI32(&decoder, &physicalPlanLen) < 0) return -1; - if (tDecodeI32(&decoder, &logicalPlanLen) < 0) return -1; + if (tDecodeI32(&decoder, &astLen) < 0) return -1; - pReq->sql = calloc(1, sqlLen + 1); - pReq->physicalPlan = calloc(1, physicalPlanLen + 1); - pReq->logicalPlan = calloc(1, logicalPlanLen + 1); - if (pReq->sql == NULL || pReq->physicalPlan == NULL || pReq->logicalPlan == NULL) return -1; + if (sqlLen > 0) { + pReq->sql = calloc(1, sqlLen + 1); + if (pReq->sql == NULL) return -1; + if (tDecodeCStrTo(&decoder, pReq->sql) < 0) return -1; + } + + if (astLen > 0) { + pReq->ast = calloc(1, astLen + 1); + if (pReq->ast == NULL) return -1; + if (tDecodeCStrTo(&decoder, pReq->ast) < 0) return -1; + } - if (tDecodeCStrTo(&decoder, pReq->sql) < 0) return -1; - if (tDecodeCStrTo(&decoder, pReq->physicalPlan) < 0) return -1; - if (tDecodeCStrTo(&decoder, pReq->logicalPlan) < 0) return -1; tEndDecode(&decoder); tCoderClear(&decoder); @@ -2047,8 +2045,7 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR void tFreeSCMCreateTopicReq(SCMCreateTopicReq *pReq) { tfree(pReq->sql); - tfree(pReq->physicalPlan); - tfree(pReq->logicalPlan); + tfree(pReq->ast); } int32_t tSerializeSCMCreateTopicRsp(void *buf, int32_t bufLen, const SCMCreateTopicRsp *pRsp) { diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index 7d7c5f9975..32fa3df910 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -236,6 +236,25 @@ static int32_t mndCheckCreateTopicReq(SCMCreateTopicReq *pCreate) { return 0; } +static int32_t mndGetPlanString(SCMCreateTopicReq *pCreate, char **pStr) { + SNode* pAst = NULL; + int32_t code = nodesStringToNode(pCreate->ast, &pAst); + + SQueryPlan* pPlan = NULL; + if (TSDB_CODE_SUCCESS == code) { + SPlanContext cxt = { .pAstRoot = pAst, .streamQuery = true }; + code = qCreateQueryPlan(&cxt, &pPlan, NULL); + } + + if (TSDB_CODE_SUCCESS == code) { + code = nodesNodeToString(pPlan, false, pStr, NULL); + } + nodesDestroyNode(pAst); + nodesDestroyNode(pPlan); + terrno = code; + return code; +} + static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateTopicReq *pCreate, SDbObj *pDb) { mDebug("topic:%s to create", pCreate->name); SMqTopicObj topicObj = {0}; @@ -247,10 +266,14 @@ static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateTopicReq topicObj.dbUid = pDb->uid; topicObj.version = 1; topicObj.sql = pCreate->sql; - topicObj.physicalPlan = pCreate->physicalPlan; - topicObj.logicalPlan = pCreate->logicalPlan; + topicObj.logicalPlan = NULL; topicObj.sqlLen = strlen(pCreate->sql); + if (TSDB_CODE_SUCCESS != mndGetPlanString(pCreate, &topicObj.physicalPlan)) { + mError("topic:%s, failed to get plan since %s", pCreate->name, terrstr()); + return -1; + } + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_TYPE_CREATE_TOPIC, &pReq->rpcMsg); if (pTrans == NULL) { mError("topic:%s, failed to create since %s", pCreate->name, terrstr()); diff --git a/source/dnode/mnode/impl/test/topic/topic.cpp b/source/dnode/mnode/impl/test/topic/topic.cpp index f58d0a6771..79f353a4d6 100644 --- a/source/dnode/mnode/impl/test/topic/topic.cpp +++ b/source/dnode/mnode/impl/test/topic/topic.cpp @@ -65,8 +65,7 @@ void* MndTestTopic::BuildCreateTopicReq(const char* topicName, const char* sql, strcpy(createReq.name, topicName); createReq.igExists = 0; createReq.sql = (char*)sql; - createReq.physicalPlan = (char*)"physicalPlan"; - createReq.logicalPlan = (char*)"logicalPlan"; + createReq.ast = (char*)"ast"; int32_t contLen = tSerializeSCMCreateTopicReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 457f863a5e..a2fd32d238 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -1730,7 +1730,7 @@ static int32_t jsonToNodeObject(const SJson* pJson, const char* pName, SNode** p } int32_t nodesNodeToString(const SNodeptr pNode, bool format, char** pStr, int32_t* pLen) { - if (NULL == pNode || NULL == pStr || NULL == pLen) { + if (NULL == pNode || NULL == pStr) { terrno = TSDB_CODE_FAILED; return TSDB_CODE_FAILED; } @@ -1750,7 +1750,10 @@ int32_t nodesNodeToString(const SNodeptr pNode, bool format, char** pStr, int32_ *pStr = format ? tjsonToString(pJson) : tjsonToUnformattedString(pJson); tjsonDelete(pJson); - *pLen = strlen(*pStr) + 1; + if (NULL != pLen) { + *pLen = strlen(*pStr) + 1; + } + return TSDB_CODE_SUCCESS; } diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index b17a4904da..75568019cb 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -92,6 +92,8 @@ SNodeptr nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SCreateDatabaseStmt)); case QUERY_NODE_DROP_DATABASE_STMT: return makeNode(type, sizeof(SDropDatabaseStmt)); + case QUERY_NODE_ALTER_DATABASE_STMT: + return makeNode(type, sizeof(SAlterDatabaseStmt)); case QUERY_NODE_SHOW_DATABASES_STMT: return makeNode(type, sizeof(SShowStmt)); case QUERY_NODE_CREATE_TABLE_STMT: @@ -131,8 +133,16 @@ SNodeptr nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SShowStmt)); case QUERY_NODE_CREATE_INDEX_STMT: return makeNode(type, sizeof(SCreateIndexStmt)); + case QUERY_NODE_DROP_INDEX_STMT: + return makeNode(type, sizeof(SDropIndexStmt)); case QUERY_NODE_CREATE_QNODE_STMT: return makeNode(type, sizeof(SCreateQnodeStmt)); + case QUERY_NODE_DROP_QNODE_STMT: + return makeNode(type, sizeof(SDropQnodeStmt)); + case QUERY_NODE_CREATE_TOPIC_STMT: + return makeNode(type, sizeof(SCreateTopicStmt)); + case QUERY_NODE_DROP_TOPIC_STMT: + return makeNode(type, sizeof(SDropTopicStmt)); case QUERY_NODE_LOGIC_PLAN_SCAN: return makeNode(type, sizeof(SScanLogicNode)); case QUERY_NODE_LOGIC_PLAN_JOIN: diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index f2fcced1a9..31d7331d0e 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -113,6 +113,7 @@ SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt); SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, const SToken* pVal); SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pDbName, SNode* pOptions); SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pDbName); +SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName, SNode* pOptions); SNode* createDefaultTableOptions(SAstCreateContext* pCxt); SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, const SToken* pVal); SNode* setTableSmaOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pSma); @@ -134,7 +135,11 @@ SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode); SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, const SToken* pIndexName, const SToken* pTableName, SNodeList* pCols, SNode* pOptions); SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding); +SNode* createDropIndexStmt(SAstCreateContext* pCxt, const SToken* pIndexName, const SToken* pTableName); SNode* createCreateQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId); +SNode* createDropQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId); +SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pQuery, const SToken* pSubscribeDbName); +SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName); #ifdef __cplusplus } diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index af2fb12c52..31c26e1e40 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -42,17 +42,17 @@ //%right NK_BITNOT. /************************************************ create/alter/drop/show user *****************************************/ -cmd ::= CREATE USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createCreateUserStmt(pCxt, &A, &B);} -cmd ::= ALTER USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PASSWD, &B);} -cmd ::= ALTER USER user_name(A) PRIVILEGE NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PRIVILEGES, &B);} +cmd ::= CREATE USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createCreateUserStmt(pCxt, &A, &B); } +cmd ::= ALTER USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PASSWD, &B); } +cmd ::= ALTER USER user_name(A) PRIVILEGE NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PRIVILEGES, &B); } cmd ::= DROP USER user_name(A). { pCxt->pRootNode = createDropUserStmt(pCxt, &A); } cmd ::= SHOW USERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL); } /************************************************ create/drop/show dnode **********************************************/ -cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL);} -cmd ::= CREATE DNODE dnode_host_name(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B);} -cmd ::= DROP DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A);} -cmd ::= DROP DNODE dnode_endpoint(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A);} +cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); } +cmd ::= CREATE DNODE dnode_host_name(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B); } +cmd ::= DROP DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A); } +cmd ::= DROP DNODE dnode_endpoint(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A); } cmd ::= SHOW DNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL); } %type dnode_endpoint { SToken } @@ -64,15 +64,17 @@ dnode_endpoint(A) ::= NK_STRING(B). dnode_host_name(A) ::= NK_ID(B). { A = B; } dnode_host_name(A) ::= NK_IPTOKEN(B). { A = B; } -/************************************************ create qnode ********************************************************/ +/************************************************ create/drop qnode ***************************************************/ cmd ::= CREATE QNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createCreateQnodeStmt(pCxt, &A); } +cmd ::= DROP QNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropQnodeStmt(pCxt, &A); } cmd ::= SHOW QNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT, NULL); } /************************************************ create/drop/show/use database ***************************************/ -cmd ::= CREATE DATABASE not_exists_opt(A) db_name(B) db_options(C). { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, A, &B, C);} +cmd ::= CREATE DATABASE not_exists_opt(A) db_name(B) db_options(C). { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, A, &B, C); } cmd ::= DROP DATABASE exists_opt(A) db_name(B). { pCxt->pRootNode = createDropDatabaseStmt(pCxt, A, &B); } cmd ::= SHOW DATABASES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL); } -cmd ::= USE db_name(A). { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &A);} +cmd ::= USE db_name(A). { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &A); } +cmd ::= ALTER DATABASE db_name(A) db_options(B). { pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &A, B); } %type not_exists_opt { bool } %destructor not_exists_opt { } @@ -198,6 +200,7 @@ col_name(A) ::= column_name(B). cmd ::= CREATE SMA INDEX index_name(A) ON table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &A, &B, NULL, C); } cmd ::= CREATE FULLTEXT INDEX index_name(A) ON table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &A, &B, C, NULL); } +cmd ::= DROP INDEX index_name(A) ON table_name(B). { pCxt->pRootNode = createDropIndexStmt(pCxt, &A, &B); } index_options(A) ::= . { A = NULL; } index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL @@ -212,6 +215,11 @@ func_list(A) ::= func_list(B) NK_COMMA func(C). func(A) ::= function_name(B) NK_LP expression_list(C) NK_RP. { A = createFunctionNode(pCxt, &B, C); } +/************************************************ create/drop topic ***************************************************/ +cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS query_expression(C). { pCxt->pRootNode = createCreateTopicStmt(pCxt, A, &B, C, NULL); } +cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS db_name(C). { pCxt->pRootNode = createCreateTopicStmt(pCxt, A, &B, NULL, &C); } +cmd ::= DROP TOPIC exists_opt(A) topic_name(B). { pCxt->pRootNode = createDropTopicStmt(pCxt, A, &B); } + /************************************************ show vgroups ********************************************************/ cmd ::= SHOW VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, NULL); } cmd ::= SHOW db_name(B) NK_DOT VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &B); } @@ -270,6 +278,10 @@ user_name(A) ::= NK_ID(B). %destructor index_name { } index_name(A) ::= NK_ID(B). { A = B; } +%type topic_name { SToken } +%destructor topic_name { } +topic_name(A) ::= NK_ID(B). { A = B; } + /************************************************ expression **********************************************************/ expression(A) ::= literal(B). { A = B; } //expression(A) ::= NK_QUESTION(B). { A = B; } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index b7ecf160fd..034346362c 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -799,6 +799,17 @@ SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, con return (SNode*)pStmt; } +SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName, SNode* pOptions) { + if (!checkDbName(pCxt, pDbName)) { + return NULL; + } + SAlterDatabaseStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_DATABASE_STMT); + CHECK_OUT_OF_MEM(pStmt); + strncpy(pStmt->dbName, pDbName->z, pDbName->n); + pStmt->pOptions = (SDatabaseOptions*)pOptions; + return (SNode*)pStmt; +} + SNode* createDefaultTableOptions(SAstCreateContext* pCxt) { STableOptions* pOptions = nodesMakeNode(QUERY_NODE_TABLE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); @@ -1022,9 +1033,47 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt return (SNode*)pOptions; } +SNode* createDropIndexStmt(SAstCreateContext* pCxt, const SToken* pIndexName, const SToken* pTableName) { + if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName)) { + return NULL; + } + SDropIndexStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_INDEX_STMT); + CHECK_OUT_OF_MEM(pStmt); + strncpy(pStmt->indexName, pIndexName->z, pIndexName->n); + strncpy(pStmt->tableName, pTableName->z, pTableName->n); + return (SNode*)pStmt; +} + SNode* createCreateQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId) { SCreateQnodeStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_QNODE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->dnodeId = strtol(pDnodeId->z, NULL, 10);; return (SNode*)pStmt; } + +SNode* createDropQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId) { + SDropQnodeStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_QNODE_STMT); + CHECK_OUT_OF_MEM(pStmt); + pStmt->dnodeId = strtol(pDnodeId->z, NULL, 10);; + return (SNode*)pStmt; +} + +SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pQuery, const SToken* pSubscribeDbName) { + SCreateTopicStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT); + CHECK_OUT_OF_MEM(pStmt); + strncpy(pStmt->topicName, pTopicName->z, pTopicName->n); + pStmt->ignoreExists = ignoreExists; + pStmt->pQuery = pQuery; + if (NULL != pSubscribeDbName) { + strncpy(pStmt->subscribeDbName, pSubscribeDbName->z, pSubscribeDbName->n); + } + return (SNode*)pStmt; +} + +SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName) { + SDropTopicStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_TOPIC_STMT); + CHECK_OUT_OF_MEM(pStmt); + strncpy(pStmt->topicName, pTopicName->z, pTopicName->n); + pStmt->ignoreNotExists = ignoreNotExists; + return (SNode*)pStmt; +} diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 4d50d92d9e..2d58d4e1e3 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -121,6 +121,7 @@ static SKeyword keywordTable[] = { {"TAGS", TK_TAGS}, {"TIMESTAMP", TK_TIMESTAMP}, {"TINYINT", TK_TINYINT}, + {"TOPIC", TK_TOPIC}, {"TTL", TK_TTL}, {"UNION", TK_UNION}, {"UNSIGNED", TK_UNSIGNED}, @@ -230,7 +231,6 @@ static SKeyword keywordTable[] = { // {"TBNAME", TK_TBNAME}, // {"VNODES", TK_VNODES}, // {"PARTITIONS", TK_PARTITIONS}, - // {"TOPIC", TK_TOPIC}, // {"TOPICS", TK_TOPICS}, // {"COMPACT", TK_COMPACT}, // {"MODIFY", TK_MODIFY}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 4f89e7e703..af7a38b702 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -21,14 +21,6 @@ #include "parUtil.h" #include "ttime.h" -static bool afterGroupBy(ESqlClause clause) { - return clause > SQL_CLAUSE_GROUP_BY; -} - -static bool beforeHaving(ESqlClause clause) { - return clause < SQL_CLAUSE_HAVING; -} - typedef struct STranslateContext { SParseContext* pParseCxt; int32_t errCode; @@ -41,6 +33,15 @@ typedef struct STranslateContext { } STranslateContext; static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode); +static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode); + +static bool afterGroupBy(ESqlClause clause) { + return clause > SQL_CLAUSE_GROUP_BY; +} + +static bool beforeHaving(ESqlClause clause) { + return clause < SQL_CLAUSE_HAVING; +} static EDealRes generateDealNodeErrMsg(STranslateContext* pCxt, int32_t errCode, ...) { va_list vArgList; @@ -833,6 +834,41 @@ static int32_t translateDropDatabase(STranslateContext* pCxt, SDropDatabaseStmt* return TSDB_CODE_SUCCESS; } +static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt, SAlterDbReq* pReq) { + SName name = {0}; + tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); + tNameGetFullDbName(&name, pReq->db); + pReq->totalBlocks = pStmt->pOptions->numOfBlocks; + pReq->daysToKeep0 = pStmt->pOptions->keep; + pReq->daysToKeep1 = -1; + pReq->daysToKeep2 = -1; + pReq->fsyncPeriod = pStmt->pOptions->fsyncPeriod; + pReq->walLevel = pStmt->pOptions->walLevel; + pReq->quorum = pStmt->pOptions->quorum; + pReq->cacheLastRow = pStmt->pOptions->cachelast; + return; +} + +static int32_t translateAlterDatabase(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt) { + SAlterDbReq alterReq = {0}; + buildAlterDbReq(pCxt, pStmt, &alterReq); + + pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); + if (NULL == pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_MND_ALTER_DB; + pCxt->pCmdMsg->msgLen = tSerializeSAlterDbReq(NULL, 0, &alterReq); + pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); + if (NULL == pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + tSerializeSAlterDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &alterReq); + + return TSDB_CODE_SUCCESS; +} + static int32_t columnNodeToField(SNodeList* pList, SArray** pArray) { *pArray = taosArrayInit(LIST_LENGTH(pList), sizeof(SField)); SNode* pNode; @@ -1201,6 +1237,27 @@ static int32_t translateCreateIndex(STranslateContext* pCxt, SCreateIndexStmt* p } } +static int32_t translateDropIndex(STranslateContext* pCxt, SDropIndexStmt* pStmt) { + SVDropTSmaReq dropSmaReq = {0}; + strcpy(dropSmaReq.indexName, pStmt->indexName); + + pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); + if (NULL == pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_VND_DROP_SMA; + pCxt->pCmdMsg->msgLen = tSerializeSVDropTSmaReq(NULL, &dropSmaReq); + pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); + if (NULL == pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + void* pBuf = pCxt->pCmdMsg->pMsg; + tSerializeSVDropTSmaReq(&pBuf, &dropSmaReq); + + return TSDB_CODE_SUCCESS; +} + static int32_t translateCreateQnode(STranslateContext* pCxt, SCreateQnodeStmt* pStmt) { SMCreateQnodeReq createReq = { .dnodeId = pStmt->dnodeId }; @@ -1220,6 +1277,93 @@ static int32_t translateCreateQnode(STranslateContext* pCxt, SCreateQnodeStmt* p return TSDB_CODE_SUCCESS; } +static int32_t translateDropQnode(STranslateContext* pCxt, SDropQnodeStmt* pStmt) { + SDDropQnodeReq dropReq = { .dnodeId = pStmt->dnodeId }; + + pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); + if (NULL == pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_DND_DROP_QNODE; + pCxt->pCmdMsg->msgLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq); + pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); + if (NULL == pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + tSerializeSMCreateDropQSBNodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq); + + return TSDB_CODE_SUCCESS; +} + +static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* pStmt) { + SCMCreateTopicReq createReq = {0}; + + if (NULL != pStmt->pQuery) { + int32_t code = translateQuery(pCxt, pStmt->pQuery); + if (TSDB_CODE_SUCCESS == code) { + code = nodesNodeToString(pStmt->pQuery, false, &createReq.ast, NULL); + } + if (TSDB_CODE_SUCCESS != code ) { + return code; + } + } else { + strcpy(createReq.subscribeDbName, pStmt->subscribeDbName); + } + + createReq.sql = strdup(pCxt->pParseCxt->pSql); + if (NULL == createReq.sql) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + SName name = { .type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId }; + strcpy(name.dbname, pCxt->pParseCxt->db); + strcpy(name.tname, pStmt->topicName); + tNameExtractFullName(&name, createReq.name); + createReq.igExists = pStmt->ignoreExists; + + pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); + if (NULL == pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_TOPIC; + pCxt->pCmdMsg->msgLen = tSerializeSCMCreateTopicReq(NULL, 0, &createReq); + pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); + if (NULL == pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + tSerializeSCMCreateTopicReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq); + tFreeSCMCreateTopicReq(&createReq); + + return TSDB_CODE_SUCCESS; +} + +static int32_t translateDropTopic(STranslateContext* pCxt, SDropTopicStmt* pStmt) { + SMDropTopicReq dropReq = {0}; + + SName name = { .type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId }; + strcpy(name.dbname, pCxt->pParseCxt->db); + strcpy(name.tname, pStmt->topicName); + tNameExtractFullName(&name, dropReq.name); + dropReq.igNotExists = pStmt->ignoreNotExists; + + pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); + if (NULL == pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_MND_DROP_TOPIC; + pCxt->pCmdMsg->msgLen = tSerializeSMDropTopicReq(NULL, 0, &dropReq); + pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); + if (NULL == pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + tSerializeSMDropTopicReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq); + + return TSDB_CODE_SUCCESS; +} + static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pNode)) { @@ -1232,6 +1376,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_DROP_DATABASE_STMT: code = translateDropDatabase(pCxt, (SDropDatabaseStmt*)pNode); break; + case QUERY_NODE_ALTER_DATABASE_STMT: + code = translateAlterDatabase(pCxt, (SAlterDatabaseStmt*)pNode); + break; case QUERY_NODE_CREATE_TABLE_STMT: code = translateCreateSuperTable(pCxt, (SCreateTableStmt*)pNode); break; @@ -1274,9 +1421,21 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_CREATE_INDEX_STMT: code = translateCreateIndex(pCxt, (SCreateIndexStmt*)pNode); break; + case QUERY_NODE_DROP_INDEX_STMT: + code = translateDropIndex(pCxt, (SDropIndexStmt*)pNode); + break; case QUERY_NODE_CREATE_QNODE_STMT: code = translateCreateQnode(pCxt, (SCreateQnodeStmt*)pNode); break; + case QUERY_NODE_DROP_QNODE_STMT: + code = translateDropQnode(pCxt, (SDropQnodeStmt*)pNode); + break; + case QUERY_NODE_CREATE_TOPIC_STMT: + code = translateCreateTopic(pCxt, (SCreateTopicStmt*)pNode); + break; + case QUERY_NODE_DROP_TOPIC_STMT: + code = translateDropTopic(pCxt, (SDropTopicStmt*)pNode); + break; default: break; } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 8b46d3600b..18b507c1b0 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -99,22 +99,22 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned char -#define YYNOCODE 218 +#define YYNOCODE 220 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SToken yy5; - bool yy25; - SNodeList* yy40; - ENullOrder yy53; - EOrder yy54; - SNode* yy68; - EJoinType yy92; - EFillMode yy94; - SDataType yy372; - EOperatorType yy416; + SNodeList* yy24; + bool yy97; + SToken yy129; + SDataType yy224; + ENullOrder yy257; + EOperatorType yy260; + EFillMode yy294; + EJoinType yy332; + EOrder yy378; + SNode* yy432; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -129,17 +129,17 @@ typedef union { #define ParseCTX_PARAM #define ParseCTX_FETCH #define ParseCTX_STORE -#define YYNSTATE 313 -#define YYNRULE 248 -#define YYNTOKEN 140 -#define YY_MAX_SHIFT 312 -#define YY_MIN_SHIFTREDUCE 480 -#define YY_MAX_SHIFTREDUCE 727 -#define YY_ERROR_ACTION 728 -#define YY_ACCEPT_ACTION 729 -#define YY_NO_ACTION 730 -#define YY_MIN_REDUCE 731 -#define YY_MAX_REDUCE 978 +#define YYNSTATE 333 +#define YYNRULE 255 +#define YYNTOKEN 141 +#define YY_MAX_SHIFT 332 +#define YY_MIN_SHIFTREDUCE 501 +#define YY_MAX_SHIFTREDUCE 755 +#define YY_ERROR_ACTION 756 +#define YY_ACCEPT_ACTION 757 +#define YY_NO_ACTION 758 +#define YY_MIN_REDUCE 759 +#define YY_MAX_REDUCE 1013 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -206,307 +206,322 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (963) +#define YY_ACTTAB_COUNT (1012) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 152, 236, 277, 871, 844, 252, 252, 167, 186, 784, - /* 10 */ 847, 844, 31, 29, 27, 26, 25, 846, 844, 209, - /* 20 */ 787, 787, 309, 308, 846, 31, 29, 27, 26, 25, - /* 30 */ 746, 236, 151, 871, 106, 826, 39, 824, 251, 844, - /* 40 */ 145, 957, 238, 61, 236, 856, 871, 782, 57, 857, - /* 50 */ 860, 896, 910, 145, 956, 154, 892, 969, 955, 187, - /* 60 */ 164, 610, 213, 832, 239, 166, 930, 10, 826, 907, - /* 70 */ 824, 251, 301, 300, 299, 298, 297, 296, 295, 294, - /* 80 */ 293, 292, 291, 290, 289, 288, 287, 286, 285, 599, - /* 90 */ 31, 29, 27, 26, 25, 24, 109, 23, 159, 228, - /* 100 */ 628, 629, 630, 631, 632, 633, 634, 636, 637, 638, - /* 110 */ 23, 159, 39, 628, 629, 630, 631, 632, 633, 634, - /* 120 */ 636, 637, 638, 783, 542, 275, 274, 273, 546, 272, - /* 130 */ 548, 549, 271, 551, 268, 165, 557, 265, 559, 560, - /* 140 */ 262, 259, 236, 54, 871, 694, 251, 789, 70, 252, - /* 150 */ 844, 65, 249, 238, 779, 224, 856, 208, 214, 56, - /* 160 */ 857, 860, 896, 229, 787, 601, 144, 892, 775, 205, - /* 170 */ 692, 693, 695, 696, 220, 10, 910, 82, 957, 31, - /* 180 */ 29, 27, 26, 25, 215, 210, 223, 170, 871, 64, - /* 190 */ 826, 81, 824, 906, 844, 955, 600, 238, 773, 826, - /* 200 */ 856, 825, 224, 57, 857, 860, 896, 187, 62, 910, - /* 210 */ 154, 892, 76, 723, 724, 27, 26, 25, 102, 903, - /* 220 */ 219, 220, 218, 284, 105, 957, 905, 729, 610, 82, - /* 230 */ 201, 923, 87, 223, 21, 871, 64, 284, 81, 227, - /* 240 */ 75, 844, 955, 635, 238, 104, 639, 856, 490, 86, - /* 250 */ 57, 857, 860, 896, 197, 62, 190, 154, 892, 76, - /* 260 */ 173, 68, 236, 278, 871, 78, 903, 904, 127, 908, - /* 270 */ 844, 817, 40, 238, 252, 84, 856, 250, 924, 57, - /* 280 */ 857, 860, 896, 957, 9, 8, 154, 892, 969, 787, - /* 290 */ 236, 48, 871, 178, 30, 28, 81, 953, 844, 206, - /* 300 */ 955, 238, 780, 590, 856, 833, 239, 57, 857, 860, - /* 310 */ 896, 588, 6, 161, 154, 892, 969, 30, 28, 670, - /* 320 */ 169, 99, 12, 790, 70, 914, 590, 31, 29, 27, - /* 330 */ 26, 25, 789, 70, 588, 774, 161, 189, 490, 236, - /* 340 */ 602, 871, 1, 677, 646, 12, 53, 844, 491, 492, - /* 350 */ 238, 50, 224, 856, 30, 28, 133, 857, 860, 252, - /* 360 */ 599, 253, 122, 590, 252, 1, 226, 172, 915, 665, - /* 370 */ 235, 588, 590, 161, 787, 957, 589, 591, 594, 787, - /* 380 */ 588, 171, 12, 926, 253, 281, 30, 28, 81, 280, - /* 390 */ 669, 665, 955, 789, 70, 590, 82, 9, 8, 589, - /* 400 */ 591, 594, 1, 588, 282, 161, 691, 96, 236, 195, - /* 410 */ 871, 130, 193, 59, 94, 196, 844, 134, 71, 238, - /* 420 */ 91, 253, 856, 279, 221, 58, 857, 860, 896, 625, - /* 430 */ 253, 83, 895, 892, 7, 872, 589, 591, 594, 108, - /* 440 */ 236, 2, 871, 597, 174, 589, 591, 594, 844, 772, - /* 450 */ 231, 238, 188, 253, 856, 38, 640, 58, 857, 860, - /* 460 */ 896, 726, 727, 32, 234, 892, 30, 28, 589, 591, - /* 470 */ 594, 85, 30, 28, 237, 590, 236, 603, 871, 607, - /* 480 */ 191, 590, 150, 588, 844, 161, 32, 238, 82, 588, - /* 490 */ 856, 161, 198, 72, 857, 860, 30, 28, 20, 281, - /* 500 */ 598, 668, 604, 280, 602, 590, 207, 82, 31, 29, - /* 510 */ 27, 26, 25, 588, 7, 161, 232, 199, 282, 927, - /* 520 */ 7, 851, 242, 92, 236, 937, 871, 583, 849, 594, - /* 530 */ 225, 970, 844, 253, 32, 238, 160, 279, 856, 253, - /* 540 */ 114, 138, 857, 860, 1, 204, 936, 112, 589, 591, - /* 550 */ 594, 244, 95, 119, 589, 591, 594, 236, 66, 871, - /* 560 */ 67, 5, 153, 253, 917, 844, 217, 98, 238, 203, - /* 570 */ 74, 856, 4, 63, 58, 857, 860, 896, 589, 591, - /* 580 */ 594, 665, 893, 236, 220, 871, 535, 100, 601, 530, - /* 590 */ 911, 844, 33, 68, 238, 202, 59, 856, 101, 64, - /* 600 */ 138, 857, 860, 236, 155, 871, 563, 972, 233, 567, - /* 610 */ 954, 844, 572, 257, 238, 107, 67, 856, 62, 68, - /* 620 */ 137, 857, 860, 17, 230, 236, 831, 871, 79, 903, - /* 630 */ 904, 878, 908, 844, 245, 47, 238, 49, 240, 856, - /* 640 */ 241, 69, 72, 857, 860, 236, 830, 871, 67, 163, - /* 650 */ 126, 216, 246, 844, 116, 788, 238, 158, 236, 856, - /* 660 */ 871, 255, 138, 857, 860, 247, 844, 128, 123, 238, - /* 670 */ 162, 312, 856, 125, 185, 138, 857, 860, 184, 597, - /* 680 */ 971, 60, 129, 183, 22, 182, 142, 305, 143, 838, - /* 690 */ 124, 236, 749, 871, 31, 29, 27, 26, 25, 844, - /* 700 */ 176, 177, 238, 837, 179, 856, 836, 835, 136, 857, - /* 710 */ 860, 181, 180, 55, 778, 236, 120, 871, 777, 748, - /* 720 */ 745, 740, 735, 844, 776, 501, 238, 747, 739, 856, - /* 730 */ 738, 734, 139, 857, 860, 236, 733, 871, 192, 732, - /* 740 */ 828, 175, 248, 844, 200, 41, 238, 194, 88, 856, - /* 750 */ 89, 90, 131, 857, 860, 236, 3, 871, 32, 14, - /* 760 */ 93, 36, 690, 844, 73, 97, 238, 211, 42, 856, - /* 770 */ 212, 684, 140, 857, 860, 236, 683, 871, 849, 15, - /* 780 */ 19, 34, 11, 844, 662, 43, 238, 44, 236, 856, - /* 790 */ 871, 712, 132, 857, 860, 661, 844, 711, 156, 238, - /* 800 */ 35, 716, 856, 717, 103, 141, 857, 860, 80, 715, - /* 810 */ 157, 16, 236, 8, 871, 110, 608, 13, 18, 113, - /* 820 */ 844, 111, 688, 238, 115, 236, 856, 871, 827, 868, - /* 830 */ 857, 860, 117, 844, 626, 45, 238, 243, 236, 856, - /* 840 */ 871, 118, 867, 857, 860, 46, 844, 50, 592, 238, - /* 850 */ 37, 848, 856, 121, 220, 866, 857, 860, 254, 256, - /* 860 */ 236, 564, 871, 168, 258, 260, 561, 261, 844, 64, - /* 870 */ 558, 238, 263, 236, 856, 871, 264, 148, 857, 860, - /* 880 */ 552, 844, 266, 267, 238, 550, 269, 856, 62, 270, - /* 890 */ 147, 857, 860, 236, 556, 871, 555, 222, 77, 903, - /* 900 */ 904, 844, 908, 554, 238, 541, 553, 856, 276, 51, - /* 910 */ 149, 857, 860, 236, 52, 871, 571, 570, 569, 499, - /* 920 */ 283, 844, 520, 519, 238, 518, 744, 856, 517, 516, - /* 930 */ 146, 857, 860, 236, 515, 871, 514, 513, 512, 511, - /* 940 */ 510, 844, 509, 508, 238, 303, 507, 856, 506, 505, - /* 950 */ 135, 857, 860, 504, 302, 304, 737, 306, 307, 736, - /* 960 */ 731, 310, 311, + /* 0 */ 163, 856, 240, 855, 272, 162, 272, 200, 856, 814, + /* 10 */ 854, 878, 31, 29, 27, 26, 25, 65, 880, 817, + /* 20 */ 178, 817, 256, 176, 906, 31, 29, 27, 26, 25, + /* 30 */ 779, 878, 40, 705, 55, 819, 71, 63, 880, 62, + /* 40 */ 155, 229, 66, 812, 243, 809, 906, 79, 938, 939, + /* 50 */ 626, 943, 878, 155, 175, 258, 511, 863, 259, 891, + /* 60 */ 511, 638, 58, 892, 895, 931, 512, 513, 208, 165, + /* 70 */ 927, 77, 321, 320, 319, 318, 317, 316, 315, 314, + /* 80 */ 313, 312, 311, 310, 309, 308, 307, 306, 305, 775, + /* 90 */ 959, 27, 26, 25, 31, 29, 27, 26, 25, 23, + /* 100 */ 170, 271, 656, 657, 658, 659, 660, 661, 662, 664, + /* 110 */ 665, 666, 23, 170, 271, 656, 657, 658, 659, 660, + /* 120 */ 661, 662, 664, 665, 666, 31, 29, 27, 26, 25, + /* 130 */ 10, 321, 320, 319, 318, 317, 316, 315, 314, 313, + /* 140 */ 312, 311, 310, 309, 308, 307, 306, 305, 565, 295, + /* 150 */ 294, 293, 569, 292, 571, 572, 291, 574, 288, 804, + /* 160 */ 580, 285, 582, 583, 282, 279, 24, 117, 256, 196, + /* 170 */ 906, 992, 626, 195, 624, 256, 177, 906, 194, 856, + /* 180 */ 193, 854, 83, 878, 991, 83, 258, 233, 990, 244, + /* 190 */ 891, 180, 271, 57, 892, 895, 931, 54, 182, 190, + /* 200 */ 154, 927, 51, 819, 71, 272, 192, 191, 269, 301, + /* 210 */ 819, 71, 992, 300, 805, 243, 624, 906, 751, 752, + /* 220 */ 817, 10, 234, 878, 298, 82, 258, 945, 302, 990, + /* 230 */ 891, 757, 627, 58, 892, 895, 931, 256, 186, 906, + /* 240 */ 165, 927, 77, 228, 942, 878, 201, 299, 258, 628, + /* 250 */ 30, 28, 891, 201, 113, 58, 892, 895, 931, 617, + /* 260 */ 221, 958, 165, 927, 1004, 184, 256, 615, 906, 172, + /* 270 */ 629, 235, 230, 965, 878, 304, 878, 258, 12, 272, + /* 280 */ 297, 891, 270, 881, 58, 892, 895, 931, 992, 9, + /* 290 */ 8, 165, 927, 1004, 817, 256, 272, 906, 1, 130, + /* 300 */ 83, 82, 988, 878, 181, 990, 258, 856, 40, 854, + /* 310 */ 891, 817, 112, 58, 892, 895, 931, 273, 21, 813, + /* 320 */ 165, 927, 1004, 30, 28, 698, 272, 663, 189, 183, + /* 330 */ 667, 949, 617, 99, 616, 618, 621, 114, 30, 28, + /* 340 */ 615, 817, 172, 329, 328, 803, 247, 617, 256, 674, + /* 350 */ 906, 12, 722, 83, 140, 615, 878, 172, 161, 258, + /* 360 */ 141, 72, 244, 891, 30, 28, 144, 892, 895, 49, + /* 370 */ 945, 1, 945, 617, 84, 225, 720, 721, 723, 724, + /* 380 */ 810, 615, 226, 172, 304, 992, 7, 941, 6, 940, + /* 390 */ 273, 697, 12, 864, 259, 256, 248, 906, 82, 820, + /* 400 */ 71, 136, 990, 878, 847, 273, 258, 616, 618, 621, + /* 410 */ 891, 240, 1, 59, 892, 895, 931, 256, 107, 906, + /* 420 */ 930, 927, 616, 618, 621, 878, 65, 217, 258, 950, + /* 430 */ 693, 273, 891, 251, 69, 59, 892, 895, 931, 207, + /* 440 */ 244, 83, 254, 927, 213, 961, 63, 211, 616, 618, + /* 450 */ 621, 83, 94, 30, 28, 257, 110, 938, 239, 241, + /* 460 */ 238, 249, 617, 992, 719, 617, 30, 28, 693, 93, + /* 470 */ 615, 60, 172, 615, 246, 617, 82, 104, 907, 256, + /* 480 */ 990, 906, 668, 615, 102, 172, 116, 878, 255, 32, + /* 490 */ 258, 2, 754, 755, 891, 635, 624, 73, 892, 895, + /* 500 */ 252, 7, 32, 696, 607, 9, 8, 30, 28, 185, + /* 510 */ 256, 32, 906, 632, 7, 885, 617, 625, 878, 85, + /* 520 */ 273, 258, 883, 273, 615, 891, 172, 631, 59, 892, + /* 530 */ 895, 931, 214, 273, 245, 1005, 928, 616, 618, 621, + /* 540 */ 616, 618, 621, 197, 198, 256, 199, 906, 39, 653, + /* 550 */ 616, 618, 621, 878, 202, 1, 258, 171, 90, 122, + /* 560 */ 891, 215, 209, 148, 892, 895, 120, 256, 630, 906, + /* 570 */ 264, 134, 160, 127, 273, 878, 558, 67, 258, 222, + /* 580 */ 68, 216, 891, 69, 992, 148, 892, 895, 256, 218, + /* 590 */ 906, 616, 618, 621, 629, 553, 878, 82, 95, 258, + /* 600 */ 962, 990, 60, 891, 586, 133, 147, 892, 895, 590, + /* 610 */ 256, 277, 906, 61, 802, 227, 68, 219, 878, 325, + /* 620 */ 972, 258, 132, 262, 256, 891, 906, 100, 73, 892, + /* 630 */ 895, 621, 878, 224, 971, 258, 169, 236, 256, 891, + /* 640 */ 906, 103, 148, 892, 895, 56, 878, 164, 128, 258, + /* 650 */ 173, 5, 256, 891, 906, 952, 148, 892, 895, 237, + /* 660 */ 878, 75, 106, 258, 301, 223, 1006, 891, 300, 108, + /* 670 */ 146, 892, 895, 240, 268, 4, 220, 64, 256, 96, + /* 680 */ 906, 693, 628, 302, 595, 946, 878, 33, 65, 258, + /* 690 */ 253, 69, 256, 891, 906, 109, 149, 892, 895, 70, + /* 700 */ 878, 989, 299, 258, 1007, 250, 68, 891, 63, 166, + /* 710 */ 142, 892, 895, 256, 17, 906, 115, 242, 78, 938, + /* 720 */ 939, 878, 943, 913, 258, 862, 260, 256, 891, 906, + /* 730 */ 261, 150, 892, 895, 861, 878, 265, 174, 258, 266, + /* 740 */ 124, 256, 891, 906, 267, 143, 892, 895, 48, 878, + /* 750 */ 135, 818, 258, 50, 275, 256, 891, 906, 137, 151, + /* 760 */ 892, 895, 131, 878, 872, 138, 258, 332, 152, 256, + /* 770 */ 891, 906, 153, 903, 892, 895, 139, 878, 778, 871, + /* 780 */ 258, 870, 187, 256, 891, 906, 188, 902, 892, 895, + /* 790 */ 869, 878, 808, 807, 258, 777, 774, 256, 891, 906, + /* 800 */ 768, 901, 892, 895, 763, 878, 868, 859, 258, 87, + /* 810 */ 806, 256, 891, 906, 524, 158, 892, 895, 776, 878, + /* 820 */ 773, 205, 258, 203, 204, 256, 891, 906, 767, 157, + /* 830 */ 892, 895, 766, 878, 762, 761, 258, 210, 760, 867, + /* 840 */ 891, 866, 212, 159, 892, 895, 36, 858, 256, 42, + /* 850 */ 906, 97, 98, 3, 240, 14, 878, 15, 74, 258, + /* 860 */ 101, 105, 256, 891, 906, 43, 156, 892, 895, 65, + /* 870 */ 878, 32, 231, 258, 718, 712, 92, 891, 34, 37, + /* 880 */ 145, 892, 895, 711, 76, 44, 11, 232, 690, 63, + /* 890 */ 206, 883, 689, 91, 19, 45, 20, 111, 745, 80, + /* 900 */ 938, 939, 740, 943, 35, 739, 31, 29, 27, 26, + /* 910 */ 25, 22, 81, 167, 16, 744, 41, 743, 168, 89, + /* 920 */ 8, 31, 29, 27, 26, 25, 118, 636, 13, 31, + /* 930 */ 29, 27, 26, 25, 654, 18, 263, 857, 119, 716, + /* 940 */ 121, 123, 46, 126, 125, 47, 88, 619, 51, 276, + /* 950 */ 86, 179, 38, 280, 882, 579, 587, 129, 278, 274, + /* 960 */ 584, 281, 283, 581, 284, 286, 575, 287, 289, 573, + /* 970 */ 564, 290, 52, 53, 594, 296, 593, 578, 638, 592, + /* 980 */ 303, 577, 522, 543, 576, 542, 541, 536, 540, 539, + /* 990 */ 538, 537, 535, 534, 533, 772, 532, 531, 530, 529, + /* 1000 */ 528, 527, 322, 323, 765, 764, 326, 327, 324, 759, + /* 1010 */ 330, 331, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 157, 160, 163, 162, 168, 145, 145, 157, 148, 148, - /* 10 */ 174, 168, 12, 13, 14, 15, 16, 174, 168, 178, - /* 20 */ 160, 160, 142, 143, 174, 12, 13, 14, 15, 16, - /* 30 */ 0, 160, 159, 162, 216, 162, 147, 164, 31, 168, - /* 40 */ 40, 196, 171, 154, 160, 174, 162, 158, 177, 178, - /* 50 */ 179, 180, 175, 40, 209, 184, 185, 186, 213, 39, - /* 60 */ 167, 61, 178, 170, 171, 159, 195, 60, 162, 192, - /* 70 */ 164, 31, 42, 43, 44, 45, 46, 47, 48, 49, - /* 80 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 31, - /* 90 */ 12, 13, 14, 15, 16, 181, 182, 97, 98, 68, - /* 100 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - /* 110 */ 97, 98, 147, 100, 101, 102, 103, 104, 105, 106, - /* 120 */ 107, 108, 109, 158, 70, 71, 72, 73, 74, 75, - /* 130 */ 76, 77, 78, 79, 80, 149, 82, 83, 84, 85, - /* 140 */ 86, 87, 160, 144, 162, 99, 31, 161, 162, 145, - /* 150 */ 168, 152, 148, 171, 155, 173, 174, 92, 31, 177, - /* 160 */ 178, 179, 180, 132, 160, 31, 184, 185, 0, 123, - /* 170 */ 124, 125, 126, 127, 145, 60, 175, 114, 196, 12, - /* 180 */ 13, 14, 15, 16, 119, 120, 160, 159, 162, 160, - /* 190 */ 162, 209, 164, 192, 168, 213, 31, 171, 0, 162, - /* 200 */ 174, 164, 173, 177, 178, 179, 180, 39, 179, 175, - /* 210 */ 184, 185, 186, 135, 136, 14, 15, 16, 189, 190, - /* 220 */ 191, 145, 193, 39, 198, 196, 192, 140, 61, 114, - /* 230 */ 204, 205, 19, 160, 97, 162, 160, 39, 209, 3, - /* 240 */ 27, 168, 213, 106, 171, 111, 109, 174, 21, 36, - /* 250 */ 177, 178, 179, 180, 61, 179, 29, 184, 185, 186, - /* 260 */ 173, 68, 160, 66, 162, 189, 190, 191, 150, 193, - /* 270 */ 168, 153, 59, 171, 145, 62, 174, 148, 205, 177, - /* 280 */ 178, 179, 180, 196, 1, 2, 184, 185, 186, 160, - /* 290 */ 160, 144, 162, 145, 12, 13, 209, 195, 168, 207, - /* 300 */ 213, 171, 155, 21, 174, 170, 171, 177, 178, 179, - /* 310 */ 180, 29, 34, 31, 184, 185, 186, 12, 13, 14, - /* 320 */ 149, 201, 40, 161, 162, 195, 21, 12, 13, 14, - /* 330 */ 15, 16, 161, 162, 29, 0, 31, 142, 21, 160, - /* 340 */ 31, 162, 60, 14, 61, 40, 60, 168, 31, 32, - /* 350 */ 171, 65, 173, 174, 12, 13, 177, 178, 179, 145, - /* 360 */ 31, 79, 148, 21, 145, 60, 130, 148, 112, 113, - /* 370 */ 40, 29, 21, 31, 160, 196, 94, 95, 96, 160, - /* 380 */ 29, 149, 40, 176, 79, 50, 12, 13, 209, 54, - /* 390 */ 4, 113, 213, 161, 162, 21, 114, 1, 2, 94, - /* 400 */ 95, 96, 60, 29, 69, 31, 61, 61, 160, 20, - /* 410 */ 162, 18, 23, 68, 68, 22, 168, 24, 25, 171, - /* 420 */ 111, 79, 174, 88, 194, 177, 178, 179, 180, 99, - /* 430 */ 79, 38, 184, 185, 60, 162, 94, 95, 96, 210, - /* 440 */ 160, 197, 162, 31, 145, 94, 95, 96, 168, 0, - /* 450 */ 68, 171, 145, 79, 174, 147, 61, 177, 178, 179, - /* 460 */ 180, 138, 139, 68, 184, 185, 12, 13, 94, 95, - /* 470 */ 96, 147, 12, 13, 14, 21, 160, 31, 162, 61, - /* 480 */ 141, 21, 141, 29, 168, 31, 68, 171, 114, 29, - /* 490 */ 174, 31, 160, 177, 178, 179, 12, 13, 2, 50, - /* 500 */ 31, 115, 31, 54, 31, 21, 122, 114, 12, 13, - /* 510 */ 14, 15, 16, 29, 60, 31, 134, 165, 69, 176, - /* 520 */ 60, 60, 121, 169, 160, 206, 162, 61, 67, 96, - /* 530 */ 214, 215, 168, 79, 68, 171, 172, 88, 174, 79, - /* 540 */ 61, 177, 178, 179, 60, 168, 206, 68, 94, 95, - /* 550 */ 96, 61, 169, 61, 94, 95, 96, 160, 68, 162, - /* 560 */ 68, 129, 168, 79, 203, 168, 128, 202, 171, 117, - /* 570 */ 200, 174, 116, 160, 177, 178, 179, 180, 94, 95, - /* 580 */ 96, 113, 185, 160, 145, 162, 61, 199, 31, 61, - /* 590 */ 175, 168, 110, 68, 171, 172, 68, 174, 187, 160, - /* 600 */ 177, 178, 179, 160, 137, 162, 61, 217, 133, 61, - /* 610 */ 212, 168, 61, 68, 171, 211, 68, 174, 179, 68, - /* 620 */ 177, 178, 179, 60, 131, 160, 169, 162, 189, 190, - /* 630 */ 191, 183, 193, 168, 91, 144, 171, 60, 168, 174, - /* 640 */ 168, 61, 177, 178, 179, 160, 169, 162, 68, 168, - /* 650 */ 153, 208, 166, 168, 160, 160, 171, 172, 160, 174, - /* 660 */ 162, 156, 177, 178, 179, 165, 168, 145, 144, 171, - /* 670 */ 172, 141, 174, 19, 26, 177, 178, 179, 30, 31, - /* 680 */ 215, 27, 146, 35, 2, 37, 151, 33, 151, 0, - /* 690 */ 36, 160, 0, 162, 12, 13, 14, 15, 16, 168, - /* 700 */ 56, 67, 171, 0, 56, 174, 0, 0, 177, 178, - /* 710 */ 179, 63, 64, 59, 0, 160, 62, 162, 0, 0, - /* 720 */ 0, 0, 0, 168, 0, 41, 171, 0, 0, 174, - /* 730 */ 0, 0, 177, 178, 179, 160, 0, 162, 21, 0, - /* 740 */ 0, 93, 88, 168, 90, 60, 171, 21, 19, 174, - /* 750 */ 34, 89, 177, 178, 179, 160, 68, 162, 68, 118, - /* 760 */ 61, 68, 61, 168, 60, 60, 171, 29, 60, 174, - /* 770 */ 68, 61, 177, 178, 179, 160, 61, 162, 67, 118, - /* 780 */ 68, 112, 118, 168, 61, 60, 171, 4, 160, 174, - /* 790 */ 162, 29, 177, 178, 179, 61, 168, 29, 29, 171, - /* 800 */ 68, 29, 174, 61, 67, 177, 178, 179, 67, 29, - /* 810 */ 29, 68, 160, 2, 162, 67, 61, 60, 60, 60, - /* 820 */ 168, 61, 61, 171, 60, 160, 174, 162, 0, 177, - /* 830 */ 178, 179, 34, 168, 99, 60, 171, 92, 160, 174, - /* 840 */ 162, 89, 177, 178, 179, 60, 168, 65, 21, 171, - /* 850 */ 60, 67, 174, 67, 145, 177, 178, 179, 66, 29, - /* 860 */ 160, 61, 162, 29, 60, 29, 61, 60, 168, 160, - /* 870 */ 61, 171, 29, 160, 174, 162, 60, 177, 178, 179, - /* 880 */ 61, 168, 29, 60, 171, 61, 29, 174, 179, 60, - /* 890 */ 177, 178, 179, 160, 81, 162, 81, 188, 189, 190, - /* 900 */ 191, 168, 193, 81, 171, 21, 81, 174, 69, 60, - /* 910 */ 177, 178, 179, 160, 60, 162, 29, 29, 21, 41, - /* 920 */ 40, 168, 29, 29, 171, 29, 0, 174, 29, 29, - /* 930 */ 177, 178, 179, 160, 29, 162, 29, 21, 29, 29, - /* 940 */ 29, 168, 29, 29, 171, 27, 29, 174, 29, 29, - /* 950 */ 177, 178, 179, 29, 29, 34, 0, 29, 28, 0, - /* 960 */ 0, 21, 20, 218, 218, 218, 218, 218, 218, 218, - /* 970 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 980 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 990 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1000 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1010 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1020 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1030 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1040 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1050 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1060 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1070 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1080 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1090 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1100 */ 218, 218, 218, + /* 0 */ 158, 163, 146, 165, 146, 160, 146, 149, 163, 149, + /* 10 */ 165, 169, 12, 13, 14, 15, 16, 161, 176, 161, + /* 20 */ 158, 161, 161, 150, 163, 12, 13, 14, 15, 16, + /* 30 */ 0, 169, 148, 14, 145, 162, 163, 181, 176, 155, + /* 40 */ 40, 180, 153, 159, 161, 156, 163, 191, 192, 193, + /* 50 */ 31, 195, 169, 40, 168, 172, 21, 171, 172, 176, + /* 60 */ 21, 61, 179, 180, 181, 182, 31, 32, 29, 186, + /* 70 */ 187, 188, 42, 43, 44, 45, 46, 47, 48, 49, + /* 80 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 0, + /* 90 */ 207, 14, 15, 16, 12, 13, 14, 15, 16, 99, + /* 100 */ 100, 31, 102, 103, 104, 105, 106, 107, 108, 109, + /* 110 */ 110, 111, 99, 100, 31, 102, 103, 104, 105, 106, + /* 120 */ 107, 108, 109, 110, 111, 12, 13, 14, 15, 16, + /* 130 */ 60, 42, 43, 44, 45, 46, 47, 48, 49, 50, + /* 140 */ 51, 52, 53, 54, 55, 56, 57, 58, 70, 71, + /* 150 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 0, + /* 160 */ 82, 83, 84, 85, 86, 87, 183, 184, 161, 26, + /* 170 */ 163, 198, 31, 30, 31, 161, 160, 163, 35, 163, + /* 180 */ 37, 165, 115, 169, 211, 115, 172, 180, 215, 175, + /* 190 */ 176, 150, 31, 179, 180, 181, 182, 60, 150, 56, + /* 200 */ 186, 187, 65, 162, 163, 146, 63, 64, 149, 50, + /* 210 */ 162, 163, 198, 54, 0, 161, 31, 163, 136, 137, + /* 220 */ 161, 60, 31, 169, 66, 211, 172, 177, 69, 215, + /* 230 */ 176, 141, 31, 179, 180, 181, 182, 161, 95, 163, + /* 240 */ 186, 187, 188, 92, 194, 169, 39, 88, 172, 31, + /* 250 */ 12, 13, 176, 39, 200, 179, 180, 181, 182, 21, + /* 260 */ 206, 207, 186, 187, 188, 175, 161, 29, 163, 31, + /* 270 */ 31, 120, 121, 197, 169, 39, 169, 172, 40, 146, + /* 280 */ 164, 176, 149, 176, 179, 180, 181, 182, 198, 1, + /* 290 */ 2, 186, 187, 188, 161, 161, 146, 163, 60, 149, + /* 300 */ 115, 211, 197, 169, 160, 215, 172, 163, 148, 165, + /* 310 */ 176, 161, 94, 179, 180, 181, 182, 79, 99, 159, + /* 320 */ 186, 187, 188, 12, 13, 14, 146, 108, 146, 149, + /* 330 */ 111, 197, 21, 94, 96, 97, 98, 218, 12, 13, + /* 340 */ 29, 161, 31, 143, 144, 0, 3, 21, 161, 61, + /* 350 */ 163, 40, 101, 115, 18, 29, 169, 31, 22, 172, + /* 360 */ 24, 25, 175, 176, 12, 13, 179, 180, 181, 145, + /* 370 */ 177, 60, 177, 21, 38, 124, 125, 126, 127, 128, + /* 380 */ 156, 29, 209, 31, 39, 198, 60, 194, 34, 194, + /* 390 */ 79, 4, 40, 171, 172, 161, 68, 163, 211, 162, + /* 400 */ 163, 151, 215, 169, 154, 79, 172, 96, 97, 98, + /* 410 */ 176, 146, 60, 179, 180, 181, 182, 161, 203, 163, + /* 420 */ 186, 187, 96, 97, 98, 169, 161, 61, 172, 113, + /* 430 */ 114, 79, 176, 68, 68, 179, 180, 181, 182, 143, + /* 440 */ 175, 115, 186, 187, 20, 178, 181, 23, 96, 97, + /* 450 */ 98, 115, 19, 12, 13, 14, 191, 192, 193, 196, + /* 460 */ 195, 133, 21, 198, 61, 21, 12, 13, 114, 36, + /* 470 */ 29, 68, 31, 29, 131, 21, 211, 61, 163, 161, + /* 480 */ 215, 163, 61, 29, 68, 31, 212, 169, 40, 68, + /* 490 */ 172, 199, 139, 140, 176, 61, 31, 179, 180, 181, + /* 500 */ 135, 60, 68, 116, 61, 1, 2, 12, 13, 146, + /* 510 */ 161, 68, 163, 31, 60, 60, 21, 31, 169, 148, + /* 520 */ 79, 172, 67, 79, 29, 176, 31, 31, 179, 180, + /* 530 */ 181, 182, 146, 79, 216, 217, 187, 96, 97, 98, + /* 540 */ 96, 97, 98, 174, 161, 161, 166, 163, 148, 101, + /* 550 */ 96, 97, 98, 169, 146, 60, 172, 173, 148, 61, + /* 560 */ 176, 175, 142, 179, 180, 181, 68, 161, 31, 163, + /* 570 */ 61, 146, 142, 61, 79, 169, 61, 68, 172, 173, + /* 580 */ 68, 174, 176, 68, 198, 179, 180, 181, 161, 161, + /* 590 */ 163, 96, 97, 98, 31, 61, 169, 211, 145, 172, + /* 600 */ 178, 215, 68, 176, 61, 19, 179, 180, 181, 61, + /* 610 */ 161, 68, 163, 27, 0, 123, 68, 166, 169, 33, + /* 620 */ 208, 172, 36, 122, 161, 176, 163, 170, 179, 180, + /* 630 */ 181, 98, 169, 169, 208, 172, 173, 210, 161, 176, + /* 640 */ 163, 170, 179, 180, 181, 59, 169, 169, 62, 172, + /* 650 */ 173, 130, 161, 176, 163, 205, 179, 180, 181, 129, + /* 660 */ 169, 202, 204, 172, 50, 118, 217, 176, 54, 201, + /* 670 */ 179, 180, 181, 146, 88, 117, 90, 161, 161, 93, + /* 680 */ 163, 114, 31, 69, 61, 177, 169, 112, 161, 172, + /* 690 */ 134, 68, 161, 176, 163, 189, 179, 180, 181, 61, + /* 700 */ 169, 214, 88, 172, 219, 132, 68, 176, 181, 138, + /* 710 */ 179, 180, 181, 161, 60, 163, 213, 190, 191, 192, + /* 720 */ 193, 169, 195, 185, 172, 170, 169, 161, 176, 163, + /* 730 */ 169, 179, 180, 181, 170, 169, 91, 169, 172, 167, + /* 740 */ 161, 161, 176, 163, 166, 179, 180, 181, 145, 169, + /* 750 */ 154, 161, 172, 60, 157, 161, 176, 163, 146, 179, + /* 760 */ 180, 181, 145, 169, 0, 147, 172, 142, 152, 161, + /* 770 */ 176, 163, 152, 179, 180, 181, 147, 169, 0, 0, + /* 780 */ 172, 0, 56, 161, 176, 163, 67, 179, 180, 181, + /* 790 */ 0, 169, 0, 0, 172, 0, 0, 161, 176, 163, + /* 800 */ 0, 179, 180, 181, 0, 169, 0, 0, 172, 34, + /* 810 */ 0, 161, 176, 163, 41, 179, 180, 181, 0, 169, + /* 820 */ 0, 34, 172, 29, 27, 161, 176, 163, 0, 179, + /* 830 */ 180, 181, 0, 169, 0, 0, 172, 21, 0, 0, + /* 840 */ 176, 0, 21, 179, 180, 181, 94, 0, 161, 60, + /* 850 */ 163, 34, 89, 68, 146, 119, 169, 119, 60, 172, + /* 860 */ 61, 60, 161, 176, 163, 60, 179, 180, 181, 161, + /* 870 */ 169, 68, 29, 172, 61, 61, 19, 176, 113, 68, + /* 880 */ 179, 180, 181, 61, 27, 60, 119, 68, 61, 181, + /* 890 */ 33, 67, 61, 36, 68, 4, 2, 67, 61, 191, + /* 900 */ 192, 193, 29, 195, 68, 29, 12, 13, 14, 15, + /* 910 */ 16, 2, 67, 29, 68, 29, 59, 29, 29, 62, + /* 920 */ 2, 12, 13, 14, 15, 16, 67, 61, 60, 12, + /* 930 */ 13, 14, 15, 16, 101, 60, 92, 0, 61, 61, + /* 940 */ 60, 60, 60, 89, 34, 60, 89, 21, 65, 29, + /* 950 */ 93, 29, 60, 29, 67, 81, 61, 67, 60, 66, + /* 960 */ 61, 60, 29, 61, 60, 29, 61, 60, 29, 61, + /* 970 */ 21, 60, 60, 60, 29, 69, 29, 81, 61, 21, + /* 980 */ 40, 81, 41, 29, 81, 29, 29, 21, 29, 29, + /* 990 */ 29, 29, 29, 29, 29, 0, 29, 29, 29, 29, + /* 1000 */ 29, 29, 29, 27, 0, 0, 29, 28, 34, 0, + /* 1010 */ 21, 20, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1020 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1030 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1040 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1050 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1060 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1070 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1080 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1090 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1100 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1110 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1120 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1130 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1140 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1150 */ 220, 220, 220, }; -#define YY_SHIFT_COUNT (312) +#define YY_SHIFT_COUNT (332) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (960) +#define YY_SHIFT_MAX (1009) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 393, 282, 305, 342, 342, 342, 342, 374, 342, 342, - /* 10 */ 115, 454, 484, 460, 454, 454, 454, 454, 454, 454, + /* 0 */ 336, 238, 311, 352, 352, 352, 352, 326, 352, 352, + /* 10 */ 70, 454, 495, 441, 454, 454, 454, 454, 454, 454, /* 20 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 30 */ 454, 454, 454, 7, 7, 7, 351, 351, 40, 40, - /* 40 */ 20, 58, 127, 127, 63, 165, 58, 40, 40, 58, - /* 50 */ 40, 58, 58, 58, 40, 184, 0, 13, 13, 351, - /* 60 */ 317, 168, 134, 134, 134, 198, 165, 58, 58, 197, - /* 70 */ 54, 648, 78, 46, 65, 227, 309, 256, 278, 256, - /* 80 */ 329, 236, 386, 412, 20, 412, 20, 446, 446, 469, - /* 90 */ 471, 473, 384, 401, 433, 384, 401, 433, 432, 438, - /* 100 */ 452, 456, 468, 469, 557, 482, 467, 475, 493, 563, - /* 110 */ 58, 401, 433, 433, 401, 433, 543, 469, 471, 197, - /* 120 */ 184, 469, 577, 412, 184, 446, 963, 963, 963, 30, - /* 130 */ 654, 496, 682, 167, 213, 315, 315, 315, 315, 315, - /* 140 */ 315, 315, 335, 449, 283, 137, 201, 201, 201, 201, - /* 150 */ 389, 193, 345, 346, 396, 323, 31, 382, 395, 330, - /* 160 */ 418, 461, 466, 479, 490, 492, 525, 528, 545, 548, - /* 170 */ 551, 580, 286, 689, 692, 703, 706, 644, 634, 707, - /* 180 */ 714, 718, 719, 720, 721, 722, 724, 684, 727, 728, - /* 190 */ 730, 731, 736, 717, 739, 726, 729, 740, 685, 716, - /* 200 */ 662, 688, 690, 641, 699, 693, 701, 704, 705, 710, - /* 210 */ 708, 715, 738, 702, 711, 725, 712, 661, 723, 734, - /* 220 */ 737, 669, 732, 741, 742, 743, 664, 783, 762, 768, - /* 230 */ 769, 772, 780, 781, 811, 735, 748, 755, 757, 758, - /* 240 */ 760, 761, 759, 764, 745, 775, 828, 798, 752, 785, - /* 250 */ 782, 784, 786, 827, 790, 792, 800, 830, 834, 804, - /* 260 */ 805, 836, 807, 809, 843, 816, 819, 853, 823, 824, - /* 270 */ 857, 829, 813, 815, 822, 825, 884, 839, 849, 854, - /* 280 */ 887, 888, 897, 878, 880, 893, 894, 896, 899, 900, - /* 290 */ 905, 907, 916, 909, 910, 911, 913, 914, 917, 919, - /* 300 */ 920, 924, 926, 925, 918, 921, 956, 928, 930, 959, - /* 310 */ 960, 940, 942, + /* 30 */ 454, 454, 454, 161, 161, 161, 185, 444, 444, 83, + /* 40 */ 83, 207, 141, 191, 191, 67, 201, 141, 83, 83, + /* 50 */ 141, 83, 141, 141, 141, 83, 236, 0, 13, 13, + /* 60 */ 444, 35, 214, 218, 218, 218, 345, 201, 141, 141, + /* 70 */ 158, 78, 143, 82, 251, 151, 39, 239, 316, 354, + /* 80 */ 316, 19, 343, 387, 465, 482, 207, 486, 496, 207, + /* 90 */ 465, 207, 537, 465, 537, 482, 236, 486, 496, 563, + /* 100 */ 492, 501, 533, 492, 501, 533, 521, 530, 547, 558, + /* 110 */ 567, 486, 651, 575, 571, 556, 573, 654, 141, 501, + /* 120 */ 533, 533, 501, 533, 645, 486, 496, 158, 236, 486, + /* 130 */ 693, 465, 236, 537, 1012, 1012, 1012, 1012, 30, 89, + /* 140 */ 586, 857, 894, 909, 917, 113, 113, 113, 113, 113, + /* 150 */ 113, 113, 159, 614, 288, 219, 77, 77, 77, 77, + /* 160 */ 424, 433, 366, 403, 416, 504, 353, 328, 365, 421, + /* 170 */ 448, 434, 455, 443, 498, 509, 512, 515, 534, 543, + /* 180 */ 548, 623, 638, 137, 764, 778, 779, 781, 726, 719, + /* 190 */ 790, 792, 793, 795, 796, 800, 804, 806, 807, 775, + /* 200 */ 810, 773, 818, 820, 794, 797, 787, 828, 832, 834, + /* 210 */ 835, 816, 838, 821, 839, 841, 752, 847, 789, 817, + /* 220 */ 763, 785, 803, 736, 799, 811, 813, 798, 801, 814, + /* 230 */ 805, 822, 843, 819, 824, 825, 826, 738, 827, 831, + /* 240 */ 830, 765, 836, 845, 837, 846, 767, 891, 873, 876, + /* 250 */ 884, 886, 888, 889, 918, 833, 859, 866, 868, 875, + /* 260 */ 877, 878, 880, 881, 844, 882, 937, 910, 854, 885, + /* 270 */ 883, 887, 890, 926, 892, 893, 895, 920, 922, 898, + /* 280 */ 899, 924, 901, 902, 933, 904, 905, 936, 907, 908, + /* 290 */ 939, 911, 874, 896, 900, 903, 949, 906, 912, 913, + /* 300 */ 945, 947, 958, 941, 940, 954, 956, 957, 959, 960, + /* 310 */ 961, 962, 966, 963, 964, 965, 967, 968, 969, 970, + /* 320 */ 971, 972, 995, 973, 976, 974, 1004, 977, 979, 1005, + /* 330 */ 1009, 989, 991, }; -#define YY_REDUCE_COUNT (128) -#define YY_REDUCE_MIN (-182) -#define YY_REDUCE_MAX (773) +#define YY_REDUCE_COUNT (137) +#define YY_REDUCE_MIN (-162) +#define YY_REDUCE_MAX (708) static const short yy_reduce_ofst[] = { - /* 0 */ 87, -18, 26, 73, -129, 102, 130, 179, 248, 280, - /* 10 */ 29, 316, 397, 364, 423, 443, 465, 485, 498, 531, - /* 20 */ 555, 575, 595, 615, 628, 652, 665, 678, 700, 713, - /* 30 */ 733, 753, 773, 709, 76, 439, -157, -150, -140, -139, - /* 40 */ -111, -127, -159, -116, -155, -107, -14, 4, 129, -94, - /* 50 */ 214, 171, 28, 232, 219, -1, -86, -86, -86, -164, - /* 60 */ -120, -35, -123, 1, 34, 147, 135, 162, 37, 118, - /* 70 */ -161, 148, -182, 92, 120, 195, 207, 230, 230, 230, - /* 80 */ 273, 229, 244, 299, 308, 307, 324, 339, 341, 332, - /* 90 */ 352, 343, 319, 354, 377, 340, 383, 394, 361, 365, - /* 100 */ 370, 388, 230, 413, 415, 411, 390, 398, 404, 448, - /* 110 */ 273, 457, 470, 472, 477, 481, 486, 494, 500, 497, - /* 120 */ 491, 495, 505, 522, 524, 530, 535, 537, 536, + /* 0 */ 90, 14, 54, -117, 76, 105, 134, 187, 234, 256, + /* 10 */ 265, 318, 349, 384, 406, 427, 449, 463, 477, 491, + /* 20 */ 517, 531, 552, 566, 580, 594, 608, 622, 636, 650, + /* 30 */ 664, 687, 701, 527, -144, 708, 386, -158, -138, -142, + /* 40 */ -140, -116, -155, -139, 7, -27, -114, -127, 59, 133, + /* 50 */ 16, 150, 41, 144, 48, 180, -111, -17, -17, -17, + /* 60 */ 107, 200, 160, 50, 193, 195, 224, 222, 237, -162, + /* 70 */ 250, 116, 182, 119, 173, 215, 296, 267, 263, 263, + /* 80 */ 263, 315, 274, 292, 363, 369, 371, 383, 380, 400, + /* 90 */ 408, 410, 420, 425, 430, 407, 453, 428, 451, 422, + /* 100 */ 412, 457, 464, 426, 471, 478, 450, 458, 459, 468, + /* 110 */ 263, 516, 508, 506, 485, 487, 503, 538, 315, 555, + /* 120 */ 557, 561, 564, 568, 572, 579, 578, 596, 603, 590, + /* 130 */ 597, 612, 617, 625, 618, 616, 620, 629, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 10 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 20 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 30 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 40 */ 753, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 50 */ 728, 728, 728, 728, 728, 751, 728, 898, 728, 728, - /* 60 */ 728, 753, 909, 909, 909, 751, 728, 728, 728, 816, - /* 70 */ 728, 728, 973, 728, 933, 728, 925, 901, 915, 902, - /* 80 */ 728, 958, 918, 728, 753, 728, 753, 728, 728, 728, - /* 90 */ 728, 728, 940, 938, 728, 940, 938, 728, 952, 948, - /* 100 */ 931, 929, 915, 728, 728, 728, 976, 964, 960, 728, - /* 110 */ 728, 938, 728, 728, 938, 728, 829, 728, 728, 728, - /* 120 */ 751, 728, 785, 728, 751, 728, 819, 819, 754, 728, - /* 130 */ 728, 728, 728, 728, 728, 870, 951, 950, 869, 875, - /* 140 */ 874, 873, 728, 728, 728, 728, 864, 865, 863, 862, - /* 150 */ 728, 728, 728, 728, 899, 728, 961, 965, 728, 728, - /* 160 */ 728, 850, 728, 728, 728, 728, 728, 728, 728, 728, - /* 170 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 180 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 190 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 200 */ 728, 922, 932, 728, 728, 728, 728, 728, 728, 728, - /* 210 */ 728, 728, 728, 728, 850, 728, 949, 728, 908, 904, - /* 220 */ 728, 728, 900, 728, 728, 959, 728, 728, 728, 728, - /* 230 */ 728, 728, 728, 728, 894, 728, 728, 728, 728, 728, - /* 240 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 250 */ 728, 849, 728, 728, 728, 728, 728, 728, 728, 813, - /* 260 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 270 */ 728, 728, 798, 796, 795, 794, 728, 791, 728, 728, - /* 280 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 290 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 300 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 310 */ 728, 728, 728, + /* 0 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 10 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 20 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 30 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 40 */ 756, 783, 756, 756, 756, 756, 756, 756, 756, 756, + /* 50 */ 756, 756, 756, 756, 756, 756, 781, 756, 933, 756, + /* 60 */ 756, 756, 783, 944, 944, 944, 781, 756, 756, 756, + /* 70 */ 846, 756, 756, 1008, 756, 968, 756, 960, 936, 950, + /* 80 */ 937, 756, 993, 953, 756, 756, 783, 756, 756, 783, + /* 90 */ 756, 783, 756, 756, 756, 756, 781, 756, 756, 756, + /* 100 */ 975, 973, 756, 975, 973, 756, 987, 983, 966, 964, + /* 110 */ 950, 756, 756, 756, 1011, 999, 995, 756, 756, 973, + /* 120 */ 756, 756, 973, 756, 860, 756, 756, 756, 781, 756, + /* 130 */ 815, 756, 781, 756, 784, 849, 849, 784, 756, 756, + /* 140 */ 756, 756, 756, 756, 756, 905, 986, 985, 904, 910, + /* 150 */ 909, 908, 756, 756, 756, 756, 899, 900, 898, 897, + /* 160 */ 756, 756, 756, 756, 756, 934, 756, 996, 1000, 756, + /* 170 */ 756, 756, 884, 756, 756, 756, 756, 756, 756, 756, + /* 180 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 190 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 200 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 210 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 220 */ 756, 957, 967, 756, 756, 756, 756, 756, 756, 756, + /* 230 */ 756, 756, 756, 756, 884, 756, 984, 756, 943, 939, + /* 240 */ 756, 756, 935, 756, 756, 994, 756, 756, 756, 756, + /* 250 */ 756, 756, 756, 756, 929, 756, 756, 756, 756, 756, + /* 260 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 270 */ 756, 883, 756, 756, 756, 756, 756, 756, 756, 843, + /* 280 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 290 */ 756, 756, 828, 826, 825, 824, 756, 821, 756, 756, + /* 300 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 310 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 320 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 330 */ 756, 756, 756, }; /********** End of lemon-generated parsing tables *****************************/ @@ -706,131 +721,133 @@ static const char *const yyTokenName[] = { /* 90 */ "FULLTEXT", /* 91 */ "FUNCTION", /* 92 */ "INTERVAL", - /* 93 */ "MNODES", - /* 94 */ "NK_FLOAT", - /* 95 */ "NK_BOOL", - /* 96 */ "NK_VARIABLE", - /* 97 */ "BETWEEN", - /* 98 */ "IS", - /* 99 */ "NULL", - /* 100 */ "NK_LT", - /* 101 */ "NK_GT", - /* 102 */ "NK_LE", - /* 103 */ "NK_GE", - /* 104 */ "NK_NE", - /* 105 */ "NK_EQ", - /* 106 */ "LIKE", - /* 107 */ "MATCH", - /* 108 */ "NMATCH", - /* 109 */ "IN", - /* 110 */ "FROM", - /* 111 */ "AS", - /* 112 */ "JOIN", - /* 113 */ "INNER", - /* 114 */ "SELECT", - /* 115 */ "DISTINCT", - /* 116 */ "WHERE", - /* 117 */ "PARTITION", - /* 118 */ "BY", - /* 119 */ "SESSION", - /* 120 */ "STATE_WINDOW", - /* 121 */ "SLIDING", - /* 122 */ "FILL", - /* 123 */ "VALUE", - /* 124 */ "NONE", - /* 125 */ "PREV", - /* 126 */ "LINEAR", - /* 127 */ "NEXT", - /* 128 */ "GROUP", - /* 129 */ "HAVING", - /* 130 */ "ORDER", - /* 131 */ "SLIMIT", - /* 132 */ "SOFFSET", - /* 133 */ "LIMIT", - /* 134 */ "OFFSET", - /* 135 */ "ASC", - /* 136 */ "DESC", - /* 137 */ "NULLS", - /* 138 */ "FIRST", - /* 139 */ "LAST", - /* 140 */ "cmd", - /* 141 */ "user_name", - /* 142 */ "dnode_endpoint", - /* 143 */ "dnode_host_name", - /* 144 */ "not_exists_opt", - /* 145 */ "db_name", - /* 146 */ "db_options", - /* 147 */ "exists_opt", - /* 148 */ "full_table_name", - /* 149 */ "column_def_list", - /* 150 */ "tags_def_opt", - /* 151 */ "table_options", - /* 152 */ "multi_create_clause", - /* 153 */ "tags_def", - /* 154 */ "multi_drop_clause", - /* 155 */ "create_subtable_clause", - /* 156 */ "specific_tags_opt", - /* 157 */ "literal_list", - /* 158 */ "drop_table_clause", - /* 159 */ "col_name_list", - /* 160 */ "table_name", - /* 161 */ "column_def", - /* 162 */ "column_name", - /* 163 */ "type_name", - /* 164 */ "col_name", - /* 165 */ "index_name", - /* 166 */ "index_options", - /* 167 */ "func_list", - /* 168 */ "duration_literal", - /* 169 */ "sliding_opt", - /* 170 */ "func", - /* 171 */ "function_name", - /* 172 */ "expression_list", - /* 173 */ "query_expression", - /* 174 */ "literal", - /* 175 */ "table_alias", - /* 176 */ "column_alias", - /* 177 */ "expression", - /* 178 */ "column_reference", - /* 179 */ "subquery", - /* 180 */ "predicate", - /* 181 */ "compare_op", - /* 182 */ "in_op", - /* 183 */ "in_predicate_value", - /* 184 */ "boolean_value_expression", - /* 185 */ "boolean_primary", - /* 186 */ "common_expression", - /* 187 */ "from_clause", - /* 188 */ "table_reference_list", - /* 189 */ "table_reference", - /* 190 */ "table_primary", - /* 191 */ "joined_table", - /* 192 */ "alias_opt", - /* 193 */ "parenthesized_joined_table", - /* 194 */ "join_type", - /* 195 */ "search_condition", - /* 196 */ "query_specification", - /* 197 */ "set_quantifier_opt", - /* 198 */ "select_list", - /* 199 */ "where_clause_opt", - /* 200 */ "partition_by_clause_opt", - /* 201 */ "twindow_clause_opt", - /* 202 */ "group_by_clause_opt", - /* 203 */ "having_clause_opt", - /* 204 */ "select_sublist", - /* 205 */ "select_item", - /* 206 */ "fill_opt", - /* 207 */ "fill_mode", - /* 208 */ "group_by_list", - /* 209 */ "query_expression_body", - /* 210 */ "order_by_clause_opt", - /* 211 */ "slimit_clause_opt", - /* 212 */ "limit_clause_opt", - /* 213 */ "query_primary", - /* 214 */ "sort_specification_list", - /* 215 */ "sort_specification", - /* 216 */ "ordering_specification_opt", - /* 217 */ "null_ordering_opt", + /* 93 */ "TOPIC", + /* 94 */ "AS", + /* 95 */ "MNODES", + /* 96 */ "NK_FLOAT", + /* 97 */ "NK_BOOL", + /* 98 */ "NK_VARIABLE", + /* 99 */ "BETWEEN", + /* 100 */ "IS", + /* 101 */ "NULL", + /* 102 */ "NK_LT", + /* 103 */ "NK_GT", + /* 104 */ "NK_LE", + /* 105 */ "NK_GE", + /* 106 */ "NK_NE", + /* 107 */ "NK_EQ", + /* 108 */ "LIKE", + /* 109 */ "MATCH", + /* 110 */ "NMATCH", + /* 111 */ "IN", + /* 112 */ "FROM", + /* 113 */ "JOIN", + /* 114 */ "INNER", + /* 115 */ "SELECT", + /* 116 */ "DISTINCT", + /* 117 */ "WHERE", + /* 118 */ "PARTITION", + /* 119 */ "BY", + /* 120 */ "SESSION", + /* 121 */ "STATE_WINDOW", + /* 122 */ "SLIDING", + /* 123 */ "FILL", + /* 124 */ "VALUE", + /* 125 */ "NONE", + /* 126 */ "PREV", + /* 127 */ "LINEAR", + /* 128 */ "NEXT", + /* 129 */ "GROUP", + /* 130 */ "HAVING", + /* 131 */ "ORDER", + /* 132 */ "SLIMIT", + /* 133 */ "SOFFSET", + /* 134 */ "LIMIT", + /* 135 */ "OFFSET", + /* 136 */ "ASC", + /* 137 */ "DESC", + /* 138 */ "NULLS", + /* 139 */ "FIRST", + /* 140 */ "LAST", + /* 141 */ "cmd", + /* 142 */ "user_name", + /* 143 */ "dnode_endpoint", + /* 144 */ "dnode_host_name", + /* 145 */ "not_exists_opt", + /* 146 */ "db_name", + /* 147 */ "db_options", + /* 148 */ "exists_opt", + /* 149 */ "full_table_name", + /* 150 */ "column_def_list", + /* 151 */ "tags_def_opt", + /* 152 */ "table_options", + /* 153 */ "multi_create_clause", + /* 154 */ "tags_def", + /* 155 */ "multi_drop_clause", + /* 156 */ "create_subtable_clause", + /* 157 */ "specific_tags_opt", + /* 158 */ "literal_list", + /* 159 */ "drop_table_clause", + /* 160 */ "col_name_list", + /* 161 */ "table_name", + /* 162 */ "column_def", + /* 163 */ "column_name", + /* 164 */ "type_name", + /* 165 */ "col_name", + /* 166 */ "index_name", + /* 167 */ "index_options", + /* 168 */ "func_list", + /* 169 */ "duration_literal", + /* 170 */ "sliding_opt", + /* 171 */ "func", + /* 172 */ "function_name", + /* 173 */ "expression_list", + /* 174 */ "topic_name", + /* 175 */ "query_expression", + /* 176 */ "literal", + /* 177 */ "table_alias", + /* 178 */ "column_alias", + /* 179 */ "expression", + /* 180 */ "column_reference", + /* 181 */ "subquery", + /* 182 */ "predicate", + /* 183 */ "compare_op", + /* 184 */ "in_op", + /* 185 */ "in_predicate_value", + /* 186 */ "boolean_value_expression", + /* 187 */ "boolean_primary", + /* 188 */ "common_expression", + /* 189 */ "from_clause", + /* 190 */ "table_reference_list", + /* 191 */ "table_reference", + /* 192 */ "table_primary", + /* 193 */ "joined_table", + /* 194 */ "alias_opt", + /* 195 */ "parenthesized_joined_table", + /* 196 */ "join_type", + /* 197 */ "search_condition", + /* 198 */ "query_specification", + /* 199 */ "set_quantifier_opt", + /* 200 */ "select_list", + /* 201 */ "where_clause_opt", + /* 202 */ "partition_by_clause_opt", + /* 203 */ "twindow_clause_opt", + /* 204 */ "group_by_clause_opt", + /* 205 */ "having_clause_opt", + /* 206 */ "select_sublist", + /* 207 */ "select_item", + /* 208 */ "fill_opt", + /* 209 */ "fill_mode", + /* 210 */ "group_by_list", + /* 211 */ "query_expression_body", + /* 212 */ "order_by_clause_opt", + /* 213 */ "slimit_clause_opt", + /* 214 */ "limit_clause_opt", + /* 215 */ "query_primary", + /* 216 */ "sort_specification_list", + /* 217 */ "sort_specification", + /* 218 */ "ordering_specification_opt", + /* 219 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -852,240 +869,247 @@ static const char *const yyRuleName[] = { /* 11 */ "dnode_host_name ::= NK_ID", /* 12 */ "dnode_host_name ::= NK_IPTOKEN", /* 13 */ "cmd ::= CREATE QNODE ON DNODE NK_INTEGER", - /* 14 */ "cmd ::= SHOW QNODES", - /* 15 */ "cmd ::= CREATE DATABASE not_exists_opt db_name db_options", - /* 16 */ "cmd ::= DROP DATABASE exists_opt db_name", - /* 17 */ "cmd ::= SHOW DATABASES", - /* 18 */ "cmd ::= USE db_name", - /* 19 */ "not_exists_opt ::= IF NOT EXISTS", - /* 20 */ "not_exists_opt ::=", - /* 21 */ "exists_opt ::= IF EXISTS", - /* 22 */ "exists_opt ::=", - /* 23 */ "db_options ::=", - /* 24 */ "db_options ::= db_options BLOCKS NK_INTEGER", - /* 25 */ "db_options ::= db_options CACHE NK_INTEGER", - /* 26 */ "db_options ::= db_options CACHELAST NK_INTEGER", - /* 27 */ "db_options ::= db_options COMP NK_INTEGER", - /* 28 */ "db_options ::= db_options DAYS NK_INTEGER", - /* 29 */ "db_options ::= db_options FSYNC NK_INTEGER", - /* 30 */ "db_options ::= db_options MAXROWS NK_INTEGER", - /* 31 */ "db_options ::= db_options MINROWS NK_INTEGER", - /* 32 */ "db_options ::= db_options KEEP NK_INTEGER", - /* 33 */ "db_options ::= db_options PRECISION NK_STRING", - /* 34 */ "db_options ::= db_options QUORUM NK_INTEGER", - /* 35 */ "db_options ::= db_options REPLICA NK_INTEGER", - /* 36 */ "db_options ::= db_options TTL NK_INTEGER", - /* 37 */ "db_options ::= db_options WAL NK_INTEGER", - /* 38 */ "db_options ::= db_options VGROUPS NK_INTEGER", - /* 39 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", - /* 40 */ "db_options ::= db_options STREAM_MODE NK_INTEGER", - /* 41 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", - /* 42 */ "cmd ::= CREATE TABLE multi_create_clause", - /* 43 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", - /* 44 */ "cmd ::= DROP TABLE multi_drop_clause", - /* 45 */ "cmd ::= DROP STABLE exists_opt full_table_name", - /* 46 */ "cmd ::= SHOW TABLES", - /* 47 */ "cmd ::= SHOW STABLES", - /* 48 */ "multi_create_clause ::= create_subtable_clause", - /* 49 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 50 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP", - /* 51 */ "multi_drop_clause ::= drop_table_clause", - /* 52 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", - /* 53 */ "drop_table_clause ::= exists_opt full_table_name", - /* 54 */ "specific_tags_opt ::=", - /* 55 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", - /* 56 */ "full_table_name ::= table_name", - /* 57 */ "full_table_name ::= db_name NK_DOT table_name", - /* 58 */ "column_def_list ::= column_def", - /* 59 */ "column_def_list ::= column_def_list NK_COMMA column_def", - /* 60 */ "column_def ::= column_name type_name", - /* 61 */ "column_def ::= column_name type_name COMMENT NK_STRING", - /* 62 */ "type_name ::= BOOL", - /* 63 */ "type_name ::= TINYINT", - /* 64 */ "type_name ::= SMALLINT", - /* 65 */ "type_name ::= INT", - /* 66 */ "type_name ::= INTEGER", - /* 67 */ "type_name ::= BIGINT", - /* 68 */ "type_name ::= FLOAT", - /* 69 */ "type_name ::= DOUBLE", - /* 70 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 71 */ "type_name ::= TIMESTAMP", - /* 72 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 73 */ "type_name ::= TINYINT UNSIGNED", - /* 74 */ "type_name ::= SMALLINT UNSIGNED", - /* 75 */ "type_name ::= INT UNSIGNED", - /* 76 */ "type_name ::= BIGINT UNSIGNED", - /* 77 */ "type_name ::= JSON", - /* 78 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 79 */ "type_name ::= MEDIUMBLOB", - /* 80 */ "type_name ::= BLOB", - /* 81 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 82 */ "type_name ::= DECIMAL", - /* 83 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 84 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 85 */ "tags_def_opt ::=", - /* 86 */ "tags_def_opt ::= tags_def", - /* 87 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", - /* 88 */ "table_options ::=", - /* 89 */ "table_options ::= table_options COMMENT NK_STRING", - /* 90 */ "table_options ::= table_options KEEP NK_INTEGER", - /* 91 */ "table_options ::= table_options TTL NK_INTEGER", - /* 92 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 93 */ "col_name_list ::= col_name", - /* 94 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 95 */ "col_name ::= column_name", - /* 96 */ "cmd ::= CREATE SMA INDEX index_name ON table_name index_options", - /* 97 */ "cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP", - /* 98 */ "index_options ::=", - /* 99 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", - /* 100 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", - /* 101 */ "func_list ::= func", - /* 102 */ "func_list ::= func_list NK_COMMA func", - /* 103 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 104 */ "cmd ::= SHOW VGROUPS", - /* 105 */ "cmd ::= SHOW db_name NK_DOT VGROUPS", - /* 106 */ "cmd ::= SHOW MNODES", - /* 107 */ "cmd ::= query_expression", - /* 108 */ "literal ::= NK_INTEGER", - /* 109 */ "literal ::= NK_FLOAT", - /* 110 */ "literal ::= NK_STRING", - /* 111 */ "literal ::= NK_BOOL", - /* 112 */ "literal ::= TIMESTAMP NK_STRING", - /* 113 */ "literal ::= duration_literal", - /* 114 */ "duration_literal ::= NK_VARIABLE", - /* 115 */ "literal_list ::= literal", - /* 116 */ "literal_list ::= literal_list NK_COMMA literal", - /* 117 */ "db_name ::= NK_ID", - /* 118 */ "table_name ::= NK_ID", - /* 119 */ "column_name ::= NK_ID", - /* 120 */ "function_name ::= NK_ID", - /* 121 */ "table_alias ::= NK_ID", - /* 122 */ "column_alias ::= NK_ID", - /* 123 */ "user_name ::= NK_ID", - /* 124 */ "index_name ::= NK_ID", - /* 125 */ "expression ::= literal", - /* 126 */ "expression ::= column_reference", - /* 127 */ "expression ::= function_name NK_LP expression_list NK_RP", - /* 128 */ "expression ::= function_name NK_LP NK_STAR NK_RP", - /* 129 */ "expression ::= subquery", - /* 130 */ "expression ::= NK_LP expression NK_RP", - /* 131 */ "expression ::= NK_PLUS expression", - /* 132 */ "expression ::= NK_MINUS expression", - /* 133 */ "expression ::= expression NK_PLUS expression", - /* 134 */ "expression ::= expression NK_MINUS expression", - /* 135 */ "expression ::= expression NK_STAR expression", - /* 136 */ "expression ::= expression NK_SLASH expression", - /* 137 */ "expression ::= expression NK_REM expression", - /* 138 */ "expression_list ::= expression", - /* 139 */ "expression_list ::= expression_list NK_COMMA expression", - /* 140 */ "column_reference ::= column_name", - /* 141 */ "column_reference ::= table_name NK_DOT column_name", - /* 142 */ "predicate ::= expression compare_op expression", - /* 143 */ "predicate ::= expression BETWEEN expression AND expression", - /* 144 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 145 */ "predicate ::= expression IS NULL", - /* 146 */ "predicate ::= expression IS NOT NULL", - /* 147 */ "predicate ::= expression in_op in_predicate_value", - /* 148 */ "compare_op ::= NK_LT", - /* 149 */ "compare_op ::= NK_GT", - /* 150 */ "compare_op ::= NK_LE", - /* 151 */ "compare_op ::= NK_GE", - /* 152 */ "compare_op ::= NK_NE", - /* 153 */ "compare_op ::= NK_EQ", - /* 154 */ "compare_op ::= LIKE", - /* 155 */ "compare_op ::= NOT LIKE", - /* 156 */ "compare_op ::= MATCH", - /* 157 */ "compare_op ::= NMATCH", - /* 158 */ "in_op ::= IN", - /* 159 */ "in_op ::= NOT IN", - /* 160 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 161 */ "boolean_value_expression ::= boolean_primary", - /* 162 */ "boolean_value_expression ::= NOT boolean_primary", - /* 163 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 164 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 165 */ "boolean_primary ::= predicate", - /* 166 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 167 */ "common_expression ::= expression", - /* 168 */ "common_expression ::= boolean_value_expression", - /* 169 */ "from_clause ::= FROM table_reference_list", - /* 170 */ "table_reference_list ::= table_reference", - /* 171 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 172 */ "table_reference ::= table_primary", - /* 173 */ "table_reference ::= joined_table", - /* 174 */ "table_primary ::= table_name alias_opt", - /* 175 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 176 */ "table_primary ::= subquery alias_opt", - /* 177 */ "table_primary ::= parenthesized_joined_table", - /* 178 */ "alias_opt ::=", - /* 179 */ "alias_opt ::= table_alias", - /* 180 */ "alias_opt ::= AS table_alias", - /* 181 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 182 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 183 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 184 */ "join_type ::=", - /* 185 */ "join_type ::= INNER", - /* 186 */ "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", - /* 187 */ "set_quantifier_opt ::=", - /* 188 */ "set_quantifier_opt ::= DISTINCT", - /* 189 */ "set_quantifier_opt ::= ALL", - /* 190 */ "select_list ::= NK_STAR", - /* 191 */ "select_list ::= select_sublist", - /* 192 */ "select_sublist ::= select_item", - /* 193 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 194 */ "select_item ::= common_expression", - /* 195 */ "select_item ::= common_expression column_alias", - /* 196 */ "select_item ::= common_expression AS column_alias", - /* 197 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 198 */ "where_clause_opt ::=", - /* 199 */ "where_clause_opt ::= WHERE search_condition", - /* 200 */ "partition_by_clause_opt ::=", - /* 201 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 202 */ "twindow_clause_opt ::=", - /* 203 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP", - /* 204 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", - /* 205 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 206 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 207 */ "sliding_opt ::=", - /* 208 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 209 */ "fill_opt ::=", - /* 210 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 211 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 212 */ "fill_mode ::= NONE", - /* 213 */ "fill_mode ::= PREV", - /* 214 */ "fill_mode ::= NULL", - /* 215 */ "fill_mode ::= LINEAR", - /* 216 */ "fill_mode ::= NEXT", - /* 217 */ "group_by_clause_opt ::=", - /* 218 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 219 */ "group_by_list ::= expression", - /* 220 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 221 */ "having_clause_opt ::=", - /* 222 */ "having_clause_opt ::= HAVING search_condition", - /* 223 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 224 */ "query_expression_body ::= query_primary", - /* 225 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 226 */ "query_primary ::= query_specification", - /* 227 */ "order_by_clause_opt ::=", - /* 228 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 229 */ "slimit_clause_opt ::=", - /* 230 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 231 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 232 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 233 */ "limit_clause_opt ::=", - /* 234 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 235 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 236 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 237 */ "subquery ::= NK_LP query_expression NK_RP", - /* 238 */ "search_condition ::= common_expression", - /* 239 */ "sort_specification_list ::= sort_specification", - /* 240 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 241 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 242 */ "ordering_specification_opt ::=", - /* 243 */ "ordering_specification_opt ::= ASC", - /* 244 */ "ordering_specification_opt ::= DESC", - /* 245 */ "null_ordering_opt ::=", - /* 246 */ "null_ordering_opt ::= NULLS FIRST", - /* 247 */ "null_ordering_opt ::= NULLS LAST", + /* 14 */ "cmd ::= DROP QNODE ON DNODE NK_INTEGER", + /* 15 */ "cmd ::= SHOW QNODES", + /* 16 */ "cmd ::= CREATE DATABASE not_exists_opt db_name db_options", + /* 17 */ "cmd ::= DROP DATABASE exists_opt db_name", + /* 18 */ "cmd ::= SHOW DATABASES", + /* 19 */ "cmd ::= USE db_name", + /* 20 */ "cmd ::= ALTER DATABASE db_name db_options", + /* 21 */ "not_exists_opt ::= IF NOT EXISTS", + /* 22 */ "not_exists_opt ::=", + /* 23 */ "exists_opt ::= IF EXISTS", + /* 24 */ "exists_opt ::=", + /* 25 */ "db_options ::=", + /* 26 */ "db_options ::= db_options BLOCKS NK_INTEGER", + /* 27 */ "db_options ::= db_options CACHE NK_INTEGER", + /* 28 */ "db_options ::= db_options CACHELAST NK_INTEGER", + /* 29 */ "db_options ::= db_options COMP NK_INTEGER", + /* 30 */ "db_options ::= db_options DAYS NK_INTEGER", + /* 31 */ "db_options ::= db_options FSYNC NK_INTEGER", + /* 32 */ "db_options ::= db_options MAXROWS NK_INTEGER", + /* 33 */ "db_options ::= db_options MINROWS NK_INTEGER", + /* 34 */ "db_options ::= db_options KEEP NK_INTEGER", + /* 35 */ "db_options ::= db_options PRECISION NK_STRING", + /* 36 */ "db_options ::= db_options QUORUM NK_INTEGER", + /* 37 */ "db_options ::= db_options REPLICA NK_INTEGER", + /* 38 */ "db_options ::= db_options TTL NK_INTEGER", + /* 39 */ "db_options ::= db_options WAL NK_INTEGER", + /* 40 */ "db_options ::= db_options VGROUPS NK_INTEGER", + /* 41 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", + /* 42 */ "db_options ::= db_options STREAM_MODE NK_INTEGER", + /* 43 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", + /* 44 */ "cmd ::= CREATE TABLE multi_create_clause", + /* 45 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", + /* 46 */ "cmd ::= DROP TABLE multi_drop_clause", + /* 47 */ "cmd ::= DROP STABLE exists_opt full_table_name", + /* 48 */ "cmd ::= SHOW TABLES", + /* 49 */ "cmd ::= SHOW STABLES", + /* 50 */ "multi_create_clause ::= create_subtable_clause", + /* 51 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", + /* 52 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP", + /* 53 */ "multi_drop_clause ::= drop_table_clause", + /* 54 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", + /* 55 */ "drop_table_clause ::= exists_opt full_table_name", + /* 56 */ "specific_tags_opt ::=", + /* 57 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", + /* 58 */ "full_table_name ::= table_name", + /* 59 */ "full_table_name ::= db_name NK_DOT table_name", + /* 60 */ "column_def_list ::= column_def", + /* 61 */ "column_def_list ::= column_def_list NK_COMMA column_def", + /* 62 */ "column_def ::= column_name type_name", + /* 63 */ "column_def ::= column_name type_name COMMENT NK_STRING", + /* 64 */ "type_name ::= BOOL", + /* 65 */ "type_name ::= TINYINT", + /* 66 */ "type_name ::= SMALLINT", + /* 67 */ "type_name ::= INT", + /* 68 */ "type_name ::= INTEGER", + /* 69 */ "type_name ::= BIGINT", + /* 70 */ "type_name ::= FLOAT", + /* 71 */ "type_name ::= DOUBLE", + /* 72 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", + /* 73 */ "type_name ::= TIMESTAMP", + /* 74 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", + /* 75 */ "type_name ::= TINYINT UNSIGNED", + /* 76 */ "type_name ::= SMALLINT UNSIGNED", + /* 77 */ "type_name ::= INT UNSIGNED", + /* 78 */ "type_name ::= BIGINT UNSIGNED", + /* 79 */ "type_name ::= JSON", + /* 80 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", + /* 81 */ "type_name ::= MEDIUMBLOB", + /* 82 */ "type_name ::= BLOB", + /* 83 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", + /* 84 */ "type_name ::= DECIMAL", + /* 85 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", + /* 86 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 87 */ "tags_def_opt ::=", + /* 88 */ "tags_def_opt ::= tags_def", + /* 89 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", + /* 90 */ "table_options ::=", + /* 91 */ "table_options ::= table_options COMMENT NK_STRING", + /* 92 */ "table_options ::= table_options KEEP NK_INTEGER", + /* 93 */ "table_options ::= table_options TTL NK_INTEGER", + /* 94 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 95 */ "col_name_list ::= col_name", + /* 96 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 97 */ "col_name ::= column_name", + /* 98 */ "cmd ::= CREATE SMA INDEX index_name ON table_name index_options", + /* 99 */ "cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP", + /* 100 */ "cmd ::= DROP INDEX index_name ON table_name", + /* 101 */ "index_options ::=", + /* 102 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", + /* 103 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", + /* 104 */ "func_list ::= func", + /* 105 */ "func_list ::= func_list NK_COMMA func", + /* 106 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 107 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", + /* 108 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name", + /* 109 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 110 */ "cmd ::= SHOW VGROUPS", + /* 111 */ "cmd ::= SHOW db_name NK_DOT VGROUPS", + /* 112 */ "cmd ::= SHOW MNODES", + /* 113 */ "cmd ::= query_expression", + /* 114 */ "literal ::= NK_INTEGER", + /* 115 */ "literal ::= NK_FLOAT", + /* 116 */ "literal ::= NK_STRING", + /* 117 */ "literal ::= NK_BOOL", + /* 118 */ "literal ::= TIMESTAMP NK_STRING", + /* 119 */ "literal ::= duration_literal", + /* 120 */ "duration_literal ::= NK_VARIABLE", + /* 121 */ "literal_list ::= literal", + /* 122 */ "literal_list ::= literal_list NK_COMMA literal", + /* 123 */ "db_name ::= NK_ID", + /* 124 */ "table_name ::= NK_ID", + /* 125 */ "column_name ::= NK_ID", + /* 126 */ "function_name ::= NK_ID", + /* 127 */ "table_alias ::= NK_ID", + /* 128 */ "column_alias ::= NK_ID", + /* 129 */ "user_name ::= NK_ID", + /* 130 */ "index_name ::= NK_ID", + /* 131 */ "topic_name ::= NK_ID", + /* 132 */ "expression ::= literal", + /* 133 */ "expression ::= column_reference", + /* 134 */ "expression ::= function_name NK_LP expression_list NK_RP", + /* 135 */ "expression ::= function_name NK_LP NK_STAR NK_RP", + /* 136 */ "expression ::= subquery", + /* 137 */ "expression ::= NK_LP expression NK_RP", + /* 138 */ "expression ::= NK_PLUS expression", + /* 139 */ "expression ::= NK_MINUS expression", + /* 140 */ "expression ::= expression NK_PLUS expression", + /* 141 */ "expression ::= expression NK_MINUS expression", + /* 142 */ "expression ::= expression NK_STAR expression", + /* 143 */ "expression ::= expression NK_SLASH expression", + /* 144 */ "expression ::= expression NK_REM expression", + /* 145 */ "expression_list ::= expression", + /* 146 */ "expression_list ::= expression_list NK_COMMA expression", + /* 147 */ "column_reference ::= column_name", + /* 148 */ "column_reference ::= table_name NK_DOT column_name", + /* 149 */ "predicate ::= expression compare_op expression", + /* 150 */ "predicate ::= expression BETWEEN expression AND expression", + /* 151 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 152 */ "predicate ::= expression IS NULL", + /* 153 */ "predicate ::= expression IS NOT NULL", + /* 154 */ "predicate ::= expression in_op in_predicate_value", + /* 155 */ "compare_op ::= NK_LT", + /* 156 */ "compare_op ::= NK_GT", + /* 157 */ "compare_op ::= NK_LE", + /* 158 */ "compare_op ::= NK_GE", + /* 159 */ "compare_op ::= NK_NE", + /* 160 */ "compare_op ::= NK_EQ", + /* 161 */ "compare_op ::= LIKE", + /* 162 */ "compare_op ::= NOT LIKE", + /* 163 */ "compare_op ::= MATCH", + /* 164 */ "compare_op ::= NMATCH", + /* 165 */ "in_op ::= IN", + /* 166 */ "in_op ::= NOT IN", + /* 167 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 168 */ "boolean_value_expression ::= boolean_primary", + /* 169 */ "boolean_value_expression ::= NOT boolean_primary", + /* 170 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 171 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 172 */ "boolean_primary ::= predicate", + /* 173 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 174 */ "common_expression ::= expression", + /* 175 */ "common_expression ::= boolean_value_expression", + /* 176 */ "from_clause ::= FROM table_reference_list", + /* 177 */ "table_reference_list ::= table_reference", + /* 178 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 179 */ "table_reference ::= table_primary", + /* 180 */ "table_reference ::= joined_table", + /* 181 */ "table_primary ::= table_name alias_opt", + /* 182 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 183 */ "table_primary ::= subquery alias_opt", + /* 184 */ "table_primary ::= parenthesized_joined_table", + /* 185 */ "alias_opt ::=", + /* 186 */ "alias_opt ::= table_alias", + /* 187 */ "alias_opt ::= AS table_alias", + /* 188 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 189 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 190 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 191 */ "join_type ::=", + /* 192 */ "join_type ::= INNER", + /* 193 */ "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", + /* 194 */ "set_quantifier_opt ::=", + /* 195 */ "set_quantifier_opt ::= DISTINCT", + /* 196 */ "set_quantifier_opt ::= ALL", + /* 197 */ "select_list ::= NK_STAR", + /* 198 */ "select_list ::= select_sublist", + /* 199 */ "select_sublist ::= select_item", + /* 200 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 201 */ "select_item ::= common_expression", + /* 202 */ "select_item ::= common_expression column_alias", + /* 203 */ "select_item ::= common_expression AS column_alias", + /* 204 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 205 */ "where_clause_opt ::=", + /* 206 */ "where_clause_opt ::= WHERE search_condition", + /* 207 */ "partition_by_clause_opt ::=", + /* 208 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 209 */ "twindow_clause_opt ::=", + /* 210 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP", + /* 211 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", + /* 212 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 213 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 214 */ "sliding_opt ::=", + /* 215 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 216 */ "fill_opt ::=", + /* 217 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 218 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 219 */ "fill_mode ::= NONE", + /* 220 */ "fill_mode ::= PREV", + /* 221 */ "fill_mode ::= NULL", + /* 222 */ "fill_mode ::= LINEAR", + /* 223 */ "fill_mode ::= NEXT", + /* 224 */ "group_by_clause_opt ::=", + /* 225 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 226 */ "group_by_list ::= expression", + /* 227 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 228 */ "having_clause_opt ::=", + /* 229 */ "having_clause_opt ::= HAVING search_condition", + /* 230 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 231 */ "query_expression_body ::= query_primary", + /* 232 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 233 */ "query_primary ::= query_specification", + /* 234 */ "order_by_clause_opt ::=", + /* 235 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 236 */ "slimit_clause_opt ::=", + /* 237 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 238 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 239 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 240 */ "limit_clause_opt ::=", + /* 241 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 242 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 243 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 244 */ "subquery ::= NK_LP query_expression NK_RP", + /* 245 */ "search_condition ::= common_expression", + /* 246 */ "sort_specification_list ::= sort_specification", + /* 247 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 248 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 249 */ "ordering_specification_opt ::=", + /* 250 */ "ordering_specification_opt ::= ASC", + /* 251 */ "ordering_specification_opt ::= DESC", + /* 252 */ "null_ordering_opt ::=", + /* 253 */ "null_ordering_opt ::= NULLS FIRST", + /* 254 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -1212,120 +1236,121 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 140: /* cmd */ - case 146: /* db_options */ - case 148: /* full_table_name */ - case 151: /* table_options */ - case 155: /* create_subtable_clause */ - case 158: /* drop_table_clause */ - case 161: /* column_def */ - case 164: /* col_name */ - case 166: /* index_options */ - case 168: /* duration_literal */ - case 169: /* sliding_opt */ - case 170: /* func */ - case 173: /* query_expression */ - case 174: /* literal */ - case 177: /* expression */ - case 178: /* column_reference */ - case 179: /* subquery */ - case 180: /* predicate */ - case 183: /* in_predicate_value */ - case 184: /* boolean_value_expression */ - case 185: /* boolean_primary */ - case 186: /* common_expression */ - case 187: /* from_clause */ - case 188: /* table_reference_list */ - case 189: /* table_reference */ - case 190: /* table_primary */ - case 191: /* joined_table */ - case 193: /* parenthesized_joined_table */ - case 195: /* search_condition */ - case 196: /* query_specification */ - case 199: /* where_clause_opt */ - case 201: /* twindow_clause_opt */ - case 203: /* having_clause_opt */ - case 205: /* select_item */ - case 206: /* fill_opt */ - case 209: /* query_expression_body */ - case 211: /* slimit_clause_opt */ - case 212: /* limit_clause_opt */ - case 213: /* query_primary */ - case 215: /* sort_specification */ + case 141: /* cmd */ + case 147: /* db_options */ + case 149: /* full_table_name */ + case 152: /* table_options */ + case 156: /* create_subtable_clause */ + case 159: /* drop_table_clause */ + case 162: /* column_def */ + case 165: /* col_name */ + case 167: /* index_options */ + case 169: /* duration_literal */ + case 170: /* sliding_opt */ + case 171: /* func */ + case 175: /* query_expression */ + case 176: /* literal */ + case 179: /* expression */ + case 180: /* column_reference */ + case 181: /* subquery */ + case 182: /* predicate */ + case 185: /* in_predicate_value */ + case 186: /* boolean_value_expression */ + case 187: /* boolean_primary */ + case 188: /* common_expression */ + case 189: /* from_clause */ + case 190: /* table_reference_list */ + case 191: /* table_reference */ + case 192: /* table_primary */ + case 193: /* joined_table */ + case 195: /* parenthesized_joined_table */ + case 197: /* search_condition */ + case 198: /* query_specification */ + case 201: /* where_clause_opt */ + case 203: /* twindow_clause_opt */ + case 205: /* having_clause_opt */ + case 207: /* select_item */ + case 208: /* fill_opt */ + case 211: /* query_expression_body */ + case 213: /* slimit_clause_opt */ + case 214: /* limit_clause_opt */ + case 215: /* query_primary */ + case 217: /* sort_specification */ { - nodesDestroyNode((yypminor->yy68)); + nodesDestroyNode((yypminor->yy432)); } break; - case 141: /* user_name */ - case 142: /* dnode_endpoint */ - case 143: /* dnode_host_name */ - case 145: /* db_name */ - case 160: /* table_name */ - case 162: /* column_name */ - case 165: /* index_name */ - case 171: /* function_name */ - case 175: /* table_alias */ - case 176: /* column_alias */ - case 192: /* alias_opt */ + case 142: /* user_name */ + case 143: /* dnode_endpoint */ + case 144: /* dnode_host_name */ + case 146: /* db_name */ + case 161: /* table_name */ + case 163: /* column_name */ + case 166: /* index_name */ + case 172: /* function_name */ + case 174: /* topic_name */ + case 177: /* table_alias */ + case 178: /* column_alias */ + case 194: /* alias_opt */ { } break; - case 144: /* not_exists_opt */ - case 147: /* exists_opt */ - case 197: /* set_quantifier_opt */ + case 145: /* not_exists_opt */ + case 148: /* exists_opt */ + case 199: /* set_quantifier_opt */ { } break; - case 149: /* column_def_list */ - case 150: /* tags_def_opt */ - case 152: /* multi_create_clause */ - case 153: /* tags_def */ - case 154: /* multi_drop_clause */ - case 156: /* specific_tags_opt */ - case 157: /* literal_list */ - case 159: /* col_name_list */ - case 167: /* func_list */ - case 172: /* expression_list */ - case 198: /* select_list */ - case 200: /* partition_by_clause_opt */ - case 202: /* group_by_clause_opt */ - case 204: /* select_sublist */ - case 208: /* group_by_list */ - case 210: /* order_by_clause_opt */ - case 214: /* sort_specification_list */ + case 150: /* column_def_list */ + case 151: /* tags_def_opt */ + case 153: /* multi_create_clause */ + case 154: /* tags_def */ + case 155: /* multi_drop_clause */ + case 157: /* specific_tags_opt */ + case 158: /* literal_list */ + case 160: /* col_name_list */ + case 168: /* func_list */ + case 173: /* expression_list */ + case 200: /* select_list */ + case 202: /* partition_by_clause_opt */ + case 204: /* group_by_clause_opt */ + case 206: /* select_sublist */ + case 210: /* group_by_list */ + case 212: /* order_by_clause_opt */ + case 216: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy40)); + nodesDestroyList((yypminor->yy24)); } break; - case 163: /* type_name */ + case 164: /* type_name */ { } break; - case 181: /* compare_op */ - case 182: /* in_op */ + case 183: /* compare_op */ + case 184: /* in_op */ { } break; - case 194: /* join_type */ + case 196: /* join_type */ { } break; - case 207: /* fill_mode */ + case 209: /* fill_mode */ { } break; - case 216: /* ordering_specification_opt */ + case 218: /* ordering_specification_opt */ { } break; - case 217: /* null_ordering_opt */ + case 219: /* null_ordering_opt */ { } @@ -1624,254 +1649,261 @@ 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[] = { - { 140, -5 }, /* (0) cmd ::= CREATE USER user_name PASS NK_STRING */ - { 140, -5 }, /* (1) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 140, -5 }, /* (2) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ - { 140, -3 }, /* (3) cmd ::= DROP USER user_name */ - { 140, -2 }, /* (4) cmd ::= SHOW USERS */ - { 140, -3 }, /* (5) cmd ::= CREATE DNODE dnode_endpoint */ - { 140, -5 }, /* (6) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ - { 140, -3 }, /* (7) cmd ::= DROP DNODE NK_INTEGER */ - { 140, -3 }, /* (8) cmd ::= DROP DNODE dnode_endpoint */ - { 140, -2 }, /* (9) cmd ::= SHOW DNODES */ - { 142, -1 }, /* (10) dnode_endpoint ::= NK_STRING */ - { 143, -1 }, /* (11) dnode_host_name ::= NK_ID */ - { 143, -1 }, /* (12) dnode_host_name ::= NK_IPTOKEN */ - { 140, -5 }, /* (13) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 140, -2 }, /* (14) cmd ::= SHOW QNODES */ - { 140, -5 }, /* (15) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 140, -4 }, /* (16) cmd ::= DROP DATABASE exists_opt db_name */ - { 140, -2 }, /* (17) cmd ::= SHOW DATABASES */ - { 140, -2 }, /* (18) cmd ::= USE db_name */ - { 144, -3 }, /* (19) not_exists_opt ::= IF NOT EXISTS */ - { 144, 0 }, /* (20) not_exists_opt ::= */ - { 147, -2 }, /* (21) exists_opt ::= IF EXISTS */ - { 147, 0 }, /* (22) exists_opt ::= */ - { 146, 0 }, /* (23) db_options ::= */ - { 146, -3 }, /* (24) db_options ::= db_options BLOCKS NK_INTEGER */ - { 146, -3 }, /* (25) db_options ::= db_options CACHE NK_INTEGER */ - { 146, -3 }, /* (26) db_options ::= db_options CACHELAST NK_INTEGER */ - { 146, -3 }, /* (27) db_options ::= db_options COMP NK_INTEGER */ - { 146, -3 }, /* (28) db_options ::= db_options DAYS NK_INTEGER */ - { 146, -3 }, /* (29) db_options ::= db_options FSYNC NK_INTEGER */ - { 146, -3 }, /* (30) db_options ::= db_options MAXROWS NK_INTEGER */ - { 146, -3 }, /* (31) db_options ::= db_options MINROWS NK_INTEGER */ - { 146, -3 }, /* (32) db_options ::= db_options KEEP NK_INTEGER */ - { 146, -3 }, /* (33) db_options ::= db_options PRECISION NK_STRING */ - { 146, -3 }, /* (34) db_options ::= db_options QUORUM NK_INTEGER */ - { 146, -3 }, /* (35) db_options ::= db_options REPLICA NK_INTEGER */ - { 146, -3 }, /* (36) db_options ::= db_options TTL NK_INTEGER */ - { 146, -3 }, /* (37) db_options ::= db_options WAL NK_INTEGER */ - { 146, -3 }, /* (38) db_options ::= db_options VGROUPS NK_INTEGER */ - { 146, -3 }, /* (39) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 146, -3 }, /* (40) db_options ::= db_options STREAM_MODE NK_INTEGER */ - { 140, -9 }, /* (41) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 140, -3 }, /* (42) cmd ::= CREATE TABLE multi_create_clause */ - { 140, -9 }, /* (43) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 140, -3 }, /* (44) cmd ::= DROP TABLE multi_drop_clause */ - { 140, -4 }, /* (45) cmd ::= DROP STABLE exists_opt full_table_name */ - { 140, -2 }, /* (46) cmd ::= SHOW TABLES */ - { 140, -2 }, /* (47) cmd ::= SHOW STABLES */ - { 152, -1 }, /* (48) multi_create_clause ::= create_subtable_clause */ - { 152, -2 }, /* (49) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 155, -9 }, /* (50) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ - { 154, -1 }, /* (51) multi_drop_clause ::= drop_table_clause */ - { 154, -2 }, /* (52) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 158, -2 }, /* (53) drop_table_clause ::= exists_opt full_table_name */ - { 156, 0 }, /* (54) specific_tags_opt ::= */ - { 156, -3 }, /* (55) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - { 148, -1 }, /* (56) full_table_name ::= table_name */ - { 148, -3 }, /* (57) full_table_name ::= db_name NK_DOT table_name */ - { 149, -1 }, /* (58) column_def_list ::= column_def */ - { 149, -3 }, /* (59) column_def_list ::= column_def_list NK_COMMA column_def */ - { 161, -2 }, /* (60) column_def ::= column_name type_name */ - { 161, -4 }, /* (61) column_def ::= column_name type_name COMMENT NK_STRING */ - { 163, -1 }, /* (62) type_name ::= BOOL */ - { 163, -1 }, /* (63) type_name ::= TINYINT */ - { 163, -1 }, /* (64) type_name ::= SMALLINT */ - { 163, -1 }, /* (65) type_name ::= INT */ - { 163, -1 }, /* (66) type_name ::= INTEGER */ - { 163, -1 }, /* (67) type_name ::= BIGINT */ - { 163, -1 }, /* (68) type_name ::= FLOAT */ - { 163, -1 }, /* (69) type_name ::= DOUBLE */ - { 163, -4 }, /* (70) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 163, -1 }, /* (71) type_name ::= TIMESTAMP */ - { 163, -4 }, /* (72) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 163, -2 }, /* (73) type_name ::= TINYINT UNSIGNED */ - { 163, -2 }, /* (74) type_name ::= SMALLINT UNSIGNED */ - { 163, -2 }, /* (75) type_name ::= INT UNSIGNED */ - { 163, -2 }, /* (76) type_name ::= BIGINT UNSIGNED */ - { 163, -1 }, /* (77) type_name ::= JSON */ - { 163, -4 }, /* (78) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 163, -1 }, /* (79) type_name ::= MEDIUMBLOB */ - { 163, -1 }, /* (80) type_name ::= BLOB */ - { 163, -4 }, /* (81) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 163, -1 }, /* (82) type_name ::= DECIMAL */ - { 163, -4 }, /* (83) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 163, -6 }, /* (84) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 150, 0 }, /* (85) tags_def_opt ::= */ - { 150, -1 }, /* (86) tags_def_opt ::= tags_def */ - { 153, -4 }, /* (87) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 151, 0 }, /* (88) table_options ::= */ - { 151, -3 }, /* (89) table_options ::= table_options COMMENT NK_STRING */ - { 151, -3 }, /* (90) table_options ::= table_options KEEP NK_INTEGER */ - { 151, -3 }, /* (91) table_options ::= table_options TTL NK_INTEGER */ - { 151, -5 }, /* (92) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 159, -1 }, /* (93) col_name_list ::= col_name */ - { 159, -3 }, /* (94) col_name_list ::= col_name_list NK_COMMA col_name */ - { 164, -1 }, /* (95) col_name ::= column_name */ - { 140, -7 }, /* (96) cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ - { 140, -9 }, /* (97) cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ - { 166, 0 }, /* (98) index_options ::= */ - { 166, -9 }, /* (99) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ - { 166, -11 }, /* (100) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ - { 167, -1 }, /* (101) func_list ::= func */ - { 167, -3 }, /* (102) func_list ::= func_list NK_COMMA func */ - { 170, -4 }, /* (103) func ::= function_name NK_LP expression_list NK_RP */ - { 140, -2 }, /* (104) cmd ::= SHOW VGROUPS */ - { 140, -4 }, /* (105) cmd ::= SHOW db_name NK_DOT VGROUPS */ - { 140, -2 }, /* (106) cmd ::= SHOW MNODES */ - { 140, -1 }, /* (107) cmd ::= query_expression */ - { 174, -1 }, /* (108) literal ::= NK_INTEGER */ - { 174, -1 }, /* (109) literal ::= NK_FLOAT */ - { 174, -1 }, /* (110) literal ::= NK_STRING */ - { 174, -1 }, /* (111) literal ::= NK_BOOL */ - { 174, -2 }, /* (112) literal ::= TIMESTAMP NK_STRING */ - { 174, -1 }, /* (113) literal ::= duration_literal */ - { 168, -1 }, /* (114) duration_literal ::= NK_VARIABLE */ - { 157, -1 }, /* (115) literal_list ::= literal */ - { 157, -3 }, /* (116) literal_list ::= literal_list NK_COMMA literal */ - { 145, -1 }, /* (117) db_name ::= NK_ID */ - { 160, -1 }, /* (118) table_name ::= NK_ID */ - { 162, -1 }, /* (119) column_name ::= NK_ID */ - { 171, -1 }, /* (120) function_name ::= NK_ID */ - { 175, -1 }, /* (121) table_alias ::= NK_ID */ - { 176, -1 }, /* (122) column_alias ::= NK_ID */ - { 141, -1 }, /* (123) user_name ::= NK_ID */ - { 165, -1 }, /* (124) index_name ::= NK_ID */ - { 177, -1 }, /* (125) expression ::= literal */ - { 177, -1 }, /* (126) expression ::= column_reference */ - { 177, -4 }, /* (127) expression ::= function_name NK_LP expression_list NK_RP */ - { 177, -4 }, /* (128) expression ::= function_name NK_LP NK_STAR NK_RP */ - { 177, -1 }, /* (129) expression ::= subquery */ - { 177, -3 }, /* (130) expression ::= NK_LP expression NK_RP */ - { 177, -2 }, /* (131) expression ::= NK_PLUS expression */ - { 177, -2 }, /* (132) expression ::= NK_MINUS expression */ - { 177, -3 }, /* (133) expression ::= expression NK_PLUS expression */ - { 177, -3 }, /* (134) expression ::= expression NK_MINUS expression */ - { 177, -3 }, /* (135) expression ::= expression NK_STAR expression */ - { 177, -3 }, /* (136) expression ::= expression NK_SLASH expression */ - { 177, -3 }, /* (137) expression ::= expression NK_REM expression */ - { 172, -1 }, /* (138) expression_list ::= expression */ - { 172, -3 }, /* (139) expression_list ::= expression_list NK_COMMA expression */ - { 178, -1 }, /* (140) column_reference ::= column_name */ - { 178, -3 }, /* (141) column_reference ::= table_name NK_DOT column_name */ - { 180, -3 }, /* (142) predicate ::= expression compare_op expression */ - { 180, -5 }, /* (143) predicate ::= expression BETWEEN expression AND expression */ - { 180, -6 }, /* (144) predicate ::= expression NOT BETWEEN expression AND expression */ - { 180, -3 }, /* (145) predicate ::= expression IS NULL */ - { 180, -4 }, /* (146) predicate ::= expression IS NOT NULL */ - { 180, -3 }, /* (147) predicate ::= expression in_op in_predicate_value */ - { 181, -1 }, /* (148) compare_op ::= NK_LT */ - { 181, -1 }, /* (149) compare_op ::= NK_GT */ - { 181, -1 }, /* (150) compare_op ::= NK_LE */ - { 181, -1 }, /* (151) compare_op ::= NK_GE */ - { 181, -1 }, /* (152) compare_op ::= NK_NE */ - { 181, -1 }, /* (153) compare_op ::= NK_EQ */ - { 181, -1 }, /* (154) compare_op ::= LIKE */ - { 181, -2 }, /* (155) compare_op ::= NOT LIKE */ - { 181, -1 }, /* (156) compare_op ::= MATCH */ - { 181, -1 }, /* (157) compare_op ::= NMATCH */ - { 182, -1 }, /* (158) in_op ::= IN */ - { 182, -2 }, /* (159) in_op ::= NOT IN */ - { 183, -3 }, /* (160) in_predicate_value ::= NK_LP expression_list NK_RP */ - { 184, -1 }, /* (161) boolean_value_expression ::= boolean_primary */ - { 184, -2 }, /* (162) boolean_value_expression ::= NOT boolean_primary */ - { 184, -3 }, /* (163) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 184, -3 }, /* (164) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 185, -1 }, /* (165) boolean_primary ::= predicate */ - { 185, -3 }, /* (166) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 186, -1 }, /* (167) common_expression ::= expression */ - { 186, -1 }, /* (168) common_expression ::= boolean_value_expression */ - { 187, -2 }, /* (169) from_clause ::= FROM table_reference_list */ - { 188, -1 }, /* (170) table_reference_list ::= table_reference */ - { 188, -3 }, /* (171) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 189, -1 }, /* (172) table_reference ::= table_primary */ - { 189, -1 }, /* (173) table_reference ::= joined_table */ - { 190, -2 }, /* (174) table_primary ::= table_name alias_opt */ - { 190, -4 }, /* (175) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 190, -2 }, /* (176) table_primary ::= subquery alias_opt */ - { 190, -1 }, /* (177) table_primary ::= parenthesized_joined_table */ - { 192, 0 }, /* (178) alias_opt ::= */ - { 192, -1 }, /* (179) alias_opt ::= table_alias */ - { 192, -2 }, /* (180) alias_opt ::= AS table_alias */ - { 193, -3 }, /* (181) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 193, -3 }, /* (182) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 191, -6 }, /* (183) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 194, 0 }, /* (184) join_type ::= */ - { 194, -1 }, /* (185) join_type ::= INNER */ - { 196, -9 }, /* (186) 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 */ - { 197, 0 }, /* (187) set_quantifier_opt ::= */ - { 197, -1 }, /* (188) set_quantifier_opt ::= DISTINCT */ - { 197, -1 }, /* (189) set_quantifier_opt ::= ALL */ - { 198, -1 }, /* (190) select_list ::= NK_STAR */ - { 198, -1 }, /* (191) select_list ::= select_sublist */ - { 204, -1 }, /* (192) select_sublist ::= select_item */ - { 204, -3 }, /* (193) select_sublist ::= select_sublist NK_COMMA select_item */ - { 205, -1 }, /* (194) select_item ::= common_expression */ - { 205, -2 }, /* (195) select_item ::= common_expression column_alias */ - { 205, -3 }, /* (196) select_item ::= common_expression AS column_alias */ - { 205, -3 }, /* (197) select_item ::= table_name NK_DOT NK_STAR */ - { 199, 0 }, /* (198) where_clause_opt ::= */ - { 199, -2 }, /* (199) where_clause_opt ::= WHERE search_condition */ - { 200, 0 }, /* (200) partition_by_clause_opt ::= */ - { 200, -3 }, /* (201) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 201, 0 }, /* (202) twindow_clause_opt ::= */ - { 201, -6 }, /* (203) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ - { 201, -4 }, /* (204) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ - { 201, -6 }, /* (205) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 201, -8 }, /* (206) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 169, 0 }, /* (207) sliding_opt ::= */ - { 169, -4 }, /* (208) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 206, 0 }, /* (209) fill_opt ::= */ - { 206, -4 }, /* (210) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 206, -6 }, /* (211) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 207, -1 }, /* (212) fill_mode ::= NONE */ - { 207, -1 }, /* (213) fill_mode ::= PREV */ - { 207, -1 }, /* (214) fill_mode ::= NULL */ - { 207, -1 }, /* (215) fill_mode ::= LINEAR */ - { 207, -1 }, /* (216) fill_mode ::= NEXT */ - { 202, 0 }, /* (217) group_by_clause_opt ::= */ - { 202, -3 }, /* (218) group_by_clause_opt ::= GROUP BY group_by_list */ - { 208, -1 }, /* (219) group_by_list ::= expression */ - { 208, -3 }, /* (220) group_by_list ::= group_by_list NK_COMMA expression */ - { 203, 0 }, /* (221) having_clause_opt ::= */ - { 203, -2 }, /* (222) having_clause_opt ::= HAVING search_condition */ - { 173, -4 }, /* (223) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 209, -1 }, /* (224) query_expression_body ::= query_primary */ - { 209, -4 }, /* (225) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 213, -1 }, /* (226) query_primary ::= query_specification */ - { 210, 0 }, /* (227) order_by_clause_opt ::= */ - { 210, -3 }, /* (228) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 211, 0 }, /* (229) slimit_clause_opt ::= */ - { 211, -2 }, /* (230) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 211, -4 }, /* (231) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 211, -4 }, /* (232) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 212, 0 }, /* (233) limit_clause_opt ::= */ - { 212, -2 }, /* (234) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 212, -4 }, /* (235) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 212, -4 }, /* (236) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 179, -3 }, /* (237) subquery ::= NK_LP query_expression NK_RP */ - { 195, -1 }, /* (238) search_condition ::= common_expression */ - { 214, -1 }, /* (239) sort_specification_list ::= sort_specification */ - { 214, -3 }, /* (240) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 215, -3 }, /* (241) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 216, 0 }, /* (242) ordering_specification_opt ::= */ - { 216, -1 }, /* (243) ordering_specification_opt ::= ASC */ - { 216, -1 }, /* (244) ordering_specification_opt ::= DESC */ - { 217, 0 }, /* (245) null_ordering_opt ::= */ - { 217, -2 }, /* (246) null_ordering_opt ::= NULLS FIRST */ - { 217, -2 }, /* (247) null_ordering_opt ::= NULLS LAST */ + { 141, -5 }, /* (0) cmd ::= CREATE USER user_name PASS NK_STRING */ + { 141, -5 }, /* (1) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 141, -5 }, /* (2) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ + { 141, -3 }, /* (3) cmd ::= DROP USER user_name */ + { 141, -2 }, /* (4) cmd ::= SHOW USERS */ + { 141, -3 }, /* (5) cmd ::= CREATE DNODE dnode_endpoint */ + { 141, -5 }, /* (6) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ + { 141, -3 }, /* (7) cmd ::= DROP DNODE NK_INTEGER */ + { 141, -3 }, /* (8) cmd ::= DROP DNODE dnode_endpoint */ + { 141, -2 }, /* (9) cmd ::= SHOW DNODES */ + { 143, -1 }, /* (10) dnode_endpoint ::= NK_STRING */ + { 144, -1 }, /* (11) dnode_host_name ::= NK_ID */ + { 144, -1 }, /* (12) dnode_host_name ::= NK_IPTOKEN */ + { 141, -5 }, /* (13) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 141, -5 }, /* (14) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 141, -2 }, /* (15) cmd ::= SHOW QNODES */ + { 141, -5 }, /* (16) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 141, -4 }, /* (17) cmd ::= DROP DATABASE exists_opt db_name */ + { 141, -2 }, /* (18) cmd ::= SHOW DATABASES */ + { 141, -2 }, /* (19) cmd ::= USE db_name */ + { 141, -4 }, /* (20) cmd ::= ALTER DATABASE db_name db_options */ + { 145, -3 }, /* (21) not_exists_opt ::= IF NOT EXISTS */ + { 145, 0 }, /* (22) not_exists_opt ::= */ + { 148, -2 }, /* (23) exists_opt ::= IF EXISTS */ + { 148, 0 }, /* (24) exists_opt ::= */ + { 147, 0 }, /* (25) db_options ::= */ + { 147, -3 }, /* (26) db_options ::= db_options BLOCKS NK_INTEGER */ + { 147, -3 }, /* (27) db_options ::= db_options CACHE NK_INTEGER */ + { 147, -3 }, /* (28) db_options ::= db_options CACHELAST NK_INTEGER */ + { 147, -3 }, /* (29) db_options ::= db_options COMP NK_INTEGER */ + { 147, -3 }, /* (30) db_options ::= db_options DAYS NK_INTEGER */ + { 147, -3 }, /* (31) db_options ::= db_options FSYNC NK_INTEGER */ + { 147, -3 }, /* (32) db_options ::= db_options MAXROWS NK_INTEGER */ + { 147, -3 }, /* (33) db_options ::= db_options MINROWS NK_INTEGER */ + { 147, -3 }, /* (34) db_options ::= db_options KEEP NK_INTEGER */ + { 147, -3 }, /* (35) db_options ::= db_options PRECISION NK_STRING */ + { 147, -3 }, /* (36) db_options ::= db_options QUORUM NK_INTEGER */ + { 147, -3 }, /* (37) db_options ::= db_options REPLICA NK_INTEGER */ + { 147, -3 }, /* (38) db_options ::= db_options TTL NK_INTEGER */ + { 147, -3 }, /* (39) db_options ::= db_options WAL NK_INTEGER */ + { 147, -3 }, /* (40) db_options ::= db_options VGROUPS NK_INTEGER */ + { 147, -3 }, /* (41) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 147, -3 }, /* (42) db_options ::= db_options STREAM_MODE NK_INTEGER */ + { 141, -9 }, /* (43) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 141, -3 }, /* (44) cmd ::= CREATE TABLE multi_create_clause */ + { 141, -9 }, /* (45) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 141, -3 }, /* (46) cmd ::= DROP TABLE multi_drop_clause */ + { 141, -4 }, /* (47) cmd ::= DROP STABLE exists_opt full_table_name */ + { 141, -2 }, /* (48) cmd ::= SHOW TABLES */ + { 141, -2 }, /* (49) cmd ::= SHOW STABLES */ + { 153, -1 }, /* (50) multi_create_clause ::= create_subtable_clause */ + { 153, -2 }, /* (51) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 156, -9 }, /* (52) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ + { 155, -1 }, /* (53) multi_drop_clause ::= drop_table_clause */ + { 155, -2 }, /* (54) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 159, -2 }, /* (55) drop_table_clause ::= exists_opt full_table_name */ + { 157, 0 }, /* (56) specific_tags_opt ::= */ + { 157, -3 }, /* (57) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + { 149, -1 }, /* (58) full_table_name ::= table_name */ + { 149, -3 }, /* (59) full_table_name ::= db_name NK_DOT table_name */ + { 150, -1 }, /* (60) column_def_list ::= column_def */ + { 150, -3 }, /* (61) column_def_list ::= column_def_list NK_COMMA column_def */ + { 162, -2 }, /* (62) column_def ::= column_name type_name */ + { 162, -4 }, /* (63) column_def ::= column_name type_name COMMENT NK_STRING */ + { 164, -1 }, /* (64) type_name ::= BOOL */ + { 164, -1 }, /* (65) type_name ::= TINYINT */ + { 164, -1 }, /* (66) type_name ::= SMALLINT */ + { 164, -1 }, /* (67) type_name ::= INT */ + { 164, -1 }, /* (68) type_name ::= INTEGER */ + { 164, -1 }, /* (69) type_name ::= BIGINT */ + { 164, -1 }, /* (70) type_name ::= FLOAT */ + { 164, -1 }, /* (71) type_name ::= DOUBLE */ + { 164, -4 }, /* (72) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 164, -1 }, /* (73) type_name ::= TIMESTAMP */ + { 164, -4 }, /* (74) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 164, -2 }, /* (75) type_name ::= TINYINT UNSIGNED */ + { 164, -2 }, /* (76) type_name ::= SMALLINT UNSIGNED */ + { 164, -2 }, /* (77) type_name ::= INT UNSIGNED */ + { 164, -2 }, /* (78) type_name ::= BIGINT UNSIGNED */ + { 164, -1 }, /* (79) type_name ::= JSON */ + { 164, -4 }, /* (80) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 164, -1 }, /* (81) type_name ::= MEDIUMBLOB */ + { 164, -1 }, /* (82) type_name ::= BLOB */ + { 164, -4 }, /* (83) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 164, -1 }, /* (84) type_name ::= DECIMAL */ + { 164, -4 }, /* (85) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 164, -6 }, /* (86) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 151, 0 }, /* (87) tags_def_opt ::= */ + { 151, -1 }, /* (88) tags_def_opt ::= tags_def */ + { 154, -4 }, /* (89) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 152, 0 }, /* (90) table_options ::= */ + { 152, -3 }, /* (91) table_options ::= table_options COMMENT NK_STRING */ + { 152, -3 }, /* (92) table_options ::= table_options KEEP NK_INTEGER */ + { 152, -3 }, /* (93) table_options ::= table_options TTL NK_INTEGER */ + { 152, -5 }, /* (94) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 160, -1 }, /* (95) col_name_list ::= col_name */ + { 160, -3 }, /* (96) col_name_list ::= col_name_list NK_COMMA col_name */ + { 165, -1 }, /* (97) col_name ::= column_name */ + { 141, -7 }, /* (98) cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ + { 141, -9 }, /* (99) cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ + { 141, -5 }, /* (100) cmd ::= DROP INDEX index_name ON table_name */ + { 167, 0 }, /* (101) index_options ::= */ + { 167, -9 }, /* (102) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ + { 167, -11 }, /* (103) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ + { 168, -1 }, /* (104) func_list ::= func */ + { 168, -3 }, /* (105) func_list ::= func_list NK_COMMA func */ + { 171, -4 }, /* (106) func ::= function_name NK_LP expression_list NK_RP */ + { 141, -6 }, /* (107) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ + { 141, -6 }, /* (108) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ + { 141, -4 }, /* (109) cmd ::= DROP TOPIC exists_opt topic_name */ + { 141, -2 }, /* (110) cmd ::= SHOW VGROUPS */ + { 141, -4 }, /* (111) cmd ::= SHOW db_name NK_DOT VGROUPS */ + { 141, -2 }, /* (112) cmd ::= SHOW MNODES */ + { 141, -1 }, /* (113) cmd ::= query_expression */ + { 176, -1 }, /* (114) literal ::= NK_INTEGER */ + { 176, -1 }, /* (115) literal ::= NK_FLOAT */ + { 176, -1 }, /* (116) literal ::= NK_STRING */ + { 176, -1 }, /* (117) literal ::= NK_BOOL */ + { 176, -2 }, /* (118) literal ::= TIMESTAMP NK_STRING */ + { 176, -1 }, /* (119) literal ::= duration_literal */ + { 169, -1 }, /* (120) duration_literal ::= NK_VARIABLE */ + { 158, -1 }, /* (121) literal_list ::= literal */ + { 158, -3 }, /* (122) literal_list ::= literal_list NK_COMMA literal */ + { 146, -1 }, /* (123) db_name ::= NK_ID */ + { 161, -1 }, /* (124) table_name ::= NK_ID */ + { 163, -1 }, /* (125) column_name ::= NK_ID */ + { 172, -1 }, /* (126) function_name ::= NK_ID */ + { 177, -1 }, /* (127) table_alias ::= NK_ID */ + { 178, -1 }, /* (128) column_alias ::= NK_ID */ + { 142, -1 }, /* (129) user_name ::= NK_ID */ + { 166, -1 }, /* (130) index_name ::= NK_ID */ + { 174, -1 }, /* (131) topic_name ::= NK_ID */ + { 179, -1 }, /* (132) expression ::= literal */ + { 179, -1 }, /* (133) expression ::= column_reference */ + { 179, -4 }, /* (134) expression ::= function_name NK_LP expression_list NK_RP */ + { 179, -4 }, /* (135) expression ::= function_name NK_LP NK_STAR NK_RP */ + { 179, -1 }, /* (136) expression ::= subquery */ + { 179, -3 }, /* (137) expression ::= NK_LP expression NK_RP */ + { 179, -2 }, /* (138) expression ::= NK_PLUS expression */ + { 179, -2 }, /* (139) expression ::= NK_MINUS expression */ + { 179, -3 }, /* (140) expression ::= expression NK_PLUS expression */ + { 179, -3 }, /* (141) expression ::= expression NK_MINUS expression */ + { 179, -3 }, /* (142) expression ::= expression NK_STAR expression */ + { 179, -3 }, /* (143) expression ::= expression NK_SLASH expression */ + { 179, -3 }, /* (144) expression ::= expression NK_REM expression */ + { 173, -1 }, /* (145) expression_list ::= expression */ + { 173, -3 }, /* (146) expression_list ::= expression_list NK_COMMA expression */ + { 180, -1 }, /* (147) column_reference ::= column_name */ + { 180, -3 }, /* (148) column_reference ::= table_name NK_DOT column_name */ + { 182, -3 }, /* (149) predicate ::= expression compare_op expression */ + { 182, -5 }, /* (150) predicate ::= expression BETWEEN expression AND expression */ + { 182, -6 }, /* (151) predicate ::= expression NOT BETWEEN expression AND expression */ + { 182, -3 }, /* (152) predicate ::= expression IS NULL */ + { 182, -4 }, /* (153) predicate ::= expression IS NOT NULL */ + { 182, -3 }, /* (154) predicate ::= expression in_op in_predicate_value */ + { 183, -1 }, /* (155) compare_op ::= NK_LT */ + { 183, -1 }, /* (156) compare_op ::= NK_GT */ + { 183, -1 }, /* (157) compare_op ::= NK_LE */ + { 183, -1 }, /* (158) compare_op ::= NK_GE */ + { 183, -1 }, /* (159) compare_op ::= NK_NE */ + { 183, -1 }, /* (160) compare_op ::= NK_EQ */ + { 183, -1 }, /* (161) compare_op ::= LIKE */ + { 183, -2 }, /* (162) compare_op ::= NOT LIKE */ + { 183, -1 }, /* (163) compare_op ::= MATCH */ + { 183, -1 }, /* (164) compare_op ::= NMATCH */ + { 184, -1 }, /* (165) in_op ::= IN */ + { 184, -2 }, /* (166) in_op ::= NOT IN */ + { 185, -3 }, /* (167) in_predicate_value ::= NK_LP expression_list NK_RP */ + { 186, -1 }, /* (168) boolean_value_expression ::= boolean_primary */ + { 186, -2 }, /* (169) boolean_value_expression ::= NOT boolean_primary */ + { 186, -3 }, /* (170) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 186, -3 }, /* (171) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 187, -1 }, /* (172) boolean_primary ::= predicate */ + { 187, -3 }, /* (173) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 188, -1 }, /* (174) common_expression ::= expression */ + { 188, -1 }, /* (175) common_expression ::= boolean_value_expression */ + { 189, -2 }, /* (176) from_clause ::= FROM table_reference_list */ + { 190, -1 }, /* (177) table_reference_list ::= table_reference */ + { 190, -3 }, /* (178) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 191, -1 }, /* (179) table_reference ::= table_primary */ + { 191, -1 }, /* (180) table_reference ::= joined_table */ + { 192, -2 }, /* (181) table_primary ::= table_name alias_opt */ + { 192, -4 }, /* (182) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 192, -2 }, /* (183) table_primary ::= subquery alias_opt */ + { 192, -1 }, /* (184) table_primary ::= parenthesized_joined_table */ + { 194, 0 }, /* (185) alias_opt ::= */ + { 194, -1 }, /* (186) alias_opt ::= table_alias */ + { 194, -2 }, /* (187) alias_opt ::= AS table_alias */ + { 195, -3 }, /* (188) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 195, -3 }, /* (189) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 193, -6 }, /* (190) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 196, 0 }, /* (191) join_type ::= */ + { 196, -1 }, /* (192) join_type ::= INNER */ + { 198, -9 }, /* (193) 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 */ + { 199, 0 }, /* (194) set_quantifier_opt ::= */ + { 199, -1 }, /* (195) set_quantifier_opt ::= DISTINCT */ + { 199, -1 }, /* (196) set_quantifier_opt ::= ALL */ + { 200, -1 }, /* (197) select_list ::= NK_STAR */ + { 200, -1 }, /* (198) select_list ::= select_sublist */ + { 206, -1 }, /* (199) select_sublist ::= select_item */ + { 206, -3 }, /* (200) select_sublist ::= select_sublist NK_COMMA select_item */ + { 207, -1 }, /* (201) select_item ::= common_expression */ + { 207, -2 }, /* (202) select_item ::= common_expression column_alias */ + { 207, -3 }, /* (203) select_item ::= common_expression AS column_alias */ + { 207, -3 }, /* (204) select_item ::= table_name NK_DOT NK_STAR */ + { 201, 0 }, /* (205) where_clause_opt ::= */ + { 201, -2 }, /* (206) where_clause_opt ::= WHERE search_condition */ + { 202, 0 }, /* (207) partition_by_clause_opt ::= */ + { 202, -3 }, /* (208) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 203, 0 }, /* (209) twindow_clause_opt ::= */ + { 203, -6 }, /* (210) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ + { 203, -4 }, /* (211) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ + { 203, -6 }, /* (212) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 203, -8 }, /* (213) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 170, 0 }, /* (214) sliding_opt ::= */ + { 170, -4 }, /* (215) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 208, 0 }, /* (216) fill_opt ::= */ + { 208, -4 }, /* (217) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 208, -6 }, /* (218) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 209, -1 }, /* (219) fill_mode ::= NONE */ + { 209, -1 }, /* (220) fill_mode ::= PREV */ + { 209, -1 }, /* (221) fill_mode ::= NULL */ + { 209, -1 }, /* (222) fill_mode ::= LINEAR */ + { 209, -1 }, /* (223) fill_mode ::= NEXT */ + { 204, 0 }, /* (224) group_by_clause_opt ::= */ + { 204, -3 }, /* (225) group_by_clause_opt ::= GROUP BY group_by_list */ + { 210, -1 }, /* (226) group_by_list ::= expression */ + { 210, -3 }, /* (227) group_by_list ::= group_by_list NK_COMMA expression */ + { 205, 0 }, /* (228) having_clause_opt ::= */ + { 205, -2 }, /* (229) having_clause_opt ::= HAVING search_condition */ + { 175, -4 }, /* (230) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 211, -1 }, /* (231) query_expression_body ::= query_primary */ + { 211, -4 }, /* (232) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 215, -1 }, /* (233) query_primary ::= query_specification */ + { 212, 0 }, /* (234) order_by_clause_opt ::= */ + { 212, -3 }, /* (235) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 213, 0 }, /* (236) slimit_clause_opt ::= */ + { 213, -2 }, /* (237) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 213, -4 }, /* (238) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 213, -4 }, /* (239) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 214, 0 }, /* (240) limit_clause_opt ::= */ + { 214, -2 }, /* (241) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 214, -4 }, /* (242) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 214, -4 }, /* (243) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 181, -3 }, /* (244) subquery ::= NK_LP query_expression NK_RP */ + { 197, -1 }, /* (245) search_condition ::= common_expression */ + { 216, -1 }, /* (246) sort_specification_list ::= sort_specification */ + { 216, -3 }, /* (247) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 217, -3 }, /* (248) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 218, 0 }, /* (249) ordering_specification_opt ::= */ + { 218, -1 }, /* (250) ordering_specification_opt ::= ASC */ + { 218, -1 }, /* (251) ordering_specification_opt ::= DESC */ + { 219, 0 }, /* (252) null_ordering_opt ::= */ + { 219, -2 }, /* (253) null_ordering_opt ::= NULLS FIRST */ + { 219, -2 }, /* (254) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -1959,31 +1991,31 @@ static YYACTIONTYPE yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0); } break; case 1: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy5, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy129, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; case 2: /* cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy5, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy129, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } break; case 3: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy5); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy129); } break; case 4: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL); } break; case 5: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy5, NULL);} +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy129, NULL); } break; case 6: /* cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0); } break; case 7: /* cmd ::= DROP DNODE NK_INTEGER */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; case 8: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy5);} +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy129); } break; case 9: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL); } @@ -1991,742 +2023,761 @@ static YYACTIONTYPE yy_reduce( case 10: /* dnode_endpoint ::= NK_STRING */ case 11: /* dnode_host_name ::= NK_ID */ yytestcase(yyruleno==11); case 12: /* dnode_host_name ::= NK_IPTOKEN */ yytestcase(yyruleno==12); - case 117: /* db_name ::= NK_ID */ yytestcase(yyruleno==117); - case 118: /* table_name ::= NK_ID */ yytestcase(yyruleno==118); - case 119: /* column_name ::= NK_ID */ yytestcase(yyruleno==119); - case 120: /* function_name ::= NK_ID */ yytestcase(yyruleno==120); - case 121: /* table_alias ::= NK_ID */ yytestcase(yyruleno==121); - case 122: /* column_alias ::= NK_ID */ yytestcase(yyruleno==122); - case 123: /* user_name ::= NK_ID */ yytestcase(yyruleno==123); - case 124: /* index_name ::= NK_ID */ yytestcase(yyruleno==124); -{ yylhsminor.yy5 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy5 = yylhsminor.yy5; + case 123: /* db_name ::= NK_ID */ yytestcase(yyruleno==123); + case 124: /* table_name ::= NK_ID */ yytestcase(yyruleno==124); + case 125: /* column_name ::= NK_ID */ yytestcase(yyruleno==125); + case 126: /* function_name ::= NK_ID */ yytestcase(yyruleno==126); + case 127: /* table_alias ::= NK_ID */ yytestcase(yyruleno==127); + case 128: /* column_alias ::= NK_ID */ yytestcase(yyruleno==128); + case 129: /* user_name ::= NK_ID */ yytestcase(yyruleno==129); + case 130: /* index_name ::= NK_ID */ yytestcase(yyruleno==130); + case 131: /* topic_name ::= NK_ID */ yytestcase(yyruleno==131); +{ yylhsminor.yy129 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy129 = yylhsminor.yy129; break; case 13: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createCreateQnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 14: /* cmd ::= SHOW QNODES */ + case 14: /* cmd ::= DROP QNODE ON DNODE NK_INTEGER */ +{ pCxt->pRootNode = createDropQnodeStmt(pCxt, &yymsp[0].minor.yy0); } + break; + case 15: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT, NULL); } break; - case 15: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy25, &yymsp[-1].minor.yy5, yymsp[0].minor.yy68);} + case 16: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy97, &yymsp[-1].minor.yy129, yymsp[0].minor.yy432); } break; - case 16: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy25, &yymsp[0].minor.yy5); } + case 17: /* cmd ::= DROP DATABASE exists_opt db_name */ +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy97, &yymsp[0].minor.yy129); } break; - case 17: /* cmd ::= SHOW DATABASES */ + case 18: /* cmd ::= SHOW DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL); } break; - case 18: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy5);} + case 19: /* cmd ::= USE db_name */ +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy129); } break; - case 19: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy25 = true; } + case 20: /* cmd ::= ALTER DATABASE db_name db_options */ +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy129, yymsp[0].minor.yy432); } break; - case 20: /* not_exists_opt ::= */ - case 22: /* exists_opt ::= */ yytestcase(yyruleno==22); - case 187: /* set_quantifier_opt ::= */ yytestcase(yyruleno==187); -{ yymsp[1].minor.yy25 = false; } + case 21: /* not_exists_opt ::= IF NOT EXISTS */ +{ yymsp[-2].minor.yy97 = true; } break; - case 21: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy25 = true; } + case 22: /* not_exists_opt ::= */ + case 24: /* exists_opt ::= */ yytestcase(yyruleno==24); + case 194: /* set_quantifier_opt ::= */ yytestcase(yyruleno==194); +{ yymsp[1].minor.yy97 = false; } break; - case 23: /* db_options ::= */ -{ yymsp[1].minor.yy68 = createDefaultDatabaseOptions(pCxt); } + case 23: /* exists_opt ::= IF EXISTS */ +{ yymsp[-1].minor.yy97 = true; } break; - case 24: /* db_options ::= db_options BLOCKS NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 25: /* db_options ::= */ +{ yymsp[1].minor.yy432 = createDefaultDatabaseOptions(pCxt); } break; - case 25: /* db_options ::= db_options CACHE NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 26: /* db_options ::= db_options BLOCKS NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 26: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 27: /* db_options ::= db_options CACHE NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 27: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 28: /* db_options ::= db_options CACHELAST NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 28: /* db_options ::= db_options DAYS NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 29: /* db_options ::= db_options COMP NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 29: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 30: /* db_options ::= db_options DAYS NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 30: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 31: /* db_options ::= db_options FSYNC NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 31: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 32: /* db_options ::= db_options MAXROWS NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 32: /* db_options ::= db_options KEEP NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 33: /* db_options ::= db_options MINROWS NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 33: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 34: /* db_options ::= db_options KEEP NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_KEEP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 34: /* db_options ::= db_options QUORUM NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 35: /* db_options ::= db_options PRECISION NK_STRING */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 35: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 36: /* db_options ::= db_options QUORUM NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 36: /* db_options ::= db_options TTL NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 37: /* db_options ::= db_options REPLICA NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 37: /* db_options ::= db_options WAL NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 38: /* db_options ::= db_options TTL NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 38: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 39: /* db_options ::= db_options WAL NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 39: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_SINGLESTABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 40: /* db_options ::= db_options VGROUPS NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 40: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_STREAMMODE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 41: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_SINGLESTABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 41: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - case 43: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==43); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy25, yymsp[-5].minor.yy68, yymsp[-3].minor.yy40, yymsp[-1].minor.yy40, yymsp[0].minor.yy68);} + case 42: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_STREAMMODE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 42: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy40);} + case 43: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + case 45: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==45); +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy97, yymsp[-5].minor.yy432, yymsp[-3].minor.yy24, yymsp[-1].minor.yy24, yymsp[0].minor.yy432);} break; - case 44: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy40); } + case 44: /* cmd ::= CREATE TABLE multi_create_clause */ +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy24);} break; - case 45: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy25, yymsp[0].minor.yy68); } + case 46: /* cmd ::= DROP TABLE multi_drop_clause */ +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy24); } break; - case 46: /* cmd ::= SHOW TABLES */ + case 47: /* cmd ::= DROP STABLE exists_opt full_table_name */ +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy97, yymsp[0].minor.yy432); } + break; + case 48: /* cmd ::= SHOW TABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, NULL); } break; - case 47: /* cmd ::= SHOW STABLES */ + case 49: /* cmd ::= SHOW STABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, NULL); } break; - case 48: /* multi_create_clause ::= create_subtable_clause */ - case 51: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==51); - case 58: /* column_def_list ::= column_def */ yytestcase(yyruleno==58); - case 93: /* col_name_list ::= col_name */ yytestcase(yyruleno==93); - case 101: /* func_list ::= func */ yytestcase(yyruleno==101); - case 192: /* select_sublist ::= select_item */ yytestcase(yyruleno==192); - case 239: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==239); -{ yylhsminor.yy40 = createNodeList(pCxt, yymsp[0].minor.yy68); } - yymsp[0].minor.yy40 = yylhsminor.yy40; + case 50: /* multi_create_clause ::= create_subtable_clause */ + case 53: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==53); + case 60: /* column_def_list ::= column_def */ yytestcase(yyruleno==60); + case 95: /* col_name_list ::= col_name */ yytestcase(yyruleno==95); + case 104: /* func_list ::= func */ yytestcase(yyruleno==104); + case 199: /* select_sublist ::= select_item */ yytestcase(yyruleno==199); + case 246: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==246); +{ yylhsminor.yy24 = createNodeList(pCxt, yymsp[0].minor.yy432); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 49: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 52: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==52); -{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-1].minor.yy40, yymsp[0].minor.yy68); } - yymsp[-1].minor.yy40 = yylhsminor.yy40; + case 51: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ + case 54: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==54); +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-1].minor.yy24, yymsp[0].minor.yy432); } + yymsp[-1].minor.yy24 = yylhsminor.yy24; break; - case 50: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ -{ yylhsminor.yy68 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy25, yymsp[-7].minor.yy68, yymsp[-5].minor.yy68, yymsp[-4].minor.yy40, yymsp[-1].minor.yy40); } - yymsp[-8].minor.yy68 = yylhsminor.yy68; + case 52: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ +{ yylhsminor.yy432 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy97, yymsp[-7].minor.yy432, yymsp[-5].minor.yy432, yymsp[-4].minor.yy24, yymsp[-1].minor.yy24); } + yymsp[-8].minor.yy432 = yylhsminor.yy432; break; - case 53: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy68 = createDropTableClause(pCxt, yymsp[-1].minor.yy25, yymsp[0].minor.yy68); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + case 55: /* drop_table_clause ::= exists_opt full_table_name */ +{ yylhsminor.yy432 = createDropTableClause(pCxt, yymsp[-1].minor.yy97, yymsp[0].minor.yy432); } + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 54: /* specific_tags_opt ::= */ - case 85: /* tags_def_opt ::= */ yytestcase(yyruleno==85); - case 200: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==200); - case 217: /* group_by_clause_opt ::= */ yytestcase(yyruleno==217); - case 227: /* order_by_clause_opt ::= */ yytestcase(yyruleno==227); -{ yymsp[1].minor.yy40 = NULL; } + case 56: /* specific_tags_opt ::= */ + case 87: /* tags_def_opt ::= */ yytestcase(yyruleno==87); + case 207: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==207); + case 224: /* group_by_clause_opt ::= */ yytestcase(yyruleno==224); + case 234: /* order_by_clause_opt ::= */ yytestcase(yyruleno==234); +{ yymsp[1].minor.yy24 = NULL; } break; - case 55: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy40 = yymsp[-1].minor.yy40; } + case 57: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ +{ yymsp[-2].minor.yy24 = yymsp[-1].minor.yy24; } break; - case 56: /* full_table_name ::= table_name */ -{ yylhsminor.yy68 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy5, NULL); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 58: /* full_table_name ::= table_name */ +{ yylhsminor.yy432 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy129, NULL); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 57: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy68 = createRealTableNode(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy5, NULL); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 59: /* full_table_name ::= db_name NK_DOT table_name */ +{ yylhsminor.yy432 = createRealTableNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129, NULL); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 59: /* column_def_list ::= column_def_list NK_COMMA column_def */ - case 94: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==94); - case 102: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==102); - case 193: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==193); - case 240: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==240); -{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-2].minor.yy40, yymsp[0].minor.yy68); } - yymsp[-2].minor.yy40 = yylhsminor.yy40; + case 61: /* column_def_list ::= column_def_list NK_COMMA column_def */ + case 96: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==96); + case 105: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==105); + case 200: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==200); + case 247: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==247); +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, yymsp[0].minor.yy432); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 60: /* column_def ::= column_name type_name */ -{ yylhsminor.yy68 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy5, yymsp[0].minor.yy372, NULL); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + case 62: /* column_def ::= column_name type_name */ +{ yylhsminor.yy432 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy129, yymsp[0].minor.yy224, NULL); } + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 61: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy68 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy5, yymsp[-2].minor.yy372, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + case 63: /* column_def ::= column_name type_name COMMENT NK_STRING */ +{ yylhsminor.yy432 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-2].minor.yy224, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy432 = yylhsminor.yy432; break; - case 62: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_BOOL); } + case 64: /* type_name ::= BOOL */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_BOOL); } break; - case 63: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_TINYINT); } + case 65: /* type_name ::= TINYINT */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; - case 64: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_SMALLINT); } + case 66: /* type_name ::= SMALLINT */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; - case 65: /* type_name ::= INT */ - case 66: /* type_name ::= INTEGER */ yytestcase(yyruleno==66); -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_INT); } + case 67: /* type_name ::= INT */ + case 68: /* type_name ::= INTEGER */ yytestcase(yyruleno==68); +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_INT); } break; - case 67: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_BIGINT); } + case 69: /* type_name ::= BIGINT */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; - case 68: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_FLOAT); } + case 70: /* type_name ::= FLOAT */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; - case 69: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_DOUBLE); } + case 71: /* type_name ::= DOUBLE */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; - case 70: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy372 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } + case 72: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy224 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; - case 71: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } + case 73: /* type_name ::= TIMESTAMP */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; - case 72: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy372 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } + case 74: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy224 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; - case 73: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy372 = createDataType(TSDB_DATA_TYPE_UTINYINT); } + case 75: /* type_name ::= TINYINT UNSIGNED */ +{ yymsp[-1].minor.yy224 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; - case 74: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy372 = createDataType(TSDB_DATA_TYPE_USMALLINT); } + case 76: /* type_name ::= SMALLINT UNSIGNED */ +{ yymsp[-1].minor.yy224 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; - case 75: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy372 = createDataType(TSDB_DATA_TYPE_UINT); } + case 77: /* type_name ::= INT UNSIGNED */ +{ yymsp[-1].minor.yy224 = createDataType(TSDB_DATA_TYPE_UINT); } break; - case 76: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy372 = createDataType(TSDB_DATA_TYPE_UBIGINT); } + case 78: /* type_name ::= BIGINT UNSIGNED */ +{ yymsp[-1].minor.yy224 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; - case 77: /* type_name ::= JSON */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_JSON); } + case 79: /* type_name ::= JSON */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_JSON); } break; - case 78: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy372 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } + case 80: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy224 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; - case 79: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } + case 81: /* type_name ::= MEDIUMBLOB */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; - case 80: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_BLOB); } + case 82: /* type_name ::= BLOB */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_BLOB); } break; - case 81: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy372 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } + case 83: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy224 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; - case 82: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 84: /* type_name ::= DECIMAL */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 83: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy372 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 85: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy224 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 84: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy372 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 86: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy224 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 86: /* tags_def_opt ::= tags_def */ - case 191: /* select_list ::= select_sublist */ yytestcase(yyruleno==191); -{ yylhsminor.yy40 = yymsp[0].minor.yy40; } - yymsp[0].minor.yy40 = yylhsminor.yy40; + case 88: /* tags_def_opt ::= tags_def */ + case 198: /* select_list ::= select_sublist */ yytestcase(yyruleno==198); +{ yylhsminor.yy24 = yymsp[0].minor.yy24; } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 87: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy40 = yymsp[-1].minor.yy40; } + case 89: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ +{ yymsp[-3].minor.yy24 = yymsp[-1].minor.yy24; } break; - case 88: /* table_options ::= */ -{ yymsp[1].minor.yy68 = createDefaultTableOptions(pCxt);} + case 90: /* table_options ::= */ +{ yymsp[1].minor.yy432 = createDefaultTableOptions(pCxt);} break; - case 89: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy68 = setTableOption(pCxt, yymsp[-2].minor.yy68, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 91: /* table_options ::= table_options COMMENT NK_STRING */ +{ yylhsminor.yy432 = setTableOption(pCxt, yymsp[-2].minor.yy432, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 90: /* table_options ::= table_options KEEP NK_INTEGER */ -{ yylhsminor.yy68 = setTableOption(pCxt, yymsp[-2].minor.yy68, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 92: /* table_options ::= table_options KEEP NK_INTEGER */ +{ yylhsminor.yy432 = setTableOption(pCxt, yymsp[-2].minor.yy432, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 91: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy68 = setTableOption(pCxt, yymsp[-2].minor.yy68, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 93: /* table_options ::= table_options TTL NK_INTEGER */ +{ yylhsminor.yy432 = setTableOption(pCxt, yymsp[-2].minor.yy432, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 92: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy68 = setTableSmaOption(pCxt, yymsp[-4].minor.yy68, yymsp[-1].minor.yy40); } - yymsp[-4].minor.yy68 = yylhsminor.yy68; + case 94: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ +{ yylhsminor.yy432 = setTableSmaOption(pCxt, yymsp[-4].minor.yy432, yymsp[-1].minor.yy24); } + yymsp[-4].minor.yy432 = yylhsminor.yy432; break; - case 95: /* col_name ::= column_name */ -{ yylhsminor.yy68 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy5); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 97: /* col_name ::= column_name */ +{ yylhsminor.yy432 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy129); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 96: /* cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &yymsp[-3].minor.yy5, &yymsp[-1].minor.yy5, NULL, yymsp[0].minor.yy68); } + case 98: /* cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &yymsp[-3].minor.yy129, &yymsp[-1].minor.yy129, NULL, yymsp[0].minor.yy432); } break; - case 97: /* cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &yymsp[-5].minor.yy5, &yymsp[-3].minor.yy5, yymsp[-1].minor.yy40, NULL); } + case 99: /* cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &yymsp[-5].minor.yy129, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy24, NULL); } break; - case 98: /* index_options ::= */ - case 198: /* where_clause_opt ::= */ yytestcase(yyruleno==198); - case 202: /* twindow_clause_opt ::= */ yytestcase(yyruleno==202); - case 207: /* sliding_opt ::= */ yytestcase(yyruleno==207); - case 209: /* fill_opt ::= */ yytestcase(yyruleno==209); - case 221: /* having_clause_opt ::= */ yytestcase(yyruleno==221); - case 229: /* slimit_clause_opt ::= */ yytestcase(yyruleno==229); - case 233: /* limit_clause_opt ::= */ yytestcase(yyruleno==233); -{ yymsp[1].minor.yy68 = NULL; } + case 100: /* cmd ::= DROP INDEX index_name ON table_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129); } break; - case 99: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ -{ yymsp[-8].minor.yy68 = createIndexOption(pCxt, yymsp[-6].minor.yy40, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), NULL, yymsp[0].minor.yy68); } + case 101: /* index_options ::= */ + case 205: /* where_clause_opt ::= */ yytestcase(yyruleno==205); + case 209: /* twindow_clause_opt ::= */ yytestcase(yyruleno==209); + case 214: /* sliding_opt ::= */ yytestcase(yyruleno==214); + case 216: /* fill_opt ::= */ yytestcase(yyruleno==216); + case 228: /* having_clause_opt ::= */ yytestcase(yyruleno==228); + case 236: /* slimit_clause_opt ::= */ yytestcase(yyruleno==236); + case 240: /* limit_clause_opt ::= */ yytestcase(yyruleno==240); +{ yymsp[1].minor.yy432 = NULL; } break; - case 100: /* 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.yy68 = createIndexOption(pCxt, yymsp[-8].minor.yy40, releaseRawExprNode(pCxt, yymsp[-4].minor.yy68), releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), yymsp[0].minor.yy68); } + case 102: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ +{ yymsp[-8].minor.yy432 = createIndexOption(pCxt, yymsp[-6].minor.yy24, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), NULL, yymsp[0].minor.yy432); } break; - case 103: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy68 = createFunctionNode(pCxt, &yymsp[-3].minor.yy5, yymsp[-1].minor.yy40); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + case 103: /* 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.yy432 = createIndexOption(pCxt, yymsp[-8].minor.yy24, releaseRawExprNode(pCxt, yymsp[-4].minor.yy432), releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), yymsp[0].minor.yy432); } break; - case 104: /* cmd ::= SHOW VGROUPS */ + case 106: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy432 = createFunctionNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy24); } + yymsp[-3].minor.yy432 = yylhsminor.yy432; + break; + case 107: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy97, &yymsp[-2].minor.yy129, yymsp[0].minor.yy432, NULL); } + break; + case 108: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy97, &yymsp[-2].minor.yy129, NULL, &yymsp[0].minor.yy129); } + break; + case 109: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy97, &yymsp[0].minor.yy129); } + break; + case 110: /* cmd ::= SHOW VGROUPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, NULL); } break; - case 105: /* cmd ::= SHOW db_name NK_DOT VGROUPS */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &yymsp[-2].minor.yy5); } + case 111: /* cmd ::= SHOW db_name NK_DOT VGROUPS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &yymsp[-2].minor.yy129); } break; - case 106: /* cmd ::= SHOW MNODES */ + case 112: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL); } break; - case 107: /* cmd ::= query_expression */ -{ pCxt->pRootNode = yymsp[0].minor.yy68; } + case 113: /* cmd ::= query_expression */ +{ pCxt->pRootNode = yymsp[0].minor.yy432; } break; - case 108: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 114: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 109: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 115: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 110: /* literal ::= NK_STRING */ -{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 116: /* literal ::= NK_STRING */ +{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 111: /* literal ::= NK_BOOL */ -{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 117: /* literal ::= NK_BOOL */ +{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 112: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + case 118: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 113: /* literal ::= duration_literal */ - case 125: /* expression ::= literal */ yytestcase(yyruleno==125); - case 126: /* expression ::= column_reference */ yytestcase(yyruleno==126); - case 129: /* expression ::= subquery */ yytestcase(yyruleno==129); - case 161: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==161); - case 165: /* boolean_primary ::= predicate */ yytestcase(yyruleno==165); - case 167: /* common_expression ::= expression */ yytestcase(yyruleno==167); - case 168: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==168); - case 170: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==170); - case 172: /* table_reference ::= table_primary */ yytestcase(yyruleno==172); - case 173: /* table_reference ::= joined_table */ yytestcase(yyruleno==173); - case 177: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==177); - case 224: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==224); - case 226: /* query_primary ::= query_specification */ yytestcase(yyruleno==226); -{ yylhsminor.yy68 = yymsp[0].minor.yy68; } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 119: /* literal ::= duration_literal */ + case 132: /* expression ::= literal */ yytestcase(yyruleno==132); + case 133: /* expression ::= column_reference */ yytestcase(yyruleno==133); + case 136: /* expression ::= subquery */ yytestcase(yyruleno==136); + case 168: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==168); + case 172: /* boolean_primary ::= predicate */ yytestcase(yyruleno==172); + case 174: /* common_expression ::= expression */ yytestcase(yyruleno==174); + case 175: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==175); + case 177: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==177); + case 179: /* table_reference ::= table_primary */ yytestcase(yyruleno==179); + case 180: /* table_reference ::= joined_table */ yytestcase(yyruleno==180); + case 184: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==184); + case 231: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==231); + case 233: /* query_primary ::= query_specification */ yytestcase(yyruleno==233); +{ yylhsminor.yy432 = yymsp[0].minor.yy432; } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 114: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 120: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 115: /* literal_list ::= literal */ - case 138: /* expression_list ::= expression */ yytestcase(yyruleno==138); -{ yylhsminor.yy40 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy68)); } - yymsp[0].minor.yy40 = yylhsminor.yy40; + case 121: /* literal_list ::= literal */ + case 145: /* expression_list ::= expression */ yytestcase(yyruleno==145); +{ yylhsminor.yy24 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy432)); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 116: /* literal_list ::= literal_list NK_COMMA literal */ - case 139: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==139); -{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-2].minor.yy40, releaseRawExprNode(pCxt, yymsp[0].minor.yy68)); } - yymsp[-2].minor.yy40 = yylhsminor.yy40; + case 122: /* literal_list ::= literal_list NK_COMMA literal */ + case 146: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==146); +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, releaseRawExprNode(pCxt, yymsp[0].minor.yy432)); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 127: /* expression ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy5, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy5, yymsp[-1].minor.yy40)); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + case 134: /* expression ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy129, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy24)); } + yymsp[-3].minor.yy432 = yylhsminor.yy432; break; - case 128: /* expression ::= function_name NK_LP NK_STAR NK_RP */ -{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy5, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy5, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + case 135: /* expression ::= function_name NK_LP NK_STAR NK_RP */ +{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy129, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy129, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } + yymsp[-3].minor.yy432 = yylhsminor.yy432; break; - case 130: /* expression ::= NK_LP expression NK_RP */ - case 166: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==166); -{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy68)); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 137: /* expression ::= NK_LP expression NK_RP */ + case 173: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==173); +{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy432)); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 131: /* expression ::= NK_PLUS expression */ + case 138: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy68)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy432)); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 132: /* expression ::= NK_MINUS expression */ + case 139: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy68), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy432), NULL)); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 133: /* expression ::= expression NK_PLUS expression */ + case 140: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 134: /* expression ::= expression NK_MINUS expression */ + case 141: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 135: /* expression ::= expression NK_STAR expression */ + case 142: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 136: /* expression ::= expression NK_SLASH expression */ + case 143: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 137: /* expression ::= expression NK_REM expression */ + case 144: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 140: /* column_reference ::= column_name */ -{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy5, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy5)); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 147: /* column_reference ::= column_name */ +{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy129, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy129)); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 141: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy5, createColumnNode(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy5)); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 148: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129, createColumnNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129)); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 142: /* predicate ::= expression compare_op expression */ - case 147: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==147); + case 149: /* predicate ::= expression compare_op expression */ + case 154: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==154); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy416, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy260, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 143: /* predicate ::= expression BETWEEN expression AND expression */ + case 150: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy68), releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy432), releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-4].minor.yy68 = yylhsminor.yy68; + yymsp[-4].minor.yy432 = yylhsminor.yy432; break; - case 144: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 151: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[-5].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[-5].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-5].minor.yy68 = yylhsminor.yy68; + yymsp[-5].minor.yy432 = yylhsminor.yy432; break; - case 145: /* predicate ::= expression IS NULL */ + case 152: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), NULL)); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 146: /* predicate ::= expression IS NOT NULL */ + case 153: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy68), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy432), NULL)); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + yymsp[-3].minor.yy432 = yylhsminor.yy432; break; - case 148: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy416 = OP_TYPE_LOWER_THAN; } + case 155: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy260 = OP_TYPE_LOWER_THAN; } break; - case 149: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy416 = OP_TYPE_GREATER_THAN; } + case 156: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy260 = OP_TYPE_GREATER_THAN; } break; - case 150: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy416 = OP_TYPE_LOWER_EQUAL; } + case 157: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy260 = OP_TYPE_LOWER_EQUAL; } break; - case 151: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy416 = OP_TYPE_GREATER_EQUAL; } + case 158: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy260 = OP_TYPE_GREATER_EQUAL; } break; - case 152: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy416 = OP_TYPE_NOT_EQUAL; } + case 159: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy260 = OP_TYPE_NOT_EQUAL; } break; - case 153: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy416 = OP_TYPE_EQUAL; } + case 160: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy260 = OP_TYPE_EQUAL; } break; - case 154: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy416 = OP_TYPE_LIKE; } + case 161: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy260 = OP_TYPE_LIKE; } break; - case 155: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy416 = OP_TYPE_NOT_LIKE; } + case 162: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy260 = OP_TYPE_NOT_LIKE; } break; - case 156: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy416 = OP_TYPE_MATCH; } + case 163: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy260 = OP_TYPE_MATCH; } break; - case 157: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy416 = OP_TYPE_NMATCH; } + case 164: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy260 = OP_TYPE_NMATCH; } break; - case 158: /* in_op ::= IN */ -{ yymsp[0].minor.yy416 = OP_TYPE_IN; } + case 165: /* in_op ::= IN */ +{ yymsp[0].minor.yy260 = OP_TYPE_IN; } break; - case 159: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy416 = OP_TYPE_NOT_IN; } + case 166: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy260 = OP_TYPE_NOT_IN; } break; - case 160: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy40)); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 167: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy24)); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 162: /* boolean_value_expression ::= NOT boolean_primary */ + case 169: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy68), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy432), NULL)); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 163: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 170: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 164: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 171: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 169: /* from_clause ::= FROM table_reference_list */ - case 199: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==199); - case 222: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==222); -{ yymsp[-1].minor.yy68 = yymsp[0].minor.yy68; } + case 176: /* from_clause ::= FROM table_reference_list */ + case 206: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==206); + case 229: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==229); +{ yymsp[-1].minor.yy432 = yymsp[0].minor.yy432; } break; - case 171: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy68 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy68, yymsp[0].minor.yy68, NULL); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 178: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy432 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy432, yymsp[0].minor.yy432, NULL); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 174: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy68 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy5, &yymsp[0].minor.yy5); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + case 181: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy432 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy129, &yymsp[0].minor.yy129); } + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 175: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy68 = createRealTableNode(pCxt, &yymsp[-3].minor.yy5, &yymsp[-1].minor.yy5, &yymsp[0].minor.yy5); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + case 182: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy432 = createRealTableNode(pCxt, &yymsp[-3].minor.yy129, &yymsp[-1].minor.yy129, &yymsp[0].minor.yy129); } + yymsp[-3].minor.yy432 = yylhsminor.yy432; break; - case 176: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy68 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy68), &yymsp[0].minor.yy5); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + case 183: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy432 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy432), &yymsp[0].minor.yy129); } + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 178: /* alias_opt ::= */ -{ yymsp[1].minor.yy5 = nil_token; } + case 185: /* alias_opt ::= */ +{ yymsp[1].minor.yy129 = nil_token; } break; - case 179: /* alias_opt ::= table_alias */ -{ yylhsminor.yy5 = yymsp[0].minor.yy5; } - yymsp[0].minor.yy5 = yylhsminor.yy5; + case 186: /* alias_opt ::= table_alias */ +{ yylhsminor.yy129 = yymsp[0].minor.yy129; } + yymsp[0].minor.yy129 = yylhsminor.yy129; break; - case 180: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy5 = yymsp[0].minor.yy5; } + case 187: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy129 = yymsp[0].minor.yy129; } break; - case 181: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 182: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==182); -{ yymsp[-2].minor.yy68 = yymsp[-1].minor.yy68; } + case 188: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 189: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==189); +{ yymsp[-2].minor.yy432 = yymsp[-1].minor.yy432; } break; - case 183: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy68 = createJoinTableNode(pCxt, yymsp[-4].minor.yy92, yymsp[-5].minor.yy68, yymsp[-2].minor.yy68, yymsp[0].minor.yy68); } - yymsp[-5].minor.yy68 = yylhsminor.yy68; + case 190: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy432 = createJoinTableNode(pCxt, yymsp[-4].minor.yy332, yymsp[-5].minor.yy432, yymsp[-2].minor.yy432, yymsp[0].minor.yy432); } + yymsp[-5].minor.yy432 = yylhsminor.yy432; break; - case 184: /* join_type ::= */ -{ yymsp[1].minor.yy92 = JOIN_TYPE_INNER; } + case 191: /* join_type ::= */ +{ yymsp[1].minor.yy332 = JOIN_TYPE_INNER; } break; - case 185: /* join_type ::= INNER */ -{ yymsp[0].minor.yy92 = JOIN_TYPE_INNER; } + case 192: /* join_type ::= INNER */ +{ yymsp[0].minor.yy332 = JOIN_TYPE_INNER; } break; - case 186: /* 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 193: /* 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.yy68 = createSelectStmt(pCxt, yymsp[-7].minor.yy25, yymsp[-6].minor.yy40, yymsp[-5].minor.yy68); - yymsp[-8].minor.yy68 = addWhereClause(pCxt, yymsp[-8].minor.yy68, yymsp[-4].minor.yy68); - yymsp[-8].minor.yy68 = addPartitionByClause(pCxt, yymsp[-8].minor.yy68, yymsp[-3].minor.yy40); - yymsp[-8].minor.yy68 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy68, yymsp[-2].minor.yy68); - yymsp[-8].minor.yy68 = addGroupByClause(pCxt, yymsp[-8].minor.yy68, yymsp[-1].minor.yy40); - yymsp[-8].minor.yy68 = addHavingClause(pCxt, yymsp[-8].minor.yy68, yymsp[0].minor.yy68); + yymsp[-8].minor.yy432 = createSelectStmt(pCxt, yymsp[-7].minor.yy97, yymsp[-6].minor.yy24, yymsp[-5].minor.yy432); + yymsp[-8].minor.yy432 = addWhereClause(pCxt, yymsp[-8].minor.yy432, yymsp[-4].minor.yy432); + yymsp[-8].minor.yy432 = addPartitionByClause(pCxt, yymsp[-8].minor.yy432, yymsp[-3].minor.yy24); + yymsp[-8].minor.yy432 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy432, yymsp[-2].minor.yy432); + yymsp[-8].minor.yy432 = addGroupByClause(pCxt, yymsp[-8].minor.yy432, yymsp[-1].minor.yy24); + yymsp[-8].minor.yy432 = addHavingClause(pCxt, yymsp[-8].minor.yy432, yymsp[0].minor.yy432); } break; - case 188: /* set_quantifier_opt ::= DISTINCT */ -{ yymsp[0].minor.yy25 = true; } + case 195: /* set_quantifier_opt ::= DISTINCT */ +{ yymsp[0].minor.yy97 = true; } break; - case 189: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy25 = false; } + case 196: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy97 = false; } break; - case 190: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy40 = NULL; } + case 197: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy24 = NULL; } break; - case 194: /* select_item ::= common_expression */ + case 201: /* select_item ::= common_expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy68), &t); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy432), &t); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 195: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy68 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy68), &yymsp[0].minor.yy5); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + case 202: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy432 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy432), &yymsp[0].minor.yy129); } + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 196: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy68 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), &yymsp[0].minor.yy5); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 203: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy432 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), &yymsp[0].minor.yy129); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 197: /* select_item ::= table_name NK_DOT NK_STAR */ -{ yylhsminor.yy68 = createColumnNode(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 204: /* select_item ::= table_name NK_DOT NK_STAR */ +{ yylhsminor.yy432 = createColumnNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 201: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 218: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==218); - case 228: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==228); -{ yymsp[-2].minor.yy40 = yymsp[0].minor.yy40; } + case 208: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 225: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==225); + case 235: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==235); +{ yymsp[-2].minor.yy24 = yymsp[0].minor.yy24; } break; - case 203: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy68 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy68), &yymsp[-1].minor.yy0); } + case 210: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy432 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy432), &yymsp[-1].minor.yy0); } break; - case 204: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ -{ yymsp[-3].minor.yy68 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy68)); } + case 211: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ +{ yymsp[-3].minor.yy432 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy432)); } break; - case 205: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy68 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy68), NULL, yymsp[-1].minor.yy68, yymsp[0].minor.yy68); } + case 212: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy432 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy432), NULL, yymsp[-1].minor.yy432, yymsp[0].minor.yy432); } break; - case 206: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy68 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy68), releaseRawExprNode(pCxt, yymsp[-3].minor.yy68), yymsp[-1].minor.yy68, yymsp[0].minor.yy68); } + case 213: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy432 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy432), releaseRawExprNode(pCxt, yymsp[-3].minor.yy432), yymsp[-1].minor.yy432, yymsp[0].minor.yy432); } break; - case 208: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ -{ yymsp[-3].minor.yy68 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy68); } + case 215: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ +{ yymsp[-3].minor.yy432 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy432); } break; - case 210: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy68 = createFillNode(pCxt, yymsp[-1].minor.yy94, NULL); } + case 217: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy432 = createFillNode(pCxt, yymsp[-1].minor.yy294, NULL); } break; - case 211: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy68 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy40)); } + case 218: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy432 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy24)); } break; - case 212: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy94 = FILL_MODE_NONE; } + case 219: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy294 = FILL_MODE_NONE; } break; - case 213: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy94 = FILL_MODE_PREV; } + case 220: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy294 = FILL_MODE_PREV; } break; - case 214: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy94 = FILL_MODE_NULL; } + case 221: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy294 = FILL_MODE_NULL; } break; - case 215: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy94 = FILL_MODE_LINEAR; } + case 222: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy294 = FILL_MODE_LINEAR; } break; - case 216: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy94 = FILL_MODE_NEXT; } + case 223: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy294 = FILL_MODE_NEXT; } break; - case 219: /* group_by_list ::= expression */ -{ yylhsminor.yy40 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[0].minor.yy40 = yylhsminor.yy40; + case 226: /* group_by_list ::= expression */ +{ yylhsminor.yy24 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 220: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-2].minor.yy40, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-2].minor.yy40 = yylhsminor.yy40; + case 227: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 223: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 230: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy68 = addOrderByClause(pCxt, yymsp[-3].minor.yy68, yymsp[-2].minor.yy40); - yylhsminor.yy68 = addSlimitClause(pCxt, yylhsminor.yy68, yymsp[-1].minor.yy68); - yylhsminor.yy68 = addLimitClause(pCxt, yylhsminor.yy68, yymsp[0].minor.yy68); + yylhsminor.yy432 = addOrderByClause(pCxt, yymsp[-3].minor.yy432, yymsp[-2].minor.yy24); + yylhsminor.yy432 = addSlimitClause(pCxt, yylhsminor.yy432, yymsp[-1].minor.yy432); + yylhsminor.yy432 = addLimitClause(pCxt, yylhsminor.yy432, yymsp[0].minor.yy432); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + yymsp[-3].minor.yy432 = yylhsminor.yy432; break; - case 225: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy68 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy68, yymsp[0].minor.yy68); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + case 232: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy432 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy432, yymsp[0].minor.yy432); } + yymsp[-3].minor.yy432 = yylhsminor.yy432; break; - case 230: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 234: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==234); -{ yymsp[-1].minor.yy68 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 237: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 241: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==241); +{ yymsp[-1].minor.yy432 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 231: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 235: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==235); -{ yymsp[-3].minor.yy68 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 238: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 242: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==242); +{ yymsp[-3].minor.yy432 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 232: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 236: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==236); -{ yymsp[-3].minor.yy68 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 239: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 243: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==243); +{ yymsp[-3].minor.yy432 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 237: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy68); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 244: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy432); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 238: /* search_condition ::= common_expression */ -{ yylhsminor.yy68 = releaseRawExprNode(pCxt, yymsp[0].minor.yy68); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 245: /* search_condition ::= common_expression */ +{ yylhsminor.yy432 = releaseRawExprNode(pCxt, yymsp[0].minor.yy432); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 241: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy68 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), yymsp[-1].minor.yy54, yymsp[0].minor.yy53); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 248: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy432 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), yymsp[-1].minor.yy378, yymsp[0].minor.yy257); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 242: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy54 = ORDER_ASC; } + case 249: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy378 = ORDER_ASC; } break; - case 243: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy54 = ORDER_ASC; } + case 250: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy378 = ORDER_ASC; } break; - case 244: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy54 = ORDER_DESC; } + case 251: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy378 = ORDER_DESC; } break; - case 245: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy53 = NULL_ORDER_DEFAULT; } + case 252: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy257 = NULL_ORDER_DEFAULT; } break; - case 246: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy53 = NULL_ORDER_FIRST; } + case 253: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy257 = NULL_ORDER_FIRST; } break; - case 247: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy53 = NULL_ORDER_LAST; } + case 254: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy257 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/parserAstTest.cpp b/source/libs/parser/test/parserAstTest.cpp index 259c4712ba..f4c1bde478 100644 --- a/source/libs/parser/test/parserAstTest.cpp +++ b/source/libs/parser/test/parserAstTest.cpp @@ -340,6 +340,23 @@ TEST_F(ParserTest, createDatabase) { ASSERT_TRUE(run()); } +TEST_F(ParserTest, alterDatabase) { + setDatabase("root", "test"); + + bind("alter database wxy_db BLOCKS 200"); + ASSERT_TRUE(run()); + + bind("alter database wxy_db " + "BLOCKS 200 " + "CACHELAST 1 " + "FSYNC 200 " + "KEEP 200 " + "QUORUM 2 " + "WAL 1 " + ); + ASSERT_TRUE(run()); +} + TEST_F(ParserTest, showDatabase) { setDatabase("root", "test"); @@ -406,9 +423,49 @@ TEST_F(ParserTest, createSmaIndex) { ASSERT_TRUE(run()); } +TEST_F(ParserTest, dropIndex) { + setDatabase("root", "test"); + + bind("drop index index1 on t1"); + ASSERT_TRUE(run()); +} + TEST_F(ParserTest, createQnode) { setDatabase("root", "test"); bind("create qnode on dnode 1"); ASSERT_TRUE(run()); } + +TEST_F(ParserTest, dropQnode) { + setDatabase("root", "test"); + + bind("drop qnode on dnode 1"); + ASSERT_TRUE(run()); +} + +TEST_F(ParserTest, createTopic) { + setDatabase("root", "test"); + + bind("create topic tp1 as select * from t1"); + ASSERT_TRUE(run()); + + bind("create topic if not exists tp1 as select * from t1"); + ASSERT_TRUE(run()); + + bind("create topic tp1 as test"); + ASSERT_TRUE(run()); + + bind("create topic if not exists tp1 as test"); + ASSERT_TRUE(run()); +} + +TEST_F(ParserTest, dropTopic) { + setDatabase("root", "test"); + + bind("drop topic tp1"); + ASSERT_TRUE(run()); + + bind("drop topic if exists tp1"); + ASSERT_TRUE(run()); +} From 4046173c48d05f3a6f849ef5443dacb6a7cbc7b9 Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Wed, 16 Mar 2022 14:17:03 +0800 Subject: [PATCH 31/38] [add interval case] --- tests/script/tsim/query/interval.sim | 207 +++++++++++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 tests/script/tsim/query/interval.sim diff --git a/tests/script/tsim/query/interval.sim b/tests/script/tsim/query/interval.sim new file mode 100644 index 0000000000..35e7c938d8 --- /dev/null +++ b/tests/script/tsim/query/interval.sim @@ -0,0 +1,207 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wal -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = m_in_db +$tbPrefix = m_in_tb +$mtPrefix = m_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +print ====== start create child tables and insert data +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb interval(1m) +print ===> $rows +if $rows < $rowNum then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +print =============== step3 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms interval(1m) +print ===> $rows +if $rows > 10 then + return -1 +endi +if $rows < 3 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +print =============== step4 +$cc = 40 * 60000 +$ms = 1601481600000 + $cc + +$cc = 1 * 60000 +$ms2 = 1601481600000 - $cc + +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) +print ===> $rows +if $rows < 18 then + return -1 +endi +if $rows > 22 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +print =============== step5 +$cc = 40 * 60000 +$ms = 1601481600000 + $cc + +$cc = 1 * 60000 +$ms2 = 1601481600000 - $cc + +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) fill(value,0) +print ===> $rows +if $rows < 30 then + return -1 +endi +if $rows > 50 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data25 != 1 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt interval(1m) +print ===> $rows +if $rows < 18 then + return -1 +endi +if $rows > 22 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== step7 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms interval(1m) +print ===> $rows +if $rows < 3 then + return -1 +endi +if $rows > 7 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== step8 +$cc = 40 * 60000 +$ms1 = 1601481600000 + $cc + +$cc = 1 * 60000 +$ms2 = 1601481600000 - $cc + +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) +print ===> $rows +if $rows < 18 then + return -1 +endi +if $rows > 22 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== step9 +$cc = 40 * 60000 +$ms1 = 1601481600000 + $cc + +$cc = 1 * 60000 +$ms2 = 1601481600000 - $cc + +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) fill(value, 0) +if $rows < 30 then + return -1 +endi +if $rows > 50 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file From a9692987d9b411aaa74c1ac6deae54f84dcc2d73 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 16 Mar 2022 14:34:09 +0800 Subject: [PATCH 32/38] handle except and update UT --- source/libs/transport/src/transSrv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/libs/transport/src/transSrv.c b/source/libs/transport/src/transSrv.c index 040c12b880..ec42ab6402 100644 --- a/source/libs/transport/src/transSrv.c +++ b/source/libs/transport/src/transSrv.c @@ -214,7 +214,9 @@ static void uvHandleReq(SSrvConn* pConn) { // pHead = rpcDecompresSTransMsg(pHead); } else { pHead->msgLen = htonl(pHead->msgLen); - // impl later + if (pHead->secured == 1) { + pHead->msgLen -= sizeof(STransUserMsg); + } // } From 5967a4dff8c36f0754352758c900587e0c6e4c36 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Wed, 16 Mar 2022 02:53:25 -0400 Subject: [PATCH 33/38] TD-13597 create/drop topic, alter database, drop index, drop qnode statement implement --- source/dnode/mnode/impl/src/mndTopic.c | 17 +++++++++++++++-- source/dnode/mnode/impl/test/topic/topic.cpp | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index 32fa3df910..e913cae1ac 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -237,6 +237,10 @@ static int32_t mndCheckCreateTopicReq(SCMCreateTopicReq *pCreate) { } static int32_t mndGetPlanString(SCMCreateTopicReq *pCreate, char **pStr) { + if (NULL == pCreate->ast) { + return TSDB_CODE_SUCCESS; + } + SNode* pAst = NULL; int32_t code = nodesStringToNode(pCreate->ast, &pAst); @@ -266,17 +270,23 @@ static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateTopicReq topicObj.dbUid = pDb->uid; topicObj.version = 1; topicObj.sql = pCreate->sql; - topicObj.logicalPlan = NULL; + topicObj.physicalPlan = ""; + topicObj.logicalPlan = ""; topicObj.sqlLen = strlen(pCreate->sql); - if (TSDB_CODE_SUCCESS != mndGetPlanString(pCreate, &topicObj.physicalPlan)) { + char* pPlanStr = NULL; + if (TSDB_CODE_SUCCESS != mndGetPlanString(pCreate, &pPlanStr)) { mError("topic:%s, failed to get plan since %s", pCreate->name, terrstr()); return -1; } + if (NULL != pPlanStr) { + topicObj.physicalPlan = pPlanStr; + } STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_TYPE_CREATE_TOPIC, &pReq->rpcMsg); if (pTrans == NULL) { mError("topic:%s, failed to create since %s", pCreate->name, terrstr()); + tfree(pPlanStr); return -1; } mDebug("trans:%d, used to create topic:%s", pTrans->id, pCreate->name); @@ -284,6 +294,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateTopicReq SSdbRaw *pRedoRaw = mndTopicActionEncode(&topicObj); if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) { mError("trans:%d, failed to append redo log since %s", pTrans->id, terrstr()); + tfree(pPlanStr); mndTransDrop(pTrans); return -1; } @@ -291,10 +302,12 @@ static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateTopicReq if (mndTransPrepare(pMnode, pTrans) != 0) { mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); + tfree(pPlanStr); mndTransDrop(pTrans); return -1; } + tfree(pPlanStr); mndTransDrop(pTrans); return 0; } diff --git a/source/dnode/mnode/impl/test/topic/topic.cpp b/source/dnode/mnode/impl/test/topic/topic.cpp index 79f353a4d6..73eefd875d 100644 --- a/source/dnode/mnode/impl/test/topic/topic.cpp +++ b/source/dnode/mnode/impl/test/topic/topic.cpp @@ -65,7 +65,7 @@ void* MndTestTopic::BuildCreateTopicReq(const char* topicName, const char* sql, strcpy(createReq.name, topicName); createReq.igExists = 0; createReq.sql = (char*)sql; - createReq.ast = (char*)"ast"; + createReq.ast = NULL; int32_t contLen = tSerializeSCMCreateTopicReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); From e10f471b9525e452746c98820f8034c2766741e1 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Wed, 16 Mar 2022 18:19:26 +0800 Subject: [PATCH 34/38] refactor --- include/common/tmsg.h | 25 +--- include/util/taoserror.h | 1 + source/dnode/vnode/src/inc/tsdbDef.h | 9 +- source/dnode/vnode/src/tsdb/tsdbBDBImpl.c | 4 +- source/dnode/vnode/src/tsdb/tsdbSma.c | 170 ++++++++++++++-------- source/dnode/vnode/test/tsdbSmaTest.cpp | 121 +++++++-------- source/util/src/terror.c | 1 + 7 files changed, 184 insertions(+), 147 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index f0718900c0..40bf9a7f62 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1896,33 +1896,18 @@ static FORCE_INLINE void* tDecodeSSchemaWrapper(void* buf, SSchemaWrapper* pSW) } return buf; } -typedef enum { - TD_TIME_UNIT_UNKNOWN = -1, - TD_TIME_UNIT_YEAR = 0, - TD_TIME_UNIT_SEASON = 1, - TD_TIME_UNIT_MONTH = 2, - TD_TIME_UNIT_WEEK = 3, - TD_TIME_UNIT_DAY = 4, - TD_TIME_UNIT_HOUR = 5, - TD_TIME_UNIT_MINUTE = 6, - TD_TIME_UNIT_SEC = 7, - TD_TIME_UNIT_MILLISEC = 8, - TD_TIME_UNIT_MICROSEC = 9, - TD_TIME_UNIT_NANOSEC = 10 -} ETDTimeUnit; - typedef struct { int8_t version; // for compatibility(default 0) - int8_t intervalUnit; - int8_t slidingUnit; + int8_t intervalUnit; // MACRO: TIME_UNIT_XXX + int8_t slidingUnit; // MACRO: TIME_UNIT_XXX char indexName[TSDB_INDEX_NAME_LEN]; - char timezone[TD_TIMEZONE_LEN]; // sma data is invalid if timezone change. + char timezone[TD_TIMEZONE_LEN]; // sma data expired if timezone changes. int32_t exprLen; int32_t tagsFilterLen; int64_t indexUid; tb_uid_t tableUid; // super/child/common table uid int64_t interval; - int64_t offset; + int64_t offset; // use unit by precision of DB int64_t sliding; char* expr; // sma expression char* tagsFilter; @@ -1967,7 +1952,7 @@ typedef struct { typedef struct { int64_t indexUid; - TSKEY skey; // startTS of one interval/sliding + TSKEY skey; // startKey of one interval/sliding window int64_t interval; int32_t dataLen; // not including head int8_t intervalUnit; diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 1c61d738b5..fe06a1c4a2 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -354,6 +354,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_TDB_IVLD_TAG_VAL TAOS_DEF_ERROR_CODE(0, 0x0615) #define TSDB_CODE_TDB_NO_CACHE_LAST_ROW TAOS_DEF_ERROR_CODE(0, 0x0616) #define TSDB_CODE_TDB_NO_SMA_INDEX_IN_META TAOS_DEF_ERROR_CODE(0, 0x0617) +#define TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR TAOS_DEF_ERROR_CODE(0, 0x0618) // query #define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700) diff --git a/source/dnode/vnode/src/inc/tsdbDef.h b/source/dnode/vnode/src/inc/tsdbDef.h index 6f91b4d3ab..5e4c852621 100644 --- a/source/dnode/vnode/src/inc/tsdbDef.h +++ b/source/dnode/vnode/src/inc/tsdbDef.h @@ -60,10 +60,11 @@ struct STsdb { SSmaEnv * pRSmaEnv; }; -#define REPO_ID(r) ((r)->vgId) -#define REPO_CFG(r) (&(r)->config) -#define REPO_FS(r) (r)->fs -#define IS_REPO_LOCKED(r) (r)->repoLocked +#define REPO_ID(r) ((r)->vgId) +#define REPO_CFG(r) (&(r)->config) +#define REPO_FS(r) (r)->fs +#define IS_REPO_LOCKED(r) (r)->repoLocked +#define REPO_SMA_ENV(r, t) ((TSDB_SMA_TYPE_ROLLUP == (t)) ? (r)->pRSmaEnv : (r)->pTSmaEnv) int tsdbLockRepo(STsdb *pTsdb); int tsdbUnlockRepo(STsdb *pTsdb); diff --git a/source/dnode/vnode/src/tsdb/tsdbBDBImpl.c b/source/dnode/vnode/src/tsdb/tsdbBDBImpl.c index cf3351c5d8..ee279abf47 100644 --- a/source/dnode/vnode/src/tsdb/tsdbBDBImpl.c +++ b/source/dnode/vnode/src/tsdb/tsdbBDBImpl.c @@ -68,8 +68,8 @@ int32_t tsdbOpenBDBEnv(DB_ENV **ppEnv, const char *path) { ret = pEnv->open(pEnv, path, DB_CREATE | DB_INIT_CDB | DB_INIT_MPOOL, 0); if (ret != 0) { - // BDB_PERR("Failed to open tsdb env", ret); - tsdbWarn("Failed to open tsdb env for path %s since %d", path ? path : "NULL", ret); + terrno = TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR; + tsdbWarn("Failed to open tsdb env for path %s since ret %d != 0", path ? path : "NULL", ret); return -1; } diff --git a/source/dnode/vnode/src/tsdb/tsdbSma.c b/source/dnode/vnode/src/tsdb/tsdbSma.c index 7335e4f585..880eb403f4 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSma.c +++ b/source/dnode/vnode/src/tsdb/tsdbSma.c @@ -17,7 +17,7 @@ #undef SMA_PRINT_DEBUG_LOG #define SMA_STORAGE_TSDB_DAYS 30 -#define SMA_STORAGE_TSDB_TIMES 30 +#define SMA_STORAGE_TSDB_TIMES 10 #define SMA_STORAGE_SPLIT_HOURS 24 #define SMA_KEY_LEN 18 // tableUid_colId_TSKEY 8+2+8 @@ -93,6 +93,11 @@ static int32_t tsdbGetTSmaDays(STsdb *pTsdb, int64_t interval, int32_t storageLe static int32_t tsdbSetTSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData, int32_t storageLevel, int32_t fid); static int32_t tsdbInitTSmaFile(STSmaReadH *pSmaH, TSKEY skey); static bool tsdbSetAndOpenTSmaFile(STSmaReadH *pReadH, TSKEY *queryKey); +static void tsdbGetSmaDir(int32_t repoid, int8_t smaType, char dirName[]); + +static void tsdbGetSmaDir(int32_t repoid, int8_t smaType, char dirName[]) { + snprintf(dirName, TSDB_FILENAME_LEN, "vnode/vnode%d/tsdb/data", repoid); +} static SSmaEnv *tsdbNewSmaEnv(const STsdb *pTsdb, const char *path) { SSmaEnv *pEnv = NULL; @@ -136,7 +141,7 @@ static int32_t tsdbInitSmaEnv(STsdb *pTsdb, const char *path, SSmaEnv **pEnv) { return TSDB_CODE_FAILED; } - if (pEnv && *pEnv) { + if (*pEnv) { return TSDB_CODE_SUCCESS; } @@ -144,7 +149,7 @@ static int32_t tsdbInitSmaEnv(STsdb *pTsdb, const char *path, SSmaEnv **pEnv) { return TSDB_CODE_FAILED; } - if (*pEnv == NULL) { + if (*pEnv == NULL) { // 2nd phase check if ((*pEnv = tsdbNewSmaEnv(pTsdb, path)) == NULL) { tsdbUnlockRepo(pTsdb); return TSDB_CODE_FAILED; @@ -152,7 +157,7 @@ static int32_t tsdbInitSmaEnv(STsdb *pTsdb, const char *path, SSmaEnv **pEnv) { } if (tsdbUnlockRepo(pTsdb) != 0) { - tsdbFreeSmaEnv(*pEnv); + *pEnv = tsdbFreeSmaEnv(*pEnv); return TSDB_CODE_FAILED; } @@ -244,6 +249,39 @@ int32_t tsdbDestroySmaState(SSmaStat *pSmaStat) { } } +static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) { + switch (smaType) { + case TSDB_SMA_TYPE_TIME_RANGE: + if (pTsdb->pTSmaEnv) { + return TSDB_CODE_SUCCESS; + } + break; + case TSDB_SMA_TYPE_ROLLUP: + if (pTsdb->pRSmaEnv) { + return TSDB_CODE_SUCCESS; + } + break; + default: + terrno = TSDB_CODE_INVALID_PARA; + return TSDB_CODE_FAILED; + } + + // SDiskID did = {0}; + SSmaEnv *pEnv = NULL; + char smaPath[TSDB_FILENAME_LEN] = "/proj/.sma/"; + if (tsdbInitSmaEnv(pTsdb, smaPath, &pEnv) != TSDB_CODE_SUCCESS) { + return TSDB_CODE_FAILED; + } + + if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { + pTsdb->pTSmaEnv = pEnv; + } else { + pTsdb->pRSmaEnv = pEnv; + } + + return TSDB_CODE_SUCCESS; +}; + /** * @brief Update expired window according to msg from stream computing module. * @@ -253,26 +291,17 @@ int32_t tsdbDestroySmaState(SSmaStat *pSmaStat) { * @return int32_t */ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, int8_t smaType, char *msg) { - STsdbCfg *pCfg = REPO_CFG(pTsdb); - SSmaEnv * pEnv = NULL; - if (!msg || !pTsdb->pMeta) { terrno = TSDB_CODE_INVALID_PTR; return TSDB_CODE_FAILED; } - char smaPath[TSDB_FILENAME_LEN] = "/proj/.sma/"; - if (tsdbInitSmaEnv(pTsdb, smaPath, &pEnv) != TSDB_CODE_SUCCESS) { + if (tsdbCheckAndInitSmaEnv(pTsdb, smaType) != TSDB_CODE_SUCCESS) { + terrno = TSDB_CODE_TDB_INIT_FAILED; return TSDB_CODE_FAILED; } - if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { - pTsdb->pTSmaEnv = pEnv; - } else if (smaType == TSDB_SMA_TYPE_ROLLUP) { - pTsdb->pRSmaEnv = pEnv; - } else { - ASSERT(0); - } + SSmaEnv *pEnv = REPO_SMA_ENV(pTsdb, smaType); // TODO: decode the msg => start int64_t indexUid = SMA_TEST_INDEX_UID; @@ -308,7 +337,6 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, int8_t smaType, char *msg) { } pItem->pSma = pSma; - // TODO: change indexName to indexUid if (taosHashPut(pItemsHash, &indexUid, sizeof(indexUid), &pItem, sizeof(pItem)) != 0) { // If error occurs during put smaStatItem, free the resources of pItem taosHashCleanup(pItem->expiredWindows); @@ -378,32 +406,32 @@ static int32_t tsdbResetExpiredWindow(SSmaStat *pStat, int64_t indexUid, TSKEY s static int32_t tsdbGetSmaStorageLevel(int64_t interval, int8_t intervalUnit) { // TODO: configurable for SMA_STORAGE_SPLIT_HOURS? switch (intervalUnit) { - case TD_TIME_UNIT_HOUR: + case TIME_UNIT_HOUR: if (interval < SMA_STORAGE_SPLIT_HOURS) { return SMA_STORAGE_LEVEL_DFILESET; } break; - case TD_TIME_UNIT_MINUTE: + case TIME_UNIT_MINUTE: if (interval < 60 * SMA_STORAGE_SPLIT_HOURS) { return SMA_STORAGE_LEVEL_DFILESET; } break; - case TD_TIME_UNIT_SEC: + case TIME_UNIT_SECOND: if (interval < 3600 * SMA_STORAGE_SPLIT_HOURS) { return SMA_STORAGE_LEVEL_DFILESET; } break; - case TD_TIME_UNIT_MILLISEC: + case TIME_UNIT_MILLISECOND: if (interval < 3600 * 1e3 * SMA_STORAGE_SPLIT_HOURS) { return SMA_STORAGE_LEVEL_DFILESET; } break; - case TD_TIME_UNIT_MICROSEC: + case TIME_UNIT_MICROSECOND: if (interval < 3600 * 1e6 * SMA_STORAGE_SPLIT_HOURS) { return SMA_STORAGE_LEVEL_DFILESET; } break; - case TD_TIME_UNIT_NANOSEC: + case TIME_UNIT_NANOSECOND: if (interval < 3600 * 1e9 * SMA_STORAGE_SPLIT_HOURS) { return SMA_STORAGE_LEVEL_DFILESET; } @@ -429,8 +457,8 @@ static int32_t tsdbInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, uint32_t k // TODO: insert sma data blocks into B+Tree tsdbDebug("vgId:%d insert sma data blocks into %s: smaKey %" PRIx64 "-%" PRIu16 "-%" PRIx64 ", dataLen %d", - REPO_ID(pSmaH->pTsdb), pDBFile->path, *(tb_uid_t *)smaKey, *(uint16_t *)POINTER_SHIFT(smaKey, 8), - *(int64_t *)POINTER_SHIFT(smaKey, 10), dataLen); + REPO_ID(pSmaH->pTsdb), pDBFile->path, *(tb_uid_t *)smaKey, *(uint16_t *)POINTER_SHIFT(smaKey, 8), + *(int64_t *)POINTER_SHIFT(smaKey, 10), dataLen); if (tsdbSaveSmaToDB(pDBFile, smaKey, keyLen, pData, dataLen) != 0) { return TSDB_CODE_FAILED; @@ -447,66 +475,73 @@ static int32_t tsdbInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, uint32_t k return TSDB_CODE_SUCCESS; } +/** + * @brief Approximate value for week/month/year. + * + * @param interval + * @param intervalUnit + * @param precision + * @return int64_t + */ static int64_t tsdbGetIntervalByPrecision(int64_t interval, uint8_t intervalUnit, int8_t precision) { - if (intervalUnit < TD_TIME_UNIT_MILLISEC) { - switch (intervalUnit) { - case TD_TIME_UNIT_YEAR: - case TD_TIME_UNIT_SEASON: - case TD_TIME_UNIT_MONTH: - case TD_TIME_UNIT_WEEK: - // illegal time unit - tsdbError("invalid interval unit: %d\n", intervalUnit); - TASSERT(0); - break; - case TD_TIME_UNIT_DAY: // the interval for tSma calculation must <= day - interval *= 86400 * 1e3; - break; - case TD_TIME_UNIT_HOUR: - interval *= 3600 * 1e3; - break; - case TD_TIME_UNIT_MINUTE: - interval *= 60 * 1e3; - break; - case TD_TIME_UNIT_SEC: - interval *= 1e3; - break; - default: - break; - } + switch (intervalUnit) { + case TIME_UNIT_YEAR: // approximate value + interval *= 365 * 86400 * 1e3; + break; + case TIME_UNIT_MONTH: // approximate value + interval *= 30 * 86400 * 1e3; + break; + case TIME_UNIT_WEEK: // approximate value + interval *= 7 * 86400 * 1e3; + break; + case TIME_UNIT_DAY: // the interval for tSma calculation must <= day + interval *= 86400 * 1e3; + break; + case TIME_UNIT_HOUR: + interval *= 3600 * 1e3; + break; + case TIME_UNIT_MINUTE: + interval *= 60 * 1e3; + break; + case TIME_UNIT_SECOND: + interval *= 1e3; + break; + default: + break; } switch (precision) { case TSDB_TIME_PRECISION_MILLI: - if (TD_TIME_UNIT_MICROSEC == intervalUnit) { // us + if (TIME_UNIT_MICROSECOND == intervalUnit) { // us return interval / 1e3; - } else if (TD_TIME_UNIT_NANOSEC == intervalUnit) { // nano second + } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // nano second return interval / 1e6; } else { return interval; } break; case TSDB_TIME_PRECISION_MICRO: - if (TD_TIME_UNIT_MICROSEC == intervalUnit) { // us + if (TIME_UNIT_MICROSECOND == intervalUnit) { // us return interval; - } else if (TD_TIME_UNIT_NANOSEC == intervalUnit) { // nano second + } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // nano second return interval / 1e3; } else { return interval * 1e3; } break; case TSDB_TIME_PRECISION_NANO: - if (TD_TIME_UNIT_MICROSEC == intervalUnit) { + if (TIME_UNIT_MICROSECOND == intervalUnit) { return interval * 1e3; - } else if (TD_TIME_UNIT_NANOSEC == intervalUnit) { // nano second + } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // nano second return interval; } else { return interval * 1e6; } break; default: // ms - if (TD_TIME_UNIT_MICROSEC == intervalUnit) { // us + if (TIME_UNIT_MICROSECOND == intervalUnit) { // us return interval / 1e3; - } else if (TD_TIME_UNIT_NANOSEC == intervalUnit) { // nano second + } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // nano second return interval / 1e6; } else { return interval; @@ -800,10 +835,19 @@ static bool tsdbSetAndOpenTSmaFile(STSmaReadH *pReadH, TSKEY *queryKey) { static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval, int8_t intervalUnit, tb_uid_t tableUid, col_id_t colId, TSKEY querySkey, int32_t nMaxResult) { + if (!pTsdb->pTSmaEnv) { + terrno = TSDB_CODE_INVALID_PTR; + tsdbWarn("vgId:%d getTSmaDataImpl failed since pTSmaEnv is NULL", REPO_ID(pTsdb)); + return TSDB_CODE_FAILED; + } + SSmaStatItem *pItem = (SSmaStatItem *)taosHashGet(SMA_ENV_STAT_ITEMS(pTsdb->pTSmaEnv), &indexUid, sizeof(indexUid)); if (pItem == NULL) { - // mark all window as expired and notify query module to query raw TS data. - return TSDB_CODE_SUCCESS; + // Normally pItem should not be NULL, mark all windows as expired and notify query module to fetch raw TS data if + // it's NULL. + terrno = TSDB_CODE_TDB_INVALID_ACTION; + tsdbWarn("vgId:%d getTSmaDataImpl failed since no index %" PRIi64 " in local cache", REPO_ID(pTsdb), indexUid); + return TSDB_CODE_FAILED; } #if 0 @@ -815,6 +859,7 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_ } } #endif + #if 0 if (taosHashGet(pItem->expiredWindows, &querySkey, sizeof(TSKEY)) != NULL) { // TODO: mark this window as expired. @@ -835,8 +880,8 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_ tsdbEncodeTSmaKey(tableUid, colId, querySkey, (void **)&pSmaKey); tsdbDebug("vgId:%d get sma data from %s: smaKey %" PRIx64 "-%" PRIu16 "-%" PRIx64 ", keyLen %d", REPO_ID(pTsdb), - tReadH.dFile.path, *(tb_uid_t *)smaKey, *(uint16_t *)POINTER_SHIFT(smaKey, 8), - *(int64_t *)POINTER_SHIFT(smaKey, 10), SMA_KEY_LEN); + tReadH.dFile.path, *(tb_uid_t *)smaKey, *(uint16_t *)POINTER_SHIFT(smaKey, 8), + *(int64_t *)POINTER_SHIFT(smaKey, 10), SMA_KEY_LEN); void * result = NULL; uint32_t valueSize = 0; @@ -947,7 +992,6 @@ int32_t tsdbUpdateSmaWindow(STsdb *pTsdb, int8_t smaType, char *msg) { * @brief Insert Time-range-wise Rollup Sma(RSma) data * * @param pTsdb - * @param param * @param msg * @return int32_t */ diff --git a/source/dnode/vnode/test/tsdbSmaTest.cpp b/source/dnode/vnode/test/tsdbSmaTest.cpp index 18dca33bda..96fd35e700 100644 --- a/source/dnode/vnode/test/tsdbSmaTest.cpp +++ b/source/dnode/vnode/test/tsdbSmaTest.cpp @@ -37,9 +37,9 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) { // encode STSma tSma = {0}; tSma.version = 0; - tSma.intervalUnit = TD_TIME_UNIT_DAY; + tSma.intervalUnit = TIME_UNIT_DAY; tSma.interval = 1; - tSma.slidingUnit = TD_TIME_UNIT_HOUR; + tSma.slidingUnit = TIME_UNIT_HOUR; tSma.sliding = 0; tstrncpy(tSma.indexName, "sma_index_test", TSDB_INDEX_NAME_LEN); tstrncpy(tSma.timezone, "Asia/Shanghai", TD_TIMEZONE_LEN); @@ -50,37 +50,37 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) { uint32_t bufLen = tEncodeTSmaWrapper(NULL, &tSmaWrapper); void *buf = calloc(bufLen, 1); - assert(buf != NULL); + ASSERT_NE(buf, nullptr); STSmaWrapper *pSW = (STSmaWrapper *)buf; uint32_t len = tEncodeTSmaWrapper(&buf, &tSmaWrapper); - EXPECT_EQ(len, bufLen); + ASSERT_EQ(len, bufLen); // decode STSmaWrapper dstTSmaWrapper = {0}; void * result = tDecodeTSmaWrapper(pSW, &dstTSmaWrapper); - assert(result != NULL); + ASSERT_NE(result, nullptr); - EXPECT_EQ(tSmaWrapper.number, dstTSmaWrapper.number); + ASSERT_EQ(tSmaWrapper.number, dstTSmaWrapper.number); for (int i = 0; i < tSmaWrapper.number; ++i) { STSma *pSma = tSmaWrapper.tSma + i; STSma *qSma = dstTSmaWrapper.tSma + i; - EXPECT_EQ(pSma->version, qSma->version); - EXPECT_EQ(pSma->intervalUnit, qSma->intervalUnit); - EXPECT_EQ(pSma->slidingUnit, qSma->slidingUnit); - EXPECT_STRCASEEQ(pSma->indexName, qSma->indexName); - EXPECT_STRCASEEQ(pSma->timezone, qSma->timezone); - EXPECT_EQ(pSma->indexUid, qSma->indexUid); - EXPECT_EQ(pSma->tableUid, qSma->tableUid); - EXPECT_EQ(pSma->interval, qSma->interval); - EXPECT_EQ(pSma->sliding, qSma->sliding); - EXPECT_EQ(pSma->exprLen, qSma->exprLen); - EXPECT_STRCASEEQ(pSma->expr, qSma->expr); - EXPECT_EQ(pSma->tagsFilterLen, qSma->tagsFilterLen); - EXPECT_STRCASEEQ(pSma->tagsFilter, qSma->tagsFilter); + ASSERT_EQ(pSma->version, qSma->version); + ASSERT_EQ(pSma->intervalUnit, qSma->intervalUnit); + ASSERT_EQ(pSma->slidingUnit, qSma->slidingUnit); + ASSERT_STRCASEEQ(pSma->indexName, qSma->indexName); + ASSERT_STRCASEEQ(pSma->timezone, qSma->timezone); + ASSERT_EQ(pSma->indexUid, qSma->indexUid); + ASSERT_EQ(pSma->tableUid, qSma->tableUid); + ASSERT_EQ(pSma->interval, qSma->interval); + ASSERT_EQ(pSma->sliding, qSma->sliding); + ASSERT_EQ(pSma->exprLen, qSma->exprLen); + ASSERT_STRCASEEQ(pSma->expr, qSma->expr); + ASSERT_EQ(pSma->tagsFilterLen, qSma->tagsFilterLen); + ASSERT_STRCASEEQ(pSma->tagsFilter, qSma->tagsFilter); } // resource release @@ -103,9 +103,9 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { // encode STSma tSma = {0}; tSma.version = 0; - tSma.intervalUnit = TD_TIME_UNIT_DAY; + tSma.intervalUnit = TIME_UNIT_DAY; tSma.interval = 1; - tSma.slidingUnit = TD_TIME_UNIT_HOUR; + tSma.slidingUnit = TIME_UNIT_HOUR; tSma.sliding = 0; tSma.indexUid = indexUid1; tstrncpy(tSma.indexName, smaIndexName1, TSDB_INDEX_NAME_LEN); @@ -114,10 +114,12 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { tSma.exprLen = strlen(expr); tSma.expr = (char *)calloc(tSma.exprLen + 1, 1); + ASSERT_NE(tSma.expr, nullptr); tstrncpy(tSma.expr, expr, tSma.exprLen + 1); tSma.tagsFilterLen = strlen(tagsFilter); tSma.tagsFilter = (char *)calloc(tSma.tagsFilterLen + 1, 1); + ASSERT_NE(tSma.tagsFilter, nullptr); tstrncpy(tSma.tagsFilter, tagsFilter, tSma.tagsFilterLen + 1); SMeta * pMeta = NULL; @@ -129,18 +131,18 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { pMeta = metaOpen(smaTestDir, pMetaCfg, NULL); assert(pMeta != NULL); // save index 1 - EXPECT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); + ASSERT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); pSmaCfg->indexUid = indexUid2; tstrncpy(pSmaCfg->indexName, smaIndexName2, TSDB_INDEX_NAME_LEN); pSmaCfg->version = 1; - pSmaCfg->intervalUnit = TD_TIME_UNIT_HOUR; + pSmaCfg->intervalUnit = TIME_UNIT_HOUR; pSmaCfg->interval = 1; - pSmaCfg->slidingUnit = TD_TIME_UNIT_MINUTE; + pSmaCfg->slidingUnit = TIME_UNIT_MINUTE; pSmaCfg->sliding = 5; // save index 2 - EXPECT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); + ASSERT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); // get value by indexName STSma *qSmaCfg = NULL; @@ -150,8 +152,8 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { printf("timezone1 = %s\n", qSmaCfg->timezone); printf("expr1 = %s\n", qSmaCfg->expr != NULL ? qSmaCfg->expr : ""); printf("tagsFilter1 = %s\n", qSmaCfg->tagsFilter != NULL ? qSmaCfg->tagsFilter : ""); - EXPECT_STRCASEEQ(qSmaCfg->indexName, smaIndexName1); - EXPECT_EQ(qSmaCfg->tableUid, tSma.tableUid); + ASSERT_STRCASEEQ(qSmaCfg->indexName, smaIndexName1); + ASSERT_EQ(qSmaCfg->tableUid, tSma.tableUid); tdDestroyTSma(qSmaCfg); tfree(qSmaCfg); @@ -161,8 +163,8 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { printf("timezone2 = %s\n", qSmaCfg->timezone); printf("expr2 = %s\n", qSmaCfg->expr != NULL ? qSmaCfg->expr : ""); printf("tagsFilter2 = %s\n", qSmaCfg->tagsFilter != NULL ? qSmaCfg->tagsFilter : ""); - EXPECT_STRCASEEQ(qSmaCfg->indexName, smaIndexName2); - EXPECT_EQ(qSmaCfg->interval, tSma.interval); + ASSERT_STRCASEEQ(qSmaCfg->indexName, smaIndexName2); + ASSERT_EQ(qSmaCfg->interval, tSma.interval); tdDestroyTSma(qSmaCfg); tfree(qSmaCfg); @@ -178,25 +180,25 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { printf("indexName = %s\n", indexName); ++indexCnt; } - EXPECT_EQ(indexCnt, nCntTSma); + ASSERT_EQ(indexCnt, nCntTSma); metaCloseSmaCurosr(pSmaCur); // get wrapper by table uid STSmaWrapper *pSW = metaGetSmaInfoByTable(pMeta, tbUid); assert(pSW != NULL); - EXPECT_EQ(pSW->number, nCntTSma); - EXPECT_STRCASEEQ(pSW->tSma->indexName, smaIndexName1); - EXPECT_STRCASEEQ(pSW->tSma->timezone, timezone); - EXPECT_STRCASEEQ(pSW->tSma->expr, expr); - EXPECT_STRCASEEQ(pSW->tSma->tagsFilter, tagsFilter); - EXPECT_EQ(pSW->tSma->indexUid, indexUid1); - EXPECT_EQ(pSW->tSma->tableUid, tbUid); - EXPECT_STRCASEEQ((pSW->tSma + 1)->indexName, smaIndexName2); - EXPECT_STRCASEEQ((pSW->tSma + 1)->timezone, timezone); - EXPECT_STRCASEEQ((pSW->tSma + 1)->expr, expr); - EXPECT_STRCASEEQ((pSW->tSma + 1)->tagsFilter, tagsFilter); - EXPECT_EQ((pSW->tSma + 1)->indexUid, indexUid2); - EXPECT_EQ((pSW->tSma + 1)->tableUid, tbUid); + ASSERT_EQ(pSW->number, nCntTSma); + ASSERT_STRCASEEQ(pSW->tSma->indexName, smaIndexName1); + ASSERT_STRCASEEQ(pSW->tSma->timezone, timezone); + ASSERT_STRCASEEQ(pSW->tSma->expr, expr); + ASSERT_STRCASEEQ(pSW->tSma->tagsFilter, tagsFilter); + ASSERT_EQ(pSW->tSma->indexUid, indexUid1); + ASSERT_EQ(pSW->tSma->tableUid, tbUid); + ASSERT_STRCASEEQ((pSW->tSma + 1)->indexName, smaIndexName2); + ASSERT_STRCASEEQ((pSW->tSma + 1)->timezone, timezone); + ASSERT_STRCASEEQ((pSW->tSma + 1)->expr, expr); + ASSERT_STRCASEEQ((pSW->tSma + 1)->tagsFilter, tagsFilter); + ASSERT_EQ((pSW->tSma + 1)->indexUid, indexUid2); + ASSERT_EQ((pSW->tSma + 1)->tableUid, tbUid); tdDestroyTSmaWrapper(pSW); tfree(pSW); @@ -208,7 +210,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { printf("metaGetSmaTbUids: uid[%" PRIu32 "] = %" PRIi64 "\n", i, *(tb_uid_t *)taosArrayGet(pUids, i)); // printf("metaGetSmaTbUids: index[%" PRIu32 "] = %s", i, (char *)taosArrayGet(pUids, i)); } - EXPECT_EQ(taosArrayGetSize(pUids), 1); + ASSERT_EQ(taosArrayGetSize(pUids), 1); taosArrayDestroy(pUids); // resource release @@ -231,7 +233,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { const tb_uid_t tbUid = 1234567890; const int64_t indexUid1 = 2000000001; const int64_t interval1 = 1; - const int8_t intervalUnit1 = TD_TIME_UNIT_DAY; + const int8_t intervalUnit1 = TIME_UNIT_DAY; const uint32_t nCntTSma = 2; TSKEY skey1 = 1646987196; const int64_t testSmaData1 = 100; @@ -239,9 +241,9 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { // encode STSma tSma = {0}; tSma.version = 0; - tSma.intervalUnit = TD_TIME_UNIT_DAY; + tSma.intervalUnit = TIME_UNIT_DAY; tSma.interval = 1; - tSma.slidingUnit = TD_TIME_UNIT_HOUR; + tSma.slidingUnit = TIME_UNIT_HOUR; tSma.sliding = 0; tSma.indexUid = indexUid1; tstrncpy(tSma.indexName, smaIndexName1, TSDB_INDEX_NAME_LEN); @@ -250,10 +252,12 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { tSma.exprLen = strlen(expr); tSma.expr = (char *)calloc(tSma.exprLen + 1, 1); + ASSERT_NE(tSma.expr, nullptr); tstrncpy(tSma.expr, expr, tSma.exprLen + 1); tSma.tagsFilterLen = strlen(tagsFilter); tSma.tagsFilter = (char *)calloc(tSma.tagsFilterLen + 1, 1); + ASSERT_NE(tSma.tagsFilter, nullptr); tstrncpy(tSma.tagsFilter, tagsFilter, tSma.tagsFilterLen + 1); SMeta * pMeta = NULL; @@ -265,7 +269,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { pMeta = metaOpen(smaTestDir, pMetaCfg, NULL); assert(pMeta != NULL); // save index 1 - EXPECT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); + ASSERT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); // step 2: insert data STSmaDataWrapper *pSmaData = NULL; @@ -298,18 +302,19 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { } char *msg = (char *)calloc(100, 1); - EXPECT_EQ(tsdbUpdateSmaWindow(&tsdb, TSDB_SMA_TYPE_TIME_RANGE, msg), 0); + assert(msg != NULL); + ASSERT_EQ(tsdbUpdateSmaWindow(&tsdb, TSDB_SMA_TYPE_TIME_RANGE, msg), 0); // init int32_t allocCnt = 0; - int32_t allocStep = 40960; - int32_t buffer = 4096; + int32_t allocStep = 16384; + int32_t buffer = 1024; void * buf = NULL; - EXPECT_EQ(tsdbMakeRoom(&buf, allocStep), 0); + ASSERT_EQ(tsdbMakeRoom(&buf, allocStep), 0); int32_t bufSize = taosTSizeof(buf); int32_t numOfTables = 10; col_id_t numOfCols = 4096; - EXPECT_GT(numOfCols, 0); + ASSERT_GT(numOfCols, 0); pSmaData = (STSmaDataWrapper *)buf; printf(">> allocate [%d] time to %d and addr is %p\n", ++allocCnt, bufSize, pSmaData); @@ -326,7 +331,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { int32_t tableDataLen = sizeof(STSmaTbData); for (col_id_t c = 0; c < numOfCols; ++c) { if (bufSize - len - tableDataLen < buffer) { - EXPECT_EQ(tsdbMakeRoom(&buf, bufSize + allocStep), 0); + ASSERT_EQ(tsdbMakeRoom(&buf, bufSize + allocStep), 0); pSmaData = (STSmaDataWrapper *)buf; pTbData = (STSmaTbData *)POINTER_SHIFT(pSmaData, len); bufSize = taosTSizeof(buf); @@ -353,22 +358,22 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { } pSmaData->dataLen = (len - sizeof(STSmaDataWrapper)); - EXPECT_GE(bufSize, pSmaData->dataLen); + ASSERT_GE(bufSize, pSmaData->dataLen); // execute - EXPECT_EQ(tsdbInsertTSmaData(&tsdb, (char *)pSmaData), TSDB_CODE_SUCCESS); + ASSERT_EQ(tsdbInsertTSmaData(&tsdb, (char *)pSmaData), TSDB_CODE_SUCCESS); // step 3: query uint32_t checkDataCnt = 0; for (int32_t t = 0; t < numOfTables; ++t) { for (col_id_t c = 0; c < numOfCols; ++c) { - EXPECT_EQ(tsdbGetTSmaData(&tsdb, NULL, indexUid1, interval1, intervalUnit1, tbUid + t, + ASSERT_EQ(tsdbGetTSmaData(&tsdb, NULL, indexUid1, interval1, intervalUnit1, tbUid + t, c + PRIMARYKEY_TIMESTAMP_COL_ID, skey1, 1), TSDB_CODE_SUCCESS); ++checkDataCnt; } } - + printf("%s:%d The sma data check count for insert and query is %" PRIu32 "\n", __FILE__, __LINE__, checkDataCnt); // release data diff --git a/source/util/src/terror.c b/source/util/src/terror.c index f97df62ccc..469b944bf9 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -350,6 +350,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TDB_MESSED_MSG, "TSDB messed message") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_IVLD_TAG_VAL, "TSDB invalid tag value") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_CACHE_LAST_ROW, "TSDB no cache last row data") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_SMA_INDEX_IN_META, "No sma index in meta") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR, "TDB env open error") // query TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_QHANDLE, "Invalid handle") From 18f254a0178cd1487b3e31dee4994da4f30d3d9b Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Wed, 16 Mar 2022 18:29:31 +0800 Subject: [PATCH 35/38] task deploy and task exec --- include/common/tcommon.h | 21 +++-- include/common/tmsg.h | 100 ++++++++++++++------- include/common/tmsgdef.h | 1 + include/dnode/snode/snode.h | 3 +- source/common/src/tmsg.c | 72 ++++++++++----- source/dnode/mgmt/impl/src/dndSnode.c | 27 ++++-- source/dnode/mnode/impl/inc/mndDef.h | 10 +-- source/dnode/mnode/impl/inc/mndScheduler.h | 2 + source/dnode/mnode/impl/src/mndScheduler.c | 75 ++++++++++------ source/dnode/mnode/impl/src/mndStream.c | 7 ++ source/dnode/snode/CMakeLists.txt | 3 +- source/dnode/snode/inc/sndInt.h | 31 ++----- source/dnode/snode/src/snode.c | 75 +++++++++++++--- 13 files changed, 285 insertions(+), 142 deletions(-) diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 23dd349861..cb8b077b47 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -58,7 +58,10 @@ typedef struct SDataBlockInfo { int32_t rows; int32_t rowSize; int32_t numOfCols; - union {int64_t uid; int64_t blockId;}; + union { + int64_t uid; + int64_t blockId; + }; } SDataBlockInfo; typedef struct SConstantItem { @@ -70,10 +73,10 @@ typedef struct SConstantItem { // info.numOfCols = taosArrayGetSize(pDataBlock) + taosArrayGetSize(pConstantList); typedef struct SSDataBlock { - SColumnDataAgg *pBlockAgg; - SArray *pDataBlock; // SArray - SArray *pConstantList; // SArray, it is a constant/tags value of the corresponding result value. - SDataBlockInfo info; + SColumnDataAgg* pBlockAgg; + SArray* pDataBlock; // SArray + SArray* pConstantList; // SArray, it is a constant/tags value of the corresponding result value. + SDataBlockInfo info; } SSDataBlock; typedef struct SVarColAttr { @@ -244,7 +247,7 @@ typedef struct SGroupbyExpr { typedef struct SFunctParam { int32_t type; - SColumn *pCol; + SColumn* pCol; SVariant param; } SFunctParam; @@ -262,12 +265,12 @@ typedef struct SResSchame { typedef struct SExprBasicInfo { SResSchema resSchema; int16_t numOfParams; // argument value of each function - SFunctParam *pParam; + SFunctParam* pParam; } SExprBasicInfo; typedef struct SExprInfo { - struct SExprBasicInfo base; - struct tExprNode *pExpr; + struct SExprBasicInfo base; + struct tExprNode* pExpr; } SExprInfo; typedef struct SStateWindow { diff --git a/include/common/tmsg.h b/include/common/tmsg.h index a3e35e1874..30f61374ea 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -24,6 +24,7 @@ #include "thash.h" #include "tlist.h" #include "trow.h" +#include "tuuid.h" #ifdef __cplusplus extern "C" { @@ -171,7 +172,7 @@ typedef struct { char db[TSDB_DB_FNAME_LEN]; int64_t dbId; int32_t vgVersion; - int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT + int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT } SBuildUseDBInput; typedef struct SField { @@ -427,10 +428,10 @@ typedef struct { int16_t slotId; }; - int16_t type; - int32_t bytes; - uint8_t precision; - uint8_t scale; + int16_t type; + int32_t bytes; + uint8_t precision; + uint8_t scale; } SColumnInfo; typedef struct { @@ -526,7 +527,7 @@ typedef struct { char db[TSDB_DB_FNAME_LEN]; int64_t dbId; int32_t vgVersion; - int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT + int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT } SUseDbReq; int32_t tSerializeSUseDbReq(void* buf, int32_t bufLen, SUseDbReq* pReq); @@ -553,15 +554,13 @@ int32_t tSerializeSQnodeListReq(void* buf, int32_t bufLen, SQnodeListReq* pReq); int32_t tDeserializeSQnodeListReq(void* buf, int32_t bufLen, SQnodeListReq* pReq); typedef struct { - SArray *epSetList; // SArray + SArray* epSetList; // SArray } SQnodeListRsp; int32_t tSerializeSQnodeListRsp(void* buf, int32_t bufLen, SQnodeListRsp* pRsp); int32_t tDeserializeSQnodeListRsp(void* buf, int32_t bufLen, SQnodeListRsp* pRsp); void tFreeSQnodeListRsp(SQnodeListRsp* pRsp); - - typedef struct { SArray* pArray; // Array of SUseDbRsp } SUseDbBatchRsp; @@ -777,7 +776,6 @@ typedef struct SVgroupInfo { int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT } SVgroupInfo; - typedef struct { int32_t numOfVgroups; SVgroupInfo vgroups[]; @@ -1062,8 +1060,8 @@ typedef struct { } STaskStatus; typedef struct { - int64_t refId; - SArray *taskStatus; //SArray + int64_t refId; + SArray* taskStatus; // SArray } SSchedulerStatusRsp; typedef struct { @@ -1072,35 +1070,31 @@ typedef struct { int8_t action; } STaskAction; - typedef struct SQueryNodeEpId { int32_t nodeId; // vgId or qnodeId SEp ep; } SQueryNodeEpId; - typedef struct { SMsgHead header; uint64_t sId; SQueryNodeEpId epId; - SArray *taskAction; //SArray + SArray* taskAction; // SArray } SSchedulerHbReq; -int32_t tSerializeSSchedulerHbReq(void *buf, int32_t bufLen, SSchedulerHbReq *pReq); -int32_t tDeserializeSSchedulerHbReq(void *buf, int32_t bufLen, SSchedulerHbReq *pReq); -void tFreeSSchedulerHbReq(SSchedulerHbReq *pReq); - +int32_t tSerializeSSchedulerHbReq(void* buf, int32_t bufLen, SSchedulerHbReq* pReq); +int32_t tDeserializeSSchedulerHbReq(void* buf, int32_t bufLen, SSchedulerHbReq* pReq); +void tFreeSSchedulerHbReq(SSchedulerHbReq* pReq); typedef struct { uint64_t seqId; SQueryNodeEpId epId; - SArray *taskStatus; //SArray + SArray* taskStatus; // SArray } SSchedulerHbRsp; -int32_t tSerializeSSchedulerHbRsp(void *buf, int32_t bufLen, SSchedulerHbRsp *pRsp); -int32_t tDeserializeSSchedulerHbRsp(void *buf, int32_t bufLen, SSchedulerHbRsp *pRsp); -void tFreeSSchedulerHbRsp(SSchedulerHbRsp *pRsp); - +int32_t tSerializeSSchedulerHbRsp(void* buf, int32_t bufLen, SSchedulerHbRsp* pRsp); +int32_t tDeserializeSSchedulerHbRsp(void* buf, int32_t bufLen, SSchedulerHbRsp* pRsp); +void tFreeSSchedulerHbRsp(SSchedulerHbRsp* pRsp); typedef struct { SMsgHead header; @@ -1370,7 +1364,7 @@ typedef struct SVCreateTbReq { } SVCreateTbReq, SVUpdateTbReq; typedef struct { - int tmp; // TODO: to avoid compile error + int tmp; // TODO: to avoid compile error } SVCreateTbRsp, SVUpdateTbRsp; int32_t tSerializeSVCreateTbReq(void** buf, SVCreateTbReq* pReq); @@ -1382,7 +1376,7 @@ typedef struct { } SVCreateTbBatchReq; typedef struct { - int tmp; // TODO: to avoid compile error + int tmp; // TODO: to avoid compile error } SVCreateTbBatchRsp; int32_t tSerializeSVCreateTbBatchReq(void** buf, SVCreateTbBatchReq* pReq); @@ -1396,7 +1390,7 @@ typedef struct { } SVDropTbReq; typedef struct { - int tmp; // TODO: to avoid compile error + int tmp; // TODO: to avoid compile error } SVDropTbRsp; int32_t tSerializeSVDropTbReq(void** buf, SVDropTbReq* pReq); @@ -1933,7 +1927,7 @@ typedef struct { } SVCreateTSmaReq; typedef struct { - int8_t type; // 0 status report, 1 update data + int8_t type; // 0 status report, 1 update data char indexName[TSDB_INDEX_NAME_LEN]; // STimeWindow windows; } STSmaMsg; @@ -1944,7 +1938,7 @@ typedef struct { } SVDropTSmaReq; typedef struct { - int tmp; // TODO: to avoid compile error + int tmp; // TODO: to avoid compile error } SVCreateTSmaRsp, SVDropTSmaRsp; int32_t tSerializeSVCreateTSmaReq(void** buf, SVCreateTSmaReq* pReq); @@ -2029,7 +2023,7 @@ static FORCE_INLINE int32_t tEncodeTSma(void** buf, const STSma* pSma) { tlen += taosEncodeFixedI64(buf, pSma->tableUid); tlen += taosEncodeFixedI64(buf, pSma->interval); tlen += taosEncodeFixedI64(buf, pSma->sliding); - + if (pSma->exprLen > 0) { tlen += taosEncodeString(buf, pSma->expr); } @@ -2064,7 +2058,6 @@ static FORCE_INLINE void* tDecodeTSma(void* buf, STSma* pSma) { buf = taosDecodeFixedI64(buf, &pSma->interval); buf = taosDecodeFixedI64(buf, &pSma->sliding); - if (pSma->exprLen > 0) { pSma->expr = (char*)calloc(pSma->exprLen, 1); if (pSma->expr != NULL) { @@ -2265,6 +2258,51 @@ static FORCE_INLINE void* tDecodeSMqCMGetSubEpRsp(void* buf, SMqCMGetSubEpRsp* p return buf; } +enum { + STREAM_TASK_STATUS__RUNNING = 1, + STREAM_TASK_STATUS__STOP, +}; + +typedef struct { + int64_t streamId; + int32_t taskId; + int32_t level; + int8_t status; + char* qmsg; + void* executor; + // void* stateStore; + // storage handle +} SStreamTask; + +static FORCE_INLINE SStreamTask* streamTaskNew(int64_t streamId, int32_t level) { + SStreamTask* pTask = (SStreamTask*)calloc(1, sizeof(SStreamTask)); + if (pTask == NULL) { + return NULL; + } + pTask->taskId = tGenIdPI32(); + pTask->status = STREAM_TASK_STATUS__RUNNING; + pTask->qmsg = NULL; + return pTask; +} + +int32_t tEncodeSStreamTask(SCoder* pEncoder, const SStreamTask* pTask); +int32_t tDecodeSStreamTask(SCoder* pDecoder, SStreamTask* pTask); +void tFreeSStreamTask(SStreamTask* pTask); + +typedef struct { + SMsgHead head; + SStreamTask* task; +} SStreamTaskDeployReq; + +typedef struct { + int32_t reserved; +} SStreamTaskDeployRsp; + +typedef struct { + SMsgHead head; + // TODO: other info needed by task +} SStreamTaskExecReq; + #pragma pack(pop) #ifdef __cplusplus diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index 03f8daad42..b30a325d7c 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -199,6 +199,7 @@ enum { // Requests handled by SNODE TD_NEW_MSG_SEG(TDMT_SND_MSG) + TD_DEF_MSG_TYPE(TDMT_SND_TASK_DEPLOY, "snode-task-deploy", SStreamTaskDeployReq, SStreamTaskDeployRsp) #if defined(TD_MSG_NUMBER_) TDMT_MAX diff --git a/include/dnode/snode/snode.h b/include/dnode/snode/snode.h index 21a93532e0..b25f8a8666 100644 --- a/include/dnode/snode/snode.h +++ b/include/dnode/snode/snode.h @@ -16,6 +16,7 @@ #ifndef _TD_SNODE_H_ #define _TD_SNODE_H_ +#include "tcommon.h" #include "tmsg.h" #include "trpc.h" @@ -78,7 +79,7 @@ int32_t sndGetLoad(SSnode *pSnode, SSnodeLoad *pLoad); * @param pRsp The response message * @return int32_t 0 for success, -1 for failure */ -int32_t sndProcessMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp); +// int32_t sndProcessMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp); int32_t sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg); diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index f26f19f3b2..121f5271b3 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -1467,8 +1467,7 @@ int32_t tDeserializeSUseDbReq(void *buf, int32_t bufLen, SUseDbReq *pReq) { return 0; } - -int32_t tSerializeSQnodeListReq(void* buf, int32_t bufLen, SQnodeListReq* pReq) { +int32_t tSerializeSQnodeListReq(void *buf, int32_t bufLen, SQnodeListReq *pReq) { SCoder encoder = {0}; tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); @@ -1499,7 +1498,7 @@ int32_t tSerializeSQnodeListRsp(void *buf, int32_t bufLen, SQnodeListRsp *pRsp) if (tStartEncode(&encoder) < 0) return -1; int32_t num = taosArrayGetSize(pRsp->epSetList); - if (tEncodeI32(&encoder, num) < 0) return -1; + if (tEncodeI32(&encoder, num) < 0) return -1; for (int32_t i = 0; i < num; ++i) { SEpSet *epSet = taosArrayGet(pRsp->epSetList, i); if (tEncodeSEpSet(&encoder, epSet) < 0) return -1; @@ -2491,27 +2490,27 @@ int32_t tSerializeSSchedulerHbReq(void *buf, int32_t bufLen, SSchedulerHbReq *pR tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); if (tStartEncode(&encoder) < 0) return -1; - if (tEncodeU64(&encoder, pReq->sId) < 0) return -1; - if (tEncodeI32(&encoder, pReq->epId.nodeId) < 0) return -1; + if (tEncodeU64(&encoder, pReq->sId) < 0) return -1; + if (tEncodeI32(&encoder, pReq->epId.nodeId) < 0) return -1; if (tEncodeU16(&encoder, pReq->epId.ep.port) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->epId.ep.fqdn) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->epId.ep.fqdn) < 0) return -1; if (pReq->taskAction) { int32_t num = taosArrayGetSize(pReq->taskAction); - if (tEncodeI32(&encoder, num) < 0) return -1; + if (tEncodeI32(&encoder, num) < 0) return -1; for (int32_t i = 0; i < num; ++i) { STaskAction *action = taosArrayGet(pReq->taskAction, i); - if (tEncodeU64(&encoder, action->queryId) < 0) return -1; - if (tEncodeU64(&encoder, action->taskId) < 0) return -1; - if (tEncodeI8(&encoder, action->action) < 0) return -1; + if (tEncodeU64(&encoder, action->queryId) < 0) return -1; + if (tEncodeU64(&encoder, action->taskId) < 0) return -1; + if (tEncodeI8(&encoder, action->action) < 0) return -1; } } else { - if (tEncodeI32(&encoder, 0) < 0) return -1; + if (tEncodeI32(&encoder, 0) < 0) return -1; } tEndEncode(&encoder); int32_t tlen = encoder.pos; tCoderClear(&encoder); - + if (buf != NULL) { SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen); pHead->vgId = htonl(pReq->header.vgId); @@ -2559,29 +2558,27 @@ int32_t tDeserializeSSchedulerHbReq(void *buf, int32_t bufLen, SSchedulerHbReq * void tFreeSSchedulerHbReq(SSchedulerHbReq *pReq) { taosArrayDestroy(pReq->taskAction); } - - int32_t tSerializeSSchedulerHbRsp(void *buf, int32_t bufLen, SSchedulerHbRsp *pRsp) { SCoder encoder = {0}; tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); if (tStartEncode(&encoder) < 0) return -1; - if (tEncodeU64(&encoder, pRsp->seqId) < 0) return -1; - if (tEncodeI32(&encoder, pRsp->epId.nodeId) < 0) return -1; + if (tEncodeU64(&encoder, pRsp->seqId) < 0) return -1; + if (tEncodeI32(&encoder, pRsp->epId.nodeId) < 0) return -1; if (tEncodeU16(&encoder, pRsp->epId.ep.port) < 0) return -1; - if (tEncodeCStr(&encoder, pRsp->epId.ep.fqdn) < 0) return -1; + if (tEncodeCStr(&encoder, pRsp->epId.ep.fqdn) < 0) return -1; if (pRsp->taskStatus) { int32_t num = taosArrayGetSize(pRsp->taskStatus); - if (tEncodeI32(&encoder, num) < 0) return -1; + if (tEncodeI32(&encoder, num) < 0) return -1; for (int32_t i = 0; i < num; ++i) { STaskStatus *status = taosArrayGet(pRsp->taskStatus, i); - if (tEncodeU64(&encoder, status->queryId) < 0) return -1; - if (tEncodeU64(&encoder, status->taskId) < 0) return -1; - if (tEncodeI64(&encoder, status->refId) < 0) return -1; - if (tEncodeI8(&encoder, status->status) < 0) return -1; + if (tEncodeU64(&encoder, status->queryId) < 0) return -1; + if (tEncodeU64(&encoder, status->taskId) < 0) return -1; + if (tEncodeI64(&encoder, status->refId) < 0) return -1; + if (tEncodeI8(&encoder, status->status) < 0) return -1; } } else { - if (tEncodeI32(&encoder, 0) < 0) return -1; + if (tEncodeI32(&encoder, 0) < 0) return -1; } tEndEncode(&encoder); @@ -2694,3 +2691,32 @@ void tFreeSCMCreateStreamReq(SCMCreateStreamReq *pReq) { tfree(pReq->physicalPlan); tfree(pReq->logicalPlan); } + +int32_t tEncodeSStreamTask(SCoder *pEncoder, const SStreamTask *pTask) { + if (tStartEncode(pEncoder) < 0) return -1; + if (tEncodeI64(pEncoder, pTask->streamId) < 0) return -1; + if (tEncodeI32(pEncoder, pTask->taskId) < 0) return -1; + if (tEncodeI32(pEncoder, pTask->level) < 0) return -1; + if (tEncodeI8(pEncoder, pTask->status) < 0) return -1; + if (tEncodeCStr(pEncoder, pTask->qmsg) < 0) return -1; + tEndEncode(pEncoder); + return pEncoder->pos; +} + +int32_t tDecodeSStreamTask(SCoder *pDecoder, SStreamTask *pTask) { + if (tStartDecode(pDecoder) < 0) return -1; + if (tDecodeI64(pDecoder, &pTask->streamId) < 0) return -1; + if (tDecodeI32(pDecoder, &pTask->taskId) < 0) return -1; + if (tDecodeI32(pDecoder, &pTask->level) < 0) return -1; + if (tDecodeI8(pDecoder, &pTask->status) < 0) return -1; + if (tDecodeCStr(pDecoder, (const char **)&pTask->qmsg) < 0) return -1; + tEndDecode(pDecoder); + return 0; +} + +void tFreeSStreamTask(SStreamTask *pTask) { + // TODO + /*free(pTask->qmsg);*/ + /*free(pTask->executor);*/ + /*free(pTask);*/ +} diff --git a/source/dnode/mgmt/impl/src/dndSnode.c b/source/dnode/mgmt/impl/src/dndSnode.c index 5ea8a841d2..8667952f2c 100644 --- a/source/dnode/mgmt/impl/src/dndSnode.c +++ b/source/dnode/mgmt/impl/src/dndSnode.c @@ -323,8 +323,8 @@ int32_t dndProcessDropSnodeReq(SDnode *pDnode, SRpcMsg *pReq) { } static void dndProcessSnodeUniqueQueue(SDnode *pDnode, STaosQall *qall, int32_t numOfMsgs) { - SSnodeMgmt *pMgmt = &pDnode->smgmt; - int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED; + /*SSnodeMgmt *pMgmt = &pDnode->smgmt;*/ + int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED; SSnode *pSnode = dndAcquireSnode(pDnode); if (pSnode != NULL) { @@ -334,22 +334,35 @@ static void dndProcessSnodeUniqueQueue(SDnode *pDnode, STaosQall *qall, int32_t sndProcessUMsg(pSnode, pMsg); + rpcFreeCont(pMsg->pCont); + taosFreeQitem(pMsg); + } + dndReleaseSnode(pDnode, pSnode); + } else { + for (int32_t i = 0; i < numOfMsgs; i++) { + SRpcMsg *pMsg = NULL; + taosGetQitem(qall, (void **)&pMsg); + SRpcMsg rpcRsp = {.handle = pMsg->handle, .ahandle = pMsg->ahandle, .code = code}; + rpcSendResponse(&rpcRsp); + rpcFreeCont(pMsg->pCont); taosFreeQitem(pMsg); } } - dndReleaseSnode(pDnode, pSnode); } static void dndProcessSnodeSharedQueue(SDnode *pDnode, SRpcMsg *pMsg) { - SSnodeMgmt *pMgmt = &pDnode->smgmt; - int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED; + /*SSnodeMgmt *pMgmt = &pDnode->smgmt;*/ + int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED; SSnode *pSnode = dndAcquireSnode(pDnode); if (pSnode != NULL) { - code = sndProcessSMsg(pSnode, pMsg); + sndProcessSMsg(pSnode, pMsg); + dndReleaseSnode(pDnode, pSnode); + } else { + SRpcMsg rpcRsp = {.handle = pMsg->handle, .ahandle = pMsg->ahandle, .code = code}; + rpcSendResponse(&rpcRsp); } - dndReleaseSnode(pDnode, pSnode); #if 0 if (pMsg->msgType & 1u) { diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index a7116b72ff..8ea9cc141f 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -85,6 +85,8 @@ typedef enum { TRN_TYPE_REBALANCE = 1017, TRN_TYPE_COMMIT_OFFSET = 1018, TRN_TYPE_CREATE_STREAM = 1019, + TRN_TYPE_DROP_STREAM = 1020, + TRN_TYPE_ALTER_STREAM = 1021, TRN_TYPE_BASIC_SCOPE_END, TRN_TYPE_GLOBAL_SCOPE = 2000, TRN_TYPE_CREATE_DNODE = 2001, @@ -679,12 +681,6 @@ static FORCE_INLINE void* tDecodeSMqConsumerObj(void* buf, SMqConsumerObj* pCons return buf; } -typedef struct { - int32_t taskId; - int32_t level; - SSubplan* plan; -} SStreamTaskMeta; - typedef struct { char name[TSDB_TOPIC_FNAME_LEN]; char db[TSDB_DB_FNAME_LEN]; @@ -700,7 +696,7 @@ typedef struct { char* sql; char* logicalPlan; char* physicalPlan; - SArray* tasks; // SArray> + SArray* tasks; // SArray> } SStreamObj; int32_t tEncodeSStreamObj(SCoder* pEncoder, const SStreamObj* pObj); diff --git a/source/dnode/mnode/impl/inc/mndScheduler.h b/source/dnode/mnode/impl/inc/mndScheduler.h index 3bf6e0c33a..42951beca2 100644 --- a/source/dnode/mnode/impl/inc/mndScheduler.h +++ b/source/dnode/mnode/impl/inc/mndScheduler.h @@ -27,6 +27,8 @@ void mndCleanupScheduler(SMnode* pMnode); int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscribeObj* pSub); +int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream); + #ifdef __cplusplus } #endif diff --git a/source/dnode/mnode/impl/src/mndScheduler.c b/source/dnode/mnode/impl/src/mndScheduler.c index 855e244daa..16b1ba8a5c 100644 --- a/source/dnode/mnode/impl/src/mndScheduler.c +++ b/source/dnode/mnode/impl/src/mndScheduler.c @@ -31,7 +31,7 @@ #include "tname.h" #include "tuuid.h" -int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) { +int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { SSdb* pSdb = pMnode->pSdb; SVgObj* pVgroup = NULL; SQueryPlan* pPlan = qStringToQueryPlan(pStream->physicalPlan); @@ -41,17 +41,18 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) { } ASSERT(pStream->vgNum == 0); - int32_t levelNum = LIST_LENGTH(pPlan->pSubplans); - pStream->tasks = taosArrayInit(levelNum, sizeof(SArray)); + int32_t totLevel = LIST_LENGTH(pPlan->pSubplans); + pStream->tasks = taosArrayInit(totLevel, sizeof(SArray)); - for (int32_t i = 0; i < levelNum; i++) { - SArray* taskOneLevel = taosArrayInit(0, sizeof(SStreamTaskMeta)); - SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, i); + int32_t msgLen; + for (int32_t level = 0; level < totLevel; level++) { + SArray* taskOneLevel = taosArrayInit(0, sizeof(SStreamTask)); + SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, level); int32_t opNum = LIST_LENGTH(inner->pNodeList); ASSERT(opNum == 1); - SSubplan* plan = nodesListGetNode(inner->pNodeList, 0); - if (i == 0) { + SSubplan* plan = nodesListGetNode(inner->pNodeList, level); + if (level == 0) { ASSERT(plan->type == SUBPLAN_TYPE_SCAN); void* pIter = NULL; while (1) { @@ -63,15 +64,19 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) { } pStream->vgNum++; + // send to vnode + + SStreamTask* pTask = streamTaskNew(pStream->uid, level); + plan->execNode.nodeId = pVgroup->vgId; plan->execNode.epSet = mndGetVgroupEpset(pMnode, pVgroup); - SStreamTaskMeta task = { - .taskId = tGenIdPI32(), - .level = i, - .plan = plan, - }; - // send to vnode - taosArrayPush(taskOneLevel, &task); + if (qSubPlanToString(plan, &pTask->qmsg, &msgLen) < 0) { + sdbRelease(pSdb, pVgroup); + qDestroyQueryPlan(pPlan); + terrno = TSDB_CODE_QRY_INVALID_INPUT; + return -1; + } + taosArrayPush(taskOneLevel, pTask); } } else if (plan->subplanType == SUBPLAN_TYPE_SCAN) { // duplicatable @@ -82,22 +87,36 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) { // if has snode, set to shared thread num in snode parallel = SND_SHARED_THREAD_NUM; - for (int32_t j = 0; j < parallel; j++) { - SStreamTaskMeta task = { - .taskId = tGenIdPI32(), - .level = i, - .plan = plan, - }; - taosArrayPush(taskOneLevel, &task); + for (int32_t i = 0; i < parallel; i++) { + SStreamTask* pTask = streamTaskNew(pStream->uid, level); + + // TODO:get snode id and ep + plan->execNode.nodeId = pVgroup->vgId; + plan->execNode.epSet = mndGetVgroupEpset(pMnode, pVgroup); + + if (qSubPlanToString(plan, &pTask->qmsg, &msgLen) < 0) { + qDestroyQueryPlan(pPlan); + terrno = TSDB_CODE_QRY_INVALID_INPUT; + return -1; + } + + taosArrayPush(taskOneLevel, pTask); } } else { // not duplicatable - SStreamTaskMeta task = { - .taskId = tGenIdPI32(), - .level = i, - .plan = plan, - }; - taosArrayPush(taskOneLevel, &task); + SStreamTask* pTask = streamTaskNew(pStream->uid, level); + + // TODO:get snode id and ep + plan->execNode.nodeId = pVgroup->vgId; + plan->execNode.epSet = mndGetVgroupEpset(pMnode, pVgroup); + + if (qSubPlanToString(plan, &pTask->qmsg, &msgLen) < 0) { + sdbRelease(pSdb, pVgroup); + qDestroyQueryPlan(pPlan); + terrno = TSDB_CODE_QRY_INVALID_INPUT; + return -1; + } + taosArrayPush(taskOneLevel, pTask); } taosArrayPush(pStream->tasks, taskOneLevel); } diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index 54ad9cd7e2..67011dfe8a 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -18,6 +18,7 @@ #include "mndDb.h" #include "mndDnode.h" #include "mndMnode.h" +#include "mndScheduler.h" #include "mndShow.h" #include "mndStb.h" #include "mndTrans.h" @@ -237,6 +238,12 @@ static int32_t mndCreateStream(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateStreamR } sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY); + if (mndScheduleStream(pMnode, pTrans, &streamObj) < 0) { + mError("stream:%ld, schedule stream since %s", streamObj.uid, terrstr()); + mndTransDrop(pTrans); + return -1; + } + if (mndTransPrepare(pMnode, pTrans) != 0) { mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); mndTransDrop(pTrans); diff --git a/source/dnode/snode/CMakeLists.txt b/source/dnode/snode/CMakeLists.txt index dafd5d6594..d1b1abdf1d 100644 --- a/source/dnode/snode/CMakeLists.txt +++ b/source/dnode/snode/CMakeLists.txt @@ -7,8 +7,9 @@ target_include_directories( ) target_link_libraries( snode + PRIVATE executor PRIVATE transport PRIVATE os PRIVATE common PRIVATE util -) \ No newline at end of file +) diff --git a/source/dnode/snode/inc/sndInt.h b/source/dnode/snode/inc/sndInt.h index 3fe816845d..e5f6c3c266 100644 --- a/source/dnode/snode/inc/sndInt.h +++ b/source/dnode/snode/inc/sndInt.h @@ -38,13 +38,8 @@ enum { STREAM_STATUS__DELETING, }; -enum { - STREAM_TASK_STATUS__RUNNING = 1, - STREAM_TASK_STATUS__STOP, -}; - typedef struct { - SHashObj* pHash; // taskId -> streamTask + SHashObj* pHash; // taskId -> SStreamTask } SStreamMeta; typedef struct SSnode { @@ -52,26 +47,16 @@ typedef struct SSnode { SSnodeOpt cfg; } SSnode; -typedef struct { - int64_t streamId; - int32_t taskId; - int32_t IdxInLevel; - int32_t level; -} SStreamTaskInfo; +SStreamMeta* sndMetaNew(); +void sndMetaDelete(SStreamMeta* pMeta); -typedef struct { - SStreamTaskInfo meta; - int8_t status; - void* executor; - void* stateStore; - // storage handle -} SStreamTask; +int32_t sndMetaDeployTask(SStreamMeta* pMeta, SStreamTask* pTask); +int32_t sndMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId); -int32_t sndCreateTask(); -int32_t sndDropTaskOfStream(int64_t streamId); +int32_t sndDropTaskOfStream(SStreamMeta* pMeta, int64_t streamId); -int32_t sndStopTaskOfStream(int64_t streamId); -int32_t sndResumeTaskOfStream(int64_t streamId); +int32_t sndStopTaskOfStream(SStreamMeta* pMeta, int64_t streamId); +int32_t sndResumeTaskOfStream(SStreamMeta* pMeta, int64_t streamId); #ifdef __cplusplus } diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c index 74e41d45c5..80e33bd971 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -13,40 +13,91 @@ * along with this program. If not, see . */ +#include "executor.h" #include "sndInt.h" #include "tuuid.h" SSnode *sndOpen(const char *path, const SSnodeOpt *pOption) { SSnode *pSnode = calloc(1, sizeof(SSnode)); + if (pSnode == NULL) { + return NULL; + } memcpy(&pSnode->cfg, pOption, sizeof(SSnodeOpt)); + pSnode->pMeta = sndMetaNew(); + if (pSnode->pMeta == NULL) { + free(pSnode); + return NULL; + } return pSnode; } -void sndClose(SSnode *pSnode) { free(pSnode); } +void sndClose(SSnode *pSnode) { + sndMetaDelete(pSnode->pMeta); + free(pSnode); +} int32_t sndGetLoad(SSnode *pSnode, SSnodeLoad *pLoad) { return 0; } -int32_t sndProcessMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { - *pRsp = NULL; - return 0; -} +/*int32_t sndProcessMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {*/ +/**pRsp = NULL;*/ +/*return 0;*/ +/*}*/ void sndDestroy(const char *path) {} -static int32_t sndDeployTask(SSnode *pSnode, SRpcMsg *pMsg) { - SStreamTask *task = malloc(sizeof(SStreamTask)); - if (task == NULL) { +SStreamMeta *sndMetaNew() { + SStreamMeta *pMeta = calloc(1, sizeof(SStreamMeta)); + if (pMeta == NULL) { + return NULL; + } + pMeta->pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK); + if (pMeta->pHash == NULL) { + free(pMeta); + return NULL; + } + return pMeta; +} + +void sndMetaDelete(SStreamMeta *pMeta) { + taosHashCleanup(pMeta->pHash); + free(pMeta); +} + +int32_t sndMetaDeployTask(SStreamMeta *pMeta, SStreamTask *pTask) { + pTask->executor = qCreateStreamExecTaskInfo(pTask->qmsg, NULL); + return taosHashPut(pMeta->pHash, &pTask->taskId, sizeof(int32_t), pTask, sizeof(void *)); +} + +int32_t sndMetaRemoveTask(SStreamMeta *pMeta, int32_t taskId) { + SStreamTask *pTask = taosHashGet(pMeta->pHash, &taskId, sizeof(int32_t)); + if (pTask == NULL) { return -1; } - task->meta.taskId = tGenIdPI32(); - taosHashPut(pSnode->pMeta->pHash, &task->meta.taskId, sizeof(int32_t), &task, sizeof(void *)); - return 0; + free(pTask->qmsg); + // TODO:free executor + free(pTask); + return taosHashRemove(pMeta->pHash, &taskId, sizeof(int32_t)); } int32_t sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg) { - // stream deployment + // stream deploy // stream stop/resume // operator exec + if (pMsg->msgType == TDMT_SND_TASK_DEPLOY) { + void *msg = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)); + SStreamTask *pTask = malloc(sizeof(SStreamTask)); + if (pTask == NULL) { + return -1; + } + SCoder decoder; + tCoderInit(&decoder, TD_LITTLE_ENDIAN, msg, pMsg->contLen - sizeof(SMsgHead), TD_DECODER); + tDecodeSStreamTask(&decoder, pTask); + tCoderClear(&decoder); + + sndMetaDeployTask(pSnode->pMeta, pTask); + } else { + // + } return 0; } From 231ac079bee6f2304da05d2d5a66dc87dc4211be Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Wed, 16 Mar 2022 19:01:45 +0800 Subject: [PATCH 36/38] refactor --- source/dnode/vnode/src/tsdb/tsdbFile.c | 4 ++-- source/dnode/vnode/src/tsdb/tsdbSma.c | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbFile.c b/source/dnode/vnode/src/tsdb/tsdbFile.c index b756cc9862..00e97c7b61 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFile.c +++ b/source/dnode/vnode/src/tsdb/tsdbFile.c @@ -23,8 +23,8 @@ static const char *TSDB_FNAME_SUFFIX[] = { "smal", // TSDB_FILE_SMAL "", // TSDB_FILE_MAX "meta", // TSDB_FILE_META - "sma", // TSDB_FILE_TSMA(directory name) - "sma", // TSDB_FILE_RSMA(directory name) + "tsma", // TSDB_FILE_TSMA + "rsma", // TSDB_FILE_RSMA }; static void tsdbGetFilename(int vid, int fid, uint32_t ver, TSDB_FILE_T ftype, char *fname); diff --git a/source/dnode/vnode/src/tsdb/tsdbSma.c b/source/dnode/vnode/src/tsdb/tsdbSma.c index 880eb403f4..cd8b60385f 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSma.c +++ b/source/dnode/vnode/src/tsdb/tsdbSma.c @@ -15,6 +15,12 @@ #include "tsdbDef.h" +static const char *TSDB_SMA_DNAME[] = { + "", // TSDB_SMA_TYPE_BLOCK + "tsma", // TSDB_SMA_TYPE_TIME_RANGE + "rsma", // TSDB_SMA_TYPE_ROLLUP +}; + #undef SMA_PRINT_DEBUG_LOG #define SMA_STORAGE_TSDB_DAYS 30 #define SMA_STORAGE_TSDB_TIMES 10 @@ -93,10 +99,10 @@ static int32_t tsdbGetTSmaDays(STsdb *pTsdb, int64_t interval, int32_t storageLe static int32_t tsdbSetTSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData, int32_t storageLevel, int32_t fid); static int32_t tsdbInitTSmaFile(STSmaReadH *pSmaH, TSKEY skey); static bool tsdbSetAndOpenTSmaFile(STSmaReadH *pReadH, TSKEY *queryKey); -static void tsdbGetSmaDir(int32_t repoid, int8_t smaType, char dirName[]); +static void tsdbGetSmaDir(int32_t vgId, ETsdbSmaType smaType, char dirName[]); -static void tsdbGetSmaDir(int32_t repoid, int8_t smaType, char dirName[]) { - snprintf(dirName, TSDB_FILENAME_LEN, "vnode/vnode%d/tsdb/data", repoid); +static void tsdbGetSmaDir(int32_t vgId, ETsdbSmaType smaType, char dirName[]) { + snprintf(dirName, TSDB_FILENAME_LEN, "vnode/vnode%d/tsdb/%s", vgId, TSDB_SMA_DNAME[smaType]); } static SSmaEnv *tsdbNewSmaEnv(const STsdb *pTsdb, const char *path) { From 575ab144393190af14a10914d71ceaaf4fbbeebd Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Wed, 16 Mar 2022 19:28:33 +0800 Subject: [PATCH 37/38] trow bug fix --- include/common/trow.h | 30 +++++++++++++++--------------- source/libs/parser/src/parInsert.c | 6 +++--- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/common/trow.h b/include/common/trow.h index 4dd3daba4d..47edf6f1ad 100644 --- a/include/common/trow.h +++ b/include/common/trow.h @@ -98,13 +98,13 @@ typedef void *SRow; typedef struct { TDRowValT valType; - void *val; + void * val; } SCellVal; typedef struct { // TODO - int tmp; // TODO: to avoid compile error -} STpRow; // tuple + int tmp; // TODO: to avoid compile error +} STpRow; // tuple #pragma pack(push, 1) typedef struct { @@ -158,8 +158,8 @@ typedef struct { int16_t nBitmaps; int16_t nBoundBitmaps; int32_t offset; - void *pBitmap; - void *pOffset; + void * pBitmap; + void * pOffset; int32_t extendedRowSize; } SRowBuilder; @@ -273,7 +273,7 @@ static FORCE_INLINE int32_t tdSetBitmapValType(void *pBitmap, int16_t colIdx, TD } int16_t nBytes = colIdx / TD_VTYPE_PARTS; int16_t nOffset = colIdx & TD_VTYPE_OPTR; - char *pDestByte = (char *)POINTER_SHIFT(pBitmap, nBytes); + char * pDestByte = (char *)POINTER_SHIFT(pBitmap, nBytes); switch (nOffset) { case 0: *pDestByte = ((*pDestByte) & 0x3F) | (valType << 6); @@ -311,7 +311,7 @@ static FORCE_INLINE int32_t tdGetBitmapValType(void *pBitmap, int16_t colIdx, TD } int16_t nBytes = colIdx / TD_VTYPE_PARTS; int16_t nOffset = colIdx & TD_VTYPE_OPTR; - char *pDestByte = (char *)POINTER_SHIFT(pBitmap, nBytes); + char * pDestByte = (char *)POINTER_SHIFT(pBitmap, nBytes); switch (nOffset) { case 0: *pValType = (((*pDestByte) & 0xC0) >> 6); @@ -617,7 +617,7 @@ static FORCE_INLINE int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowVa if (tdValIsNorm(valType, val, colType)) { // ts key stored in STSRow.ts SKvRowIdx *pColIdx = (SKvRowIdx *)POINTER_SHIFT(TD_ROW_COL_IDX(row), offset); - char *ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row)); + char * ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row)); pColIdx->colId = colId; pColIdx->offset = TD_ROW_LEN(row); // the offset include the TD_ROW_HEAD_LEN @@ -635,7 +635,7 @@ static FORCE_INLINE int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowVa // NULL/None value else { SKvRowIdx *pColIdx = (SKvRowIdx *)POINTER_SHIFT(TD_ROW_COL_IDX(row), offset); - char *ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row)); + char * ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row)); pColIdx->colId = colId; pColIdx->offset = TD_ROW_LEN(row); // the offset include the TD_ROW_HEAD_LEN const void *nullVal = getNullValue(colType); @@ -697,9 +697,9 @@ static FORCE_INLINE int32_t tdAppendColValToRow(SRowBuilder *pBuilder, int16_t c } // TODO: We can avoid the type judegement by FP, but would prevent the inline scheme. if (TD_IS_TP_ROW(pRow)) { - tdAppendColValToTpRow(pBuilder, valType, val, true, colType, colIdx, offset); + tdAppendColValToTpRow(pBuilder, valType, val, isCopyVarData, colType, colIdx, offset); } else { - tdAppendColValToKvRow(pBuilder, valType, val, true, colType, colIdx, offset, colId); + tdAppendColValToKvRow(pBuilder, valType, val, isCopyVarData, colType, colIdx, offset, colId); } return TSDB_CODE_SUCCESS; } @@ -771,8 +771,8 @@ static FORCE_INLINE int32_t tdGetKvRowValOfCol(SCellVal *output, STSRow *pRow, v typedef struct { STSchema *pSchema; - STSRow *pRow; - void *pBitmap; + STSRow * pRow; + void * pBitmap; uint32_t offset; col_id_t maxColId; col_id_t colIdx; // [PRIMARYKEY_TIMESTAMP_COL_ID, nSchemaCols], PRIMARYKEY_TIMESTAMP_COL_ID equals 1 @@ -877,7 +877,7 @@ static FORCE_INLINE bool tdGetTpRowDataOfCol(STSRowIter *pIter, col_type_t colTy // internal static FORCE_INLINE bool tdGetKvRowValOfColEx(STSRowIter *pIter, col_id_t colId, col_type_t colType, col_id_t *nIdx, SCellVal *pVal) { - STSRow *pRow = pIter->pRow; + STSRow * pRow = pIter->pRow; SKvRowIdx *pKvIdx = NULL; bool colFound = false; col_id_t kvNCols = tdRowGetNCols(pRow); @@ -1068,7 +1068,7 @@ typedef struct { typedef struct { STSchema *pSchema; - STSRow *pRow; + STSRow * pRow; } STSRowReader; typedef struct { diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 28f680cfbb..6db3abb9d6 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -617,7 +617,7 @@ static FORCE_INLINE int32_t MemRowAppend(const void* value, int32_t len, void* p if (TSDB_DATA_TYPE_BINARY == pa->schema->type) { const char* rowEnd = tdRowEnd(rb->pBuf); STR_WITH_SIZE_TO_VARSTR(rowEnd, value, len); - tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, rowEnd, false, pa->toffset, pa->colIdx); + tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, rowEnd, true, pa->toffset, pa->colIdx); } else if (TSDB_DATA_TYPE_NCHAR == pa->schema->type) { // if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long' int32_t output = 0; @@ -626,9 +626,9 @@ static FORCE_INLINE int32_t MemRowAppend(const void* value, int32_t len, void* p return TSDB_CODE_TSC_SQL_SYNTAX_ERROR; } varDataSetLen(rowEnd, output); - tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, rowEnd, false, pa->toffset, pa->colIdx); + tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, rowEnd, true, pa->toffset, pa->colIdx); } else { - tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, value, true, pa->toffset, pa->colIdx); + tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, value, false, pa->toffset, pa->colIdx); } return TSDB_CODE_SUCCESS; } From 7f4c88b756c5c42b34f29379a1efde747549edce Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Wed, 16 Mar 2022 19:40:48 +0800 Subject: [PATCH 38/38] task deploy and task exec --- include/common/tmsg.h | 4 ++++ include/common/tmsgdef.h | 1 + include/util/tencode.h | 25 ++++++++++++++++++++++++- source/common/src/tmsg.c | 8 ++++---- source/dnode/mnode/impl/src/mndDef.c | 6 +++--- source/dnode/snode/inc/sndInt.h | 5 +++-- source/dnode/snode/src/snode.c | 23 ++++++++++++++++++++++- 7 files changed, 61 insertions(+), 11 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 7e9b2186da..b449cad2a1 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -2306,6 +2306,10 @@ typedef struct { // TODO: other info needed by task } SStreamTaskExecReq; +typedef struct { + int32_t reserved; +} SStreamTaskExecRsp; + #pragma pack(pop) #ifdef __cplusplus diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index b30a325d7c..6a07887721 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -200,6 +200,7 @@ enum { // Requests handled by SNODE TD_NEW_MSG_SEG(TDMT_SND_MSG) TD_DEF_MSG_TYPE(TDMT_SND_TASK_DEPLOY, "snode-task-deploy", SStreamTaskDeployReq, SStreamTaskDeployRsp) + TD_DEF_MSG_TYPE(TDMT_SND_TASK_EXEC, "snode-task-exec", SStreamTaskExecReq, SStreamTaskExecRsp) #if defined(TD_MSG_NUMBER_) TDMT_MAX diff --git a/include/util/tencode.h b/include/util/tencode.h index c058eebb50..cbbd55c8a3 100644 --- a/include/util/tencode.h +++ b/include/util/tencode.h @@ -402,10 +402,33 @@ static int32_t tDecodeCStrTo(SCoder* pDecoder, char* val) { return 0; } +static FORCE_INLINE int32_t tDecodeBinaryAlloc(SCoder* pDecoder, void** val, uint64_t* len) { + if (tDecodeU64v(pDecoder, len) < 0) return -1; + + if (TD_CODER_CHECK_CAPACITY_FAILED(pDecoder, *len)) return -1; + *val = malloc(*len); + if (*val == NULL) return -1; + memcpy(*val, TD_CODER_CURRENT(pDecoder), *len); + + TD_CODER_MOVE_POS(pDecoder, *len); + return 0; +} + +static FORCE_INLINE int32_t tDecodeCStrAndLenAlloc(SCoder* pDecoder, char** val, uint64_t* len) { + if (tDecodeBinaryAlloc(pDecoder, (void**)val, len) < 0) return -1; + (*len) -= 1; + return 0; +} + +static FORCE_INLINE int32_t tDecodeCStrAlloc(SCoder* pDecoder, char** val) { + uint64_t len; + return tDecodeCStrAndLenAlloc(pDecoder, val, &len); +} + static FORCE_INLINE bool tDecodeIsEnd(SCoder* pCoder) { return (pCoder->size == pCoder->pos); } #ifdef __cplusplus } #endif -#endif /*_TD_UTIL_ENCODE_H_*/ \ No newline at end of file +#endif /*_TD_UTIL_ENCODE_H_*/ diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 469090c05b..794e5a8542 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -2674,9 +2674,9 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea if (tStartDecode(&decoder) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1; if (tDecodeI8(&decoder, &pReq->igExists) < 0) return -1; - if (tDecodeCStr(&decoder, (const char **)&pReq->sql) < 0) return -1; - if (tDecodeCStr(&decoder, (const char **)&pReq->physicalPlan) < 0) return -1; - if (tDecodeCStr(&decoder, (const char **)&pReq->logicalPlan) < 0) return -1; + if (tDecodeCStrAlloc(&decoder, &pReq->sql) < 0) return -1; + if (tDecodeCStrAlloc(&decoder, &pReq->physicalPlan) < 0) return -1; + if (tDecodeCStrAlloc(&decoder, &pReq->logicalPlan) < 0) return -1; tEndDecode(&decoder); tCoderClear(&decoder); @@ -2706,7 +2706,7 @@ int32_t tDecodeSStreamTask(SCoder *pDecoder, SStreamTask *pTask) { if (tDecodeI32(pDecoder, &pTask->taskId) < 0) return -1; if (tDecodeI32(pDecoder, &pTask->level) < 0) return -1; if (tDecodeI8(pDecoder, &pTask->status) < 0) return -1; - if (tDecodeCStr(pDecoder, (const char **)&pTask->qmsg) < 0) return -1; + if (tDecodeCStrAlloc(pDecoder, &pTask->qmsg) < 0) return -1; tEndDecode(pDecoder); return 0; } diff --git a/source/dnode/mnode/impl/src/mndDef.c b/source/dnode/mnode/impl/src/mndDef.c index 6e8d9aa79f..cc5bf843ce 100644 --- a/source/dnode/mnode/impl/src/mndDef.c +++ b/source/dnode/mnode/impl/src/mndDef.c @@ -39,8 +39,8 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) { if (tDecodeI64(pDecoder, &pObj->dbUid) < 0) return -1; if (tDecodeI32(pDecoder, &pObj->version) < 0) return -1; if (tDecodeI8(pDecoder, &pObj->status) < 0) return -1; - if (tDecodeCStr(pDecoder, (const char **)&pObj->sql) < 0) return -1; - if (tDecodeCStr(pDecoder, (const char **)&pObj->logicalPlan) < 0) return -1; - if (tDecodeCStr(pDecoder, (const char **)&pObj->physicalPlan) < 0) return -1; + if (tDecodeCStrAlloc(pDecoder, &pObj->sql) < 0) return -1; + if (tDecodeCStrAlloc(pDecoder, &pObj->logicalPlan) < 0) return -1; + if (tDecodeCStrAlloc(pDecoder, &pObj->physicalPlan) < 0) return -1; return 0; } diff --git a/source/dnode/snode/inc/sndInt.h b/source/dnode/snode/inc/sndInt.h index e5f6c3c266..d1122fc4ec 100644 --- a/source/dnode/snode/inc/sndInt.h +++ b/source/dnode/snode/inc/sndInt.h @@ -50,8 +50,9 @@ typedef struct SSnode { SStreamMeta* sndMetaNew(); void sndMetaDelete(SStreamMeta* pMeta); -int32_t sndMetaDeployTask(SStreamMeta* pMeta, SStreamTask* pTask); -int32_t sndMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId); +int32_t sndMetaDeployTask(SStreamMeta* pMeta, SStreamTask* pTask); +SStreamTask* sndMetaGetTask(SStreamMeta* pMeta, int32_t taskId); +int32_t sndMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId); int32_t sndDropTaskOfStream(SStreamMeta* pMeta, int64_t streamId); diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c index 80e33bd971..2ecaeb00e9 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -68,6 +68,10 @@ int32_t sndMetaDeployTask(SStreamMeta *pMeta, SStreamTask *pTask) { return taosHashPut(pMeta->pHash, &pTask->taskId, sizeof(int32_t), pTask, sizeof(void *)); } +SStreamTask *sndMetaGetTask(SStreamMeta *pMeta, int32_t taskId) { + return taosHashGet(pMeta->pHash, &taskId, sizeof(int32_t)); +} + int32_t sndMetaRemoveTask(SStreamMeta *pMeta, int32_t taskId) { SStreamTask *pTask = taosHashGet(pMeta->pHash, &taskId, sizeof(int32_t)); if (pTask == NULL) { @@ -79,6 +83,16 @@ int32_t sndMetaRemoveTask(SStreamMeta *pMeta, int32_t taskId) { return taosHashRemove(pMeta->pHash, &taskId, sizeof(int32_t)); } +static int32_t sndProcessTaskExecReq(SSnode *pSnode, SRpcMsg *pMsg) { + SMsgHead *pHead = pMsg->pCont; + int32_t taskId = pHead->streamTaskId; + SStreamTask *pTask = sndMetaGetTask(pSnode->pMeta, taskId); + if (pTask == NULL) { + return -1; + } + return 0; +} + int32_t sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg) { // stream deploy // stream stop/resume @@ -95,13 +109,20 @@ int32_t sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg) { tCoderClear(&decoder); sndMetaDeployTask(pSnode->pMeta, pTask); + } else if (pMsg->msgType == TDMT_SND_TASK_EXEC) { + sndProcessTaskExecReq(pSnode, pMsg); } else { - // + ASSERT(0); } return 0; } int32_t sndProcessSMsg(SSnode *pSnode, SRpcMsg *pMsg) { // operator exec + if (pMsg->msgType == TDMT_SND_TASK_EXEC) { + sndProcessTaskExecReq(pSnode, pMsg); + } else { + ASSERT(0); + } return 0; }