From 45a806f78961c23979ae4ae68eaa9c3e89d2e1ca Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Tue, 21 Jun 2022 19:52:26 +0800 Subject: [PATCH 1/3] feat: sql function 'last_row' --- include/libs/function/functionMgt.h | 1 + include/libs/nodes/nodes.h | 9 ++-- include/libs/nodes/plannodes.h | 4 +- include/libs/nodes/querynodes.h | 1 + source/libs/function/src/builtins.c | 2 +- source/libs/function/src/functionMgt.c | 7 +++ source/libs/nodes/src/nodesCodeFuncs.c | 4 ++ source/libs/nodes/src/nodesUtilFuncs.c | 3 ++ source/libs/parser/src/parCalcConst.c | 2 +- source/libs/parser/src/parTranslater.c | 1 + source/libs/planner/src/planLogicCreater.c | 59 +++++++++++++++++++++- source/libs/planner/src/planOptimizer.c | 2 +- source/libs/planner/src/planPhysiCreater.c | 5 +- source/libs/planner/src/planSpliter.c | 2 +- source/libs/planner/test/planBasicTest.cpp | 12 +++++ 15 files changed, 103 insertions(+), 11 deletions(-) diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index cbaff29cb2..1f314d19e7 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -190,6 +190,7 @@ bool fmIsForbidWindowFunc(int32_t funcId); bool fmIsForbidGroupByFunc(int32_t funcId); bool fmIsIntervalInterpoFunc(int32_t funcId); bool fmIsInterpFunc(int32_t funcId); +bool fmIsLastRowFunc(int32_t funcId); int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc, SFunctionNode** pMergeFunc); diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 58e2393970..88a6185495 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -59,10 +59,10 @@ extern "C" { for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); \ (NULL != cell ? (node = &(cell->pNode), true) : (node = NULL, false)); cell = cell->pNext) -#define DESTORY_LIST(list) \ - do { \ - nodesDestroyList((list)); \ - (list) = NULL; \ +#define NODES_DESTORY_LIST(list) \ + do { \ + nodesDestroyList((list)); \ + (list) = NULL; \ } while (0) #define NODES_CLEAR_LIST(list) \ @@ -219,6 +219,7 @@ typedef enum ENodeType { QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN, QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN, QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN, + QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN, QUERY_NODE_PHYSICAL_PLAN_PROJECT, QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN, QUERY_NODE_PHYSICAL_PLAN_HASH_AGG, diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index b07e8f39d5..9fdc66d76c 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -40,7 +40,8 @@ typedef enum EScanType { SCAN_TYPE_SYSTEM_TABLE, SCAN_TYPE_STREAM, SCAN_TYPE_TABLE_MERGE, - SCAN_TYPE_BLOCK_INFO + SCAN_TYPE_BLOCK_INFO, + SCAN_TYPE_LAST_ROW } EScanType; typedef struct SScanLogicNode { @@ -260,6 +261,7 @@ typedef struct SScanPhysiNode { typedef SScanPhysiNode STagScanPhysiNode; typedef SScanPhysiNode SBlockDistScanPhysiNode; +typedef SScanPhysiNode SLastRowScanPhysiNode; typedef struct SSystemTableScanPhysiNode { SScanPhysiNode scan; diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 7a63f87412..78013e5457 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -258,6 +258,7 @@ typedef struct SSelectStmt { bool hasUniqueFunc; bool hasTailFunc; bool hasInterpFunc; + bool hasLastRowFunc; } SSelectStmt; typedef enum ESetOperatorType { SET_OP_TYPE_UNION_ALL = 1, SET_OP_TYPE_UNION } ESetOperatorType; diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index cfad00f458..0c92f1328f 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -1799,7 +1799,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "last_row", .type = FUNCTION_TYPE_LAST_ROW, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC, + .classification = FUNC_MGT_MULTI_RES_FUNC, .translateFunc = translateLastRow, .getEnvFunc = getMinmaxFuncEnv, .initFunc = minmaxFunctionSetup, diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index 710b01ce59..5fcf5e239c 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -186,6 +186,13 @@ bool fmIsInterpFunc(int32_t funcId) { return FUNCTION_TYPE_INTERP == funcMgtBuiltins[funcId].type; } +bool fmIsLastRowFunc(int32_t funcId) { + if (funcId < 0 || funcId >= funcMgtBuiltinsNum) { + return false; + } + return FUNCTION_TYPE_LAST_ROW == funcMgtBuiltins[funcId].type; +} + void fmFuncMgtDestroy() { void* m = gFunMgtService.pFuncNameHashTable; if (m != NULL && atomic_val_compare_exchange_ptr((void**)&gFunMgtService.pFuncNameHashTable, m, 0) == m) { diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index bde5159087..e3430b866b 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -220,6 +220,8 @@ const char* nodesNodeName(ENodeType type) { return "PhysiSystemTableScan"; case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN: return "PhysiBlockDistScan"; + case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: + return "PhysiLastRowScan"; case QUERY_NODE_PHYSICAL_PLAN_PROJECT: return "PhysiProject"; case QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN: @@ -4105,6 +4107,7 @@ static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { return logicPlanToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN: + case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: return physiTagScanNodeToJson(pObj, pJson); case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN: @@ -4245,6 +4248,7 @@ static int32_t jsonToSpecificNode(const SJson* pJson, void* pObj) { return jsonToLogicPlan(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN: + case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: return jsonToPhysiTagScanNode(pJson, pObj); case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN: diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index ebacf5574f..e3755c74e6 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -273,6 +273,8 @@ SNode* nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SSystemTableScanPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN: return makeNode(type, sizeof(SBlockDistScanPhysiNode)); + case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: + return makeNode(type, sizeof(SLastRowScanPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_PROJECT: return makeNode(type, sizeof(SProjectPhysiNode)); case QUERY_NODE_PHYSICAL_PLAN_MERGE_JOIN: @@ -781,6 +783,7 @@ void nodesDestroyNode(SNode* pNode) { case QUERY_NODE_PHYSICAL_PLAN_STREAM_SCAN: case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN: case QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN: + case QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN: destroyScanPhysiNode((SScanPhysiNode*)pNode); break; case QUERY_NODE_PHYSICAL_PLAN_PROJECT: { diff --git a/source/libs/parser/src/parCalcConst.c b/source/libs/parser/src/parCalcConst.c index 22d7afd642..042d6ab184 100644 --- a/source/libs/parser/src/parCalcConst.c +++ b/source/libs/parser/src/parCalcConst.c @@ -227,7 +227,7 @@ static int32_t calcConstGroupBy(SCalcConstContext* pCxt, SSelectStmt* pSelect) { } } } - DESTORY_LIST(pSelect->pGroupByList); + NODES_DESTORY_LIST(pSelect->pGroupByList); } return code; } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index fa0a66820f..d6619ebcc8 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -1176,6 +1176,7 @@ static void setFuncClassification(SSelectStmt* pSelect, SFunctionNode* pFunc) { pSelect->hasUniqueFunc = pSelect->hasUniqueFunc ? true : (FUNCTION_TYPE_UNIQUE == pFunc->funcType); pSelect->hasTailFunc = pSelect->hasTailFunc ? true : (FUNCTION_TYPE_TAIL == pFunc->funcType); pSelect->hasInterpFunc = pSelect->hasInterpFunc ? true : (FUNCTION_TYPE_INTERP == pFunc->funcType); + pSelect->hasLastRowFunc = pSelect->hasLastRowFunc ? true : (FUNCTION_TYPE_LAST_ROW == pFunc->funcType); } } diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 36d2efc13f..7e95cb8b7e 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -296,6 +296,59 @@ static int32_t createScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect return code; } +static int32_t createColumnByLastRow(SNodeList* pFuncs, SNodeList** pOutput) { + int32_t code = TSDB_CODE_SUCCESS; + SNodeList* pCols = NULL; + SNode* pFunc = NULL; + FOREACH(pFunc, pFuncs) { + SFunctionNode* pLastRow = (SFunctionNode*)pFunc; + SColumnNode* pCol = (SColumnNode*)nodesListGetNode(pLastRow->pParameterList, 0); + snprintf(pCol->colName, sizeof(pCol->colName), "%s", pLastRow->node.aliasName); + snprintf(pCol->node.aliasName, sizeof(pCol->colName), "%s", pLastRow->node.aliasName); + NODES_CLEAR_LIST(pLastRow->pParameterList); + code = nodesListMakeStrictAppend(&pCols, (SNode*)pCol); + if (TSDB_CODE_SUCCESS != code) { + break; + } + } + if (TSDB_CODE_SUCCESS == code) { + *pOutput = pCols; + } else { + nodesDestroyList(pCols); + } + return code; +} + +static int32_t createLastRowScanLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SRealTableNode* pRealTable, + SLogicNode** pLogicNode) { + SScanLogicNode* pScan = NULL; + int32_t code = makeScanLogicNode(pCxt, pRealTable, false, (SLogicNode**)&pScan); + + SNodeList* pFuncs = NULL; + if (TSDB_CODE_SUCCESS == code) { + pScan->scanType = SCAN_TYPE_LAST_ROW; + code = nodesCollectFuncs(pSelect, SQL_CLAUSE_FROM, fmIsLastRowFunc, &pFuncs); + } + if (TSDB_CODE_SUCCESS == code) { + code = rewriteExprsForSelect(pFuncs, pSelect, SQL_CLAUSE_FROM); + } + if (TSDB_CODE_SUCCESS == code) { + code = createColumnByLastRow(pFuncs, &pScan->pScanCols); + } + if (TSDB_CODE_SUCCESS == code) { + code = createColumnByRewriteExprs(pScan->pScanCols, &pScan->node.pTargets); + } + + if (TSDB_CODE_SUCCESS == code) { + *pLogicNode = (SLogicNode*)pScan; + } else { + nodesDestroyNode((SNode*)pScan); + } + nodesDestroyList(pFuncs); + + return code; +} + static int32_t createSubqueryLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, STempTableNode* pTable, SLogicNode** pLogicNode) { return createQueryLogicNode(pCxt, pTable->pSubquery, pLogicNode); @@ -367,7 +420,11 @@ static int32_t doCreateLogicNodeByTable(SLogicPlanContext* pCxt, SSelectStmt* pS SLogicNode** pLogicNode) { switch (nodeType(pTable)) { case QUERY_NODE_REAL_TABLE: - return createScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode); + if (pSelect->hasLastRowFunc) { + return createLastRowScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode); + } else { + return createScanLogicNode(pCxt, pSelect, (SRealTableNode*)pTable, pLogicNode); + } case QUERY_NODE_TEMP_TABLE: return createSubqueryLogicNode(pCxt, pSelect, (STempTableNode*)pTable, pLogicNode); case QUERY_NODE_JOIN_TABLE: diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index cd3218cf94..d74d6230fc 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -1126,7 +1126,7 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub break; } } - DESTORY_LIST(((SAggLogicNode*)pNode)->pGroupKeys); + NODES_DESTORY_LIST(((SAggLogicNode*)pNode)->pGroupKeys); } if (TSDB_CODE_SUCCESS == code) { code = partTagsOptRebuildTbanme(pScan->pPartTags); diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index ff78370c52..42ac3855f9 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -462,6 +462,8 @@ static ENodeType getScanOperatorType(EScanType scanType) { return QUERY_NODE_PHYSICAL_PLAN_TABLE_MERGE_SCAN; case SCAN_TYPE_BLOCK_INFO: return QUERY_NODE_PHYSICAL_PLAN_BLOCK_DIST_SCAN; + case SCAN_TYPE_LAST_ROW: + return QUERY_NODE_PHYSICAL_PLAN_LAST_ROW_SCAN; default: break; } @@ -559,6 +561,7 @@ static int32_t createScanPhysiNode(SPhysiPlanContext* pCxt, SSubplan* pSubplan, switch (pScanLogicNode->scanType) { case SCAN_TYPE_TAG: case SCAN_TYPE_BLOCK_INFO: + case SCAN_TYPE_LAST_ROW: return createSimpleScanPhysiNode(pCxt, pSubplan, pScanLogicNode, pPhyNode); case SCAN_TYPE_TABLE: return createTableScanPhysiNode(pCxt, pSubplan, pScanLogicNode, pPhyNode); @@ -732,7 +735,7 @@ static int32_t rewritePrecalcExprs(SPhysiPlanContext* pCxt, SNodeList* pList, SN SRewritePrecalcExprsCxt cxt = {.errCode = TSDB_CODE_SUCCESS, .pPrecalcExprs = *pPrecalcExprs}; nodesRewriteExprs(*pRewrittenList, doRewritePrecalcExprs, &cxt); if (0 == LIST_LENGTH(cxt.pPrecalcExprs) || TSDB_CODE_SUCCESS != cxt.errCode) { - DESTORY_LIST(*pPrecalcExprs); + NODES_DESTORY_LIST(*pPrecalcExprs); } return cxt.errCode; } diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index 29119bf1d2..f0e0e84bd9 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -934,7 +934,7 @@ static int32_t unionSplitSubplan(SSplitContext* pCxt, SLogicSubplan* pUnionSubpl } if (TSDB_CODE_SUCCESS == code) { nodesDestroyList(pSubplanChildren); - DESTORY_LIST(pSplitNode->pChildren); + NODES_DESTORY_LIST(pSplitNode->pChildren); } return code; } diff --git a/source/libs/planner/test/planBasicTest.cpp b/source/libs/planner/test/planBasicTest.cpp index f74c7df355..4ee6c1ad01 100644 --- a/source/libs/planner/test/planBasicTest.cpp +++ b/source/libs/planner/test/planBasicTest.cpp @@ -83,3 +83,15 @@ TEST_F(PlanBasicTest, interpFunc) { run("SELECT INTERP(c1) FROM t1 RANGE('2017-7-14 18:00:00', '2017-7-14 19:00:00') EVERY(5s) FILL(LINEAR)"); } + +TEST_F(PlanBasicTest, lastRowFunc) { + useDb("root", "test"); + + run("SELECT LAST_ROW(c1) FROM t1"); + + run("SELECT LAST_ROW(*) FROM t1"); + + run("SELECT LAST_ROW(c1, c2) FROM t1"); + + run("SELECT LAST_ROW(c1) FROM st1"); +} From eeab56e31836cb6a6a8a2eb29cae5e02133e6ff8 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Wed, 22 Jun 2022 09:54:31 +0800 Subject: [PATCH 2/3] feat: sql command 'select constant' --- source/libs/function/src/builtins.c | 2 +- source/libs/parser/inc/sql.y | 11 +- source/libs/parser/src/parCalcConst.c | 14 +- source/libs/parser/src/parTranslater.c | 16 +- source/libs/parser/src/sql.c | 1057 ++++++++++---------- source/libs/parser/test/parSelectTest.cpp | 6 + source/libs/planner/src/planLogicCreater.c | 15 +- source/libs/planner/src/planOptimizer.c | 26 +- source/libs/planner/src/planPhysiCreater.c | 12 +- source/libs/planner/test/planBasicTest.cpp | 6 + 10 files changed, 617 insertions(+), 548 deletions(-) diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 0c92f1328f..cfad00f458 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -1799,7 +1799,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "last_row", .type = FUNCTION_TYPE_LAST_ROW, - .classification = FUNC_MGT_MULTI_RES_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_MULTI_RES_FUNC, .translateFunc = translateLastRow, .getEnvFunc = getMinmaxFuncEnv, .initFunc = minmaxFunctionSetup, diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 54c46ecb5d..16a78712ed 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -757,8 +757,9 @@ boolean_primary(A) ::= NK_LP(C) boolean_value_expression(B) NK_RP(D). common_expression(A) ::= expression(B). { A = B; } common_expression(A) ::= boolean_value_expression(B). { A = B; } -/************************************************ from_clause *********************************************************/ -from_clause(A) ::= FROM table_reference_list(B). { A = B; } +/************************************************ from_clause_opt *********************************************************/ +from_clause_opt(A) ::= . { A = NULL; } +from_clause_opt(A) ::= FROM table_reference_list(B). { A = B; } table_reference_list(A) ::= table_reference(B). { A = B; } table_reference_list(A) ::= table_reference_list(B) NK_COMMA table_reference(C). { A = createJoinTableNode(pCxt, JOIN_TYPE_INNER, B, C, NULL); } @@ -792,9 +793,9 @@ join_type(A) ::= INNER. /************************************************ query_specification *************************************************/ query_specification(A) ::= - SELECT set_quantifier_opt(B) select_list(C) from_clause(D) where_clause_opt(E) - partition_by_clause_opt(F) range_opt(J) every_opt(K) fill_opt(L) twindow_clause_opt(G) - group_by_clause_opt(H) having_clause_opt(I). { + SELECT set_quantifier_opt(B) select_list(C) from_clause_opt(D) + where_clause_opt(E) partition_by_clause_opt(F) range_opt(J) every_opt(K) + fill_opt(L) twindow_clause_opt(G) group_by_clause_opt(H) having_clause_opt(I). { A = createSelectStmt(pCxt, B, C, D); A = addWhereClause(pCxt, A, E); A = addPartitionByClause(pCxt, A, F); diff --git a/source/libs/parser/src/parCalcConst.c b/source/libs/parser/src/parCalcConst.c index 042d6ab184..0dfc79269e 100644 --- a/source/libs/parser/src/parCalcConst.c +++ b/source/libs/parser/src/parCalcConst.c @@ -232,7 +232,11 @@ static int32_t calcConstGroupBy(SCalcConstContext* pCxt, SSelectStmt* pSelect) { return code; } -static int32_t calcConstSelect(SCalcConstContext* pCxt, SSelectStmt* pSelect, bool subquery) { +static int32_t calcConstSelectWithoutFrom(SCalcConstContext* pCxt, SSelectStmt* pSelect, bool subquery) { + return calcConstProjections(pCxt, pSelect, subquery); +} + +static int32_t calcConstSelectFrom(SCalcConstContext* pCxt, SSelectStmt* pSelect, bool subquery) { int32_t code = calcConstFromTable(pCxt, pSelect->pFromTable); if (TSDB_CODE_SUCCESS == code) { code = calcConstProjections(pCxt, pSelect, subquery); @@ -258,6 +262,14 @@ static int32_t calcConstSelect(SCalcConstContext* pCxt, SSelectStmt* pSelect, bo return code; } +static int32_t calcConstSelect(SCalcConstContext* pCxt, SSelectStmt* pSelect, bool subquery) { + if (NULL == pSelect->pFromTable) { + return calcConstSelectWithoutFrom(pCxt, pSelect, subquery); + } else { + return calcConstSelectFrom(pCxt, pSelect, subquery); + } +} + static int32_t calcConstDelete(SCalcConstContext* pCxt, SDeleteStmt* pDelete) { int32_t code = calcConstFromTable(pCxt, pDelete->pFromTable); if (TSDB_CODE_SUCCESS == code) { diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index d6619ebcc8..13202295a6 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -2466,7 +2466,13 @@ static int32_t replaceOrderByAlias(STranslateContext* pCxt, SNodeList* pProjecti return pCxt->errCode; } -static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) { +static int32_t translateSelectWithoutFrom(STranslateContext* pCxt, SSelectStmt* pSelect) { + pCxt->pCurrSelectStmt = pSelect; + pCxt->currClause = SQL_CLAUSE_SELECT; + return translateExprList(pCxt, pSelect->pProjectionList); +} + +static int32_t translateSelectFrom(STranslateContext* pCxt, SSelectStmt* pSelect) { pCxt->pCurrSelectStmt = pSelect; int32_t code = translateFrom(pCxt, pSelect->pFromTable); if (TSDB_CODE_SUCCESS == code) { @@ -2515,6 +2521,14 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) { return code; } +static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) { + if (NULL == pSelect->pFromTable) { + return translateSelectWithoutFrom(pCxt, pSelect); + } else { + return translateSelectFrom(pCxt, pSelect); + } +} + static SNode* createSetOperProject(const char* pTableAlias, SNode* pNode) { SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == pCol) { diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index c7651137b1..330cf67b22 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -139,16 +139,16 @@ typedef union { #define ParseCTX_STORE #define YYFALLBACK 1 #define YYNSTATE 641 -#define YYNRULE 466 +#define YYNRULE 467 #define YYNTOKEN 242 #define YY_MAX_SHIFT 640 #define YY_MIN_SHIFTREDUCE 933 -#define YY_MAX_SHIFTREDUCE 1398 -#define YY_ERROR_ACTION 1399 -#define YY_ACCEPT_ACTION 1400 -#define YY_NO_ACTION 1401 -#define YY_MIN_REDUCE 1402 -#define YY_MAX_REDUCE 1867 +#define YY_MAX_SHIFTREDUCE 1399 +#define YY_ERROR_ACTION 1400 +#define YY_ACCEPT_ACTION 1401 +#define YY_NO_ACTION 1402 +#define YY_MIN_REDUCE 1403 +#define YY_MAX_REDUCE 1869 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -217,226 +217,226 @@ typedef union { *********** Begin parsing tables **********************************************/ #define YY_ACTTAB_COUNT (2192) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 1697, 1845, 1522, 309, 412, 1697, 413, 1434, 326, 1400, - /* 10 */ 137, 1694, 37, 35, 1490, 1844, 1694, 1710, 417, 1842, + /* 0 */ 1698, 1847, 1523, 309, 412, 1698, 413, 1435, 326, 1401, + /* 10 */ 137, 1695, 37, 35, 1491, 1846, 1695, 1711, 417, 1844, /* 20 */ 318, 556, 1208, 556, 1230, 38, 36, 34, 33, 32, - /* 30 */ 325, 324, 109, 420, 109, 413, 1434, 1690, 1696, 451, - /* 40 */ 1222, 456, 1690, 1696, 1726, 30, 240, 1206, 559, 1533, - /* 50 */ 1793, 1533, 540, 559, 22, 556, 555, 1680, 14, 539, - /* 60 */ 37, 35, 1335, 322, 1214, 1215, 157, 335, 318, 1710, - /* 70 */ 1208, 134, 520, 365, 1790, 38, 36, 34, 33, 32, - /* 80 */ 1535, 1, 1214, 1533, 1739, 67, 555, 85, 1711, 542, - /* 90 */ 1713, 1714, 538, 58, 559, 1206, 1726, 1779, 113, 76, - /* 100 */ 371, 292, 1775, 637, 519, 556, 14, 1528, 1845, 1680, - /* 110 */ 1425, 539, 1214, 1845, 1845, 543, 369, 1277, 1278, 963, - /* 120 */ 1526, 560, 152, 470, 555, 1631, 1842, 154, 152, 2, - /* 130 */ 430, 1842, 1842, 1533, 206, 82, 1739, 290, 478, 86, - /* 140 */ 1711, 542, 1713, 1714, 538, 1369, 559, 40, 118, 1779, - /* 150 */ 1680, 637, 198, 311, 1775, 148, 1525, 967, 968, 1209, + /* 30 */ 325, 324, 109, 420, 109, 413, 1435, 1691, 1697, 451, + /* 40 */ 1222, 456, 1691, 1697, 1727, 30, 240, 1206, 559, 1534, + /* 50 */ 1795, 1534, 540, 559, 22, 556, 555, 1681, 14, 539, + /* 60 */ 37, 35, 1336, 322, 1214, 1215, 157, 335, 318, 1711, + /* 70 */ 1208, 134, 520, 365, 1792, 38, 36, 34, 33, 32, + /* 80 */ 1536, 1, 1214, 1534, 1740, 67, 555, 85, 1712, 542, + /* 90 */ 1714, 1715, 538, 58, 559, 1206, 1727, 1780, 113, 76, + /* 100 */ 371, 292, 1776, 637, 519, 556, 14, 1529, 1847, 1681, + /* 110 */ 1426, 539, 1214, 1847, 1847, 543, 369, 1277, 1278, 963, + /* 120 */ 1527, 560, 152, 470, 555, 1632, 1844, 154, 152, 2, + /* 130 */ 430, 1844, 1844, 1534, 206, 82, 1740, 290, 478, 86, + /* 140 */ 1712, 542, 1714, 1715, 538, 1370, 559, 40, 118, 1780, + /* 150 */ 1681, 637, 198, 311, 1776, 148, 1526, 967, 968, 1209, /* 160 */ 58, 1207, 70, 328, 473, 1277, 1278, 232, 56, 467, - /* 170 */ 364, 134, 363, 1233, 197, 495, 1806, 1223, 330, 1218, - /* 180 */ 1535, 1578, 1580, 1212, 1213, 41, 1259, 1260, 1262, 1263, + /* 170 */ 364, 134, 363, 1233, 197, 495, 1808, 1223, 330, 1218, + /* 180 */ 1536, 1579, 1581, 1212, 1213, 41, 1259, 1260, 1262, 1263, /* 190 */ 1264, 1265, 1266, 535, 557, 1274, 1275, 1276, 1279, 53, - /* 200 */ 1232, 1226, 52, 1579, 1580, 26, 59, 1209, 1845, 1207, + /* 200 */ 1232, 1226, 52, 1580, 1581, 26, 59, 1209, 1847, 1207, /* 210 */ 510, 155, 557, 1274, 1275, 38, 36, 34, 33, 32, - /* 220 */ 37, 35, 153, 155, 1424, 1710, 1842, 402, 318, 67, + /* 220 */ 37, 35, 153, 155, 1425, 1711, 1844, 402, 318, 67, /* 230 */ 1208, 1212, 1213, 302, 1259, 1260, 1262, 1263, 1264, 1265, - /* 240 */ 1266, 535, 557, 1274, 1275, 1276, 1279, 516, 1726, 465, - /* 250 */ 464, 1529, 1726, 489, 463, 1206, 509, 114, 460, 1668, - /* 260 */ 540, 459, 458, 457, 1680, 1680, 14, 539, 37, 35, + /* 240 */ 1266, 535, 557, 1274, 1275, 1276, 1279, 516, 1727, 465, + /* 250 */ 464, 1530, 1727, 489, 463, 1206, 509, 114, 460, 1669, + /* 260 */ 540, 459, 458, 457, 1681, 1681, 14, 539, 37, 35, /* 270 */ 1112, 1113, 1214, 166, 165, 117, 318, 155, 1208, 1299, - /* 280 */ 520, 1511, 303, 58, 301, 300, 356, 453, 58, 2, - /* 290 */ 155, 455, 1739, 508, 1845, 85, 1711, 542, 1713, 1714, - /* 300 */ 538, 1304, 559, 1206, 344, 1779, 358, 354, 152, 292, - /* 310 */ 1775, 637, 1842, 454, 115, 38, 36, 34, 33, 32, - /* 320 */ 1214, 1845, 136, 1524, 1414, 1277, 1278, 1509, 518, 149, - /* 330 */ 1786, 1787, 1233, 1791, 1694, 152, 27, 8, 430, 1842, + /* 280 */ 520, 1512, 303, 58, 301, 300, 356, 453, 58, 2, + /* 290 */ 155, 455, 1740, 508, 1847, 85, 1712, 542, 1714, 1715, + /* 300 */ 538, 1304, 559, 1206, 344, 1780, 358, 354, 152, 292, + /* 310 */ 1776, 637, 1844, 454, 115, 38, 36, 34, 33, 32, + /* 320 */ 1214, 1847, 136, 1525, 1415, 1277, 1278, 1510, 518, 149, + /* 330 */ 1788, 1789, 1233, 1793, 1695, 152, 27, 8, 430, 1844, /* 340 */ 1070, 582, 581, 580, 1074, 579, 1076, 1077, 578, 1079, - /* 350 */ 575, 1403, 1085, 572, 1087, 1088, 569, 566, 81, 637, - /* 360 */ 1690, 1696, 38, 36, 34, 33, 32, 1209, 78, 1207, - /* 370 */ 1359, 559, 99, 1277, 1278, 98, 97, 96, 95, 94, - /* 380 */ 93, 92, 91, 90, 593, 1349, 38, 36, 34, 33, + /* 350 */ 575, 1404, 1085, 572, 1087, 1088, 569, 566, 81, 637, + /* 360 */ 1691, 1697, 38, 36, 34, 33, 32, 1209, 78, 1207, + /* 370 */ 1360, 559, 99, 1277, 1278, 98, 97, 96, 95, 94, + /* 380 */ 93, 92, 91, 90, 593, 1350, 38, 36, 34, 33, /* 390 */ 32, 1212, 1213, 522, 1259, 1260, 1262, 1263, 1264, 1265, - /* 400 */ 1266, 535, 557, 1274, 1275, 1276, 1279, 502, 1357, 1358, - /* 410 */ 1360, 1361, 980, 155, 979, 1209, 99, 1207, 155, 98, + /* 400 */ 1266, 535, 557, 1274, 1275, 1276, 1279, 502, 1358, 1359, + /* 410 */ 1361, 1362, 980, 155, 979, 1209, 99, 1207, 155, 98, /* 420 */ 97, 96, 95, 94, 93, 92, 91, 90, 37, 35, - /* 430 */ 1280, 11, 10, 1710, 462, 461, 318, 162, 1208, 1212, + /* 430 */ 1280, 11, 10, 1711, 462, 461, 318, 162, 1208, 1212, /* 440 */ 1213, 981, 1259, 1260, 1262, 1263, 1264, 1265, 1266, 535, /* 450 */ 557, 1274, 1275, 1276, 1279, 38, 36, 34, 33, 32, - /* 460 */ 1726, 479, 65, 1206, 1845, 64, 593, 155, 540, 980, - /* 470 */ 147, 979, 1585, 1680, 1231, 539, 37, 35, 1843, 308, - /* 480 */ 1214, 1461, 1842, 1572, 318, 1793, 1208, 1423, 1583, 1214, - /* 490 */ 38, 36, 34, 33, 32, 1422, 449, 9, 981, 1234, - /* 500 */ 1739, 1395, 1845, 87, 1711, 542, 1713, 1714, 538, 1789, - /* 510 */ 559, 1206, 1311, 1779, 199, 134, 152, 1778, 1775, 637, - /* 520 */ 1842, 543, 133, 1585, 1536, 1246, 1342, 1680, 1214, 321, - /* 530 */ 323, 1630, 1232, 1277, 1278, 1680, 293, 609, 607, 1583, - /* 540 */ 1421, 615, 614, 613, 333, 9, 612, 611, 610, 119, + /* 460 */ 1727, 479, 65, 1206, 1847, 64, 593, 155, 540, 980, + /* 470 */ 147, 979, 1586, 1681, 1231, 539, 37, 35, 1845, 308, + /* 480 */ 1214, 1462, 1844, 1573, 318, 1795, 1208, 1424, 1584, 1214, + /* 490 */ 38, 36, 34, 33, 32, 1423, 449, 9, 981, 1234, + /* 500 */ 1740, 1396, 1847, 87, 1712, 542, 1714, 1715, 538, 1791, + /* 510 */ 559, 1206, 1311, 1780, 199, 134, 152, 1779, 1776, 637, + /* 520 */ 1844, 543, 133, 1586, 1537, 1246, 1343, 1681, 1214, 321, + /* 530 */ 323, 1631, 1232, 1277, 1278, 1681, 293, 609, 607, 1584, + /* 540 */ 1422, 615, 614, 613, 333, 9, 612, 611, 610, 119, /* 550 */ 605, 604, 603, 602, 601, 600, 599, 598, 127, 594, - /* 560 */ 1246, 1402, 38, 36, 34, 33, 32, 637, 1297, 505, - /* 570 */ 69, 291, 1285, 967, 968, 1209, 1420, 1207, 1232, 1419, - /* 580 */ 1680, 1277, 1278, 1394, 28, 108, 107, 106, 105, 104, + /* 560 */ 1246, 1403, 38, 36, 34, 33, 32, 637, 1297, 505, + /* 570 */ 69, 291, 1285, 967, 968, 1209, 1421, 1207, 1232, 1420, + /* 580 */ 1681, 1277, 1278, 1395, 28, 108, 107, 106, 105, 104, /* 590 */ 103, 102, 101, 100, 38, 36, 34, 33, 32, 1212, - /* 600 */ 1213, 1510, 1259, 1260, 1262, 1263, 1264, 1265, 1266, 535, - /* 610 */ 557, 1274, 1275, 1276, 1279, 556, 1680, 1585, 1585, 1680, - /* 620 */ 1298, 331, 585, 1209, 329, 1207, 370, 231, 1518, 134, - /* 630 */ 34, 33, 32, 1583, 1584, 1418, 37, 35, 1535, 511, - /* 640 */ 506, 200, 1303, 1533, 318, 591, 1208, 1212, 1213, 1417, + /* 600 */ 1213, 1511, 1259, 1260, 1262, 1263, 1264, 1265, 1266, 535, + /* 610 */ 557, 1274, 1275, 1276, 1279, 556, 1681, 1586, 1586, 1681, + /* 620 */ 1298, 331, 585, 1209, 329, 1207, 370, 231, 1519, 134, + /* 630 */ 34, 33, 32, 1584, 1585, 1419, 37, 35, 1536, 511, + /* 640 */ 506, 200, 1303, 1534, 318, 591, 1208, 1212, 1213, 1418, /* 650 */ 1259, 1260, 1262, 1263, 1264, 1265, 1266, 535, 557, 1274, /* 660 */ 1275, 1276, 1279, 556, 125, 124, 588, 587, 586, 411, - /* 670 */ 419, 1206, 415, 415, 372, 1680, 556, 29, 316, 1292, - /* 680 */ 1293, 1294, 1295, 1296, 1300, 1301, 1302, 387, 1214, 1680, - /* 690 */ 185, 1533, 556, 263, 591, 597, 1563, 1505, 1416, 1261, - /* 700 */ 1190, 1191, 140, 388, 1533, 2, 1413, 556, 447, 443, - /* 710 */ 439, 435, 184, 125, 124, 588, 587, 586, 429, 1793, - /* 720 */ 1533, 1698, 1710, 1334, 289, 1232, 1230, 637, 1412, 1700, - /* 730 */ 1411, 455, 1694, 395, 7, 1533, 407, 68, 1680, 556, - /* 740 */ 182, 1277, 1278, 1788, 556, 1261, 1680, 1410, 1409, 1726, - /* 750 */ 1530, 380, 1235, 454, 408, 1657, 382, 540, 1690, 1696, - /* 760 */ 135, 524, 1680, 556, 539, 269, 1702, 1533, 1680, 559, - /* 770 */ 1680, 1621, 1533, 556, 487, 496, 589, 267, 55, 1576, - /* 780 */ 527, 54, 164, 1209, 553, 1207, 373, 1680, 1680, 1739, - /* 790 */ 596, 1533, 287, 1711, 542, 1713, 1714, 538, 167, 559, - /* 800 */ 181, 1533, 173, 1464, 178, 1520, 425, 1212, 1213, 1408, + /* 670 */ 419, 1206, 415, 415, 372, 1681, 556, 29, 316, 1292, + /* 680 */ 1293, 1294, 1295, 1296, 1300, 1301, 1302, 387, 1214, 1681, + /* 690 */ 185, 1534, 556, 263, 591, 597, 1564, 1506, 1417, 1261, + /* 700 */ 1190, 1191, 140, 388, 1534, 2, 1414, 556, 447, 443, + /* 710 */ 439, 435, 184, 125, 124, 588, 587, 586, 429, 1795, + /* 720 */ 1534, 1699, 1711, 1335, 289, 1232, 1230, 637, 1413, 1701, + /* 730 */ 1412, 455, 1695, 395, 7, 1534, 407, 68, 1681, 556, + /* 740 */ 182, 1277, 1278, 1790, 556, 1261, 1681, 1411, 1410, 1727, + /* 750 */ 1531, 380, 1235, 454, 408, 1658, 382, 540, 1691, 1697, + /* 760 */ 135, 524, 1681, 556, 539, 269, 1703, 1534, 1681, 559, + /* 770 */ 1681, 1622, 1534, 556, 487, 496, 589, 267, 55, 1577, + /* 780 */ 527, 54, 164, 1209, 553, 1207, 373, 1681, 1681, 1740, + /* 790 */ 596, 1534, 287, 1712, 542, 1714, 1715, 538, 167, 559, + /* 800 */ 181, 1534, 173, 1465, 178, 1521, 425, 1212, 1213, 1409, /* 810 */ 1259, 1260, 1262, 1263, 1264, 1265, 1266, 535, 557, 1274, - /* 820 */ 1275, 1276, 1279, 58, 590, 171, 406, 1576, 1516, 401, + /* 820 */ 1275, 1276, 1279, 58, 590, 171, 406, 1577, 1517, 401, /* 830 */ 400, 399, 398, 397, 394, 393, 392, 391, 390, 386, - /* 840 */ 385, 384, 383, 377, 376, 375, 374, 203, 1032, 1680, + /* 840 */ 385, 384, 383, 377, 376, 375, 374, 203, 1032, 1681, /* 850 */ 38, 36, 34, 33, 32, 556, 556, 1208, 556, 516, - /* 860 */ 1407, 84, 1406, 465, 464, 1034, 554, 253, 463, 332, - /* 870 */ 1405, 114, 460, 1798, 1330, 459, 458, 457, 608, 1451, - /* 880 */ 212, 534, 1206, 1533, 1533, 190, 1533, 117, 188, 486, - /* 890 */ 1710, 1508, 1261, 62, 61, 368, 293, 1217, 161, 1214, - /* 900 */ 1680, 466, 1680, 192, 362, 516, 191, 1330, 194, 196, - /* 910 */ 1680, 193, 195, 1446, 1444, 288, 584, 1726, 352, 359, - /* 920 */ 350, 346, 342, 158, 337, 519, 115, 477, 1297, 1415, - /* 930 */ 1680, 1333, 539, 117, 1216, 468, 471, 123, 637, 1004, - /* 940 */ 475, 150, 1786, 1787, 532, 1791, 235, 11, 10, 48, - /* 950 */ 525, 216, 1491, 155, 448, 503, 1005, 1739, 1710, 480, - /* 960 */ 86, 1711, 542, 1713, 1714, 538, 1440, 559, 1397, 1398, - /* 970 */ 1779, 528, 115, 39, 311, 1775, 148, 223, 491, 39, - /* 980 */ 1298, 1727, 1710, 334, 591, 1726, 39, 151, 1786, 1787, - /* 990 */ 1356, 1791, 218, 540, 1209, 242, 1207, 1807, 1680, 1435, - /* 1000 */ 539, 1573, 1303, 125, 124, 588, 587, 586, 1809, 1726, + /* 860 */ 1408, 84, 1407, 465, 464, 1034, 554, 253, 463, 332, + /* 870 */ 1406, 114, 460, 1800, 1331, 459, 458, 457, 608, 1452, + /* 880 */ 212, 534, 1206, 1534, 1534, 190, 1534, 117, 188, 486, + /* 890 */ 1711, 1509, 1261, 62, 61, 368, 293, 1217, 161, 1214, + /* 900 */ 1681, 466, 1681, 192, 362, 516, 191, 1331, 194, 196, + /* 910 */ 1681, 193, 195, 1447, 1445, 288, 584, 1727, 352, 359, + /* 920 */ 350, 346, 342, 158, 337, 519, 115, 477, 1297, 1416, + /* 930 */ 1681, 1334, 539, 117, 1216, 468, 471, 123, 637, 1004, + /* 940 */ 475, 150, 1788, 1789, 532, 1793, 235, 11, 10, 48, + /* 950 */ 525, 216, 1492, 155, 448, 503, 1005, 1740, 1711, 480, + /* 960 */ 86, 1712, 542, 1714, 1715, 538, 1441, 559, 1398, 1399, + /* 970 */ 1780, 528, 115, 39, 311, 1776, 148, 223, 491, 39, + /* 980 */ 1298, 1728, 1711, 334, 591, 1727, 39, 151, 1788, 1789, + /* 990 */ 1357, 1793, 218, 540, 1209, 242, 1207, 1809, 1681, 1436, + /* 1000 */ 539, 1574, 1303, 125, 124, 588, 587, 586, 1811, 1727, /* 1010 */ 121, 1220, 633, 517, 1305, 234, 237, 540, 1212, 1213, - /* 1020 */ 1267, 239, 1680, 1710, 539, 1739, 3, 1163, 272, 1711, - /* 1030 */ 542, 1713, 1714, 538, 122, 559, 244, 29, 316, 1292, - /* 1040 */ 1293, 1294, 1295, 1296, 1300, 1301, 1302, 123, 1219, 1739, - /* 1050 */ 1726, 548, 86, 1711, 542, 1713, 1714, 538, 540, 559, - /* 1060 */ 48, 564, 1779, 1680, 1710, 539, 311, 1775, 1858, 1289, - /* 1070 */ 122, 123, 110, 122, 5, 250, 336, 1813, 1230, 339, + /* 1020 */ 1267, 239, 1681, 1711, 539, 1740, 3, 1163, 272, 1712, + /* 1030 */ 542, 1714, 1715, 538, 122, 559, 244, 29, 316, 1292, + /* 1040 */ 1293, 1294, 1295, 1296, 1300, 1301, 1302, 123, 1219, 1740, + /* 1050 */ 1727, 548, 86, 1712, 542, 1714, 1715, 538, 540, 559, + /* 1060 */ 48, 564, 1780, 1681, 1711, 539, 311, 1776, 1860, 1289, + /* 1070 */ 122, 123, 110, 122, 5, 250, 336, 1815, 1230, 339, /* 1080 */ 343, 298, 1174, 1032, 299, 259, 389, 163, 1063, 396, - /* 1090 */ 1739, 1726, 1623, 86, 1711, 542, 1713, 1714, 538, 540, - /* 1100 */ 559, 262, 1091, 1779, 1680, 404, 539, 311, 1775, 1858, - /* 1110 */ 403, 1095, 1102, 1100, 126, 405, 409, 1236, 1836, 410, + /* 1090 */ 1740, 1727, 1624, 86, 1712, 542, 1714, 1715, 538, 540, + /* 1100 */ 559, 262, 1091, 1780, 1681, 404, 539, 311, 1776, 1860, + /* 1110 */ 403, 1095, 1102, 1100, 126, 405, 409, 1236, 1838, 410, /* 1120 */ 418, 1239, 421, 170, 172, 1238, 422, 423, 1240, 426, - /* 1130 */ 424, 1739, 175, 177, 86, 1711, 542, 1713, 1714, 538, - /* 1140 */ 1710, 559, 427, 1237, 1779, 428, 180, 450, 311, 1775, - /* 1150 */ 1858, 431, 452, 66, 183, 1523, 187, 1519, 481, 1797, - /* 1160 */ 189, 128, 307, 89, 260, 129, 1521, 1726, 482, 485, - /* 1170 */ 201, 204, 488, 1517, 130, 540, 131, 490, 207, 1235, - /* 1180 */ 1680, 210, 539, 1810, 504, 546, 6, 492, 1662, 1820, - /* 1190 */ 1661, 1819, 513, 1800, 222, 520, 142, 499, 500, 224, - /* 1200 */ 498, 225, 493, 1710, 501, 1330, 310, 1739, 497, 226, - /* 1210 */ 278, 1711, 542, 1713, 1714, 538, 507, 559, 214, 217, - /* 1220 */ 1710, 116, 1234, 42, 1841, 18, 526, 529, 227, 523, - /* 1230 */ 1726, 233, 312, 1861, 544, 545, 1845, 320, 540, 1794, - /* 1240 */ 1629, 549, 246, 1680, 1628, 539, 551, 1726, 261, 550, - /* 1250 */ 154, 77, 1534, 248, 1842, 540, 75, 562, 520, 264, - /* 1260 */ 1680, 228, 539, 1760, 1577, 1506, 256, 49, 636, 266, - /* 1270 */ 1739, 270, 1674, 278, 1711, 542, 1713, 1714, 538, 279, - /* 1280 */ 559, 271, 268, 1710, 141, 236, 1673, 1739, 530, 60, - /* 1290 */ 87, 1711, 542, 1713, 1714, 538, 238, 559, 1672, 1845, - /* 1300 */ 1779, 1710, 338, 1669, 531, 1775, 340, 341, 1201, 1202, - /* 1310 */ 1726, 159, 345, 152, 1667, 347, 348, 1842, 537, 349, - /* 1320 */ 1666, 1665, 351, 1680, 353, 539, 1664, 355, 1726, 1663, - /* 1330 */ 357, 1647, 160, 360, 361, 1177, 540, 1176, 1641, 1640, - /* 1340 */ 366, 1680, 367, 539, 1639, 1638, 1149, 1616, 63, 1615, - /* 1350 */ 1739, 378, 1710, 286, 1711, 542, 1713, 1714, 538, 536, - /* 1360 */ 559, 533, 1751, 1614, 1613, 1612, 1611, 1610, 1739, 379, - /* 1370 */ 640, 138, 1711, 542, 1713, 1714, 538, 381, 559, 1726, - /* 1380 */ 1609, 1608, 1607, 1606, 258, 1605, 1604, 540, 1603, 1602, - /* 1390 */ 1601, 1600, 1680, 516, 539, 1599, 145, 1598, 1597, 1596, - /* 1400 */ 120, 1595, 631, 627, 623, 619, 257, 1594, 1593, 1592, - /* 1410 */ 1591, 1590, 1589, 1710, 1151, 1588, 521, 1859, 1587, 1739, - /* 1420 */ 1586, 117, 87, 1711, 542, 1713, 1714, 538, 1463, 559, - /* 1430 */ 1431, 83, 1779, 168, 251, 146, 970, 1776, 969, 111, - /* 1440 */ 1726, 520, 1430, 169, 414, 1655, 1649, 416, 540, 1637, - /* 1450 */ 112, 174, 1636, 1680, 176, 539, 1626, 1512, 179, 1462, - /* 1460 */ 115, 1460, 434, 998, 433, 1458, 1710, 552, 438, 1456, - /* 1470 */ 432, 1454, 437, 436, 441, 229, 1786, 515, 442, 514, - /* 1480 */ 1739, 440, 1845, 282, 1711, 542, 1713, 1714, 538, 1710, - /* 1490 */ 559, 444, 445, 1726, 1443, 494, 154, 446, 208, 1442, - /* 1500 */ 1842, 540, 1429, 1514, 186, 1106, 1680, 516, 539, 1105, - /* 1510 */ 1513, 1031, 1452, 1030, 1029, 1028, 1726, 1182, 606, 202, - /* 1520 */ 608, 1025, 512, 47, 540, 1024, 304, 1023, 1447, 1680, - /* 1530 */ 305, 539, 469, 1739, 1445, 117, 138, 1711, 542, 1713, - /* 1540 */ 1714, 538, 315, 559, 306, 1710, 1428, 472, 474, 1427, - /* 1550 */ 88, 476, 1654, 1184, 51, 520, 1739, 1648, 483, 287, - /* 1560 */ 1711, 542, 1713, 1714, 538, 1635, 559, 1634, 1633, 1625, - /* 1570 */ 71, 15, 1726, 4, 115, 209, 39, 1371, 23, 213, - /* 1580 */ 537, 205, 1860, 484, 45, 1680, 211, 539, 50, 229, - /* 1590 */ 1786, 515, 139, 514, 220, 215, 1845, 132, 1710, 1355, - /* 1600 */ 219, 24, 221, 1348, 1700, 72, 230, 1710, 143, 1327, - /* 1610 */ 152, 25, 1739, 1326, 1842, 286, 1711, 542, 1713, 1714, - /* 1620 */ 538, 1710, 559, 44, 1752, 1726, 1388, 17, 1383, 1377, - /* 1630 */ 10, 1382, 313, 540, 1726, 1387, 1386, 314, 1680, 19, - /* 1640 */ 539, 1269, 540, 1268, 31, 1290, 144, 1680, 1726, 539, + /* 1130 */ 424, 1740, 175, 177, 86, 1712, 542, 1714, 1715, 538, + /* 1140 */ 1711, 559, 427, 1237, 1780, 428, 180, 450, 311, 1776, + /* 1150 */ 1860, 431, 452, 66, 183, 1524, 187, 1520, 481, 1799, + /* 1160 */ 189, 128, 307, 89, 260, 129, 1522, 1727, 482, 485, + /* 1170 */ 201, 204, 488, 1518, 130, 540, 131, 490, 207, 1235, + /* 1180 */ 1681, 210, 539, 1812, 504, 546, 6, 492, 1663, 1822, + /* 1190 */ 1662, 1821, 513, 1802, 222, 520, 142, 499, 500, 224, + /* 1200 */ 498, 225, 493, 1711, 501, 1331, 310, 1740, 497, 226, + /* 1210 */ 278, 1712, 542, 1714, 1715, 538, 507, 559, 214, 217, + /* 1220 */ 1711, 116, 1234, 42, 1843, 18, 526, 529, 227, 523, + /* 1230 */ 1727, 233, 312, 1863, 544, 545, 1847, 320, 540, 1796, + /* 1240 */ 1630, 549, 246, 1681, 1629, 539, 551, 1727, 261, 550, + /* 1250 */ 154, 77, 1535, 248, 1844, 540, 75, 562, 520, 264, + /* 1260 */ 1681, 228, 539, 1761, 1578, 1507, 256, 49, 636, 266, + /* 1270 */ 1740, 270, 1675, 278, 1712, 542, 1714, 1715, 538, 279, + /* 1280 */ 559, 271, 268, 1711, 141, 236, 1674, 1740, 530, 60, + /* 1290 */ 87, 1712, 542, 1714, 1715, 538, 238, 559, 1673, 1847, + /* 1300 */ 1780, 1711, 338, 1670, 531, 1776, 340, 341, 1201, 1202, + /* 1310 */ 1727, 159, 345, 152, 1668, 347, 348, 1844, 537, 349, + /* 1320 */ 1667, 1666, 351, 1681, 353, 539, 1665, 355, 1727, 1664, + /* 1330 */ 357, 1648, 160, 360, 361, 1177, 540, 1176, 1642, 1641, + /* 1340 */ 366, 1681, 367, 539, 1640, 1639, 1149, 1617, 63, 1616, + /* 1350 */ 1740, 378, 1711, 286, 1712, 542, 1714, 1715, 538, 536, + /* 1360 */ 559, 533, 1752, 1615, 1614, 1613, 1612, 1611, 1740, 379, + /* 1370 */ 640, 138, 1712, 542, 1714, 1715, 538, 381, 559, 1727, + /* 1380 */ 1610, 1609, 1608, 1607, 258, 1606, 1605, 540, 1604, 1603, + /* 1390 */ 1602, 1601, 1681, 516, 539, 1600, 145, 1599, 1598, 1597, + /* 1400 */ 120, 1596, 631, 627, 623, 619, 257, 1595, 1594, 1593, + /* 1410 */ 1592, 1591, 1590, 1711, 1151, 1589, 521, 1861, 1588, 1740, + /* 1420 */ 1587, 117, 87, 1712, 542, 1714, 1715, 538, 1464, 559, + /* 1430 */ 1432, 83, 1780, 168, 251, 146, 970, 1777, 969, 111, + /* 1440 */ 1727, 520, 1431, 169, 414, 1656, 1650, 416, 540, 1638, + /* 1450 */ 112, 174, 1637, 1681, 176, 539, 1627, 1513, 179, 1463, + /* 1460 */ 115, 1461, 434, 998, 433, 1459, 1711, 552, 438, 1457, + /* 1470 */ 432, 1455, 437, 436, 441, 229, 1788, 515, 442, 514, + /* 1480 */ 1740, 440, 1847, 282, 1712, 542, 1714, 1715, 538, 1711, + /* 1490 */ 559, 444, 445, 1727, 1444, 494, 154, 446, 208, 1443, + /* 1500 */ 1844, 540, 1430, 1515, 186, 1106, 1681, 516, 539, 1105, + /* 1510 */ 1514, 1031, 1453, 1030, 1029, 1028, 1727, 1182, 606, 202, + /* 1520 */ 608, 1025, 512, 47, 540, 1024, 304, 1023, 1448, 1681, + /* 1530 */ 305, 539, 469, 1740, 1446, 117, 138, 1712, 542, 1714, + /* 1540 */ 1715, 538, 315, 559, 306, 1711, 1429, 472, 474, 1428, + /* 1550 */ 88, 476, 1655, 1184, 51, 520, 1740, 1649, 483, 287, + /* 1560 */ 1712, 542, 1714, 1715, 538, 1636, 559, 1635, 1634, 1626, + /* 1570 */ 71, 15, 1727, 4, 115, 209, 39, 1372, 23, 213, + /* 1580 */ 537, 205, 1862, 484, 45, 1681, 211, 539, 50, 229, + /* 1590 */ 1788, 515, 139, 514, 220, 215, 1847, 132, 1711, 1356, + /* 1600 */ 219, 24, 221, 1349, 1701, 72, 230, 1711, 143, 1328, + /* 1610 */ 152, 25, 1740, 1327, 1844, 286, 1712, 542, 1714, 1715, + /* 1620 */ 538, 1711, 559, 44, 1753, 1727, 1389, 17, 1384, 1378, + /* 1630 */ 10, 1383, 313, 540, 1727, 1388, 1387, 314, 1681, 19, + /* 1640 */ 539, 1269, 540, 1268, 31, 1290, 144, 1681, 1727, 539, /* 1650 */ 156, 317, 16, 12, 13, 20, 540, 43, 1254, 21, - /* 1660 */ 319, 1680, 1710, 539, 1624, 1739, 541, 247, 287, 1711, - /* 1670 */ 542, 1713, 1714, 538, 1739, 559, 241, 287, 1711, 542, - /* 1680 */ 1713, 1714, 538, 1710, 559, 1353, 243, 547, 1739, 1726, - /* 1690 */ 245, 273, 1711, 542, 1713, 1714, 538, 540, 559, 73, - /* 1700 */ 74, 78, 1680, 1699, 539, 252, 1742, 1224, 1271, 249, - /* 1710 */ 1726, 1092, 558, 46, 561, 563, 327, 1089, 540, 565, - /* 1720 */ 567, 568, 570, 1680, 1086, 539, 571, 573, 1080, 1739, - /* 1730 */ 574, 576, 274, 1711, 542, 1713, 1714, 538, 1078, 559, - /* 1740 */ 1069, 1710, 1084, 583, 577, 1101, 1083, 79, 1082, 1081, - /* 1750 */ 1739, 80, 1710, 281, 1711, 542, 1713, 1714, 538, 57, - /* 1760 */ 559, 254, 1097, 1710, 996, 592, 1020, 595, 1726, 255, - /* 1770 */ 1038, 1013, 1018, 1017, 1016, 1035, 540, 1015, 1014, 1726, - /* 1780 */ 1012, 1680, 1011, 539, 1033, 1008, 1007, 540, 1006, 1003, - /* 1790 */ 1726, 1002, 1680, 1001, 539, 1459, 617, 616, 540, 618, - /* 1800 */ 1457, 620, 621, 1680, 622, 539, 1455, 624, 1739, 625, - /* 1810 */ 626, 283, 1711, 542, 1713, 1714, 538, 1453, 559, 1739, - /* 1820 */ 629, 628, 275, 1711, 542, 1713, 1714, 538, 1710, 559, - /* 1830 */ 1739, 630, 1441, 284, 1711, 542, 1713, 1714, 538, 632, - /* 1840 */ 559, 1426, 634, 635, 1710, 1210, 265, 638, 639, 1401, - /* 1850 */ 1401, 1401, 1401, 1401, 1401, 1726, 1401, 1401, 1401, 1401, - /* 1860 */ 1401, 1401, 1401, 540, 1401, 1401, 1401, 1401, 1680, 1401, - /* 1870 */ 539, 1726, 1401, 1401, 1401, 1401, 1401, 1401, 1401, 540, - /* 1880 */ 1401, 1401, 1401, 1401, 1680, 1401, 539, 1401, 1401, 1401, - /* 1890 */ 1401, 1401, 1401, 1710, 1401, 1739, 1401, 1401, 276, 1711, - /* 1900 */ 542, 1713, 1714, 538, 1401, 559, 1401, 1710, 1401, 1401, - /* 1910 */ 1401, 1739, 1401, 1401, 285, 1711, 542, 1713, 1714, 538, - /* 1920 */ 1726, 559, 1401, 1401, 1401, 1401, 1401, 1401, 540, 1401, - /* 1930 */ 1401, 1401, 1401, 1680, 1726, 539, 1401, 1401, 1401, 1401, - /* 1940 */ 1401, 1401, 540, 1401, 1401, 1401, 1401, 1680, 1710, 539, - /* 1950 */ 1401, 1401, 1401, 1401, 1401, 1401, 1401, 1401, 1401, 1401, - /* 1960 */ 1739, 1401, 1401, 277, 1711, 542, 1713, 1714, 538, 1710, - /* 1970 */ 559, 1401, 1401, 1401, 1739, 1726, 1401, 1722, 1711, 542, - /* 1980 */ 1713, 1714, 538, 540, 559, 1401, 1401, 1401, 1680, 1401, - /* 1990 */ 539, 1401, 1401, 1401, 1401, 1401, 1726, 1401, 1401, 1401, - /* 2000 */ 1401, 1401, 1401, 1401, 540, 1401, 1401, 1401, 1401, 1680, - /* 2010 */ 1401, 539, 1401, 1401, 1401, 1739, 1401, 1401, 1721, 1711, - /* 2020 */ 542, 1713, 1714, 538, 1401, 559, 1401, 1710, 1401, 1401, - /* 2030 */ 1401, 1401, 1401, 1401, 1401, 1401, 1739, 1401, 1710, 1720, - /* 2040 */ 1711, 542, 1713, 1714, 538, 1401, 559, 1401, 1401, 1710, - /* 2050 */ 1401, 1401, 1401, 1401, 1726, 1401, 1401, 1401, 1401, 1401, - /* 2060 */ 1401, 1401, 540, 1401, 1401, 1726, 1401, 1680, 1401, 539, - /* 2070 */ 1401, 1401, 1401, 540, 1401, 1401, 1726, 1401, 1680, 1401, - /* 2080 */ 539, 1401, 1401, 1401, 540, 1401, 1401, 1401, 1401, 1680, - /* 2090 */ 1710, 539, 1401, 1401, 1739, 1401, 1401, 296, 1711, 542, - /* 2100 */ 1713, 1714, 538, 1401, 559, 1739, 1401, 1401, 295, 1711, - /* 2110 */ 542, 1713, 1714, 538, 1710, 559, 1739, 1726, 1401, 297, - /* 2120 */ 1711, 542, 1713, 1714, 538, 540, 559, 1401, 1401, 1401, - /* 2130 */ 1680, 1401, 539, 1401, 1401, 1401, 1401, 1401, 1401, 1401, - /* 2140 */ 1401, 1726, 1401, 1401, 1401, 1401, 1401, 1401, 1401, 540, - /* 2150 */ 1401, 1401, 1401, 1401, 1680, 1401, 539, 1739, 1401, 1401, - /* 2160 */ 294, 1711, 542, 1713, 1714, 538, 1401, 559, 1401, 1401, - /* 2170 */ 1401, 1401, 1401, 1401, 1401, 1401, 1401, 1401, 1401, 1401, - /* 2180 */ 1401, 1739, 1401, 1401, 280, 1711, 542, 1713, 1714, 538, - /* 2190 */ 1401, 559, + /* 1660 */ 319, 1681, 1711, 539, 1625, 1740, 541, 247, 287, 1712, + /* 1670 */ 542, 1714, 1715, 538, 1740, 559, 241, 287, 1712, 542, + /* 1680 */ 1714, 1715, 538, 1711, 559, 1354, 243, 547, 1740, 1727, + /* 1690 */ 245, 273, 1712, 542, 1714, 1715, 538, 540, 559, 73, + /* 1700 */ 74, 78, 1681, 1700, 539, 252, 1743, 1224, 1271, 249, + /* 1710 */ 1727, 1092, 558, 46, 561, 563, 327, 1089, 540, 565, + /* 1720 */ 567, 568, 570, 1681, 1086, 539, 571, 573, 1080, 1740, + /* 1730 */ 574, 576, 274, 1712, 542, 1714, 1715, 538, 1078, 559, + /* 1740 */ 1069, 1711, 1084, 583, 577, 1101, 1083, 79, 1082, 1081, + /* 1750 */ 1740, 80, 1711, 281, 1712, 542, 1714, 1715, 538, 57, + /* 1760 */ 559, 254, 1097, 1711, 996, 592, 1020, 595, 1727, 255, + /* 1770 */ 1038, 1013, 1018, 1017, 1016, 1035, 540, 1015, 1014, 1727, + /* 1780 */ 1012, 1681, 1011, 539, 1033, 1008, 1007, 540, 1006, 1003, + /* 1790 */ 1727, 1002, 1681, 1001, 539, 1460, 617, 616, 540, 618, + /* 1800 */ 1458, 620, 621, 1681, 622, 539, 1456, 624, 1740, 625, + /* 1810 */ 626, 283, 1712, 542, 1714, 1715, 538, 1454, 559, 1740, + /* 1820 */ 629, 628, 275, 1712, 542, 1714, 1715, 538, 1711, 559, + /* 1830 */ 1740, 630, 1442, 284, 1712, 542, 1714, 1715, 538, 632, + /* 1840 */ 559, 1427, 634, 635, 1711, 1210, 265, 638, 639, 1402, + /* 1850 */ 1402, 1402, 1402, 1402, 1402, 1727, 1402, 1402, 1402, 1402, + /* 1860 */ 1402, 1402, 1402, 540, 1402, 1402, 1402, 1402, 1681, 1402, + /* 1870 */ 539, 1727, 1402, 1402, 1402, 1402, 1402, 1402, 1402, 540, + /* 1880 */ 1402, 1402, 1402, 1402, 1681, 1402, 539, 1402, 1402, 1402, + /* 1890 */ 1402, 1402, 1402, 1711, 1402, 1740, 1402, 1402, 276, 1712, + /* 1900 */ 542, 1714, 1715, 538, 1402, 559, 1402, 1711, 1402, 1402, + /* 1910 */ 1402, 1740, 1402, 1402, 285, 1712, 542, 1714, 1715, 538, + /* 1920 */ 1727, 559, 1402, 1402, 1402, 1402, 1402, 1402, 540, 1402, + /* 1930 */ 1402, 1402, 1402, 1681, 1727, 539, 1402, 1402, 1402, 1402, + /* 1940 */ 1402, 1402, 540, 1402, 1402, 1402, 1402, 1681, 1711, 539, + /* 1950 */ 1402, 1402, 1402, 1402, 1402, 1402, 1402, 1402, 1402, 1402, + /* 1960 */ 1740, 1402, 1402, 277, 1712, 542, 1714, 1715, 538, 1711, + /* 1970 */ 559, 1402, 1402, 1402, 1740, 1727, 1402, 1723, 1712, 542, + /* 1980 */ 1714, 1715, 538, 540, 559, 1402, 1402, 1402, 1681, 1402, + /* 1990 */ 539, 1402, 1402, 1402, 1402, 1402, 1727, 1402, 1402, 1402, + /* 2000 */ 1402, 1402, 1402, 1402, 540, 1402, 1402, 1402, 1402, 1681, + /* 2010 */ 1402, 539, 1402, 1402, 1402, 1740, 1402, 1402, 1722, 1712, + /* 2020 */ 542, 1714, 1715, 538, 1402, 559, 1402, 1711, 1402, 1402, + /* 2030 */ 1402, 1402, 1402, 1402, 1402, 1402, 1740, 1402, 1711, 1721, + /* 2040 */ 1712, 542, 1714, 1715, 538, 1402, 559, 1402, 1402, 1711, + /* 2050 */ 1402, 1402, 1402, 1402, 1727, 1402, 1402, 1402, 1402, 1402, + /* 2060 */ 1402, 1402, 540, 1402, 1402, 1727, 1402, 1681, 1402, 539, + /* 2070 */ 1402, 1402, 1402, 540, 1402, 1402, 1727, 1402, 1681, 1402, + /* 2080 */ 539, 1402, 1402, 1402, 540, 1402, 1402, 1402, 1402, 1681, + /* 2090 */ 1711, 539, 1402, 1402, 1740, 1402, 1402, 296, 1712, 542, + /* 2100 */ 1714, 1715, 538, 1402, 559, 1740, 1402, 1402, 295, 1712, + /* 2110 */ 542, 1714, 1715, 538, 1711, 559, 1740, 1727, 1402, 297, + /* 2120 */ 1712, 542, 1714, 1715, 538, 540, 559, 1402, 1402, 1402, + /* 2130 */ 1681, 1402, 539, 1402, 1402, 1402, 1402, 1402, 1402, 1402, + /* 2140 */ 1402, 1727, 1402, 1402, 1402, 1402, 1402, 1402, 1402, 540, + /* 2150 */ 1402, 1402, 1402, 1402, 1681, 1402, 539, 1740, 1402, 1402, + /* 2160 */ 294, 1712, 542, 1714, 1715, 538, 1402, 559, 1402, 1402, + /* 2170 */ 1402, 1402, 1402, 1402, 1402, 1402, 1402, 1402, 1402, 1402, + /* 2180 */ 1402, 1740, 1402, 1402, 280, 1712, 542, 1714, 1715, 538, + /* 2190 */ 1402, 559, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 274, 341, 273, 277, 248, 274, 250, 251, 277, 242, @@ -763,71 +763,71 @@ static const short yy_reduce_ofst[] = { /* 260 */ 977, 1005, 1013, 1015, 1014, 1039, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 10 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 20 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 30 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 40 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 50 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 60 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1468, 1399, - /* 70 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 80 */ 1399, 1399, 1399, 1466, 1617, 1399, 1781, 1399, 1399, 1399, - /* 90 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 100 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 110 */ 1399, 1399, 1399, 1468, 1399, 1792, 1792, 1792, 1466, 1399, - /* 120 */ 1399, 1399, 1399, 1399, 1399, 1399, 1562, 1399, 1399, 1399, - /* 130 */ 1399, 1399, 1399, 1399, 1399, 1650, 1399, 1399, 1862, 1399, - /* 140 */ 1399, 1656, 1816, 1399, 1399, 1399, 1399, 1515, 1808, 1784, - /* 150 */ 1798, 1785, 1847, 1847, 1847, 1801, 1399, 1812, 1399, 1399, - /* 160 */ 1399, 1642, 1399, 1399, 1622, 1619, 1619, 1399, 1399, 1399, - /* 170 */ 1399, 1468, 1399, 1468, 1399, 1399, 1468, 1399, 1468, 1399, - /* 180 */ 1399, 1468, 1468, 1399, 1468, 1399, 1399, 1399, 1399, 1399, - /* 190 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 200 */ 1399, 1399, 1466, 1652, 1399, 1466, 1399, 1399, 1466, 1399, - /* 210 */ 1399, 1466, 1399, 1399, 1823, 1821, 1399, 1823, 1821, 1399, - /* 220 */ 1399, 1399, 1835, 1831, 1823, 1839, 1837, 1814, 1812, 1798, - /* 230 */ 1399, 1399, 1399, 1853, 1849, 1865, 1853, 1849, 1853, 1849, - /* 240 */ 1399, 1821, 1399, 1399, 1821, 1399, 1627, 1399, 1399, 1466, - /* 250 */ 1399, 1466, 1399, 1531, 1399, 1399, 1399, 1466, 1399, 1644, - /* 260 */ 1658, 1565, 1565, 1565, 1469, 1404, 1399, 1399, 1399, 1399, - /* 270 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1527, - /* 280 */ 1725, 1834, 1833, 1757, 1756, 1755, 1753, 1724, 1399, 1399, - /* 290 */ 1399, 1399, 1399, 1399, 1718, 1719, 1717, 1716, 1399, 1399, - /* 300 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 310 */ 1399, 1782, 1399, 1850, 1854, 1399, 1399, 1399, 1701, 1399, - /* 320 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 330 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 340 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 350 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 360 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 370 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 380 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 390 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 400 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 410 */ 1399, 1399, 1399, 1433, 1399, 1399, 1399, 1399, 1399, 1399, - /* 420 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 430 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 440 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 450 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 460 */ 1399, 1496, 1495, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 470 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 480 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 490 */ 1399, 1399, 1399, 1399, 1399, 1805, 1815, 1399, 1399, 1399, - /* 500 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 510 */ 1701, 1399, 1832, 1399, 1791, 1787, 1399, 1399, 1783, 1399, - /* 520 */ 1399, 1848, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 530 */ 1399, 1777, 1399, 1750, 1399, 1399, 1399, 1399, 1399, 1399, - /* 540 */ 1399, 1399, 1712, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 550 */ 1399, 1399, 1399, 1399, 1399, 1700, 1399, 1741, 1399, 1399, - /* 560 */ 1399, 1399, 1399, 1399, 1399, 1399, 1559, 1399, 1399, 1399, - /* 570 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1544, - /* 580 */ 1542, 1541, 1540, 1399, 1537, 1399, 1399, 1399, 1399, 1568, - /* 590 */ 1567, 1399, 1399, 1399, 1399, 1399, 1399, 1488, 1399, 1399, - /* 600 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1479, 1399, 1478, - /* 610 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 620 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 630 */ 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, 1399, - /* 640 */ 1399, + /* 0 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 10 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 20 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 30 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 40 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 50 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 60 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1469, 1400, + /* 70 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 80 */ 1400, 1400, 1400, 1467, 1618, 1400, 1782, 1400, 1400, 1400, + /* 90 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 100 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 110 */ 1400, 1400, 1400, 1469, 1400, 1794, 1794, 1794, 1467, 1400, + /* 120 */ 1400, 1400, 1400, 1400, 1400, 1400, 1563, 1400, 1400, 1400, + /* 130 */ 1400, 1400, 1400, 1400, 1400, 1651, 1400, 1400, 1864, 1400, + /* 140 */ 1400, 1657, 1818, 1400, 1400, 1400, 1400, 1516, 1810, 1786, + /* 150 */ 1800, 1787, 1849, 1849, 1849, 1803, 1400, 1814, 1400, 1400, + /* 160 */ 1400, 1643, 1400, 1400, 1623, 1620, 1620, 1400, 1400, 1400, + /* 170 */ 1400, 1469, 1400, 1469, 1400, 1400, 1469, 1400, 1469, 1400, + /* 180 */ 1400, 1469, 1469, 1400, 1469, 1400, 1400, 1400, 1400, 1400, + /* 190 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 200 */ 1400, 1400, 1467, 1653, 1400, 1467, 1400, 1400, 1467, 1400, + /* 210 */ 1400, 1467, 1400, 1400, 1825, 1823, 1400, 1825, 1823, 1400, + /* 220 */ 1400, 1400, 1837, 1833, 1825, 1841, 1839, 1816, 1814, 1800, + /* 230 */ 1400, 1400, 1784, 1855, 1851, 1867, 1855, 1851, 1855, 1851, + /* 240 */ 1400, 1823, 1400, 1400, 1823, 1400, 1628, 1400, 1400, 1467, + /* 250 */ 1400, 1467, 1400, 1532, 1400, 1400, 1400, 1467, 1400, 1645, + /* 260 */ 1659, 1566, 1566, 1566, 1470, 1405, 1400, 1400, 1400, 1400, + /* 270 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1528, + /* 280 */ 1726, 1836, 1835, 1758, 1757, 1756, 1754, 1725, 1400, 1400, + /* 290 */ 1400, 1400, 1400, 1400, 1719, 1720, 1718, 1717, 1400, 1400, + /* 300 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 310 */ 1400, 1783, 1400, 1852, 1856, 1400, 1400, 1400, 1702, 1400, + /* 320 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 330 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 340 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 350 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 360 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 370 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 380 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 390 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 400 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 410 */ 1400, 1400, 1400, 1434, 1400, 1400, 1400, 1400, 1400, 1400, + /* 420 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 430 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 440 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 450 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 460 */ 1400, 1497, 1496, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 470 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 480 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 490 */ 1400, 1400, 1400, 1400, 1400, 1807, 1817, 1400, 1400, 1400, + /* 500 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 510 */ 1702, 1400, 1834, 1400, 1793, 1789, 1400, 1400, 1785, 1400, + /* 520 */ 1400, 1850, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 530 */ 1400, 1778, 1400, 1751, 1400, 1400, 1400, 1400, 1400, 1400, + /* 540 */ 1400, 1400, 1713, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 550 */ 1400, 1400, 1400, 1400, 1400, 1701, 1400, 1742, 1400, 1400, + /* 560 */ 1400, 1400, 1400, 1400, 1400, 1400, 1560, 1400, 1400, 1400, + /* 570 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1545, + /* 580 */ 1543, 1542, 1541, 1400, 1538, 1400, 1400, 1400, 1400, 1569, + /* 590 */ 1568, 1400, 1400, 1400, 1400, 1400, 1400, 1489, 1400, 1400, + /* 600 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1480, 1400, 1479, + /* 610 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 620 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 630 */ 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, 1400, + /* 640 */ 1400, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1508,7 +1508,7 @@ static const char *const yyTokenName[] = { /* 329 */ "boolean_value_expression", /* 330 */ "boolean_primary", /* 331 */ "common_expression", - /* 332 */ "from_clause", + /* 332 */ "from_clause_opt", /* 333 */ "table_reference_list", /* 334 */ "table_reference", /* 335 */ "table_primary", @@ -1928,91 +1928,92 @@ static const char *const yyRuleName[] = { /* 378 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", /* 379 */ "common_expression ::= expression", /* 380 */ "common_expression ::= boolean_value_expression", - /* 381 */ "from_clause ::= FROM table_reference_list", - /* 382 */ "table_reference_list ::= table_reference", - /* 383 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 384 */ "table_reference ::= table_primary", - /* 385 */ "table_reference ::= joined_table", - /* 386 */ "table_primary ::= table_name alias_opt", - /* 387 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 388 */ "table_primary ::= subquery alias_opt", - /* 389 */ "table_primary ::= parenthesized_joined_table", - /* 390 */ "alias_opt ::=", - /* 391 */ "alias_opt ::= table_alias", - /* 392 */ "alias_opt ::= AS table_alias", - /* 393 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 394 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 395 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 396 */ "join_type ::=", - /* 397 */ "join_type ::= INNER", - /* 398 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 399 */ "set_quantifier_opt ::=", - /* 400 */ "set_quantifier_opt ::= DISTINCT", - /* 401 */ "set_quantifier_opt ::= ALL", - /* 402 */ "select_list ::= NK_STAR", - /* 403 */ "select_list ::= select_sublist", - /* 404 */ "select_sublist ::= select_item", - /* 405 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 406 */ "select_item ::= common_expression", - /* 407 */ "select_item ::= common_expression column_alias", - /* 408 */ "select_item ::= common_expression AS column_alias", - /* 409 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 410 */ "where_clause_opt ::=", - /* 411 */ "where_clause_opt ::= WHERE search_condition", - /* 412 */ "partition_by_clause_opt ::=", - /* 413 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 414 */ "twindow_clause_opt ::=", - /* 415 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 416 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", - /* 417 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 418 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 419 */ "sliding_opt ::=", - /* 420 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 421 */ "fill_opt ::=", - /* 422 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 423 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 424 */ "fill_mode ::= NONE", - /* 425 */ "fill_mode ::= PREV", - /* 426 */ "fill_mode ::= NULL", - /* 427 */ "fill_mode ::= LINEAR", - /* 428 */ "fill_mode ::= NEXT", - /* 429 */ "group_by_clause_opt ::=", - /* 430 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 431 */ "group_by_list ::= expression", - /* 432 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 433 */ "having_clause_opt ::=", - /* 434 */ "having_clause_opt ::= HAVING search_condition", - /* 435 */ "range_opt ::=", - /* 436 */ "range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP", - /* 437 */ "every_opt ::=", - /* 438 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 439 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 440 */ "query_expression_body ::= query_primary", - /* 441 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 442 */ "query_expression_body ::= query_expression_body UNION query_expression_body", - /* 443 */ "query_primary ::= query_specification", - /* 444 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", - /* 445 */ "order_by_clause_opt ::=", - /* 446 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 447 */ "slimit_clause_opt ::=", - /* 448 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 449 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 450 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 451 */ "limit_clause_opt ::=", - /* 452 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 453 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 454 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 455 */ "subquery ::= NK_LP query_expression NK_RP", - /* 456 */ "search_condition ::= common_expression", - /* 457 */ "sort_specification_list ::= sort_specification", - /* 458 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 459 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 460 */ "ordering_specification_opt ::=", - /* 461 */ "ordering_specification_opt ::= ASC", - /* 462 */ "ordering_specification_opt ::= DESC", - /* 463 */ "null_ordering_opt ::=", - /* 464 */ "null_ordering_opt ::= NULLS FIRST", - /* 465 */ "null_ordering_opt ::= NULLS LAST", + /* 381 */ "from_clause_opt ::=", + /* 382 */ "from_clause_opt ::= FROM table_reference_list", + /* 383 */ "table_reference_list ::= table_reference", + /* 384 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 385 */ "table_reference ::= table_primary", + /* 386 */ "table_reference ::= joined_table", + /* 387 */ "table_primary ::= table_name alias_opt", + /* 388 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 389 */ "table_primary ::= subquery alias_opt", + /* 390 */ "table_primary ::= parenthesized_joined_table", + /* 391 */ "alias_opt ::=", + /* 392 */ "alias_opt ::= table_alias", + /* 393 */ "alias_opt ::= AS table_alias", + /* 394 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 395 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 396 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 397 */ "join_type ::=", + /* 398 */ "join_type ::= INNER", + /* 399 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 400 */ "set_quantifier_opt ::=", + /* 401 */ "set_quantifier_opt ::= DISTINCT", + /* 402 */ "set_quantifier_opt ::= ALL", + /* 403 */ "select_list ::= NK_STAR", + /* 404 */ "select_list ::= select_sublist", + /* 405 */ "select_sublist ::= select_item", + /* 406 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 407 */ "select_item ::= common_expression", + /* 408 */ "select_item ::= common_expression column_alias", + /* 409 */ "select_item ::= common_expression AS column_alias", + /* 410 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 411 */ "where_clause_opt ::=", + /* 412 */ "where_clause_opt ::= WHERE search_condition", + /* 413 */ "partition_by_clause_opt ::=", + /* 414 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 415 */ "twindow_clause_opt ::=", + /* 416 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 417 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP", + /* 418 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 419 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 420 */ "sliding_opt ::=", + /* 421 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 422 */ "fill_opt ::=", + /* 423 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 424 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 425 */ "fill_mode ::= NONE", + /* 426 */ "fill_mode ::= PREV", + /* 427 */ "fill_mode ::= NULL", + /* 428 */ "fill_mode ::= LINEAR", + /* 429 */ "fill_mode ::= NEXT", + /* 430 */ "group_by_clause_opt ::=", + /* 431 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 432 */ "group_by_list ::= expression", + /* 433 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 434 */ "having_clause_opt ::=", + /* 435 */ "having_clause_opt ::= HAVING search_condition", + /* 436 */ "range_opt ::=", + /* 437 */ "range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP", + /* 438 */ "every_opt ::=", + /* 439 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 440 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 441 */ "query_expression_body ::= query_primary", + /* 442 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 443 */ "query_expression_body ::= query_expression_body UNION query_expression_body", + /* 444 */ "query_primary ::= query_specification", + /* 445 */ "query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP", + /* 446 */ "order_by_clause_opt ::=", + /* 447 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 448 */ "slimit_clause_opt ::=", + /* 449 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 450 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 451 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 452 */ "limit_clause_opt ::=", + /* 453 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 454 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 455 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 456 */ "subquery ::= NK_LP query_expression NK_RP", + /* 457 */ "search_condition ::= common_expression", + /* 458 */ "sort_specification_list ::= sort_specification", + /* 459 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 460 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 461 */ "ordering_specification_opt ::=", + /* 462 */ "ordering_specification_opt ::= ASC", + /* 463 */ "ordering_specification_opt ::= DESC", + /* 464 */ "null_ordering_opt ::=", + /* 465 */ "null_ordering_opt ::= NULLS FIRST", + /* 466 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -2180,7 +2181,7 @@ static void yy_destructor( case 329: /* boolean_value_expression */ case 330: /* boolean_primary */ case 331: /* common_expression */ - case 332: /* from_clause */ + case 332: /* from_clause_opt */ case 333: /* table_reference_list */ case 334: /* table_reference */ case 335: /* table_primary */ @@ -2988,91 +2989,92 @@ static const struct { { 330, -3 }, /* (378) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ { 331, -1 }, /* (379) common_expression ::= expression */ { 331, -1 }, /* (380) common_expression ::= boolean_value_expression */ - { 332, -2 }, /* (381) from_clause ::= FROM table_reference_list */ - { 333, -1 }, /* (382) table_reference_list ::= table_reference */ - { 333, -3 }, /* (383) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 334, -1 }, /* (384) table_reference ::= table_primary */ - { 334, -1 }, /* (385) table_reference ::= joined_table */ - { 335, -2 }, /* (386) table_primary ::= table_name alias_opt */ - { 335, -4 }, /* (387) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 335, -2 }, /* (388) table_primary ::= subquery alias_opt */ - { 335, -1 }, /* (389) table_primary ::= parenthesized_joined_table */ - { 337, 0 }, /* (390) alias_opt ::= */ - { 337, -1 }, /* (391) alias_opt ::= table_alias */ - { 337, -2 }, /* (392) alias_opt ::= AS table_alias */ - { 338, -3 }, /* (393) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 338, -3 }, /* (394) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 336, -6 }, /* (395) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 339, 0 }, /* (396) join_type ::= */ - { 339, -1 }, /* (397) join_type ::= INNER */ - { 341, -12 }, /* (398) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - { 342, 0 }, /* (399) set_quantifier_opt ::= */ - { 342, -1 }, /* (400) set_quantifier_opt ::= DISTINCT */ - { 342, -1 }, /* (401) set_quantifier_opt ::= ALL */ - { 343, -1 }, /* (402) select_list ::= NK_STAR */ - { 343, -1 }, /* (403) select_list ::= select_sublist */ - { 351, -1 }, /* (404) select_sublist ::= select_item */ - { 351, -3 }, /* (405) select_sublist ::= select_sublist NK_COMMA select_item */ - { 352, -1 }, /* (406) select_item ::= common_expression */ - { 352, -2 }, /* (407) select_item ::= common_expression column_alias */ - { 352, -3 }, /* (408) select_item ::= common_expression AS column_alias */ - { 352, -3 }, /* (409) select_item ::= table_name NK_DOT NK_STAR */ - { 310, 0 }, /* (410) where_clause_opt ::= */ - { 310, -2 }, /* (411) where_clause_opt ::= WHERE search_condition */ - { 344, 0 }, /* (412) partition_by_clause_opt ::= */ - { 344, -3 }, /* (413) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 348, 0 }, /* (414) twindow_clause_opt ::= */ - { 348, -6 }, /* (415) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 348, -4 }, /* (416) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ - { 348, -6 }, /* (417) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 348, -8 }, /* (418) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 296, 0 }, /* (419) sliding_opt ::= */ - { 296, -4 }, /* (420) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 347, 0 }, /* (421) fill_opt ::= */ - { 347, -4 }, /* (422) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 347, -6 }, /* (423) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 353, -1 }, /* (424) fill_mode ::= NONE */ - { 353, -1 }, /* (425) fill_mode ::= PREV */ - { 353, -1 }, /* (426) fill_mode ::= NULL */ - { 353, -1 }, /* (427) fill_mode ::= LINEAR */ - { 353, -1 }, /* (428) fill_mode ::= NEXT */ - { 349, 0 }, /* (429) group_by_clause_opt ::= */ - { 349, -3 }, /* (430) group_by_clause_opt ::= GROUP BY group_by_list */ - { 354, -1 }, /* (431) group_by_list ::= expression */ - { 354, -3 }, /* (432) group_by_list ::= group_by_list NK_COMMA expression */ - { 350, 0 }, /* (433) having_clause_opt ::= */ - { 350, -2 }, /* (434) having_clause_opt ::= HAVING search_condition */ - { 345, 0 }, /* (435) range_opt ::= */ - { 345, -6 }, /* (436) range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ - { 346, 0 }, /* (437) every_opt ::= */ - { 346, -4 }, /* (438) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - { 300, -4 }, /* (439) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 355, -1 }, /* (440) query_expression_body ::= query_primary */ - { 355, -4 }, /* (441) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 355, -3 }, /* (442) query_expression_body ::= query_expression_body UNION query_expression_body */ - { 359, -1 }, /* (443) query_primary ::= query_specification */ - { 359, -6 }, /* (444) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ - { 356, 0 }, /* (445) order_by_clause_opt ::= */ - { 356, -3 }, /* (446) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 357, 0 }, /* (447) slimit_clause_opt ::= */ - { 357, -2 }, /* (448) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 357, -4 }, /* (449) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 357, -4 }, /* (450) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 358, 0 }, /* (451) limit_clause_opt ::= */ - { 358, -2 }, /* (452) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 358, -4 }, /* (453) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 358, -4 }, /* (454) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 319, -3 }, /* (455) subquery ::= NK_LP query_expression NK_RP */ - { 340, -1 }, /* (456) search_condition ::= common_expression */ - { 360, -1 }, /* (457) sort_specification_list ::= sort_specification */ - { 360, -3 }, /* (458) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 361, -3 }, /* (459) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 362, 0 }, /* (460) ordering_specification_opt ::= */ - { 362, -1 }, /* (461) ordering_specification_opt ::= ASC */ - { 362, -1 }, /* (462) ordering_specification_opt ::= DESC */ - { 363, 0 }, /* (463) null_ordering_opt ::= */ - { 363, -2 }, /* (464) null_ordering_opt ::= NULLS FIRST */ - { 363, -2 }, /* (465) null_ordering_opt ::= NULLS LAST */ + { 332, 0 }, /* (381) from_clause_opt ::= */ + { 332, -2 }, /* (382) from_clause_opt ::= FROM table_reference_list */ + { 333, -1 }, /* (383) table_reference_list ::= table_reference */ + { 333, -3 }, /* (384) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 334, -1 }, /* (385) table_reference ::= table_primary */ + { 334, -1 }, /* (386) table_reference ::= joined_table */ + { 335, -2 }, /* (387) table_primary ::= table_name alias_opt */ + { 335, -4 }, /* (388) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 335, -2 }, /* (389) table_primary ::= subquery alias_opt */ + { 335, -1 }, /* (390) table_primary ::= parenthesized_joined_table */ + { 337, 0 }, /* (391) alias_opt ::= */ + { 337, -1 }, /* (392) alias_opt ::= table_alias */ + { 337, -2 }, /* (393) alias_opt ::= AS table_alias */ + { 338, -3 }, /* (394) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 338, -3 }, /* (395) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 336, -6 }, /* (396) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 339, 0 }, /* (397) join_type ::= */ + { 339, -1 }, /* (398) join_type ::= INNER */ + { 341, -12 }, /* (399) query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + { 342, 0 }, /* (400) set_quantifier_opt ::= */ + { 342, -1 }, /* (401) set_quantifier_opt ::= DISTINCT */ + { 342, -1 }, /* (402) set_quantifier_opt ::= ALL */ + { 343, -1 }, /* (403) select_list ::= NK_STAR */ + { 343, -1 }, /* (404) select_list ::= select_sublist */ + { 351, -1 }, /* (405) select_sublist ::= select_item */ + { 351, -3 }, /* (406) select_sublist ::= select_sublist NK_COMMA select_item */ + { 352, -1 }, /* (407) select_item ::= common_expression */ + { 352, -2 }, /* (408) select_item ::= common_expression column_alias */ + { 352, -3 }, /* (409) select_item ::= common_expression AS column_alias */ + { 352, -3 }, /* (410) select_item ::= table_name NK_DOT NK_STAR */ + { 310, 0 }, /* (411) where_clause_opt ::= */ + { 310, -2 }, /* (412) where_clause_opt ::= WHERE search_condition */ + { 344, 0 }, /* (413) partition_by_clause_opt ::= */ + { 344, -3 }, /* (414) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 348, 0 }, /* (415) twindow_clause_opt ::= */ + { 348, -6 }, /* (416) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 348, -4 }, /* (417) twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ + { 348, -6 }, /* (418) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 348, -8 }, /* (419) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 296, 0 }, /* (420) sliding_opt ::= */ + { 296, -4 }, /* (421) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 347, 0 }, /* (422) fill_opt ::= */ + { 347, -4 }, /* (423) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 347, -6 }, /* (424) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 353, -1 }, /* (425) fill_mode ::= NONE */ + { 353, -1 }, /* (426) fill_mode ::= PREV */ + { 353, -1 }, /* (427) fill_mode ::= NULL */ + { 353, -1 }, /* (428) fill_mode ::= LINEAR */ + { 353, -1 }, /* (429) fill_mode ::= NEXT */ + { 349, 0 }, /* (430) group_by_clause_opt ::= */ + { 349, -3 }, /* (431) group_by_clause_opt ::= GROUP BY group_by_list */ + { 354, -1 }, /* (432) group_by_list ::= expression */ + { 354, -3 }, /* (433) group_by_list ::= group_by_list NK_COMMA expression */ + { 350, 0 }, /* (434) having_clause_opt ::= */ + { 350, -2 }, /* (435) having_clause_opt ::= HAVING search_condition */ + { 345, 0 }, /* (436) range_opt ::= */ + { 345, -6 }, /* (437) range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ + { 346, 0 }, /* (438) every_opt ::= */ + { 346, -4 }, /* (439) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + { 300, -4 }, /* (440) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 355, -1 }, /* (441) query_expression_body ::= query_primary */ + { 355, -4 }, /* (442) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 355, -3 }, /* (443) query_expression_body ::= query_expression_body UNION query_expression_body */ + { 359, -1 }, /* (444) query_primary ::= query_specification */ + { 359, -6 }, /* (445) query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ + { 356, 0 }, /* (446) order_by_clause_opt ::= */ + { 356, -3 }, /* (447) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 357, 0 }, /* (448) slimit_clause_opt ::= */ + { 357, -2 }, /* (449) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 357, -4 }, /* (450) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 357, -4 }, /* (451) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 358, 0 }, /* (452) limit_clause_opt ::= */ + { 358, -2 }, /* (453) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 358, -4 }, /* (454) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 358, -4 }, /* (455) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 319, -3 }, /* (456) subquery ::= NK_LP query_expression NK_RP */ + { 340, -1 }, /* (457) search_condition ::= common_expression */ + { 360, -1 }, /* (458) sort_specification_list ::= sort_specification */ + { 360, -3 }, /* (459) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 361, -3 }, /* (460) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 362, 0 }, /* (461) ordering_specification_opt ::= */ + { 362, -1 }, /* (462) ordering_specification_opt ::= ASC */ + { 362, -1 }, /* (463) ordering_specification_opt ::= DESC */ + { 363, 0 }, /* (464) null_ordering_opt ::= */ + { 363, -2 }, /* (465) null_ordering_opt ::= NULLS FIRST */ + { 363, -2 }, /* (466) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -3349,7 +3351,7 @@ static YYACTIONTYPE yy_reduce( case 66: /* exists_opt ::= */ yytestcase(yyruleno==66); case 240: /* analyze_opt ::= */ yytestcase(yyruleno==240); case 248: /* agg_func_opt ::= */ yytestcase(yyruleno==248); - case 399: /* set_quantifier_opt ::= */ yytestcase(yyruleno==399); + case 400: /* set_quantifier_opt ::= */ yytestcase(yyruleno==400); { yymsp[1].minor.yy481 = false; } break; case 65: /* exists_opt ::= IF EXISTS */ @@ -3491,8 +3493,8 @@ static YYACTIONTYPE yy_reduce( case 228: /* func_list ::= func */ yytestcase(yyruleno==228); case 295: /* literal_list ::= signed_literal */ yytestcase(yyruleno==295); case 349: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==349); - case 404: /* select_sublist ::= select_item */ yytestcase(yyruleno==404); - case 457: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==457); + case 405: /* select_sublist ::= select_item */ yytestcase(yyruleno==405); + case 458: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==458); { yylhsminor.yy600 = createNodeList(pCxt, yymsp[0].minor.yy392); } yymsp[0].minor.yy600 = yylhsminor.yy600; break; @@ -3503,8 +3505,8 @@ static YYACTIONTYPE yy_reduce( case 229: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==229); case 296: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==296); case 350: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==350); - case 405: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==405); - case 458: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==458); + case 406: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==406); + case 459: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==459); { yylhsminor.yy600 = addNodeToList(pCxt, yymsp[-2].minor.yy600, yymsp[0].minor.yy392); } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; @@ -3585,9 +3587,9 @@ static YYACTIONTYPE yy_reduce( break; case 129: /* specific_tags_opt ::= */ case 160: /* tags_def_opt ::= */ yytestcase(yyruleno==160); - case 412: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==412); - case 429: /* group_by_clause_opt ::= */ yytestcase(yyruleno==429); - case 445: /* order_by_clause_opt ::= */ yytestcase(yyruleno==445); + case 413: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==413); + case 430: /* group_by_clause_opt ::= */ yytestcase(yyruleno==430); + case 446: /* order_by_clause_opt ::= */ yytestcase(yyruleno==446); { yymsp[1].minor.yy600 = NULL; } break; case 130: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ @@ -3678,7 +3680,7 @@ static YYACTIONTYPE yy_reduce( break; case 161: /* tags_def_opt ::= tags_def */ case 348: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==348); - case 403: /* select_list ::= select_sublist */ yytestcase(yyruleno==403); + case 404: /* select_list ::= select_sublist */ yytestcase(yyruleno==404); { yylhsminor.yy600 = yymsp[0].minor.yy600; } yymsp[0].minor.yy600 = yylhsminor.yy600; break; @@ -3851,15 +3853,16 @@ static YYACTIONTYPE yy_reduce( case 217: /* like_pattern_opt ::= */ case 225: /* index_options ::= */ yytestcase(yyruleno==225); case 254: /* into_opt ::= */ yytestcase(yyruleno==254); - case 410: /* where_clause_opt ::= */ yytestcase(yyruleno==410); - case 414: /* twindow_clause_opt ::= */ yytestcase(yyruleno==414); - case 419: /* sliding_opt ::= */ yytestcase(yyruleno==419); - case 421: /* fill_opt ::= */ yytestcase(yyruleno==421); - case 433: /* having_clause_opt ::= */ yytestcase(yyruleno==433); - case 435: /* range_opt ::= */ yytestcase(yyruleno==435); - case 437: /* every_opt ::= */ yytestcase(yyruleno==437); - case 447: /* slimit_clause_opt ::= */ yytestcase(yyruleno==447); - case 451: /* limit_clause_opt ::= */ yytestcase(yyruleno==451); + case 381: /* from_clause_opt ::= */ yytestcase(yyruleno==381); + case 411: /* where_clause_opt ::= */ yytestcase(yyruleno==411); + case 415: /* twindow_clause_opt ::= */ yytestcase(yyruleno==415); + case 420: /* sliding_opt ::= */ yytestcase(yyruleno==420); + case 422: /* fill_opt ::= */ yytestcase(yyruleno==422); + case 434: /* having_clause_opt ::= */ yytestcase(yyruleno==434); + case 436: /* range_opt ::= */ yytestcase(yyruleno==436); + case 438: /* every_opt ::= */ yytestcase(yyruleno==438); + case 448: /* slimit_clause_opt ::= */ yytestcase(yyruleno==448); + case 452: /* limit_clause_opt ::= */ yytestcase(yyruleno==452); { yymsp[1].minor.yy392 = NULL; } break; case 218: /* like_pattern_opt ::= LIKE NK_STRING */ @@ -3918,7 +3921,7 @@ static YYACTIONTYPE yy_reduce( break; case 241: /* analyze_opt ::= ANALYZE */ case 249: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==249); - case 400: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==400); + case 401: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==401); { yymsp[0].minor.yy481 = true; } break; case 242: /* explain_options ::= */ @@ -3954,9 +3957,9 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy481, &yymsp[0].minor.yy57); } break; case 255: /* into_opt ::= INTO full_table_name */ - case 381: /* from_clause ::= FROM table_reference_list */ yytestcase(yyruleno==381); - case 411: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==411); - case 434: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==434); + case 382: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==382); + case 412: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==412); + case 435: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==435); { yymsp[-1].minor.yy392 = yymsp[0].minor.yy392; } break; case 256: /* stream_options ::= */ @@ -4040,12 +4043,12 @@ static YYACTIONTYPE yy_reduce( case 377: /* boolean_primary ::= predicate */ yytestcase(yyruleno==377); case 379: /* common_expression ::= expression */ yytestcase(yyruleno==379); case 380: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==380); - case 382: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==382); - case 384: /* table_reference ::= table_primary */ yytestcase(yyruleno==384); - case 385: /* table_reference ::= joined_table */ yytestcase(yyruleno==385); - case 389: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==389); - case 440: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==440); - case 443: /* query_primary ::= query_specification */ yytestcase(yyruleno==443); + case 383: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==383); + case 385: /* table_reference ::= table_primary */ yytestcase(yyruleno==385); + case 386: /* table_reference ::= joined_table */ yytestcase(yyruleno==386); + case 390: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==390); + case 441: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==441); + case 444: /* query_primary ::= query_specification */ yytestcase(yyruleno==444); { yylhsminor.yy392 = yymsp[0].minor.yy392; } yymsp[0].minor.yy392 = yylhsminor.yy392; break; @@ -4105,8 +4108,8 @@ static YYACTIONTYPE yy_reduce( case 292: /* signed_literal ::= duration_literal */ case 294: /* signed_literal ::= literal_func */ yytestcase(yyruleno==294); case 351: /* star_func_para ::= expression */ yytestcase(yyruleno==351); - case 406: /* select_item ::= common_expression */ yytestcase(yyruleno==406); - case 456: /* search_condition ::= common_expression */ yytestcase(yyruleno==456); + case 407: /* select_item ::= common_expression */ yytestcase(yyruleno==407); + case 457: /* search_condition ::= common_expression */ yytestcase(yyruleno==457); { yylhsminor.yy392 = releaseRawExprNode(pCxt, yymsp[0].minor.yy392); } yymsp[0].minor.yy392 = yylhsminor.yy392; break; @@ -4221,7 +4224,7 @@ static YYACTIONTYPE yy_reduce( yymsp[0].minor.yy600 = yylhsminor.yy600; break; case 352: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 409: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==409); + case 410: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==410); { yylhsminor.yy392 = createColumnNode(pCxt, &yymsp[-2].minor.yy57, &yymsp[0].minor.yy0); } yymsp[-2].minor.yy392 = yylhsminor.yy392; break; @@ -4330,47 +4333,47 @@ static YYACTIONTYPE yy_reduce( } yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 383: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ + case 384: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ { yylhsminor.yy392 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy392, yymsp[0].minor.yy392, NULL); } yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 386: /* table_primary ::= table_name alias_opt */ + case 387: /* table_primary ::= table_name alias_opt */ { yylhsminor.yy392 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy57, &yymsp[0].minor.yy57); } yymsp[-1].minor.yy392 = yylhsminor.yy392; break; - case 387: /* table_primary ::= db_name NK_DOT table_name alias_opt */ + case 388: /* table_primary ::= db_name NK_DOT table_name alias_opt */ { yylhsminor.yy392 = createRealTableNode(pCxt, &yymsp[-3].minor.yy57, &yymsp[-1].minor.yy57, &yymsp[0].minor.yy57); } yymsp[-3].minor.yy392 = yylhsminor.yy392; break; - case 388: /* table_primary ::= subquery alias_opt */ + case 389: /* table_primary ::= subquery alias_opt */ { yylhsminor.yy392 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy392), &yymsp[0].minor.yy57); } yymsp[-1].minor.yy392 = yylhsminor.yy392; break; - case 390: /* alias_opt ::= */ + case 391: /* alias_opt ::= */ { yymsp[1].minor.yy57 = nil_token; } break; - case 391: /* alias_opt ::= table_alias */ + case 392: /* alias_opt ::= table_alias */ { yylhsminor.yy57 = yymsp[0].minor.yy57; } yymsp[0].minor.yy57 = yylhsminor.yy57; break; - case 392: /* alias_opt ::= AS table_alias */ + case 393: /* alias_opt ::= AS table_alias */ { yymsp[-1].minor.yy57 = yymsp[0].minor.yy57; } break; - case 393: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 394: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==394); + case 394: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 395: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==395); { yymsp[-2].minor.yy392 = yymsp[-1].minor.yy392; } break; - case 395: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + case 396: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ { yylhsminor.yy392 = createJoinTableNode(pCxt, yymsp[-4].minor.yy204, yymsp[-5].minor.yy392, yymsp[-2].minor.yy392, yymsp[0].minor.yy392); } yymsp[-5].minor.yy392 = yylhsminor.yy392; break; - case 396: /* join_type ::= */ + case 397: /* join_type ::= */ { yymsp[1].minor.yy204 = JOIN_TYPE_INNER; } break; - case 397: /* join_type ::= INNER */ + case 398: /* join_type ::= INNER */ { yymsp[0].minor.yy204 = JOIN_TYPE_INNER; } break; - case 398: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 399: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { yymsp[-11].minor.yy392 = createSelectStmt(pCxt, yymsp[-10].minor.yy481, yymsp[-9].minor.yy600, yymsp[-8].minor.yy392); yymsp[-11].minor.yy392 = addWhereClause(pCxt, yymsp[-11].minor.yy392, yymsp[-7].minor.yy392); @@ -4383,74 +4386,74 @@ static YYACTIONTYPE yy_reduce( yymsp[-11].minor.yy392 = addFillClause(pCxt, yymsp[-11].minor.yy392, yymsp[-3].minor.yy392); } break; - case 401: /* set_quantifier_opt ::= ALL */ + case 402: /* set_quantifier_opt ::= ALL */ { yymsp[0].minor.yy481 = false; } break; - case 402: /* select_list ::= NK_STAR */ + case 403: /* select_list ::= NK_STAR */ { yymsp[0].minor.yy600 = NULL; } break; - case 407: /* select_item ::= common_expression column_alias */ + case 408: /* select_item ::= common_expression column_alias */ { yylhsminor.yy392 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy392), &yymsp[0].minor.yy57); } yymsp[-1].minor.yy392 = yylhsminor.yy392; break; - case 408: /* select_item ::= common_expression AS column_alias */ + case 409: /* select_item ::= common_expression AS column_alias */ { yylhsminor.yy392 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), &yymsp[0].minor.yy57); } yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 413: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 430: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==430); - case 446: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==446); + case 414: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 431: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==431); + case 447: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==447); { yymsp[-2].minor.yy600 = yymsp[0].minor.yy600; } break; - case 415: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + case 416: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ { yymsp[-5].minor.yy392 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy392), releaseRawExprNode(pCxt, yymsp[-1].minor.yy392)); } break; - case 416: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ + case 417: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expression NK_RP */ { yymsp[-3].minor.yy392 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy392)); } break; - case 417: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + case 418: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ { yymsp[-5].minor.yy392 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy392), NULL, yymsp[-1].minor.yy392, yymsp[0].minor.yy392); } break; - case 418: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + case 419: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ { yymsp[-7].minor.yy392 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy392), releaseRawExprNode(pCxt, yymsp[-3].minor.yy392), yymsp[-1].minor.yy392, yymsp[0].minor.yy392); } break; - case 420: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - case 438: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==438); + case 421: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + case 439: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==439); { yymsp[-3].minor.yy392 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy392); } break; - case 422: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ + case 423: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ { yymsp[-3].minor.yy392 = createFillNode(pCxt, yymsp[-1].minor.yy270, NULL); } break; - case 423: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + case 424: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ { yymsp[-5].minor.yy392 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy600)); } break; - case 424: /* fill_mode ::= NONE */ + case 425: /* fill_mode ::= NONE */ { yymsp[0].minor.yy270 = FILL_MODE_NONE; } break; - case 425: /* fill_mode ::= PREV */ + case 426: /* fill_mode ::= PREV */ { yymsp[0].minor.yy270 = FILL_MODE_PREV; } break; - case 426: /* fill_mode ::= NULL */ + case 427: /* fill_mode ::= NULL */ { yymsp[0].minor.yy270 = FILL_MODE_NULL; } break; - case 427: /* fill_mode ::= LINEAR */ + case 428: /* fill_mode ::= LINEAR */ { yymsp[0].minor.yy270 = FILL_MODE_LINEAR; } break; - case 428: /* fill_mode ::= NEXT */ + case 429: /* fill_mode ::= NEXT */ { yymsp[0].minor.yy270 = FILL_MODE_NEXT; } break; - case 431: /* group_by_list ::= expression */ + case 432: /* group_by_list ::= expression */ { yylhsminor.yy600 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy392))); } yymsp[0].minor.yy600 = yylhsminor.yy600; break; - case 432: /* group_by_list ::= group_by_list NK_COMMA expression */ + case 433: /* group_by_list ::= group_by_list NK_COMMA expression */ { yylhsminor.yy600 = addNodeToList(pCxt, yymsp[-2].minor.yy600, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy392))); } yymsp[-2].minor.yy600 = yylhsminor.yy600; break; - case 436: /* range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ + case 437: /* range_opt ::= RANGE NK_LP expression NK_COMMA expression NK_RP */ { yymsp[-5].minor.yy392 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy392), releaseRawExprNode(pCxt, yymsp[-1].minor.yy392)); } break; - case 439: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 440: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { yylhsminor.yy392 = addOrderByClause(pCxt, yymsp[-3].minor.yy392, yymsp[-2].minor.yy600); yylhsminor.yy392 = addSlimitClause(pCxt, yylhsminor.yy392, yymsp[-1].minor.yy392); @@ -4458,56 +4461,56 @@ static YYACTIONTYPE yy_reduce( } yymsp[-3].minor.yy392 = yylhsminor.yy392; break; - case 441: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + case 442: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ { yylhsminor.yy392 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy392, yymsp[0].minor.yy392); } yymsp[-3].minor.yy392 = yylhsminor.yy392; break; - case 442: /* query_expression_body ::= query_expression_body UNION query_expression_body */ + case 443: /* query_expression_body ::= query_expression_body UNION query_expression_body */ { yylhsminor.yy392 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy392, yymsp[0].minor.yy392); } yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 444: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ + case 445: /* query_primary ::= NK_LP query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt NK_RP */ { yymsp[-5].minor.yy392 = yymsp[-4].minor.yy392; } yy_destructor(yypParser,356,&yymsp[-3].minor); yy_destructor(yypParser,357,&yymsp[-2].minor); yy_destructor(yypParser,358,&yymsp[-1].minor); break; - case 448: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 452: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==452); + case 449: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 453: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==453); { yymsp[-1].minor.yy392 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 449: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 453: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==453); + case 450: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 454: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==454); { yymsp[-3].minor.yy392 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 450: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 454: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==454); + case 451: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 455: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==455); { yymsp[-3].minor.yy392 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 455: /* subquery ::= NK_LP query_expression NK_RP */ + case 456: /* subquery ::= NK_LP query_expression NK_RP */ { yylhsminor.yy392 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy392); } yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 459: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + case 460: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ { yylhsminor.yy392 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy392), yymsp[-1].minor.yy162, yymsp[0].minor.yy529); } yymsp[-2].minor.yy392 = yylhsminor.yy392; break; - case 460: /* ordering_specification_opt ::= */ + case 461: /* ordering_specification_opt ::= */ { yymsp[1].minor.yy162 = ORDER_ASC; } break; - case 461: /* ordering_specification_opt ::= ASC */ + case 462: /* ordering_specification_opt ::= ASC */ { yymsp[0].minor.yy162 = ORDER_ASC; } break; - case 462: /* ordering_specification_opt ::= DESC */ + case 463: /* ordering_specification_opt ::= DESC */ { yymsp[0].minor.yy162 = ORDER_DESC; } break; - case 463: /* null_ordering_opt ::= */ + case 464: /* null_ordering_opt ::= */ { yymsp[1].minor.yy529 = NULL_ORDER_DEFAULT; } break; - case 464: /* null_ordering_opt ::= NULLS FIRST */ + case 465: /* null_ordering_opt ::= NULLS FIRST */ { yymsp[-1].minor.yy529 = NULL_ORDER_FIRST; } break; - case 465: /* null_ordering_opt ::= NULLS LAST */ + case 466: /* null_ordering_opt ::= NULLS LAST */ { yymsp[-1].minor.yy529 = NULL_ORDER_LAST; } break; default: diff --git a/source/libs/parser/test/parSelectTest.cpp b/source/libs/parser/test/parSelectTest.cpp index 11e09cd83d..e7ab1cb61b 100644 --- a/source/libs/parser/test/parSelectTest.cpp +++ b/source/libs/parser/test/parSelectTest.cpp @@ -388,4 +388,10 @@ TEST_F(ParserSelectTest, informationSchema) { run("SELECT * FROM information_schema.user_databases WHERE name = 'information_schema'"); } +TEST_F(ParserSelectTest, withoutFrom) { + useDb("root", "test"); + + run("SELECT 1"); +} + } // namespace ParserTest diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 7e95cb8b7e..eafc6ba37a 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -901,7 +901,12 @@ static int32_t createDistinctLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSe return code; } -static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { +static int32_t createSelectWithoutFromLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, + SLogicNode** pLogicNode) { + return createProjectLogicNode(pCxt, pSelect, pLogicNode); +} + +static int32_t createSelectFromLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { SLogicNode* pRoot = NULL; int32_t code = createLogicNodeByTable(pCxt, pSelect, pSelect->pFromTable, &pRoot); if (TSDB_CODE_SUCCESS == code) { @@ -941,6 +946,14 @@ static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSele return code; } +static int32_t createSelectLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect, SLogicNode** pLogicNode) { + if (NULL == pSelect->pFromTable) { + return createSelectWithoutFromLogicNode(pCxt, pSelect, pLogicNode); + } else { + return createSelectFromLogicNode(pCxt, pSelect, pLogicNode); + } +} + static int32_t createSetOpRootLogicNode(SLogicPlanContext* pCxt, SSetOperator* pSetOperator, FCreateSetOpLogicNode func, SLogicNode** pRoot) { return createRootLogicNode(pCxt, pSetOperator, pSetOperator->precision, (FCreateLogicNode)func, pRoot); diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index d74d6230fc..3155828f32 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -293,16 +293,22 @@ static int32_t cpdCondAppend(SNode** pCond, SNode** pAdditionalCond) { return code; } -static int32_t cpdCalcTimeRange(SScanLogicNode* pScan, SNode** pPrimaryKeyCond, SNode** pOtherCond) { - bool isStrict = false; - int32_t code = filterGetTimeRange(*pPrimaryKeyCond, &pScan->scanRange, &isStrict); - if (TSDB_CODE_SUCCESS == code) { - if (isStrict) { - nodesDestroyNode(*pPrimaryKeyCond); - } else { - code = cpdCondAppend(pOtherCond, pPrimaryKeyCond); +static int32_t cpdCalcTimeRange(SOptimizeContext* pCxt, SScanLogicNode* pScan, SNode** pPrimaryKeyCond, + SNode** pOtherCond) { + int32_t code = TSDB_CODE_SUCCESS; + if (pCxt->pPlanCxt->topicQuery || pCxt->pPlanCxt->streamQuery) { + code = cpdCondAppend(pOtherCond, pPrimaryKeyCond); + } else { + bool isStrict = false; + code = filterGetTimeRange(*pPrimaryKeyCond, &pScan->scanRange, &isStrict); + if (TSDB_CODE_SUCCESS == code) { + if (isStrict) { + nodesDestroyNode(*pPrimaryKeyCond); + } else { + code = cpdCondAppend(pOtherCond, pPrimaryKeyCond); + } + *pPrimaryKeyCond = NULL; } - *pPrimaryKeyCond = NULL; } return code; } @@ -344,7 +350,7 @@ static int32_t cpdOptimizeScanCondition(SOptimizeContext* pCxt, SScanLogicNode* SNode* pOtherCond = NULL; int32_t code = nodesPartitionCond(&pScan->node.pConditions, &pPrimaryKeyCond, &pTagCond, &pOtherCond); if (TSDB_CODE_SUCCESS == code && NULL != pPrimaryKeyCond) { - code = cpdCalcTimeRange(pScan, &pPrimaryKeyCond, &pOtherCond); + code = cpdCalcTimeRange(pCxt, pScan, &pPrimaryKeyCond, &pOtherCond); } if (TSDB_CODE_SUCCESS == code && NULL != pTagCond) { code = cpdApplyTagIndex(pScan, &pTagCond, &pOtherCond); diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 42ac3855f9..67ffdfb7d5 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -917,8 +917,16 @@ static int32_t createProjectPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChild pProject->slimit = pProjectLogicNode->slimit; pProject->soffset = pProjectLogicNode->soffset; - int32_t code = setListSlotId(pCxt, ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc->dataBlockId, - -1, pProjectLogicNode->pProjections, &pProject->pProjections); + int32_t code = TSDB_CODE_SUCCESS; + if (0 == LIST_LENGTH(pChildren)) { + pProject->pProjections = nodesCloneList(pProjectLogicNode->pProjections); + if (NULL == pProject->pProjections) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + } else { + code = setListSlotId(pCxt, ((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc->dataBlockId, -1, + pProjectLogicNode->pProjections, &pProject->pProjections); + } if (TSDB_CODE_SUCCESS == code) { code = addDataBlockSlotsForProject(pCxt, pProjectLogicNode->stmtName, pProject->pProjections, pProject->node.pOutputDataBlockDesc); diff --git a/source/libs/planner/test/planBasicTest.cpp b/source/libs/planner/test/planBasicTest.cpp index 4ee6c1ad01..790c418b17 100644 --- a/source/libs/planner/test/planBasicTest.cpp +++ b/source/libs/planner/test/planBasicTest.cpp @@ -95,3 +95,9 @@ TEST_F(PlanBasicTest, lastRowFunc) { run("SELECT LAST_ROW(c1) FROM st1"); } + +TEST_F(PlanBasicTest, withoutFrom) { + useDb("root", "test"); + + run("SELECT 1"); +} From 5661f88742fbf9e0002c056680221172dd03fd81 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Wed, 22 Jun 2022 10:25:53 +0800 Subject: [PATCH 3/3] feat: sql command 'select constant' --- source/libs/parser/src/parTranslater.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 13202295a6..a87d60898a 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -665,6 +665,10 @@ static EDealRes translateColumnUseAlias(STranslateContext* pCxt, SColumnNode** p } static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode** pCol) { + if (NULL != pCxt->pCurrSelectStmt && NULL == pCxt->pCurrSelectStmt->pFromTable) { + return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_INVALID_COLUMN, (*pCol)->colName); + } + // count(*)/first(*)/last(*) and so on if (0 == strcmp((*pCol)->colName, "*")) { return DEAL_RES_CONTINUE;