diff --git a/include/nodes/nodes.h b/include/nodes/nodes.h index b3ef5ba45cf1a605d8ed8fe7167e5efffd6e1b49..b182063808c1e58874a7885d712bdcd71a7c7c45 100644 --- a/include/nodes/nodes.h +++ b/include/nodes/nodes.h @@ -31,16 +31,7 @@ extern "C" { for (SListCell* cell = (NULL != (list) ? (list)->pHead : NULL); (NULL != cell ? (node = cell->pNode, true) : (node = NULL, false)); cell = cell->pNext) // only be use in FOREACH -#define ERASE_NODE(list) \ - if (NULL == cell->pPrev) { \ - (list)->pHead = cell->pNext; \ - } else { \ - cell->pPrev->pNext = cell->pNext; \ - cell->pNext->pPrev = cell->pPrev; \ - } \ - SListCell* tmp = cell; \ - cell = cell->pNext; \ - tfree(tmp); +#define ERASE_NODE(list) cell = nodesListErase(list, cell); #define REPLACE_NODE(newNode) cell->pNode = (SNode*)(newNode) @@ -343,18 +334,22 @@ void nodesDestroyNode(SNode* pNode); SNodeList* nodesMakeList(); SNodeList* nodesListAppend(SNodeList* pList, SNode* pNode); +SListCell* nodesListErase(SNodeList* pList, SListCell* pCell); SNode* nodesListGetNode(SNodeList* pList, int32_t index); void nodesDestroyList(SNodeList* pList); -typedef bool (*FQueryNodeWalker)(SNode* pNode, void* pContext); +typedef enum EDealRes { + DEAL_RES_CONTINUE = 1, + DEAL_RES_IGNORE_CHILD, + DEAL_RES_ERROR, +} EDealRes; +typedef EDealRes (*FQueryNodeWalker)(SNode* pNode, void* pContext); void nodesWalkNode(SNode* pNode, FQueryNodeWalker walker, void* pContext); void nodesWalkList(SNodeList* pList, FQueryNodeWalker walker, void* pContext); void nodesWalkNodePostOrder(SNode* pNode, FQueryNodeWalker walker, void* pContext); void nodesWalkListPostOrder(SNodeList* pList, FQueryNodeWalker walker, void* pContext); -bool nodesWalkStmt(SNode* pNode, FQueryNodeWalker walker, void* pContext); - bool nodesEqualNode(const SNode* a, const SNode* b); void nodesCloneNode(const SNode* pNode); @@ -362,6 +357,8 @@ void nodesCloneNode(const SNode* pNode); int32_t nodesNodeToString(const SNode* pNode, char** pStr, int32_t* pLen); int32_t nodesStringToNode(const char* pStr, SNode** pNode); +bool nodesIsExprNode(const SNode* pNode); + bool nodesIsArithmeticOp(const SOperatorNode* pOp); bool nodesIsComparisonOp(const SOperatorNode* pOp); bool nodesIsJsonOp(const SOperatorNode* pOp); diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 7ac9b1929b3b853c194886f352cb0421b83329d7..ad56e7333de94558715210cc77870a63742605c1 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -453,6 +453,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_FUNTION_PARA_TYPE TAOS_DEF_ERROR_CODE(0, 0x2607) //Inconsistent datatypes #define TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION TAOS_DEF_ERROR_CODE(0, 0x2608) //There mustn't be aggregation #define TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT TAOS_DEF_ERROR_CODE(0, 0x2609) //ORDER BY item must be the number of a SELECT-list expression +#define TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION TAOS_DEF_ERROR_CODE(0, 0x260A) //Not a GROUP BY expression #ifdef __cplusplus } diff --git a/source/libs/parser/inc/astCreateFuncs.h b/source/libs/parser/inc/astCreateFuncs.h index 82315a5ba481ddb6d4053241724bc62cf2d9308f..5b97a0e0c638cc473e1b6684843ebe91f3822f9f 100644 --- a/source/libs/parser/inc/astCreateFuncs.h +++ b/source/libs/parser/inc/astCreateFuncs.h @@ -55,6 +55,7 @@ SNode* createSessionWindowNode(SAstCreateContext* pCxt, SNode* pCol, const SToke SNode* createStateWindowNode(SAstCreateContext* pCxt, SNode* pCol); SNode* createIntervalWindowNode(SAstCreateContext* pCxt, SNode* pInterval, SNode* pOffset, SNode* pSliding, SNode* pFill); SNode* createFillNode(SAstCreateContext* pCxt, EFillMode mode, SNode* pValues); +SNode* createGroupingSetNode(SAstCreateContext* pCxt, SNode* pNode); SNode* addWhereClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pWhere); SNode* addPartitionByClause(SAstCreateContext* pCxt, SNode* pStmt, SNodeList* pPartitionByList); diff --git a/source/libs/parser/inc/new_sql.y b/source/libs/parser/inc/new_sql.y index 763f4ee38b25b9ec0defa90606bc09345c1f6108..eef04b17c3f8bf0360540eb7e07749bbddb45ae4 100644 --- a/source/libs/parser/inc/new_sql.y +++ b/source/libs/parser/inc/new_sql.y @@ -238,6 +238,7 @@ joined_table(A) ::= %type join_type { EJoinType } %destructor join_type { PARSER_DESTRUCTOR_TRACE; } +join_type(A) ::= . { PARSER_TRACE; A = JOIN_TYPE_INNER; } join_type(A) ::= INNER. { PARSER_TRACE; A = JOIN_TYPE_INNER; } /************************************************ query_specification *************************************************/ @@ -315,7 +316,12 @@ fill_mode(A) ::= NEXT. %type group_by_clause_opt { SNodeList* } %destructor group_by_clause_opt { PARSER_DESTRUCTOR_TRACE; nodesDestroyList($$); } group_by_clause_opt(A) ::= . { PARSER_TRACE; A = NULL; } -group_by_clause_opt(A) ::= GROUP BY expression_list(B). { PARSER_TRACE; A = B; } +group_by_clause_opt(A) ::= GROUP BY group_by_list(B). { PARSER_TRACE; A = B; } + +%type group_by_list { SNodeList* } +%destructor group_by_list { PARSER_DESTRUCTOR_TRACE; nodesDestroyList($$); } +group_by_list(A) ::= expression(B). { PARSER_TRACE; A = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, B))); } +group_by_list(A) ::= group_by_list(B) NK_COMMA expression(C). { PARSER_TRACE; A = addNodeToList(pCxt, B, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, C))); } having_clause_opt(A) ::= . { PARSER_TRACE; A = NULL; } having_clause_opt(A) ::= HAVING search_condition(B). { PARSER_TRACE; A = B; } diff --git a/source/libs/parser/src/astCreateFuncs.c b/source/libs/parser/src/astCreateFuncs.c index bfcebfd8b8cccc043d4bb611aec28645b701db22..ce2903f6aaa1d4f62927f7f937504f2cda22a3da 100644 --- a/source/libs/parser/src/astCreateFuncs.c +++ b/source/libs/parser/src/astCreateFuncs.c @@ -242,6 +242,9 @@ SNode* createOrderByExprNode(SAstCreateContext* pCxt, SNode* pExpr, EOrder order CHECK_OUT_OF_MEM(orderByExpr); orderByExpr->pExpr = pExpr; orderByExpr->order = order; + if (NULL_ORDER_DEFAULT == nullOrder) { + nullOrder = (ORDER_ASC == order ? NULL_ORDER_FIRST : NULL_ORDER_LAST); + } orderByExpr->nullOrder = nullOrder; return (SNode*)orderByExpr; } @@ -279,6 +282,15 @@ SNode* createFillNode(SAstCreateContext* pCxt, EFillMode mode, SNode* pValues) { return (SNode*)fill; } +SNode* createGroupingSetNode(SAstCreateContext* pCxt, SNode* pNode) { + SGroupingSetNode* groupingSet = (SGroupingSetNode*)nodesMakeNode(QUERY_NODE_GROUPING_SET); + CHECK_OUT_OF_MEM(groupingSet); + groupingSet->groupingSetType = GP_TYPE_NORMAL; + groupingSet->pParameterList = nodesMakeList(); + nodesListAppend(groupingSet->pParameterList, pNode); + return (SNode*)groupingSet; +} + SNode* setProjectionAlias(SAstCreateContext* pCxt, SNode* pNode, const SToken* pAlias) { strncpy(((SExprNode*)pNode)->aliasName, pAlias->z, pAlias->n); return pNode; diff --git a/source/libs/parser/src/new_sql.c b/source/libs/parser/src/new_sql.c index 4d03de14d42ae3ad53779653ad91ca86d8645570..b7a82e5d979c5b64b2547980e2953789e59f4ffb 100644 --- a/source/libs/parser/src/new_sql.c +++ b/source/libs/parser/src/new_sql.c @@ -109,21 +109,21 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned char -#define YYNOCODE 124 +#define YYNOCODE 125 #define YYACTIONTYPE unsigned short int #define NewParseTOKENTYPE SToken typedef union { int yyinit; NewParseTOKENTYPE yy0; - EOrder yy10; - EFillMode yy14; - SNode* yy168; - ENullOrder yy177; - SNodeList* yy192; - bool yy209; - EOperatorType yy228; - EJoinType yy229; - SToken yy241; + EOperatorType yy40; + EFillMode yy44; + SToken yy79; + ENullOrder yy107; + EJoinType yy162; + SNodeList* yy174; + EOrder yy188; + SNode* yy212; + bool yy237; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -138,17 +138,17 @@ typedef union { #define NewParseCTX_PARAM #define NewParseCTX_FETCH #define NewParseCTX_STORE -#define YYNSTATE 144 -#define YYNRULE 135 +#define YYNSTATE 147 +#define YYNRULE 138 #define YYNTOKEN 72 -#define YY_MAX_SHIFT 143 -#define YY_MIN_SHIFTREDUCE 240 -#define YY_MAX_SHIFTREDUCE 374 -#define YY_ERROR_ACTION 375 -#define YY_ACCEPT_ACTION 376 -#define YY_NO_ACTION 377 -#define YY_MIN_REDUCE 378 -#define YY_MAX_REDUCE 512 +#define YY_MAX_SHIFT 146 +#define YY_MIN_SHIFTREDUCE 243 +#define YY_MAX_SHIFTREDUCE 380 +#define YY_ERROR_ACTION 381 +#define YY_ACCEPT_ACTION 382 +#define YY_NO_ACTION 383 +#define YY_MIN_REDUCE 384 +#define YY_MAX_REDUCE 521 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -215,200 +215,208 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (692) +#define YY_ACTTAB_COUNT (737) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 387, 385, 89, 22, 64, 388, 385, 462, 29, 27, - /* 10 */ 25, 24, 23, 395, 385, 138, 410, 138, 410, 139, - /* 20 */ 71, 109, 78, 396, 262, 399, 21, 84, 93, 143, - /* 30 */ 280, 281, 282, 283, 284, 285, 286, 288, 289, 290, - /* 40 */ 29, 27, 25, 24, 23, 395, 385, 138, 410, 138, - /* 50 */ 410, 139, 318, 113, 81, 396, 97, 399, 21, 84, - /* 60 */ 93, 51, 280, 281, 282, 283, 284, 285, 286, 288, - /* 70 */ 289, 290, 128, 395, 385, 114, 447, 138, 410, 139, - /* 80 */ 125, 9, 38, 396, 51, 399, 435, 255, 28, 26, - /* 90 */ 83, 431, 491, 444, 317, 242, 243, 244, 245, 140, - /* 100 */ 248, 491, 98, 1, 343, 490, 67, 10, 106, 489, - /* 110 */ 326, 395, 385, 60, 50, 138, 410, 139, 489, 123, - /* 120 */ 39, 396, 253, 399, 435, 51, 125, 9, 91, 431, - /* 130 */ 105, 341, 342, 344, 345, 395, 385, 73, 466, 138, - /* 140 */ 410, 139, 4, 314, 39, 396, 411, 399, 435, 51, - /* 150 */ 447, 447, 91, 431, 242, 243, 244, 245, 140, 248, - /* 160 */ 395, 385, 487, 8, 138, 410, 139, 443, 442, 39, - /* 170 */ 396, 40, 399, 435, 340, 18, 107, 91, 431, 7, - /* 180 */ 6, 29, 27, 25, 24, 23, 135, 451, 128, 395, - /* 190 */ 385, 7, 6, 138, 410, 139, 28, 26, 77, 396, - /* 200 */ 473, 399, 298, 242, 243, 244, 245, 140, 248, 104, - /* 210 */ 98, 1, 28, 26, 392, 10, 390, 491, 52, 242, - /* 220 */ 243, 244, 245, 140, 248, 248, 98, 5, 102, 54, - /* 230 */ 50, 136, 57, 19, 489, 395, 385, 131, 103, 138, - /* 240 */ 410, 139, 472, 287, 39, 396, 291, 399, 435, 51, - /* 250 */ 373, 374, 434, 431, 25, 24, 23, 29, 27, 25, - /* 260 */ 24, 23, 30, 395, 385, 292, 56, 138, 410, 139, - /* 270 */ 90, 256, 39, 396, 132, 399, 435, 28, 26, 319, - /* 280 */ 118, 431, 3, 453, 242, 243, 244, 245, 140, 248, - /* 290 */ 70, 98, 5, 117, 395, 385, 130, 128, 126, 410, - /* 300 */ 139, 122, 43, 44, 396, 20, 399, 119, 59, 277, - /* 310 */ 41, 29, 27, 25, 24, 23, 101, 133, 47, 65, - /* 320 */ 440, 121, 30, 120, 69, 259, 491, 115, 110, 108, - /* 330 */ 99, 459, 29, 27, 25, 24, 23, 2, 314, 50, - /* 340 */ 28, 26, 127, 489, 61, 16, 417, 242, 243, 244, - /* 350 */ 245, 140, 248, 42, 98, 5, 28, 26, 29, 27, - /* 360 */ 25, 24, 23, 242, 243, 244, 245, 140, 248, 252, - /* 370 */ 98, 1, 395, 385, 262, 255, 138, 410, 139, 31, - /* 380 */ 448, 39, 396, 256, 399, 435, 28, 26, 62, 463, - /* 390 */ 432, 370, 371, 242, 243, 244, 245, 140, 248, 94, - /* 400 */ 98, 5, 506, 137, 488, 395, 385, 253, 134, 138, - /* 410 */ 410, 139, 13, 72, 45, 396, 30, 399, 395, 385, - /* 420 */ 14, 53, 126, 410, 139, 337, 55, 44, 396, 34, - /* 430 */ 399, 395, 385, 339, 46, 138, 410, 139, 58, 35, - /* 440 */ 81, 396, 100, 399, 111, 376, 141, 333, 332, 112, - /* 450 */ 390, 129, 504, 395, 385, 460, 6, 138, 410, 139, - /* 460 */ 36, 15, 81, 396, 116, 399, 312, 278, 395, 385, - /* 470 */ 311, 33, 138, 410, 139, 491, 66, 81, 396, 92, - /* 480 */ 399, 395, 385, 32, 389, 138, 410, 139, 50, 49, - /* 490 */ 45, 396, 489, 399, 395, 385, 260, 364, 138, 410, - /* 500 */ 139, 17, 11, 75, 396, 37, 399, 395, 385, 359, - /* 510 */ 358, 138, 410, 139, 95, 363, 79, 396, 362, 399, - /* 520 */ 29, 27, 25, 24, 23, 96, 395, 385, 505, 12, - /* 530 */ 138, 410, 139, 74, 379, 76, 396, 246, 399, 395, - /* 540 */ 385, 378, 142, 138, 410, 139, 377, 377, 80, 396, - /* 550 */ 377, 399, 395, 385, 377, 377, 138, 410, 139, 377, - /* 560 */ 377, 407, 396, 377, 399, 395, 385, 377, 377, 138, - /* 570 */ 410, 139, 377, 377, 406, 396, 377, 399, 395, 385, - /* 580 */ 377, 377, 138, 410, 139, 377, 377, 405, 396, 377, - /* 590 */ 399, 395, 385, 377, 377, 138, 410, 139, 377, 377, - /* 600 */ 87, 396, 377, 399, 377, 395, 385, 377, 377, 138, - /* 610 */ 410, 139, 377, 377, 86, 396, 377, 399, 395, 385, - /* 620 */ 377, 377, 138, 410, 139, 377, 377, 88, 396, 377, - /* 630 */ 399, 395, 385, 377, 377, 138, 410, 139, 377, 377, - /* 640 */ 85, 396, 377, 399, 395, 385, 377, 377, 138, 410, - /* 650 */ 139, 377, 377, 82, 396, 377, 399, 122, 43, 377, - /* 660 */ 377, 377, 122, 43, 377, 377, 41, 377, 377, 122, - /* 670 */ 43, 41, 377, 377, 124, 63, 440, 441, 41, 445, - /* 680 */ 48, 440, 441, 377, 445, 377, 377, 68, 440, 441, - /* 690 */ 377, 445, + /* 0 */ 393, 391, 92, 23, 66, 394, 391, 469, 30, 28, + /* 10 */ 26, 25, 24, 401, 391, 141, 416, 141, 416, 142, + /* 20 */ 72, 112, 46, 402, 265, 405, 22, 87, 96, 117, + /* 30 */ 283, 284, 285, 286, 287, 288, 289, 291, 292, 293, + /* 40 */ 30, 28, 26, 25, 24, 401, 391, 141, 416, 141, + /* 50 */ 416, 142, 146, 116, 46, 402, 54, 405, 22, 87, + /* 60 */ 96, 514, 283, 284, 285, 286, 287, 288, 289, 291, + /* 70 */ 292, 293, 131, 401, 391, 128, 9, 141, 416, 142, + /* 80 */ 4, 318, 39, 402, 54, 405, 441, 109, 29, 27, + /* 90 */ 86, 437, 132, 513, 63, 245, 246, 247, 248, 143, + /* 100 */ 251, 500, 101, 1, 118, 113, 111, 10, 245, 246, + /* 110 */ 247, 248, 143, 251, 500, 53, 453, 401, 391, 498, + /* 120 */ 258, 141, 416, 142, 126, 54, 40, 402, 499, 405, + /* 130 */ 441, 453, 498, 450, 94, 437, 453, 401, 391, 69, + /* 140 */ 330, 141, 416, 142, 473, 417, 40, 402, 449, 405, + /* 150 */ 441, 134, 256, 448, 94, 437, 41, 401, 391, 344, + /* 160 */ 8, 141, 416, 142, 496, 74, 40, 402, 347, 405, + /* 170 */ 441, 458, 110, 318, 94, 437, 131, 401, 391, 107, + /* 180 */ 322, 141, 416, 142, 457, 57, 78, 402, 60, 405, + /* 190 */ 128, 9, 29, 27, 108, 345, 346, 348, 349, 245, + /* 200 */ 246, 247, 248, 143, 251, 500, 101, 1, 19, 31, + /* 210 */ 133, 10, 295, 54, 30, 28, 26, 25, 24, 53, + /* 220 */ 29, 27, 321, 498, 26, 25, 24, 245, 246, 247, + /* 230 */ 248, 143, 251, 480, 101, 5, 401, 391, 7, 6, + /* 240 */ 141, 416, 142, 7, 6, 40, 402, 251, 405, 441, + /* 250 */ 122, 138, 280, 440, 437, 55, 398, 54, 396, 401, + /* 260 */ 391, 301, 105, 141, 416, 142, 379, 380, 40, 402, + /* 270 */ 106, 405, 441, 29, 27, 323, 121, 437, 479, 59, + /* 280 */ 245, 246, 247, 248, 143, 251, 93, 101, 5, 30, + /* 290 */ 28, 26, 25, 24, 401, 391, 139, 131, 129, 416, + /* 300 */ 142, 125, 44, 45, 402, 265, 405, 3, 460, 135, + /* 310 */ 42, 120, 20, 30, 28, 26, 25, 24, 62, 67, + /* 320 */ 446, 124, 290, 123, 70, 294, 500, 259, 104, 21, + /* 330 */ 102, 466, 48, 64, 2, 30, 28, 26, 25, 24, + /* 340 */ 53, 16, 31, 423, 498, 262, 71, 318, 255, 29, + /* 350 */ 27, 130, 136, 43, 258, 454, 245, 246, 247, 248, + /* 360 */ 143, 251, 32, 101, 5, 29, 27, 30, 28, 26, + /* 370 */ 25, 24, 245, 246, 247, 248, 143, 251, 65, 101, + /* 380 */ 1, 401, 391, 259, 470, 141, 416, 142, 97, 140, + /* 390 */ 40, 402, 515, 405, 441, 29, 27, 497, 137, 438, + /* 400 */ 73, 256, 245, 246, 247, 248, 143, 251, 56, 101, + /* 410 */ 5, 13, 30, 28, 26, 25, 24, 31, 14, 401, + /* 420 */ 391, 341, 58, 141, 416, 142, 376, 377, 84, 402, + /* 430 */ 100, 405, 401, 391, 35, 343, 129, 416, 142, 47, + /* 440 */ 61, 45, 402, 337, 405, 36, 114, 401, 391, 382, + /* 450 */ 144, 141, 416, 142, 336, 37, 84, 402, 103, 405, + /* 460 */ 115, 396, 401, 391, 18, 315, 141, 416, 142, 467, + /* 470 */ 6, 80, 402, 15, 405, 281, 314, 401, 391, 500, + /* 480 */ 68, 141, 416, 142, 33, 34, 84, 402, 95, 405, + /* 490 */ 395, 52, 17, 53, 263, 401, 391, 498, 370, 141, + /* 500 */ 416, 142, 11, 119, 79, 402, 38, 405, 401, 391, + /* 510 */ 365, 75, 141, 416, 142, 364, 98, 81, 402, 369, + /* 520 */ 405, 368, 401, 391, 385, 99, 141, 416, 142, 249, + /* 530 */ 12, 76, 402, 384, 405, 145, 383, 401, 391, 383, + /* 540 */ 383, 141, 416, 142, 383, 383, 82, 402, 383, 405, + /* 550 */ 383, 383, 401, 391, 383, 383, 141, 416, 142, 383, + /* 560 */ 383, 77, 402, 383, 405, 383, 383, 383, 383, 383, + /* 570 */ 401, 391, 383, 383, 141, 416, 142, 383, 383, 83, + /* 580 */ 402, 383, 405, 401, 391, 383, 383, 141, 416, 142, + /* 590 */ 383, 383, 413, 402, 383, 405, 383, 401, 391, 383, + /* 600 */ 383, 141, 416, 142, 383, 383, 412, 402, 383, 405, + /* 610 */ 383, 383, 401, 391, 383, 383, 141, 416, 142, 383, + /* 620 */ 383, 411, 402, 383, 405, 383, 383, 401, 391, 383, + /* 630 */ 383, 141, 416, 142, 383, 383, 90, 402, 383, 405, + /* 640 */ 383, 383, 383, 383, 383, 401, 391, 383, 383, 141, + /* 650 */ 416, 142, 383, 383, 89, 402, 383, 405, 401, 391, + /* 660 */ 383, 383, 141, 416, 142, 383, 383, 91, 402, 383, + /* 670 */ 405, 383, 401, 391, 383, 383, 141, 416, 142, 383, + /* 680 */ 383, 88, 402, 383, 405, 125, 44, 401, 391, 383, + /* 690 */ 383, 141, 416, 142, 42, 383, 85, 402, 383, 405, + /* 700 */ 125, 44, 127, 49, 446, 447, 383, 451, 383, 42, + /* 710 */ 383, 383, 383, 383, 125, 44, 383, 383, 50, 446, + /* 720 */ 447, 383, 451, 42, 383, 383, 383, 383, 383, 383, + /* 730 */ 383, 383, 51, 446, 447, 383, 451, }; static const YYCODETYPE yy_lookahead[] = { /* 0 */ 74, 75, 76, 88, 89, 74, 75, 82, 8, 9, /* 10 */ 10, 11, 12, 74, 75, 78, 79, 78, 79, 80, - /* 20 */ 122, 84, 83, 84, 24, 86, 26, 27, 28, 13, + /* 20 */ 123, 84, 83, 84, 24, 86, 26, 27, 28, 22, /* 30 */ 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, /* 40 */ 8, 9, 10, 11, 12, 74, 75, 78, 79, 78, - /* 50 */ 79, 80, 4, 84, 83, 84, 85, 86, 26, 27, - /* 60 */ 28, 45, 30, 31, 32, 33, 34, 35, 36, 37, - /* 70 */ 38, 39, 73, 74, 75, 22, 81, 78, 79, 80, - /* 80 */ 22, 23, 83, 84, 45, 86, 87, 22, 8, 9, - /* 90 */ 91, 92, 102, 98, 46, 15, 16, 17, 18, 19, - /* 100 */ 20, 102, 22, 23, 29, 115, 41, 27, 114, 119, - /* 110 */ 10, 74, 75, 107, 115, 78, 79, 80, 119, 100, - /* 120 */ 83, 84, 22, 86, 87, 45, 22, 23, 91, 92, - /* 130 */ 55, 56, 57, 58, 59, 74, 75, 116, 101, 78, - /* 140 */ 79, 80, 43, 44, 83, 84, 79, 86, 87, 45, - /* 150 */ 81, 81, 91, 92, 15, 16, 17, 18, 19, 20, - /* 160 */ 74, 75, 101, 103, 78, 79, 80, 98, 98, 83, - /* 170 */ 84, 21, 86, 87, 24, 2, 54, 91, 92, 1, - /* 180 */ 2, 8, 9, 10, 11, 12, 21, 101, 73, 74, - /* 190 */ 75, 1, 2, 78, 79, 80, 8, 9, 83, 84, - /* 200 */ 113, 86, 24, 15, 16, 17, 18, 19, 20, 53, - /* 210 */ 22, 23, 8, 9, 23, 27, 25, 102, 112, 15, - /* 220 */ 16, 17, 18, 19, 20, 20, 22, 23, 75, 21, - /* 230 */ 115, 66, 24, 26, 119, 74, 75, 3, 75, 78, - /* 240 */ 79, 80, 113, 36, 83, 84, 39, 86, 87, 45, - /* 250 */ 70, 71, 91, 92, 10, 11, 12, 8, 9, 10, - /* 260 */ 11, 12, 21, 74, 75, 24, 112, 78, 79, 80, - /* 270 */ 75, 22, 83, 84, 21, 86, 87, 8, 9, 10, - /* 280 */ 91, 92, 61, 109, 15, 16, 17, 18, 19, 20, - /* 290 */ 41, 22, 23, 60, 74, 75, 62, 73, 78, 79, - /* 300 */ 80, 77, 78, 83, 84, 2, 86, 27, 108, 29, - /* 310 */ 86, 8, 9, 10, 11, 12, 48, 64, 106, 95, - /* 320 */ 96, 97, 21, 99, 104, 24, 102, 50, 51, 52, - /* 330 */ 110, 111, 8, 9, 10, 11, 12, 47, 44, 115, - /* 340 */ 8, 9, 10, 119, 105, 23, 90, 15, 16, 17, - /* 350 */ 18, 19, 20, 78, 22, 23, 8, 9, 8, 9, - /* 360 */ 10, 11, 12, 15, 16, 17, 18, 19, 20, 22, - /* 370 */ 22, 23, 74, 75, 24, 22, 78, 79, 80, 40, - /* 380 */ 81, 83, 84, 22, 86, 87, 8, 9, 93, 82, - /* 390 */ 92, 67, 68, 15, 16, 17, 18, 19, 20, 69, - /* 400 */ 22, 23, 123, 65, 118, 74, 75, 22, 63, 78, - /* 410 */ 79, 80, 21, 117, 83, 84, 21, 86, 74, 75, - /* 420 */ 49, 24, 78, 79, 80, 24, 23, 83, 84, 21, - /* 430 */ 86, 74, 75, 24, 23, 78, 79, 80, 23, 23, - /* 440 */ 83, 84, 85, 86, 15, 72, 73, 24, 24, 21, - /* 450 */ 25, 120, 121, 74, 75, 111, 2, 78, 79, 80, - /* 460 */ 23, 49, 83, 84, 85, 86, 24, 29, 74, 75, - /* 470 */ 24, 21, 78, 79, 80, 102, 25, 83, 84, 85, - /* 480 */ 86, 74, 75, 42, 25, 78, 79, 80, 115, 25, - /* 490 */ 83, 84, 119, 86, 74, 75, 24, 24, 78, 79, - /* 500 */ 80, 21, 49, 83, 84, 4, 86, 74, 75, 15, - /* 510 */ 15, 78, 79, 80, 15, 15, 83, 84, 15, 86, - /* 520 */ 8, 9, 10, 11, 12, 15, 74, 75, 121, 23, - /* 530 */ 78, 79, 80, 25, 0, 83, 84, 17, 86, 74, - /* 540 */ 75, 0, 14, 78, 79, 80, 124, 124, 83, 84, - /* 550 */ 124, 86, 74, 75, 124, 124, 78, 79, 80, 124, - /* 560 */ 124, 83, 84, 124, 86, 74, 75, 124, 124, 78, - /* 570 */ 79, 80, 124, 124, 83, 84, 124, 86, 74, 75, - /* 580 */ 124, 124, 78, 79, 80, 124, 124, 83, 84, 124, - /* 590 */ 86, 74, 75, 124, 124, 78, 79, 80, 124, 124, - /* 600 */ 83, 84, 124, 86, 124, 74, 75, 124, 124, 78, - /* 610 */ 79, 80, 124, 124, 83, 84, 124, 86, 74, 75, - /* 620 */ 124, 124, 78, 79, 80, 124, 124, 83, 84, 124, - /* 630 */ 86, 74, 75, 124, 124, 78, 79, 80, 124, 124, - /* 640 */ 83, 84, 124, 86, 74, 75, 124, 124, 78, 79, - /* 650 */ 80, 124, 124, 83, 84, 124, 86, 77, 78, 124, - /* 660 */ 124, 124, 77, 78, 124, 124, 86, 124, 124, 77, - /* 670 */ 78, 86, 124, 124, 94, 95, 96, 97, 86, 99, - /* 680 */ 95, 96, 97, 124, 99, 124, 124, 95, 96, 97, - /* 690 */ 124, 99, + /* 50 */ 79, 80, 13, 84, 83, 84, 45, 86, 26, 27, + /* 60 */ 28, 122, 30, 31, 32, 33, 34, 35, 36, 37, + /* 70 */ 38, 39, 73, 74, 75, 22, 23, 78, 79, 80, + /* 80 */ 43, 44, 83, 84, 45, 86, 87, 114, 8, 9, + /* 90 */ 91, 92, 121, 122, 107, 15, 16, 17, 18, 19, + /* 100 */ 20, 102, 22, 23, 50, 51, 52, 27, 15, 16, + /* 110 */ 17, 18, 19, 20, 102, 116, 81, 74, 75, 120, + /* 120 */ 22, 78, 79, 80, 100, 45, 83, 84, 116, 86, + /* 130 */ 87, 81, 120, 98, 91, 92, 81, 74, 75, 41, + /* 140 */ 10, 78, 79, 80, 101, 79, 83, 84, 98, 86, + /* 150 */ 87, 3, 22, 98, 91, 92, 21, 74, 75, 24, + /* 160 */ 103, 78, 79, 80, 101, 117, 83, 84, 29, 86, + /* 170 */ 87, 42, 54, 44, 91, 92, 73, 74, 75, 53, + /* 180 */ 4, 78, 79, 80, 101, 21, 83, 84, 24, 86, + /* 190 */ 22, 23, 8, 9, 55, 56, 57, 58, 59, 15, + /* 200 */ 16, 17, 18, 19, 20, 102, 22, 23, 2, 21, + /* 210 */ 62, 27, 24, 45, 8, 9, 10, 11, 12, 116, + /* 220 */ 8, 9, 46, 120, 10, 11, 12, 15, 16, 17, + /* 230 */ 18, 19, 20, 113, 22, 23, 74, 75, 1, 2, + /* 240 */ 78, 79, 80, 1, 2, 83, 84, 20, 86, 87, + /* 250 */ 27, 21, 29, 91, 92, 112, 23, 45, 25, 74, + /* 260 */ 75, 24, 75, 78, 79, 80, 70, 71, 83, 84, + /* 270 */ 75, 86, 87, 8, 9, 10, 91, 92, 113, 112, + /* 280 */ 15, 16, 17, 18, 19, 20, 75, 22, 23, 8, + /* 290 */ 9, 10, 11, 12, 74, 75, 66, 73, 78, 79, + /* 300 */ 80, 77, 78, 83, 84, 24, 86, 61, 109, 21, + /* 310 */ 86, 60, 26, 8, 9, 10, 11, 12, 108, 95, + /* 320 */ 96, 97, 36, 99, 104, 39, 102, 22, 48, 2, + /* 330 */ 110, 111, 106, 105, 47, 8, 9, 10, 11, 12, + /* 340 */ 116, 23, 21, 90, 120, 24, 41, 44, 22, 8, + /* 350 */ 9, 10, 64, 78, 22, 81, 15, 16, 17, 18, + /* 360 */ 19, 20, 40, 22, 23, 8, 9, 8, 9, 10, + /* 370 */ 11, 12, 15, 16, 17, 18, 19, 20, 93, 22, + /* 380 */ 23, 74, 75, 22, 82, 78, 79, 80, 69, 65, + /* 390 */ 83, 84, 124, 86, 87, 8, 9, 119, 63, 92, + /* 400 */ 118, 22, 15, 16, 17, 18, 19, 20, 24, 22, + /* 410 */ 23, 21, 8, 9, 10, 11, 12, 21, 49, 74, + /* 420 */ 75, 24, 23, 78, 79, 80, 67, 68, 83, 84, + /* 430 */ 85, 86, 74, 75, 21, 24, 78, 79, 80, 23, + /* 440 */ 23, 83, 84, 24, 86, 23, 15, 74, 75, 72, + /* 450 */ 73, 78, 79, 80, 24, 23, 83, 84, 85, 86, + /* 460 */ 21, 25, 74, 75, 21, 24, 78, 79, 80, 111, + /* 470 */ 2, 83, 84, 49, 86, 29, 24, 74, 75, 102, + /* 480 */ 25, 78, 79, 80, 42, 21, 83, 84, 85, 86, + /* 490 */ 25, 25, 21, 116, 24, 74, 75, 120, 24, 78, + /* 500 */ 79, 80, 49, 115, 83, 84, 4, 86, 74, 75, + /* 510 */ 15, 25, 78, 79, 80, 15, 15, 83, 84, 15, + /* 520 */ 86, 15, 74, 75, 0, 15, 78, 79, 80, 17, + /* 530 */ 23, 83, 84, 0, 86, 14, 125, 74, 75, 125, + /* 540 */ 125, 78, 79, 80, 125, 125, 83, 84, 125, 86, + /* 550 */ 125, 125, 74, 75, 125, 125, 78, 79, 80, 125, + /* 560 */ 125, 83, 84, 125, 86, 125, 125, 125, 125, 125, + /* 570 */ 74, 75, 125, 125, 78, 79, 80, 125, 125, 83, + /* 580 */ 84, 125, 86, 74, 75, 125, 125, 78, 79, 80, + /* 590 */ 125, 125, 83, 84, 125, 86, 125, 74, 75, 125, + /* 600 */ 125, 78, 79, 80, 125, 125, 83, 84, 125, 86, + /* 610 */ 125, 125, 74, 75, 125, 125, 78, 79, 80, 125, + /* 620 */ 125, 83, 84, 125, 86, 125, 125, 74, 75, 125, + /* 630 */ 125, 78, 79, 80, 125, 125, 83, 84, 125, 86, + /* 640 */ 125, 125, 125, 125, 125, 74, 75, 125, 125, 78, + /* 650 */ 79, 80, 125, 125, 83, 84, 125, 86, 74, 75, + /* 660 */ 125, 125, 78, 79, 80, 125, 125, 83, 84, 125, + /* 670 */ 86, 125, 74, 75, 125, 125, 78, 79, 80, 125, + /* 680 */ 125, 83, 84, 125, 86, 77, 78, 74, 75, 125, + /* 690 */ 125, 78, 79, 80, 86, 125, 83, 84, 125, 86, + /* 700 */ 77, 78, 94, 95, 96, 97, 125, 99, 125, 86, + /* 710 */ 125, 125, 125, 125, 77, 78, 125, 125, 95, 96, + /* 720 */ 97, 125, 99, 86, 125, 125, 125, 125, 125, 125, + /* 730 */ 125, 125, 95, 96, 97, 125, 99, }; -#define YY_SHIFT_COUNT (143) +#define YY_SHIFT_COUNT (146) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (541) +#define YY_SHIFT_MAX (533) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 16, 80, 188, 188, 188, 204, 188, 188, 269, 104, - /* 10 */ 348, 378, 332, 378, 378, 378, 378, 378, 378, 378, - /* 20 */ 378, 378, 378, 378, 378, 378, 378, 378, 378, 378, - /* 30 */ 378, 58, 58, 58, 139, 53, 53, 39, 0, 32, - /* 40 */ 139, 65, 65, 65, 249, 324, 75, 277, 99, 100, - /* 50 */ 234, 48, 122, 156, 205, 205, 122, 156, 205, 221, - /* 60 */ 233, 268, 290, 294, 322, 294, 347, 353, 294, 339, - /* 70 */ 361, 330, 338, 345, 385, 173, 303, 350, 512, 512, - /* 80 */ 512, 512, 512, 178, 207, 244, 244, 244, 244, 150, - /* 90 */ 208, 190, 241, 280, 180, 253, 165, 301, 191, 391, - /* 100 */ 395, 371, 397, 401, 403, 408, 409, 411, 415, 423, - /* 110 */ 416, 424, 429, 428, 425, 437, 395, 412, 454, 438, - /* 120 */ 442, 446, 451, 441, 450, 459, 464, 472, 473, 480, - /* 130 */ 453, 501, 494, 495, 499, 500, 503, 510, 508, 506, - /* 140 */ 520, 534, 541, 528, + /* 0 */ 39, 80, 184, 184, 184, 212, 184, 184, 265, 168, + /* 10 */ 357, 387, 341, 387, 387, 387, 387, 387, 387, 387, + /* 20 */ 387, 387, 387, 387, 387, 387, 387, 387, 387, 387, + /* 30 */ 387, 387, 53, 53, 53, 93, 7, 7, 11, 0, + /* 40 */ 32, 93, 98, 98, 98, 305, 359, 139, 54, 129, + /* 50 */ 37, 129, 130, 148, 176, 118, 126, 227, 227, 118, + /* 60 */ 126, 227, 246, 251, 280, 287, 318, 303, 326, 332, + /* 70 */ 322, 361, 319, 324, 335, 379, 206, 327, 281, 404, + /* 80 */ 404, 404, 404, 404, 404, 404, 237, 286, 214, 214, + /* 90 */ 214, 214, 135, 164, 242, 188, 223, 196, 288, 230, + /* 100 */ 321, 233, 390, 396, 369, 384, 397, 399, 413, 411, + /* 110 */ 416, 417, 419, 422, 430, 431, 439, 436, 432, 443, + /* 120 */ 424, 468, 446, 441, 452, 455, 442, 464, 465, 466, + /* 130 */ 470, 474, 471, 453, 502, 495, 500, 501, 504, 506, + /* 140 */ 510, 486, 507, 512, 524, 533, 521, }; -#define YY_REDUCE_COUNT (74) -#define YY_REDUCE_MIN (-102) -#define YY_REDUCE_MAX (592) +#define YY_REDUCE_COUNT (75) +#define YY_REDUCE_MIN (-103) +#define YY_REDUCE_MAX (637) static const short yy_reduce_ofst[] = { - /* 0 */ 373, -1, 37, 61, 86, 115, 161, 189, 220, 224, - /* 10 */ 298, 331, -29, 344, 357, 379, 394, 407, -61, 420, - /* 20 */ 433, 452, 465, 478, 491, 504, 517, 531, 544, 557, - /* 30 */ 570, 580, 585, 592, -74, -63, -31, -10, -85, -85, - /* 40 */ -69, -5, 69, 70, -75, -102, -6, 6, 19, 67, - /* 50 */ 21, 60, 87, 106, 153, 163, 129, 154, 195, 174, - /* 60 */ 200, 212, 239, 19, 256, 19, 275, 299, 19, 295, - /* 70 */ 307, 279, 286, 296, 67, + /* 0 */ 377, -1, 43, 63, 83, 103, 162, 185, 220, 224, + /* 10 */ 307, -29, 345, 358, 373, 388, 403, -61, 421, 434, + /* 20 */ 448, 463, 478, 496, 509, 523, 538, 553, 571, 584, + /* 30 */ 598, 613, 608, 623, 637, -74, -63, -31, 12, -85, + /* 40 */ -85, -69, 35, 50, 55, -75, -103, -27, -13, 24, + /* 50 */ 24, 24, 66, 48, 57, 120, 143, 187, 195, 165, + /* 60 */ 167, 211, 199, 210, 226, 228, 253, 24, 275, 274, + /* 70 */ 285, 302, 268, 278, 282, 66, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 375, 375, 375, 375, 375, 375, 375, 375, 375, 375, - /* 10 */ 375, 375, 375, 375, 375, 375, 375, 375, 375, 375, - /* 20 */ 375, 375, 375, 375, 375, 375, 375, 375, 375, 375, - /* 30 */ 375, 375, 375, 375, 375, 375, 375, 375, 375, 375, - /* 40 */ 375, 446, 446, 446, 461, 507, 375, 469, 375, 375, - /* 50 */ 492, 454, 476, 474, 375, 375, 476, 474, 375, 486, - /* 60 */ 484, 467, 465, 438, 375, 375, 375, 375, 439, 375, - /* 70 */ 375, 510, 498, 494, 375, 375, 375, 375, 414, 413, - /* 80 */ 412, 408, 409, 375, 375, 403, 404, 402, 401, 375, - /* 90 */ 375, 503, 375, 375, 375, 495, 499, 375, 391, 458, - /* 100 */ 468, 375, 375, 375, 375, 375, 375, 375, 375, 375, - /* 110 */ 375, 375, 375, 375, 391, 375, 485, 375, 433, 375, - /* 120 */ 445, 441, 375, 375, 437, 390, 375, 375, 375, 493, - /* 130 */ 375, 375, 375, 375, 375, 375, 375, 375, 375, 375, - /* 140 */ 375, 375, 375, 375, + /* 0 */ 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, + /* 10 */ 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, + /* 20 */ 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, + /* 30 */ 381, 381, 381, 381, 381, 381, 381, 381, 381, 381, + /* 40 */ 381, 381, 452, 452, 452, 468, 516, 381, 476, 444, + /* 50 */ 458, 445, 381, 501, 461, 483, 481, 381, 381, 483, + /* 60 */ 481, 381, 495, 491, 474, 472, 381, 458, 381, 381, + /* 70 */ 381, 381, 519, 507, 503, 381, 381, 381, 381, 494, + /* 80 */ 493, 420, 419, 418, 414, 415, 381, 381, 409, 410, + /* 90 */ 408, 407, 381, 381, 512, 381, 381, 381, 504, 508, + /* 100 */ 381, 397, 465, 475, 381, 381, 381, 381, 381, 381, + /* 110 */ 381, 381, 381, 381, 381, 381, 381, 397, 381, 492, + /* 120 */ 381, 439, 381, 451, 447, 381, 381, 443, 396, 381, + /* 130 */ 381, 381, 502, 381, 381, 381, 381, 381, 381, 381, + /* 140 */ 381, 381, 381, 381, 381, 381, 381, }; /********** End of lemon-generated parsing tables *****************************/ @@ -630,15 +638,16 @@ static const char *const yyTokenName[] = { /* 112 */ "sliding_opt", /* 113 */ "fill_opt", /* 114 */ "fill_mode", - /* 115 */ "query_expression_body", - /* 116 */ "order_by_clause_opt", - /* 117 */ "slimit_clause_opt", - /* 118 */ "limit_clause_opt", - /* 119 */ "query_primary", - /* 120 */ "sort_specification_list", - /* 121 */ "sort_specification", - /* 122 */ "ordering_specification_opt", - /* 123 */ "null_ordering_opt", + /* 115 */ "group_by_list", + /* 116 */ "query_expression_body", + /* 117 */ "order_by_clause_opt", + /* 118 */ "slimit_clause_opt", + /* 119 */ "limit_clause_opt", + /* 120 */ "query_primary", + /* 121 */ "sort_specification_list", + /* 122 */ "sort_specification", + /* 123 */ "ordering_specification_opt", + /* 124 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -720,67 +729,70 @@ static const char *const yyRuleName[] = { /* 71 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", /* 72 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", /* 73 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 74 */ "join_type ::= INNER", - /* 75 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 76 */ "set_quantifier_opt ::=", - /* 77 */ "set_quantifier_opt ::= DISTINCT", - /* 78 */ "set_quantifier_opt ::= ALL", - /* 79 */ "select_list ::= NK_STAR", - /* 80 */ "select_list ::= select_sublist", - /* 81 */ "select_sublist ::= select_item", - /* 82 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 83 */ "select_item ::= expression", - /* 84 */ "select_item ::= expression column_alias", - /* 85 */ "select_item ::= expression AS column_alias", - /* 86 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 87 */ "where_clause_opt ::=", - /* 88 */ "where_clause_opt ::= WHERE search_condition", - /* 89 */ "partition_by_clause_opt ::=", - /* 90 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 91 */ "twindow_clause_opt ::=", - /* 92 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP", - /* 93 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", - /* 94 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 95 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 96 */ "sliding_opt ::=", - /* 97 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 98 */ "fill_opt ::=", - /* 99 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 100 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 101 */ "fill_mode ::= NONE", - /* 102 */ "fill_mode ::= PREV", - /* 103 */ "fill_mode ::= NULL", - /* 104 */ "fill_mode ::= LINEAR", - /* 105 */ "fill_mode ::= NEXT", - /* 106 */ "group_by_clause_opt ::=", - /* 107 */ "group_by_clause_opt ::= GROUP BY expression_list", - /* 108 */ "having_clause_opt ::=", - /* 109 */ "having_clause_opt ::= HAVING search_condition", - /* 110 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 111 */ "query_expression_body ::= query_primary", - /* 112 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 113 */ "query_primary ::= query_specification", - /* 114 */ "order_by_clause_opt ::=", - /* 115 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 116 */ "slimit_clause_opt ::=", - /* 117 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 118 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 119 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 120 */ "limit_clause_opt ::=", - /* 121 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 122 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 123 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 124 */ "subquery ::= NK_LP query_expression NK_RP", - /* 125 */ "search_condition ::= boolean_value_expression", - /* 126 */ "sort_specification_list ::= sort_specification", - /* 127 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 128 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 129 */ "ordering_specification_opt ::=", - /* 130 */ "ordering_specification_opt ::= ASC", - /* 131 */ "ordering_specification_opt ::= DESC", - /* 132 */ "null_ordering_opt ::=", - /* 133 */ "null_ordering_opt ::= NULLS FIRST", - /* 134 */ "null_ordering_opt ::= NULLS LAST", + /* 74 */ "join_type ::=", + /* 75 */ "join_type ::= INNER", + /* 76 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 77 */ "set_quantifier_opt ::=", + /* 78 */ "set_quantifier_opt ::= DISTINCT", + /* 79 */ "set_quantifier_opt ::= ALL", + /* 80 */ "select_list ::= NK_STAR", + /* 81 */ "select_list ::= select_sublist", + /* 82 */ "select_sublist ::= select_item", + /* 83 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 84 */ "select_item ::= expression", + /* 85 */ "select_item ::= expression column_alias", + /* 86 */ "select_item ::= expression AS column_alias", + /* 87 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 88 */ "where_clause_opt ::=", + /* 89 */ "where_clause_opt ::= WHERE search_condition", + /* 90 */ "partition_by_clause_opt ::=", + /* 91 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 92 */ "twindow_clause_opt ::=", + /* 93 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP", + /* 94 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", + /* 95 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 96 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 97 */ "sliding_opt ::=", + /* 98 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 99 */ "fill_opt ::=", + /* 100 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 101 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 102 */ "fill_mode ::= NONE", + /* 103 */ "fill_mode ::= PREV", + /* 104 */ "fill_mode ::= NULL", + /* 105 */ "fill_mode ::= LINEAR", + /* 106 */ "fill_mode ::= NEXT", + /* 107 */ "group_by_clause_opt ::=", + /* 108 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 109 */ "group_by_list ::= expression", + /* 110 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 111 */ "having_clause_opt ::=", + /* 112 */ "having_clause_opt ::= HAVING search_condition", + /* 113 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 114 */ "query_expression_body ::= query_primary", + /* 115 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 116 */ "query_primary ::= query_specification", + /* 117 */ "order_by_clause_opt ::=", + /* 118 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 119 */ "slimit_clause_opt ::=", + /* 120 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 121 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 122 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 123 */ "limit_clause_opt ::=", + /* 124 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 125 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 126 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 127 */ "subquery ::= NK_LP query_expression NK_RP", + /* 128 */ "search_condition ::= boolean_value_expression", + /* 129 */ "sort_specification_list ::= sort_specification", + /* 130 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 131 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 132 */ "ordering_specification_opt ::=", + /* 133 */ "ordering_specification_opt ::= ASC", + /* 134 */ "ordering_specification_opt ::= DESC", + /* 135 */ "null_ordering_opt ::=", + /* 136 */ "null_ordering_opt ::= NULLS FIRST", + /* 137 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -932,13 +944,13 @@ static void yy_destructor( case 111: /* select_item */ case 112: /* sliding_opt */ case 113: /* fill_opt */ - case 115: /* query_expression_body */ - case 117: /* slimit_clause_opt */ - case 118: /* limit_clause_opt */ - case 119: /* query_primary */ - case 121: /* sort_specification */ + case 116: /* query_expression_body */ + case 118: /* slimit_clause_opt */ + case 119: /* limit_clause_opt */ + case 120: /* query_primary */ + case 122: /* sort_specification */ { - PARSER_DESTRUCTOR_TRACE; nodesDestroyNode((yypminor->yy168)); + PARSER_DESTRUCTOR_TRACE; nodesDestroyNode((yypminor->yy212)); } break; case 76: /* literal_list */ @@ -947,10 +959,11 @@ static void yy_destructor( case 106: /* partition_by_clause_opt */ case 108: /* group_by_clause_opt */ case 110: /* select_sublist */ - case 116: /* order_by_clause_opt */ - case 120: /* sort_specification_list */ + case 115: /* group_by_list */ + case 117: /* order_by_clause_opt */ + case 121: /* sort_specification_list */ { - PARSER_DESTRUCTOR_TRACE; nodesDestroyList((yypminor->yy192)); + PARSER_DESTRUCTOR_TRACE; nodesDestroyList((yypminor->yy174)); } break; case 77: /* db_name */ @@ -985,12 +998,12 @@ static void yy_destructor( PARSER_DESTRUCTOR_TRACE; } break; - case 122: /* ordering_specification_opt */ + case 123: /* ordering_specification_opt */ { PARSER_DESTRUCTOR_TRACE; } break; - case 123: /* null_ordering_opt */ + case 124: /* null_ordering_opt */ { PARSER_DESTRUCTOR_TRACE; } @@ -1363,67 +1376,70 @@ static const struct { { 99, -3 }, /* (71) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ { 99, -3 }, /* (72) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ { 97, -6 }, /* (73) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 100, -1 }, /* (74) join_type ::= INNER */ - { 102, -9 }, /* (75) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - { 103, 0 }, /* (76) set_quantifier_opt ::= */ - { 103, -1 }, /* (77) set_quantifier_opt ::= DISTINCT */ - { 103, -1 }, /* (78) set_quantifier_opt ::= ALL */ - { 104, -1 }, /* (79) select_list ::= NK_STAR */ - { 104, -1 }, /* (80) select_list ::= select_sublist */ - { 110, -1 }, /* (81) select_sublist ::= select_item */ - { 110, -3 }, /* (82) select_sublist ::= select_sublist NK_COMMA select_item */ - { 111, -1 }, /* (83) select_item ::= expression */ - { 111, -2 }, /* (84) select_item ::= expression column_alias */ - { 111, -3 }, /* (85) select_item ::= expression AS column_alias */ - { 111, -3 }, /* (86) select_item ::= table_name NK_DOT NK_STAR */ - { 105, 0 }, /* (87) where_clause_opt ::= */ - { 105, -2 }, /* (88) where_clause_opt ::= WHERE search_condition */ - { 106, 0 }, /* (89) partition_by_clause_opt ::= */ - { 106, -3 }, /* (90) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 107, 0 }, /* (91) twindow_clause_opt ::= */ - { 107, -6 }, /* (92) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ - { 107, -4 }, /* (93) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ - { 107, -6 }, /* (94) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 107, -8 }, /* (95) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 112, 0 }, /* (96) sliding_opt ::= */ - { 112, -4 }, /* (97) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 113, 0 }, /* (98) fill_opt ::= */ - { 113, -4 }, /* (99) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 113, -6 }, /* (100) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 114, -1 }, /* (101) fill_mode ::= NONE */ - { 114, -1 }, /* (102) fill_mode ::= PREV */ - { 114, -1 }, /* (103) fill_mode ::= NULL */ - { 114, -1 }, /* (104) fill_mode ::= LINEAR */ - { 114, -1 }, /* (105) fill_mode ::= NEXT */ - { 108, 0 }, /* (106) group_by_clause_opt ::= */ - { 108, -3 }, /* (107) group_by_clause_opt ::= GROUP BY expression_list */ - { 109, 0 }, /* (108) having_clause_opt ::= */ - { 109, -2 }, /* (109) having_clause_opt ::= HAVING search_condition */ - { 73, -4 }, /* (110) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 115, -1 }, /* (111) query_expression_body ::= query_primary */ - { 115, -4 }, /* (112) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 119, -1 }, /* (113) query_primary ::= query_specification */ - { 116, 0 }, /* (114) order_by_clause_opt ::= */ - { 116, -3 }, /* (115) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 117, 0 }, /* (116) slimit_clause_opt ::= */ - { 117, -2 }, /* (117) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 117, -4 }, /* (118) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 117, -4 }, /* (119) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 118, 0 }, /* (120) limit_clause_opt ::= */ - { 118, -2 }, /* (121) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 118, -4 }, /* (122) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 118, -4 }, /* (123) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 86, -3 }, /* (124) subquery ::= NK_LP query_expression NK_RP */ - { 101, -1 }, /* (125) search_condition ::= boolean_value_expression */ - { 120, -1 }, /* (126) sort_specification_list ::= sort_specification */ - { 120, -3 }, /* (127) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 121, -3 }, /* (128) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 122, 0 }, /* (129) ordering_specification_opt ::= */ - { 122, -1 }, /* (130) ordering_specification_opt ::= ASC */ - { 122, -1 }, /* (131) ordering_specification_opt ::= DESC */ - { 123, 0 }, /* (132) null_ordering_opt ::= */ - { 123, -2 }, /* (133) null_ordering_opt ::= NULLS FIRST */ - { 123, -2 }, /* (134) null_ordering_opt ::= NULLS LAST */ + { 100, 0 }, /* (74) join_type ::= */ + { 100, -1 }, /* (75) join_type ::= INNER */ + { 102, -9 }, /* (76) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + { 103, 0 }, /* (77) set_quantifier_opt ::= */ + { 103, -1 }, /* (78) set_quantifier_opt ::= DISTINCT */ + { 103, -1 }, /* (79) set_quantifier_opt ::= ALL */ + { 104, -1 }, /* (80) select_list ::= NK_STAR */ + { 104, -1 }, /* (81) select_list ::= select_sublist */ + { 110, -1 }, /* (82) select_sublist ::= select_item */ + { 110, -3 }, /* (83) select_sublist ::= select_sublist NK_COMMA select_item */ + { 111, -1 }, /* (84) select_item ::= expression */ + { 111, -2 }, /* (85) select_item ::= expression column_alias */ + { 111, -3 }, /* (86) select_item ::= expression AS column_alias */ + { 111, -3 }, /* (87) select_item ::= table_name NK_DOT NK_STAR */ + { 105, 0 }, /* (88) where_clause_opt ::= */ + { 105, -2 }, /* (89) where_clause_opt ::= WHERE search_condition */ + { 106, 0 }, /* (90) partition_by_clause_opt ::= */ + { 106, -3 }, /* (91) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 107, 0 }, /* (92) twindow_clause_opt ::= */ + { 107, -6 }, /* (93) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ + { 107, -4 }, /* (94) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ + { 107, -6 }, /* (95) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 107, -8 }, /* (96) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 112, 0 }, /* (97) sliding_opt ::= */ + { 112, -4 }, /* (98) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 113, 0 }, /* (99) fill_opt ::= */ + { 113, -4 }, /* (100) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 113, -6 }, /* (101) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 114, -1 }, /* (102) fill_mode ::= NONE */ + { 114, -1 }, /* (103) fill_mode ::= PREV */ + { 114, -1 }, /* (104) fill_mode ::= NULL */ + { 114, -1 }, /* (105) fill_mode ::= LINEAR */ + { 114, -1 }, /* (106) fill_mode ::= NEXT */ + { 108, 0 }, /* (107) group_by_clause_opt ::= */ + { 108, -3 }, /* (108) group_by_clause_opt ::= GROUP BY group_by_list */ + { 115, -1 }, /* (109) group_by_list ::= expression */ + { 115, -3 }, /* (110) group_by_list ::= group_by_list NK_COMMA expression */ + { 109, 0 }, /* (111) having_clause_opt ::= */ + { 109, -2 }, /* (112) having_clause_opt ::= HAVING search_condition */ + { 73, -4 }, /* (113) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 116, -1 }, /* (114) query_expression_body ::= query_primary */ + { 116, -4 }, /* (115) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 120, -1 }, /* (116) query_primary ::= query_specification */ + { 117, 0 }, /* (117) order_by_clause_opt ::= */ + { 117, -3 }, /* (118) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 118, 0 }, /* (119) slimit_clause_opt ::= */ + { 118, -2 }, /* (120) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 118, -4 }, /* (121) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 118, -4 }, /* (122) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 119, 0 }, /* (123) limit_clause_opt ::= */ + { 119, -2 }, /* (124) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 119, -4 }, /* (125) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 119, -4 }, /* (126) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 86, -3 }, /* (127) subquery ::= NK_LP query_expression NK_RP */ + { 101, -1 }, /* (128) search_condition ::= boolean_value_expression */ + { 121, -1 }, /* (129) sort_specification_list ::= sort_specification */ + { 121, -3 }, /* (130) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 122, -3 }, /* (131) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 123, 0 }, /* (132) ordering_specification_opt ::= */ + { 123, -1 }, /* (133) ordering_specification_opt ::= ASC */ + { 123, -1 }, /* (134) ordering_specification_opt ::= DESC */ + { 124, 0 }, /* (135) null_ordering_opt ::= */ + { 124, -2 }, /* (136) null_ordering_opt ::= NULLS FIRST */ + { 124, -2 }, /* (137) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -1514,27 +1530,27 @@ static YYACTIONTYPE yy_reduce( { PARSER_TRACE; createShowStmt(pCxt, SHOW_TYPE_DATABASE); } break; case 1: /* cmd ::= query_expression */ -{ PARSER_TRACE; pCxt->pRootNode = yymsp[0].minor.yy168; } +{ PARSER_TRACE; pCxt->pRootNode = yymsp[0].minor.yy212; } break; case 2: /* literal ::= NK_INTEGER */ -{ PARSER_TRACE; yylhsminor.yy168 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; case 3: /* literal ::= NK_FLOAT */ -{ PARSER_TRACE; yylhsminor.yy168 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; case 4: /* literal ::= NK_STRING */ -{ PARSER_TRACE; yylhsminor.yy168 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; case 5: /* literal ::= NK_BOOL */ -{ PARSER_TRACE; yylhsminor.yy168 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; case 6: /* literal ::= TIMESTAMP NK_STRING */ -{ PARSER_TRACE; yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy212 = yylhsminor.yy212; break; case 7: /* literal ::= duration_literal */ case 17: /* expression ::= literal */ yytestcase(yyruleno==17); @@ -1546,25 +1562,25 @@ static YYACTIONTYPE yy_reduce( case 62: /* table_reference ::= table_primary */ yytestcase(yyruleno==62); case 63: /* table_reference ::= joined_table */ yytestcase(yyruleno==63); case 67: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==67); - case 111: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==111); - case 113: /* query_primary ::= query_specification */ yytestcase(yyruleno==113); - case 125: /* search_condition ::= boolean_value_expression */ yytestcase(yyruleno==125); -{ PARSER_TRACE; yylhsminor.yy168 = yymsp[0].minor.yy168; } - yymsp[0].minor.yy168 = yylhsminor.yy168; + case 114: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==114); + case 116: /* query_primary ::= query_specification */ yytestcase(yyruleno==116); + case 128: /* search_condition ::= boolean_value_expression */ yytestcase(yyruleno==128); +{ PARSER_TRACE; yylhsminor.yy212 = yymsp[0].minor.yy212; } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; case 8: /* duration_literal ::= NK_VARIABLE */ -{ PARSER_TRACE; yylhsminor.yy168 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; case 9: /* literal_list ::= literal */ case 30: /* expression_list ::= expression */ yytestcase(yyruleno==30); -{ PARSER_TRACE; yylhsminor.yy192 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy168)); } - yymsp[0].minor.yy192 = yylhsminor.yy192; +{ PARSER_TRACE; yylhsminor.yy174 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy212)); } + yymsp[0].minor.yy174 = yylhsminor.yy174; break; case 10: /* literal_list ::= literal_list NK_COMMA literal */ case 31: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==31); -{ PARSER_TRACE; yylhsminor.yy192 = addNodeToList(pCxt, yymsp[-2].minor.yy192, releaseRawExprNode(pCxt, yymsp[0].minor.yy168)); } - yymsp[-2].minor.yy192 = yylhsminor.yy192; +{ PARSER_TRACE; yylhsminor.yy174 = addNodeToList(pCxt, yymsp[-2].minor.yy174, releaseRawExprNode(pCxt, yymsp[0].minor.yy212)); } + yymsp[-2].minor.yy174 = yylhsminor.yy174; break; case 11: /* db_name ::= NK_ID */ case 12: /* table_name ::= NK_ID */ yytestcase(yyruleno==12); @@ -1572,369 +1588,380 @@ static YYACTIONTYPE yy_reduce( case 14: /* function_name ::= NK_ID */ yytestcase(yyruleno==14); case 15: /* table_alias ::= NK_ID */ yytestcase(yyruleno==15); case 16: /* column_alias ::= NK_ID */ yytestcase(yyruleno==16); -{ PARSER_TRACE; yylhsminor.yy241 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy241 = yylhsminor.yy241; +{ PARSER_TRACE; yylhsminor.yy79 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy79 = yylhsminor.yy79; break; case 19: /* expression ::= function_name NK_LP expression_list NK_RP */ -{ PARSER_TRACE; yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy241, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy241, yymsp[-1].minor.yy192)); } - yymsp[-3].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy79, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy79, yymsp[-1].minor.yy174)); } + yymsp[-3].minor.yy212 = yylhsminor.yy212; break; case 20: /* expression ::= function_name NK_LP NK_STAR NK_RP */ -{ PARSER_TRACE; yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy241, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy241, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } - yymsp[-3].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy79, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy79, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } + yymsp[-3].minor.yy212 = yylhsminor.yy212; break; case 22: /* expression ::= NK_LP expression NK_RP */ -{ PARSER_TRACE; yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy168)); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy212)); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 23: /* expression ::= NK_PLUS expression */ { PARSER_TRACE; - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); - yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy168)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy212)); } - yymsp[-1].minor.yy168 = yylhsminor.yy168; + yymsp[-1].minor.yy212 = yylhsminor.yy212; break; case 24: /* expression ::= NK_MINUS expression */ { PARSER_TRACE; - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); - yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy168), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy212), NULL)); } - yymsp[-1].minor.yy168 = yylhsminor.yy168; + yymsp[-1].minor.yy212 = yylhsminor.yy212; break; case 25: /* expression ::= expression NK_PLUS expression */ { PARSER_TRACE; - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); - yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy212); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), releaseRawExprNode(pCxt, yymsp[0].minor.yy212))); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 26: /* expression ::= expression NK_MINUS expression */ { PARSER_TRACE; - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); - yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy212); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), releaseRawExprNode(pCxt, yymsp[0].minor.yy212))); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 27: /* expression ::= expression NK_STAR expression */ { PARSER_TRACE; - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); - yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy212); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), releaseRawExprNode(pCxt, yymsp[0].minor.yy212))); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 28: /* expression ::= expression NK_SLASH expression */ { PARSER_TRACE; - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); - yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy212); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), releaseRawExprNode(pCxt, yymsp[0].minor.yy212))); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 29: /* expression ::= expression NK_REM expression */ { PARSER_TRACE; - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy168); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); - yylhsminor.yy168 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy212); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), releaseRawExprNode(pCxt, yymsp[0].minor.yy212))); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 32: /* column_reference ::= column_name */ -{ PARSER_TRACE; yylhsminor.yy168 = createRawExprNode(pCxt, &yymsp[0].minor.yy241, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy241)); } - yymsp[0].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createRawExprNode(pCxt, &yymsp[0].minor.yy79, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy79)); } + yymsp[0].minor.yy212 = yylhsminor.yy212; break; case 33: /* column_reference ::= table_name NK_DOT column_name */ -{ PARSER_TRACE; yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241, createColumnNode(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy241)); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy79, &yymsp[0].minor.yy79, createColumnNode(pCxt, &yymsp[-2].minor.yy79, &yymsp[0].minor.yy79)); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 34: /* predicate ::= expression compare_op expression */ -{ PARSER_TRACE; yylhsminor.yy168 = createOperatorNode(pCxt, yymsp[-1].minor.yy228, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168)); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createOperatorNode(pCxt, yymsp[-1].minor.yy40, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), releaseRawExprNode(pCxt, yymsp[0].minor.yy212)); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 35: /* predicate ::= expression BETWEEN expression AND expression */ -{ PARSER_TRACE; yylhsminor.yy168 = createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy168), releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168)); } - yymsp[-4].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy212), releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), releaseRawExprNode(pCxt, yymsp[0].minor.yy212)); } + yymsp[-4].minor.yy212 = yylhsminor.yy212; break; case 36: /* predicate ::= expression NOT BETWEEN expression AND expression */ -{ PARSER_TRACE; yylhsminor.yy168 = createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), releaseRawExprNode(pCxt, yymsp[-5].minor.yy168), releaseRawExprNode(pCxt, yymsp[0].minor.yy168)); } - yymsp[-5].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), releaseRawExprNode(pCxt, yymsp[-5].minor.yy212), releaseRawExprNode(pCxt, yymsp[0].minor.yy212)); } + yymsp[-5].minor.yy212 = yylhsminor.yy212; break; case 37: /* predicate ::= expression IS NULL */ -{ PARSER_TRACE; yylhsminor.yy168 = createIsNullCondNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), true); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createIsNullCondNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), true); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 38: /* predicate ::= expression IS NOT NULL */ -{ PARSER_TRACE; yylhsminor.yy168 = createIsNullCondNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy168), false); } - yymsp[-3].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createIsNullCondNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy212), false); } + yymsp[-3].minor.yy212 = yylhsminor.yy212; break; case 39: /* predicate ::= expression in_op in_predicate_value */ -{ PARSER_TRACE; yylhsminor.yy168 = createOperatorNode(pCxt, yymsp[-1].minor.yy228, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), yymsp[0].minor.yy168); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createOperatorNode(pCxt, yymsp[-1].minor.yy40, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), yymsp[0].minor.yy212); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 40: /* compare_op ::= NK_LT */ -{ PARSER_TRACE; yymsp[0].minor.yy228 = OP_TYPE_LOWER_THAN; } +{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_LOWER_THAN; } break; case 41: /* compare_op ::= NK_GT */ -{ PARSER_TRACE; yymsp[0].minor.yy228 = OP_TYPE_GREATER_THAN; } +{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_GREATER_THAN; } break; case 42: /* compare_op ::= NK_LE */ -{ PARSER_TRACE; yymsp[0].minor.yy228 = OP_TYPE_LOWER_EQUAL; } +{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_LOWER_EQUAL; } break; case 43: /* compare_op ::= NK_GE */ -{ PARSER_TRACE; yymsp[0].minor.yy228 = OP_TYPE_GREATER_EQUAL; } +{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_GREATER_EQUAL; } break; case 44: /* compare_op ::= NK_NE */ -{ PARSER_TRACE; yymsp[0].minor.yy228 = OP_TYPE_NOT_EQUAL; } +{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_NOT_EQUAL; } break; case 45: /* compare_op ::= NK_EQ */ -{ PARSER_TRACE; yymsp[0].minor.yy228 = OP_TYPE_EQUAL; } +{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_EQUAL; } break; case 46: /* compare_op ::= LIKE */ -{ PARSER_TRACE; yymsp[0].minor.yy228 = OP_TYPE_LIKE; } +{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_LIKE; } break; case 47: /* compare_op ::= NOT LIKE */ -{ PARSER_TRACE; yymsp[-1].minor.yy228 = OP_TYPE_NOT_LIKE; } +{ PARSER_TRACE; yymsp[-1].minor.yy40 = OP_TYPE_NOT_LIKE; } break; case 48: /* compare_op ::= MATCH */ -{ PARSER_TRACE; yymsp[0].minor.yy228 = OP_TYPE_MATCH; } +{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_MATCH; } break; case 49: /* compare_op ::= NMATCH */ -{ PARSER_TRACE; yymsp[0].minor.yy228 = OP_TYPE_NMATCH; } +{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_NMATCH; } break; case 50: /* in_op ::= IN */ -{ PARSER_TRACE; yymsp[0].minor.yy228 = OP_TYPE_IN; } +{ PARSER_TRACE; yymsp[0].minor.yy40 = OP_TYPE_IN; } break; case 51: /* in_op ::= NOT IN */ -{ PARSER_TRACE; yymsp[-1].minor.yy228 = OP_TYPE_NOT_IN; } +{ PARSER_TRACE; yymsp[-1].minor.yy40 = OP_TYPE_NOT_IN; } break; case 52: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ PARSER_TRACE; yymsp[-2].minor.yy168 = createNodeListNode(pCxt, yymsp[-1].minor.yy192); } +{ PARSER_TRACE; yymsp[-2].minor.yy212 = createNodeListNode(pCxt, yymsp[-1].minor.yy174); } break; case 54: /* boolean_value_expression ::= NOT boolean_primary */ -{ PARSER_TRACE; yymsp[-1].minor.yy168 = createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, yymsp[0].minor.yy168, NULL); } +{ PARSER_TRACE; yymsp[-1].minor.yy212 = createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, yymsp[0].minor.yy212, NULL); } break; case 55: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ -{ PARSER_TRACE; yylhsminor.yy168 = createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 56: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ -{ PARSER_TRACE; yylhsminor.yy168 = createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 58: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ case 71: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ yytestcase(yyruleno==71); case 72: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==72); -{ PARSER_TRACE; yymsp[-2].minor.yy168 = yymsp[-1].minor.yy168; } +{ PARSER_TRACE; yymsp[-2].minor.yy212 = yymsp[-1].minor.yy212; } break; case 59: /* from_clause ::= FROM table_reference_list */ - case 88: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==88); - case 109: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==109); -{ PARSER_TRACE; yymsp[-1].minor.yy168 = yymsp[0].minor.yy168; } + case 89: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==89); + case 112: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==112); +{ PARSER_TRACE; yymsp[-1].minor.yy212 = yymsp[0].minor.yy212; } break; case 61: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ PARSER_TRACE; yylhsminor.yy168 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy168, yymsp[0].minor.yy168, NULL); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy212, yymsp[0].minor.yy212, NULL); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; case 64: /* table_primary ::= table_name alias_opt */ -{ PARSER_TRACE; yylhsminor.yy168 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy241, &yymsp[0].minor.yy241); } - yymsp[-1].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy79, &yymsp[0].minor.yy79); } + yymsp[-1].minor.yy212 = yylhsminor.yy212; break; case 65: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ PARSER_TRACE; yylhsminor.yy168 = createRealTableNode(pCxt, &yymsp[-3].minor.yy241, &yymsp[-1].minor.yy241, &yymsp[0].minor.yy241); } - yymsp[-3].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createRealTableNode(pCxt, &yymsp[-3].minor.yy79, &yymsp[-1].minor.yy79, &yymsp[0].minor.yy79); } + yymsp[-3].minor.yy212 = yylhsminor.yy212; break; case 66: /* table_primary ::= subquery alias_opt */ -{ PARSER_TRACE; yylhsminor.yy168 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy168), &yymsp[0].minor.yy241); } - yymsp[-1].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy212), &yymsp[0].minor.yy79); } + yymsp[-1].minor.yy212 = yylhsminor.yy212; break; case 68: /* alias_opt ::= */ -{ PARSER_TRACE; yymsp[1].minor.yy241 = nil_token; } +{ PARSER_TRACE; yymsp[1].minor.yy79 = nil_token; } break; case 69: /* alias_opt ::= table_alias */ -{ PARSER_TRACE; yylhsminor.yy241 = yymsp[0].minor.yy241; } - yymsp[0].minor.yy241 = yylhsminor.yy241; +{ PARSER_TRACE; yylhsminor.yy79 = yymsp[0].minor.yy79; } + yymsp[0].minor.yy79 = yylhsminor.yy79; break; case 70: /* alias_opt ::= AS table_alias */ -{ PARSER_TRACE; yymsp[-1].minor.yy241 = yymsp[0].minor.yy241; } +{ PARSER_TRACE; yymsp[-1].minor.yy79 = yymsp[0].minor.yy79; } break; case 73: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ PARSER_TRACE; yylhsminor.yy168 = createJoinTableNode(pCxt, yymsp[-4].minor.yy229, yymsp[-5].minor.yy168, yymsp[-2].minor.yy168, yymsp[0].minor.yy168); } - yymsp[-5].minor.yy168 = yylhsminor.yy168; +{ PARSER_TRACE; yylhsminor.yy212 = createJoinTableNode(pCxt, yymsp[-4].minor.yy162, yymsp[-5].minor.yy212, yymsp[-2].minor.yy212, yymsp[0].minor.yy212); } + yymsp[-5].minor.yy212 = yylhsminor.yy212; break; - case 74: /* join_type ::= INNER */ -{ PARSER_TRACE; yymsp[0].minor.yy229 = JOIN_TYPE_INNER; } + case 74: /* join_type ::= */ +{ PARSER_TRACE; yymsp[1].minor.yy162 = JOIN_TYPE_INNER; } break; - case 75: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 75: /* join_type ::= INNER */ +{ PARSER_TRACE; yymsp[0].minor.yy162 = JOIN_TYPE_INNER; } + break; + case 76: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { PARSER_TRACE; - yymsp[-8].minor.yy168 = createSelectStmt(pCxt, yymsp[-7].minor.yy209, yymsp[-6].minor.yy192, yymsp[-5].minor.yy168); - yymsp[-8].minor.yy168 = addWhereClause(pCxt, yymsp[-8].minor.yy168, yymsp[-4].minor.yy168); - yymsp[-8].minor.yy168 = addPartitionByClause(pCxt, yymsp[-8].minor.yy168, yymsp[-3].minor.yy192); - yymsp[-8].minor.yy168 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy168, yymsp[-2].minor.yy168); - yymsp[-8].minor.yy168 = addGroupByClause(pCxt, yymsp[-8].minor.yy168, yymsp[-1].minor.yy192); - yymsp[-8].minor.yy168 = addHavingClause(pCxt, yymsp[-8].minor.yy168, yymsp[0].minor.yy168); + yymsp[-8].minor.yy212 = createSelectStmt(pCxt, yymsp[-7].minor.yy237, yymsp[-6].minor.yy174, yymsp[-5].minor.yy212); + yymsp[-8].minor.yy212 = addWhereClause(pCxt, yymsp[-8].minor.yy212, yymsp[-4].minor.yy212); + yymsp[-8].minor.yy212 = addPartitionByClause(pCxt, yymsp[-8].minor.yy212, yymsp[-3].minor.yy174); + yymsp[-8].minor.yy212 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy212, yymsp[-2].minor.yy212); + yymsp[-8].minor.yy212 = addGroupByClause(pCxt, yymsp[-8].minor.yy212, yymsp[-1].minor.yy174); + yymsp[-8].minor.yy212 = addHavingClause(pCxt, yymsp[-8].minor.yy212, yymsp[0].minor.yy212); } break; - case 76: /* set_quantifier_opt ::= */ -{ PARSER_TRACE; yymsp[1].minor.yy209 = false; } + case 77: /* set_quantifier_opt ::= */ +{ PARSER_TRACE; yymsp[1].minor.yy237 = false; } break; - case 77: /* set_quantifier_opt ::= DISTINCT */ -{ PARSER_TRACE; yymsp[0].minor.yy209 = true; } + case 78: /* set_quantifier_opt ::= DISTINCT */ +{ PARSER_TRACE; yymsp[0].minor.yy237 = true; } break; - case 78: /* set_quantifier_opt ::= ALL */ -{ PARSER_TRACE; yymsp[0].minor.yy209 = false; } + case 79: /* set_quantifier_opt ::= ALL */ +{ PARSER_TRACE; yymsp[0].minor.yy237 = false; } break; - case 79: /* select_list ::= NK_STAR */ -{ PARSER_TRACE; yymsp[0].minor.yy192 = NULL; } + case 80: /* select_list ::= NK_STAR */ +{ PARSER_TRACE; yymsp[0].minor.yy174 = NULL; } break; - case 80: /* select_list ::= select_sublist */ -{ PARSER_TRACE; yylhsminor.yy192 = yymsp[0].minor.yy192; } - yymsp[0].minor.yy192 = yylhsminor.yy192; + case 81: /* select_list ::= select_sublist */ +{ PARSER_TRACE; yylhsminor.yy174 = yymsp[0].minor.yy174; } + yymsp[0].minor.yy174 = yylhsminor.yy174; break; - case 81: /* select_sublist ::= select_item */ - case 126: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==126); -{ PARSER_TRACE; yylhsminor.yy192 = createNodeList(pCxt, yymsp[0].minor.yy168); } - yymsp[0].minor.yy192 = yylhsminor.yy192; + case 82: /* select_sublist ::= select_item */ + case 129: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==129); +{ PARSER_TRACE; yylhsminor.yy174 = createNodeList(pCxt, yymsp[0].minor.yy212); } + yymsp[0].minor.yy174 = yylhsminor.yy174; break; - case 82: /* select_sublist ::= select_sublist NK_COMMA select_item */ - case 127: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==127); -{ PARSER_TRACE; yylhsminor.yy192 = addNodeToList(pCxt, yymsp[-2].minor.yy192, yymsp[0].minor.yy168); } - yymsp[-2].minor.yy192 = yylhsminor.yy192; + case 83: /* select_sublist ::= select_sublist NK_COMMA select_item */ + case 130: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==130); +{ PARSER_TRACE; yylhsminor.yy174 = addNodeToList(pCxt, yymsp[-2].minor.yy174, yymsp[0].minor.yy212); } + yymsp[-2].minor.yy174 = yylhsminor.yy174; break; - case 83: /* select_item ::= expression */ + case 84: /* select_item ::= expression */ { PARSER_TRACE; - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy168); - yylhsminor.yy168 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy168), &t); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy212); + yylhsminor.yy212 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy212), &t); } - yymsp[0].minor.yy168 = yylhsminor.yy168; + yymsp[0].minor.yy212 = yylhsminor.yy212; + break; + case 85: /* select_item ::= expression column_alias */ +{ PARSER_TRACE; yylhsminor.yy212 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy212), &yymsp[0].minor.yy79); } + yymsp[-1].minor.yy212 = yylhsminor.yy212; + break; + case 86: /* select_item ::= expression AS column_alias */ +{ PARSER_TRACE; yylhsminor.yy212 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), &yymsp[0].minor.yy79); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 84: /* select_item ::= expression column_alias */ -{ PARSER_TRACE; yylhsminor.yy168 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy168), &yymsp[0].minor.yy241); } - yymsp[-1].minor.yy168 = yylhsminor.yy168; + case 87: /* select_item ::= table_name NK_DOT NK_STAR */ +{ PARSER_TRACE; yylhsminor.yy212 = createColumnNode(pCxt, &yymsp[-2].minor.yy79, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 85: /* select_item ::= expression AS column_alias */ -{ PARSER_TRACE; yylhsminor.yy168 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), &yymsp[0].minor.yy241); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 88: /* where_clause_opt ::= */ + case 92: /* twindow_clause_opt ::= */ yytestcase(yyruleno==92); + case 97: /* sliding_opt ::= */ yytestcase(yyruleno==97); + case 99: /* fill_opt ::= */ yytestcase(yyruleno==99); + case 111: /* having_clause_opt ::= */ yytestcase(yyruleno==111); + case 119: /* slimit_clause_opt ::= */ yytestcase(yyruleno==119); + case 123: /* limit_clause_opt ::= */ yytestcase(yyruleno==123); +{ PARSER_TRACE; yymsp[1].minor.yy212 = NULL; } break; - case 86: /* select_item ::= table_name NK_DOT NK_STAR */ -{ PARSER_TRACE; yylhsminor.yy168 = createColumnNode(pCxt, &yymsp[-2].minor.yy241, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 90: /* partition_by_clause_opt ::= */ + case 107: /* group_by_clause_opt ::= */ yytestcase(yyruleno==107); + case 117: /* order_by_clause_opt ::= */ yytestcase(yyruleno==117); +{ PARSER_TRACE; yymsp[1].minor.yy174 = NULL; } break; - case 87: /* where_clause_opt ::= */ - case 91: /* twindow_clause_opt ::= */ yytestcase(yyruleno==91); - case 96: /* sliding_opt ::= */ yytestcase(yyruleno==96); - case 98: /* fill_opt ::= */ yytestcase(yyruleno==98); - case 108: /* having_clause_opt ::= */ yytestcase(yyruleno==108); - case 116: /* slimit_clause_opt ::= */ yytestcase(yyruleno==116); - case 120: /* limit_clause_opt ::= */ yytestcase(yyruleno==120); -{ PARSER_TRACE; yymsp[1].minor.yy168 = NULL; } + case 91: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 108: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==108); + case 118: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==118); +{ PARSER_TRACE; yymsp[-2].minor.yy174 = yymsp[0].minor.yy174; } break; - case 89: /* partition_by_clause_opt ::= */ - case 106: /* group_by_clause_opt ::= */ yytestcase(yyruleno==106); - case 114: /* order_by_clause_opt ::= */ yytestcase(yyruleno==114); -{ PARSER_TRACE; yymsp[1].minor.yy192 = NULL; } + case 93: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ +{ PARSER_TRACE; yymsp[-5].minor.yy212 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy212), &yymsp[-1].minor.yy0); } break; - case 90: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 107: /* group_by_clause_opt ::= GROUP BY expression_list */ yytestcase(yyruleno==107); - case 115: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==115); -{ PARSER_TRACE; yymsp[-2].minor.yy192 = yymsp[0].minor.yy192; } + case 94: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ +{ PARSER_TRACE; yymsp[-3].minor.yy212 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy212)); } break; - case 92: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ -{ PARSER_TRACE; yymsp[-5].minor.yy168 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy168), &yymsp[-1].minor.yy0); } + case 95: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ PARSER_TRACE; yymsp[-5].minor.yy212 = createIntervalWindowNode(pCxt, yymsp[-3].minor.yy212, NULL, yymsp[-1].minor.yy212, yymsp[0].minor.yy212); } break; - case 93: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ -{ PARSER_TRACE; yymsp[-3].minor.yy168 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy168)); } + case 96: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ PARSER_TRACE; yymsp[-7].minor.yy212 = createIntervalWindowNode(pCxt, yymsp[-5].minor.yy212, yymsp[-3].minor.yy212, yymsp[-1].minor.yy212, yymsp[0].minor.yy212); } break; - case 94: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ PARSER_TRACE; yymsp[-5].minor.yy168 = createIntervalWindowNode(pCxt, yymsp[-3].minor.yy168, NULL, yymsp[-1].minor.yy168, yymsp[0].minor.yy168); } + case 98: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ +{ PARSER_TRACE; yymsp[-3].minor.yy212 = yymsp[-1].minor.yy212; } break; - case 95: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ PARSER_TRACE; yymsp[-7].minor.yy168 = createIntervalWindowNode(pCxt, yymsp[-5].minor.yy168, yymsp[-3].minor.yy168, yymsp[-1].minor.yy168, yymsp[0].minor.yy168); } + case 100: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ PARSER_TRACE; yymsp[-3].minor.yy212 = createFillNode(pCxt, yymsp[-1].minor.yy44, NULL); } break; - case 97: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ -{ PARSER_TRACE; yymsp[-3].minor.yy168 = yymsp[-1].minor.yy168; } + case 101: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ PARSER_TRACE; yymsp[-5].minor.yy212 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy174)); } break; - case 99: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ PARSER_TRACE; yymsp[-3].minor.yy168 = createFillNode(pCxt, yymsp[-1].minor.yy14, NULL); } + case 102: /* fill_mode ::= NONE */ +{ PARSER_TRACE; yymsp[0].minor.yy44 = FILL_MODE_NONE; } break; - case 100: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ PARSER_TRACE; yymsp[-5].minor.yy168 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy192)); } + case 103: /* fill_mode ::= PREV */ +{ PARSER_TRACE; yymsp[0].minor.yy44 = FILL_MODE_PREV; } break; - case 101: /* fill_mode ::= NONE */ -{ PARSER_TRACE; yymsp[0].minor.yy14 = FILL_MODE_NONE; } + case 104: /* fill_mode ::= NULL */ +{ PARSER_TRACE; yymsp[0].minor.yy44 = FILL_MODE_NULL; } break; - case 102: /* fill_mode ::= PREV */ -{ PARSER_TRACE; yymsp[0].minor.yy14 = FILL_MODE_PREV; } + case 105: /* fill_mode ::= LINEAR */ +{ PARSER_TRACE; yymsp[0].minor.yy44 = FILL_MODE_LINEAR; } break; - case 103: /* fill_mode ::= NULL */ -{ PARSER_TRACE; yymsp[0].minor.yy14 = FILL_MODE_NULL; } + case 106: /* fill_mode ::= NEXT */ +{ PARSER_TRACE; yymsp[0].minor.yy44 = FILL_MODE_NEXT; } break; - case 104: /* fill_mode ::= LINEAR */ -{ PARSER_TRACE; yymsp[0].minor.yy14 = FILL_MODE_LINEAR; } + case 109: /* group_by_list ::= expression */ +{ PARSER_TRACE; yylhsminor.yy174 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy212))); } + yymsp[0].minor.yy174 = yylhsminor.yy174; break; - case 105: /* fill_mode ::= NEXT */ -{ PARSER_TRACE; yymsp[0].minor.yy14 = FILL_MODE_NEXT; } + case 110: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ PARSER_TRACE; yylhsminor.yy174 = addNodeToList(pCxt, yymsp[-2].minor.yy174, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy212))); } + yymsp[-2].minor.yy174 = yylhsminor.yy174; break; - case 110: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 113: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { PARSER_TRACE; - yylhsminor.yy168 = addOrderByClause(pCxt, yymsp[-3].minor.yy168, yymsp[-2].minor.yy192); - yylhsminor.yy168 = addSlimitClause(pCxt, yylhsminor.yy168, yymsp[-1].minor.yy168); - yylhsminor.yy168 = addLimitClause(pCxt, yylhsminor.yy168, yymsp[0].minor.yy168); + yylhsminor.yy212 = addOrderByClause(pCxt, yymsp[-3].minor.yy212, yymsp[-2].minor.yy174); + yylhsminor.yy212 = addSlimitClause(pCxt, yylhsminor.yy212, yymsp[-1].minor.yy212); + yylhsminor.yy212 = addLimitClause(pCxt, yylhsminor.yy212, yymsp[0].minor.yy212); } - yymsp[-3].minor.yy168 = yylhsminor.yy168; + yymsp[-3].minor.yy212 = yylhsminor.yy212; break; - case 112: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ PARSER_TRACE; yylhsminor.yy168 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy168, yymsp[0].minor.yy168); } - yymsp[-3].minor.yy168 = yylhsminor.yy168; + case 115: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ PARSER_TRACE; yylhsminor.yy212 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy212, yymsp[0].minor.yy212); } + yymsp[-3].minor.yy212 = yylhsminor.yy212; break; - case 117: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 121: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==121); -{ PARSER_TRACE; yymsp[-1].minor.yy168 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 120: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 124: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==124); +{ PARSER_TRACE; yymsp[-1].minor.yy212 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 118: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 122: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==122); -{ PARSER_TRACE; yymsp[-3].minor.yy168 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 121: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 125: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==125); +{ PARSER_TRACE; yymsp[-3].minor.yy212 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 119: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 123: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==123); -{ PARSER_TRACE; yymsp[-3].minor.yy168 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 122: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 126: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==126); +{ PARSER_TRACE; yymsp[-3].minor.yy212 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 124: /* subquery ::= NK_LP query_expression NK_RP */ -{ PARSER_TRACE; yylhsminor.yy168 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy168); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 127: /* subquery ::= NK_LP query_expression NK_RP */ +{ PARSER_TRACE; yylhsminor.yy212 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy212); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 128: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ PARSER_TRACE; yylhsminor.yy168 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy168), yymsp[-1].minor.yy10, yymsp[0].minor.yy177); } - yymsp[-2].minor.yy168 = yylhsminor.yy168; + case 131: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ PARSER_TRACE; yylhsminor.yy212 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy212), yymsp[-1].minor.yy188, yymsp[0].minor.yy107); } + yymsp[-2].minor.yy212 = yylhsminor.yy212; break; - case 129: /* ordering_specification_opt ::= */ -{ PARSER_TRACE; yymsp[1].minor.yy10 = ORDER_ASC; } + case 132: /* ordering_specification_opt ::= */ +{ PARSER_TRACE; yymsp[1].minor.yy188 = ORDER_ASC; } break; - case 130: /* ordering_specification_opt ::= ASC */ -{ PARSER_TRACE; yymsp[0].minor.yy10 = ORDER_ASC; } + case 133: /* ordering_specification_opt ::= ASC */ +{ PARSER_TRACE; yymsp[0].minor.yy188 = ORDER_ASC; } break; - case 131: /* ordering_specification_opt ::= DESC */ -{ PARSER_TRACE; yymsp[0].minor.yy10 = ORDER_DESC; } + case 134: /* ordering_specification_opt ::= DESC */ +{ PARSER_TRACE; yymsp[0].minor.yy188 = ORDER_DESC; } break; - case 132: /* null_ordering_opt ::= */ -{ PARSER_TRACE; yymsp[1].minor.yy177 = NULL_ORDER_DEFAULT; } + case 135: /* null_ordering_opt ::= */ +{ PARSER_TRACE; yymsp[1].minor.yy107 = NULL_ORDER_DEFAULT; } break; - case 133: /* null_ordering_opt ::= NULLS FIRST */ -{ PARSER_TRACE; yymsp[-1].minor.yy177 = NULL_ORDER_FIRST; } + case 136: /* null_ordering_opt ::= NULLS FIRST */ +{ PARSER_TRACE; yymsp[-1].minor.yy107 = NULL_ORDER_FIRST; } break; - case 134: /* null_ordering_opt ::= NULLS LAST */ -{ PARSER_TRACE; yymsp[-1].minor.yy177 = NULL_ORDER_LAST; } + case 137: /* null_ordering_opt ::= NULLS LAST */ +{ PARSER_TRACE; yymsp[-1].minor.yy107 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/src/parserImpl.c b/source/libs/parser/src/parserImpl.c index dede1510043c5704656aa796d6d12f2e837e3973..85554d62a69d0cbe515ccc50a6e276280c0ab567 100644 --- a/source/libs/parser/src/parserImpl.c +++ b/source/libs/parser/src/parserImpl.c @@ -116,10 +116,6 @@ static uint32_t toNewTokenId(uint32_t tokenId) { return NEW_TK_FROM; case TK_JOIN: return NEW_TK_JOIN; - // case TK_ON: - // return NEW_TK_ON; - // case TK_INNER: - // return NEW_TK_INNER; // case TK_PARTITION: // return NEW_TK_PARTITION; case TK_SESSION: @@ -163,6 +159,8 @@ static uint32_t toNewTokenId(uint32_t tokenId) { case TK_OFFSET: return NEW_TK_OFFSET; case TK_SPACE: + case NEW_TK_ON: + case NEW_TK_INNER: break; default: printf("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!tokenId = %d\n", tokenId); @@ -248,6 +246,10 @@ typedef enum ESqlClause { } ESqlClause; static bool afterGroupBy(ESqlClause clause) { + return clause > SQL_CLAUSE_GROUP_BY; +} + +static bool beforeHaving(ESqlClause clause) { return clause < SQL_CLAUSE_HAVING; } @@ -259,7 +261,7 @@ typedef struct STranslateContext { SArray* pNsLevel; // element is SArray*, the element of this subarray is STableNode* int32_t currLevel; ESqlClause currClause; - void* pExt; + SSelectStmt* pCurrStmt; } STranslateContext; static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode); @@ -284,6 +286,8 @@ static char* getSyntaxErrFormat(int32_t errCode) { return "There mustn't be aggregation"; case TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT: return "ORDER BY item must be the number of a SELECT-list expression"; + case TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION: + return "Not a GROUP BY expression"; default: return "Unknown error"; } @@ -415,7 +419,7 @@ static bool findAndSetColumn(SColumnNode* pCol, const STableNode* pTable) { return found; } -static bool translateColumnWithPrefix(STranslateContext* pCxt, SColumnNode* pCol) { +static EDealRes translateColumnWithPrefix(STranslateContext* pCxt, SColumnNode* pCol) { SArray* pTables = taosArrayGetP(pCxt->pNsLevel, pCxt->currLevel); size_t nums = taosArrayGetSize(pTables); for (size_t i = 0; i < nums; ++i) { @@ -425,13 +429,13 @@ static bool translateColumnWithPrefix(STranslateContext* pCxt, SColumnNode* pCol break; } generateSyntaxErrMsg(pCxt, TSDB_CODE_PAR_INVALID_COLUMN, pCol->colName); - return false; + return DEAL_RES_ERROR; } } - return true; + return DEAL_RES_CONTINUE; } -static bool translateColumnWithoutPrefix(STranslateContext* pCxt, SColumnNode* pCol) { +static EDealRes translateColumnWithoutPrefix(STranslateContext* pCxt, SColumnNode* pCol) { SArray* pTables = taosArrayGetP(pCxt->pNsLevel, pCxt->currLevel); size_t nums = taosArrayGetSize(pTables); bool found = false; @@ -440,20 +444,20 @@ static bool translateColumnWithoutPrefix(STranslateContext* pCxt, SColumnNode* p if (findAndSetColumn(pCol, pTable)) { if (found) { generateSyntaxErrMsg(pCxt, TSDB_CODE_PAR_AMBIGUOUS_COLUMN, pCol->colName); - return false; + return DEAL_RES_ERROR; } found = true; } } if (!found) { generateSyntaxErrMsg(pCxt, TSDB_CODE_PAR_INVALID_COLUMN, pCol->colName); - return false; + return DEAL_RES_ERROR; } - return true; + return DEAL_RES_CONTINUE; } static bool translateColumnUseAlias(STranslateContext* pCxt, SColumnNode* pCol) { - SNodeList* pProjectionList = pCxt->pExt; + SNodeList* pProjectionList = pCxt->pCurrStmt->pProjectionList; SNode* pNode; FOREACH(pNode, pProjectionList) { SExprNode* pExpr = (SExprNode*)pNode; @@ -465,10 +469,10 @@ static bool translateColumnUseAlias(STranslateContext* pCxt, SColumnNode* pCol) return false; } -static bool translateColumn(STranslateContext* pCxt, SColumnNode* pCol) { +static EDealRes translateColumn(STranslateContext* pCxt, SColumnNode* pCol) { // count(*)/first(*)/last(*) if (0 == strcmp(pCol->colName, "*")) { - return true; + return DEAL_RES_CONTINUE; } if ('\0' != pCol->tableAlias[0]) { return translateColumnWithPrefix(pCxt, pCol); @@ -477,7 +481,7 @@ static bool translateColumn(STranslateContext* pCxt, SColumnNode* pCol) { if (SQL_CLAUSE_ORDER_BY == pCxt->currClause) { found = translateColumnUseAlias(pCxt, pCol); } - return found ? true : translateColumnWithoutPrefix(pCxt, pCol); + return found ? DEAL_RES_CONTINUE : translateColumnWithoutPrefix(pCxt, pCol); } static int32_t trimStringCopy(const char* src, int32_t len, char* dst) { @@ -500,12 +504,12 @@ static int32_t trimStringCopy(const char* src, int32_t len, char* dst) { return j; } -static bool translateValue(STranslateContext* pCxt, SValueNode* pVal) { +static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) { if (pVal->isDuration) { char unit = 0; if (parseAbsoluteDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &unit, pVal->node.resType.precision) != TSDB_CODE_SUCCESS) { generateSyntaxErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal); - return false; + return DEAL_RES_ERROR; } } else { switch (pVal->node.resType.type) { @@ -552,7 +556,7 @@ static bool translateValue(STranslateContext* pCxt, SValueNode* pVal) { if (taosParseTime(tmp, &pVal->datum.u, len, pVal->node.resType.precision, tsDaylight) != TSDB_CODE_SUCCESS) { tfree(tmp); generateSyntaxErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal); - return false; + return DEAL_RES_ERROR; } tfree(tmp); break; @@ -565,55 +569,56 @@ static bool translateValue(STranslateContext* pCxt, SValueNode* pVal) { break; } } - return true; + return DEAL_RES_CONTINUE; } -static bool translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) { +static EDealRes translateOperator(STranslateContext* pCxt, SOperatorNode* pOp) { SDataType ldt = ((SExprNode*)(pOp->pLeft))->resType; SDataType rdt = ((SExprNode*)(pOp->pRight))->resType; if (nodesIsArithmeticOp(pOp)) { if (TSDB_DATA_TYPE_JSON == ldt.type || TSDB_DATA_TYPE_BLOB == ldt.type || TSDB_DATA_TYPE_JSON == rdt.type || TSDB_DATA_TYPE_BLOB == rdt.type) { generateSyntaxErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName); - return false; + return DEAL_RES_ERROR; } pOp->node.resType.type = TSDB_DATA_TYPE_DOUBLE; pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_DOUBLE].bytes; - return true; } else if (nodesIsComparisonOp(pOp)) { if (TSDB_DATA_TYPE_JSON == ldt.type || TSDB_DATA_TYPE_BLOB == ldt.type || TSDB_DATA_TYPE_JSON == rdt.type || TSDB_DATA_TYPE_BLOB == rdt.type) { generateSyntaxErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, ((SExprNode*)(pOp->pRight))->aliasName); - return false; + return DEAL_RES_ERROR; } pOp->node.resType.type = TSDB_DATA_TYPE_BOOL; pOp->node.resType.bytes = tDataTypes[TSDB_DATA_TYPE_BOOL].bytes; - return true; } else { // todo json operator - return true; } - return true; + return DEAL_RES_CONTINUE; } -static bool translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc) { +static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode* pFunc) { if (TSDB_CODE_SUCCESS != fmGetFuncInfo(pCxt->fmgt, pFunc->functionName, &pFunc->funcId, &pFunc->funcType)) { generateSyntaxErrMsg(pCxt, TSDB_CODE_PAR_INVALID_FUNTION, pFunc->functionName); - return false; + return DEAL_RES_ERROR; } int32_t code = fmGetFuncResultType(pFunc); if (TSDB_CODE_SUCCESS != code) { generateSyntaxErrMsg(pCxt, code, pFunc->functionName); - return false; + return DEAL_RES_ERROR; } - if (fmIsAggFunc(pFunc->funcId) && afterGroupBy(pCxt->currClause)) { + if (fmIsAggFunc(pFunc->funcId) && beforeHaving(pCxt->currClause)) { generateSyntaxErrMsg(pCxt, TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION); - return false; + return DEAL_RES_ERROR; } - return true; + return DEAL_RES_CONTINUE; +} + +static EDealRes translateExprSubquery(STranslateContext* pCxt, SNode* pNode) { + return (TSDB_CODE_SUCCESS == translateSubquery(pCxt, pNode) ? DEAL_RES_CONTINUE : DEAL_RES_ERROR); } -static bool doTranslateExpr(SNode* pNode, void* pContext) { +static EDealRes doTranslateExpr(SNode* pNode, void* pContext) { STranslateContext* pCxt = (STranslateContext*)pContext; switch (nodeType(pNode)) { case QUERY_NODE_COLUMN: @@ -625,11 +630,11 @@ static bool doTranslateExpr(SNode* pNode, void* pContext) { case QUERY_NODE_FUNCTION: return translateFunction(pCxt, (SFunctionNode*)pNode); case QUERY_NODE_TEMP_TABLE: - return translateSubquery(pCxt, ((STempTableNode*)pNode)->pSubquery); + return translateExprSubquery(pCxt, ((STempTableNode*)pNode)->pSubquery); default: break; } - return true; + return DEAL_RES_CONTINUE; } static int32_t translateExpr(STranslateContext* pCxt, SNode* pNode) { @@ -642,6 +647,41 @@ static int32_t translateExprList(STranslateContext* pCxt, SNodeList* pList) { return pCxt->errCode; } +static bool isAliasColumn(SColumnNode* pCol) { + return ('\0' == pCol->tableAlias[0]); +} + +static EDealRes doCheckkExprForGroupBy(SNode* pNode, void* pContext) { + STranslateContext* pCxt = (STranslateContext*)pContext; + if (!nodesIsExprNode(pNode) || (QUERY_NODE_COLUMN == nodeType(pNode) && isAliasColumn((SColumnNode*)pNode))) { + return DEAL_RES_CONTINUE; + } + if (QUERY_NODE_FUNCTION == nodeType(pNode) && fmIsAggFunc(((SFunctionNode*)pNode)->funcId)) { + return DEAL_RES_IGNORE_CHILD; + } + SNode* pGroupNode; + FOREACH(pGroupNode, pCxt->pCurrStmt->pGroupByList) { + if (nodesEqualNode(nodesListGetNode(((SGroupingSetNode*)pGroupNode)->pParameterList, 0), pNode)) { + return DEAL_RES_IGNORE_CHILD; + } + } + if (QUERY_NODE_COLUMN == nodeType(pNode)) { + generateSyntaxErrMsg(pCxt, TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION); + return DEAL_RES_ERROR; + } + return DEAL_RES_CONTINUE; +} + +static int32_t checkExprForGroupBy(STranslateContext* pCxt, SNode* pNode) { + nodesWalkNode(pNode, doCheckkExprForGroupBy, pCxt); + return pCxt->errCode; +} + +static int32_t checkExprListForGroupBy(STranslateContext* pCxt, SNodeList* pList) { + nodesWalkList(pList, doCheckkExprForGroupBy, pCxt); + return pCxt->errCode; +} + static int32_t translateTable(STranslateContext* pCxt, SNode* pTable) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pTable)) { @@ -732,12 +772,13 @@ static bool translateOrderByPosition(STranslateContext* pCxt, SNodeList* pProjec *pOther = false; SNode* pNode; FOREACH(pNode, pOrderByList) { - if (QUERY_NODE_VALUE == nodeType(pNode)) { - SValueNode* pVal = (SValueNode*)pNode; - if (translateValue(pCxt, pVal)) { + SNode* pExpr = ((SOrderByExprNode*)pNode)->pExpr; + if (QUERY_NODE_VALUE == nodeType(pExpr)) { + SValueNode* pVal = (SValueNode*)pExpr; + if (!translateValue(pCxt, pVal)) { return false; } - int32_t pos = getPositionValue((SValueNode*)pNode); + int32_t pos = getPositionValue((SValueNode*)pExpr); if (pos < 0) { ERASE_NODE(pOrderByList); nodesDestroyNode(pNode); @@ -747,9 +788,9 @@ static bool translateOrderByPosition(STranslateContext* pCxt, SNodeList* pProjec return false; } else { SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); - setColumnInfoByExpr(NULL, (SExprNode*)nodesListGetNode(pProjectionList, pos), pCol); - REPLACE_NODE(pCol); - nodesDestroyNode(pNode); + setColumnInfoByExpr(NULL, (SExprNode*)nodesListGetNode(pProjectionList, pos - 1), pCol); + ((SOrderByExprNode*)pNode)->pExpr = (SNode*)pCol; + nodesDestroyNode(pExpr); } } else { *pOther = true; @@ -758,17 +799,20 @@ static bool translateOrderByPosition(STranslateContext* pCxt, SNodeList* pProjec return true; } -static int32_t translateOrderBy(STranslateContext* pCxt, SNodeList* pProjectionList, SNodeList* pOrderByList) { +static int32_t translateOrderBy(STranslateContext* pCxt, SSelectStmt* pSelect) { bool other; - if (!translateOrderByPosition(pCxt, pProjectionList, pOrderByList, &other)) { + if (!translateOrderByPosition(pCxt, pSelect->pProjectionList, pSelect->pOrderByList, &other)) { return pCxt->errCode; } if (!other) { return TSDB_CODE_SUCCESS; } pCxt->currClause = SQL_CLAUSE_ORDER_BY; - pCxt->pExt = pProjectionList; - return translateExprList(pCxt, pOrderByList); + int32_t code = translateExprList(pCxt, pSelect->pOrderByList); + if (TSDB_CODE_SUCCESS == code && NULL != pSelect->pGroupByList) { + code = checkExprListForGroupBy(pCxt, pSelect->pOrderByList); + } + return code; } static int32_t translateSelectList(STranslateContext* pCxt, SSelectStmt* pSelect) { @@ -778,12 +822,22 @@ static int32_t translateSelectList(STranslateContext* pCxt, SSelectStmt* pSelect pCxt->currClause = SQL_CLAUSE_SELECT; code = translateExprList(pCxt, pSelect->pProjectionList); } + if (TSDB_CODE_SUCCESS == code && NULL != pSelect->pGroupByList) { + code = checkExprListForGroupBy(pCxt, pSelect->pProjectionList); + } return code; } -static int32_t translateHaving(STranslateContext* pCxt, SNode* pHaving) { +static int32_t translateHaving(STranslateContext* pCxt, SSelectStmt* pSelect) { + if (NULL == pSelect->pGroupByList && NULL != pSelect->pHaving) { + return generateSyntaxErrMsg(pCxt, TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION); + } pCxt->currClause = SQL_CLAUSE_HAVING; - return translateExpr(pCxt, pHaving); + int32_t code = translateExpr(pCxt, pSelect->pHaving); + if (TSDB_CODE_SUCCESS == code) { + code = checkExprForGroupBy(pCxt, pSelect->pHaving); + } + return code; } static int32_t translateGroupBy(STranslateContext* pCxt, SNodeList* pGroupByList) { @@ -818,8 +872,8 @@ static int32_t translateFrom(STranslateContext* pCxt, SNode* pTable) { // } SSelectStmt; static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) { - int32_t code = TSDB_CODE_SUCCESS; - code = translateFrom(pCxt, pSelect->pFromTable); + pCxt->pCurrStmt = pSelect; + int32_t code = translateFrom(pCxt, pSelect->pFromTable); if (TSDB_CODE_SUCCESS == code) { code = translateWhere(pCxt, pSelect->pWhere); } @@ -833,15 +887,14 @@ static int32_t translateSelect(STranslateContext* pCxt, SSelectStmt* pSelect) { code = translateGroupBy(pCxt, pSelect->pGroupByList); } if (TSDB_CODE_SUCCESS == code) { - code = translateHaving(pCxt, pSelect->pHaving); + code = translateHaving(pCxt, pSelect); } if (TSDB_CODE_SUCCESS == code) { code = translateSelectList(pCxt, pSelect); } if (TSDB_CODE_SUCCESS == code) { - code = translateOrderBy(pCxt, pSelect->pProjectionList, pSelect->pOrderByList); + code = translateOrderBy(pCxt, pSelect); } - // printf("%s:%d code = %d\n", __FUNCTION__, __LINE__, code); return code; } @@ -860,11 +913,11 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode) { ++(pCxt->currLevel); ESqlClause currClause = pCxt->currClause; - void* pExt = pCxt->pExt; + SSelectStmt* pCurrStmt = pCxt->pCurrStmt; int32_t code = translateQuery(pCxt, pNode); --(pCxt->currLevel); pCxt->currClause = currClause; - pCxt->pExt = pExt; + pCxt->pCurrStmt = pCurrStmt; return code; } diff --git a/source/libs/parser/src/ttokenizer.c b/source/libs/parser/src/ttokenizer.c index 8e5b22aaa3b6f1aa9a46529d701e8a461da844a3..d5d6b11833adc287c53c6ad8a9b880b888f9803b 100644 --- a/source/libs/parser/src/ttokenizer.c +++ b/source/libs/parser/src/ttokenizer.c @@ -227,7 +227,9 @@ static SKeyword keywordTable[] = { {"OUTPUTTYPE", TK_OUTPUTTYPE}, {"AGGREGATE", TK_AGGREGATE}, {"BUFSIZE", TK_BUFSIZE}, - {"PORT", TK_PORT}, + {"PORT", TK_PORT}, + {"INNER", NEW_TK_INNER}, + {"ON", NEW_TK_ON}, }; static const char isIdChar[] = { diff --git a/source/libs/parser/test/newParserTest.cpp b/source/libs/parser/test/newParserTest.cpp index be239bccfb6993e9f2cec7951180b3a3d7ac6664..2414b7c15f86443ae499e09053597d1e8b729a25 100644 --- a/source/libs/parser/test/newParserTest.cpp +++ b/source/libs/parser/test/newParserTest.cpp @@ -53,8 +53,8 @@ protected: code = doTranslate(&cxt_, &query_); // cout << "doTranslate return " << code << endl; if (code != TSDB_CODE_SUCCESS) { - cout << "sql:[" << cxt_.pSql << "] code:" << tstrerror(code) << ", msg:" << errMagBuf_ << endl; - return (TSDB_CODE_SUCCESS != translateCode); + cout << "sql:[" << cxt_.pSql << "] code:" << code << ", " << translateCode << ", msg:" << errMagBuf_ << endl; + return (code == translateCode); } if (NULL != query_.pRoot && QUERY_NODE_SELECT_STMT == nodeType(query_.pRoot)) { cout << "input sql : [" << cxt_.pSql << "]" << endl; @@ -71,6 +71,24 @@ protected: private: static const int max_err_len = 1024; + void exprNodeToStr(const SNode* node, string& str, bool isProject) { + switch (nodeType(node)) { + case QUERY_NODE_COLUMN: + case QUERY_NODE_VALUE: + case QUERY_NODE_OPERATOR: + case QUERY_NODE_FUNCTION: { + SExprNode* pExpr = (SExprNode*)node; + str.append(" [" + dataTypeToStr(pExpr->resType) + "]"); + if (isProject) { + str.append(" AS " + string(pExpr->aliasName)); + } + break; + } + default: + break; + } + } + string dataTypeToStr(const SDataType& dt) { switch (dt.type) { case TSDB_DATA_TYPE_NULL: @@ -119,7 +137,7 @@ private: return "Unknown Data Type " + to_string(dt.type); } - void valueNodeToStr(const SValueNode* pVal, string& str, bool isProject) { + void valueNodeToStr(const SValueNode* pVal, string& str) { switch (pVal->node.resType.type) { case TSDB_DATA_TYPE_NULL: str.append("null"); @@ -160,10 +178,41 @@ private: default: break; } - str.append(" [" + dataTypeToStr(pVal->node.resType) + "]"); - if (isProject) { - str.append(" AS " + string(pVal->node.aliasName)); + } + + void columnNodeToStr(const SColumnNode* pCol, string& str) { + if ('\0' != pCol->dbName[0]) { + str.append(pCol->dbName); + str.append("."); + } + if ('\0' != pCol->tableAlias[0]) { + str.append(pCol->tableAlias); + str.append("."); } + str.append(pCol->colName); + } + + void operatorToStr(const SOperatorNode* pOp, string& str) { + nodeToStr(pOp->pLeft, str, false); + str.append(opTypeToStr(pOp->opType)); + nodeToStr(pOp->pRight, str, false); + } + + void functionToStr(const SFunctionNode* pFunc, string& str) { + str.append(pFunc->functionName); + str.append("("); + nodeListToStr(pFunc->pParameterList, "", str, false, ", "); + str.append(")"); + } + + void groupingSetToStr(SGroupingSetNode* pGroup, string& str) { + nodeToStr(nodesListGetNode(pGroup->pParameterList, 0), str, false); + } + + void orderByExprToStr(SOrderByExprNode* pOrderBy, string& str) { + nodeToStr(pOrderBy->pExpr, str, false); + str.append((ORDER_ASC == pOrderBy->order ? " ASC" : " DESC")); + str.append((NULL_ORDER_FIRST == pOrderBy->nullOrder ? " NULLS FIRST" : " NULLS LAST")); } void nodeToStr(const SNode* node, string& str, bool isProject) { @@ -173,48 +222,41 @@ private: switch (nodeType(node)) { case QUERY_NODE_COLUMN: { - SColumnNode* pCol = (SColumnNode*)node; - if ('\0' != pCol->dbName[0]) { - str.append(pCol->dbName); - str.append("."); - } - if ('\0' != pCol->tableAlias[0]) { - str.append(pCol->tableAlias); - str.append("."); - } - str.append(pCol->colName); - str.append(" [" + dataTypeToStr(pCol->node.resType) + "]"); - if (isProject) { - str.append(" AS " + string(pCol->node.aliasName)); - } + columnNodeToStr((SColumnNode*)node, str); break; } case QUERY_NODE_VALUE: { - valueNodeToStr((SValueNode*)node, str, isProject); + valueNodeToStr((SValueNode*)node, str); break; } case QUERY_NODE_OPERATOR: { - SOperatorNode* pOp = (SOperatorNode*)node; - nodeToStr(pOp->pLeft, str, false); - str.append(opTypeToStr(pOp->opType)); - nodeToStr(pOp->pRight, str, false); - str.append(" [" + dataTypeToStr(pOp->node.resType) + "]"); - if (isProject) { - str.append(" AS " + string(pOp->node.aliasName)); - } + operatorToStr((SOperatorNode*)node, str); + break; + } + case QUERY_NODE_FUNCTION: { + functionToStr((SFunctionNode*)node, str); + break; + } + case QUERY_NODE_GROUPING_SET: { + groupingSetToStr((SGroupingSetNode*)node, str); + break; + } + case QUERY_NODE_ORDER_BY_EXPR: { + orderByExprToStr((SOrderByExprNode*)node, str); break; } default: break; } + exprNodeToStr(node, str, isProject); } - void nodeListToStr(const SNodeList* nodelist, const string& prefix, string& str, bool isProject = false) { + void nodeListToStr(const SNodeList* nodelist, const string& prefix, string& str, bool isProject = false, const string& sep = string("\n")) { SNode* node = nullptr; FOREACH(node, nodelist) { str.append(prefix); nodeToStr(node, str, isProject); - str.append("\n"); + str.append(sep); } } @@ -265,8 +307,20 @@ private: } str.append("\n"); nodeListToStr(select->pProjectionList, prefix + "\t", str, true); - str.append("\n" + prefix + "FROM\n"); + str.append(prefix + "FROM\n"); tableToStr(select->pFromTable, prefix + "\t", str); + if (nullptr != select->pWhere) { + str.append("\n" + prefix + "WHERE\n\t"); + nodeToStr(select->pWhere, str, false); + } + if (nullptr != select->pGroupByList) { + str.append("\n" + prefix + "GROUP BY\n"); + nodeListToStr(select->pGroupByList, prefix + "\t", str, true); + } + if (nullptr != select->pOrderByList) { + str.append(prefix + "ORDER BY\n"); + nodeListToStr(select->pOrderByList, prefix + "\t", str, true); + } } void selectToSql(const SNode* node, string& sql) { @@ -332,15 +386,23 @@ private: case OP_TYPE_SUB: return " - "; case OP_TYPE_MULTI: + return " * "; case OP_TYPE_DIV: + return " / "; case OP_TYPE_MOD: + return " % "; case OP_TYPE_GREATER_THAN: + return " > "; case OP_TYPE_GREATER_EQUAL: + return " >= "; case OP_TYPE_LOWER_THAN: + return " < "; case OP_TYPE_LOWER_EQUAL: + return " <= "; case OP_TYPE_EQUAL: return " = "; case OP_TYPE_NOT_EQUAL: + return " != "; case OP_TYPE_IN: case OP_TYPE_NOT_IN: case OP_TYPE_LIKE: @@ -454,6 +516,23 @@ TEST_F(NewParserTest, selectExpression) { TEST_F(NewParserTest, selectClause) { setDatabase("root", "test"); + // GROUP BY clause + bind("SELECT count(*), c2 cnt FROM t1 WHERE c1 > 0"); + ASSERT_TRUE(run()); + + bind("SELECT count(*), c2 cnt FROM t1 WHERE c1 > 0 GROUP BY c2"); + ASSERT_TRUE(run()); + + bind("SELECT count(*) cnt FROM t1 WHERE c1 > 0 GROUP BY c2 HAVING count(c1) > 10"); + ASSERT_TRUE(run()); + + bind("SELECT count(*), c1, c2 + 10, c1 + c2 cnt FROM t1 WHERE c1 > 0 GROUP BY c2, c1"); + ASSERT_TRUE(run()); + + bind("SELECT count(*), c1 + 10, c2 cnt FROM t1 WHERE c1 > 0 GROUP BY c1 + 10, c2"); + ASSERT_TRUE(run()); + + // ORDER BY clause bind("SELECT count(*) cnt FROM t1 WHERE c1 > 0 GROUP BY c2 ORDER BY cnt"); ASSERT_TRUE(run()); @@ -480,15 +559,65 @@ TEST_F(NewParserTest, selectSyntaxError) { TEST_F(NewParserTest, selectSemanticError) { setDatabase("root", "test"); + // TSDB_CODE_PAR_INVALID_COLUMN + bind("SELECT c1, c3 FROM t1"); + ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_PAR_INVALID_COLUMN)); + + bind("SELECT t1.c1, t1.c3 FROM t1"); + ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_PAR_INVALID_COLUMN)); + + // TSDB_CODE_PAR_TABLE_NOT_EXIST bind("SELECT * FROM t10"); - ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_FAILED)); + ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_PAR_TABLE_NOT_EXIST)); - bind("SELECT c1, c3 FROM t1"); - ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_FAILED)); + bind("SELECT * FROM test.t10"); + ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_PAR_TABLE_NOT_EXIST)); + // TSDB_CODE_PAR_AMBIGUOUS_COLUMN bind("SELECT c2 FROM t1 tt1, t1 tt2 WHERE tt1.c1 = tt2.c1"); - ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_FAILED)); + ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_PAR_AMBIGUOUS_COLUMN)); + + // TSDB_CODE_PAR_WRONG_VALUE_TYPE + bind("SELECT 10n FROM t1"); + ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_PAR_WRONG_VALUE_TYPE)); + + bind("SELECT TIMESTAMP '2010' FROM t1"); + ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_PAR_WRONG_VALUE_TYPE)); + + // TSDB_CODE_PAR_INVALID_FUNTION + bind("SELECT cnt(*) FROM t1"); + ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_PAR_INVALID_FUNTION)); + + // TSDB_CODE_PAR_FUNTION_PARA_NUM + // TSDB_CODE_PAR_FUNTION_PARA_TYPE + + // TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION + bind("SELECT c2 FROM t1 tt1 JOIN t1 tt2 ON count(*) > 0"); + ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION)); bind("SELECT c2 FROM t1 where count(*) > 0"); - ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_FAILED)); + ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION)); + + bind("SELECT c2 FROM t1 GROUP BY count(*)"); + ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_PAR_ILLEGAL_USE_AGG_FUNCTION)); + + // TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT + bind("SELECT c2 FROM t1 ORDER BY 0"); + ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT)); + + bind("SELECT c2 FROM t1 ORDER BY 2"); + ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_PAR_WRONG_NUMBER_OF_SELECT)); + + //TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION + bind("SELECT count(*) cnt FROM t1 HAVING c1 > 0"); + ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION)); + + bind("SELECT count(*) cnt FROM t1 GROUP BY c2 HAVING c1 > 0"); + ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION)); + + bind("SELECT count(*), c1 cnt FROM t1 GROUP BY c2 HAVING c2 > 0"); + ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION)); + + bind("SELECT count(*) cnt FROM t1 GROUP BY c2 HAVING c2 > 0 ORDER BY c1"); + ASSERT_TRUE(run(TSDB_CODE_SUCCESS, TSDB_CODE_PAR_GROUPBY_LACK_EXPRESSION)); } diff --git a/source/nodes/src/nodesTraverseFuncs.c b/source/nodes/src/nodesTraverseFuncs.c index 2280d0b922fc4c8f0a38d772ed0419e0c2eb0480..796aab611b4115553726dc6598925cd40d2383e5 100644 --- a/source/nodes/src/nodesTraverseFuncs.c +++ b/source/nodes/src/nodesTraverseFuncs.c @@ -20,18 +20,22 @@ typedef enum ETraversalOrder { TRAVERSAL_POSTORDER } ETraversalOrder; -static bool walkList(SNodeList* pNodeList, ETraversalOrder order, FQueryNodeWalker walker, void* pContext); +static EDealRes walkList(SNodeList* pNodeList, ETraversalOrder order, FQueryNodeWalker walker, void* pContext); -static bool walkNode(SNode* pNode, ETraversalOrder order, FQueryNodeWalker walker, void* pContext) { +static EDealRes walkNode(SNode* pNode, ETraversalOrder order, FQueryNodeWalker walker, void* pContext) { if (NULL == pNode) { - return true; + return DEAL_RES_CONTINUE; } - if (TRAVERSAL_PREORDER == order && !walker(pNode, pContext)) { - return false; + EDealRes res = DEAL_RES_CONTINUE; + + if (TRAVERSAL_PREORDER == order) { + res = walker(pNode, pContext); + if (DEAL_RES_CONTINUE != res) { + return res; + } } - bool res = true; switch (nodeType(pNode)) { case QUERY_NODE_COLUMN: case QUERY_NODE_VALUE: @@ -41,7 +45,7 @@ static bool walkNode(SNode* pNode, ETraversalOrder order, FQueryNodeWalker walke case QUERY_NODE_OPERATOR: { SOperatorNode* pOpNode = (SOperatorNode*)pNode; res = walkNode(pOpNode->pLeft, order, walker, pContext); - if (res) { + if (DEAL_RES_ERROR != res) { res = walkNode(pOpNode->pRight, order, walker, pContext); } break; @@ -61,10 +65,10 @@ static bool walkNode(SNode* pNode, ETraversalOrder order, FQueryNodeWalker walke case QUERY_NODE_JOIN_TABLE: { SJoinTableNode* pJoinTableNode = (SJoinTableNode*)pNode; res = walkNode(pJoinTableNode->pLeft, order, walker, pContext); - if (res) { + if (DEAL_RES_ERROR != res) { res = walkNode(pJoinTableNode->pRight, order, walker, pContext); } - if (res) { + if (DEAL_RES_ERROR != res) { res = walkNode(pJoinTableNode->pOnCond, order, walker, pContext); } break; @@ -84,13 +88,13 @@ static bool walkNode(SNode* pNode, ETraversalOrder order, FQueryNodeWalker walke case QUERY_NODE_INTERVAL_WINDOW: { SIntervalWindowNode* pInterval = (SIntervalWindowNode*)pNode; res = walkNode(pInterval->pInterval, order, walker, pContext); - if (res) { + if (DEAL_RES_ERROR != res) { res = walkNode(pInterval->pOffset, order, walker, pContext); } - if (res) { + if (DEAL_RES_ERROR != res) { res = walkNode(pInterval->pSliding, order, walker, pContext); } - if (res) { + if (DEAL_RES_ERROR != res) { res = walkNode(pInterval->pFill, order, walker, pContext); } break; @@ -108,21 +112,21 @@ static bool walkNode(SNode* pNode, ETraversalOrder order, FQueryNodeWalker walke break; } - if (res && TRAVERSAL_POSTORDER == order) { + if (DEAL_RES_ERROR != res && TRAVERSAL_POSTORDER == order) { res = walker(pNode, pContext); } return res; } -static bool walkList(SNodeList* pNodeList, ETraversalOrder order, FQueryNodeWalker walker, void* pContext) { +static EDealRes walkList(SNodeList* pNodeList, ETraversalOrder order, FQueryNodeWalker walker, void* pContext) { SNode* node; FOREACH(node, pNodeList) { - if (!walkNode(node, order, walker, pContext)) { - return false; + if (DEAL_RES_ERROR == walkNode(node, order, walker, pContext)) { + return DEAL_RES_ERROR; } } - return true; + return DEAL_RES_CONTINUE; } void nodesWalkNode(SNode* pNode, FQueryNodeWalker walker, void* pContext) { @@ -140,7 +144,3 @@ void nodesWalkNodePostOrder(SNode* pNode, FQueryNodeWalker walker, void* pContex void nodesWalkListPostOrder(SNodeList* pList, FQueryNodeWalker walker, void* pContext) { (void)walkList(pList, TRAVERSAL_POSTORDER, walker, pContext); } - -bool nodesWalkStmt(SNode* pNode, FQueryNodeWalker walker, void* pContext) { - -} diff --git a/source/nodes/src/nodesUtilFuncs.c b/source/nodes/src/nodesUtilFuncs.c index 155eb6effe6288b451fd3b116908f51c3490f33d..e0e589157c8c49c53abaeaddad513bdf4728ad7f 100644 --- a/source/nodes/src/nodesUtilFuncs.c +++ b/source/nodes/src/nodesUtilFuncs.c @@ -76,7 +76,7 @@ SNode* nodesMakeNode(ENodeType type) { return NULL; } -static bool destroyNode(SNode* pNode, void* pContext) { +static EDealRes destroyNode(SNode* pNode, void* pContext) { switch (nodeType(pNode)) { case QUERY_NODE_VALUE: tfree(((SValueNode*)pNode)->literal); @@ -85,6 +85,7 @@ static bool destroyNode(SNode* pNode, void* pContext) { break; } tfree(pNode); + return DEAL_RES_CONTINUE; } void nodesDestroyNode(SNode* pNode) { @@ -116,9 +117,23 @@ SNodeList* nodesListAppend(SNodeList* pList, SNode* pNode) { pList->pTail->pNext = p; } pList->pTail = p; + ++(pList->length); return pList; } +SListCell* nodesListErase(SNodeList* pList, SListCell* pCell) { + if (NULL == pCell->pPrev) { + pList->pHead = pCell->pNext; + } else { + pCell->pPrev->pNext = pCell->pNext; + pCell->pNext->pPrev = pCell->pPrev; + } + SListCell* pNext = pCell->pNext; + tfree(pCell); + --(pList->length); + return pNext; +} + SNode* nodesListGetNode(SNodeList* pList, int32_t index) { SNode* node; FOREACH(node, pList) { @@ -137,6 +152,11 @@ void nodesDestroyList(SNodeList* pList) { tfree(pList); } +bool nodesIsExprNode(const SNode* pNode) { + ENodeType type = nodeType(pNode); + return (QUERY_NODE_COLUMN == type || QUERY_NODE_VALUE == type || QUERY_NODE_OPERATOR == type || QUERY_NODE_FUNCTION == type); +} + bool nodesIsArithmeticOp(const SOperatorNode* pOp) { switch (pOp->opType) { case OP_TYPE_ADD: