From 15cfd98449914304d8491eb40f9f6d5eea04a014 Mon Sep 17 00:00:00 2001 From: tangfangzhi Date: Tue, 15 Mar 2022 12:44:38 +0800 Subject: [PATCH 01/37] extend 3.0 ci to 4 machines --- Jenkinsfile2 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile2 b/Jenkinsfile2 index ad62fa7044..bea254d046 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -35,6 +35,7 @@ def abort_previous(){ def pre_test(){ sh'hostname' sh ''' + date sudo rmtaos || echo "taosd has not installed" ''' sh ''' @@ -98,7 +99,7 @@ pipeline { } stages { stage('pre_build'){ - agent{label 'slave3_0'} + agent{label " slave3_0 || slave15 || slave16 || slave17 "} options { skipDefaultCheckout() } when { changeRequest() From eae2d7b661c71ed64f16a4b56d949e3bbb71d77d Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Tue, 15 Mar 2022 04:00:09 -0400 Subject: [PATCH 02/37] TD-13675 create sma index grammar --- include/common/tmsg.h | 16 +- include/common/ttime.h | 11 + include/common/ttokendef.h | 101 +- include/libs/nodes/cmdnodes.h | 28 +- include/libs/nodes/nodes.h | 7 + include/libs/nodes/querynodes.h | 1 + include/util/tjson.h | 1 + source/libs/nodes/src/nodesCodeFuncs.c | 56 +- source/libs/nodes/src/nodesUtilFuncs.c | 8 + source/libs/parser/inc/parAst.h | 16 +- source/libs/parser/inc/sql.y | 32 +- source/libs/parser/src/parAstCreater.c | 67 +- source/libs/parser/src/parTokenizer.c | 3 +- source/libs/parser/src/parTranslater.c | 93 +- source/libs/parser/src/sql.c | 2686 +++++++++++---------- source/libs/parser/test/parserAstTest.cpp | 7 + source/util/src/tjson.c | 8 + 17 files changed, 1723 insertions(+), 1418 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 5975bf0a29..863f29637e 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1914,11 +1914,12 @@ typedef struct { int8_t slidingUnit; char indexName[TSDB_INDEX_NAME_LEN]; char timezone[TD_TIMEZONE_LEN]; // sma data is invalid if timezone change. - uint16_t exprLen; - uint16_t tagsFilterLen; + int32_t exprLen; + int32_t tagsFilterLen; int64_t indexUid; tb_uid_t tableUid; // super/child/common table uid int64_t interval; + int64_t offset; int64_t sliding; char* expr; // sma expression char* tagsFilter; @@ -2020,11 +2021,12 @@ static FORCE_INLINE int32_t tEncodeTSma(void** buf, const STSma* pSma) { tlen += taosEncodeFixedI8(buf, pSma->slidingUnit); tlen += taosEncodeString(buf, pSma->indexName); tlen += taosEncodeString(buf, pSma->timezone); - tlen += taosEncodeFixedU16(buf, pSma->exprLen); - tlen += taosEncodeFixedU16(buf, pSma->tagsFilterLen); + tlen += taosEncodeFixedI32(buf, pSma->exprLen); + tlen += taosEncodeFixedI32(buf, pSma->tagsFilterLen); tlen += taosEncodeFixedI64(buf, pSma->indexUid); tlen += taosEncodeFixedI64(buf, pSma->tableUid); tlen += taosEncodeFixedI64(buf, pSma->interval); + tlen += taosEncodeFixedI64(buf, pSma->offset); tlen += taosEncodeFixedI64(buf, pSma->sliding); if (pSma->exprLen > 0) { @@ -2054,14 +2056,14 @@ static FORCE_INLINE void* tDecodeTSma(void* buf, STSma* pSma) { buf = taosDecodeFixedI8(buf, &pSma->slidingUnit); buf = taosDecodeStringTo(buf, pSma->indexName); buf = taosDecodeStringTo(buf, pSma->timezone); - buf = taosDecodeFixedU16(buf, &pSma->exprLen); - buf = taosDecodeFixedU16(buf, &pSma->tagsFilterLen); + buf = taosDecodeFixedI32(buf, &pSma->exprLen); + buf = taosDecodeFixedI32(buf, &pSma->tagsFilterLen); buf = taosDecodeFixedI64(buf, &pSma->indexUid); buf = taosDecodeFixedI64(buf, &pSma->tableUid); buf = taosDecodeFixedI64(buf, &pSma->interval); + buf = taosDecodeFixedI64(buf, &pSma->offset); buf = taosDecodeFixedI64(buf, &pSma->sliding); - if (pSma->exprLen > 0) { pSma->expr = (char*)calloc(pSma->exprLen, 1); if (pSma->expr != NULL) { diff --git a/include/common/ttime.h b/include/common/ttime.h index b71426e312..57af24e635 100644 --- a/include/common/ttime.h +++ b/include/common/ttime.h @@ -25,6 +25,17 @@ extern "C" { #define TIME_IS_VAR_DURATION(_t) ((_t) == 'n' || (_t) == 'y' || (_t) == 'N' || (_t) == 'Y') +#define TIME_UNIT_NANOSECOND 'b' +#define TIME_UNIT_MICROSECOND 'u' +#define TIME_UNIT_MILLISECOND 'a' +#define TIME_UNIT_SECOND 's' +#define TIME_UNIT_MINUTE 'm' +#define TIME_UNIT_HOUR 'h' +#define TIME_UNIT_DAY 'd' +#define TIME_UNIT_WEEK 'w' +#define TIME_UNIT_MONTH 'n' +#define TIME_UNIT_YEAR 'y' + /* * @return timestamp decided by global conf variable, tsTimePrecision * if precision == TSDB_TIME_PRECISION_MICRO, it returns timestamp in microsecond. diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 2121b3175a..6745b80ac0 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -101,55 +101,58 @@ #define TK_VARBINARY 83 #define TK_DECIMAL 84 #define TK_SMA 85 -#define TK_MNODES 86 -#define TK_NK_FLOAT 87 -#define TK_NK_BOOL 88 -#define TK_NK_VARIABLE 89 -#define TK_BETWEEN 90 -#define TK_IS 91 -#define TK_NULL 92 -#define TK_NK_LT 93 -#define TK_NK_GT 94 -#define TK_NK_LE 95 -#define TK_NK_GE 96 -#define TK_NK_NE 97 -#define TK_NK_EQ 98 -#define TK_LIKE 99 -#define TK_MATCH 100 -#define TK_NMATCH 101 -#define TK_IN 102 -#define TK_FROM 103 -#define TK_AS 104 -#define TK_JOIN 105 -#define TK_ON 106 -#define TK_INNER 107 -#define TK_SELECT 108 -#define TK_DISTINCT 109 -#define TK_WHERE 110 -#define TK_PARTITION 111 -#define TK_BY 112 -#define TK_SESSION 113 -#define TK_STATE_WINDOW 114 -#define TK_INTERVAL 115 -#define TK_SLIDING 116 -#define TK_FILL 117 -#define TK_VALUE 118 -#define TK_NONE 119 -#define TK_PREV 120 -#define TK_LINEAR 121 -#define TK_NEXT 122 -#define TK_GROUP 123 -#define TK_HAVING 124 -#define TK_ORDER 125 -#define TK_SLIMIT 126 -#define TK_SOFFSET 127 -#define TK_LIMIT 128 -#define TK_OFFSET 129 -#define TK_ASC 130 -#define TK_DESC 131 -#define TK_NULLS 132 -#define TK_FIRST 133 -#define TK_LAST 134 +#define TK_INDEX 86 +#define TK_ON 87 +#define TK_FULLTEXT 88 +#define TK_FUNCTION 89 +#define TK_INTERVAL 90 +#define TK_MNODES 91 +#define TK_NK_FLOAT 92 +#define TK_NK_BOOL 93 +#define TK_NK_VARIABLE 94 +#define TK_BETWEEN 95 +#define TK_IS 96 +#define TK_NULL 97 +#define TK_NK_LT 98 +#define TK_NK_GT 99 +#define TK_NK_LE 100 +#define TK_NK_GE 101 +#define TK_NK_NE 102 +#define TK_NK_EQ 103 +#define TK_LIKE 104 +#define TK_MATCH 105 +#define TK_NMATCH 106 +#define TK_IN 107 +#define TK_FROM 108 +#define TK_AS 109 +#define TK_JOIN 110 +#define TK_INNER 111 +#define TK_SELECT 112 +#define TK_DISTINCT 113 +#define TK_WHERE 114 +#define TK_PARTITION 115 +#define TK_BY 116 +#define TK_SESSION 117 +#define TK_STATE_WINDOW 118 +#define TK_SLIDING 119 +#define TK_FILL 120 +#define TK_VALUE 121 +#define TK_NONE 122 +#define TK_PREV 123 +#define TK_LINEAR 124 +#define TK_NEXT 125 +#define TK_GROUP 126 +#define TK_HAVING 127 +#define TK_ORDER 128 +#define TK_SLIMIT 129 +#define TK_SOFFSET 130 +#define TK_LIMIT 131 +#define TK_OFFSET 132 +#define TK_ASC 133 +#define TK_DESC 134 +#define TK_NULLS 135 +#define TK_FIRST 136 +#define TK_LAST 137 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 084258e48f..aa539667e4 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -23,6 +23,7 @@ extern "C" { #include "querynodes.h" typedef struct SDatabaseOptions { + ENodeType type; int32_t numOfBlocks; int32_t cacheBlockSize; int8_t cachelast; @@ -46,7 +47,7 @@ typedef struct SCreateDatabaseStmt { ENodeType type; char dbName[TSDB_DB_NAME_LEN]; bool ignoreExists; - SDatabaseOptions options; + SDatabaseOptions* pOptions; } SCreateDatabaseStmt; typedef struct SUseDatabaseStmt { @@ -61,6 +62,7 @@ typedef struct SDropDatabaseStmt { } SDropDatabaseStmt; typedef struct STableOptions { + ENodeType type; int32_t keep; int32_t ttl; char comments[TSDB_STB_COMMENT_LEN]; @@ -81,7 +83,7 @@ typedef struct SCreateTableStmt { bool ignoreExists; SNodeList* pCols; SNodeList* pTags; - STableOptions options; + STableOptions* pOptions; } SCreateTableStmt; typedef struct SCreateSubTableClause { @@ -155,6 +157,28 @@ typedef struct SShowStmt { char dbName[TSDB_DB_NAME_LEN]; } SShowStmt; +typedef enum EIndexType { + INDEX_TYPE_SMA = 1, + INDEX_TYPE_FULLTEXT +} EIndexType; + +typedef struct SIndexOptions { + ENodeType type; + SNodeList* pFuncs; + SNode* pInterval; + SNode* pOffset; + SNode* pSliding; +} SIndexOptions; + +typedef struct SCreateIndexStmt { + ENodeType type; + EIndexType indexType; + char indexName[TSDB_INDEX_NAME_LEN]; + char tableName[TSDB_TABLE_NAME_LEN]; + SNodeList* pCols; + SIndexOptions* pOptions; +} SCreateIndexStmt; + #ifdef __cplusplus } #endif diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 3a9dd3c713..46b89416b7 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -67,6 +67,9 @@ typedef enum ENodeType { QUERY_NODE_SLOT_DESC, QUERY_NODE_COLUMN_DEF, QUERY_NODE_DOWNSTREAM_SOURCE, + QUERY_NODE_DATABASE_OPTIONS, + QUERY_NODE_TABLE_OPTIONS, + QUERY_NODE_INDEX_OPTIONS, // Statement nodes are used in parser and planner module. QUERY_NODE_SET_OPERATOR, @@ -93,6 +96,7 @@ typedef enum ENodeType { QUERY_NODE_SHOW_DNODES_STMT, QUERY_NODE_SHOW_VGROUPS_STMT, QUERY_NODE_SHOW_MNODES_STMT, + QUERY_NODE_CREATE_INDEX_STMT, // logic plan node QUERY_NODE_LOGIC_PLAN_SCAN, @@ -185,6 +189,9 @@ const char* nodesNodeName(ENodeType type); int32_t nodesNodeToString(const SNodeptr pNode, bool format, char** pStr, int32_t* pLen); int32_t nodesStringToNode(const char* pStr, SNode** pNode); +int32_t nodesListToString(const SNodeList* pList, bool format, char** pStr, int32_t* pLen); +int32_t nodesStringToList(const char* pStr, SNodeList** pList); + #ifdef __cplusplus } #endif diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 6a6d508096..fe44d8666b 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -82,6 +82,7 @@ typedef struct SValueNode { double d; char* p; } datum; + char unit; } SValueNode; typedef struct SOperatorNode { diff --git a/include/util/tjson.h b/include/util/tjson.h index 335ff0d4ba..1218caae35 100644 --- a/include/util/tjson.h +++ b/include/util/tjson.h @@ -25,6 +25,7 @@ extern "C" { typedef void SJson; SJson* tjsonCreateObject(); +SJson* tjsonCreateArray(); void tjsonDelete(SJson* pJson); SJson* tjsonAddArrayToObject(SJson* pJson, const char* pName); diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 57ebc2c4b6..2a4c98d894 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -151,8 +151,7 @@ static int32_t nodeListToJson(SJson* pJson, const char* pName, const SNodeList* return TSDB_CODE_SUCCESS; } -static int32_t jsonToNodeList(const SJson* pJson, const char* pName, SNodeList** pList) { - const SJson* pJsonArray = tjsonGetObjectItem(pJson, pName); +static int32_t jsonToNodeListImpl(const SJson* pJsonArray, SNodeList** pList) { int32_t size = (NULL == pJsonArray ? 0 : tjsonGetArraySize(pJsonArray)); if (size > 0) { *pList = nodesMakeList(); @@ -176,6 +175,10 @@ static int32_t jsonToNodeList(const SJson* pJson, const char* pName, SNodeList** return code; } +static int32_t jsonToNodeList(const SJson* pJson, const char* pName, SNodeList** pList) { + return jsonToNodeListImpl(tjsonGetObjectItem(pJson, pName), pList); +} + static const char* jkTableMetaUid = "TableMetaUid"; static const char* jkTableMetaSuid = "TableMetaSuid"; @@ -1750,3 +1753,52 @@ int32_t nodesStringToNode(const char* pStr, SNode** pNode) { } return TSDB_CODE_SUCCESS; } + +int32_t nodesListToString(const SNodeList* pList, bool format, char** pStr, int32_t* pLen) { + if (NULL == pList || NULL == pStr || NULL == pLen) { + terrno = TSDB_CODE_FAILED; + return TSDB_CODE_FAILED; + } + + if (0 == LIST_LENGTH(pList)) { + return TSDB_CODE_SUCCESS; + } + + SJson* pJson = tjsonCreateArray(); + if (NULL == pJson) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; + } + + SNode* pNode; + FOREACH(pNode, pList) { + int32_t code = tjsonAddItem(pJson, nodeToJson, pNode); + if (TSDB_CODE_SUCCESS != code) { + terrno = code; + return code; + } + } + + *pStr = format ? tjsonToString(pJson) : tjsonToUnformattedString(pJson); + tjsonDelete(pJson); + + *pLen = strlen(*pStr) + 1; + return TSDB_CODE_SUCCESS; +} + +int32_t nodesStringToList(const char* pStr, SNodeList** pList) { + if (NULL == pStr || NULL == pList) { + return TSDB_CODE_SUCCESS; + } + SJson* pJson = tjsonParse(pStr); + if (NULL == pJson) { + return TSDB_CODE_FAILED; + } + int32_t code = jsonToNodeListImpl(pJson, pList); + if (TSDB_CODE_SUCCESS != code) { + nodesDestroyList(*pList); + terrno = code; + return code; + } + return TSDB_CODE_SUCCESS; +} diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 0adbf8cb2f..cc99387095 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -76,6 +76,12 @@ SNodeptr nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SColumnDefNode)); case QUERY_NODE_DOWNSTREAM_SOURCE: return makeNode(type, sizeof(SDownstreamSourceNode)); + case QUERY_NODE_DATABASE_OPTIONS: + return makeNode(type, sizeof(SDatabaseOptions)); + case QUERY_NODE_TABLE_OPTIONS: + return makeNode(type, sizeof(STableOptions)); + case QUERY_NODE_INDEX_OPTIONS: + return makeNode(type, sizeof(SIndexOptions)); case QUERY_NODE_SET_OPERATOR: return makeNode(type, sizeof(SSetOperator)); case QUERY_NODE_SELECT_STMT: @@ -122,6 +128,8 @@ SNodeptr nodesMakeNode(ENodeType type) { case QUERY_NODE_SHOW_VGROUPS_STMT: case QUERY_NODE_SHOW_MNODES_STMT: return makeNode(type, sizeof(SShowStmt)); + case QUERY_NODE_CREATE_INDEX_STMT: + return makeNode(type, sizeof(SCreateIndexStmt)); case QUERY_NODE_LOGIC_PLAN_SCAN: return makeNode(type, sizeof(SScanLogicNode)); case QUERY_NODE_LOGIC_PLAN_JOIN: diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 11c56ddf3c..bb22e5703d 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -109,17 +109,17 @@ SNode* addLimitClause(SAstCreateContext* pCxt, SNode* pStmt, SNode* pLimit); SNode* createSelectStmt(SAstCreateContext* pCxt, bool isDistinct, SNodeList* pProjectionList, SNode* pTable); SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode* pLeft, SNode* pRight); -SDatabaseOptions* createDefaultDatabaseOptions(SAstCreateContext* pCxt); -SDatabaseOptions* setDatabaseOption(SAstCreateContext* pCxt, SDatabaseOptions* pOptions, EDatabaseOptionType type, const SToken* pVal); -SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pDbName, SDatabaseOptions* pOptions); +SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt); +SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, const SToken* pVal); +SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pDbName, SNode* pOptions); SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pDbName); -STableOptions* createDefaultTableOptions(SAstCreateContext* pCxt); -STableOptions* setTableOption(SAstCreateContext* pCxt, STableOptions* pOptions, ETableOptionType type, const SToken* pVal); -STableOptions* setTableSmaOption(SAstCreateContext* pCxt, STableOptions* pOptions, SNodeList* pSma); +SNode* createDefaultTableOptions(SAstCreateContext* pCxt); +SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, const SToken* pVal); +SNode* setTableSmaOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pSma); SNode* createColumnDefNode(SAstCreateContext* pCxt, const SToken* pColName, SDataType dataType, const SToken* pComment); SDataType createDataType(uint8_t type); SDataType createVarLenDataType(uint8_t type, const SToken* pLen); -SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNodeList* pCols, SNodeList* pTags, STableOptions* pOptions); +SNode* createCreateTableStmt(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNodeList* pCols, SNodeList* pTags, SNode* pOptions); SNode* createCreateSubTableClause(SAstCreateContext* pCxt, bool ignoreExists, SNode* pRealTable, SNode* pUseRealTable, SNodeList* pSpecificTags, SNodeList* pValsOfTags); SNode* createCreateMultiTableStmt(SAstCreateContext* pCxt, SNodeList* pSubTables); SNode* createDropTableClause(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable); @@ -132,6 +132,8 @@ SNode* createAlterUserStmt(SAstCreateContext* pCxt, const SToken* pUserName, int SNode* createDropUserStmt(SAstCreateContext* pCxt, const SToken* pUserName); SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SToken* pPort); SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode); +SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, const SToken* pIndexName, const SToken* pTableName, SNodeList* pCols, SNode* pOptions); +SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding); #ifdef __cplusplus } diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index f4ed3d8597..7515466b47 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -80,8 +80,6 @@ not_exists_opt(A) ::= . exists_opt(A) ::= IF EXISTS. { A = true; } exists_opt(A) ::= . { A = false; } -%type db_options { SDatabaseOptions* } -%destructor db_options { tfree($$); } db_options(A) ::= . { A = createDefaultDatabaseOptions(pCxt); } db_options(A) ::= db_options(B) BLOCKS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_BLOCKS, &C); } db_options(A) ::= db_options(B) CACHE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_CACHE, &C); } @@ -179,8 +177,6 @@ tags_def_opt(A) ::= tags_def(B). %destructor tags_def { nodesDestroyList($$); } tags_def(A) ::= TAGS NK_LP column_def_list(B) NK_RP. { A = B; } -%type table_options { STableOptions* } -%destructor table_options { tfree($$); } table_options(A) ::= . { A = createDefaultTableOptions(pCxt);} table_options(A) ::= table_options(B) COMMENT NK_STRING(C). { A = setTableOption(pCxt, B, TABLE_OPTION_COMMENT, &C); } table_options(A) ::= table_options(B) KEEP NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_KEEP, &C); } @@ -194,6 +190,24 @@ col_name_list(A) ::= col_name_list(B) NK_COMMA col_name(C). col_name(A) ::= column_name(B). { A = createColumnNode(pCxt, NULL, &B); } +/************************************************ create index ********************************************************/ +cmd ::= CREATE SMA INDEX index_name(A) ON table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &A, &B, NULL, C); } +cmd ::= CREATE FULLTEXT INDEX + index_name(A) ON table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &A, &B, C, NULL); } + +index_options(A) ::= . { A = NULL; } +index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL + NK_LP duration_literal(C) NK_RP sliding_opt(D). { A = createIndexOption(pCxt, B, C, NULL, D); } +index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL + NK_LP duration_literal(C) NK_COMMA duration_literal(D) NK_RP sliding_opt(E). { A = createIndexOption(pCxt, B, C, D, E); } + +%type func_list { SNodeList* } +%destructor func_list { nodesDestroyList($$); } +func_list(A) ::= func(B). { A = createNodeList(pCxt, B); } +func_list(A) ::= func_list(B) NK_COMMA func(C). { A = addNodeToList(pCxt, B, C); } + +func(A) ::= function_name(B) NK_LP expression_list(C) NK_RP. { A = createFunctionNode(pCxt, &B, C); } + /************************************************ show vgroups ********************************************************/ cmd ::= SHOW VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, NULL); } cmd ::= SHOW db_name(B) NK_DOT VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &B); } @@ -248,6 +262,10 @@ column_alias(A) ::= NK_ID(B). %destructor user_name { } user_name(A) ::= NK_ID(B). { A = B; } +%type index_name { SToken } +%destructor index_name { } +index_name(A) ::= NK_ID(B). { A = B; } + /************************************************ expression **********************************************************/ expression(A) ::= literal(B). { A = B; } //expression(A) ::= NK_QUESTION(B). { A = B; } @@ -463,13 +481,13 @@ twindow_clause_opt(A) ::= SESSION NK_LP column_reference(B) NK_COMMA NK_INTEGER(C) NK_RP. { A = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, B), &C); } twindow_clause_opt(A) ::= STATE_WINDOW NK_LP column_reference(B) NK_RP. { A = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, B)); } twindow_clause_opt(A) ::= - INTERVAL NK_LP duration_literal(B) NK_RP sliding_opt(C) fill_opt(D). { A = createIntervalWindowNode(pCxt, B, NULL, C, D); } + INTERVAL NK_LP duration_literal(B) NK_RP sliding_opt(C) fill_opt(D). { A = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, B), NULL, C, D); } twindow_clause_opt(A) ::= INTERVAL NK_LP duration_literal(B) NK_COMMA duration_literal(C) NK_RP - sliding_opt(D) fill_opt(E). { A = createIntervalWindowNode(pCxt, B, C, D, E); } + sliding_opt(D) fill_opt(E). { A = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, B), releaseRawExprNode(pCxt, C), D, E); } sliding_opt(A) ::= . { A = NULL; } -sliding_opt(A) ::= SLIDING NK_LP duration_literal(B) NK_RP. { A = B; } +sliding_opt(A) ::= SLIDING NK_LP duration_literal(B) NK_RP. { A = releaseRawExprNode(pCxt, B); } fill_opt(A) ::= . { A = NULL; } fill_opt(A) ::= FILL NK_LP fill_mode(B) NK_RP. { A = createFillNode(pCxt, B, NULL); } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index f21db0f133..994ca53a0f 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -420,6 +420,14 @@ static bool checkColumnName(SAstCreateContext* pCxt, const SToken* pColumnName) return pCxt->valid; } +static bool checkIndexName(SAstCreateContext* pCxt, const SToken* pIndexName) { + if (NULL == pIndexName) { + return false; + } + pCxt->valid = pIndexName->n < TSDB_INDEX_NAME_LEN ? true : false; + return pCxt->valid; +} + SNode* createRawExprNode(SAstCreateContext* pCxt, const SToken* pToken, SNode* pNode) { SRawExprNode* target = (SRawExprNode*)nodesMakeNode(QUERY_NODE_RAW_EXPR); CHECK_OUT_OF_MEM(target); @@ -741,8 +749,8 @@ SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode* return (SNode*)setOp; } -SDatabaseOptions* createDefaultDatabaseOptions(SAstCreateContext* pCxt) { - SDatabaseOptions* pOptions = calloc(1, sizeof(SDatabaseOptions)); +SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt) { + SDatabaseOptions* pOptions = nodesMakeNode(QUERY_NODE_DATABASE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->numOfBlocks = TSDB_DEFAULT_TOTAL_BLOCKS; pOptions->cacheBlockSize = TSDB_DEFAULT_CACHE_BLOCK_SIZE; @@ -761,14 +769,14 @@ SDatabaseOptions* createDefaultDatabaseOptions(SAstCreateContext* pCxt) { pOptions->numOfVgroups = TSDB_DEFAULT_VN_PER_DB; pOptions->singleStable = TSDB_DEFAULT_DB_SINGLE_STABLE_OPTION; pOptions->streamMode = TSDB_DEFAULT_DB_STREAM_MODE_OPTION; - return pOptions; + return (SNode*)pOptions; } -SDatabaseOptions* setDatabaseOption(SAstCreateContext* pCxt, SDatabaseOptions* pOptions, EDatabaseOptionType type, const SToken* pVal) { - return setDbOptionFuncs[type](pCxt, pOptions, pVal); +SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, const SToken* pVal) { + return (SNode*)setDbOptionFuncs[type](pCxt, (SDatabaseOptions*)pOptions, pVal); } -SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pDbName, SDatabaseOptions* pOptions) { +SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pDbName, SNode* pOptions) { if (!checkDbName(pCxt, pDbName)) { return NULL; } @@ -776,8 +784,7 @@ SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, cons CHECK_OUT_OF_MEM(pStmt); strncpy(pStmt->dbName, pDbName->z, pDbName->n); pStmt->ignoreExists = ignoreExists; - pStmt->options = *pOptions; - tfree(pOptions); + pStmt->pOptions = (SDatabaseOptions*)pOptions; return (SNode*)pStmt; } @@ -792,20 +799,20 @@ SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, con return (SNode*)pStmt; } -STableOptions* createDefaultTableOptions(SAstCreateContext* pCxt) { - STableOptions* pOptions = calloc(1, sizeof(STableOptions)); +SNode* createDefaultTableOptions(SAstCreateContext* pCxt) { + STableOptions* pOptions = nodesMakeNode(QUERY_NODE_TABLE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); pOptions->keep = TSDB_DEFAULT_KEEP; pOptions->ttl = TSDB_DEFAULT_DB_TTL_OPTION; - return pOptions; + return (SNode*)pOptions; } -STableOptions* setTableOption(SAstCreateContext* pCxt, STableOptions* pOptions, ETableOptionType type, const SToken* pVal) { - return setTableOptionFuncs[type](pCxt, pOptions, pVal); +SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, const SToken* pVal) { + return (SNode*)setTableOptionFuncs[type](pCxt, (STableOptions*)pOptions, pVal); } -STableOptions* setTableSmaOption(SAstCreateContext* pCxt, STableOptions* pOptions, SNodeList* pSma) { - pOptions->pSma = pSma; +SNode* setTableSmaOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pSma) { + ((STableOptions*)pOptions)->pSma = pSma; return pOptions; } @@ -831,7 +838,7 @@ SDataType createVarLenDataType(uint8_t type, const SToken* pLen) { } SNode* createCreateTableStmt(SAstCreateContext* pCxt, - bool ignoreExists, SNode* pRealTable, SNodeList* pCols, SNodeList* pTags, STableOptions* pOptions) { + bool ignoreExists, SNode* pRealTable, SNodeList* pCols, SNodeList* pTags, SNode* pOptions) { SCreateTableStmt* pStmt = (SCreateTableStmt*)nodesMakeNode(QUERY_NODE_CREATE_TABLE_STMT); CHECK_OUT_OF_MEM(pStmt); strcpy(pStmt->dbName, ((SRealTableNode*)pRealTable)->table.dbName); @@ -839,9 +846,7 @@ SNode* createCreateTableStmt(SAstCreateContext* pCxt, pStmt->ignoreExists = ignoreExists; pStmt->pCols = pCols; pStmt->pTags = pTags; - pStmt->options = *pOptions; - nodesDestroyList(pOptions->pSma); - tfree(pOptions); + pStmt->pOptions = (STableOptions*)pOptions; nodesDestroyNode(pRealTable); return (SNode*)pStmt; } @@ -992,3 +997,27 @@ SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode) { } return (SNode*)pStmt; } + +SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, const SToken* pIndexName, const SToken* pTableName, SNodeList* pCols, SNode* pOptions) { + if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName)) { + return NULL; + } + SCreateIndexStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_INDEX_STMT); + CHECK_OUT_OF_MEM(pStmt); + pStmt->indexType = type; + strncpy(pStmt->indexName, pIndexName->z, pIndexName->n); + strncpy(pStmt->tableName, pTableName->z, pTableName->n); + pStmt->pCols = pCols; + pStmt->pOptions = (SIndexOptions*)pOptions; + return (SNode*)pStmt; +} + +SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding) { + SIndexOptions* pOptions = nodesMakeNode(QUERY_NODE_INDEX_OPTIONS); + CHECK_OUT_OF_MEM(pOptions); + pOptions->pFuncs = pFuncs; + pOptions->pInterval = pInterval; + pOptions->pOffset = pOffset; + pOptions->pSliding = pSliding; + return (SNode*)pOptions; +} diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index eefa99dae0..57ff6d53a4 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -59,11 +59,13 @@ static SKeyword keywordTable[] = { {"FLOAT", TK_FLOAT}, {"FROM", TK_FROM}, {"FSYNC", TK_FSYNC}, + {"FUNCTION", TK_FUNCTION}, {"GROUP", TK_GROUP}, {"HAVING", TK_HAVING}, {"IF", TK_IF}, {"IMPORT", TK_IMPORT}, {"IN", TK_IN}, + {"INDEX", TK_INDEX}, {"INNER", TK_INNER}, {"INT", TK_INT}, {"INSERT", TK_INSERT}, @@ -230,7 +232,6 @@ static SKeyword keywordTable[] = { // {"TOPICS", TK_TOPICS}, // {"COMPACT", TK_COMPACT}, // {"MODIFY", TK_MODIFY}, - // {"FUNCTION", TK_FUNCTION}, // {"FUNCTIONS", TK_FUNCTIONS}, // {"OUTPUTTYPE", TK_OUTPUTTYPE}, // {"AGGREGATE", TK_AGGREGATE}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index c1ba59dd84..3fff4fa4ca 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -254,8 +254,7 @@ static int32_t trimStringWithVarFormat(const char* src, int32_t len, bool format static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal) { if (pVal->isDuration) { - char unit = 0; - if (parseAbsoluteDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &unit, pVal->node.resType.precision) != TSDB_CODE_SUCCESS) { + if (parseAbsoluteDuration(pVal->literal, strlen(pVal->literal), &pVal->datum.i, &pVal->unit, pVal->node.resType.precision) != TSDB_CODE_SUCCESS) { return generateDealNodeErrMsg(pCxt, TSDB_CODE_PAR_WRONG_VALUE_TYPE, pVal->literal); } } else { @@ -768,26 +767,26 @@ static void buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pStmt SName name = {0}; tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); tNameGetFullDbName(&name, pReq->db); - pReq->numOfVgroups = pStmt->options.numOfVgroups; - pReq->cacheBlockSize = pStmt->options.cacheBlockSize; - pReq->totalBlocks = pStmt->options.numOfBlocks; - pReq->daysPerFile = pStmt->options.daysPerFile; - pReq->daysToKeep0 = pStmt->options.keep; + pReq->numOfVgroups = pStmt->pOptions->numOfVgroups; + pReq->cacheBlockSize = pStmt->pOptions->cacheBlockSize; + pReq->totalBlocks = pStmt->pOptions->numOfBlocks; + pReq->daysPerFile = pStmt->pOptions->daysPerFile; + pReq->daysToKeep0 = pStmt->pOptions->keep; pReq->daysToKeep1 = -1; pReq->daysToKeep2 = -1; - pReq->minRows = pStmt->options.minRowsPerBlock; - pReq->maxRows = pStmt->options.maxRowsPerBlock; + pReq->minRows = pStmt->pOptions->minRowsPerBlock; + pReq->maxRows = pStmt->pOptions->maxRowsPerBlock; pReq->commitTime = -1; - pReq->fsyncPeriod = pStmt->options.fsyncPeriod; - pReq->walLevel = pStmt->options.walLevel; - pReq->precision = pStmt->options.precision; - pReq->compression = pStmt->options.compressionLevel; - pReq->replications = pStmt->options.replica; - pReq->quorum = pStmt->options.quorum; + pReq->fsyncPeriod = pStmt->pOptions->fsyncPeriod; + pReq->walLevel = pStmt->pOptions->walLevel; + pReq->precision = pStmt->pOptions->precision; + pReq->compression = pStmt->pOptions->compressionLevel; + pReq->replications = pStmt->pOptions->replica; + pReq->quorum = pStmt->pOptions->quorum; pReq->update = -1; - pReq->cacheLastRow = pStmt->options.cachelast; + pReq->cacheLastRow = pStmt->pOptions->cachelast; pReq->ignoreExist = pStmt->ignoreExists; - pReq->streamMode = pStmt->options.streamMode; + pReq->streamMode = pStmt->pOptions->streamMode; return; } @@ -1141,6 +1140,63 @@ static int32_t translateShowTables(STranslateContext* pCxt) { return TSDB_CODE_SUCCESS; } +static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) { + SVCreateTSmaReq createSmaReq = {0}; + + if (DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pInterval) || + (NULL != pStmt->pOptions->pOffset && DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pOffset)) || + (NULL != pStmt->pOptions->pSliding && DEAL_RES_ERROR == translateValue(pCxt, (SValueNode*)pStmt->pOptions->pSliding))) { + return pCxt->errCode; + } + + createSmaReq.tSma.intervalUnit = ((SValueNode*)pStmt->pOptions->pInterval)->unit; + createSmaReq.tSma.slidingUnit = (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->unit : 0); + strcpy(createSmaReq.tSma.indexName, pStmt->indexName); + + SName name; + name.type = TSDB_TABLE_NAME_T; + name.acctId = pCxt->pParseCxt->acctId; + strcpy(name.dbname, pCxt->pParseCxt->db); + strcpy(name.tname, pStmt->tableName); + STableMeta* pMeta = NULL; + int32_t code = catalogGetTableMeta(pCxt->pParseCxt->pCatalog, pCxt->pParseCxt->pTransporter, &pCxt->pParseCxt->mgmtEpSet, &name, &pMeta); + if (TSDB_CODE_SUCCESS != code) { + return code; + } + + createSmaReq.tSma.tableUid = pMeta->uid; + createSmaReq.tSma.interval = ((SValueNode*)pStmt->pOptions->pInterval)->datum.i; + createSmaReq.tSma.sliding = (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->datum.i : 0); + code = nodesListToString(pStmt->pCols, false, &createSmaReq.tSma.expr, &createSmaReq.tSma.exprLen); + if (TSDB_CODE_SUCCESS != code) { + return code; + } + + pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); + if (NULL== pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_VND_CREATE_SMA; + pCxt->pCmdMsg->msgLen = tSerializeSVCreateTSmaReq(NULL, &createSmaReq); + pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); + if (NULL== pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + tSerializeSVCreateTSmaReq(pCxt->pCmdMsg->pMsg, &createSmaReq); + + return TSDB_CODE_SUCCESS; +} + +static int32_t translateCreateIndex(STranslateContext* pCxt, SCreateIndexStmt* pStmt) { + if (INDEX_TYPE_SMA == pStmt->indexType) { + return translateCreateSmaIndex(pCxt, pStmt); + } else { + // todo fulltext index + return TSDB_CODE_FAILED; + } +} + static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pNode)) { @@ -1191,6 +1247,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_SHOW_TABLES_STMT: code = translateShowTables(pCxt); break; + case QUERY_NODE_CREATE_INDEX_STMT: + code = translateCreateIndex(pCxt, (SCreateIndexStmt*)pNode); + break; default: break; } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index c54bbd41cc..ae20ecdd7e 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -99,24 +99,22 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned char -#define YYNOCODE 209 +#define YYNOCODE 216 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SNodeList* yy46; - SDataType yy70; - SToken yy129; - ENullOrder yy147; - bool yy185; - EOrder yy202; - SNode* yy256; - EJoinType yy266; - EOperatorType yy326; - STableOptions* yy340; - EFillMode yy360; - SDatabaseOptions* yy391; + EOrder yy2; + EJoinType yy36; + SToken yy209; + ENullOrder yy217; + EOperatorType yy236; + SNodeList* yy280; + bool yy281; + SDataType yy304; + EFillMode yy342; + SNode* yy344; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -131,17 +129,17 @@ typedef union { #define ParseCTX_PARAM #define ParseCTX_FETCH #define ParseCTX_STORE -#define YYNSTATE 279 -#define YYNRULE 237 -#define YYNTOKEN 135 -#define YY_MAX_SHIFT 278 -#define YY_MIN_SHIFTREDUCE 439 -#define YY_MAX_SHIFTREDUCE 675 -#define YY_ERROR_ACTION 676 -#define YY_ACCEPT_ACTION 677 -#define YY_NO_ACTION 678 -#define YY_MIN_REDUCE 679 -#define YY_MAX_REDUCE 915 +#define YYNSTATE 308 +#define YYNRULE 246 +#define YYNTOKEN 138 +#define YY_MAX_SHIFT 307 +#define YY_MIN_SHIFTREDUCE 475 +#define YY_MAX_SHIFTREDUCE 720 +#define YY_ERROR_ACTION 721 +#define YY_ACCEPT_ACTION 722 +#define YY_NO_ACTION 723 +#define YY_MIN_REDUCE 724 +#define YY_MAX_REDUCE 969 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -208,285 +206,318 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (905) +#define YY_ACTTAB_COUNT (1037) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 137, 149, 23, 95, 772, 721, 770, 247, 150, 784, - /* 10 */ 782, 148, 30, 28, 26, 25, 24, 784, 782, 194, - /* 20 */ 177, 808, 201, 735, 66, 30, 28, 26, 25, 24, - /* 30 */ 692, 166, 194, 222, 808, 60, 208, 132, 793, 782, - /* 40 */ 195, 209, 222, 54, 794, 730, 797, 833, 733, 58, - /* 50 */ 132, 139, 829, 906, 19, 785, 782, 733, 558, 73, - /* 60 */ 840, 841, 867, 845, 30, 28, 26, 25, 24, 271, - /* 70 */ 270, 269, 268, 267, 266, 265, 264, 263, 262, 261, - /* 80 */ 260, 259, 258, 257, 256, 255, 26, 25, 24, 550, - /* 90 */ 22, 141, 171, 576, 577, 578, 579, 580, 581, 582, - /* 100 */ 584, 585, 586, 22, 141, 617, 576, 577, 578, 579, - /* 110 */ 580, 581, 582, 584, 585, 586, 275, 274, 499, 245, - /* 120 */ 244, 243, 503, 242, 505, 506, 241, 508, 238, 41, - /* 130 */ 514, 235, 516, 517, 232, 229, 194, 194, 808, 808, - /* 140 */ 729, 184, 793, 782, 195, 77, 45, 53, 794, 170, - /* 150 */ 797, 833, 194, 719, 808, 131, 829, 726, 793, 782, - /* 160 */ 195, 104, 93, 125, 794, 145, 797, 894, 153, 78, - /* 170 */ 221, 772, 180, 770, 808, 103, 736, 66, 793, 782, - /* 180 */ 195, 76, 209, 54, 794, 892, 797, 833, 194, 254, - /* 190 */ 808, 139, 829, 71, 793, 782, 195, 221, 42, 54, - /* 200 */ 794, 101, 797, 833, 772, 94, 771, 139, 829, 906, - /* 210 */ 616, 156, 860, 894, 180, 254, 808, 551, 890, 50, - /* 220 */ 793, 782, 195, 10, 47, 54, 794, 893, 797, 833, - /* 230 */ 194, 892, 808, 139, 829, 71, 793, 782, 195, 29, - /* 240 */ 27, 54, 794, 677, 797, 833, 41, 187, 539, 139, - /* 250 */ 829, 906, 114, 61, 861, 763, 537, 728, 146, 221, - /* 260 */ 851, 29, 27, 618, 11, 194, 182, 808, 196, 548, - /* 270 */ 539, 793, 782, 195, 77, 639, 121, 794, 537, 797, - /* 280 */ 146, 194, 56, 808, 1, 10, 11, 793, 782, 195, - /* 290 */ 79, 51, 55, 794, 894, 797, 833, 9, 8, 62, - /* 300 */ 832, 829, 725, 223, 222, 449, 1, 219, 76, 173, - /* 310 */ 248, 152, 892, 212, 538, 540, 543, 720, 191, 733, - /* 320 */ 194, 573, 808, 735, 66, 223, 793, 782, 195, 6, - /* 330 */ 613, 125, 794, 157, 797, 77, 538, 540, 543, 194, - /* 340 */ 222, 808, 96, 220, 184, 793, 782, 195, 29, 27, - /* 350 */ 119, 794, 163, 797, 594, 733, 847, 539, 172, 167, - /* 360 */ 165, 88, 29, 27, 251, 537, 188, 146, 250, 186, - /* 370 */ 894, 539, 222, 11, 844, 109, 847, 177, 852, 537, - /* 380 */ 613, 146, 192, 252, 76, 863, 154, 733, 892, 194, - /* 390 */ 177, 808, 60, 1, 843, 793, 782, 195, 735, 66, - /* 400 */ 55, 794, 249, 797, 833, 60, 58, 7, 181, 829, - /* 410 */ 184, 449, 223, 9, 8, 179, 72, 840, 841, 58, - /* 420 */ 845, 450, 451, 538, 540, 543, 223, 85, 189, 91, - /* 430 */ 840, 176, 625, 175, 82, 847, 894, 538, 540, 543, - /* 440 */ 178, 98, 29, 27, 183, 222, 29, 27, 155, 548, - /* 450 */ 76, 539, 809, 842, 892, 539, 674, 675, 77, 537, - /* 460 */ 733, 146, 194, 537, 808, 146, 20, 2, 793, 782, - /* 470 */ 195, 29, 27, 55, 794, 583, 797, 833, 587, 211, - /* 480 */ 539, 217, 830, 551, 215, 642, 539, 7, 537, 588, - /* 490 */ 146, 1, 864, 194, 537, 808, 31, 164, 161, 793, - /* 500 */ 782, 195, 555, 874, 68, 794, 223, 797, 80, 31, - /* 510 */ 223, 162, 640, 641, 643, 644, 7, 538, 540, 543, - /* 520 */ 789, 538, 540, 543, 106, 543, 194, 787, 808, 492, - /* 530 */ 159, 63, 793, 782, 195, 223, 64, 125, 794, 140, - /* 540 */ 797, 223, 873, 185, 907, 718, 538, 540, 543, 194, - /* 550 */ 160, 808, 538, 540, 543, 793, 782, 195, 487, 84, - /* 560 */ 68, 794, 138, 797, 194, 56, 808, 5, 854, 174, - /* 570 */ 793, 782, 195, 520, 70, 120, 794, 524, 797, 194, - /* 580 */ 227, 808, 4, 87, 63, 793, 782, 195, 158, 613, - /* 590 */ 122, 794, 251, 797, 89, 194, 250, 808, 529, 547, - /* 600 */ 908, 793, 782, 195, 59, 64, 117, 794, 65, 797, - /* 610 */ 194, 252, 808, 550, 848, 63, 793, 782, 195, 32, - /* 620 */ 16, 123, 794, 142, 797, 194, 815, 808, 90, 909, - /* 630 */ 249, 793, 782, 195, 193, 891, 118, 794, 194, 797, - /* 640 */ 808, 97, 546, 190, 793, 782, 195, 197, 210, 124, - /* 650 */ 794, 194, 797, 808, 40, 102, 552, 793, 782, 195, - /* 660 */ 734, 213, 805, 794, 147, 797, 194, 46, 808, 113, - /* 670 */ 44, 225, 793, 782, 195, 115, 110, 804, 794, 194, - /* 680 */ 797, 808, 278, 3, 128, 793, 782, 195, 129, 116, - /* 690 */ 803, 794, 31, 797, 194, 14, 808, 81, 636, 83, - /* 700 */ 793, 782, 195, 35, 638, 135, 794, 194, 797, 808, - /* 710 */ 69, 86, 37, 793, 782, 195, 632, 631, 134, 794, - /* 720 */ 194, 797, 808, 168, 38, 169, 793, 782, 195, 787, - /* 730 */ 610, 136, 794, 18, 797, 194, 15, 808, 609, 92, - /* 740 */ 207, 793, 782, 195, 206, 546, 133, 794, 205, 797, - /* 750 */ 33, 194, 34, 808, 75, 8, 574, 793, 782, 195, - /* 760 */ 556, 665, 126, 794, 17, 797, 177, 202, 12, 39, - /* 770 */ 660, 659, 143, 664, 204, 203, 30, 28, 26, 25, - /* 780 */ 24, 60, 99, 663, 130, 144, 13, 776, 218, 695, - /* 790 */ 127, 67, 775, 774, 112, 58, 200, 773, 199, 724, - /* 800 */ 198, 100, 57, 21, 723, 74, 840, 841, 111, 845, - /* 810 */ 694, 688, 683, 30, 28, 26, 25, 24, 30, 28, - /* 820 */ 26, 25, 24, 722, 458, 693, 30, 28, 26, 25, - /* 830 */ 24, 52, 687, 686, 107, 682, 681, 214, 680, 216, - /* 840 */ 105, 43, 47, 786, 226, 108, 224, 541, 36, 151, - /* 850 */ 513, 230, 521, 228, 512, 511, 518, 231, 233, 236, - /* 860 */ 515, 509, 234, 239, 558, 237, 510, 507, 498, 528, - /* 870 */ 240, 527, 526, 246, 77, 456, 48, 477, 253, 476, - /* 880 */ 470, 49, 475, 474, 473, 472, 471, 469, 685, 468, - /* 890 */ 467, 466, 465, 464, 671, 672, 463, 462, 461, 272, - /* 900 */ 273, 684, 679, 276, 277, + /* 0 */ 152, 235, 276, 862, 835, 251, 251, 167, 185, 775, + /* 10 */ 838, 835, 31, 29, 27, 26, 25, 837, 835, 208, + /* 20 */ 778, 778, 165, 178, 837, 31, 29, 27, 26, 25, + /* 30 */ 737, 39, 9, 8, 780, 70, 151, 145, 61, 817, + /* 40 */ 250, 815, 773, 235, 251, 862, 235, 248, 862, 164, + /* 50 */ 145, 835, 823, 238, 237, 24, 109, 847, 603, 778, + /* 60 */ 58, 848, 851, 887, 212, 662, 10, 886, 883, 300, + /* 70 */ 299, 298, 297, 296, 295, 294, 293, 292, 291, 290, + /* 80 */ 289, 288, 287, 286, 285, 284, 304, 303, 250, 639, + /* 90 */ 31, 29, 27, 26, 25, 23, 159, 592, 621, 622, + /* 100 */ 623, 624, 625, 626, 627, 629, 630, 631, 23, 159, + /* 110 */ 186, 621, 622, 623, 624, 625, 626, 627, 629, 630, + /* 120 */ 631, 31, 29, 27, 26, 25, 535, 274, 273, 272, + /* 130 */ 539, 271, 541, 542, 270, 544, 267, 20, 550, 264, + /* 140 */ 552, 553, 261, 258, 235, 87, 862, 31, 29, 27, + /* 150 */ 26, 25, 835, 75, 766, 237, 213, 223, 847, 86, + /* 160 */ 82, 56, 848, 851, 887, 54, 948, 603, 144, 883, + /* 170 */ 250, 130, 219, 65, 661, 195, 770, 134, 71, 947, + /* 180 */ 948, 593, 40, 946, 222, 84, 862, 64, 83, 764, + /* 190 */ 186, 583, 835, 81, 39, 237, 10, 946, 847, 581, + /* 200 */ 223, 57, 848, 851, 887, 774, 62, 207, 154, 883, + /* 210 */ 76, 716, 717, 27, 26, 25, 102, 894, 218, 485, + /* 220 */ 217, 166, 105, 948, 817, 283, 815, 189, 200, 914, + /* 230 */ 222, 125, 862, 283, 214, 209, 81, 594, 835, 60, + /* 240 */ 946, 237, 485, 277, 847, 124, 252, 57, 848, 851, + /* 250 */ 887, 82, 486, 487, 154, 883, 76, 251, 226, 235, + /* 260 */ 249, 862, 582, 584, 587, 82, 251, 835, 55, 122, + /* 270 */ 237, 120, 778, 847, 106, 915, 57, 848, 851, 887, + /* 280 */ 169, 778, 205, 154, 883, 960, 99, 235, 251, 862, + /* 290 */ 722, 172, 780, 70, 921, 835, 171, 247, 237, 127, + /* 300 */ 199, 847, 808, 778, 57, 848, 851, 887, 780, 70, + /* 310 */ 595, 154, 883, 960, 48, 104, 235, 188, 862, 21, + /* 320 */ 30, 28, 944, 173, 835, 771, 220, 237, 628, 583, + /* 330 */ 847, 632, 230, 57, 848, 851, 887, 581, 765, 161, + /* 340 */ 154, 883, 960, 6, 901, 12, 948, 30, 28, 663, + /* 350 */ 170, 905, 901, 817, 863, 815, 583, 917, 901, 81, + /* 360 */ 235, 898, 862, 946, 581, 1, 161, 658, 835, 897, + /* 370 */ 234, 237, 12, 223, 847, 896, 670, 133, 848, 851, + /* 380 */ 227, 824, 238, 225, 252, 280, 30, 28, 91, 279, + /* 390 */ 781, 70, 1, 592, 108, 583, 948, 30, 28, 231, + /* 400 */ 582, 584, 587, 581, 281, 161, 583, 174, 817, 81, + /* 410 */ 816, 252, 194, 946, 581, 192, 161, 906, 658, 196, + /* 420 */ 82, 2, 12, 278, 590, 684, 68, 582, 584, 587, + /* 430 */ 618, 7, 59, 96, 633, 235, 763, 862, 9, 8, + /* 440 */ 94, 32, 1, 835, 600, 228, 237, 719, 720, 847, + /* 450 */ 252, 32, 58, 848, 851, 887, 30, 28, 236, 233, + /* 460 */ 883, 252, 842, 30, 28, 583, 582, 584, 587, 840, + /* 470 */ 38, 53, 583, 581, 576, 161, 50, 582, 584, 587, + /* 480 */ 581, 32, 161, 280, 187, 85, 82, 279, 30, 28, + /* 490 */ 190, 184, 235, 596, 862, 183, 590, 583, 150, 182, + /* 500 */ 835, 7, 281, 237, 197, 581, 847, 161, 7, 72, + /* 510 */ 848, 851, 114, 591, 206, 219, 243, 119, 179, 112, + /* 520 */ 252, 278, 528, 66, 67, 181, 180, 252, 523, 68, + /* 530 */ 64, 597, 556, 1, 198, 59, 582, 584, 587, 256, + /* 540 */ 595, 560, 918, 582, 584, 587, 224, 961, 67, 62, + /* 550 */ 565, 928, 252, 241, 92, 69, 175, 68, 221, 77, + /* 560 */ 894, 895, 67, 899, 235, 587, 862, 203, 582, 584, + /* 570 */ 587, 95, 835, 927, 153, 237, 5, 98, 847, 908, + /* 580 */ 74, 58, 848, 851, 887, 100, 235, 687, 862, 884, + /* 590 */ 202, 4, 216, 63, 835, 658, 594, 237, 160, 902, + /* 600 */ 847, 945, 33, 138, 848, 851, 101, 155, 235, 232, + /* 610 */ 862, 204, 685, 686, 688, 689, 835, 963, 229, 237, + /* 620 */ 201, 107, 847, 17, 869, 138, 848, 851, 822, 239, + /* 630 */ 244, 235, 126, 862, 240, 49, 821, 47, 123, 835, + /* 640 */ 307, 254, 237, 245, 116, 847, 163, 128, 137, 848, + /* 650 */ 851, 235, 142, 862, 246, 129, 779, 143, 829, 835, + /* 660 */ 176, 177, 237, 740, 235, 847, 862, 828, 72, 848, + /* 670 */ 851, 827, 835, 494, 738, 237, 158, 191, 847, 215, + /* 680 */ 826, 138, 848, 851, 769, 768, 235, 739, 862, 31, + /* 690 */ 29, 27, 26, 25, 835, 88, 193, 237, 162, 733, + /* 700 */ 847, 728, 767, 138, 848, 851, 962, 732, 731, 727, + /* 710 */ 726, 235, 219, 862, 725, 819, 41, 89, 90, 835, + /* 720 */ 3, 14, 237, 93, 683, 847, 32, 64, 136, 848, + /* 730 */ 851, 235, 210, 862, 36, 73, 97, 211, 42, 835, + /* 740 */ 677, 676, 237, 43, 15, 847, 62, 34, 139, 848, + /* 750 */ 851, 655, 840, 235, 19, 862, 78, 894, 895, 35, + /* 760 */ 899, 835, 654, 16, 237, 11, 705, 847, 44, 103, + /* 770 */ 131, 848, 851, 704, 710, 235, 80, 862, 156, 709, + /* 780 */ 708, 157, 8, 835, 601, 110, 237, 619, 13, 847, + /* 790 */ 18, 113, 140, 848, 851, 818, 111, 681, 235, 115, + /* 800 */ 862, 242, 45, 46, 117, 118, 835, 839, 585, 237, + /* 810 */ 50, 121, 847, 37, 255, 132, 848, 851, 235, 557, + /* 820 */ 862, 253, 168, 257, 534, 554, 835, 259, 260, 237, + /* 830 */ 551, 235, 847, 862, 262, 141, 848, 851, 263, 835, + /* 840 */ 545, 265, 237, 266, 268, 847, 543, 269, 859, 848, + /* 850 */ 851, 549, 548, 235, 547, 862, 546, 275, 51, 52, + /* 860 */ 564, 835, 563, 562, 237, 506, 492, 847, 513, 512, + /* 870 */ 858, 848, 851, 282, 511, 510, 509, 508, 235, 507, + /* 880 */ 862, 505, 504, 503, 502, 501, 835, 500, 499, 237, + /* 890 */ 498, 497, 847, 730, 301, 857, 848, 851, 235, 302, + /* 900 */ 862, 729, 724, 305, 306, 723, 835, 723, 723, 237, + /* 910 */ 723, 723, 847, 723, 723, 148, 848, 851, 723, 723, + /* 920 */ 235, 723, 862, 723, 723, 723, 723, 723, 835, 723, + /* 930 */ 723, 237, 723, 723, 847, 723, 723, 147, 848, 851, + /* 940 */ 723, 723, 235, 723, 862, 723, 723, 723, 723, 723, + /* 950 */ 835, 723, 723, 237, 723, 723, 847, 723, 723, 149, + /* 960 */ 848, 851, 723, 723, 723, 235, 723, 862, 723, 723, + /* 970 */ 723, 723, 723, 835, 723, 219, 237, 723, 723, 847, + /* 980 */ 723, 723, 146, 848, 851, 235, 723, 862, 723, 723, + /* 990 */ 64, 723, 723, 835, 723, 723, 237, 723, 723, 847, + /* 1000 */ 723, 723, 135, 848, 851, 723, 723, 723, 723, 62, + /* 1010 */ 723, 723, 723, 723, 723, 723, 723, 723, 723, 79, + /* 1020 */ 894, 895, 22, 899, 723, 723, 723, 723, 723, 723, + /* 1030 */ 723, 723, 31, 29, 27, 26, 25, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 152, 154, 171, 172, 157, 0, 159, 158, 152, 161, - /* 10 */ 162, 144, 12, 13, 14, 15, 16, 161, 162, 155, - /* 20 */ 140, 157, 140, 156, 157, 12, 13, 14, 15, 16, - /* 30 */ 0, 167, 155, 140, 157, 155, 143, 37, 161, 162, - /* 40 */ 163, 36, 140, 166, 167, 143, 169, 170, 155, 169, - /* 50 */ 37, 174, 175, 176, 2, 161, 162, 155, 58, 179, - /* 60 */ 180, 181, 185, 183, 12, 13, 14, 15, 16, 39, + /* 0 */ 155, 158, 161, 160, 166, 143, 143, 155, 146, 146, + /* 10 */ 172, 166, 12, 13, 14, 15, 16, 172, 166, 176, + /* 20 */ 158, 158, 147, 143, 172, 12, 13, 14, 15, 16, + /* 30 */ 0, 145, 1, 2, 159, 160, 157, 37, 152, 160, + /* 40 */ 31, 162, 156, 158, 143, 160, 158, 146, 160, 165, + /* 50 */ 37, 166, 168, 169, 169, 179, 180, 172, 58, 158, + /* 60 */ 175, 176, 177, 178, 176, 4, 57, 182, 183, 39, /* 70 */ 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - /* 80 */ 50, 51, 52, 53, 54, 55, 14, 15, 16, 31, - /* 90 */ 90, 91, 31, 93, 94, 95, 96, 97, 98, 99, - /* 100 */ 100, 101, 102, 90, 91, 4, 93, 94, 95, 96, - /* 110 */ 97, 98, 99, 100, 101, 102, 137, 138, 67, 68, - /* 120 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 142, - /* 130 */ 79, 80, 81, 82, 83, 84, 155, 155, 157, 157, - /* 140 */ 153, 160, 161, 162, 163, 108, 139, 166, 167, 167, - /* 150 */ 169, 170, 155, 0, 157, 174, 175, 150, 161, 162, - /* 160 */ 163, 19, 104, 166, 167, 168, 169, 186, 154, 27, - /* 170 */ 31, 157, 155, 159, 157, 33, 156, 157, 161, 162, - /* 180 */ 163, 200, 36, 166, 167, 204, 169, 170, 155, 36, - /* 190 */ 157, 174, 175, 176, 161, 162, 163, 31, 56, 166, - /* 200 */ 167, 59, 169, 170, 157, 188, 159, 174, 175, 176, - /* 210 */ 109, 194, 195, 186, 155, 36, 157, 31, 185, 57, - /* 220 */ 161, 162, 163, 57, 62, 166, 167, 200, 169, 170, - /* 230 */ 155, 204, 157, 174, 175, 176, 161, 162, 163, 12, - /* 240 */ 13, 166, 167, 135, 169, 170, 142, 3, 21, 174, - /* 250 */ 175, 176, 145, 149, 195, 148, 29, 153, 31, 31, - /* 260 */ 185, 12, 13, 14, 37, 155, 37, 157, 160, 31, - /* 270 */ 21, 161, 162, 163, 108, 58, 166, 167, 29, 169, - /* 280 */ 31, 155, 65, 157, 57, 57, 37, 161, 162, 163, - /* 290 */ 104, 139, 166, 167, 186, 169, 170, 1, 2, 147, - /* 300 */ 174, 175, 150, 76, 140, 21, 57, 143, 200, 199, - /* 310 */ 63, 144, 204, 29, 87, 88, 89, 0, 65, 155, - /* 320 */ 155, 92, 157, 156, 157, 76, 161, 162, 163, 106, - /* 330 */ 107, 166, 167, 168, 169, 108, 87, 88, 89, 155, - /* 340 */ 140, 157, 207, 143, 160, 161, 162, 163, 12, 13, - /* 350 */ 166, 167, 198, 169, 58, 155, 164, 21, 113, 114, - /* 360 */ 115, 191, 12, 13, 47, 29, 65, 31, 51, 125, - /* 370 */ 186, 21, 140, 37, 182, 143, 164, 140, 105, 29, - /* 380 */ 107, 31, 129, 66, 200, 165, 144, 155, 204, 155, - /* 390 */ 140, 157, 155, 57, 182, 161, 162, 163, 156, 157, - /* 400 */ 166, 167, 85, 169, 170, 155, 169, 57, 174, 175, - /* 410 */ 160, 21, 76, 1, 2, 178, 179, 180, 181, 169, - /* 420 */ 183, 31, 32, 87, 88, 89, 76, 58, 127, 179, - /* 430 */ 180, 181, 14, 183, 65, 164, 186, 87, 88, 89, - /* 440 */ 184, 201, 12, 13, 14, 140, 12, 13, 143, 31, - /* 450 */ 200, 21, 157, 182, 204, 21, 133, 134, 108, 29, - /* 460 */ 155, 31, 155, 29, 157, 31, 90, 187, 161, 162, - /* 470 */ 163, 12, 13, 166, 167, 99, 169, 170, 102, 137, - /* 480 */ 21, 20, 175, 31, 23, 92, 21, 57, 29, 58, - /* 490 */ 31, 57, 165, 155, 29, 157, 65, 117, 116, 161, - /* 500 */ 162, 163, 58, 197, 166, 167, 76, 169, 196, 65, - /* 510 */ 76, 118, 119, 120, 121, 122, 57, 87, 88, 89, - /* 520 */ 57, 87, 88, 89, 58, 89, 155, 64, 157, 58, - /* 530 */ 162, 65, 161, 162, 163, 76, 65, 166, 167, 168, - /* 540 */ 169, 76, 197, 205, 206, 0, 87, 88, 89, 155, - /* 550 */ 162, 157, 87, 88, 89, 161, 162, 163, 58, 196, - /* 560 */ 166, 167, 162, 169, 155, 65, 157, 124, 193, 123, - /* 570 */ 161, 162, 163, 58, 190, 166, 167, 58, 169, 155, - /* 580 */ 65, 157, 110, 192, 65, 161, 162, 163, 111, 107, - /* 590 */ 166, 167, 47, 169, 189, 155, 51, 157, 58, 31, - /* 600 */ 206, 161, 162, 163, 155, 65, 166, 167, 58, 169, - /* 610 */ 155, 66, 157, 31, 164, 65, 161, 162, 163, 103, - /* 620 */ 57, 166, 167, 132, 169, 155, 173, 157, 177, 208, - /* 630 */ 85, 161, 162, 163, 128, 203, 166, 167, 155, 169, - /* 640 */ 157, 202, 31, 126, 161, 162, 163, 140, 140, 166, - /* 650 */ 167, 155, 169, 157, 142, 142, 31, 161, 162, 163, - /* 660 */ 155, 136, 166, 167, 136, 169, 155, 57, 157, 148, - /* 670 */ 139, 151, 161, 162, 163, 140, 139, 166, 167, 155, - /* 680 */ 169, 157, 136, 65, 146, 161, 162, 163, 146, 141, - /* 690 */ 166, 167, 65, 169, 155, 112, 157, 58, 58, 57, - /* 700 */ 161, 162, 163, 65, 58, 166, 167, 155, 169, 157, - /* 710 */ 57, 57, 57, 161, 162, 163, 58, 58, 166, 167, - /* 720 */ 155, 169, 157, 29, 57, 65, 161, 162, 163, 64, - /* 730 */ 58, 166, 167, 65, 169, 155, 112, 157, 58, 64, - /* 740 */ 26, 161, 162, 163, 30, 31, 166, 167, 34, 169, - /* 750 */ 105, 155, 65, 157, 64, 2, 92, 161, 162, 163, - /* 760 */ 58, 58, 166, 167, 65, 169, 140, 53, 112, 4, - /* 770 */ 29, 29, 29, 29, 60, 61, 12, 13, 14, 15, - /* 780 */ 16, 155, 64, 29, 18, 29, 57, 0, 22, 0, - /* 790 */ 24, 25, 0, 0, 19, 169, 64, 0, 53, 0, - /* 800 */ 86, 35, 27, 2, 0, 179, 180, 181, 33, 183, - /* 810 */ 0, 0, 0, 12, 13, 14, 15, 16, 12, 13, - /* 820 */ 14, 15, 16, 0, 38, 0, 12, 13, 14, 15, - /* 830 */ 16, 56, 0, 0, 59, 0, 0, 21, 0, 21, - /* 840 */ 19, 57, 62, 64, 29, 64, 63, 21, 57, 29, - /* 850 */ 78, 29, 58, 57, 78, 78, 58, 57, 29, 29, - /* 860 */ 58, 58, 57, 29, 58, 57, 78, 58, 21, 29, - /* 870 */ 57, 29, 21, 66, 108, 38, 57, 29, 37, 29, - /* 880 */ 21, 57, 29, 29, 29, 29, 29, 29, 0, 29, - /* 890 */ 29, 29, 29, 29, 130, 131, 29, 29, 29, 29, - /* 900 */ 28, 0, 0, 21, 20, 209, 209, 209, 209, 209, - /* 910 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 920 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 930 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 940 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 950 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 960 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 970 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 980 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 990 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 1000 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 1010 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 1020 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, - /* 1030 */ 209, 209, 209, 209, 209, 209, 209, 209, 209, 209, + /* 80 */ 50, 51, 52, 53, 54, 55, 140, 141, 31, 58, + /* 90 */ 12, 13, 14, 15, 16, 95, 96, 31, 98, 99, + /* 100 */ 100, 101, 102, 103, 104, 105, 106, 107, 95, 96, + /* 110 */ 36, 98, 99, 100, 101, 102, 103, 104, 105, 106, + /* 120 */ 107, 12, 13, 14, 15, 16, 67, 68, 69, 70, + /* 130 */ 71, 72, 73, 74, 75, 76, 77, 2, 79, 80, + /* 140 */ 81, 82, 83, 84, 158, 19, 160, 12, 13, 14, + /* 150 */ 15, 16, 166, 27, 0, 169, 31, 171, 172, 33, + /* 160 */ 112, 175, 176, 177, 178, 142, 194, 58, 182, 183, + /* 170 */ 31, 18, 143, 150, 113, 22, 153, 24, 25, 207, + /* 180 */ 194, 31, 56, 211, 158, 59, 160, 158, 35, 0, + /* 190 */ 36, 21, 166, 207, 145, 169, 57, 211, 172, 29, + /* 200 */ 171, 175, 176, 177, 178, 156, 177, 90, 182, 183, + /* 210 */ 184, 133, 134, 14, 15, 16, 187, 188, 189, 21, + /* 220 */ 191, 157, 196, 194, 160, 36, 162, 29, 202, 203, + /* 230 */ 158, 19, 160, 36, 117, 118, 207, 31, 166, 27, + /* 240 */ 211, 169, 21, 63, 172, 33, 76, 175, 176, 177, + /* 250 */ 178, 112, 31, 32, 182, 183, 184, 143, 3, 158, + /* 260 */ 146, 160, 92, 93, 94, 112, 143, 166, 56, 146, + /* 270 */ 169, 59, 158, 172, 214, 203, 175, 176, 177, 178, + /* 280 */ 147, 158, 205, 182, 183, 184, 199, 158, 143, 160, + /* 290 */ 138, 146, 159, 160, 193, 166, 147, 85, 169, 148, + /* 300 */ 88, 172, 151, 158, 175, 176, 177, 178, 159, 160, + /* 310 */ 31, 182, 183, 184, 142, 109, 158, 140, 160, 95, + /* 320 */ 12, 13, 193, 171, 166, 153, 192, 169, 104, 21, + /* 330 */ 172, 107, 65, 175, 176, 177, 178, 29, 0, 31, + /* 340 */ 182, 183, 184, 87, 173, 37, 194, 12, 13, 14, + /* 350 */ 157, 193, 173, 160, 160, 162, 21, 174, 173, 207, + /* 360 */ 158, 190, 160, 211, 29, 57, 31, 111, 166, 190, + /* 370 */ 37, 169, 37, 171, 172, 190, 14, 175, 176, 177, + /* 380 */ 65, 168, 169, 128, 76, 47, 12, 13, 109, 51, + /* 390 */ 159, 160, 57, 31, 208, 21, 194, 12, 13, 132, + /* 400 */ 92, 93, 94, 29, 66, 31, 21, 143, 160, 207, + /* 410 */ 162, 76, 20, 211, 29, 23, 31, 110, 111, 58, + /* 420 */ 112, 195, 37, 85, 31, 58, 65, 92, 93, 94, + /* 430 */ 97, 57, 65, 58, 58, 158, 0, 160, 1, 2, + /* 440 */ 65, 65, 57, 166, 58, 130, 169, 136, 137, 172, + /* 450 */ 76, 65, 175, 176, 177, 178, 12, 13, 14, 182, + /* 460 */ 183, 76, 57, 12, 13, 21, 92, 93, 94, 64, + /* 470 */ 145, 57, 21, 29, 58, 31, 62, 92, 93, 94, + /* 480 */ 29, 65, 31, 47, 143, 145, 112, 51, 12, 13, + /* 490 */ 139, 26, 158, 31, 160, 30, 31, 21, 139, 34, + /* 500 */ 166, 57, 66, 169, 158, 29, 172, 31, 57, 175, + /* 510 */ 176, 177, 58, 31, 120, 143, 58, 58, 53, 65, + /* 520 */ 76, 85, 58, 65, 65, 60, 61, 76, 58, 65, + /* 530 */ 158, 31, 58, 57, 163, 65, 92, 93, 94, 65, + /* 540 */ 31, 58, 174, 92, 93, 94, 212, 213, 65, 177, + /* 550 */ 58, 204, 76, 119, 167, 58, 91, 65, 186, 187, + /* 560 */ 188, 189, 65, 191, 158, 94, 160, 166, 92, 93, + /* 570 */ 94, 167, 166, 204, 166, 169, 127, 200, 172, 201, + /* 580 */ 198, 175, 176, 177, 178, 197, 158, 97, 160, 183, + /* 590 */ 115, 114, 126, 158, 166, 111, 31, 169, 170, 173, + /* 600 */ 172, 210, 108, 175, 176, 177, 185, 135, 158, 131, + /* 610 */ 160, 121, 122, 123, 124, 125, 166, 215, 129, 169, + /* 620 */ 170, 209, 172, 57, 181, 175, 176, 177, 167, 166, + /* 630 */ 89, 158, 151, 160, 166, 57, 167, 142, 142, 166, + /* 640 */ 139, 154, 169, 164, 158, 172, 166, 143, 175, 176, + /* 650 */ 177, 158, 149, 160, 163, 144, 158, 149, 0, 166, + /* 660 */ 53, 64, 169, 0, 158, 172, 160, 0, 175, 176, + /* 670 */ 177, 0, 166, 38, 0, 169, 170, 21, 172, 206, + /* 680 */ 0, 175, 176, 177, 0, 0, 158, 0, 160, 12, + /* 690 */ 13, 14, 15, 16, 166, 19, 21, 169, 170, 0, + /* 700 */ 172, 0, 0, 175, 176, 177, 213, 0, 0, 0, + /* 710 */ 0, 158, 143, 160, 0, 0, 57, 87, 86, 166, + /* 720 */ 65, 116, 169, 58, 58, 172, 65, 158, 175, 176, + /* 730 */ 177, 158, 29, 160, 65, 57, 57, 65, 57, 166, + /* 740 */ 58, 58, 169, 57, 116, 172, 177, 110, 175, 176, + /* 750 */ 177, 58, 64, 158, 65, 160, 187, 188, 189, 65, + /* 760 */ 191, 166, 58, 65, 169, 116, 29, 172, 4, 64, + /* 770 */ 175, 176, 177, 29, 58, 158, 64, 160, 29, 29, + /* 780 */ 29, 29, 2, 166, 58, 64, 169, 97, 57, 172, + /* 790 */ 57, 57, 175, 176, 177, 0, 58, 58, 158, 57, + /* 800 */ 160, 90, 57, 57, 87, 86, 166, 64, 21, 169, + /* 810 */ 62, 64, 172, 57, 29, 175, 176, 177, 158, 58, + /* 820 */ 160, 63, 29, 57, 21, 58, 166, 29, 57, 169, + /* 830 */ 58, 158, 172, 160, 29, 175, 176, 177, 57, 166, + /* 840 */ 58, 29, 169, 57, 29, 172, 58, 57, 175, 176, + /* 850 */ 177, 78, 78, 158, 78, 160, 78, 66, 57, 57, + /* 860 */ 29, 166, 29, 21, 169, 21, 38, 172, 29, 29, + /* 870 */ 175, 176, 177, 37, 29, 29, 29, 29, 158, 29, + /* 880 */ 160, 29, 29, 29, 29, 29, 166, 29, 29, 169, + /* 890 */ 29, 29, 172, 0, 29, 175, 176, 177, 158, 28, + /* 900 */ 160, 0, 0, 21, 20, 216, 166, 216, 216, 169, + /* 910 */ 216, 216, 172, 216, 216, 175, 176, 177, 216, 216, + /* 920 */ 158, 216, 160, 216, 216, 216, 216, 216, 166, 216, + /* 930 */ 216, 169, 216, 216, 172, 216, 216, 175, 176, 177, + /* 940 */ 216, 216, 158, 216, 160, 216, 216, 216, 216, 216, + /* 950 */ 166, 216, 216, 169, 216, 216, 172, 216, 216, 175, + /* 960 */ 176, 177, 216, 216, 216, 158, 216, 160, 216, 216, + /* 970 */ 216, 216, 216, 166, 216, 143, 169, 216, 216, 172, + /* 980 */ 216, 216, 175, 176, 177, 158, 216, 160, 216, 216, + /* 990 */ 158, 216, 216, 166, 216, 216, 169, 216, 216, 172, + /* 1000 */ 216, 216, 175, 176, 177, 216, 216, 216, 216, 177, + /* 1010 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 187, + /* 1020 */ 188, 189, 2, 191, 216, 216, 216, 216, 216, 216, + /* 1030 */ 216, 216, 12, 13, 14, 15, 16, 216, 216, 216, + /* 1040 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1050 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1060 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1070 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1080 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1090 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1100 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1110 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1120 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1130 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1140 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1150 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, + /* 1160 */ 216, }; -#define YY_SHIFT_COUNT (278) +#define YY_SHIFT_COUNT (307) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (902) +#define YY_SHIFT_MAX (1020) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 766, 227, 249, 336, 336, 336, 336, 350, 336, 336, - /* 10 */ 166, 434, 459, 430, 459, 459, 459, 459, 459, 459, - /* 20 */ 459, 459, 459, 459, 459, 459, 459, 459, 459, 459, - /* 30 */ 459, 459, 228, 228, 228, 465, 465, 61, 61, 37, - /* 40 */ 139, 139, 146, 238, 139, 139, 238, 139, 238, 238, - /* 50 */ 238, 139, 179, 0, 13, 13, 465, 390, 58, 58, - /* 60 */ 58, 5, 153, 238, 238, 247, 51, 714, 764, 393, - /* 70 */ 245, 186, 273, 223, 273, 418, 244, 101, 284, 452, - /* 80 */ 380, 382, 436, 436, 380, 382, 436, 443, 446, 477, - /* 90 */ 472, 482, 568, 582, 516, 563, 491, 506, 517, 238, - /* 100 */ 611, 146, 611, 146, 625, 625, 247, 179, 568, 610, - /* 110 */ 611, 179, 625, 905, 905, 905, 30, 52, 801, 806, - /* 120 */ 814, 814, 814, 814, 814, 814, 814, 142, 317, 545, - /* 130 */ 775, 296, 376, 72, 72, 72, 72, 217, 369, 412, - /* 140 */ 431, 229, 323, 301, 253, 444, 463, 461, 466, 471, - /* 150 */ 500, 515, 519, 540, 550, 162, 618, 627, 583, 639, - /* 160 */ 640, 642, 638, 646, 653, 654, 658, 655, 659, 694, - /* 170 */ 660, 665, 667, 668, 624, 672, 680, 675, 645, 687, - /* 180 */ 690, 753, 664, 702, 703, 699, 656, 765, 741, 742, - /* 190 */ 743, 744, 754, 756, 718, 729, 787, 789, 792, 793, - /* 200 */ 745, 732, 797, 799, 804, 810, 811, 812, 823, 786, - /* 210 */ 825, 832, 833, 835, 836, 816, 838, 818, 821, 784, - /* 220 */ 780, 779, 781, 826, 791, 783, 794, 815, 820, 796, - /* 230 */ 798, 822, 800, 802, 829, 805, 803, 830, 808, 809, - /* 240 */ 834, 813, 772, 776, 777, 788, 847, 807, 819, 824, - /* 250 */ 840, 842, 851, 837, 841, 848, 850, 853, 854, 855, - /* 260 */ 856, 857, 859, 858, 860, 861, 862, 863, 864, 867, - /* 270 */ 868, 869, 888, 870, 872, 901, 902, 882, 884, + /* 0 */ 153, 308, 335, 385, 385, 385, 385, 374, 385, 385, + /* 10 */ 139, 451, 476, 444, 451, 451, 451, 451, 451, 451, + /* 20 */ 451, 451, 451, 451, 451, 451, 451, 451, 451, 451, + /* 30 */ 451, 451, 451, 9, 9, 9, 170, 170, 57, 57, + /* 40 */ 74, 66, 125, 125, 48, 150, 66, 57, 57, 66, + /* 50 */ 57, 66, 66, 66, 57, 197, 0, 13, 13, 170, + /* 60 */ 221, 154, 206, 206, 206, 189, 150, 66, 66, 180, + /* 70 */ 59, 465, 78, 490, 117, 198, 279, 307, 256, 307, + /* 80 */ 362, 255, 61, 393, 74, 393, 74, 462, 462, 482, + /* 90 */ 500, 509, 394, 434, 471, 394, 434, 471, 449, 466, + /* 100 */ 475, 477, 484, 482, 565, 494, 472, 478, 489, 566, + /* 110 */ 66, 434, 471, 471, 434, 471, 541, 482, 500, 180, + /* 120 */ 197, 482, 578, 393, 197, 462, 1037, 1037, 1037, 30, + /* 130 */ 212, 135, 1020, 109, 126, 677, 677, 677, 677, 677, + /* 140 */ 677, 677, 338, 436, 31, 224, 199, 199, 199, 199, + /* 150 */ 392, 361, 367, 375, 437, 311, 315, 267, 376, 333, + /* 160 */ 386, 405, 416, 454, 458, 459, 464, 470, 474, 483, + /* 170 */ 492, 497, 414, 658, 663, 667, 671, 607, 597, 680, + /* 180 */ 684, 685, 687, 699, 701, 702, 635, 674, 707, 708, + /* 190 */ 709, 710, 656, 714, 675, 676, 715, 659, 630, 632, + /* 200 */ 655, 661, 605, 665, 669, 666, 678, 679, 682, 681, + /* 210 */ 683, 703, 672, 688, 686, 689, 628, 693, 704, 705, + /* 220 */ 637, 694, 712, 716, 698, 649, 764, 737, 744, 749, + /* 230 */ 750, 751, 752, 780, 690, 721, 726, 731, 733, 738, + /* 240 */ 739, 734, 742, 711, 745, 795, 717, 719, 746, 748, + /* 250 */ 743, 747, 787, 756, 758, 761, 785, 793, 766, 767, + /* 260 */ 798, 771, 772, 805, 781, 782, 812, 786, 788, 815, + /* 270 */ 790, 773, 774, 776, 778, 803, 791, 801, 802, 831, + /* 280 */ 833, 842, 828, 836, 839, 840, 845, 846, 847, 848, + /* 290 */ 850, 844, 852, 853, 854, 855, 856, 858, 859, 861, + /* 300 */ 862, 893, 865, 871, 901, 902, 882, 884, }; -#define YY_REDUCE_COUNT (115) -#define YY_REDUCE_MIN (-169) -#define YY_REDUCE_MAX (626) +#define YY_REDUCE_COUNT (128) +#define YY_REDUCE_MIN (-162) +#define YY_REDUCE_MAX (832) static const short yy_reduce_ofst[] = { - /* 0 */ 108, -19, 17, 59, -123, 33, 75, 184, 126, 234, - /* 10 */ 250, 307, 338, -3, 165, 110, 371, 394, 409, 424, - /* 20 */ 440, 455, 470, 483, 496, 511, 524, 539, 552, 565, - /* 30 */ 580, 596, 237, -120, 626, -152, -144, -136, -18, 27, - /* 40 */ -107, -98, 104, -133, 164, 200, -153, 232, 167, 14, - /* 50 */ 242, 305, 152, -169, -169, -169, -106, -21, 192, 212, - /* 60 */ 271, -13, 7, 20, 47, 107, -151, -118, 135, 154, - /* 70 */ 170, 220, 256, 256, 256, 295, 240, 280, 342, 327, - /* 80 */ 306, 312, 368, 388, 345, 363, 400, 375, 391, 384, - /* 90 */ 405, 256, 449, 450, 451, 453, 421, 432, 439, 295, - /* 100 */ 507, 512, 508, 513, 525, 528, 521, 531, 505, 520, - /* 110 */ 535, 537, 546, 538, 542, 548, + /* 0 */ 152, -14, 26, 72, 101, 129, 158, 202, -115, 277, + /* 10 */ 29, 334, 406, 428, 450, 473, 493, 506, 528, 553, + /* 20 */ 573, 595, 617, 640, 660, 673, 695, 720, 740, 762, + /* 30 */ 784, 807, 827, 372, 569, 832, -155, -148, -138, -137, + /* 40 */ -114, -121, -157, -112, -28, -116, -125, -99, 114, 64, + /* 50 */ 123, 133, 193, 149, 145, 23, -124, -124, -124, -162, + /* 60 */ -54, 49, 171, 179, 185, 172, 213, 231, 248, 151, + /* 70 */ -159, -120, 60, 77, 87, 177, 183, 134, 134, 134, + /* 80 */ 194, 186, 226, 264, 325, 341, 340, 351, 359, 346, + /* 90 */ 371, 368, 347, 387, 401, 369, 404, 408, 378, 377, + /* 100 */ 382, 388, 134, 435, 426, 421, 402, 391, 412, 443, + /* 110 */ 194, 461, 463, 468, 469, 480, 479, 486, 491, 481, + /* 120 */ 495, 498, 487, 504, 496, 501, 503, 508, 511, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - /* 10 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - /* 20 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - /* 30 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - /* 40 */ 676, 676, 699, 676, 676, 676, 676, 676, 676, 676, - /* 50 */ 676, 676, 697, 676, 835, 676, 676, 676, 846, 846, - /* 60 */ 846, 699, 697, 676, 676, 762, 676, 676, 910, 676, - /* 70 */ 870, 862, 838, 852, 839, 676, 895, 855, 676, 676, - /* 80 */ 877, 875, 676, 676, 877, 875, 676, 889, 885, 868, - /* 90 */ 866, 852, 676, 676, 676, 676, 913, 901, 897, 676, - /* 100 */ 676, 699, 676, 699, 676, 676, 676, 697, 676, 731, - /* 110 */ 676, 697, 676, 765, 765, 700, 676, 676, 676, 676, - /* 120 */ 888, 887, 812, 811, 810, 806, 807, 676, 676, 676, - /* 130 */ 676, 676, 676, 801, 802, 800, 799, 676, 676, 836, - /* 140 */ 676, 676, 676, 898, 902, 676, 788, 676, 676, 676, - /* 150 */ 676, 676, 676, 676, 676, 676, 859, 869, 676, 676, - /* 160 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - /* 170 */ 676, 788, 676, 886, 676, 845, 841, 676, 676, 837, - /* 180 */ 676, 831, 676, 676, 676, 896, 676, 676, 676, 676, - /* 190 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - /* 200 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - /* 210 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - /* 220 */ 676, 787, 676, 676, 676, 676, 676, 676, 676, 759, - /* 230 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - /* 240 */ 676, 676, 744, 742, 741, 740, 676, 737, 676, 676, - /* 250 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - /* 260 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, 676, - /* 270 */ 676, 676, 676, 676, 676, 676, 676, 676, 676, + /* 0 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 10 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 20 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 30 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 40 */ 744, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 50 */ 721, 721, 721, 721, 721, 742, 721, 889, 721, 721, + /* 60 */ 721, 744, 900, 900, 900, 742, 721, 721, 721, 807, + /* 70 */ 721, 721, 964, 721, 924, 721, 916, 892, 906, 893, + /* 80 */ 721, 949, 909, 721, 744, 721, 744, 721, 721, 721, + /* 90 */ 721, 721, 931, 929, 721, 931, 929, 721, 943, 939, + /* 100 */ 922, 920, 906, 721, 721, 721, 967, 955, 951, 721, + /* 110 */ 721, 929, 721, 721, 929, 721, 820, 721, 721, 721, + /* 120 */ 742, 721, 776, 721, 742, 721, 810, 810, 745, 721, + /* 130 */ 721, 721, 721, 721, 721, 861, 942, 941, 860, 866, + /* 140 */ 865, 864, 721, 721, 721, 721, 855, 856, 854, 853, + /* 150 */ 721, 721, 721, 721, 890, 721, 952, 956, 721, 721, + /* 160 */ 721, 841, 721, 721, 721, 721, 721, 721, 721, 721, + /* 170 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 180 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 190 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 200 */ 913, 923, 721, 721, 721, 721, 721, 721, 721, 721, + /* 210 */ 721, 721, 721, 841, 721, 940, 721, 899, 895, 721, + /* 220 */ 721, 891, 721, 721, 950, 721, 721, 721, 721, 721, + /* 230 */ 721, 721, 721, 885, 721, 721, 721, 721, 721, 721, + /* 240 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 250 */ 840, 721, 721, 721, 721, 721, 721, 721, 804, 721, + /* 260 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 270 */ 721, 789, 787, 786, 785, 721, 782, 721, 721, 721, + /* 280 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 290 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, + /* 300 */ 721, 721, 721, 721, 721, 721, 721, 721, }; /********** End of lemon-generated parsing tables *****************************/ @@ -679,129 +710,136 @@ static const char *const yyTokenName[] = { /* 83 */ "VARBINARY", /* 84 */ "DECIMAL", /* 85 */ "SMA", - /* 86 */ "MNODES", - /* 87 */ "NK_FLOAT", - /* 88 */ "NK_BOOL", - /* 89 */ "NK_VARIABLE", - /* 90 */ "BETWEEN", - /* 91 */ "IS", - /* 92 */ "NULL", - /* 93 */ "NK_LT", - /* 94 */ "NK_GT", - /* 95 */ "NK_LE", - /* 96 */ "NK_GE", - /* 97 */ "NK_NE", - /* 98 */ "NK_EQ", - /* 99 */ "LIKE", - /* 100 */ "MATCH", - /* 101 */ "NMATCH", - /* 102 */ "IN", - /* 103 */ "FROM", - /* 104 */ "AS", - /* 105 */ "JOIN", - /* 106 */ "ON", - /* 107 */ "INNER", - /* 108 */ "SELECT", - /* 109 */ "DISTINCT", - /* 110 */ "WHERE", - /* 111 */ "PARTITION", - /* 112 */ "BY", - /* 113 */ "SESSION", - /* 114 */ "STATE_WINDOW", - /* 115 */ "INTERVAL", - /* 116 */ "SLIDING", - /* 117 */ "FILL", - /* 118 */ "VALUE", - /* 119 */ "NONE", - /* 120 */ "PREV", - /* 121 */ "LINEAR", - /* 122 */ "NEXT", - /* 123 */ "GROUP", - /* 124 */ "HAVING", - /* 125 */ "ORDER", - /* 126 */ "SLIMIT", - /* 127 */ "SOFFSET", - /* 128 */ "LIMIT", - /* 129 */ "OFFSET", - /* 130 */ "ASC", - /* 131 */ "DESC", - /* 132 */ "NULLS", - /* 133 */ "FIRST", - /* 134 */ "LAST", - /* 135 */ "cmd", - /* 136 */ "user_name", - /* 137 */ "dnode_endpoint", - /* 138 */ "dnode_host_name", - /* 139 */ "not_exists_opt", - /* 140 */ "db_name", - /* 141 */ "db_options", - /* 142 */ "exists_opt", - /* 143 */ "full_table_name", - /* 144 */ "column_def_list", - /* 145 */ "tags_def_opt", - /* 146 */ "table_options", - /* 147 */ "multi_create_clause", - /* 148 */ "tags_def", - /* 149 */ "multi_drop_clause", - /* 150 */ "create_subtable_clause", - /* 151 */ "specific_tags_opt", - /* 152 */ "literal_list", - /* 153 */ "drop_table_clause", - /* 154 */ "col_name_list", - /* 155 */ "table_name", - /* 156 */ "column_def", - /* 157 */ "column_name", - /* 158 */ "type_name", - /* 159 */ "col_name", - /* 160 */ "query_expression", - /* 161 */ "literal", - /* 162 */ "duration_literal", - /* 163 */ "function_name", - /* 164 */ "table_alias", - /* 165 */ "column_alias", - /* 166 */ "expression", - /* 167 */ "column_reference", - /* 168 */ "expression_list", - /* 169 */ "subquery", - /* 170 */ "predicate", - /* 171 */ "compare_op", - /* 172 */ "in_op", - /* 173 */ "in_predicate_value", - /* 174 */ "boolean_value_expression", - /* 175 */ "boolean_primary", - /* 176 */ "common_expression", - /* 177 */ "from_clause", - /* 178 */ "table_reference_list", - /* 179 */ "table_reference", - /* 180 */ "table_primary", - /* 181 */ "joined_table", - /* 182 */ "alias_opt", - /* 183 */ "parenthesized_joined_table", - /* 184 */ "join_type", - /* 185 */ "search_condition", - /* 186 */ "query_specification", - /* 187 */ "set_quantifier_opt", - /* 188 */ "select_list", - /* 189 */ "where_clause_opt", - /* 190 */ "partition_by_clause_opt", - /* 191 */ "twindow_clause_opt", - /* 192 */ "group_by_clause_opt", - /* 193 */ "having_clause_opt", - /* 194 */ "select_sublist", - /* 195 */ "select_item", - /* 196 */ "sliding_opt", - /* 197 */ "fill_opt", - /* 198 */ "fill_mode", - /* 199 */ "group_by_list", - /* 200 */ "query_expression_body", - /* 201 */ "order_by_clause_opt", - /* 202 */ "slimit_clause_opt", - /* 203 */ "limit_clause_opt", - /* 204 */ "query_primary", - /* 205 */ "sort_specification_list", - /* 206 */ "sort_specification", - /* 207 */ "ordering_specification_opt", - /* 208 */ "null_ordering_opt", + /* 86 */ "INDEX", + /* 87 */ "ON", + /* 88 */ "FULLTEXT", + /* 89 */ "FUNCTION", + /* 90 */ "INTERVAL", + /* 91 */ "MNODES", + /* 92 */ "NK_FLOAT", + /* 93 */ "NK_BOOL", + /* 94 */ "NK_VARIABLE", + /* 95 */ "BETWEEN", + /* 96 */ "IS", + /* 97 */ "NULL", + /* 98 */ "NK_LT", + /* 99 */ "NK_GT", + /* 100 */ "NK_LE", + /* 101 */ "NK_GE", + /* 102 */ "NK_NE", + /* 103 */ "NK_EQ", + /* 104 */ "LIKE", + /* 105 */ "MATCH", + /* 106 */ "NMATCH", + /* 107 */ "IN", + /* 108 */ "FROM", + /* 109 */ "AS", + /* 110 */ "JOIN", + /* 111 */ "INNER", + /* 112 */ "SELECT", + /* 113 */ "DISTINCT", + /* 114 */ "WHERE", + /* 115 */ "PARTITION", + /* 116 */ "BY", + /* 117 */ "SESSION", + /* 118 */ "STATE_WINDOW", + /* 119 */ "SLIDING", + /* 120 */ "FILL", + /* 121 */ "VALUE", + /* 122 */ "NONE", + /* 123 */ "PREV", + /* 124 */ "LINEAR", + /* 125 */ "NEXT", + /* 126 */ "GROUP", + /* 127 */ "HAVING", + /* 128 */ "ORDER", + /* 129 */ "SLIMIT", + /* 130 */ "SOFFSET", + /* 131 */ "LIMIT", + /* 132 */ "OFFSET", + /* 133 */ "ASC", + /* 134 */ "DESC", + /* 135 */ "NULLS", + /* 136 */ "FIRST", + /* 137 */ "LAST", + /* 138 */ "cmd", + /* 139 */ "user_name", + /* 140 */ "dnode_endpoint", + /* 141 */ "dnode_host_name", + /* 142 */ "not_exists_opt", + /* 143 */ "db_name", + /* 144 */ "db_options", + /* 145 */ "exists_opt", + /* 146 */ "full_table_name", + /* 147 */ "column_def_list", + /* 148 */ "tags_def_opt", + /* 149 */ "table_options", + /* 150 */ "multi_create_clause", + /* 151 */ "tags_def", + /* 152 */ "multi_drop_clause", + /* 153 */ "create_subtable_clause", + /* 154 */ "specific_tags_opt", + /* 155 */ "literal_list", + /* 156 */ "drop_table_clause", + /* 157 */ "col_name_list", + /* 158 */ "table_name", + /* 159 */ "column_def", + /* 160 */ "column_name", + /* 161 */ "type_name", + /* 162 */ "col_name", + /* 163 */ "index_name", + /* 164 */ "index_options", + /* 165 */ "func_list", + /* 166 */ "duration_literal", + /* 167 */ "sliding_opt", + /* 168 */ "func", + /* 169 */ "function_name", + /* 170 */ "expression_list", + /* 171 */ "query_expression", + /* 172 */ "literal", + /* 173 */ "table_alias", + /* 174 */ "column_alias", + /* 175 */ "expression", + /* 176 */ "column_reference", + /* 177 */ "subquery", + /* 178 */ "predicate", + /* 179 */ "compare_op", + /* 180 */ "in_op", + /* 181 */ "in_predicate_value", + /* 182 */ "boolean_value_expression", + /* 183 */ "boolean_primary", + /* 184 */ "common_expression", + /* 185 */ "from_clause", + /* 186 */ "table_reference_list", + /* 187 */ "table_reference", + /* 188 */ "table_primary", + /* 189 */ "joined_table", + /* 190 */ "alias_opt", + /* 191 */ "parenthesized_joined_table", + /* 192 */ "join_type", + /* 193 */ "search_condition", + /* 194 */ "query_specification", + /* 195 */ "set_quantifier_opt", + /* 196 */ "select_list", + /* 197 */ "where_clause_opt", + /* 198 */ "partition_by_clause_opt", + /* 199 */ "twindow_clause_opt", + /* 200 */ "group_by_clause_opt", + /* 201 */ "having_clause_opt", + /* 202 */ "select_sublist", + /* 203 */ "select_item", + /* 204 */ "fill_opt", + /* 205 */ "fill_mode", + /* 206 */ "group_by_list", + /* 207 */ "query_expression_body", + /* 208 */ "order_by_clause_opt", + /* 209 */ "slimit_clause_opt", + /* 210 */ "limit_clause_opt", + /* 211 */ "query_primary", + /* 212 */ "sort_specification_list", + /* 213 */ "sort_specification", + /* 214 */ "ordering_specification_opt", + /* 215 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -903,149 +941,158 @@ static const char *const yyRuleName[] = { /* 91 */ "col_name_list ::= col_name", /* 92 */ "col_name_list ::= col_name_list NK_COMMA col_name", /* 93 */ "col_name ::= column_name", - /* 94 */ "cmd ::= SHOW VGROUPS", - /* 95 */ "cmd ::= SHOW db_name NK_DOT VGROUPS", - /* 96 */ "cmd ::= SHOW MNODES", - /* 97 */ "cmd ::= query_expression", - /* 98 */ "literal ::= NK_INTEGER", - /* 99 */ "literal ::= NK_FLOAT", - /* 100 */ "literal ::= NK_STRING", - /* 101 */ "literal ::= NK_BOOL", - /* 102 */ "literal ::= TIMESTAMP NK_STRING", - /* 103 */ "literal ::= duration_literal", - /* 104 */ "duration_literal ::= NK_VARIABLE", - /* 105 */ "literal_list ::= literal", - /* 106 */ "literal_list ::= literal_list NK_COMMA literal", - /* 107 */ "db_name ::= NK_ID", - /* 108 */ "table_name ::= NK_ID", - /* 109 */ "column_name ::= NK_ID", - /* 110 */ "function_name ::= NK_ID", - /* 111 */ "table_alias ::= NK_ID", - /* 112 */ "column_alias ::= NK_ID", - /* 113 */ "user_name ::= NK_ID", - /* 114 */ "expression ::= literal", - /* 115 */ "expression ::= column_reference", - /* 116 */ "expression ::= function_name NK_LP expression_list NK_RP", - /* 117 */ "expression ::= function_name NK_LP NK_STAR NK_RP", - /* 118 */ "expression ::= subquery", - /* 119 */ "expression ::= NK_LP expression NK_RP", - /* 120 */ "expression ::= NK_PLUS expression", - /* 121 */ "expression ::= NK_MINUS expression", - /* 122 */ "expression ::= expression NK_PLUS expression", - /* 123 */ "expression ::= expression NK_MINUS expression", - /* 124 */ "expression ::= expression NK_STAR expression", - /* 125 */ "expression ::= expression NK_SLASH expression", - /* 126 */ "expression ::= expression NK_REM expression", - /* 127 */ "expression_list ::= expression", - /* 128 */ "expression_list ::= expression_list NK_COMMA expression", - /* 129 */ "column_reference ::= column_name", - /* 130 */ "column_reference ::= table_name NK_DOT column_name", - /* 131 */ "predicate ::= expression compare_op expression", - /* 132 */ "predicate ::= expression BETWEEN expression AND expression", - /* 133 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 134 */ "predicate ::= expression IS NULL", - /* 135 */ "predicate ::= expression IS NOT NULL", - /* 136 */ "predicate ::= expression in_op in_predicate_value", - /* 137 */ "compare_op ::= NK_LT", - /* 138 */ "compare_op ::= NK_GT", - /* 139 */ "compare_op ::= NK_LE", - /* 140 */ "compare_op ::= NK_GE", - /* 141 */ "compare_op ::= NK_NE", - /* 142 */ "compare_op ::= NK_EQ", - /* 143 */ "compare_op ::= LIKE", - /* 144 */ "compare_op ::= NOT LIKE", - /* 145 */ "compare_op ::= MATCH", - /* 146 */ "compare_op ::= NMATCH", - /* 147 */ "in_op ::= IN", - /* 148 */ "in_op ::= NOT IN", - /* 149 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 150 */ "boolean_value_expression ::= boolean_primary", - /* 151 */ "boolean_value_expression ::= NOT boolean_primary", - /* 152 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 153 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 154 */ "boolean_primary ::= predicate", - /* 155 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 156 */ "common_expression ::= expression", - /* 157 */ "common_expression ::= boolean_value_expression", - /* 158 */ "from_clause ::= FROM table_reference_list", - /* 159 */ "table_reference_list ::= table_reference", - /* 160 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 161 */ "table_reference ::= table_primary", - /* 162 */ "table_reference ::= joined_table", - /* 163 */ "table_primary ::= table_name alias_opt", - /* 164 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 165 */ "table_primary ::= subquery alias_opt", - /* 166 */ "table_primary ::= parenthesized_joined_table", - /* 167 */ "alias_opt ::=", - /* 168 */ "alias_opt ::= table_alias", - /* 169 */ "alias_opt ::= AS table_alias", - /* 170 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 171 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 172 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 173 */ "join_type ::=", - /* 174 */ "join_type ::= INNER", - /* 175 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 176 */ "set_quantifier_opt ::=", - /* 177 */ "set_quantifier_opt ::= DISTINCT", - /* 178 */ "set_quantifier_opt ::= ALL", - /* 179 */ "select_list ::= NK_STAR", - /* 180 */ "select_list ::= select_sublist", - /* 181 */ "select_sublist ::= select_item", - /* 182 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 183 */ "select_item ::= common_expression", - /* 184 */ "select_item ::= common_expression column_alias", - /* 185 */ "select_item ::= common_expression AS column_alias", - /* 186 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 187 */ "where_clause_opt ::=", - /* 188 */ "where_clause_opt ::= WHERE search_condition", - /* 189 */ "partition_by_clause_opt ::=", - /* 190 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 191 */ "twindow_clause_opt ::=", - /* 192 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP", - /* 193 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", - /* 194 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 195 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 196 */ "sliding_opt ::=", - /* 197 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 198 */ "fill_opt ::=", - /* 199 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 200 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 201 */ "fill_mode ::= NONE", - /* 202 */ "fill_mode ::= PREV", - /* 203 */ "fill_mode ::= NULL", - /* 204 */ "fill_mode ::= LINEAR", - /* 205 */ "fill_mode ::= NEXT", - /* 206 */ "group_by_clause_opt ::=", - /* 207 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 208 */ "group_by_list ::= expression", - /* 209 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 210 */ "having_clause_opt ::=", - /* 211 */ "having_clause_opt ::= HAVING search_condition", - /* 212 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 213 */ "query_expression_body ::= query_primary", - /* 214 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 215 */ "query_primary ::= query_specification", - /* 216 */ "order_by_clause_opt ::=", - /* 217 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 218 */ "slimit_clause_opt ::=", - /* 219 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 220 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 221 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 222 */ "limit_clause_opt ::=", - /* 223 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 224 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 225 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 226 */ "subquery ::= NK_LP query_expression NK_RP", - /* 227 */ "search_condition ::= common_expression", - /* 228 */ "sort_specification_list ::= sort_specification", - /* 229 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 230 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 231 */ "ordering_specification_opt ::=", - /* 232 */ "ordering_specification_opt ::= ASC", - /* 233 */ "ordering_specification_opt ::= DESC", - /* 234 */ "null_ordering_opt ::=", - /* 235 */ "null_ordering_opt ::= NULLS FIRST", - /* 236 */ "null_ordering_opt ::= NULLS LAST", + /* 94 */ "cmd ::= CREATE SMA INDEX index_name ON table_name index_options", + /* 95 */ "cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP", + /* 96 */ "index_options ::=", + /* 97 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", + /* 98 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", + /* 99 */ "func_list ::= func", + /* 100 */ "func_list ::= func_list NK_COMMA func", + /* 101 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 102 */ "cmd ::= SHOW VGROUPS", + /* 103 */ "cmd ::= SHOW db_name NK_DOT VGROUPS", + /* 104 */ "cmd ::= SHOW MNODES", + /* 105 */ "cmd ::= query_expression", + /* 106 */ "literal ::= NK_INTEGER", + /* 107 */ "literal ::= NK_FLOAT", + /* 108 */ "literal ::= NK_STRING", + /* 109 */ "literal ::= NK_BOOL", + /* 110 */ "literal ::= TIMESTAMP NK_STRING", + /* 111 */ "literal ::= duration_literal", + /* 112 */ "duration_literal ::= NK_VARIABLE", + /* 113 */ "literal_list ::= literal", + /* 114 */ "literal_list ::= literal_list NK_COMMA literal", + /* 115 */ "db_name ::= NK_ID", + /* 116 */ "table_name ::= NK_ID", + /* 117 */ "column_name ::= NK_ID", + /* 118 */ "function_name ::= NK_ID", + /* 119 */ "table_alias ::= NK_ID", + /* 120 */ "column_alias ::= NK_ID", + /* 121 */ "user_name ::= NK_ID", + /* 122 */ "index_name ::= NK_ID", + /* 123 */ "expression ::= literal", + /* 124 */ "expression ::= column_reference", + /* 125 */ "expression ::= function_name NK_LP expression_list NK_RP", + /* 126 */ "expression ::= function_name NK_LP NK_STAR NK_RP", + /* 127 */ "expression ::= subquery", + /* 128 */ "expression ::= NK_LP expression NK_RP", + /* 129 */ "expression ::= NK_PLUS expression", + /* 130 */ "expression ::= NK_MINUS expression", + /* 131 */ "expression ::= expression NK_PLUS expression", + /* 132 */ "expression ::= expression NK_MINUS expression", + /* 133 */ "expression ::= expression NK_STAR expression", + /* 134 */ "expression ::= expression NK_SLASH expression", + /* 135 */ "expression ::= expression NK_REM expression", + /* 136 */ "expression_list ::= expression", + /* 137 */ "expression_list ::= expression_list NK_COMMA expression", + /* 138 */ "column_reference ::= column_name", + /* 139 */ "column_reference ::= table_name NK_DOT column_name", + /* 140 */ "predicate ::= expression compare_op expression", + /* 141 */ "predicate ::= expression BETWEEN expression AND expression", + /* 142 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 143 */ "predicate ::= expression IS NULL", + /* 144 */ "predicate ::= expression IS NOT NULL", + /* 145 */ "predicate ::= expression in_op in_predicate_value", + /* 146 */ "compare_op ::= NK_LT", + /* 147 */ "compare_op ::= NK_GT", + /* 148 */ "compare_op ::= NK_LE", + /* 149 */ "compare_op ::= NK_GE", + /* 150 */ "compare_op ::= NK_NE", + /* 151 */ "compare_op ::= NK_EQ", + /* 152 */ "compare_op ::= LIKE", + /* 153 */ "compare_op ::= NOT LIKE", + /* 154 */ "compare_op ::= MATCH", + /* 155 */ "compare_op ::= NMATCH", + /* 156 */ "in_op ::= IN", + /* 157 */ "in_op ::= NOT IN", + /* 158 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 159 */ "boolean_value_expression ::= boolean_primary", + /* 160 */ "boolean_value_expression ::= NOT boolean_primary", + /* 161 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 162 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 163 */ "boolean_primary ::= predicate", + /* 164 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 165 */ "common_expression ::= expression", + /* 166 */ "common_expression ::= boolean_value_expression", + /* 167 */ "from_clause ::= FROM table_reference_list", + /* 168 */ "table_reference_list ::= table_reference", + /* 169 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 170 */ "table_reference ::= table_primary", + /* 171 */ "table_reference ::= joined_table", + /* 172 */ "table_primary ::= table_name alias_opt", + /* 173 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 174 */ "table_primary ::= subquery alias_opt", + /* 175 */ "table_primary ::= parenthesized_joined_table", + /* 176 */ "alias_opt ::=", + /* 177 */ "alias_opt ::= table_alias", + /* 178 */ "alias_opt ::= AS table_alias", + /* 179 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 180 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 181 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 182 */ "join_type ::=", + /* 183 */ "join_type ::= INNER", + /* 184 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 185 */ "set_quantifier_opt ::=", + /* 186 */ "set_quantifier_opt ::= DISTINCT", + /* 187 */ "set_quantifier_opt ::= ALL", + /* 188 */ "select_list ::= NK_STAR", + /* 189 */ "select_list ::= select_sublist", + /* 190 */ "select_sublist ::= select_item", + /* 191 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 192 */ "select_item ::= common_expression", + /* 193 */ "select_item ::= common_expression column_alias", + /* 194 */ "select_item ::= common_expression AS column_alias", + /* 195 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 196 */ "where_clause_opt ::=", + /* 197 */ "where_clause_opt ::= WHERE search_condition", + /* 198 */ "partition_by_clause_opt ::=", + /* 199 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 200 */ "twindow_clause_opt ::=", + /* 201 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP", + /* 202 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", + /* 203 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 204 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 205 */ "sliding_opt ::=", + /* 206 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 207 */ "fill_opt ::=", + /* 208 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 209 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 210 */ "fill_mode ::= NONE", + /* 211 */ "fill_mode ::= PREV", + /* 212 */ "fill_mode ::= NULL", + /* 213 */ "fill_mode ::= LINEAR", + /* 214 */ "fill_mode ::= NEXT", + /* 215 */ "group_by_clause_opt ::=", + /* 216 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 217 */ "group_by_list ::= expression", + /* 218 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 219 */ "having_clause_opt ::=", + /* 220 */ "having_clause_opt ::= HAVING search_condition", + /* 221 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 222 */ "query_expression_body ::= query_primary", + /* 223 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 224 */ "query_primary ::= query_specification", + /* 225 */ "order_by_clause_opt ::=", + /* 226 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 227 */ "slimit_clause_opt ::=", + /* 228 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 229 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 230 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 231 */ "limit_clause_opt ::=", + /* 232 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 233 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 234 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 235 */ "subquery ::= NK_LP query_expression NK_RP", + /* 236 */ "search_condition ::= common_expression", + /* 237 */ "sort_specification_list ::= sort_specification", + /* 238 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 239 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 240 */ "ordering_specification_opt ::=", + /* 241 */ "ordering_specification_opt ::= ASC", + /* 242 */ "ordering_specification_opt ::= DESC", + /* 243 */ "null_ordering_opt ::=", + /* 244 */ "null_ordering_opt ::= NULLS FIRST", + /* 245 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -1172,124 +1219,120 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 135: /* cmd */ - case 143: /* full_table_name */ - case 150: /* create_subtable_clause */ - case 153: /* drop_table_clause */ - case 156: /* column_def */ - case 159: /* col_name */ - case 160: /* query_expression */ - case 161: /* literal */ - case 162: /* duration_literal */ - case 166: /* expression */ - case 167: /* column_reference */ - case 169: /* subquery */ - case 170: /* predicate */ - case 173: /* in_predicate_value */ - case 174: /* boolean_value_expression */ - case 175: /* boolean_primary */ - case 176: /* common_expression */ - case 177: /* from_clause */ - case 178: /* table_reference_list */ - case 179: /* table_reference */ - case 180: /* table_primary */ - case 181: /* joined_table */ - case 183: /* parenthesized_joined_table */ - case 185: /* search_condition */ - case 186: /* query_specification */ - case 189: /* where_clause_opt */ - case 191: /* twindow_clause_opt */ - case 193: /* having_clause_opt */ - case 195: /* select_item */ - case 196: /* sliding_opt */ - case 197: /* fill_opt */ - case 200: /* query_expression_body */ - case 202: /* slimit_clause_opt */ - case 203: /* limit_clause_opt */ - case 204: /* query_primary */ - case 206: /* sort_specification */ + case 138: /* cmd */ + case 144: /* db_options */ + case 146: /* full_table_name */ + case 149: /* table_options */ + case 153: /* create_subtable_clause */ + case 156: /* drop_table_clause */ + case 159: /* column_def */ + case 162: /* col_name */ + case 164: /* index_options */ + case 166: /* duration_literal */ + case 167: /* sliding_opt */ + case 168: /* func */ + case 171: /* query_expression */ + case 172: /* literal */ + case 175: /* expression */ + case 176: /* column_reference */ + case 177: /* subquery */ + case 178: /* predicate */ + case 181: /* in_predicate_value */ + case 182: /* boolean_value_expression */ + case 183: /* boolean_primary */ + case 184: /* common_expression */ + case 185: /* from_clause */ + case 186: /* table_reference_list */ + case 187: /* table_reference */ + case 188: /* table_primary */ + case 189: /* joined_table */ + case 191: /* parenthesized_joined_table */ + case 193: /* search_condition */ + case 194: /* query_specification */ + case 197: /* where_clause_opt */ + case 199: /* twindow_clause_opt */ + case 201: /* having_clause_opt */ + case 203: /* select_item */ + case 204: /* fill_opt */ + case 207: /* query_expression_body */ + case 209: /* slimit_clause_opt */ + case 210: /* limit_clause_opt */ + case 211: /* query_primary */ + case 213: /* sort_specification */ { - nodesDestroyNode((yypminor->yy256)); + nodesDestroyNode((yypminor->yy344)); } break; - case 136: /* user_name */ - case 137: /* dnode_endpoint */ - case 138: /* dnode_host_name */ - case 140: /* db_name */ - case 155: /* table_name */ - case 157: /* column_name */ - case 163: /* function_name */ - case 164: /* table_alias */ - case 165: /* column_alias */ - case 182: /* alias_opt */ + case 139: /* user_name */ + case 140: /* dnode_endpoint */ + case 141: /* dnode_host_name */ + case 143: /* db_name */ + case 158: /* table_name */ + case 160: /* column_name */ + case 163: /* index_name */ + case 169: /* function_name */ + case 173: /* table_alias */ + case 174: /* column_alias */ + case 190: /* alias_opt */ { } break; - case 139: /* not_exists_opt */ - case 142: /* exists_opt */ - case 187: /* set_quantifier_opt */ + case 142: /* not_exists_opt */ + case 145: /* exists_opt */ + case 195: /* set_quantifier_opt */ { } break; - case 141: /* db_options */ + case 147: /* column_def_list */ + case 148: /* tags_def_opt */ + case 150: /* multi_create_clause */ + case 151: /* tags_def */ + case 152: /* multi_drop_clause */ + case 154: /* specific_tags_opt */ + case 155: /* literal_list */ + case 157: /* col_name_list */ + case 165: /* func_list */ + case 170: /* expression_list */ + case 196: /* select_list */ + case 198: /* partition_by_clause_opt */ + case 200: /* group_by_clause_opt */ + case 202: /* select_sublist */ + case 206: /* group_by_list */ + case 208: /* order_by_clause_opt */ + case 212: /* sort_specification_list */ { - tfree((yypminor->yy391)); + nodesDestroyList((yypminor->yy280)); } break; - case 144: /* column_def_list */ - case 145: /* tags_def_opt */ - case 147: /* multi_create_clause */ - case 148: /* tags_def */ - case 149: /* multi_drop_clause */ - case 151: /* specific_tags_opt */ - case 152: /* literal_list */ - case 154: /* col_name_list */ - case 168: /* expression_list */ - case 188: /* select_list */ - case 190: /* partition_by_clause_opt */ - case 192: /* group_by_clause_opt */ - case 194: /* select_sublist */ - case 199: /* group_by_list */ - case 201: /* order_by_clause_opt */ - case 205: /* sort_specification_list */ -{ - nodesDestroyList((yypminor->yy46)); -} - break; - case 146: /* table_options */ -{ - tfree((yypminor->yy340)); -} - break; - case 158: /* type_name */ + case 161: /* type_name */ { } break; - case 171: /* compare_op */ - case 172: /* in_op */ + case 179: /* compare_op */ + case 180: /* in_op */ { } break; - case 184: /* join_type */ + case 192: /* join_type */ { } break; - case 198: /* fill_mode */ + case 205: /* fill_mode */ { } break; - case 207: /* ordering_specification_opt */ + case 214: /* ordering_specification_opt */ { } break; - case 208: /* null_ordering_opt */ + case 215: /* null_ordering_opt */ { } @@ -1588,243 +1631,252 @@ static const struct { YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ signed char nrhs; /* Negative of the number of RHS symbols in the rule */ } yyRuleInfo[] = { - { 135, -5 }, /* (0) cmd ::= CREATE USER user_name PASS NK_STRING */ - { 135, -5 }, /* (1) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 135, -5 }, /* (2) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ - { 135, -3 }, /* (3) cmd ::= DROP USER user_name */ - { 135, -2 }, /* (4) cmd ::= SHOW USERS */ - { 135, -3 }, /* (5) cmd ::= CREATE DNODE dnode_endpoint */ - { 135, -5 }, /* (6) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ - { 135, -3 }, /* (7) cmd ::= DROP DNODE NK_INTEGER */ - { 135, -3 }, /* (8) cmd ::= DROP DNODE dnode_endpoint */ - { 135, -2 }, /* (9) cmd ::= SHOW DNODES */ - { 137, -1 }, /* (10) dnode_endpoint ::= NK_STRING */ - { 138, -1 }, /* (11) dnode_host_name ::= NK_ID */ - { 138, -1 }, /* (12) dnode_host_name ::= NK_IPTOKEN */ - { 135, -5 }, /* (13) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 135, -4 }, /* (14) cmd ::= DROP DATABASE exists_opt db_name */ - { 135, -2 }, /* (15) cmd ::= SHOW DATABASES */ - { 135, -2 }, /* (16) cmd ::= USE db_name */ - { 139, -3 }, /* (17) not_exists_opt ::= IF NOT EXISTS */ - { 139, 0 }, /* (18) not_exists_opt ::= */ - { 142, -2 }, /* (19) exists_opt ::= IF EXISTS */ - { 142, 0 }, /* (20) exists_opt ::= */ - { 141, 0 }, /* (21) db_options ::= */ - { 141, -3 }, /* (22) db_options ::= db_options BLOCKS NK_INTEGER */ - { 141, -3 }, /* (23) db_options ::= db_options CACHE NK_INTEGER */ - { 141, -3 }, /* (24) db_options ::= db_options CACHELAST NK_INTEGER */ - { 141, -3 }, /* (25) db_options ::= db_options COMP NK_INTEGER */ - { 141, -3 }, /* (26) db_options ::= db_options DAYS NK_INTEGER */ - { 141, -3 }, /* (27) db_options ::= db_options FSYNC NK_INTEGER */ - { 141, -3 }, /* (28) db_options ::= db_options MAXROWS NK_INTEGER */ - { 141, -3 }, /* (29) db_options ::= db_options MINROWS NK_INTEGER */ - { 141, -3 }, /* (30) db_options ::= db_options KEEP NK_INTEGER */ - { 141, -3 }, /* (31) db_options ::= db_options PRECISION NK_STRING */ - { 141, -3 }, /* (32) db_options ::= db_options QUORUM NK_INTEGER */ - { 141, -3 }, /* (33) db_options ::= db_options REPLICA NK_INTEGER */ - { 141, -3 }, /* (34) db_options ::= db_options TTL NK_INTEGER */ - { 141, -3 }, /* (35) db_options ::= db_options WAL NK_INTEGER */ - { 141, -3 }, /* (36) db_options ::= db_options VGROUPS NK_INTEGER */ - { 141, -3 }, /* (37) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 141, -3 }, /* (38) db_options ::= db_options STREAM_MODE NK_INTEGER */ - { 135, -9 }, /* (39) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 135, -3 }, /* (40) cmd ::= CREATE TABLE multi_create_clause */ - { 135, -9 }, /* (41) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 135, -3 }, /* (42) cmd ::= DROP TABLE multi_drop_clause */ - { 135, -4 }, /* (43) cmd ::= DROP STABLE exists_opt full_table_name */ - { 135, -2 }, /* (44) cmd ::= SHOW TABLES */ - { 135, -2 }, /* (45) cmd ::= SHOW STABLES */ - { 147, -1 }, /* (46) multi_create_clause ::= create_subtable_clause */ - { 147, -2 }, /* (47) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 150, -9 }, /* (48) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ - { 149, -1 }, /* (49) multi_drop_clause ::= drop_table_clause */ - { 149, -2 }, /* (50) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 153, -2 }, /* (51) drop_table_clause ::= exists_opt full_table_name */ - { 151, 0 }, /* (52) specific_tags_opt ::= */ - { 151, -3 }, /* (53) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - { 143, -1 }, /* (54) full_table_name ::= table_name */ - { 143, -3 }, /* (55) full_table_name ::= db_name NK_DOT table_name */ - { 144, -1 }, /* (56) column_def_list ::= column_def */ - { 144, -3 }, /* (57) column_def_list ::= column_def_list NK_COMMA column_def */ - { 156, -2 }, /* (58) column_def ::= column_name type_name */ - { 156, -4 }, /* (59) column_def ::= column_name type_name COMMENT NK_STRING */ - { 158, -1 }, /* (60) type_name ::= BOOL */ - { 158, -1 }, /* (61) type_name ::= TINYINT */ - { 158, -1 }, /* (62) type_name ::= SMALLINT */ - { 158, -1 }, /* (63) type_name ::= INT */ - { 158, -1 }, /* (64) type_name ::= INTEGER */ - { 158, -1 }, /* (65) type_name ::= BIGINT */ - { 158, -1 }, /* (66) type_name ::= FLOAT */ - { 158, -1 }, /* (67) type_name ::= DOUBLE */ - { 158, -4 }, /* (68) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 158, -1 }, /* (69) type_name ::= TIMESTAMP */ - { 158, -4 }, /* (70) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 158, -2 }, /* (71) type_name ::= TINYINT UNSIGNED */ - { 158, -2 }, /* (72) type_name ::= SMALLINT UNSIGNED */ - { 158, -2 }, /* (73) type_name ::= INT UNSIGNED */ - { 158, -2 }, /* (74) type_name ::= BIGINT UNSIGNED */ - { 158, -1 }, /* (75) type_name ::= JSON */ - { 158, -4 }, /* (76) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 158, -1 }, /* (77) type_name ::= MEDIUMBLOB */ - { 158, -1 }, /* (78) type_name ::= BLOB */ - { 158, -4 }, /* (79) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 158, -1 }, /* (80) type_name ::= DECIMAL */ - { 158, -4 }, /* (81) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 158, -6 }, /* (82) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 145, 0 }, /* (83) tags_def_opt ::= */ - { 145, -1 }, /* (84) tags_def_opt ::= tags_def */ - { 148, -4 }, /* (85) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 146, 0 }, /* (86) table_options ::= */ - { 146, -3 }, /* (87) table_options ::= table_options COMMENT NK_STRING */ - { 146, -3 }, /* (88) table_options ::= table_options KEEP NK_INTEGER */ - { 146, -3 }, /* (89) table_options ::= table_options TTL NK_INTEGER */ - { 146, -5 }, /* (90) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 154, -1 }, /* (91) col_name_list ::= col_name */ - { 154, -3 }, /* (92) col_name_list ::= col_name_list NK_COMMA col_name */ - { 159, -1 }, /* (93) col_name ::= column_name */ - { 135, -2 }, /* (94) cmd ::= SHOW VGROUPS */ - { 135, -4 }, /* (95) cmd ::= SHOW db_name NK_DOT VGROUPS */ - { 135, -2 }, /* (96) cmd ::= SHOW MNODES */ - { 135, -1 }, /* (97) cmd ::= query_expression */ - { 161, -1 }, /* (98) literal ::= NK_INTEGER */ - { 161, -1 }, /* (99) literal ::= NK_FLOAT */ - { 161, -1 }, /* (100) literal ::= NK_STRING */ - { 161, -1 }, /* (101) literal ::= NK_BOOL */ - { 161, -2 }, /* (102) literal ::= TIMESTAMP NK_STRING */ - { 161, -1 }, /* (103) literal ::= duration_literal */ - { 162, -1 }, /* (104) duration_literal ::= NK_VARIABLE */ - { 152, -1 }, /* (105) literal_list ::= literal */ - { 152, -3 }, /* (106) literal_list ::= literal_list NK_COMMA literal */ - { 140, -1 }, /* (107) db_name ::= NK_ID */ - { 155, -1 }, /* (108) table_name ::= NK_ID */ - { 157, -1 }, /* (109) column_name ::= NK_ID */ - { 163, -1 }, /* (110) function_name ::= NK_ID */ - { 164, -1 }, /* (111) table_alias ::= NK_ID */ - { 165, -1 }, /* (112) column_alias ::= NK_ID */ - { 136, -1 }, /* (113) user_name ::= NK_ID */ - { 166, -1 }, /* (114) expression ::= literal */ - { 166, -1 }, /* (115) expression ::= column_reference */ - { 166, -4 }, /* (116) expression ::= function_name NK_LP expression_list NK_RP */ - { 166, -4 }, /* (117) expression ::= function_name NK_LP NK_STAR NK_RP */ - { 166, -1 }, /* (118) expression ::= subquery */ - { 166, -3 }, /* (119) expression ::= NK_LP expression NK_RP */ - { 166, -2 }, /* (120) expression ::= NK_PLUS expression */ - { 166, -2 }, /* (121) expression ::= NK_MINUS expression */ - { 166, -3 }, /* (122) expression ::= expression NK_PLUS expression */ - { 166, -3 }, /* (123) expression ::= expression NK_MINUS expression */ - { 166, -3 }, /* (124) expression ::= expression NK_STAR expression */ - { 166, -3 }, /* (125) expression ::= expression NK_SLASH expression */ - { 166, -3 }, /* (126) expression ::= expression NK_REM expression */ - { 168, -1 }, /* (127) expression_list ::= expression */ - { 168, -3 }, /* (128) expression_list ::= expression_list NK_COMMA expression */ - { 167, -1 }, /* (129) column_reference ::= column_name */ - { 167, -3 }, /* (130) column_reference ::= table_name NK_DOT column_name */ - { 170, -3 }, /* (131) predicate ::= expression compare_op expression */ - { 170, -5 }, /* (132) predicate ::= expression BETWEEN expression AND expression */ - { 170, -6 }, /* (133) predicate ::= expression NOT BETWEEN expression AND expression */ - { 170, -3 }, /* (134) predicate ::= expression IS NULL */ - { 170, -4 }, /* (135) predicate ::= expression IS NOT NULL */ - { 170, -3 }, /* (136) predicate ::= expression in_op in_predicate_value */ - { 171, -1 }, /* (137) compare_op ::= NK_LT */ - { 171, -1 }, /* (138) compare_op ::= NK_GT */ - { 171, -1 }, /* (139) compare_op ::= NK_LE */ - { 171, -1 }, /* (140) compare_op ::= NK_GE */ - { 171, -1 }, /* (141) compare_op ::= NK_NE */ - { 171, -1 }, /* (142) compare_op ::= NK_EQ */ - { 171, -1 }, /* (143) compare_op ::= LIKE */ - { 171, -2 }, /* (144) compare_op ::= NOT LIKE */ - { 171, -1 }, /* (145) compare_op ::= MATCH */ - { 171, -1 }, /* (146) compare_op ::= NMATCH */ - { 172, -1 }, /* (147) in_op ::= IN */ - { 172, -2 }, /* (148) in_op ::= NOT IN */ - { 173, -3 }, /* (149) in_predicate_value ::= NK_LP expression_list NK_RP */ - { 174, -1 }, /* (150) boolean_value_expression ::= boolean_primary */ - { 174, -2 }, /* (151) boolean_value_expression ::= NOT boolean_primary */ - { 174, -3 }, /* (152) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 174, -3 }, /* (153) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 175, -1 }, /* (154) boolean_primary ::= predicate */ - { 175, -3 }, /* (155) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 176, -1 }, /* (156) common_expression ::= expression */ - { 176, -1 }, /* (157) common_expression ::= boolean_value_expression */ - { 177, -2 }, /* (158) from_clause ::= FROM table_reference_list */ - { 178, -1 }, /* (159) table_reference_list ::= table_reference */ - { 178, -3 }, /* (160) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 179, -1 }, /* (161) table_reference ::= table_primary */ - { 179, -1 }, /* (162) table_reference ::= joined_table */ - { 180, -2 }, /* (163) table_primary ::= table_name alias_opt */ - { 180, -4 }, /* (164) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 180, -2 }, /* (165) table_primary ::= subquery alias_opt */ - { 180, -1 }, /* (166) table_primary ::= parenthesized_joined_table */ - { 182, 0 }, /* (167) alias_opt ::= */ - { 182, -1 }, /* (168) alias_opt ::= table_alias */ - { 182, -2 }, /* (169) alias_opt ::= AS table_alias */ - { 183, -3 }, /* (170) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 183, -3 }, /* (171) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 181, -6 }, /* (172) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 184, 0 }, /* (173) join_type ::= */ - { 184, -1 }, /* (174) join_type ::= INNER */ - { 186, -9 }, /* (175) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - { 187, 0 }, /* (176) set_quantifier_opt ::= */ - { 187, -1 }, /* (177) set_quantifier_opt ::= DISTINCT */ - { 187, -1 }, /* (178) set_quantifier_opt ::= ALL */ - { 188, -1 }, /* (179) select_list ::= NK_STAR */ - { 188, -1 }, /* (180) select_list ::= select_sublist */ - { 194, -1 }, /* (181) select_sublist ::= select_item */ - { 194, -3 }, /* (182) select_sublist ::= select_sublist NK_COMMA select_item */ - { 195, -1 }, /* (183) select_item ::= common_expression */ - { 195, -2 }, /* (184) select_item ::= common_expression column_alias */ - { 195, -3 }, /* (185) select_item ::= common_expression AS column_alias */ - { 195, -3 }, /* (186) select_item ::= table_name NK_DOT NK_STAR */ - { 189, 0 }, /* (187) where_clause_opt ::= */ - { 189, -2 }, /* (188) where_clause_opt ::= WHERE search_condition */ - { 190, 0 }, /* (189) partition_by_clause_opt ::= */ - { 190, -3 }, /* (190) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 191, 0 }, /* (191) twindow_clause_opt ::= */ - { 191, -6 }, /* (192) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ - { 191, -4 }, /* (193) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ - { 191, -6 }, /* (194) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 191, -8 }, /* (195) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 196, 0 }, /* (196) sliding_opt ::= */ - { 196, -4 }, /* (197) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 197, 0 }, /* (198) fill_opt ::= */ - { 197, -4 }, /* (199) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 197, -6 }, /* (200) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 198, -1 }, /* (201) fill_mode ::= NONE */ - { 198, -1 }, /* (202) fill_mode ::= PREV */ - { 198, -1 }, /* (203) fill_mode ::= NULL */ - { 198, -1 }, /* (204) fill_mode ::= LINEAR */ - { 198, -1 }, /* (205) fill_mode ::= NEXT */ - { 192, 0 }, /* (206) group_by_clause_opt ::= */ - { 192, -3 }, /* (207) group_by_clause_opt ::= GROUP BY group_by_list */ - { 199, -1 }, /* (208) group_by_list ::= expression */ - { 199, -3 }, /* (209) group_by_list ::= group_by_list NK_COMMA expression */ - { 193, 0 }, /* (210) having_clause_opt ::= */ - { 193, -2 }, /* (211) having_clause_opt ::= HAVING search_condition */ - { 160, -4 }, /* (212) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 200, -1 }, /* (213) query_expression_body ::= query_primary */ - { 200, -4 }, /* (214) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 204, -1 }, /* (215) query_primary ::= query_specification */ - { 201, 0 }, /* (216) order_by_clause_opt ::= */ - { 201, -3 }, /* (217) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 202, 0 }, /* (218) slimit_clause_opt ::= */ - { 202, -2 }, /* (219) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 202, -4 }, /* (220) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 202, -4 }, /* (221) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 203, 0 }, /* (222) limit_clause_opt ::= */ - { 203, -2 }, /* (223) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 203, -4 }, /* (224) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 203, -4 }, /* (225) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 169, -3 }, /* (226) subquery ::= NK_LP query_expression NK_RP */ - { 185, -1 }, /* (227) search_condition ::= common_expression */ - { 205, -1 }, /* (228) sort_specification_list ::= sort_specification */ - { 205, -3 }, /* (229) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 206, -3 }, /* (230) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 207, 0 }, /* (231) ordering_specification_opt ::= */ - { 207, -1 }, /* (232) ordering_specification_opt ::= ASC */ - { 207, -1 }, /* (233) ordering_specification_opt ::= DESC */ - { 208, 0 }, /* (234) null_ordering_opt ::= */ - { 208, -2 }, /* (235) null_ordering_opt ::= NULLS FIRST */ - { 208, -2 }, /* (236) null_ordering_opt ::= NULLS LAST */ + { 138, -5 }, /* (0) cmd ::= CREATE USER user_name PASS NK_STRING */ + { 138, -5 }, /* (1) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 138, -5 }, /* (2) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ + { 138, -3 }, /* (3) cmd ::= DROP USER user_name */ + { 138, -2 }, /* (4) cmd ::= SHOW USERS */ + { 138, -3 }, /* (5) cmd ::= CREATE DNODE dnode_endpoint */ + { 138, -5 }, /* (6) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ + { 138, -3 }, /* (7) cmd ::= DROP DNODE NK_INTEGER */ + { 138, -3 }, /* (8) cmd ::= DROP DNODE dnode_endpoint */ + { 138, -2 }, /* (9) cmd ::= SHOW DNODES */ + { 140, -1 }, /* (10) dnode_endpoint ::= NK_STRING */ + { 141, -1 }, /* (11) dnode_host_name ::= NK_ID */ + { 141, -1 }, /* (12) dnode_host_name ::= NK_IPTOKEN */ + { 138, -5 }, /* (13) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 138, -4 }, /* (14) cmd ::= DROP DATABASE exists_opt db_name */ + { 138, -2 }, /* (15) cmd ::= SHOW DATABASES */ + { 138, -2 }, /* (16) cmd ::= USE db_name */ + { 142, -3 }, /* (17) not_exists_opt ::= IF NOT EXISTS */ + { 142, 0 }, /* (18) not_exists_opt ::= */ + { 145, -2 }, /* (19) exists_opt ::= IF EXISTS */ + { 145, 0 }, /* (20) exists_opt ::= */ + { 144, 0 }, /* (21) db_options ::= */ + { 144, -3 }, /* (22) db_options ::= db_options BLOCKS NK_INTEGER */ + { 144, -3 }, /* (23) db_options ::= db_options CACHE NK_INTEGER */ + { 144, -3 }, /* (24) db_options ::= db_options CACHELAST NK_INTEGER */ + { 144, -3 }, /* (25) db_options ::= db_options COMP NK_INTEGER */ + { 144, -3 }, /* (26) db_options ::= db_options DAYS NK_INTEGER */ + { 144, -3 }, /* (27) db_options ::= db_options FSYNC NK_INTEGER */ + { 144, -3 }, /* (28) db_options ::= db_options MAXROWS NK_INTEGER */ + { 144, -3 }, /* (29) db_options ::= db_options MINROWS NK_INTEGER */ + { 144, -3 }, /* (30) db_options ::= db_options KEEP NK_INTEGER */ + { 144, -3 }, /* (31) db_options ::= db_options PRECISION NK_STRING */ + { 144, -3 }, /* (32) db_options ::= db_options QUORUM NK_INTEGER */ + { 144, -3 }, /* (33) db_options ::= db_options REPLICA NK_INTEGER */ + { 144, -3 }, /* (34) db_options ::= db_options TTL NK_INTEGER */ + { 144, -3 }, /* (35) db_options ::= db_options WAL NK_INTEGER */ + { 144, -3 }, /* (36) db_options ::= db_options VGROUPS NK_INTEGER */ + { 144, -3 }, /* (37) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 144, -3 }, /* (38) db_options ::= db_options STREAM_MODE NK_INTEGER */ + { 138, -9 }, /* (39) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 138, -3 }, /* (40) cmd ::= CREATE TABLE multi_create_clause */ + { 138, -9 }, /* (41) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 138, -3 }, /* (42) cmd ::= DROP TABLE multi_drop_clause */ + { 138, -4 }, /* (43) cmd ::= DROP STABLE exists_opt full_table_name */ + { 138, -2 }, /* (44) cmd ::= SHOW TABLES */ + { 138, -2 }, /* (45) cmd ::= SHOW STABLES */ + { 150, -1 }, /* (46) multi_create_clause ::= create_subtable_clause */ + { 150, -2 }, /* (47) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 153, -9 }, /* (48) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ + { 152, -1 }, /* (49) multi_drop_clause ::= drop_table_clause */ + { 152, -2 }, /* (50) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 156, -2 }, /* (51) drop_table_clause ::= exists_opt full_table_name */ + { 154, 0 }, /* (52) specific_tags_opt ::= */ + { 154, -3 }, /* (53) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + { 146, -1 }, /* (54) full_table_name ::= table_name */ + { 146, -3 }, /* (55) full_table_name ::= db_name NK_DOT table_name */ + { 147, -1 }, /* (56) column_def_list ::= column_def */ + { 147, -3 }, /* (57) column_def_list ::= column_def_list NK_COMMA column_def */ + { 159, -2 }, /* (58) column_def ::= column_name type_name */ + { 159, -4 }, /* (59) column_def ::= column_name type_name COMMENT NK_STRING */ + { 161, -1 }, /* (60) type_name ::= BOOL */ + { 161, -1 }, /* (61) type_name ::= TINYINT */ + { 161, -1 }, /* (62) type_name ::= SMALLINT */ + { 161, -1 }, /* (63) type_name ::= INT */ + { 161, -1 }, /* (64) type_name ::= INTEGER */ + { 161, -1 }, /* (65) type_name ::= BIGINT */ + { 161, -1 }, /* (66) type_name ::= FLOAT */ + { 161, -1 }, /* (67) type_name ::= DOUBLE */ + { 161, -4 }, /* (68) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 161, -1 }, /* (69) type_name ::= TIMESTAMP */ + { 161, -4 }, /* (70) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 161, -2 }, /* (71) type_name ::= TINYINT UNSIGNED */ + { 161, -2 }, /* (72) type_name ::= SMALLINT UNSIGNED */ + { 161, -2 }, /* (73) type_name ::= INT UNSIGNED */ + { 161, -2 }, /* (74) type_name ::= BIGINT UNSIGNED */ + { 161, -1 }, /* (75) type_name ::= JSON */ + { 161, -4 }, /* (76) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 161, -1 }, /* (77) type_name ::= MEDIUMBLOB */ + { 161, -1 }, /* (78) type_name ::= BLOB */ + { 161, -4 }, /* (79) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 161, -1 }, /* (80) type_name ::= DECIMAL */ + { 161, -4 }, /* (81) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 161, -6 }, /* (82) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 148, 0 }, /* (83) tags_def_opt ::= */ + { 148, -1 }, /* (84) tags_def_opt ::= tags_def */ + { 151, -4 }, /* (85) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 149, 0 }, /* (86) table_options ::= */ + { 149, -3 }, /* (87) table_options ::= table_options COMMENT NK_STRING */ + { 149, -3 }, /* (88) table_options ::= table_options KEEP NK_INTEGER */ + { 149, -3 }, /* (89) table_options ::= table_options TTL NK_INTEGER */ + { 149, -5 }, /* (90) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 157, -1 }, /* (91) col_name_list ::= col_name */ + { 157, -3 }, /* (92) col_name_list ::= col_name_list NK_COMMA col_name */ + { 162, -1 }, /* (93) col_name ::= column_name */ + { 138, -7 }, /* (94) cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ + { 138, -9 }, /* (95) cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ + { 164, 0 }, /* (96) index_options ::= */ + { 164, -9 }, /* (97) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ + { 164, -11 }, /* (98) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ + { 165, -1 }, /* (99) func_list ::= func */ + { 165, -3 }, /* (100) func_list ::= func_list NK_COMMA func */ + { 168, -4 }, /* (101) func ::= function_name NK_LP expression_list NK_RP */ + { 138, -2 }, /* (102) cmd ::= SHOW VGROUPS */ + { 138, -4 }, /* (103) cmd ::= SHOW db_name NK_DOT VGROUPS */ + { 138, -2 }, /* (104) cmd ::= SHOW MNODES */ + { 138, -1 }, /* (105) cmd ::= query_expression */ + { 172, -1 }, /* (106) literal ::= NK_INTEGER */ + { 172, -1 }, /* (107) literal ::= NK_FLOAT */ + { 172, -1 }, /* (108) literal ::= NK_STRING */ + { 172, -1 }, /* (109) literal ::= NK_BOOL */ + { 172, -2 }, /* (110) literal ::= TIMESTAMP NK_STRING */ + { 172, -1 }, /* (111) literal ::= duration_literal */ + { 166, -1 }, /* (112) duration_literal ::= NK_VARIABLE */ + { 155, -1 }, /* (113) literal_list ::= literal */ + { 155, -3 }, /* (114) literal_list ::= literal_list NK_COMMA literal */ + { 143, -1 }, /* (115) db_name ::= NK_ID */ + { 158, -1 }, /* (116) table_name ::= NK_ID */ + { 160, -1 }, /* (117) column_name ::= NK_ID */ + { 169, -1 }, /* (118) function_name ::= NK_ID */ + { 173, -1 }, /* (119) table_alias ::= NK_ID */ + { 174, -1 }, /* (120) column_alias ::= NK_ID */ + { 139, -1 }, /* (121) user_name ::= NK_ID */ + { 163, -1 }, /* (122) index_name ::= NK_ID */ + { 175, -1 }, /* (123) expression ::= literal */ + { 175, -1 }, /* (124) expression ::= column_reference */ + { 175, -4 }, /* (125) expression ::= function_name NK_LP expression_list NK_RP */ + { 175, -4 }, /* (126) expression ::= function_name NK_LP NK_STAR NK_RP */ + { 175, -1 }, /* (127) expression ::= subquery */ + { 175, -3 }, /* (128) expression ::= NK_LP expression NK_RP */ + { 175, -2 }, /* (129) expression ::= NK_PLUS expression */ + { 175, -2 }, /* (130) expression ::= NK_MINUS expression */ + { 175, -3 }, /* (131) expression ::= expression NK_PLUS expression */ + { 175, -3 }, /* (132) expression ::= expression NK_MINUS expression */ + { 175, -3 }, /* (133) expression ::= expression NK_STAR expression */ + { 175, -3 }, /* (134) expression ::= expression NK_SLASH expression */ + { 175, -3 }, /* (135) expression ::= expression NK_REM expression */ + { 170, -1 }, /* (136) expression_list ::= expression */ + { 170, -3 }, /* (137) expression_list ::= expression_list NK_COMMA expression */ + { 176, -1 }, /* (138) column_reference ::= column_name */ + { 176, -3 }, /* (139) column_reference ::= table_name NK_DOT column_name */ + { 178, -3 }, /* (140) predicate ::= expression compare_op expression */ + { 178, -5 }, /* (141) predicate ::= expression BETWEEN expression AND expression */ + { 178, -6 }, /* (142) predicate ::= expression NOT BETWEEN expression AND expression */ + { 178, -3 }, /* (143) predicate ::= expression IS NULL */ + { 178, -4 }, /* (144) predicate ::= expression IS NOT NULL */ + { 178, -3 }, /* (145) predicate ::= expression in_op in_predicate_value */ + { 179, -1 }, /* (146) compare_op ::= NK_LT */ + { 179, -1 }, /* (147) compare_op ::= NK_GT */ + { 179, -1 }, /* (148) compare_op ::= NK_LE */ + { 179, -1 }, /* (149) compare_op ::= NK_GE */ + { 179, -1 }, /* (150) compare_op ::= NK_NE */ + { 179, -1 }, /* (151) compare_op ::= NK_EQ */ + { 179, -1 }, /* (152) compare_op ::= LIKE */ + { 179, -2 }, /* (153) compare_op ::= NOT LIKE */ + { 179, -1 }, /* (154) compare_op ::= MATCH */ + { 179, -1 }, /* (155) compare_op ::= NMATCH */ + { 180, -1 }, /* (156) in_op ::= IN */ + { 180, -2 }, /* (157) in_op ::= NOT IN */ + { 181, -3 }, /* (158) in_predicate_value ::= NK_LP expression_list NK_RP */ + { 182, -1 }, /* (159) boolean_value_expression ::= boolean_primary */ + { 182, -2 }, /* (160) boolean_value_expression ::= NOT boolean_primary */ + { 182, -3 }, /* (161) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 182, -3 }, /* (162) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 183, -1 }, /* (163) boolean_primary ::= predicate */ + { 183, -3 }, /* (164) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 184, -1 }, /* (165) common_expression ::= expression */ + { 184, -1 }, /* (166) common_expression ::= boolean_value_expression */ + { 185, -2 }, /* (167) from_clause ::= FROM table_reference_list */ + { 186, -1 }, /* (168) table_reference_list ::= table_reference */ + { 186, -3 }, /* (169) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 187, -1 }, /* (170) table_reference ::= table_primary */ + { 187, -1 }, /* (171) table_reference ::= joined_table */ + { 188, -2 }, /* (172) table_primary ::= table_name alias_opt */ + { 188, -4 }, /* (173) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 188, -2 }, /* (174) table_primary ::= subquery alias_opt */ + { 188, -1 }, /* (175) table_primary ::= parenthesized_joined_table */ + { 190, 0 }, /* (176) alias_opt ::= */ + { 190, -1 }, /* (177) alias_opt ::= table_alias */ + { 190, -2 }, /* (178) alias_opt ::= AS table_alias */ + { 191, -3 }, /* (179) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 191, -3 }, /* (180) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 189, -6 }, /* (181) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 192, 0 }, /* (182) join_type ::= */ + { 192, -1 }, /* (183) join_type ::= INNER */ + { 194, -9 }, /* (184) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + { 195, 0 }, /* (185) set_quantifier_opt ::= */ + { 195, -1 }, /* (186) set_quantifier_opt ::= DISTINCT */ + { 195, -1 }, /* (187) set_quantifier_opt ::= ALL */ + { 196, -1 }, /* (188) select_list ::= NK_STAR */ + { 196, -1 }, /* (189) select_list ::= select_sublist */ + { 202, -1 }, /* (190) select_sublist ::= select_item */ + { 202, -3 }, /* (191) select_sublist ::= select_sublist NK_COMMA select_item */ + { 203, -1 }, /* (192) select_item ::= common_expression */ + { 203, -2 }, /* (193) select_item ::= common_expression column_alias */ + { 203, -3 }, /* (194) select_item ::= common_expression AS column_alias */ + { 203, -3 }, /* (195) select_item ::= table_name NK_DOT NK_STAR */ + { 197, 0 }, /* (196) where_clause_opt ::= */ + { 197, -2 }, /* (197) where_clause_opt ::= WHERE search_condition */ + { 198, 0 }, /* (198) partition_by_clause_opt ::= */ + { 198, -3 }, /* (199) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 199, 0 }, /* (200) twindow_clause_opt ::= */ + { 199, -6 }, /* (201) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ + { 199, -4 }, /* (202) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ + { 199, -6 }, /* (203) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 199, -8 }, /* (204) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 167, 0 }, /* (205) sliding_opt ::= */ + { 167, -4 }, /* (206) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 204, 0 }, /* (207) fill_opt ::= */ + { 204, -4 }, /* (208) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 204, -6 }, /* (209) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 205, -1 }, /* (210) fill_mode ::= NONE */ + { 205, -1 }, /* (211) fill_mode ::= PREV */ + { 205, -1 }, /* (212) fill_mode ::= NULL */ + { 205, -1 }, /* (213) fill_mode ::= LINEAR */ + { 205, -1 }, /* (214) fill_mode ::= NEXT */ + { 200, 0 }, /* (215) group_by_clause_opt ::= */ + { 200, -3 }, /* (216) group_by_clause_opt ::= GROUP BY group_by_list */ + { 206, -1 }, /* (217) group_by_list ::= expression */ + { 206, -3 }, /* (218) group_by_list ::= group_by_list NK_COMMA expression */ + { 201, 0 }, /* (219) having_clause_opt ::= */ + { 201, -2 }, /* (220) having_clause_opt ::= HAVING search_condition */ + { 171, -4 }, /* (221) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 207, -1 }, /* (222) query_expression_body ::= query_primary */ + { 207, -4 }, /* (223) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 211, -1 }, /* (224) query_primary ::= query_specification */ + { 208, 0 }, /* (225) order_by_clause_opt ::= */ + { 208, -3 }, /* (226) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 209, 0 }, /* (227) slimit_clause_opt ::= */ + { 209, -2 }, /* (228) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 209, -4 }, /* (229) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 209, -4 }, /* (230) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 210, 0 }, /* (231) limit_clause_opt ::= */ + { 210, -2 }, /* (232) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 210, -4 }, /* (233) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 210, -4 }, /* (234) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 177, -3 }, /* (235) subquery ::= NK_LP query_expression NK_RP */ + { 193, -1 }, /* (236) search_condition ::= common_expression */ + { 212, -1 }, /* (237) sort_specification_list ::= sort_specification */ + { 212, -3 }, /* (238) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 213, -3 }, /* (239) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 214, 0 }, /* (240) ordering_specification_opt ::= */ + { 214, -1 }, /* (241) ordering_specification_opt ::= ASC */ + { 214, -1 }, /* (242) ordering_specification_opt ::= DESC */ + { 215, 0 }, /* (243) null_ordering_opt ::= */ + { 215, -2 }, /* (244) null_ordering_opt ::= NULLS FIRST */ + { 215, -2 }, /* (245) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -1912,31 +1964,31 @@ static YYACTIONTYPE yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0);} break; case 1: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy129, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy209, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0);} break; case 2: /* cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy129, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy209, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0);} break; case 3: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy129); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy209); } break; case 4: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL); } break; case 5: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy129, NULL);} +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy209, NULL);} break; case 6: /* cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0);} break; case 7: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0);} break; case 8: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy129);} +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy209);} break; case 9: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL); } @@ -1944,122 +1996,123 @@ static YYACTIONTYPE yy_reduce( case 10: /* dnode_endpoint ::= NK_STRING */ case 11: /* dnode_host_name ::= NK_ID */ yytestcase(yyruleno==11); case 12: /* dnode_host_name ::= NK_IPTOKEN */ yytestcase(yyruleno==12); - case 107: /* db_name ::= NK_ID */ yytestcase(yyruleno==107); - case 108: /* table_name ::= NK_ID */ yytestcase(yyruleno==108); - case 109: /* column_name ::= NK_ID */ yytestcase(yyruleno==109); - case 110: /* function_name ::= NK_ID */ yytestcase(yyruleno==110); - case 111: /* table_alias ::= NK_ID */ yytestcase(yyruleno==111); - case 112: /* column_alias ::= NK_ID */ yytestcase(yyruleno==112); - case 113: /* user_name ::= NK_ID */ yytestcase(yyruleno==113); -{ yylhsminor.yy129 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy129 = yylhsminor.yy129; + case 115: /* db_name ::= NK_ID */ yytestcase(yyruleno==115); + case 116: /* table_name ::= NK_ID */ yytestcase(yyruleno==116); + case 117: /* column_name ::= NK_ID */ yytestcase(yyruleno==117); + case 118: /* function_name ::= NK_ID */ yytestcase(yyruleno==118); + case 119: /* table_alias ::= NK_ID */ yytestcase(yyruleno==119); + case 120: /* column_alias ::= NK_ID */ yytestcase(yyruleno==120); + case 121: /* user_name ::= NK_ID */ yytestcase(yyruleno==121); + case 122: /* index_name ::= NK_ID */ yytestcase(yyruleno==122); +{ yylhsminor.yy209 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy209 = yylhsminor.yy209; break; case 13: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy185, &yymsp[-1].minor.yy129, yymsp[0].minor.yy391);} +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy281, &yymsp[-1].minor.yy209, yymsp[0].minor.yy344);} break; case 14: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy185, &yymsp[0].minor.yy129); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy281, &yymsp[0].minor.yy209); } break; case 15: /* cmd ::= SHOW DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL); } break; case 16: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy129);} +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy209);} break; case 17: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy185 = true; } +{ yymsp[-2].minor.yy281 = true; } break; case 18: /* not_exists_opt ::= */ case 20: /* exists_opt ::= */ yytestcase(yyruleno==20); - case 176: /* set_quantifier_opt ::= */ yytestcase(yyruleno==176); -{ yymsp[1].minor.yy185 = false; } + case 185: /* set_quantifier_opt ::= */ yytestcase(yyruleno==185); +{ yymsp[1].minor.yy281 = false; } break; case 19: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy185 = true; } +{ yymsp[-1].minor.yy281 = true; } break; case 21: /* db_options ::= */ -{ yymsp[1].minor.yy391 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy344 = createDefaultDatabaseOptions(pCxt); } break; case 22: /* db_options ::= db_options BLOCKS NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 23: /* db_options ::= db_options CACHE NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 24: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 25: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 26: /* db_options ::= db_options DAYS NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 27: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 28: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 29: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 30: /* db_options ::= db_options KEEP NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_KEEP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 31: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 32: /* db_options ::= db_options QUORUM NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 33: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 34: /* db_options ::= db_options TTL NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 35: /* db_options ::= db_options WAL NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 36: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 37: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_SINGLESTABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_SINGLESTABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 38: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ -{ yylhsminor.yy391 = setDatabaseOption(pCxt, yymsp[-2].minor.yy391, DB_OPTION_STREAMMODE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy391 = yylhsminor.yy391; +{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_STREAMMODE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 39: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ case 41: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==41); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy185, yymsp[-5].minor.yy256, yymsp[-3].minor.yy46, yymsp[-1].minor.yy46, yymsp[0].minor.yy340);} +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy281, yymsp[-5].minor.yy344, yymsp[-3].minor.yy280, yymsp[-1].minor.yy280, yymsp[0].minor.yy344);} break; case 40: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy46);} +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy280);} break; case 42: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy46); } +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy280); } break; case 43: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy185, yymsp[0].minor.yy256); } +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy281, yymsp[0].minor.yy344); } break; case 44: /* cmd ::= SHOW TABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, NULL); } @@ -2071,589 +2124,608 @@ static YYACTIONTYPE yy_reduce( case 49: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==49); case 56: /* column_def_list ::= column_def */ yytestcase(yyruleno==56); case 91: /* col_name_list ::= col_name */ yytestcase(yyruleno==91); - case 181: /* select_sublist ::= select_item */ yytestcase(yyruleno==181); - case 228: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==228); -{ yylhsminor.yy46 = createNodeList(pCxt, yymsp[0].minor.yy256); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 99: /* func_list ::= func */ yytestcase(yyruleno==99); + case 190: /* select_sublist ::= select_item */ yytestcase(yyruleno==190); + case 237: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==237); +{ yylhsminor.yy280 = createNodeList(pCxt, yymsp[0].minor.yy344); } + yymsp[0].minor.yy280 = yylhsminor.yy280; break; case 47: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ case 50: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==50); -{ yylhsminor.yy46 = addNodeToList(pCxt, yymsp[-1].minor.yy46, yymsp[0].minor.yy256); } - yymsp[-1].minor.yy46 = yylhsminor.yy46; +{ yylhsminor.yy280 = addNodeToList(pCxt, yymsp[-1].minor.yy280, yymsp[0].minor.yy344); } + yymsp[-1].minor.yy280 = yylhsminor.yy280; break; case 48: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ -{ yylhsminor.yy256 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy185, yymsp[-7].minor.yy256, yymsp[-5].minor.yy256, yymsp[-4].minor.yy46, yymsp[-1].minor.yy46); } - yymsp[-8].minor.yy256 = yylhsminor.yy256; +{ yylhsminor.yy344 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy281, yymsp[-7].minor.yy344, yymsp[-5].minor.yy344, yymsp[-4].minor.yy280, yymsp[-1].minor.yy280); } + yymsp[-8].minor.yy344 = yylhsminor.yy344; break; case 51: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy256 = createDropTableClause(pCxt, yymsp[-1].minor.yy185, yymsp[0].minor.yy256); } - yymsp[-1].minor.yy256 = yylhsminor.yy256; +{ yylhsminor.yy344 = createDropTableClause(pCxt, yymsp[-1].minor.yy281, yymsp[0].minor.yy344); } + yymsp[-1].minor.yy344 = yylhsminor.yy344; break; case 52: /* specific_tags_opt ::= */ case 83: /* tags_def_opt ::= */ yytestcase(yyruleno==83); - case 189: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==189); - case 206: /* group_by_clause_opt ::= */ yytestcase(yyruleno==206); - case 216: /* order_by_clause_opt ::= */ yytestcase(yyruleno==216); -{ yymsp[1].minor.yy46 = NULL; } + case 198: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==198); + case 215: /* group_by_clause_opt ::= */ yytestcase(yyruleno==215); + case 225: /* order_by_clause_opt ::= */ yytestcase(yyruleno==225); +{ yymsp[1].minor.yy280 = NULL; } break; case 53: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy46 = yymsp[-1].minor.yy46; } +{ yymsp[-2].minor.yy280 = yymsp[-1].minor.yy280; } break; case 54: /* full_table_name ::= table_name */ -{ yylhsminor.yy256 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy129, NULL); } - yymsp[0].minor.yy256 = yylhsminor.yy256; +{ yylhsminor.yy344 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy209, NULL); } + yymsp[0].minor.yy344 = yylhsminor.yy344; break; case 55: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy256 = createRealTableNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129, NULL); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; +{ yylhsminor.yy344 = createRealTableNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209, NULL); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 57: /* column_def_list ::= column_def_list NK_COMMA column_def */ case 92: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==92); - case 182: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==182); - case 229: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==229); -{ yylhsminor.yy46 = addNodeToList(pCxt, yymsp[-2].minor.yy46, yymsp[0].minor.yy256); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + case 100: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==100); + case 191: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==191); + case 238: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==238); +{ yylhsminor.yy280 = addNodeToList(pCxt, yymsp[-2].minor.yy280, yymsp[0].minor.yy344); } + yymsp[-2].minor.yy280 = yylhsminor.yy280; break; case 58: /* column_def ::= column_name type_name */ -{ yylhsminor.yy256 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy129, yymsp[0].minor.yy70, NULL); } - yymsp[-1].minor.yy256 = yylhsminor.yy256; +{ yylhsminor.yy344 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy209, yymsp[0].minor.yy304, NULL); } + yymsp[-1].minor.yy344 = yylhsminor.yy344; break; case 59: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy256 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-2].minor.yy70, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy256 = yylhsminor.yy256; +{ yylhsminor.yy344 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-2].minor.yy304, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy344 = yylhsminor.yy344; break; case 60: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_BOOL); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_BOOL); } break; case 61: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_TINYINT); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; case 62: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; case 63: /* type_name ::= INT */ case 64: /* type_name ::= INTEGER */ yytestcase(yyruleno==64); -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_INT); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_INT); } break; case 65: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_BIGINT); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; case 66: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_FLOAT); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; case 67: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; case 68: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy70 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; case 69: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; case 70: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy70 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; case 71: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy70 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; case 72: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy70 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; case 73: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy70 = createDataType(TSDB_DATA_TYPE_UINT); } +{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_UINT); } break; case 74: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy70 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; case 75: /* type_name ::= JSON */ -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_JSON); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_JSON); } break; case 76: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy70 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; case 77: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; case 78: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_BLOB); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_BLOB); } break; case 79: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy70 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; case 80: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy70 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 81: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy70 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-3].minor.yy304 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 82: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy70 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +{ yymsp[-5].minor.yy304 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; case 84: /* tags_def_opt ::= tags_def */ - case 180: /* select_list ::= select_sublist */ yytestcase(yyruleno==180); -{ yylhsminor.yy46 = yymsp[0].minor.yy46; } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 189: /* select_list ::= select_sublist */ yytestcase(yyruleno==189); +{ yylhsminor.yy280 = yymsp[0].minor.yy280; } + yymsp[0].minor.yy280 = yylhsminor.yy280; break; case 85: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy46 = yymsp[-1].minor.yy46; } +{ yymsp[-3].minor.yy280 = yymsp[-1].minor.yy280; } break; case 86: /* table_options ::= */ -{ yymsp[1].minor.yy340 = createDefaultTableOptions(pCxt);} +{ yymsp[1].minor.yy344 = createDefaultTableOptions(pCxt);} break; case 87: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy340 = setTableOption(pCxt, yymsp[-2].minor.yy340, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy340 = yylhsminor.yy340; +{ yylhsminor.yy344 = setTableOption(pCxt, yymsp[-2].minor.yy344, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 88: /* table_options ::= table_options KEEP NK_INTEGER */ -{ yylhsminor.yy340 = setTableOption(pCxt, yymsp[-2].minor.yy340, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy340 = yylhsminor.yy340; +{ yylhsminor.yy344 = setTableOption(pCxt, yymsp[-2].minor.yy344, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 89: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy340 = setTableOption(pCxt, yymsp[-2].minor.yy340, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy340 = yylhsminor.yy340; +{ yylhsminor.yy344 = setTableOption(pCxt, yymsp[-2].minor.yy344, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; case 90: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy340 = setTableSmaOption(pCxt, yymsp[-4].minor.yy340, yymsp[-1].minor.yy46); } - yymsp[-4].minor.yy340 = yylhsminor.yy340; +{ yylhsminor.yy344 = setTableSmaOption(pCxt, yymsp[-4].minor.yy344, yymsp[-1].minor.yy280); } + yymsp[-4].minor.yy344 = yylhsminor.yy344; break; case 93: /* col_name ::= column_name */ -{ yylhsminor.yy256 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy129); } - yymsp[0].minor.yy256 = yylhsminor.yy256; +{ yylhsminor.yy344 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy209); } + yymsp[0].minor.yy344 = yylhsminor.yy344; break; - case 94: /* cmd ::= SHOW VGROUPS */ + case 94: /* cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &yymsp[-3].minor.yy209, &yymsp[-1].minor.yy209, NULL, yymsp[0].minor.yy344); } + break; + case 95: /* cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &yymsp[-5].minor.yy209, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy280, NULL); } + break; + case 96: /* index_options ::= */ + case 196: /* where_clause_opt ::= */ yytestcase(yyruleno==196); + case 200: /* twindow_clause_opt ::= */ yytestcase(yyruleno==200); + case 205: /* sliding_opt ::= */ yytestcase(yyruleno==205); + case 207: /* fill_opt ::= */ yytestcase(yyruleno==207); + case 219: /* having_clause_opt ::= */ yytestcase(yyruleno==219); + case 227: /* slimit_clause_opt ::= */ yytestcase(yyruleno==227); + case 231: /* limit_clause_opt ::= */ yytestcase(yyruleno==231); +{ yymsp[1].minor.yy344 = NULL; } + break; + case 97: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ +{ yymsp[-8].minor.yy344 = createIndexOption(pCxt, yymsp[-6].minor.yy280, yymsp[-2].minor.yy344, NULL, yymsp[0].minor.yy344); } + break; + case 98: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ +{ yymsp[-10].minor.yy344 = createIndexOption(pCxt, yymsp[-8].minor.yy280, yymsp[-4].minor.yy344, yymsp[-2].minor.yy344, yymsp[0].minor.yy344); } + break; + case 101: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy344 = createFunctionNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy280); } + yymsp[-3].minor.yy344 = yylhsminor.yy344; + break; + case 102: /* cmd ::= SHOW VGROUPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, NULL); } break; - case 95: /* cmd ::= SHOW db_name NK_DOT VGROUPS */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &yymsp[-2].minor.yy129); } + case 103: /* cmd ::= SHOW db_name NK_DOT VGROUPS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &yymsp[-2].minor.yy209); } break; - case 96: /* cmd ::= SHOW MNODES */ + case 104: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL); } break; - case 97: /* cmd ::= query_expression */ -{ pCxt->pRootNode = yymsp[0].minor.yy256; } + case 105: /* cmd ::= query_expression */ +{ pCxt->pRootNode = yymsp[0].minor.yy344; } break; - case 98: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy256 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy256 = yylhsminor.yy256; + case 106: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy344 = yylhsminor.yy344; break; - case 99: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy256 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy256 = yylhsminor.yy256; + case 107: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy344 = yylhsminor.yy344; break; - case 100: /* literal ::= NK_STRING */ -{ yylhsminor.yy256 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy256 = yylhsminor.yy256; + case 108: /* literal ::= NK_STRING */ +{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy344 = yylhsminor.yy344; break; - case 101: /* literal ::= NK_BOOL */ -{ yylhsminor.yy256 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy256 = yylhsminor.yy256; + case 109: /* literal ::= NK_BOOL */ +{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy344 = yylhsminor.yy344; break; - case 102: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy256 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy256 = yylhsminor.yy256; + case 110: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy344 = yylhsminor.yy344; break; - case 103: /* literal ::= duration_literal */ - case 114: /* expression ::= literal */ yytestcase(yyruleno==114); - case 115: /* expression ::= column_reference */ yytestcase(yyruleno==115); - case 118: /* expression ::= subquery */ yytestcase(yyruleno==118); - case 150: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==150); - case 154: /* boolean_primary ::= predicate */ yytestcase(yyruleno==154); - case 156: /* common_expression ::= expression */ yytestcase(yyruleno==156); - case 157: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==157); - case 159: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==159); - case 161: /* table_reference ::= table_primary */ yytestcase(yyruleno==161); - case 162: /* table_reference ::= joined_table */ yytestcase(yyruleno==162); - case 166: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==166); - case 213: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==213); - case 215: /* query_primary ::= query_specification */ yytestcase(yyruleno==215); -{ yylhsminor.yy256 = yymsp[0].minor.yy256; } - yymsp[0].minor.yy256 = yylhsminor.yy256; + case 111: /* literal ::= duration_literal */ + case 123: /* expression ::= literal */ yytestcase(yyruleno==123); + case 124: /* expression ::= column_reference */ yytestcase(yyruleno==124); + case 127: /* expression ::= subquery */ yytestcase(yyruleno==127); + case 159: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==159); + case 163: /* boolean_primary ::= predicate */ yytestcase(yyruleno==163); + case 165: /* common_expression ::= expression */ yytestcase(yyruleno==165); + case 166: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==166); + case 168: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==168); + case 170: /* table_reference ::= table_primary */ yytestcase(yyruleno==170); + case 171: /* table_reference ::= joined_table */ yytestcase(yyruleno==171); + case 175: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==175); + case 222: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==222); + case 224: /* query_primary ::= query_specification */ yytestcase(yyruleno==224); +{ yylhsminor.yy344 = yymsp[0].minor.yy344; } + yymsp[0].minor.yy344 = yylhsminor.yy344; break; - case 104: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy256 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy256 = yylhsminor.yy256; + case 112: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy344 = yylhsminor.yy344; break; - case 105: /* literal_list ::= literal */ - case 127: /* expression_list ::= expression */ yytestcase(yyruleno==127); -{ yylhsminor.yy46 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy256)); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 113: /* literal_list ::= literal */ + case 136: /* expression_list ::= expression */ yytestcase(yyruleno==136); +{ yylhsminor.yy280 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy344)); } + yymsp[0].minor.yy280 = yylhsminor.yy280; break; - case 106: /* literal_list ::= literal_list NK_COMMA literal */ - case 128: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==128); -{ yylhsminor.yy46 = addNodeToList(pCxt, yymsp[-2].minor.yy46, releaseRawExprNode(pCxt, yymsp[0].minor.yy256)); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + case 114: /* literal_list ::= literal_list NK_COMMA literal */ + case 137: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==137); +{ yylhsminor.yy280 = addNodeToList(pCxt, yymsp[-2].minor.yy280, releaseRawExprNode(pCxt, yymsp[0].minor.yy344)); } + yymsp[-2].minor.yy280 = yylhsminor.yy280; break; - case 116: /* expression ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy256 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy129, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy46)); } - yymsp[-3].minor.yy256 = yylhsminor.yy256; + case 125: /* expression ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy209, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy280)); } + yymsp[-3].minor.yy344 = yylhsminor.yy344; break; - case 117: /* expression ::= function_name NK_LP NK_STAR NK_RP */ -{ yylhsminor.yy256 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy129, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy129, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } - yymsp[-3].minor.yy256 = yylhsminor.yy256; + case 126: /* expression ::= function_name NK_LP NK_STAR NK_RP */ +{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy209, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy209, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } + yymsp[-3].minor.yy344 = yylhsminor.yy344; break; - case 119: /* expression ::= NK_LP expression NK_RP */ - case 155: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==155); -{ yylhsminor.yy256 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy256)); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + case 128: /* expression ::= NK_LP expression NK_RP */ + case 164: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==164); +{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy344)); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 120: /* expression ::= NK_PLUS expression */ + case 129: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy256)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy344)); } - yymsp[-1].minor.yy256 = yylhsminor.yy256; + yymsp[-1].minor.yy344 = yylhsminor.yy344; break; - case 121: /* expression ::= NK_MINUS expression */ + case 130: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy256), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy344), NULL)); } - yymsp[-1].minor.yy256 = yylhsminor.yy256; + yymsp[-1].minor.yy344 = yylhsminor.yy344; break; - case 122: /* expression ::= expression NK_PLUS expression */ + case 131: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy256); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 123: /* expression ::= expression NK_MINUS expression */ + case 132: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy256); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 124: /* expression ::= expression NK_STAR expression */ + case 133: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy256); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 125: /* expression ::= expression NK_SLASH expression */ + case 134: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy256); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 126: /* expression ::= expression NK_REM expression */ + case 135: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy256); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 129: /* column_reference ::= column_name */ -{ yylhsminor.yy256 = createRawExprNode(pCxt, &yymsp[0].minor.yy129, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy129)); } - yymsp[0].minor.yy256 = yylhsminor.yy256; + case 138: /* column_reference ::= column_name */ +{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy209, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy209)); } + yymsp[0].minor.yy344 = yylhsminor.yy344; break; - case 130: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy256 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129, createColumnNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129)); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + case 139: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209, createColumnNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209)); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 131: /* predicate ::= expression compare_op expression */ - case 136: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==136); + case 140: /* predicate ::= expression compare_op expression */ + case 145: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==145); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy256); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy326, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy236, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 132: /* predicate ::= expression BETWEEN expression AND expression */ + case 141: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy256); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy256), releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy344); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy344), releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[-4].minor.yy256 = yylhsminor.yy256; + yymsp[-4].minor.yy344 = yylhsminor.yy344; break; - case 133: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 142: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy256); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), releaseRawExprNode(pCxt, yymsp[-5].minor.yy256), releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy344); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[-5].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[-5].minor.yy256 = yylhsminor.yy256; + yymsp[-5].minor.yy344 = yylhsminor.yy344; break; - case 134: /* predicate ::= expression IS NULL */ + case 143: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), NULL)); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 135: /* predicate ::= expression IS NOT NULL */ + case 144: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy256), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy344), NULL)); } - yymsp[-3].minor.yy256 = yylhsminor.yy256; + yymsp[-3].minor.yy344 = yylhsminor.yy344; break; - case 137: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy326 = OP_TYPE_LOWER_THAN; } + case 146: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy236 = OP_TYPE_LOWER_THAN; } break; - case 138: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy326 = OP_TYPE_GREATER_THAN; } + case 147: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy236 = OP_TYPE_GREATER_THAN; } break; - case 139: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy326 = OP_TYPE_LOWER_EQUAL; } + case 148: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy236 = OP_TYPE_LOWER_EQUAL; } break; - case 140: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy326 = OP_TYPE_GREATER_EQUAL; } + case 149: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy236 = OP_TYPE_GREATER_EQUAL; } break; - case 141: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy326 = OP_TYPE_NOT_EQUAL; } + case 150: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy236 = OP_TYPE_NOT_EQUAL; } break; - case 142: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy326 = OP_TYPE_EQUAL; } + case 151: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy236 = OP_TYPE_EQUAL; } break; - case 143: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy326 = OP_TYPE_LIKE; } + case 152: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy236 = OP_TYPE_LIKE; } break; - case 144: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy326 = OP_TYPE_NOT_LIKE; } + case 153: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy236 = OP_TYPE_NOT_LIKE; } break; - case 145: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy326 = OP_TYPE_MATCH; } + case 154: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy236 = OP_TYPE_MATCH; } break; - case 146: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy326 = OP_TYPE_NMATCH; } + case 155: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy236 = OP_TYPE_NMATCH; } break; - case 147: /* in_op ::= IN */ -{ yymsp[0].minor.yy326 = OP_TYPE_IN; } + case 156: /* in_op ::= IN */ +{ yymsp[0].minor.yy236 = OP_TYPE_IN; } break; - case 148: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy326 = OP_TYPE_NOT_IN; } + case 157: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy236 = OP_TYPE_NOT_IN; } break; - case 149: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy256 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy46)); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + case 158: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy280)); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 151: /* boolean_value_expression ::= NOT boolean_primary */ + case 160: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy256), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy344), NULL)); } - yymsp[-1].minor.yy256 = yylhsminor.yy256; + yymsp[-1].minor.yy344 = yylhsminor.yy344; break; - case 152: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 161: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy256); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 153: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 162: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy256); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 158: /* from_clause ::= FROM table_reference_list */ - case 188: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==188); - case 211: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==211); -{ yymsp[-1].minor.yy256 = yymsp[0].minor.yy256; } + case 167: /* from_clause ::= FROM table_reference_list */ + case 197: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==197); + case 220: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==220); +{ yymsp[-1].minor.yy344 = yymsp[0].minor.yy344; } break; - case 160: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy256 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy256, yymsp[0].minor.yy256, NULL); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + case 169: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy344 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy344, yymsp[0].minor.yy344, NULL); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 163: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy256 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy129, &yymsp[0].minor.yy129); } - yymsp[-1].minor.yy256 = yylhsminor.yy256; + case 172: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy344 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy209, &yymsp[0].minor.yy209); } + yymsp[-1].minor.yy344 = yylhsminor.yy344; break; - case 164: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy256 = createRealTableNode(pCxt, &yymsp[-3].minor.yy129, &yymsp[-1].minor.yy129, &yymsp[0].minor.yy129); } - yymsp[-3].minor.yy256 = yylhsminor.yy256; + case 173: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy344 = createRealTableNode(pCxt, &yymsp[-3].minor.yy209, &yymsp[-1].minor.yy209, &yymsp[0].minor.yy209); } + yymsp[-3].minor.yy344 = yylhsminor.yy344; break; - case 165: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy256 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy256), &yymsp[0].minor.yy129); } - yymsp[-1].minor.yy256 = yylhsminor.yy256; + case 174: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy344 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy344), &yymsp[0].minor.yy209); } + yymsp[-1].minor.yy344 = yylhsminor.yy344; break; - case 167: /* alias_opt ::= */ -{ yymsp[1].minor.yy129 = nil_token; } + case 176: /* alias_opt ::= */ +{ yymsp[1].minor.yy209 = nil_token; } break; - case 168: /* alias_opt ::= table_alias */ -{ yylhsminor.yy129 = yymsp[0].minor.yy129; } - yymsp[0].minor.yy129 = yylhsminor.yy129; + case 177: /* alias_opt ::= table_alias */ +{ yylhsminor.yy209 = yymsp[0].minor.yy209; } + yymsp[0].minor.yy209 = yylhsminor.yy209; break; - case 169: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy129 = yymsp[0].minor.yy129; } + case 178: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy209 = yymsp[0].minor.yy209; } break; - case 170: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 171: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==171); -{ yymsp[-2].minor.yy256 = yymsp[-1].minor.yy256; } + case 179: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 180: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==180); +{ yymsp[-2].minor.yy344 = yymsp[-1].minor.yy344; } break; - case 172: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy256 = createJoinTableNode(pCxt, yymsp[-4].minor.yy266, yymsp[-5].minor.yy256, yymsp[-2].minor.yy256, yymsp[0].minor.yy256); } - yymsp[-5].minor.yy256 = yylhsminor.yy256; + case 181: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy344 = createJoinTableNode(pCxt, yymsp[-4].minor.yy36, yymsp[-5].minor.yy344, yymsp[-2].minor.yy344, yymsp[0].minor.yy344); } + yymsp[-5].minor.yy344 = yylhsminor.yy344; break; - case 173: /* join_type ::= */ -{ yymsp[1].minor.yy266 = JOIN_TYPE_INNER; } + case 182: /* join_type ::= */ +{ yymsp[1].minor.yy36 = JOIN_TYPE_INNER; } break; - case 174: /* join_type ::= INNER */ -{ yymsp[0].minor.yy266 = JOIN_TYPE_INNER; } + case 183: /* join_type ::= INNER */ +{ yymsp[0].minor.yy36 = JOIN_TYPE_INNER; } break; - case 175: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 184: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { - yymsp[-8].minor.yy256 = createSelectStmt(pCxt, yymsp[-7].minor.yy185, yymsp[-6].minor.yy46, yymsp[-5].minor.yy256); - yymsp[-8].minor.yy256 = addWhereClause(pCxt, yymsp[-8].minor.yy256, yymsp[-4].minor.yy256); - yymsp[-8].minor.yy256 = addPartitionByClause(pCxt, yymsp[-8].minor.yy256, yymsp[-3].minor.yy46); - yymsp[-8].minor.yy256 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy256, yymsp[-2].minor.yy256); - yymsp[-8].minor.yy256 = addGroupByClause(pCxt, yymsp[-8].minor.yy256, yymsp[-1].minor.yy46); - yymsp[-8].minor.yy256 = addHavingClause(pCxt, yymsp[-8].minor.yy256, yymsp[0].minor.yy256); + yymsp[-8].minor.yy344 = createSelectStmt(pCxt, yymsp[-7].minor.yy281, yymsp[-6].minor.yy280, yymsp[-5].minor.yy344); + yymsp[-8].minor.yy344 = addWhereClause(pCxt, yymsp[-8].minor.yy344, yymsp[-4].minor.yy344); + yymsp[-8].minor.yy344 = addPartitionByClause(pCxt, yymsp[-8].minor.yy344, yymsp[-3].minor.yy280); + yymsp[-8].minor.yy344 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy344, yymsp[-2].minor.yy344); + yymsp[-8].minor.yy344 = addGroupByClause(pCxt, yymsp[-8].minor.yy344, yymsp[-1].minor.yy280); + yymsp[-8].minor.yy344 = addHavingClause(pCxt, yymsp[-8].minor.yy344, yymsp[0].minor.yy344); } break; - case 177: /* set_quantifier_opt ::= DISTINCT */ -{ yymsp[0].minor.yy185 = true; } + case 186: /* set_quantifier_opt ::= DISTINCT */ +{ yymsp[0].minor.yy281 = true; } break; - case 178: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy185 = false; } + case 187: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy281 = false; } break; - case 179: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy46 = NULL; } + case 188: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy280 = NULL; } break; - case 183: /* select_item ::= common_expression */ + case 192: /* select_item ::= common_expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy256); - yylhsminor.yy256 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy256), &t); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); + yylhsminor.yy344 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy344), &t); } - yymsp[0].minor.yy256 = yylhsminor.yy256; + yymsp[0].minor.yy344 = yylhsminor.yy344; break; - case 184: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy256 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy256), &yymsp[0].minor.yy129); } - yymsp[-1].minor.yy256 = yylhsminor.yy256; + case 193: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy344 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy344), &yymsp[0].minor.yy209); } + yymsp[-1].minor.yy344 = yylhsminor.yy344; break; - case 185: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy256 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), &yymsp[0].minor.yy129); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + case 194: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy344 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), &yymsp[0].minor.yy209); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 186: /* select_item ::= table_name NK_DOT NK_STAR */ -{ yylhsminor.yy256 = createColumnNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + case 195: /* select_item ::= table_name NK_DOT NK_STAR */ +{ yylhsminor.yy344 = createColumnNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 187: /* where_clause_opt ::= */ - case 191: /* twindow_clause_opt ::= */ yytestcase(yyruleno==191); - case 196: /* sliding_opt ::= */ yytestcase(yyruleno==196); - case 198: /* fill_opt ::= */ yytestcase(yyruleno==198); - case 210: /* having_clause_opt ::= */ yytestcase(yyruleno==210); - case 218: /* slimit_clause_opt ::= */ yytestcase(yyruleno==218); - case 222: /* limit_clause_opt ::= */ yytestcase(yyruleno==222); -{ yymsp[1].minor.yy256 = NULL; } + case 199: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 216: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==216); + case 226: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==226); +{ yymsp[-2].minor.yy280 = yymsp[0].minor.yy280; } break; - case 190: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 207: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==207); - case 217: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==217); -{ yymsp[-2].minor.yy46 = yymsp[0].minor.yy46; } + case 201: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy344 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy344), &yymsp[-1].minor.yy0); } break; - case 192: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy256 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy256), &yymsp[-1].minor.yy0); } + case 202: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ +{ yymsp[-3].minor.yy344 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy344)); } break; - case 193: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ -{ yymsp[-3].minor.yy256 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy256)); } + case 203: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy344 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy344), NULL, yymsp[-1].minor.yy344, yymsp[0].minor.yy344); } break; - case 194: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy256 = createIntervalWindowNode(pCxt, yymsp[-3].minor.yy256, NULL, yymsp[-1].minor.yy256, yymsp[0].minor.yy256); } + case 204: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy344 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy344), releaseRawExprNode(pCxt, yymsp[-3].minor.yy344), yymsp[-1].minor.yy344, yymsp[0].minor.yy344); } break; - case 195: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy256 = createIntervalWindowNode(pCxt, yymsp[-5].minor.yy256, yymsp[-3].minor.yy256, yymsp[-1].minor.yy256, yymsp[0].minor.yy256); } + case 206: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ +{ yymsp[-3].minor.yy344 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy344); } break; - case 197: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ -{ yymsp[-3].minor.yy256 = yymsp[-1].minor.yy256; } + case 208: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy344 = createFillNode(pCxt, yymsp[-1].minor.yy342, NULL); } break; - case 199: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy256 = createFillNode(pCxt, yymsp[-1].minor.yy360, NULL); } + case 209: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy344 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy280)); } break; - case 200: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy256 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy46)); } + case 210: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy342 = FILL_MODE_NONE; } break; - case 201: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy360 = FILL_MODE_NONE; } + case 211: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy342 = FILL_MODE_PREV; } break; - case 202: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy360 = FILL_MODE_PREV; } + case 212: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy342 = FILL_MODE_NULL; } break; - case 203: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy360 = FILL_MODE_NULL; } + case 213: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy342 = FILL_MODE_LINEAR; } break; - case 204: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy360 = FILL_MODE_LINEAR; } + case 214: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy342 = FILL_MODE_NEXT; } break; - case 205: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy360 = FILL_MODE_NEXT; } + case 217: /* group_by_list ::= expression */ +{ yylhsminor.yy280 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } + yymsp[0].minor.yy280 = yylhsminor.yy280; break; - case 208: /* group_by_list ::= expression */ -{ yylhsminor.yy46 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 218: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy280 = addNodeToList(pCxt, yymsp[-2].minor.yy280, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } + yymsp[-2].minor.yy280 = yylhsminor.yy280; break; - case 209: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy46 = addNodeToList(pCxt, yymsp[-2].minor.yy46, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy256))); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; - break; - case 212: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 221: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy256 = addOrderByClause(pCxt, yymsp[-3].minor.yy256, yymsp[-2].minor.yy46); - yylhsminor.yy256 = addSlimitClause(pCxt, yylhsminor.yy256, yymsp[-1].minor.yy256); - yylhsminor.yy256 = addLimitClause(pCxt, yylhsminor.yy256, yymsp[0].minor.yy256); + yylhsminor.yy344 = addOrderByClause(pCxt, yymsp[-3].minor.yy344, yymsp[-2].minor.yy280); + yylhsminor.yy344 = addSlimitClause(pCxt, yylhsminor.yy344, yymsp[-1].minor.yy344); + yylhsminor.yy344 = addLimitClause(pCxt, yylhsminor.yy344, yymsp[0].minor.yy344); } - yymsp[-3].minor.yy256 = yylhsminor.yy256; + yymsp[-3].minor.yy344 = yylhsminor.yy344; break; - case 214: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy256 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy256, yymsp[0].minor.yy256); } - yymsp[-3].minor.yy256 = yylhsminor.yy256; + case 223: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy344 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy344, yymsp[0].minor.yy344); } + yymsp[-3].minor.yy344 = yylhsminor.yy344; break; - case 219: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 223: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==223); -{ yymsp[-1].minor.yy256 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 228: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 232: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==232); +{ yymsp[-1].minor.yy344 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 220: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 224: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==224); -{ yymsp[-3].minor.yy256 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 229: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 233: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==233); +{ yymsp[-3].minor.yy344 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 221: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 225: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==225); -{ yymsp[-3].minor.yy256 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 230: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 234: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==234); +{ yymsp[-3].minor.yy344 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 226: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy256 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy256); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + case 235: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy344); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 227: /* search_condition ::= common_expression */ -{ yylhsminor.yy256 = releaseRawExprNode(pCxt, yymsp[0].minor.yy256); } - yymsp[0].minor.yy256 = yylhsminor.yy256; + case 236: /* search_condition ::= common_expression */ +{ yylhsminor.yy344 = releaseRawExprNode(pCxt, yymsp[0].minor.yy344); } + yymsp[0].minor.yy344 = yylhsminor.yy344; break; - case 230: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy256 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy256), yymsp[-1].minor.yy202, yymsp[0].minor.yy147); } - yymsp[-2].minor.yy256 = yylhsminor.yy256; + case 239: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy344 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), yymsp[-1].minor.yy2, yymsp[0].minor.yy217); } + yymsp[-2].minor.yy344 = yylhsminor.yy344; break; - case 231: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy202 = ORDER_ASC; } + case 240: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy2 = ORDER_ASC; } break; - case 232: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy202 = ORDER_ASC; } + case 241: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy2 = ORDER_ASC; } break; - case 233: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy202 = ORDER_DESC; } + case 242: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy2 = ORDER_DESC; } break; - case 234: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy147 = NULL_ORDER_DEFAULT; } + case 243: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy217 = NULL_ORDER_DEFAULT; } break; - case 235: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy147 = NULL_ORDER_FIRST; } + case 244: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy217 = NULL_ORDER_FIRST; } break; - case 236: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy147 = NULL_ORDER_LAST; } + case 245: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy217 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/parserAstTest.cpp b/source/libs/parser/test/parserAstTest.cpp index d30c21cc21..cf889c0f3c 100644 --- a/source/libs/parser/test/parserAstTest.cpp +++ b/source/libs/parser/test/parserAstTest.cpp @@ -398,3 +398,10 @@ TEST_F(ParserTest, createTable) { ); ASSERT_TRUE(run()); } + +TEST_F(ParserTest, createSmaIndex) { + setDatabase("root", "test"); + + bind("create sma index index1 on t1 function(max(c1), min(c3 + 10), sum(c4))"); + ASSERT_TRUE(run()); +} diff --git a/source/util/src/tjson.c b/source/util/src/tjson.c index 634cfcb026..0a4a1a07a6 100644 --- a/source/util/src/tjson.c +++ b/source/util/src/tjson.c @@ -26,6 +26,14 @@ SJson* tjsonCreateObject() { return pJson; } +SJson* tjsonCreateArray() { + SJson* pJson = cJSON_CreateArray(); + if (pJson == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + } + return pJson; +} + void tjsonDelete(SJson* pJson) { if (pJson != NULL) { cJSON_Delete((cJSON*)pJson); From c2aebb25bf5d4c9e023cc93339bcda572637ffde Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Tue, 15 Mar 2022 06:44:38 -0400 Subject: [PATCH 03/37] TD-13675 create sma index parser implement --- include/libs/parser/parser.h | 1 + include/libs/planner/planner.h | 1 + source/client/inc/clientInt.h | 2 + source/client/src/clientImpl.c | 3 -- source/client/src/tmq.c | 14 +++--- source/libs/nodes/src/nodesUtilFuncs.c | 14 ++++++ source/libs/parser/inc/sql.y | 4 +- source/libs/parser/src/parTranslater.c | 56 ++++++++++++----------- source/libs/parser/src/sql.c | 4 +- source/libs/parser/test/parserAstTest.cpp | 2 +- 10 files changed, 58 insertions(+), 43 deletions(-) diff --git a/include/libs/parser/parser.h b/include/libs/parser/parser.h index bf0c963059..77838c705f 100644 --- a/include/libs/parser/parser.h +++ b/include/libs/parser/parser.h @@ -51,6 +51,7 @@ typedef struct SQuery { SSchema* pResSchema; SCmdMsgInfo* pCmdMsg; int32_t msgType; + bool streamQuery; } SQuery; int32_t qParseQuerySql(SParseContext* pCxt, SQuery** pQuery); diff --git a/include/libs/planner/planner.h b/include/libs/planner/planner.h index 07579e0a7d..7eb9d038a5 100644 --- a/include/libs/planner/planner.h +++ b/include/libs/planner/planner.h @@ -26,6 +26,7 @@ typedef struct SPlanContext { uint64_t queryId; int32_t acctId; SNode* pAstRoot; + bool streamQuery; } SPlanContext; // Create the physical plan for the query, according to the AST. diff --git a/source/client/inc/clientInt.h b/source/client/inc/clientInt.h index 321e8ab77b..b672c9bb47 100644 --- a/source/client/inc/clientInt.h +++ b/source/client/inc/clientInt.h @@ -21,6 +21,7 @@ extern "C" { #endif #include "parser.h" +#include "planner.h" #include "query.h" #include "taos.h" #include "tcommon.h" @@ -229,6 +230,7 @@ void setResultDataPtr(SReqResultInfo* pResultInfo, TAOS_FIELD* pFields, int32_t int32_t buildRequest(STscObj* pTscObj, const char* sql, int sqlLen, SRequestObj** pRequest); int32_t parseSql(SRequestObj* pRequest, SQuery** pQuery); +int32_t getPlan(SRequestObj* pRequest, SQuery* pQuery, SQueryPlan** pPlan, SArray* pNodeList); // --- heartbeat // global, called by mgmt diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index 646b443fb7..fc97f4113c 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -1,8 +1,6 @@ #include "clientInt.h" #include "clientLog.h" -#include "parser.h" -#include "planner.h" #include "scheduler.h" #include "tdatablock.h" #include "tdef.h" @@ -211,7 +209,6 @@ void setResSchemaInfo(SReqResultInfo* pResInfo, const SSchema* pSchema, int32_t } } - int32_t scheduleQuery(SRequestObj* pRequest, SQueryPlan* pDag, SArray* pNodeList) { void* pTransporter = pRequest->pTscObj->pAppInfo->pTransporter; diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index 846329f0f4..0e4c7cdf47 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -482,21 +482,19 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i } tscDebug("start to create topic, %s", topicName); -#if 0 + CHECK_CODE_GOTO(buildRequest(pTscObj, sql, sqlLen, &pRequest), _return); CHECK_CODE_GOTO(parseSql(pRequest, &pQueryNode), _return); - SQueryStmtInfo* pQueryStmtInfo = (SQueryStmtInfo*)pQueryNode; - pQueryStmtInfo->info.continueQuery = true; + pQueryNode->streamQuery = true; // todo check for invalid sql statement and return with error code SSchema* schema = NULL; int32_t numOfCols = 0; - CHECK_CODE_GOTO(qCreateQueryDag(pQueryNode, &pRequest->body.pDag, &schema, &numOfCols, NULL, pRequest->requestId), - _return); + CHECK_CODE_GOTO(getPlan(pRequest, pQueryNode, &pRequest->body.pDag, NULL), _return); - pStr = qDagToString(pRequest->body.pDag); + pStr = qQueryPlanToString(pRequest->body.pDag); if (pStr == NULL) { goto _return; } @@ -506,7 +504,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i // The topic should be related to a database that the queried table is belonged to. SName name = {0}; char dbName[TSDB_DB_FNAME_LEN] = {0}; - tNameGetFullDbName(&((SQueryStmtInfo*)pQueryNode)->pTableMetaInfo[0]->name, dbName); + // tNameGetFullDbName(&((SQueryStmtInfo*)pQueryNode)->pTableMetaInfo[0]->name, dbName); tNameFromString(&name, dbName, T_NAME_ACCT | T_NAME_DB); tNameFromString(&name, topicName, T_NAME_TABLE); @@ -538,7 +536,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i asyncSendMsgToServer(pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo); tsem_wait(&pRequest->body.rspSem); -#endif + _return: qDestroyQuery(pQueryNode); /*if (sendInfo != NULL) {*/ diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index cc99387095..43caa25c3d 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -216,6 +216,14 @@ static EDealRes destroyNode(SNode** pNode, void* pContext) { case QUERY_NODE_NODE_LIST: nodesClearList(((SNodeListNode*)(*pNode))->pNodeList); break; + case QUERY_NODE_INDEX_OPTIONS: { + SIndexOptions* pStmt = (SIndexOptions*)*pNode; + nodesDestroyList(pStmt->pFuncs); + nodesDestroyNode(pStmt->pInterval); + nodesDestroyNode(pStmt->pOffset); + nodesDestroyNode(pStmt->pSliding); + break; + } case QUERY_NODE_SELECT_STMT: { SSelectStmt* pStmt = (SSelectStmt*)*pNode; nodesDestroyList(pStmt->pProjectionList); @@ -256,6 +264,12 @@ static EDealRes destroyNode(SNode** pNode, void* pContext) { case QUERY_NODE_CREATE_MULTI_TABLE_STMT: nodesDestroyList(((SCreateMultiTableStmt*)(*pNode))->pSubTables); break; + case QUERY_NODE_CREATE_INDEX_STMT: { + SCreateIndexStmt* pStmt = (SCreateIndexStmt*)*pNode; + nodesDestroyNode(pStmt->pOptions); + nodesDestroyList(pStmt->pCols); + break; + } default: break; } diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 7515466b47..a9fb0a9f5e 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -197,9 +197,9 @@ cmd ::= CREATE FULLTEXT INDEX index_options(A) ::= . { A = NULL; } index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL - NK_LP duration_literal(C) NK_RP sliding_opt(D). { A = createIndexOption(pCxt, B, C, NULL, D); } + NK_LP duration_literal(C) NK_RP sliding_opt(D). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), NULL, D); } index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL - NK_LP duration_literal(C) NK_COMMA duration_literal(D) NK_RP sliding_opt(E). { A = createIndexOption(pCxt, B, C, D, E); } + NK_LP duration_literal(C) NK_COMMA duration_literal(D) NK_RP sliding_opt(E). { A = createIndexOption(pCxt, B, releaseRawExprNode(pCxt, C), releaseRawExprNode(pCxt, D), E); } %type func_list { SNodeList* } %destructor func_list { nodesDestroyList($$); } diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 3fff4fa4ca..dbba590620 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -795,14 +795,14 @@ static int32_t translateCreateDatabase(STranslateContext* pCxt, SCreateDatabaseS buildCreateDbReq(pCxt, pStmt, &createReq); pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_DB; pCxt->pCmdMsg->msgLen = tSerializeSCreateDbReq(NULL, 0, &createReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { return TSDB_CODE_OUT_OF_MEMORY; } tSerializeSCreateDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq); @@ -818,14 +818,14 @@ static int32_t translateDropDatabase(STranslateContext* pCxt, SDropDatabaseStmt* dropReq.ignoreNotExists = pStmt->ignoreNotExists; pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; pCxt->pCmdMsg->msgType = TDMT_MND_DROP_DB; pCxt->pCmdMsg->msgLen = tSerializeSDropDbReq(NULL, 0, &dropReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { return TSDB_CODE_OUT_OF_MEMORY; } tSerializeSDropDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq); @@ -859,7 +859,7 @@ static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableSt tNameExtractFullName(&tableName, createReq.name); pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { tFreeSMCreateStbReq(&createReq); return TSDB_CODE_OUT_OF_MEMORY; } @@ -867,7 +867,7 @@ static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableSt pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_STB; pCxt->pCmdMsg->msgLen = tSerializeSMCreateStbReq(NULL, 0, &createReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { tFreeSMCreateStbReq(&createReq); return TSDB_CODE_OUT_OF_MEMORY; } @@ -883,14 +883,14 @@ static int32_t doTranslateDropSuperTable(STranslateContext* pCxt, const SName* p dropReq.igNotExists = ignoreNotExists; pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; pCxt->pCmdMsg->msgType = TDMT_MND_DROP_STB; pCxt->pCmdMsg->msgLen = tSerializeSMDropStbReq(NULL, 0, &dropReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { return TSDB_CODE_OUT_OF_MEMORY; } tSerializeSMDropStbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq); @@ -936,14 +936,14 @@ static int32_t translateUseDatabase(STranslateContext* pCxt, SUseDatabaseStmt* p catalogGetDBVgVersion(pCxt->pParseCxt->pCatalog, usedbReq.db, &usedbReq.vgVersion, &usedbReq.dbId, &usedbReq.numOfTable); pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; pCxt->pCmdMsg->msgType = TDMT_MND_USE_DB; pCxt->pCmdMsg->msgLen = tSerializeSUseDbReq(NULL, 0, &usedbReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { return TSDB_CODE_OUT_OF_MEMORY; } tSerializeSUseDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &usedbReq); @@ -959,14 +959,14 @@ static int32_t translateCreateUser(STranslateContext* pCxt, SCreateUserStmt* pSt strcpy(createReq.pass, pStmt->password); pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_USER; pCxt->pCmdMsg->msgLen = tSerializeSCreateUserReq(NULL, 0, &createReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { return TSDB_CODE_OUT_OF_MEMORY; } tSerializeSCreateUserReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq); @@ -985,14 +985,14 @@ static int32_t translateAlterUser(STranslateContext* pCxt, SAlterUserStmt* pStmt } pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; pCxt->pCmdMsg->msgType = TDMT_MND_ALTER_USER; pCxt->pCmdMsg->msgLen = tSerializeSAlterUserReq(NULL, 0, &alterReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { return TSDB_CODE_OUT_OF_MEMORY; } tSerializeSAlterUserReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &alterReq); @@ -1005,14 +1005,14 @@ static int32_t translateDropUser(STranslateContext* pCxt, SDropUserStmt* pStmt) strcpy(dropReq.user, pStmt->useName); pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; pCxt->pCmdMsg->msgType = TDMT_MND_DROP_USER; pCxt->pCmdMsg->msgLen = tSerializeSDropUserReq(NULL, 0, &dropReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { return TSDB_CODE_OUT_OF_MEMORY; } tSerializeSDropUserReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq); @@ -1026,14 +1026,14 @@ static int32_t translateCreateDnode(STranslateContext* pCxt, SCreateDnodeStmt* p createReq.port = pStmt->port; pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_DNODE; pCxt->pCmdMsg->msgLen = tSerializeSCreateDnodeReq(NULL, 0, &createReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { return TSDB_CODE_OUT_OF_MEMORY; } tSerializeSCreateDnodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq); @@ -1048,14 +1048,14 @@ static int32_t translateDropDnode(STranslateContext* pCxt, SDropDnodeStmt* pStmt dropReq.port = pStmt->port; pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; pCxt->pCmdMsg->msgType = TDMT_MND_DROP_DNODE; pCxt->pCmdMsg->msgLen = tSerializeSDropDnodeReq(NULL, 0, &dropReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { return TSDB_CODE_OUT_OF_MEMORY; } tSerializeSDropDnodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq); @@ -1093,14 +1093,14 @@ static int32_t translateShow(STranslateContext* pCxt, SShowStmt* pStmt) { } pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; pCxt->pCmdMsg->msgType = TDMT_MND_SHOW; pCxt->pCmdMsg->msgLen = tSerializeSShowReq(NULL, 0, &showReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { return TSDB_CODE_OUT_OF_MEMORY; } tSerializeSShowReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &showReq); @@ -1128,7 +1128,7 @@ static int32_t translateShowTables(STranslateContext* pCxt) { pShowReq->head.vgId = htonl(info->vgId); pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = info->epSet; @@ -1167,23 +1167,25 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt createSmaReq.tSma.tableUid = pMeta->uid; createSmaReq.tSma.interval = ((SValueNode*)pStmt->pOptions->pInterval)->datum.i; createSmaReq.tSma.sliding = (NULL != pStmt->pOptions->pSliding ? ((SValueNode*)pStmt->pOptions->pSliding)->datum.i : 0); - code = nodesListToString(pStmt->pCols, false, &createSmaReq.tSma.expr, &createSmaReq.tSma.exprLen); + code = nodesListToString(pStmt->pOptions->pFuncs, false, &createSmaReq.tSma.expr, &createSmaReq.tSma.exprLen); if (TSDB_CODE_SUCCESS != code) { return code; } pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); - if (NULL== pCxt->pCmdMsg) { + if (NULL == pCxt->pCmdMsg) { return TSDB_CODE_OUT_OF_MEMORY; } pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; pCxt->pCmdMsg->msgType = TDMT_VND_CREATE_SMA; pCxt->pCmdMsg->msgLen = tSerializeSVCreateTSmaReq(NULL, &createSmaReq); pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); - if (NULL== pCxt->pCmdMsg->pMsg) { + if (NULL == pCxt->pCmdMsg->pMsg) { return TSDB_CODE_OUT_OF_MEMORY; } - tSerializeSVCreateTSmaReq(pCxt->pCmdMsg->pMsg, &createSmaReq); + void* pBuf = pCxt->pCmdMsg->pMsg; + tSerializeSVCreateTSmaReq(&pBuf, &createSmaReq); + // todo clear SVCreateTSmaReq return TSDB_CODE_SUCCESS; } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index ae20ecdd7e..c135d59298 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -2292,10 +2292,10 @@ static YYACTIONTYPE yy_reduce( { yymsp[1].minor.yy344 = NULL; } break; case 97: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ -{ yymsp[-8].minor.yy344 = createIndexOption(pCxt, yymsp[-6].minor.yy280, yymsp[-2].minor.yy344, NULL, yymsp[0].minor.yy344); } +{ yymsp[-8].minor.yy344 = createIndexOption(pCxt, yymsp[-6].minor.yy280, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), NULL, yymsp[0].minor.yy344); } break; case 98: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ -{ yymsp[-10].minor.yy344 = createIndexOption(pCxt, yymsp[-8].minor.yy280, yymsp[-4].minor.yy344, yymsp[-2].minor.yy344, yymsp[0].minor.yy344); } +{ yymsp[-10].minor.yy344 = createIndexOption(pCxt, yymsp[-8].minor.yy280, releaseRawExprNode(pCxt, yymsp[-4].minor.yy344), releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), yymsp[0].minor.yy344); } break; case 101: /* func ::= function_name NK_LP expression_list NK_RP */ { yylhsminor.yy344 = createFunctionNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy280); } diff --git a/source/libs/parser/test/parserAstTest.cpp b/source/libs/parser/test/parserAstTest.cpp index cf889c0f3c..119e94dde9 100644 --- a/source/libs/parser/test/parserAstTest.cpp +++ b/source/libs/parser/test/parserAstTest.cpp @@ -402,6 +402,6 @@ TEST_F(ParserTest, createTable) { TEST_F(ParserTest, createSmaIndex) { setDatabase("root", "test"); - bind("create sma index index1 on t1 function(max(c1), min(c3 + 10), sum(c4))"); + bind("create sma index index1 on t1 function(max(c1), min(c3 + 10), sum(c4)) INTERVAL(10s)"); ASSERT_TRUE(run()); } From 607a7ac025b432a3c2722f7cb075555ef4e4b31b Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Tue, 15 Mar 2022 19:54:06 +0800 Subject: [PATCH 04/37] handle except and update UT --- include/libs/transport/trpc.h | 12 +- source/libs/transport/inc/transComm.h | 7 +- source/libs/transport/inc/transportInt.h | 1 + source/libs/transport/src/trans.c | 1 + source/libs/transport/src/transCli.c | 32 +++-- source/libs/transport/src/transSrv.c | 4 +- source/libs/transport/test/transUT.cc | 157 +++++++++++++++++++---- 7 files changed, 167 insertions(+), 47 deletions(-) diff --git a/include/libs/transport/trpc.h b/include/libs/transport/trpc.h index 8dfd736df6..231bc4af45 100644 --- a/include/libs/transport/trpc.h +++ b/include/libs/transport/trpc.h @@ -29,7 +29,6 @@ extern "C" { extern int tsRpcHeadSize; - typedef struct SRpcConnInfo { uint32_t clientIp; uint16_t clientPort; @@ -46,7 +45,6 @@ typedef struct SRpcMsg { void * ahandle; // app handle set by client } SRpcMsg; - typedef struct SRpcInit { uint16_t localPort; // local port char * label; // for debug purpose @@ -71,9 +69,11 @@ typedef struct SRpcInit { // call back to keep conn or not bool (*pfp)(void *parent, tmsg_t msgType); - // to support Send messages multiple times on a link - // - void* (*mfp)(void *parent, tmsg_t msgType); + // to support Send messages multiple times on a link + void *(*mfp)(void *parent, tmsg_t msgType); + + // call back to handle except when query/fetch in progress + void (*efp)(void *parent, tmsg_t msgType); void *parent; } SRpcInit; @@ -94,7 +94,7 @@ int rpcReportProgress(void *pConn, char *pCont, int contLen); void rpcCancelRequest(int64_t rid); // just release client conn to rpc instance, no close sock -void rpcReleaseHandle(void *handle); +void rpcReleaseHandle(void *handle); void rpcRefHandle(void *handle, int8_t type); void rpcUnrefHandle(void *handle, int8_t type); diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index 99f890d3a0..76347cdba2 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -125,9 +125,8 @@ typedef SRpcInfo STrans; typedef SRpcConnInfo STransHandleInfo; typedef struct { - SEpSet epSet; // ip list provided by app - void* ahandle; // handle provided by app - // struct SRpcConn* pConn; // pConn allocated + SEpSet epSet; // ip list provided by app + void* ahandle; // handle provided by app tmsg_t msgType; // message type uint8_t* pCont; // content provided by app int32_t contLen; // content length @@ -135,7 +134,7 @@ typedef struct { // int16_t numOfTry; // number of try for different servers // int8_t oldInUse; // server EP inUse passed by app // int8_t redirect; // flag to indicate redirect - int8_t connType; // connection type + int8_t connType; // connection type cli/srv int64_t rid; // refId returned by taosAddRef STransMsg* pRsp; // for synchronous API diff --git a/source/libs/transport/inc/transportInt.h b/source/libs/transport/inc/transportInt.h index 3924a5cf1a..e760fe1de9 100644 --- a/source/libs/transport/inc/transportInt.h +++ b/source/libs/transport/inc/transportInt.h @@ -65,6 +65,7 @@ typedef struct { int (*afp)(void* parent, char* user, char* spi, char* encrypt, char* secret, char* ckey); bool (*pfp)(void* parent, tmsg_t msgType); void* (*mfp)(void* parent, tmsg_t msgType); + void (*efp)(void* parent, tmsg_t msgType); int32_t refCount; void* parent; diff --git a/source/libs/transport/src/trans.c b/source/libs/transport/src/trans.c index 58809ee3be..213782c5bd 100644 --- a/source/libs/transport/src/trans.c +++ b/source/libs/transport/src/trans.c @@ -36,6 +36,7 @@ void* rpcOpen(const SRpcInit* pInit) { pRpc->afp = pInit->afp; pRpc->pfp = pInit->pfp; pRpc->mfp = pInit->mfp; + pRpc->efp = pInit->efp; if (pInit->connType == TAOS_CONN_SERVER) { pRpc->numOfThreads = pInit->numOfThreads > TSDB_MAX_RPC_THREADS ? TSDB_MAX_RPC_THREADS : pInit->numOfThreads; diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 2f6ff3763f..5c50ca2bc3 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -34,6 +34,10 @@ typedef struct SCliConn { // spi configure char spi; char secured; + + char* ip; + uint32_t port; + // debug and log info struct sockaddr_in addr; struct sockaddr_in locaddr; @@ -79,7 +83,7 @@ typedef struct SConnList { static void* createConnPool(int size); static void* destroyConnPool(void* pool); static SCliConn* getConnFromPool(void* pool, char* ip, uint32_t port); -static void addConnToPool(void* pool, char* ip, uint32_t port, SCliConn* conn); +static void addConnToPool(void* pool, SCliConn* conn); // register timer in each thread to clear expire conn static void cliTimeoutCb(uv_timer_t* handle); @@ -188,6 +192,12 @@ void cliHandleResp(SCliConn* conn) { conn->secured = pHead->secured; + if (pCtx == NULL && CONN_NO_PERSIST_BY_APP(conn)) { + tTrace("except, server continue send while cli ignore it"); + // transUnrefCliHandle(conn); + return; + } + if (pCtx == NULL || pCtx->pSem == NULL) { tTrace("%s cli conn %p handle resp", pTransInst->label, conn); (pTransInst->cfp)(pTransInst->parent, &transMsg, NULL); @@ -197,14 +207,13 @@ void cliHandleResp(SCliConn* conn) { tsem_post(pCtx->pSem); } - uv_read_start((uv_stream_t*)conn->stream, cliAllocRecvBufferCb, cliRecvCb); - if (CONN_NO_PERSIST_BY_APP(conn)) { - addConnToPool(pThrd->pool, pCtx->ip, pCtx->port, conn); + addConnToPool(pThrd->pool, conn); } destroyCmsg(conn->data); conn->data = NULL; + uv_read_start((uv_stream_t*)conn->stream, cliAllocRecvBufferCb, cliRecvCb); // start thread's timer of conn pool if not active if (!uv_is_active((uv_handle_t*)&pThrd->timer) && pTransInst->idleTime > 0) { // uv_timer_start((uv_timer_t*)&pThrd->timer, cliTimeoutCb, CONN_PERSIST_TIME(pRpc->idleTime) / 2, 0); @@ -317,11 +326,11 @@ static SCliConn* getConnFromPool(void* pool, char* ip, uint32_t port) { QUEUE_INIT(&conn->conn); return conn; } -static void addConnToPool(void* pool, char* ip, uint32_t port, SCliConn* conn) { +static void addConnToPool(void* pool, SCliConn* conn) { char key[128] = {0}; - tstrncpy(key, ip, strlen(ip)); - tstrncpy(key + strlen(key), (char*)(&port), sizeof(port)); + tstrncpy(key, conn->ip, strlen(conn->ip)); + tstrncpy(key + strlen(key), (char*)(&conn->port), sizeof(conn->port)); tTrace("cli conn %p added to conn pool, read buf cap: %d", conn, conn->readBuf.cap); STrans* pTransInst = ((SCliThrdObj*)conn->hostThrd)->pTransInst; @@ -395,7 +404,7 @@ static void cliDestroyConn(SCliConn* conn, bool clear) { } static void cliDestroy(uv_handle_t* handle) { SCliConn* conn = handle->data; - + free(conn->ip); free(conn->stream); tTrace("%s cli conn %p destroy successfully", CONN_GET_INST_LABEL(conn), conn); free(conn); @@ -524,11 +533,16 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) { SCliConn* conn = cliGetConn(pMsg, pThrd); if (conn != NULL) { conn->data = pMsg; + conn->hThrdIdx = pCtx->hThrdIdx; + transDestroyBuffer(&conn->readBuf); cliSend(conn); } else { conn = cliCreateConn(pThrd); conn->data = pMsg; + conn->hThrdIdx = pCtx->hThrdIdx; + conn->ip = strdup(pMsg->ctx->ip); + conn->port = pMsg->ctx->port; int ret = transSetConnOption((uv_tcp_t*)conn->stream); if (ret) { @@ -540,8 +554,6 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) { tTrace("%s cli conn %p try to connect to %s:%d", pTransInst->label, conn, pMsg->ctx->ip, pMsg->ctx->port); uv_tcp_connect(&conn->connReq, (uv_tcp_t*)(conn->stream), (const struct sockaddr*)&addr, cliConnCb); } - - conn->hThrdIdx = pCtx->hThrdIdx; } static void cliAsyncCb(uv_async_t* handle) { SAsyncItem* item = handle->data; diff --git a/source/libs/transport/src/transSrv.c b/source/libs/transport/src/transSrv.c index cb3bbaefec..a3cc6b6181 100644 --- a/source/libs/transport/src/transSrv.c +++ b/source/libs/transport/src/transSrv.c @@ -289,11 +289,13 @@ void uvOnSendCb(uv_write_t* req, int status) { if (conn->srvMsgs != NULL) { assert(taosArrayGetSize(conn->srvMsgs) >= 1); SSrvMsg* msg = taosArrayGetP(conn->srvMsgs, 0); + tTrace("server conn %p sending msg size: %d", conn, (int)taosArrayGetSize(conn->srvMsgs)); taosArrayRemove(conn->srvMsgs, 0); destroySmsg(msg); // send second data, just use for push if (taosArrayGetSize(conn->srvMsgs) > 0) { + tTrace("resent server conn %p sending msg size: %d", conn, (int)taosArrayGetSize(conn->srvMsgs)); msg = (SSrvMsg*)taosArrayGetP(conn->srvMsgs, 0); uvStartSendRespInternal(msg); } @@ -733,7 +735,7 @@ void destroyWorkThrd(SWorkThrdObj* pThrd) { } void sendQuitToWorkThrd(SWorkThrdObj* pThrd) { SSrvMsg* srvMsg = calloc(1, sizeof(SSrvMsg)); - tDebug("send quit msg to work thread"); + tDebug("server send quit msg to work thread"); transSendAsync(pThrd->asyncPool, &srvMsg->q); } diff --git a/source/libs/transport/test/transUT.cc b/source/libs/transport/test/transUT.cc index fa20327003..b0fae2f8b4 100644 --- a/source/libs/transport/test/transUT.cc +++ b/source/libs/transport/test/transUT.cc @@ -29,7 +29,29 @@ const char *ckey = "ckey"; class Server; int port = 7000; // server process + +static bool cliPersistHandle(void *parent, tmsg_t msgType) { + // client persist handle + return msgType == 2 || msgType == 4; +} + +typedef struct CbArgs { + tmsg_t msgType; +} CbArgs; + +static void *ConstructArgForSpecificMsgType(void *parent, tmsg_t msgType) { + if (msgType == 1 || msgType == 2) { + CbArgs *args = (CbArgs *)calloc(1, sizeof(CbArgs)); + args->msgType = msgType; + return args; + } + return NULL; +} +// server except +static void NotifyAppLinkBroken(void *parent, tmsg_t msgType) {} typedef void (*CB)(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet); + +static void processContinueSend(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet); static void processReq(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet); // client process; static void processResp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet); @@ -61,17 +83,17 @@ class Client { rpcInit_.cfp = cb; this->transCli = rpcOpen(&rpcInit_); } - void setPersistFP(bool (*pfp)(void *parent, tmsg_t msgType)) { + void SetPersistFP(bool (*pfp)(void *parent, tmsg_t msgType)) { rpcClose(this->transCli); rpcInit_.pfp = pfp; this->transCli = rpcOpen(&rpcInit_); } - void setConstructFP(void *(*mfp)(void *parent, tmsg_t msgType)) { + void SetConstructFP(void *(*mfp)(void *parent, tmsg_t msgType)) { rpcClose(this->transCli); rpcInit_.mfp = mfp; this->transCli = rpcOpen(&rpcInit_); } - void setPAndMFp(bool (*pfp)(void *parent, tmsg_t msgType), void *(*mfp)(void *parent, tmsg_t msgType)) { + void SetPAndMFp(bool (*pfp)(void *parent, tmsg_t msgType), void *(*mfp)(void *parent, tmsg_t msgType)) { rpcClose(this->transCli); rpcInit_.pfp = pfp; @@ -88,6 +110,7 @@ class Client { SemWait(); *resp = this->resp; } + void SendWithHandle(SRpcMsg *req, SRpcMsg *resp) {} void SemWait() { tsem_wait(&this->sem); } void SemPost() { tsem_post(&this->sem); } void Reset() {} @@ -105,19 +128,20 @@ class Client { class Server { public: Server() { - memset(&rpcInit, 0, sizeof(rpcInit)); - rpcInit.localPort = port; - rpcInit.label = (char *)label; - rpcInit.numOfThreads = 5; - rpcInit.cfp = processReq; - rpcInit.user = (char *)user; - rpcInit.secret = (char *)secret; - rpcInit.ckey = (char *)ckey; - rpcInit.spi = 1; - rpcInit.connType = TAOS_CONN_SERVER; + memset(&rpcInit_, 0, sizeof(rpcInit_)); + rpcInit_.localPort = port; + rpcInit_.label = (char *)label; + rpcInit_.numOfThreads = 5; + rpcInit_.cfp = processReq; + rpcInit_.efp = NULL; + rpcInit_.user = (char *)user; + rpcInit_.secret = (char *)secret; + rpcInit_.ckey = (char *)ckey; + rpcInit_.spi = 1; + rpcInit_.connType = TAOS_CONN_SERVER; } void Start() { - this->transSrv = rpcOpen(&this->rpcInit); + this->transSrv = rpcOpen(&this->rpcInit_); taosMsleep(1000); } void Stop() { @@ -125,6 +149,16 @@ class Server { rpcClose(this->transSrv); this->transSrv = NULL; } + void SetExceptFp(void (*efp)(void *parent, tmsg_t msgType)) { + this->Stop(); + rpcInit_.efp = efp; + this->Start(); + } + void SetSrvContinueSend(void (*cfp)(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet)) { + this->Stop(); + rpcInit_.cfp = cfp; + this->Start(); + } void Restart() { this->Stop(); this->Start(); @@ -135,7 +169,7 @@ class Server { } private: - SRpcInit rpcInit; + SRpcInit rpcInit_; void * transSrv; }; static void processReq(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { @@ -146,6 +180,20 @@ static void processReq(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { rpcMsg.code = 0; rpcSendResponse(&rpcMsg); } + +static void processContinueSend(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { + for (int i = 0; i < 9; i++) { + rpcRefHandle(pMsg->handle, TAOS_CONN_SERVER); + } + for (int i = 0; i < 10; i++) { + SRpcMsg rpcMsg = {0}; + rpcMsg.pCont = rpcMallocCont(100); + rpcMsg.contLen = 100; + rpcMsg.handle = pMsg->handle; + rpcMsg.code = 0; + rpcSendResponse(&rpcMsg); + } +} // client process; static void processResp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { Client *client = (Client *)parent; @@ -170,7 +218,7 @@ static void initEnv() { tsAsyncLog = 0; std::string path = "/tmp/transport"; - taosRemoveDir(path.c_str()); + // taosRemoveDir(path.c_str()); taosMkDir(path.c_str()); tstrncpy(tsLogDir, path.c_str(), PATH_MAX); @@ -178,6 +226,7 @@ static void initEnv() { printf("failed to init log file\n"); } } + class TransObj { public: TransObj() { @@ -188,22 +237,38 @@ class TransObj { srv->Start(); } - void RestartCli(CB cb) { cli->Restart(cb); } - void StopSrv() { srv->Stop(); } + void RestartCli(CB cb) { + // + cli->Restart(cb); + } + void StopSrv() { + // + srv->Stop(); + } void SetCliPersistFp(bool (*pfp)(void *parent, tmsg_t msgType)) { // do nothing - cli->setPersistFP(pfp); + cli->SetPersistFP(pfp); } void SetCliMFp(void *(*mfp)(void *parent, tmsg_t msgType)) { // do nothing - cli->setConstructFP(mfp); + cli->SetConstructFP(mfp); } - void SetMAndPFp(bool (*pfp)(void *parent, tmsg_t msgType), void *(*mfp)(void *parent, tmsg_t msgType)) { + void SetCliMAndPFp(bool (*pfp)(void *parent, tmsg_t msgType), void *(*mfp)(void *parent, tmsg_t msgType)) { // do nothing - cli->setPAndMFp(pfp, mfp); + cli->SetPAndMFp(pfp, mfp); + } + // call when link broken, and notify query or fetch stop + void SetSrvExceptFp(void (*efp)(void *parent, tmsg_t msgType)) { + //////// + srv->SetExceptFp(efp); + } + void SetSrvContinueSend(void (*cfp)(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet)) { + /////// + srv->SetSrvContinueSend(cfp); } void RestartSrv() { srv->Restart(); } void cliSendAndRecv(SRpcMsg *req, SRpcMsg *resp) { cli->SendAndRecv(req, resp); } + ~TransObj() { delete cli; delete srv; @@ -256,13 +321,50 @@ TEST_F(TransEnv, 02StopServer) { tr->cliSendAndRecv(&req, &resp); assert(resp.code != 0); } -TEST_F(TransEnv, clientUserDefined) {} +TEST_F(TransEnv, clientUserDefined) { + tr->RestartSrv(); + for (int i = 0; i < 10; i++) { + SRpcMsg req = {0}, resp = {0}; + req.msgType = 0; + req.pCont = rpcMallocCont(10); + req.contLen = 10; + tr->cliSendAndRecv(&req, &resp); + assert(resp.code == 0); + } + + ////////////////// +} TEST_F(TransEnv, cliPersistHandle) { - // impl late + tr->SetCliPersistFp(cliPersistHandle); + SRpcMsg resp = {0}; + for (int i = 0; i < 10; i++) { + SRpcMsg req = {.handle = resp.handle}; + req.msgType = 1; + req.pCont = rpcMallocCont(10); + req.contLen = 10; + tr->cliSendAndRecv(&req, &resp); + if (i == 5) { + std::cout << "stop server" << std::endl; + tr->StopSrv(); + } + if (i >= 6) { + EXPECT_TRUE(resp.code != 0); + } + } + + ////////////////// } -TEST_F(TransEnv, srvPersistHandle) { - // impl later +TEST_F(TransEnv, srvContinueSend) { + tr->SetSrvContinueSend(processContinueSend); + for (int i = 0; i < 10; i++) { + SRpcMsg req = {0}, resp = {0}; + req.msgType = 1; + req.pCont = rpcMallocCont(10); + req.contLen = 10; + tr->cliSendAndRecv(&req, &resp); + } + taosMsleep(2000); } TEST_F(TransEnv, srvPersisHandleExcept) { @@ -282,3 +384,6 @@ TEST_F(TransEnv, multiSrvPersisHandleExcept) { TEST_F(TransEnv, queryExcept) { // query and conn is broken } +TEST_F(TransEnv, noResp) { + // no resp +} From bd60e92f298b08914c0bcd600854bf4da80eefbe Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Tue, 15 Mar 2022 20:04:19 +0800 Subject: [PATCH 05/37] add stream scheduler --- include/dnode/snode/snode.h | 3 - include/util/tdef.h | 23 ++++--- source/client/src/tmq.c | 2 +- source/dnode/mnode/impl/inc/mndDef.h | 14 +++- source/dnode/mnode/impl/src/mndScheduler.c | 79 +++++++++++++++++++++- source/dnode/snode/inc/sndInt.h | 8 +-- source/util/src/tuuid.c | 2 - 7 files changed, 106 insertions(+), 25 deletions(-) diff --git a/include/dnode/snode/snode.h b/include/dnode/snode/snode.h index 9dcd58a05f..21a93532e0 100644 --- a/include/dnode/snode/snode.h +++ b/include/dnode/snode/snode.h @@ -23,9 +23,6 @@ extern "C" { #endif -#define SND_UNIQUE_THREAD_NUM 2 -#define SND_SHARED_THREAD_NUM 2 - /* ------------------------ TYPES EXPOSED ------------------------ */ typedef struct SDnode SDnode; typedef struct SSnode SSnode; diff --git a/include/util/tdef.h b/include/util/tdef.h index a53b81894a..41a61ceb55 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -345,19 +345,19 @@ typedef enum ELogicConditionType { #define TSDB_MAX_DB_QUORUM_OPTION 2 #define TSDB_DEFAULT_DB_QUORUM_OPTION 1 -#define TSDB_MIN_DB_TTL_OPTION 1 -#define TSDB_DEFAULT_DB_TTL_OPTION 0 +#define TSDB_MIN_DB_TTL_OPTION 1 +#define TSDB_DEFAULT_DB_TTL_OPTION 0 -#define TSDB_MIN_DB_SINGLE_STABLE_OPTION 0 -#define TSDB_MAX_DB_SINGLE_STABLE_OPTION 1 -#define TSDB_DEFAULT_DB_SINGLE_STABLE_OPTION 0 +#define TSDB_MIN_DB_SINGLE_STABLE_OPTION 0 +#define TSDB_MAX_DB_SINGLE_STABLE_OPTION 1 +#define TSDB_DEFAULT_DB_SINGLE_STABLE_OPTION 0 -#define TSDB_MIN_DB_STREAM_MODE_OPTION 0 -#define TSDB_MAX_DB_STREAM_MODE_OPTION 1 -#define TSDB_DEFAULT_DB_STREAM_MODE_OPTION 0 +#define TSDB_MIN_DB_STREAM_MODE_OPTION 0 +#define TSDB_MAX_DB_STREAM_MODE_OPTION 1 +#define TSDB_DEFAULT_DB_STREAM_MODE_OPTION 0 -#define TSDB_MAX_JOIN_TABLE_NUM 10 -#define TSDB_MAX_UNION_CLAUSE 5 +#define TSDB_MAX_JOIN_TABLE_NUM 10 +#define TSDB_MAX_UNION_CLAUSE 5 #define TSDB_MIN_DB_UPDATE 0 #define TSDB_MAX_DB_UPDATE 2 @@ -445,6 +445,9 @@ typedef struct { #define TMQ_SEPARATOR ':' +#define SND_UNIQUE_THREAD_NUM 2 +#define SND_SHARED_THREAD_NUM 2 + #ifdef __cplusplus } #endif diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index 846329f0f4..2e2c44951e 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -459,7 +459,7 @@ void tmq_conf_set_offset_commit_cb(tmq_conf_t* conf, tmq_commit_cb* cb) { conf-> TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, int sqlLen) { STscObj* pTscObj = (STscObj*)taos; SRequestObj* pRequest = NULL; - SQuery* pQueryNode = NULL; + SQuery* pQueryNode = NULL; char* pStr = NULL; terrno = TSDB_CODE_SUCCESS; diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 9ed6104140..a7116b72ff 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -679,6 +679,12 @@ static FORCE_INLINE void* tDecodeSMqConsumerObj(void* buf, SMqConsumerObj* pCons return buf; } +typedef struct { + int32_t taskId; + int32_t level; + SSubplan* plan; +} SStreamTaskMeta; + typedef struct { char name[TSDB_TOPIC_FNAME_LEN]; char db[TSDB_DB_FNAME_LEN]; @@ -687,12 +693,14 @@ typedef struct { int64_t uid; int64_t dbUid; int32_t version; + int32_t vgNum; SRWLatch lock; int8_t status; // int32_t sqlLen; - char* sql; - char* logicalPlan; - char* physicalPlan; + char* sql; + char* logicalPlan; + char* physicalPlan; + SArray* tasks; // SArray> } SStreamObj; int32_t tEncodeSStreamObj(SCoder* pEncoder, const SStreamObj* pObj); diff --git a/source/dnode/mnode/impl/src/mndScheduler.c b/source/dnode/mnode/impl/src/mndScheduler.c index e827810cc9..855e244daa 100644 --- a/source/dnode/mnode/impl/src/mndScheduler.c +++ b/source/dnode/mnode/impl/src/mndScheduler.c @@ -21,6 +21,7 @@ #include "mndOffset.h" #include "mndShow.h" #include "mndStb.h" +#include "mndStream.h" #include "mndSubscribe.h" #include "mndTopic.h" #include "mndTrans.h" @@ -28,10 +29,84 @@ #include "mndVgroup.h" #include "tcompare.h" #include "tname.h" +#include "tuuid.h" + +int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) { + SSdb* pSdb = pMnode->pSdb; + SVgObj* pVgroup = NULL; + SQueryPlan* pPlan = qStringToQueryPlan(pStream->physicalPlan); + if (pPlan == NULL) { + terrno = TSDB_CODE_QRY_INVALID_INPUT; + return -1; + } + ASSERT(pStream->vgNum == 0); + + int32_t levelNum = LIST_LENGTH(pPlan->pSubplans); + pStream->tasks = taosArrayInit(levelNum, sizeof(SArray)); + + for (int32_t i = 0; i < levelNum; i++) { + SArray* taskOneLevel = taosArrayInit(0, sizeof(SStreamTaskMeta)); + SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, i); + int32_t opNum = LIST_LENGTH(inner->pNodeList); + ASSERT(opNum == 1); + + SSubplan* plan = nodesListGetNode(inner->pNodeList, 0); + if (i == 0) { + ASSERT(plan->type == SUBPLAN_TYPE_SCAN); + void* pIter = NULL; + while (1) { + pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void**)&pVgroup); + if (pIter == NULL) break; + if (pVgroup->dbUid != pStream->dbUid) { + sdbRelease(pSdb, pVgroup); + continue; + } + + pStream->vgNum++; + plan->execNode.nodeId = pVgroup->vgId; + plan->execNode.epSet = mndGetVgroupEpset(pMnode, pVgroup); + SStreamTaskMeta task = { + .taskId = tGenIdPI32(), + .level = i, + .plan = plan, + }; + // send to vnode + taosArrayPush(taskOneLevel, &task); + } + } else if (plan->subplanType == SUBPLAN_TYPE_SCAN) { + // duplicatable + + int32_t parallel = 0; + // if no snode, parallel set to fetch thread num in vnode + + // if has snode, set to shared thread num in snode + parallel = SND_SHARED_THREAD_NUM; + + for (int32_t j = 0; j < parallel; j++) { + SStreamTaskMeta task = { + .taskId = tGenIdPI32(), + .level = i, + .plan = plan, + }; + taosArrayPush(taskOneLevel, &task); + } + } else { + // not duplicatable + SStreamTaskMeta task = { + .taskId = tGenIdPI32(), + .level = i, + .plan = plan, + }; + taosArrayPush(taskOneLevel, &task); + } + taosArrayPush(pStream->tasks, taskOneLevel); + } + return 0; +} int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscribeObj* pSub) { - SSdb* pSdb = pMnode->pSdb; - SVgObj* pVgroup = NULL; + SSdb* pSdb = pMnode->pSdb; + SVgObj* pVgroup = NULL; SQueryPlan* pPlan = qStringToQueryPlan(pTopic->physicalPlan); if (pPlan == NULL) { terrno = TSDB_CODE_QRY_INVALID_INPUT; diff --git a/source/dnode/snode/inc/sndInt.h b/source/dnode/snode/inc/sndInt.h index ffe691aeb4..3fe816845d 100644 --- a/source/dnode/snode/inc/sndInt.h +++ b/source/dnode/snode/inc/sndInt.h @@ -67,11 +67,11 @@ typedef struct { // storage handle } SStreamTask; -int32_t sndCreateStream(); -int32_t sndDropStream(); +int32_t sndCreateTask(); +int32_t sndDropTaskOfStream(int64_t streamId); -int32_t sndStopStream(); -int32_t sndResumeStream(); +int32_t sndStopTaskOfStream(int64_t streamId); +int32_t sndResumeTaskOfStream(int64_t streamId); #ifdef __cplusplus } diff --git a/source/util/src/tuuid.c b/source/util/src/tuuid.c index 0405403220..ceca33436a 100644 --- a/source/util/src/tuuid.c +++ b/source/util/src/tuuid.c @@ -24,7 +24,6 @@ int32_t tGenIdPI32(void) { int32_t code = taosGetSystemUUID(uid, tListLen(uid)); if (code != TSDB_CODE_SUCCESS) { terrno = TAOS_SYSTEM_ERROR(errno); - return -1; } else { hashId = MurmurHash3_32(uid, strlen(uid)); } @@ -44,7 +43,6 @@ int64_t tGenIdPI64(void) { int32_t code = taosGetSystemUUID(uid, tListLen(uid)); if (code != TSDB_CODE_SUCCESS) { terrno = TAOS_SYSTEM_ERROR(errno); - return -1; } else { hashId = MurmurHash3_32(uid, strlen(uid)); } From 4281664e03eafd364ec4ffd91ee163c3cea9495b Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Tue, 15 Mar 2022 08:04:52 -0400 Subject: [PATCH 06/37] TD-14068 create qnode implement --- include/common/ttokendef.h | 212 +- include/libs/nodes/cmdnodes.h | 5 + include/libs/nodes/nodes.h | 2 + source/libs/nodes/src/nodesUtilFuncs.c | 3 + source/libs/parser/inc/parAst.h | 1 + source/libs/parser/inc/sql.y | 4 + source/libs/parser/src/parAstCreater.c | 7 + source/libs/parser/src/parTokenizer.c | 2 + source/libs/parser/src/parTranslater.c | 27 +- source/libs/parser/src/sql.c | 3177 +++++++++++---------- source/libs/parser/test/parserAstTest.cpp | 7 + 11 files changed, 1753 insertions(+), 1694 deletions(-) diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 6745b80ac0..5693091bd5 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -48,111 +48,113 @@ #define TK_DNODES 30 #define TK_NK_ID 31 #define TK_NK_IPTOKEN 32 -#define TK_DATABASE 33 -#define TK_DATABASES 34 -#define TK_USE 35 -#define TK_IF 36 -#define TK_NOT 37 -#define TK_EXISTS 38 -#define TK_BLOCKS 39 -#define TK_CACHE 40 -#define TK_CACHELAST 41 -#define TK_COMP 42 -#define TK_DAYS 43 -#define TK_FSYNC 44 -#define TK_MAXROWS 45 -#define TK_MINROWS 46 -#define TK_KEEP 47 -#define TK_PRECISION 48 -#define TK_QUORUM 49 -#define TK_REPLICA 50 -#define TK_TTL 51 -#define TK_WAL 52 -#define TK_VGROUPS 53 -#define TK_SINGLE_STABLE 54 -#define TK_STREAM_MODE 55 -#define TK_TABLE 56 -#define TK_NK_LP 57 -#define TK_NK_RP 58 -#define TK_STABLE 59 -#define TK_TABLES 60 -#define TK_STABLES 61 -#define TK_USING 62 -#define TK_TAGS 63 -#define TK_NK_DOT 64 -#define TK_NK_COMMA 65 -#define TK_COMMENT 66 -#define TK_BOOL 67 -#define TK_TINYINT 68 -#define TK_SMALLINT 69 -#define TK_INT 70 -#define TK_INTEGER 71 -#define TK_BIGINT 72 -#define TK_FLOAT 73 -#define TK_DOUBLE 74 -#define TK_BINARY 75 -#define TK_TIMESTAMP 76 -#define TK_NCHAR 77 -#define TK_UNSIGNED 78 -#define TK_JSON 79 -#define TK_VARCHAR 80 -#define TK_MEDIUMBLOB 81 -#define TK_BLOB 82 -#define TK_VARBINARY 83 -#define TK_DECIMAL 84 -#define TK_SMA 85 -#define TK_INDEX 86 -#define TK_ON 87 -#define TK_FULLTEXT 88 -#define TK_FUNCTION 89 -#define TK_INTERVAL 90 -#define TK_MNODES 91 -#define TK_NK_FLOAT 92 -#define TK_NK_BOOL 93 -#define TK_NK_VARIABLE 94 -#define TK_BETWEEN 95 -#define TK_IS 96 -#define TK_NULL 97 -#define TK_NK_LT 98 -#define TK_NK_GT 99 -#define TK_NK_LE 100 -#define TK_NK_GE 101 -#define TK_NK_NE 102 -#define TK_NK_EQ 103 -#define TK_LIKE 104 -#define TK_MATCH 105 -#define TK_NMATCH 106 -#define TK_IN 107 -#define TK_FROM 108 -#define TK_AS 109 -#define TK_JOIN 110 -#define TK_INNER 111 -#define TK_SELECT 112 -#define TK_DISTINCT 113 -#define TK_WHERE 114 -#define TK_PARTITION 115 -#define TK_BY 116 -#define TK_SESSION 117 -#define TK_STATE_WINDOW 118 -#define TK_SLIDING 119 -#define TK_FILL 120 -#define TK_VALUE 121 -#define TK_NONE 122 -#define TK_PREV 123 -#define TK_LINEAR 124 -#define TK_NEXT 125 -#define TK_GROUP 126 -#define TK_HAVING 127 -#define TK_ORDER 128 -#define TK_SLIMIT 129 -#define TK_SOFFSET 130 -#define TK_LIMIT 131 -#define TK_OFFSET 132 -#define TK_ASC 133 -#define TK_DESC 134 -#define TK_NULLS 135 -#define TK_FIRST 136 -#define TK_LAST 137 +#define TK_QNODE 33 +#define TK_ON 34 +#define TK_QNODES 35 +#define TK_DATABASE 36 +#define TK_DATABASES 37 +#define TK_USE 38 +#define TK_IF 39 +#define TK_NOT 40 +#define TK_EXISTS 41 +#define TK_BLOCKS 42 +#define TK_CACHE 43 +#define TK_CACHELAST 44 +#define TK_COMP 45 +#define TK_DAYS 46 +#define TK_FSYNC 47 +#define TK_MAXROWS 48 +#define TK_MINROWS 49 +#define TK_KEEP 50 +#define TK_PRECISION 51 +#define TK_QUORUM 52 +#define TK_REPLICA 53 +#define TK_TTL 54 +#define TK_WAL 55 +#define TK_VGROUPS 56 +#define TK_SINGLE_STABLE 57 +#define TK_STREAM_MODE 58 +#define TK_TABLE 59 +#define TK_NK_LP 60 +#define TK_NK_RP 61 +#define TK_STABLE 62 +#define TK_TABLES 63 +#define TK_STABLES 64 +#define TK_USING 65 +#define TK_TAGS 66 +#define TK_NK_DOT 67 +#define TK_NK_COMMA 68 +#define TK_COMMENT 69 +#define TK_BOOL 70 +#define TK_TINYINT 71 +#define TK_SMALLINT 72 +#define TK_INT 73 +#define TK_INTEGER 74 +#define TK_BIGINT 75 +#define TK_FLOAT 76 +#define TK_DOUBLE 77 +#define TK_BINARY 78 +#define TK_TIMESTAMP 79 +#define TK_NCHAR 80 +#define TK_UNSIGNED 81 +#define TK_JSON 82 +#define TK_VARCHAR 83 +#define TK_MEDIUMBLOB 84 +#define TK_BLOB 85 +#define TK_VARBINARY 86 +#define TK_DECIMAL 87 +#define TK_SMA 88 +#define TK_INDEX 89 +#define TK_FULLTEXT 90 +#define TK_FUNCTION 91 +#define TK_INTERVAL 92 +#define TK_MNODES 93 +#define TK_NK_FLOAT 94 +#define TK_NK_BOOL 95 +#define TK_NK_VARIABLE 96 +#define TK_BETWEEN 97 +#define TK_IS 98 +#define TK_NULL 99 +#define TK_NK_LT 100 +#define TK_NK_GT 101 +#define TK_NK_LE 102 +#define TK_NK_GE 103 +#define TK_NK_NE 104 +#define TK_NK_EQ 105 +#define TK_LIKE 106 +#define TK_MATCH 107 +#define TK_NMATCH 108 +#define TK_IN 109 +#define TK_FROM 110 +#define TK_AS 111 +#define TK_JOIN 112 +#define TK_INNER 113 +#define TK_SELECT 114 +#define TK_DISTINCT 115 +#define TK_WHERE 116 +#define TK_PARTITION 117 +#define TK_BY 118 +#define TK_SESSION 119 +#define TK_STATE_WINDOW 120 +#define TK_SLIDING 121 +#define TK_FILL 122 +#define TK_VALUE 123 +#define TK_NONE 124 +#define TK_PREV 125 +#define TK_LINEAR 126 +#define TK_NEXT 127 +#define TK_GROUP 128 +#define TK_HAVING 129 +#define TK_ORDER 130 +#define TK_SLIMIT 131 +#define TK_SOFFSET 132 +#define TK_LIMIT 133 +#define TK_OFFSET 134 +#define TK_ASC 135 +#define TK_DESC 136 +#define TK_NULLS 137 +#define TK_FIRST 138 +#define TK_LAST 139 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index aa539667e4..21d9ff83c8 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -179,6 +179,11 @@ typedef struct SCreateIndexStmt { SIndexOptions* pOptions; } SCreateIndexStmt; +typedef struct SCreateQnodeStmt { + ENodeType type; + int32_t dnodeId; +} SCreateQnodeStmt; + #ifdef __cplusplus } #endif diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 46b89416b7..cf34c6665a 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -96,7 +96,9 @@ typedef enum ENodeType { QUERY_NODE_SHOW_DNODES_STMT, QUERY_NODE_SHOW_VGROUPS_STMT, QUERY_NODE_SHOW_MNODES_STMT, + QUERY_NODE_SHOW_QNODES_STMT, QUERY_NODE_CREATE_INDEX_STMT, + QUERY_NODE_CREATE_QNODE_STMT, // logic plan node QUERY_NODE_LOGIC_PLAN_SCAN, diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 43caa25c3d..b17a4904da 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -127,9 +127,12 @@ SNodeptr nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SShowStmt)); case QUERY_NODE_SHOW_VGROUPS_STMT: case QUERY_NODE_SHOW_MNODES_STMT: + case QUERY_NODE_SHOW_QNODES_STMT: return makeNode(type, sizeof(SShowStmt)); case QUERY_NODE_CREATE_INDEX_STMT: return makeNode(type, sizeof(SCreateIndexStmt)); + case QUERY_NODE_CREATE_QNODE_STMT: + return makeNode(type, sizeof(SCreateQnodeStmt)); case QUERY_NODE_LOGIC_PLAN_SCAN: return makeNode(type, sizeof(SScanLogicNode)); case QUERY_NODE_LOGIC_PLAN_JOIN: diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index bb22e5703d..f2fcced1a9 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -134,6 +134,7 @@ SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode); SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, const SToken* pIndexName, const SToken* pTableName, SNodeList* pCols, SNode* pOptions); SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding); +SNode* createCreateQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId); #ifdef __cplusplus } diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index a9fb0a9f5e..af2fb12c52 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -64,6 +64,10 @@ dnode_endpoint(A) ::= NK_STRING(B). dnode_host_name(A) ::= NK_ID(B). { A = B; } dnode_host_name(A) ::= NK_IPTOKEN(B). { A = B; } +/************************************************ create qnode ********************************************************/ +cmd ::= CREATE QNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createCreateQnodeStmt(pCxt, &A); } +cmd ::= SHOW QNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT, NULL); } + /************************************************ create/drop/show/use database ***************************************/ cmd ::= CREATE DATABASE not_exists_opt(A) db_name(B) db_options(C). { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, A, &B, C);} cmd ::= DROP DATABASE exists_opt(A) db_name(B). { pCxt->pRootNode = createDropDatabaseStmt(pCxt, A, &B); } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 994ca53a0f..b7ecf160fd 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -1021,3 +1021,10 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt pOptions->pSliding = pSliding; return (SNode*)pOptions; } + +SNode* createCreateQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId) { + SCreateQnodeStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_QNODE_STMT); + CHECK_OUT_OF_MEM(pStmt); + pStmt->dnodeId = strtol(pDnodeId->z, NULL, 10);; + return (SNode*)pStmt; +} diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 57ff6d53a4..4d50d92d9e 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -99,6 +99,8 @@ static SKeyword keywordTable[] = { {"PRECISION", TK_PRECISION}, {"PRIVILEGE", TK_PRIVILEGE}, {"PREV", TK_PREV}, + {"QNODE", TK_QNODE}, + {"QNODES", TK_QNODES}, {"QUORUM", TK_QUORUM}, {"REPLICA", TK_REPLICA}, {"SELECT", TK_SELECT}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index dbba590620..4f89e7e703 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -1077,6 +1077,8 @@ static int32_t nodeTypeToShowType(ENodeType nt) { return TSDB_MGMT_TABLE_VGROUP; case QUERY_NODE_SHOW_MNODES_STMT: return TSDB_MGMT_TABLE_MNODE; + case QUERY_NODE_SHOW_QNODES_STMT: + return TSDB_MGMT_TABLE_QNODE; default: break; } @@ -1185,7 +1187,7 @@ static int32_t translateCreateSmaIndex(STranslateContext* pCxt, SCreateIndexStmt } void* pBuf = pCxt->pCmdMsg->pMsg; tSerializeSVCreateTSmaReq(&pBuf, &createSmaReq); - // todo clear SVCreateTSmaReq + tdDestroyTSma(&createSmaReq.tSma); return TSDB_CODE_SUCCESS; } @@ -1199,6 +1201,25 @@ static int32_t translateCreateIndex(STranslateContext* pCxt, SCreateIndexStmt* p } } +static int32_t translateCreateQnode(STranslateContext* pCxt, SCreateQnodeStmt* pStmt) { + SMCreateQnodeReq createReq = { .dnodeId = pStmt->dnodeId }; + + pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); + if (NULL == pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_DND_CREATE_QNODE; + pCxt->pCmdMsg->msgLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &createReq); + pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); + if (NULL == pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + tSerializeSMCreateDropQSBNodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq); + + return TSDB_CODE_SUCCESS; +} + static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pNode)) { @@ -1244,6 +1265,7 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_SHOW_DNODES_STMT: case QUERY_NODE_SHOW_VGROUPS_STMT: case QUERY_NODE_SHOW_MNODES_STMT: + case QUERY_NODE_SHOW_QNODES_STMT: code = translateShow(pCxt, (SShowStmt*)pNode); break; case QUERY_NODE_SHOW_TABLES_STMT: @@ -1252,6 +1274,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_CREATE_INDEX_STMT: code = translateCreateIndex(pCxt, (SCreateIndexStmt*)pNode); break; + case QUERY_NODE_CREATE_QNODE_STMT: + code = translateCreateQnode(pCxt, (SCreateQnodeStmt*)pNode); + break; default: break; } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index c135d59298..8b46d3600b 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -99,22 +99,22 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned char -#define YYNOCODE 216 +#define YYNOCODE 218 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - EOrder yy2; - EJoinType yy36; - SToken yy209; - ENullOrder yy217; - EOperatorType yy236; - SNodeList* yy280; - bool yy281; - SDataType yy304; - EFillMode yy342; - SNode* yy344; + SToken yy5; + bool yy25; + SNodeList* yy40; + ENullOrder yy53; + EOrder yy54; + SNode* yy68; + EJoinType yy92; + EFillMode yy94; + SDataType yy372; + EOperatorType yy416; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -129,17 +129,17 @@ typedef union { #define ParseCTX_PARAM #define ParseCTX_FETCH #define ParseCTX_STORE -#define YYNSTATE 308 -#define YYNRULE 246 -#define YYNTOKEN 138 -#define YY_MAX_SHIFT 307 -#define YY_MIN_SHIFTREDUCE 475 -#define YY_MAX_SHIFTREDUCE 720 -#define YY_ERROR_ACTION 721 -#define YY_ACCEPT_ACTION 722 -#define YY_NO_ACTION 723 -#define YY_MIN_REDUCE 724 -#define YY_MAX_REDUCE 969 +#define YYNSTATE 313 +#define YYNRULE 248 +#define YYNTOKEN 140 +#define YY_MAX_SHIFT 312 +#define YY_MIN_SHIFTREDUCE 480 +#define YY_MAX_SHIFTREDUCE 727 +#define YY_ERROR_ACTION 728 +#define YY_ACCEPT_ACTION 729 +#define YY_NO_ACTION 730 +#define YY_MIN_REDUCE 731 +#define YY_MAX_REDUCE 978 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -206,318 +206,307 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (1037) +#define YY_ACTTAB_COUNT (963) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 152, 235, 276, 862, 835, 251, 251, 167, 185, 775, - /* 10 */ 838, 835, 31, 29, 27, 26, 25, 837, 835, 208, - /* 20 */ 778, 778, 165, 178, 837, 31, 29, 27, 26, 25, - /* 30 */ 737, 39, 9, 8, 780, 70, 151, 145, 61, 817, - /* 40 */ 250, 815, 773, 235, 251, 862, 235, 248, 862, 164, - /* 50 */ 145, 835, 823, 238, 237, 24, 109, 847, 603, 778, - /* 60 */ 58, 848, 851, 887, 212, 662, 10, 886, 883, 300, - /* 70 */ 299, 298, 297, 296, 295, 294, 293, 292, 291, 290, - /* 80 */ 289, 288, 287, 286, 285, 284, 304, 303, 250, 639, - /* 90 */ 31, 29, 27, 26, 25, 23, 159, 592, 621, 622, - /* 100 */ 623, 624, 625, 626, 627, 629, 630, 631, 23, 159, - /* 110 */ 186, 621, 622, 623, 624, 625, 626, 627, 629, 630, - /* 120 */ 631, 31, 29, 27, 26, 25, 535, 274, 273, 272, - /* 130 */ 539, 271, 541, 542, 270, 544, 267, 20, 550, 264, - /* 140 */ 552, 553, 261, 258, 235, 87, 862, 31, 29, 27, - /* 150 */ 26, 25, 835, 75, 766, 237, 213, 223, 847, 86, - /* 160 */ 82, 56, 848, 851, 887, 54, 948, 603, 144, 883, - /* 170 */ 250, 130, 219, 65, 661, 195, 770, 134, 71, 947, - /* 180 */ 948, 593, 40, 946, 222, 84, 862, 64, 83, 764, - /* 190 */ 186, 583, 835, 81, 39, 237, 10, 946, 847, 581, - /* 200 */ 223, 57, 848, 851, 887, 774, 62, 207, 154, 883, - /* 210 */ 76, 716, 717, 27, 26, 25, 102, 894, 218, 485, - /* 220 */ 217, 166, 105, 948, 817, 283, 815, 189, 200, 914, - /* 230 */ 222, 125, 862, 283, 214, 209, 81, 594, 835, 60, - /* 240 */ 946, 237, 485, 277, 847, 124, 252, 57, 848, 851, - /* 250 */ 887, 82, 486, 487, 154, 883, 76, 251, 226, 235, - /* 260 */ 249, 862, 582, 584, 587, 82, 251, 835, 55, 122, - /* 270 */ 237, 120, 778, 847, 106, 915, 57, 848, 851, 887, - /* 280 */ 169, 778, 205, 154, 883, 960, 99, 235, 251, 862, - /* 290 */ 722, 172, 780, 70, 921, 835, 171, 247, 237, 127, - /* 300 */ 199, 847, 808, 778, 57, 848, 851, 887, 780, 70, - /* 310 */ 595, 154, 883, 960, 48, 104, 235, 188, 862, 21, - /* 320 */ 30, 28, 944, 173, 835, 771, 220, 237, 628, 583, - /* 330 */ 847, 632, 230, 57, 848, 851, 887, 581, 765, 161, - /* 340 */ 154, 883, 960, 6, 901, 12, 948, 30, 28, 663, - /* 350 */ 170, 905, 901, 817, 863, 815, 583, 917, 901, 81, - /* 360 */ 235, 898, 862, 946, 581, 1, 161, 658, 835, 897, - /* 370 */ 234, 237, 12, 223, 847, 896, 670, 133, 848, 851, - /* 380 */ 227, 824, 238, 225, 252, 280, 30, 28, 91, 279, - /* 390 */ 781, 70, 1, 592, 108, 583, 948, 30, 28, 231, - /* 400 */ 582, 584, 587, 581, 281, 161, 583, 174, 817, 81, - /* 410 */ 816, 252, 194, 946, 581, 192, 161, 906, 658, 196, - /* 420 */ 82, 2, 12, 278, 590, 684, 68, 582, 584, 587, - /* 430 */ 618, 7, 59, 96, 633, 235, 763, 862, 9, 8, - /* 440 */ 94, 32, 1, 835, 600, 228, 237, 719, 720, 847, - /* 450 */ 252, 32, 58, 848, 851, 887, 30, 28, 236, 233, - /* 460 */ 883, 252, 842, 30, 28, 583, 582, 584, 587, 840, - /* 470 */ 38, 53, 583, 581, 576, 161, 50, 582, 584, 587, - /* 480 */ 581, 32, 161, 280, 187, 85, 82, 279, 30, 28, - /* 490 */ 190, 184, 235, 596, 862, 183, 590, 583, 150, 182, - /* 500 */ 835, 7, 281, 237, 197, 581, 847, 161, 7, 72, - /* 510 */ 848, 851, 114, 591, 206, 219, 243, 119, 179, 112, - /* 520 */ 252, 278, 528, 66, 67, 181, 180, 252, 523, 68, - /* 530 */ 64, 597, 556, 1, 198, 59, 582, 584, 587, 256, - /* 540 */ 595, 560, 918, 582, 584, 587, 224, 961, 67, 62, - /* 550 */ 565, 928, 252, 241, 92, 69, 175, 68, 221, 77, - /* 560 */ 894, 895, 67, 899, 235, 587, 862, 203, 582, 584, - /* 570 */ 587, 95, 835, 927, 153, 237, 5, 98, 847, 908, - /* 580 */ 74, 58, 848, 851, 887, 100, 235, 687, 862, 884, - /* 590 */ 202, 4, 216, 63, 835, 658, 594, 237, 160, 902, - /* 600 */ 847, 945, 33, 138, 848, 851, 101, 155, 235, 232, - /* 610 */ 862, 204, 685, 686, 688, 689, 835, 963, 229, 237, - /* 620 */ 201, 107, 847, 17, 869, 138, 848, 851, 822, 239, - /* 630 */ 244, 235, 126, 862, 240, 49, 821, 47, 123, 835, - /* 640 */ 307, 254, 237, 245, 116, 847, 163, 128, 137, 848, - /* 650 */ 851, 235, 142, 862, 246, 129, 779, 143, 829, 835, - /* 660 */ 176, 177, 237, 740, 235, 847, 862, 828, 72, 848, - /* 670 */ 851, 827, 835, 494, 738, 237, 158, 191, 847, 215, - /* 680 */ 826, 138, 848, 851, 769, 768, 235, 739, 862, 31, - /* 690 */ 29, 27, 26, 25, 835, 88, 193, 237, 162, 733, - /* 700 */ 847, 728, 767, 138, 848, 851, 962, 732, 731, 727, - /* 710 */ 726, 235, 219, 862, 725, 819, 41, 89, 90, 835, - /* 720 */ 3, 14, 237, 93, 683, 847, 32, 64, 136, 848, - /* 730 */ 851, 235, 210, 862, 36, 73, 97, 211, 42, 835, - /* 740 */ 677, 676, 237, 43, 15, 847, 62, 34, 139, 848, - /* 750 */ 851, 655, 840, 235, 19, 862, 78, 894, 895, 35, - /* 760 */ 899, 835, 654, 16, 237, 11, 705, 847, 44, 103, - /* 770 */ 131, 848, 851, 704, 710, 235, 80, 862, 156, 709, - /* 780 */ 708, 157, 8, 835, 601, 110, 237, 619, 13, 847, - /* 790 */ 18, 113, 140, 848, 851, 818, 111, 681, 235, 115, - /* 800 */ 862, 242, 45, 46, 117, 118, 835, 839, 585, 237, - /* 810 */ 50, 121, 847, 37, 255, 132, 848, 851, 235, 557, - /* 820 */ 862, 253, 168, 257, 534, 554, 835, 259, 260, 237, - /* 830 */ 551, 235, 847, 862, 262, 141, 848, 851, 263, 835, - /* 840 */ 545, 265, 237, 266, 268, 847, 543, 269, 859, 848, - /* 850 */ 851, 549, 548, 235, 547, 862, 546, 275, 51, 52, - /* 860 */ 564, 835, 563, 562, 237, 506, 492, 847, 513, 512, - /* 870 */ 858, 848, 851, 282, 511, 510, 509, 508, 235, 507, - /* 880 */ 862, 505, 504, 503, 502, 501, 835, 500, 499, 237, - /* 890 */ 498, 497, 847, 730, 301, 857, 848, 851, 235, 302, - /* 900 */ 862, 729, 724, 305, 306, 723, 835, 723, 723, 237, - /* 910 */ 723, 723, 847, 723, 723, 148, 848, 851, 723, 723, - /* 920 */ 235, 723, 862, 723, 723, 723, 723, 723, 835, 723, - /* 930 */ 723, 237, 723, 723, 847, 723, 723, 147, 848, 851, - /* 940 */ 723, 723, 235, 723, 862, 723, 723, 723, 723, 723, - /* 950 */ 835, 723, 723, 237, 723, 723, 847, 723, 723, 149, - /* 960 */ 848, 851, 723, 723, 723, 235, 723, 862, 723, 723, - /* 970 */ 723, 723, 723, 835, 723, 219, 237, 723, 723, 847, - /* 980 */ 723, 723, 146, 848, 851, 235, 723, 862, 723, 723, - /* 990 */ 64, 723, 723, 835, 723, 723, 237, 723, 723, 847, - /* 1000 */ 723, 723, 135, 848, 851, 723, 723, 723, 723, 62, - /* 1010 */ 723, 723, 723, 723, 723, 723, 723, 723, 723, 79, - /* 1020 */ 894, 895, 22, 899, 723, 723, 723, 723, 723, 723, - /* 1030 */ 723, 723, 31, 29, 27, 26, 25, + /* 0 */ 152, 236, 277, 871, 844, 252, 252, 167, 186, 784, + /* 10 */ 847, 844, 31, 29, 27, 26, 25, 846, 844, 209, + /* 20 */ 787, 787, 309, 308, 846, 31, 29, 27, 26, 25, + /* 30 */ 746, 236, 151, 871, 106, 826, 39, 824, 251, 844, + /* 40 */ 145, 957, 238, 61, 236, 856, 871, 782, 57, 857, + /* 50 */ 860, 896, 910, 145, 956, 154, 892, 969, 955, 187, + /* 60 */ 164, 610, 213, 832, 239, 166, 930, 10, 826, 907, + /* 70 */ 824, 251, 301, 300, 299, 298, 297, 296, 295, 294, + /* 80 */ 293, 292, 291, 290, 289, 288, 287, 286, 285, 599, + /* 90 */ 31, 29, 27, 26, 25, 24, 109, 23, 159, 228, + /* 100 */ 628, 629, 630, 631, 632, 633, 634, 636, 637, 638, + /* 110 */ 23, 159, 39, 628, 629, 630, 631, 632, 633, 634, + /* 120 */ 636, 637, 638, 783, 542, 275, 274, 273, 546, 272, + /* 130 */ 548, 549, 271, 551, 268, 165, 557, 265, 559, 560, + /* 140 */ 262, 259, 236, 54, 871, 694, 251, 789, 70, 252, + /* 150 */ 844, 65, 249, 238, 779, 224, 856, 208, 214, 56, + /* 160 */ 857, 860, 896, 229, 787, 601, 144, 892, 775, 205, + /* 170 */ 692, 693, 695, 696, 220, 10, 910, 82, 957, 31, + /* 180 */ 29, 27, 26, 25, 215, 210, 223, 170, 871, 64, + /* 190 */ 826, 81, 824, 906, 844, 955, 600, 238, 773, 826, + /* 200 */ 856, 825, 224, 57, 857, 860, 896, 187, 62, 910, + /* 210 */ 154, 892, 76, 723, 724, 27, 26, 25, 102, 903, + /* 220 */ 219, 220, 218, 284, 105, 957, 905, 729, 610, 82, + /* 230 */ 201, 923, 87, 223, 21, 871, 64, 284, 81, 227, + /* 240 */ 75, 844, 955, 635, 238, 104, 639, 856, 490, 86, + /* 250 */ 57, 857, 860, 896, 197, 62, 190, 154, 892, 76, + /* 260 */ 173, 68, 236, 278, 871, 78, 903, 904, 127, 908, + /* 270 */ 844, 817, 40, 238, 252, 84, 856, 250, 924, 57, + /* 280 */ 857, 860, 896, 957, 9, 8, 154, 892, 969, 787, + /* 290 */ 236, 48, 871, 178, 30, 28, 81, 953, 844, 206, + /* 300 */ 955, 238, 780, 590, 856, 833, 239, 57, 857, 860, + /* 310 */ 896, 588, 6, 161, 154, 892, 969, 30, 28, 670, + /* 320 */ 169, 99, 12, 790, 70, 914, 590, 31, 29, 27, + /* 330 */ 26, 25, 789, 70, 588, 774, 161, 189, 490, 236, + /* 340 */ 602, 871, 1, 677, 646, 12, 53, 844, 491, 492, + /* 350 */ 238, 50, 224, 856, 30, 28, 133, 857, 860, 252, + /* 360 */ 599, 253, 122, 590, 252, 1, 226, 172, 915, 665, + /* 370 */ 235, 588, 590, 161, 787, 957, 589, 591, 594, 787, + /* 380 */ 588, 171, 12, 926, 253, 281, 30, 28, 81, 280, + /* 390 */ 669, 665, 955, 789, 70, 590, 82, 9, 8, 589, + /* 400 */ 591, 594, 1, 588, 282, 161, 691, 96, 236, 195, + /* 410 */ 871, 130, 193, 59, 94, 196, 844, 134, 71, 238, + /* 420 */ 91, 253, 856, 279, 221, 58, 857, 860, 896, 625, + /* 430 */ 253, 83, 895, 892, 7, 872, 589, 591, 594, 108, + /* 440 */ 236, 2, 871, 597, 174, 589, 591, 594, 844, 772, + /* 450 */ 231, 238, 188, 253, 856, 38, 640, 58, 857, 860, + /* 460 */ 896, 726, 727, 32, 234, 892, 30, 28, 589, 591, + /* 470 */ 594, 85, 30, 28, 237, 590, 236, 603, 871, 607, + /* 480 */ 191, 590, 150, 588, 844, 161, 32, 238, 82, 588, + /* 490 */ 856, 161, 198, 72, 857, 860, 30, 28, 20, 281, + /* 500 */ 598, 668, 604, 280, 602, 590, 207, 82, 31, 29, + /* 510 */ 27, 26, 25, 588, 7, 161, 232, 199, 282, 927, + /* 520 */ 7, 851, 242, 92, 236, 937, 871, 583, 849, 594, + /* 530 */ 225, 970, 844, 253, 32, 238, 160, 279, 856, 253, + /* 540 */ 114, 138, 857, 860, 1, 204, 936, 112, 589, 591, + /* 550 */ 594, 244, 95, 119, 589, 591, 594, 236, 66, 871, + /* 560 */ 67, 5, 153, 253, 917, 844, 217, 98, 238, 203, + /* 570 */ 74, 856, 4, 63, 58, 857, 860, 896, 589, 591, + /* 580 */ 594, 665, 893, 236, 220, 871, 535, 100, 601, 530, + /* 590 */ 911, 844, 33, 68, 238, 202, 59, 856, 101, 64, + /* 600 */ 138, 857, 860, 236, 155, 871, 563, 972, 233, 567, + /* 610 */ 954, 844, 572, 257, 238, 107, 67, 856, 62, 68, + /* 620 */ 137, 857, 860, 17, 230, 236, 831, 871, 79, 903, + /* 630 */ 904, 878, 908, 844, 245, 47, 238, 49, 240, 856, + /* 640 */ 241, 69, 72, 857, 860, 236, 830, 871, 67, 163, + /* 650 */ 126, 216, 246, 844, 116, 788, 238, 158, 236, 856, + /* 660 */ 871, 255, 138, 857, 860, 247, 844, 128, 123, 238, + /* 670 */ 162, 312, 856, 125, 185, 138, 857, 860, 184, 597, + /* 680 */ 971, 60, 129, 183, 22, 182, 142, 305, 143, 838, + /* 690 */ 124, 236, 749, 871, 31, 29, 27, 26, 25, 844, + /* 700 */ 176, 177, 238, 837, 179, 856, 836, 835, 136, 857, + /* 710 */ 860, 181, 180, 55, 778, 236, 120, 871, 777, 748, + /* 720 */ 745, 740, 735, 844, 776, 501, 238, 747, 739, 856, + /* 730 */ 738, 734, 139, 857, 860, 236, 733, 871, 192, 732, + /* 740 */ 828, 175, 248, 844, 200, 41, 238, 194, 88, 856, + /* 750 */ 89, 90, 131, 857, 860, 236, 3, 871, 32, 14, + /* 760 */ 93, 36, 690, 844, 73, 97, 238, 211, 42, 856, + /* 770 */ 212, 684, 140, 857, 860, 236, 683, 871, 849, 15, + /* 780 */ 19, 34, 11, 844, 662, 43, 238, 44, 236, 856, + /* 790 */ 871, 712, 132, 857, 860, 661, 844, 711, 156, 238, + /* 800 */ 35, 716, 856, 717, 103, 141, 857, 860, 80, 715, + /* 810 */ 157, 16, 236, 8, 871, 110, 608, 13, 18, 113, + /* 820 */ 844, 111, 688, 238, 115, 236, 856, 871, 827, 868, + /* 830 */ 857, 860, 117, 844, 626, 45, 238, 243, 236, 856, + /* 840 */ 871, 118, 867, 857, 860, 46, 844, 50, 592, 238, + /* 850 */ 37, 848, 856, 121, 220, 866, 857, 860, 254, 256, + /* 860 */ 236, 564, 871, 168, 258, 260, 561, 261, 844, 64, + /* 870 */ 558, 238, 263, 236, 856, 871, 264, 148, 857, 860, + /* 880 */ 552, 844, 266, 267, 238, 550, 269, 856, 62, 270, + /* 890 */ 147, 857, 860, 236, 556, 871, 555, 222, 77, 903, + /* 900 */ 904, 844, 908, 554, 238, 541, 553, 856, 276, 51, + /* 910 */ 149, 857, 860, 236, 52, 871, 571, 570, 569, 499, + /* 920 */ 283, 844, 520, 519, 238, 518, 744, 856, 517, 516, + /* 930 */ 146, 857, 860, 236, 515, 871, 514, 513, 512, 511, + /* 940 */ 510, 844, 509, 508, 238, 303, 507, 856, 506, 505, + /* 950 */ 135, 857, 860, 504, 302, 304, 737, 306, 307, 736, + /* 960 */ 731, 310, 311, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 155, 158, 161, 160, 166, 143, 143, 155, 146, 146, - /* 10 */ 172, 166, 12, 13, 14, 15, 16, 172, 166, 176, - /* 20 */ 158, 158, 147, 143, 172, 12, 13, 14, 15, 16, - /* 30 */ 0, 145, 1, 2, 159, 160, 157, 37, 152, 160, - /* 40 */ 31, 162, 156, 158, 143, 160, 158, 146, 160, 165, - /* 50 */ 37, 166, 168, 169, 169, 179, 180, 172, 58, 158, - /* 60 */ 175, 176, 177, 178, 176, 4, 57, 182, 183, 39, - /* 70 */ 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, - /* 80 */ 50, 51, 52, 53, 54, 55, 140, 141, 31, 58, - /* 90 */ 12, 13, 14, 15, 16, 95, 96, 31, 98, 99, - /* 100 */ 100, 101, 102, 103, 104, 105, 106, 107, 95, 96, - /* 110 */ 36, 98, 99, 100, 101, 102, 103, 104, 105, 106, - /* 120 */ 107, 12, 13, 14, 15, 16, 67, 68, 69, 70, - /* 130 */ 71, 72, 73, 74, 75, 76, 77, 2, 79, 80, - /* 140 */ 81, 82, 83, 84, 158, 19, 160, 12, 13, 14, - /* 150 */ 15, 16, 166, 27, 0, 169, 31, 171, 172, 33, - /* 160 */ 112, 175, 176, 177, 178, 142, 194, 58, 182, 183, - /* 170 */ 31, 18, 143, 150, 113, 22, 153, 24, 25, 207, - /* 180 */ 194, 31, 56, 211, 158, 59, 160, 158, 35, 0, - /* 190 */ 36, 21, 166, 207, 145, 169, 57, 211, 172, 29, - /* 200 */ 171, 175, 176, 177, 178, 156, 177, 90, 182, 183, - /* 210 */ 184, 133, 134, 14, 15, 16, 187, 188, 189, 21, - /* 220 */ 191, 157, 196, 194, 160, 36, 162, 29, 202, 203, - /* 230 */ 158, 19, 160, 36, 117, 118, 207, 31, 166, 27, - /* 240 */ 211, 169, 21, 63, 172, 33, 76, 175, 176, 177, - /* 250 */ 178, 112, 31, 32, 182, 183, 184, 143, 3, 158, - /* 260 */ 146, 160, 92, 93, 94, 112, 143, 166, 56, 146, - /* 270 */ 169, 59, 158, 172, 214, 203, 175, 176, 177, 178, - /* 280 */ 147, 158, 205, 182, 183, 184, 199, 158, 143, 160, - /* 290 */ 138, 146, 159, 160, 193, 166, 147, 85, 169, 148, - /* 300 */ 88, 172, 151, 158, 175, 176, 177, 178, 159, 160, - /* 310 */ 31, 182, 183, 184, 142, 109, 158, 140, 160, 95, - /* 320 */ 12, 13, 193, 171, 166, 153, 192, 169, 104, 21, - /* 330 */ 172, 107, 65, 175, 176, 177, 178, 29, 0, 31, - /* 340 */ 182, 183, 184, 87, 173, 37, 194, 12, 13, 14, - /* 350 */ 157, 193, 173, 160, 160, 162, 21, 174, 173, 207, - /* 360 */ 158, 190, 160, 211, 29, 57, 31, 111, 166, 190, - /* 370 */ 37, 169, 37, 171, 172, 190, 14, 175, 176, 177, - /* 380 */ 65, 168, 169, 128, 76, 47, 12, 13, 109, 51, - /* 390 */ 159, 160, 57, 31, 208, 21, 194, 12, 13, 132, - /* 400 */ 92, 93, 94, 29, 66, 31, 21, 143, 160, 207, - /* 410 */ 162, 76, 20, 211, 29, 23, 31, 110, 111, 58, - /* 420 */ 112, 195, 37, 85, 31, 58, 65, 92, 93, 94, - /* 430 */ 97, 57, 65, 58, 58, 158, 0, 160, 1, 2, - /* 440 */ 65, 65, 57, 166, 58, 130, 169, 136, 137, 172, - /* 450 */ 76, 65, 175, 176, 177, 178, 12, 13, 14, 182, - /* 460 */ 183, 76, 57, 12, 13, 21, 92, 93, 94, 64, - /* 470 */ 145, 57, 21, 29, 58, 31, 62, 92, 93, 94, - /* 480 */ 29, 65, 31, 47, 143, 145, 112, 51, 12, 13, - /* 490 */ 139, 26, 158, 31, 160, 30, 31, 21, 139, 34, - /* 500 */ 166, 57, 66, 169, 158, 29, 172, 31, 57, 175, - /* 510 */ 176, 177, 58, 31, 120, 143, 58, 58, 53, 65, - /* 520 */ 76, 85, 58, 65, 65, 60, 61, 76, 58, 65, - /* 530 */ 158, 31, 58, 57, 163, 65, 92, 93, 94, 65, - /* 540 */ 31, 58, 174, 92, 93, 94, 212, 213, 65, 177, - /* 550 */ 58, 204, 76, 119, 167, 58, 91, 65, 186, 187, - /* 560 */ 188, 189, 65, 191, 158, 94, 160, 166, 92, 93, - /* 570 */ 94, 167, 166, 204, 166, 169, 127, 200, 172, 201, - /* 580 */ 198, 175, 176, 177, 178, 197, 158, 97, 160, 183, - /* 590 */ 115, 114, 126, 158, 166, 111, 31, 169, 170, 173, - /* 600 */ 172, 210, 108, 175, 176, 177, 185, 135, 158, 131, - /* 610 */ 160, 121, 122, 123, 124, 125, 166, 215, 129, 169, - /* 620 */ 170, 209, 172, 57, 181, 175, 176, 177, 167, 166, - /* 630 */ 89, 158, 151, 160, 166, 57, 167, 142, 142, 166, - /* 640 */ 139, 154, 169, 164, 158, 172, 166, 143, 175, 176, - /* 650 */ 177, 158, 149, 160, 163, 144, 158, 149, 0, 166, - /* 660 */ 53, 64, 169, 0, 158, 172, 160, 0, 175, 176, - /* 670 */ 177, 0, 166, 38, 0, 169, 170, 21, 172, 206, - /* 680 */ 0, 175, 176, 177, 0, 0, 158, 0, 160, 12, - /* 690 */ 13, 14, 15, 16, 166, 19, 21, 169, 170, 0, - /* 700 */ 172, 0, 0, 175, 176, 177, 213, 0, 0, 0, - /* 710 */ 0, 158, 143, 160, 0, 0, 57, 87, 86, 166, - /* 720 */ 65, 116, 169, 58, 58, 172, 65, 158, 175, 176, - /* 730 */ 177, 158, 29, 160, 65, 57, 57, 65, 57, 166, - /* 740 */ 58, 58, 169, 57, 116, 172, 177, 110, 175, 176, - /* 750 */ 177, 58, 64, 158, 65, 160, 187, 188, 189, 65, - /* 760 */ 191, 166, 58, 65, 169, 116, 29, 172, 4, 64, - /* 770 */ 175, 176, 177, 29, 58, 158, 64, 160, 29, 29, - /* 780 */ 29, 29, 2, 166, 58, 64, 169, 97, 57, 172, - /* 790 */ 57, 57, 175, 176, 177, 0, 58, 58, 158, 57, - /* 800 */ 160, 90, 57, 57, 87, 86, 166, 64, 21, 169, - /* 810 */ 62, 64, 172, 57, 29, 175, 176, 177, 158, 58, - /* 820 */ 160, 63, 29, 57, 21, 58, 166, 29, 57, 169, - /* 830 */ 58, 158, 172, 160, 29, 175, 176, 177, 57, 166, - /* 840 */ 58, 29, 169, 57, 29, 172, 58, 57, 175, 176, - /* 850 */ 177, 78, 78, 158, 78, 160, 78, 66, 57, 57, - /* 860 */ 29, 166, 29, 21, 169, 21, 38, 172, 29, 29, - /* 870 */ 175, 176, 177, 37, 29, 29, 29, 29, 158, 29, - /* 880 */ 160, 29, 29, 29, 29, 29, 166, 29, 29, 169, - /* 890 */ 29, 29, 172, 0, 29, 175, 176, 177, 158, 28, - /* 900 */ 160, 0, 0, 21, 20, 216, 166, 216, 216, 169, - /* 910 */ 216, 216, 172, 216, 216, 175, 176, 177, 216, 216, - /* 920 */ 158, 216, 160, 216, 216, 216, 216, 216, 166, 216, - /* 930 */ 216, 169, 216, 216, 172, 216, 216, 175, 176, 177, - /* 940 */ 216, 216, 158, 216, 160, 216, 216, 216, 216, 216, - /* 950 */ 166, 216, 216, 169, 216, 216, 172, 216, 216, 175, - /* 960 */ 176, 177, 216, 216, 216, 158, 216, 160, 216, 216, - /* 970 */ 216, 216, 216, 166, 216, 143, 169, 216, 216, 172, - /* 980 */ 216, 216, 175, 176, 177, 158, 216, 160, 216, 216, - /* 990 */ 158, 216, 216, 166, 216, 216, 169, 216, 216, 172, - /* 1000 */ 216, 216, 175, 176, 177, 216, 216, 216, 216, 177, - /* 1010 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 187, - /* 1020 */ 188, 189, 2, 191, 216, 216, 216, 216, 216, 216, - /* 1030 */ 216, 216, 12, 13, 14, 15, 16, 216, 216, 216, - /* 1040 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1050 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1060 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1070 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1080 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1090 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1100 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1110 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1120 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1130 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1140 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1150 */ 216, 216, 216, 216, 216, 216, 216, 216, 216, 216, - /* 1160 */ 216, + /* 0 */ 157, 160, 163, 162, 168, 145, 145, 157, 148, 148, + /* 10 */ 174, 168, 12, 13, 14, 15, 16, 174, 168, 178, + /* 20 */ 160, 160, 142, 143, 174, 12, 13, 14, 15, 16, + /* 30 */ 0, 160, 159, 162, 216, 162, 147, 164, 31, 168, + /* 40 */ 40, 196, 171, 154, 160, 174, 162, 158, 177, 178, + /* 50 */ 179, 180, 175, 40, 209, 184, 185, 186, 213, 39, + /* 60 */ 167, 61, 178, 170, 171, 159, 195, 60, 162, 192, + /* 70 */ 164, 31, 42, 43, 44, 45, 46, 47, 48, 49, + /* 80 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 31, + /* 90 */ 12, 13, 14, 15, 16, 181, 182, 97, 98, 68, + /* 100 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, + /* 110 */ 97, 98, 147, 100, 101, 102, 103, 104, 105, 106, + /* 120 */ 107, 108, 109, 158, 70, 71, 72, 73, 74, 75, + /* 130 */ 76, 77, 78, 79, 80, 149, 82, 83, 84, 85, + /* 140 */ 86, 87, 160, 144, 162, 99, 31, 161, 162, 145, + /* 150 */ 168, 152, 148, 171, 155, 173, 174, 92, 31, 177, + /* 160 */ 178, 179, 180, 132, 160, 31, 184, 185, 0, 123, + /* 170 */ 124, 125, 126, 127, 145, 60, 175, 114, 196, 12, + /* 180 */ 13, 14, 15, 16, 119, 120, 160, 159, 162, 160, + /* 190 */ 162, 209, 164, 192, 168, 213, 31, 171, 0, 162, + /* 200 */ 174, 164, 173, 177, 178, 179, 180, 39, 179, 175, + /* 210 */ 184, 185, 186, 135, 136, 14, 15, 16, 189, 190, + /* 220 */ 191, 145, 193, 39, 198, 196, 192, 140, 61, 114, + /* 230 */ 204, 205, 19, 160, 97, 162, 160, 39, 209, 3, + /* 240 */ 27, 168, 213, 106, 171, 111, 109, 174, 21, 36, + /* 250 */ 177, 178, 179, 180, 61, 179, 29, 184, 185, 186, + /* 260 */ 173, 68, 160, 66, 162, 189, 190, 191, 150, 193, + /* 270 */ 168, 153, 59, 171, 145, 62, 174, 148, 205, 177, + /* 280 */ 178, 179, 180, 196, 1, 2, 184, 185, 186, 160, + /* 290 */ 160, 144, 162, 145, 12, 13, 209, 195, 168, 207, + /* 300 */ 213, 171, 155, 21, 174, 170, 171, 177, 178, 179, + /* 310 */ 180, 29, 34, 31, 184, 185, 186, 12, 13, 14, + /* 320 */ 149, 201, 40, 161, 162, 195, 21, 12, 13, 14, + /* 330 */ 15, 16, 161, 162, 29, 0, 31, 142, 21, 160, + /* 340 */ 31, 162, 60, 14, 61, 40, 60, 168, 31, 32, + /* 350 */ 171, 65, 173, 174, 12, 13, 177, 178, 179, 145, + /* 360 */ 31, 79, 148, 21, 145, 60, 130, 148, 112, 113, + /* 370 */ 40, 29, 21, 31, 160, 196, 94, 95, 96, 160, + /* 380 */ 29, 149, 40, 176, 79, 50, 12, 13, 209, 54, + /* 390 */ 4, 113, 213, 161, 162, 21, 114, 1, 2, 94, + /* 400 */ 95, 96, 60, 29, 69, 31, 61, 61, 160, 20, + /* 410 */ 162, 18, 23, 68, 68, 22, 168, 24, 25, 171, + /* 420 */ 111, 79, 174, 88, 194, 177, 178, 179, 180, 99, + /* 430 */ 79, 38, 184, 185, 60, 162, 94, 95, 96, 210, + /* 440 */ 160, 197, 162, 31, 145, 94, 95, 96, 168, 0, + /* 450 */ 68, 171, 145, 79, 174, 147, 61, 177, 178, 179, + /* 460 */ 180, 138, 139, 68, 184, 185, 12, 13, 94, 95, + /* 470 */ 96, 147, 12, 13, 14, 21, 160, 31, 162, 61, + /* 480 */ 141, 21, 141, 29, 168, 31, 68, 171, 114, 29, + /* 490 */ 174, 31, 160, 177, 178, 179, 12, 13, 2, 50, + /* 500 */ 31, 115, 31, 54, 31, 21, 122, 114, 12, 13, + /* 510 */ 14, 15, 16, 29, 60, 31, 134, 165, 69, 176, + /* 520 */ 60, 60, 121, 169, 160, 206, 162, 61, 67, 96, + /* 530 */ 214, 215, 168, 79, 68, 171, 172, 88, 174, 79, + /* 540 */ 61, 177, 178, 179, 60, 168, 206, 68, 94, 95, + /* 550 */ 96, 61, 169, 61, 94, 95, 96, 160, 68, 162, + /* 560 */ 68, 129, 168, 79, 203, 168, 128, 202, 171, 117, + /* 570 */ 200, 174, 116, 160, 177, 178, 179, 180, 94, 95, + /* 580 */ 96, 113, 185, 160, 145, 162, 61, 199, 31, 61, + /* 590 */ 175, 168, 110, 68, 171, 172, 68, 174, 187, 160, + /* 600 */ 177, 178, 179, 160, 137, 162, 61, 217, 133, 61, + /* 610 */ 212, 168, 61, 68, 171, 211, 68, 174, 179, 68, + /* 620 */ 177, 178, 179, 60, 131, 160, 169, 162, 189, 190, + /* 630 */ 191, 183, 193, 168, 91, 144, 171, 60, 168, 174, + /* 640 */ 168, 61, 177, 178, 179, 160, 169, 162, 68, 168, + /* 650 */ 153, 208, 166, 168, 160, 160, 171, 172, 160, 174, + /* 660 */ 162, 156, 177, 178, 179, 165, 168, 145, 144, 171, + /* 670 */ 172, 141, 174, 19, 26, 177, 178, 179, 30, 31, + /* 680 */ 215, 27, 146, 35, 2, 37, 151, 33, 151, 0, + /* 690 */ 36, 160, 0, 162, 12, 13, 14, 15, 16, 168, + /* 700 */ 56, 67, 171, 0, 56, 174, 0, 0, 177, 178, + /* 710 */ 179, 63, 64, 59, 0, 160, 62, 162, 0, 0, + /* 720 */ 0, 0, 0, 168, 0, 41, 171, 0, 0, 174, + /* 730 */ 0, 0, 177, 178, 179, 160, 0, 162, 21, 0, + /* 740 */ 0, 93, 88, 168, 90, 60, 171, 21, 19, 174, + /* 750 */ 34, 89, 177, 178, 179, 160, 68, 162, 68, 118, + /* 760 */ 61, 68, 61, 168, 60, 60, 171, 29, 60, 174, + /* 770 */ 68, 61, 177, 178, 179, 160, 61, 162, 67, 118, + /* 780 */ 68, 112, 118, 168, 61, 60, 171, 4, 160, 174, + /* 790 */ 162, 29, 177, 178, 179, 61, 168, 29, 29, 171, + /* 800 */ 68, 29, 174, 61, 67, 177, 178, 179, 67, 29, + /* 810 */ 29, 68, 160, 2, 162, 67, 61, 60, 60, 60, + /* 820 */ 168, 61, 61, 171, 60, 160, 174, 162, 0, 177, + /* 830 */ 178, 179, 34, 168, 99, 60, 171, 92, 160, 174, + /* 840 */ 162, 89, 177, 178, 179, 60, 168, 65, 21, 171, + /* 850 */ 60, 67, 174, 67, 145, 177, 178, 179, 66, 29, + /* 860 */ 160, 61, 162, 29, 60, 29, 61, 60, 168, 160, + /* 870 */ 61, 171, 29, 160, 174, 162, 60, 177, 178, 179, + /* 880 */ 61, 168, 29, 60, 171, 61, 29, 174, 179, 60, + /* 890 */ 177, 178, 179, 160, 81, 162, 81, 188, 189, 190, + /* 900 */ 191, 168, 193, 81, 171, 21, 81, 174, 69, 60, + /* 910 */ 177, 178, 179, 160, 60, 162, 29, 29, 21, 41, + /* 920 */ 40, 168, 29, 29, 171, 29, 0, 174, 29, 29, + /* 930 */ 177, 178, 179, 160, 29, 162, 29, 21, 29, 29, + /* 940 */ 29, 168, 29, 29, 171, 27, 29, 174, 29, 29, + /* 950 */ 177, 178, 179, 29, 29, 34, 0, 29, 28, 0, + /* 960 */ 0, 21, 20, 218, 218, 218, 218, 218, 218, 218, + /* 970 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 980 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 990 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 1000 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 1010 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 1020 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 1030 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 1040 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 1050 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 1060 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 1070 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 1080 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 1090 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, + /* 1100 */ 218, 218, 218, }; -#define YY_SHIFT_COUNT (307) +#define YY_SHIFT_COUNT (312) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1020) +#define YY_SHIFT_MAX (960) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 153, 308, 335, 385, 385, 385, 385, 374, 385, 385, - /* 10 */ 139, 451, 476, 444, 451, 451, 451, 451, 451, 451, - /* 20 */ 451, 451, 451, 451, 451, 451, 451, 451, 451, 451, - /* 30 */ 451, 451, 451, 9, 9, 9, 170, 170, 57, 57, - /* 40 */ 74, 66, 125, 125, 48, 150, 66, 57, 57, 66, - /* 50 */ 57, 66, 66, 66, 57, 197, 0, 13, 13, 170, - /* 60 */ 221, 154, 206, 206, 206, 189, 150, 66, 66, 180, - /* 70 */ 59, 465, 78, 490, 117, 198, 279, 307, 256, 307, - /* 80 */ 362, 255, 61, 393, 74, 393, 74, 462, 462, 482, - /* 90 */ 500, 509, 394, 434, 471, 394, 434, 471, 449, 466, - /* 100 */ 475, 477, 484, 482, 565, 494, 472, 478, 489, 566, - /* 110 */ 66, 434, 471, 471, 434, 471, 541, 482, 500, 180, - /* 120 */ 197, 482, 578, 393, 197, 462, 1037, 1037, 1037, 30, - /* 130 */ 212, 135, 1020, 109, 126, 677, 677, 677, 677, 677, - /* 140 */ 677, 677, 338, 436, 31, 224, 199, 199, 199, 199, - /* 150 */ 392, 361, 367, 375, 437, 311, 315, 267, 376, 333, - /* 160 */ 386, 405, 416, 454, 458, 459, 464, 470, 474, 483, - /* 170 */ 492, 497, 414, 658, 663, 667, 671, 607, 597, 680, - /* 180 */ 684, 685, 687, 699, 701, 702, 635, 674, 707, 708, - /* 190 */ 709, 710, 656, 714, 675, 676, 715, 659, 630, 632, - /* 200 */ 655, 661, 605, 665, 669, 666, 678, 679, 682, 681, - /* 210 */ 683, 703, 672, 688, 686, 689, 628, 693, 704, 705, - /* 220 */ 637, 694, 712, 716, 698, 649, 764, 737, 744, 749, - /* 230 */ 750, 751, 752, 780, 690, 721, 726, 731, 733, 738, - /* 240 */ 739, 734, 742, 711, 745, 795, 717, 719, 746, 748, - /* 250 */ 743, 747, 787, 756, 758, 761, 785, 793, 766, 767, - /* 260 */ 798, 771, 772, 805, 781, 782, 812, 786, 788, 815, - /* 270 */ 790, 773, 774, 776, 778, 803, 791, 801, 802, 831, - /* 280 */ 833, 842, 828, 836, 839, 840, 845, 846, 847, 848, - /* 290 */ 850, 844, 852, 853, 854, 855, 856, 858, 859, 861, - /* 300 */ 862, 893, 865, 871, 901, 902, 882, 884, + /* 0 */ 393, 282, 305, 342, 342, 342, 342, 374, 342, 342, + /* 10 */ 115, 454, 484, 460, 454, 454, 454, 454, 454, 454, + /* 20 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, + /* 30 */ 454, 454, 454, 7, 7, 7, 351, 351, 40, 40, + /* 40 */ 20, 58, 127, 127, 63, 165, 58, 40, 40, 58, + /* 50 */ 40, 58, 58, 58, 40, 184, 0, 13, 13, 351, + /* 60 */ 317, 168, 134, 134, 134, 198, 165, 58, 58, 197, + /* 70 */ 54, 648, 78, 46, 65, 227, 309, 256, 278, 256, + /* 80 */ 329, 236, 386, 412, 20, 412, 20, 446, 446, 469, + /* 90 */ 471, 473, 384, 401, 433, 384, 401, 433, 432, 438, + /* 100 */ 452, 456, 468, 469, 557, 482, 467, 475, 493, 563, + /* 110 */ 58, 401, 433, 433, 401, 433, 543, 469, 471, 197, + /* 120 */ 184, 469, 577, 412, 184, 446, 963, 963, 963, 30, + /* 130 */ 654, 496, 682, 167, 213, 315, 315, 315, 315, 315, + /* 140 */ 315, 315, 335, 449, 283, 137, 201, 201, 201, 201, + /* 150 */ 389, 193, 345, 346, 396, 323, 31, 382, 395, 330, + /* 160 */ 418, 461, 466, 479, 490, 492, 525, 528, 545, 548, + /* 170 */ 551, 580, 286, 689, 692, 703, 706, 644, 634, 707, + /* 180 */ 714, 718, 719, 720, 721, 722, 724, 684, 727, 728, + /* 190 */ 730, 731, 736, 717, 739, 726, 729, 740, 685, 716, + /* 200 */ 662, 688, 690, 641, 699, 693, 701, 704, 705, 710, + /* 210 */ 708, 715, 738, 702, 711, 725, 712, 661, 723, 734, + /* 220 */ 737, 669, 732, 741, 742, 743, 664, 783, 762, 768, + /* 230 */ 769, 772, 780, 781, 811, 735, 748, 755, 757, 758, + /* 240 */ 760, 761, 759, 764, 745, 775, 828, 798, 752, 785, + /* 250 */ 782, 784, 786, 827, 790, 792, 800, 830, 834, 804, + /* 260 */ 805, 836, 807, 809, 843, 816, 819, 853, 823, 824, + /* 270 */ 857, 829, 813, 815, 822, 825, 884, 839, 849, 854, + /* 280 */ 887, 888, 897, 878, 880, 893, 894, 896, 899, 900, + /* 290 */ 905, 907, 916, 909, 910, 911, 913, 914, 917, 919, + /* 300 */ 920, 924, 926, 925, 918, 921, 956, 928, 930, 959, + /* 310 */ 960, 940, 942, }; #define YY_REDUCE_COUNT (128) -#define YY_REDUCE_MIN (-162) -#define YY_REDUCE_MAX (832) +#define YY_REDUCE_MIN (-182) +#define YY_REDUCE_MAX (773) static const short yy_reduce_ofst[] = { - /* 0 */ 152, -14, 26, 72, 101, 129, 158, 202, -115, 277, - /* 10 */ 29, 334, 406, 428, 450, 473, 493, 506, 528, 553, - /* 20 */ 573, 595, 617, 640, 660, 673, 695, 720, 740, 762, - /* 30 */ 784, 807, 827, 372, 569, 832, -155, -148, -138, -137, - /* 40 */ -114, -121, -157, -112, -28, -116, -125, -99, 114, 64, - /* 50 */ 123, 133, 193, 149, 145, 23, -124, -124, -124, -162, - /* 60 */ -54, 49, 171, 179, 185, 172, 213, 231, 248, 151, - /* 70 */ -159, -120, 60, 77, 87, 177, 183, 134, 134, 134, - /* 80 */ 194, 186, 226, 264, 325, 341, 340, 351, 359, 346, - /* 90 */ 371, 368, 347, 387, 401, 369, 404, 408, 378, 377, - /* 100 */ 382, 388, 134, 435, 426, 421, 402, 391, 412, 443, - /* 110 */ 194, 461, 463, 468, 469, 480, 479, 486, 491, 481, - /* 120 */ 495, 498, 487, 504, 496, 501, 503, 508, 511, + /* 0 */ 87, -18, 26, 73, -129, 102, 130, 179, 248, 280, + /* 10 */ 29, 316, 397, 364, 423, 443, 465, 485, 498, 531, + /* 20 */ 555, 575, 595, 615, 628, 652, 665, 678, 700, 713, + /* 30 */ 733, 753, 773, 709, 76, 439, -157, -150, -140, -139, + /* 40 */ -111, -127, -159, -116, -155, -107, -14, 4, 129, -94, + /* 50 */ 214, 171, 28, 232, 219, -1, -86, -86, -86, -164, + /* 60 */ -120, -35, -123, 1, 34, 147, 135, 162, 37, 118, + /* 70 */ -161, 148, -182, 92, 120, 195, 207, 230, 230, 230, + /* 80 */ 273, 229, 244, 299, 308, 307, 324, 339, 341, 332, + /* 90 */ 352, 343, 319, 354, 377, 340, 383, 394, 361, 365, + /* 100 */ 370, 388, 230, 413, 415, 411, 390, 398, 404, 448, + /* 110 */ 273, 457, 470, 472, 477, 481, 486, 494, 500, 497, + /* 120 */ 491, 495, 505, 522, 524, 530, 535, 537, 536, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 10 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 20 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 30 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 40 */ 744, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 50 */ 721, 721, 721, 721, 721, 742, 721, 889, 721, 721, - /* 60 */ 721, 744, 900, 900, 900, 742, 721, 721, 721, 807, - /* 70 */ 721, 721, 964, 721, 924, 721, 916, 892, 906, 893, - /* 80 */ 721, 949, 909, 721, 744, 721, 744, 721, 721, 721, - /* 90 */ 721, 721, 931, 929, 721, 931, 929, 721, 943, 939, - /* 100 */ 922, 920, 906, 721, 721, 721, 967, 955, 951, 721, - /* 110 */ 721, 929, 721, 721, 929, 721, 820, 721, 721, 721, - /* 120 */ 742, 721, 776, 721, 742, 721, 810, 810, 745, 721, - /* 130 */ 721, 721, 721, 721, 721, 861, 942, 941, 860, 866, - /* 140 */ 865, 864, 721, 721, 721, 721, 855, 856, 854, 853, - /* 150 */ 721, 721, 721, 721, 890, 721, 952, 956, 721, 721, - /* 160 */ 721, 841, 721, 721, 721, 721, 721, 721, 721, 721, - /* 170 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 180 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 190 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 200 */ 913, 923, 721, 721, 721, 721, 721, 721, 721, 721, - /* 210 */ 721, 721, 721, 841, 721, 940, 721, 899, 895, 721, - /* 220 */ 721, 891, 721, 721, 950, 721, 721, 721, 721, 721, - /* 230 */ 721, 721, 721, 885, 721, 721, 721, 721, 721, 721, - /* 240 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 250 */ 840, 721, 721, 721, 721, 721, 721, 721, 804, 721, - /* 260 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 270 */ 721, 789, 787, 786, 785, 721, 782, 721, 721, 721, - /* 280 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 290 */ 721, 721, 721, 721, 721, 721, 721, 721, 721, 721, - /* 300 */ 721, 721, 721, 721, 721, 721, 721, 721, + /* 0 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 10 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 20 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 30 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 40 */ 753, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 50 */ 728, 728, 728, 728, 728, 751, 728, 898, 728, 728, + /* 60 */ 728, 753, 909, 909, 909, 751, 728, 728, 728, 816, + /* 70 */ 728, 728, 973, 728, 933, 728, 925, 901, 915, 902, + /* 80 */ 728, 958, 918, 728, 753, 728, 753, 728, 728, 728, + /* 90 */ 728, 728, 940, 938, 728, 940, 938, 728, 952, 948, + /* 100 */ 931, 929, 915, 728, 728, 728, 976, 964, 960, 728, + /* 110 */ 728, 938, 728, 728, 938, 728, 829, 728, 728, 728, + /* 120 */ 751, 728, 785, 728, 751, 728, 819, 819, 754, 728, + /* 130 */ 728, 728, 728, 728, 728, 870, 951, 950, 869, 875, + /* 140 */ 874, 873, 728, 728, 728, 728, 864, 865, 863, 862, + /* 150 */ 728, 728, 728, 728, 899, 728, 961, 965, 728, 728, + /* 160 */ 728, 850, 728, 728, 728, 728, 728, 728, 728, 728, + /* 170 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 180 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 190 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 200 */ 728, 922, 932, 728, 728, 728, 728, 728, 728, 728, + /* 210 */ 728, 728, 728, 728, 850, 728, 949, 728, 908, 904, + /* 220 */ 728, 728, 900, 728, 728, 959, 728, 728, 728, 728, + /* 230 */ 728, 728, 728, 728, 894, 728, 728, 728, 728, 728, + /* 240 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 250 */ 728, 849, 728, 728, 728, 728, 728, 728, 728, 813, + /* 260 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 270 */ 728, 728, 798, 796, 795, 794, 728, 791, 728, 728, + /* 280 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 290 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 300 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, + /* 310 */ 728, 728, 728, }; /********** End of lemon-generated parsing tables *****************************/ @@ -657,189 +646,191 @@ static const char *const yyTokenName[] = { /* 30 */ "DNODES", /* 31 */ "NK_ID", /* 32 */ "NK_IPTOKEN", - /* 33 */ "DATABASE", - /* 34 */ "DATABASES", - /* 35 */ "USE", - /* 36 */ "IF", - /* 37 */ "NOT", - /* 38 */ "EXISTS", - /* 39 */ "BLOCKS", - /* 40 */ "CACHE", - /* 41 */ "CACHELAST", - /* 42 */ "COMP", - /* 43 */ "DAYS", - /* 44 */ "FSYNC", - /* 45 */ "MAXROWS", - /* 46 */ "MINROWS", - /* 47 */ "KEEP", - /* 48 */ "PRECISION", - /* 49 */ "QUORUM", - /* 50 */ "REPLICA", - /* 51 */ "TTL", - /* 52 */ "WAL", - /* 53 */ "VGROUPS", - /* 54 */ "SINGLE_STABLE", - /* 55 */ "STREAM_MODE", - /* 56 */ "TABLE", - /* 57 */ "NK_LP", - /* 58 */ "NK_RP", - /* 59 */ "STABLE", - /* 60 */ "TABLES", - /* 61 */ "STABLES", - /* 62 */ "USING", - /* 63 */ "TAGS", - /* 64 */ "NK_DOT", - /* 65 */ "NK_COMMA", - /* 66 */ "COMMENT", - /* 67 */ "BOOL", - /* 68 */ "TINYINT", - /* 69 */ "SMALLINT", - /* 70 */ "INT", - /* 71 */ "INTEGER", - /* 72 */ "BIGINT", - /* 73 */ "FLOAT", - /* 74 */ "DOUBLE", - /* 75 */ "BINARY", - /* 76 */ "TIMESTAMP", - /* 77 */ "NCHAR", - /* 78 */ "UNSIGNED", - /* 79 */ "JSON", - /* 80 */ "VARCHAR", - /* 81 */ "MEDIUMBLOB", - /* 82 */ "BLOB", - /* 83 */ "VARBINARY", - /* 84 */ "DECIMAL", - /* 85 */ "SMA", - /* 86 */ "INDEX", - /* 87 */ "ON", - /* 88 */ "FULLTEXT", - /* 89 */ "FUNCTION", - /* 90 */ "INTERVAL", - /* 91 */ "MNODES", - /* 92 */ "NK_FLOAT", - /* 93 */ "NK_BOOL", - /* 94 */ "NK_VARIABLE", - /* 95 */ "BETWEEN", - /* 96 */ "IS", - /* 97 */ "NULL", - /* 98 */ "NK_LT", - /* 99 */ "NK_GT", - /* 100 */ "NK_LE", - /* 101 */ "NK_GE", - /* 102 */ "NK_NE", - /* 103 */ "NK_EQ", - /* 104 */ "LIKE", - /* 105 */ "MATCH", - /* 106 */ "NMATCH", - /* 107 */ "IN", - /* 108 */ "FROM", - /* 109 */ "AS", - /* 110 */ "JOIN", - /* 111 */ "INNER", - /* 112 */ "SELECT", - /* 113 */ "DISTINCT", - /* 114 */ "WHERE", - /* 115 */ "PARTITION", - /* 116 */ "BY", - /* 117 */ "SESSION", - /* 118 */ "STATE_WINDOW", - /* 119 */ "SLIDING", - /* 120 */ "FILL", - /* 121 */ "VALUE", - /* 122 */ "NONE", - /* 123 */ "PREV", - /* 124 */ "LINEAR", - /* 125 */ "NEXT", - /* 126 */ "GROUP", - /* 127 */ "HAVING", - /* 128 */ "ORDER", - /* 129 */ "SLIMIT", - /* 130 */ "SOFFSET", - /* 131 */ "LIMIT", - /* 132 */ "OFFSET", - /* 133 */ "ASC", - /* 134 */ "DESC", - /* 135 */ "NULLS", - /* 136 */ "FIRST", - /* 137 */ "LAST", - /* 138 */ "cmd", - /* 139 */ "user_name", - /* 140 */ "dnode_endpoint", - /* 141 */ "dnode_host_name", - /* 142 */ "not_exists_opt", - /* 143 */ "db_name", - /* 144 */ "db_options", - /* 145 */ "exists_opt", - /* 146 */ "full_table_name", - /* 147 */ "column_def_list", - /* 148 */ "tags_def_opt", - /* 149 */ "table_options", - /* 150 */ "multi_create_clause", - /* 151 */ "tags_def", - /* 152 */ "multi_drop_clause", - /* 153 */ "create_subtable_clause", - /* 154 */ "specific_tags_opt", - /* 155 */ "literal_list", - /* 156 */ "drop_table_clause", - /* 157 */ "col_name_list", - /* 158 */ "table_name", - /* 159 */ "column_def", - /* 160 */ "column_name", - /* 161 */ "type_name", - /* 162 */ "col_name", - /* 163 */ "index_name", - /* 164 */ "index_options", - /* 165 */ "func_list", - /* 166 */ "duration_literal", - /* 167 */ "sliding_opt", - /* 168 */ "func", - /* 169 */ "function_name", - /* 170 */ "expression_list", - /* 171 */ "query_expression", - /* 172 */ "literal", - /* 173 */ "table_alias", - /* 174 */ "column_alias", - /* 175 */ "expression", - /* 176 */ "column_reference", - /* 177 */ "subquery", - /* 178 */ "predicate", - /* 179 */ "compare_op", - /* 180 */ "in_op", - /* 181 */ "in_predicate_value", - /* 182 */ "boolean_value_expression", - /* 183 */ "boolean_primary", - /* 184 */ "common_expression", - /* 185 */ "from_clause", - /* 186 */ "table_reference_list", - /* 187 */ "table_reference", - /* 188 */ "table_primary", - /* 189 */ "joined_table", - /* 190 */ "alias_opt", - /* 191 */ "parenthesized_joined_table", - /* 192 */ "join_type", - /* 193 */ "search_condition", - /* 194 */ "query_specification", - /* 195 */ "set_quantifier_opt", - /* 196 */ "select_list", - /* 197 */ "where_clause_opt", - /* 198 */ "partition_by_clause_opt", - /* 199 */ "twindow_clause_opt", - /* 200 */ "group_by_clause_opt", - /* 201 */ "having_clause_opt", - /* 202 */ "select_sublist", - /* 203 */ "select_item", - /* 204 */ "fill_opt", - /* 205 */ "fill_mode", - /* 206 */ "group_by_list", - /* 207 */ "query_expression_body", - /* 208 */ "order_by_clause_opt", - /* 209 */ "slimit_clause_opt", - /* 210 */ "limit_clause_opt", - /* 211 */ "query_primary", - /* 212 */ "sort_specification_list", - /* 213 */ "sort_specification", - /* 214 */ "ordering_specification_opt", - /* 215 */ "null_ordering_opt", + /* 33 */ "QNODE", + /* 34 */ "ON", + /* 35 */ "QNODES", + /* 36 */ "DATABASE", + /* 37 */ "DATABASES", + /* 38 */ "USE", + /* 39 */ "IF", + /* 40 */ "NOT", + /* 41 */ "EXISTS", + /* 42 */ "BLOCKS", + /* 43 */ "CACHE", + /* 44 */ "CACHELAST", + /* 45 */ "COMP", + /* 46 */ "DAYS", + /* 47 */ "FSYNC", + /* 48 */ "MAXROWS", + /* 49 */ "MINROWS", + /* 50 */ "KEEP", + /* 51 */ "PRECISION", + /* 52 */ "QUORUM", + /* 53 */ "REPLICA", + /* 54 */ "TTL", + /* 55 */ "WAL", + /* 56 */ "VGROUPS", + /* 57 */ "SINGLE_STABLE", + /* 58 */ "STREAM_MODE", + /* 59 */ "TABLE", + /* 60 */ "NK_LP", + /* 61 */ "NK_RP", + /* 62 */ "STABLE", + /* 63 */ "TABLES", + /* 64 */ "STABLES", + /* 65 */ "USING", + /* 66 */ "TAGS", + /* 67 */ "NK_DOT", + /* 68 */ "NK_COMMA", + /* 69 */ "COMMENT", + /* 70 */ "BOOL", + /* 71 */ "TINYINT", + /* 72 */ "SMALLINT", + /* 73 */ "INT", + /* 74 */ "INTEGER", + /* 75 */ "BIGINT", + /* 76 */ "FLOAT", + /* 77 */ "DOUBLE", + /* 78 */ "BINARY", + /* 79 */ "TIMESTAMP", + /* 80 */ "NCHAR", + /* 81 */ "UNSIGNED", + /* 82 */ "JSON", + /* 83 */ "VARCHAR", + /* 84 */ "MEDIUMBLOB", + /* 85 */ "BLOB", + /* 86 */ "VARBINARY", + /* 87 */ "DECIMAL", + /* 88 */ "SMA", + /* 89 */ "INDEX", + /* 90 */ "FULLTEXT", + /* 91 */ "FUNCTION", + /* 92 */ "INTERVAL", + /* 93 */ "MNODES", + /* 94 */ "NK_FLOAT", + /* 95 */ "NK_BOOL", + /* 96 */ "NK_VARIABLE", + /* 97 */ "BETWEEN", + /* 98 */ "IS", + /* 99 */ "NULL", + /* 100 */ "NK_LT", + /* 101 */ "NK_GT", + /* 102 */ "NK_LE", + /* 103 */ "NK_GE", + /* 104 */ "NK_NE", + /* 105 */ "NK_EQ", + /* 106 */ "LIKE", + /* 107 */ "MATCH", + /* 108 */ "NMATCH", + /* 109 */ "IN", + /* 110 */ "FROM", + /* 111 */ "AS", + /* 112 */ "JOIN", + /* 113 */ "INNER", + /* 114 */ "SELECT", + /* 115 */ "DISTINCT", + /* 116 */ "WHERE", + /* 117 */ "PARTITION", + /* 118 */ "BY", + /* 119 */ "SESSION", + /* 120 */ "STATE_WINDOW", + /* 121 */ "SLIDING", + /* 122 */ "FILL", + /* 123 */ "VALUE", + /* 124 */ "NONE", + /* 125 */ "PREV", + /* 126 */ "LINEAR", + /* 127 */ "NEXT", + /* 128 */ "GROUP", + /* 129 */ "HAVING", + /* 130 */ "ORDER", + /* 131 */ "SLIMIT", + /* 132 */ "SOFFSET", + /* 133 */ "LIMIT", + /* 134 */ "OFFSET", + /* 135 */ "ASC", + /* 136 */ "DESC", + /* 137 */ "NULLS", + /* 138 */ "FIRST", + /* 139 */ "LAST", + /* 140 */ "cmd", + /* 141 */ "user_name", + /* 142 */ "dnode_endpoint", + /* 143 */ "dnode_host_name", + /* 144 */ "not_exists_opt", + /* 145 */ "db_name", + /* 146 */ "db_options", + /* 147 */ "exists_opt", + /* 148 */ "full_table_name", + /* 149 */ "column_def_list", + /* 150 */ "tags_def_opt", + /* 151 */ "table_options", + /* 152 */ "multi_create_clause", + /* 153 */ "tags_def", + /* 154 */ "multi_drop_clause", + /* 155 */ "create_subtable_clause", + /* 156 */ "specific_tags_opt", + /* 157 */ "literal_list", + /* 158 */ "drop_table_clause", + /* 159 */ "col_name_list", + /* 160 */ "table_name", + /* 161 */ "column_def", + /* 162 */ "column_name", + /* 163 */ "type_name", + /* 164 */ "col_name", + /* 165 */ "index_name", + /* 166 */ "index_options", + /* 167 */ "func_list", + /* 168 */ "duration_literal", + /* 169 */ "sliding_opt", + /* 170 */ "func", + /* 171 */ "function_name", + /* 172 */ "expression_list", + /* 173 */ "query_expression", + /* 174 */ "literal", + /* 175 */ "table_alias", + /* 176 */ "column_alias", + /* 177 */ "expression", + /* 178 */ "column_reference", + /* 179 */ "subquery", + /* 180 */ "predicate", + /* 181 */ "compare_op", + /* 182 */ "in_op", + /* 183 */ "in_predicate_value", + /* 184 */ "boolean_value_expression", + /* 185 */ "boolean_primary", + /* 186 */ "common_expression", + /* 187 */ "from_clause", + /* 188 */ "table_reference_list", + /* 189 */ "table_reference", + /* 190 */ "table_primary", + /* 191 */ "joined_table", + /* 192 */ "alias_opt", + /* 193 */ "parenthesized_joined_table", + /* 194 */ "join_type", + /* 195 */ "search_condition", + /* 196 */ "query_specification", + /* 197 */ "set_quantifier_opt", + /* 198 */ "select_list", + /* 199 */ "where_clause_opt", + /* 200 */ "partition_by_clause_opt", + /* 201 */ "twindow_clause_opt", + /* 202 */ "group_by_clause_opt", + /* 203 */ "having_clause_opt", + /* 204 */ "select_sublist", + /* 205 */ "select_item", + /* 206 */ "fill_opt", + /* 207 */ "fill_mode", + /* 208 */ "group_by_list", + /* 209 */ "query_expression_body", + /* 210 */ "order_by_clause_opt", + /* 211 */ "slimit_clause_opt", + /* 212 */ "limit_clause_opt", + /* 213 */ "query_primary", + /* 214 */ "sort_specification_list", + /* 215 */ "sort_specification", + /* 216 */ "ordering_specification_opt", + /* 217 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -860,239 +851,241 @@ static const char *const yyRuleName[] = { /* 10 */ "dnode_endpoint ::= NK_STRING", /* 11 */ "dnode_host_name ::= NK_ID", /* 12 */ "dnode_host_name ::= NK_IPTOKEN", - /* 13 */ "cmd ::= CREATE DATABASE not_exists_opt db_name db_options", - /* 14 */ "cmd ::= DROP DATABASE exists_opt db_name", - /* 15 */ "cmd ::= SHOW DATABASES", - /* 16 */ "cmd ::= USE db_name", - /* 17 */ "not_exists_opt ::= IF NOT EXISTS", - /* 18 */ "not_exists_opt ::=", - /* 19 */ "exists_opt ::= IF EXISTS", - /* 20 */ "exists_opt ::=", - /* 21 */ "db_options ::=", - /* 22 */ "db_options ::= db_options BLOCKS NK_INTEGER", - /* 23 */ "db_options ::= db_options CACHE NK_INTEGER", - /* 24 */ "db_options ::= db_options CACHELAST NK_INTEGER", - /* 25 */ "db_options ::= db_options COMP NK_INTEGER", - /* 26 */ "db_options ::= db_options DAYS NK_INTEGER", - /* 27 */ "db_options ::= db_options FSYNC NK_INTEGER", - /* 28 */ "db_options ::= db_options MAXROWS NK_INTEGER", - /* 29 */ "db_options ::= db_options MINROWS NK_INTEGER", - /* 30 */ "db_options ::= db_options KEEP NK_INTEGER", - /* 31 */ "db_options ::= db_options PRECISION NK_STRING", - /* 32 */ "db_options ::= db_options QUORUM NK_INTEGER", - /* 33 */ "db_options ::= db_options REPLICA NK_INTEGER", - /* 34 */ "db_options ::= db_options TTL NK_INTEGER", - /* 35 */ "db_options ::= db_options WAL NK_INTEGER", - /* 36 */ "db_options ::= db_options VGROUPS NK_INTEGER", - /* 37 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", - /* 38 */ "db_options ::= db_options STREAM_MODE NK_INTEGER", - /* 39 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", - /* 40 */ "cmd ::= CREATE TABLE multi_create_clause", - /* 41 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", - /* 42 */ "cmd ::= DROP TABLE multi_drop_clause", - /* 43 */ "cmd ::= DROP STABLE exists_opt full_table_name", - /* 44 */ "cmd ::= SHOW TABLES", - /* 45 */ "cmd ::= SHOW STABLES", - /* 46 */ "multi_create_clause ::= create_subtable_clause", - /* 47 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 48 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP", - /* 49 */ "multi_drop_clause ::= drop_table_clause", - /* 50 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", - /* 51 */ "drop_table_clause ::= exists_opt full_table_name", - /* 52 */ "specific_tags_opt ::=", - /* 53 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", - /* 54 */ "full_table_name ::= table_name", - /* 55 */ "full_table_name ::= db_name NK_DOT table_name", - /* 56 */ "column_def_list ::= column_def", - /* 57 */ "column_def_list ::= column_def_list NK_COMMA column_def", - /* 58 */ "column_def ::= column_name type_name", - /* 59 */ "column_def ::= column_name type_name COMMENT NK_STRING", - /* 60 */ "type_name ::= BOOL", - /* 61 */ "type_name ::= TINYINT", - /* 62 */ "type_name ::= SMALLINT", - /* 63 */ "type_name ::= INT", - /* 64 */ "type_name ::= INTEGER", - /* 65 */ "type_name ::= BIGINT", - /* 66 */ "type_name ::= FLOAT", - /* 67 */ "type_name ::= DOUBLE", - /* 68 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 69 */ "type_name ::= TIMESTAMP", - /* 70 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 71 */ "type_name ::= TINYINT UNSIGNED", - /* 72 */ "type_name ::= SMALLINT UNSIGNED", - /* 73 */ "type_name ::= INT UNSIGNED", - /* 74 */ "type_name ::= BIGINT UNSIGNED", - /* 75 */ "type_name ::= JSON", - /* 76 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 77 */ "type_name ::= MEDIUMBLOB", - /* 78 */ "type_name ::= BLOB", - /* 79 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 80 */ "type_name ::= DECIMAL", - /* 81 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 82 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 83 */ "tags_def_opt ::=", - /* 84 */ "tags_def_opt ::= tags_def", - /* 85 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", - /* 86 */ "table_options ::=", - /* 87 */ "table_options ::= table_options COMMENT NK_STRING", - /* 88 */ "table_options ::= table_options KEEP NK_INTEGER", - /* 89 */ "table_options ::= table_options TTL NK_INTEGER", - /* 90 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 91 */ "col_name_list ::= col_name", - /* 92 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 93 */ "col_name ::= column_name", - /* 94 */ "cmd ::= CREATE SMA INDEX index_name ON table_name index_options", - /* 95 */ "cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP", - /* 96 */ "index_options ::=", - /* 97 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", - /* 98 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", - /* 99 */ "func_list ::= func", - /* 100 */ "func_list ::= func_list NK_COMMA func", - /* 101 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 102 */ "cmd ::= SHOW VGROUPS", - /* 103 */ "cmd ::= SHOW db_name NK_DOT VGROUPS", - /* 104 */ "cmd ::= SHOW MNODES", - /* 105 */ "cmd ::= query_expression", - /* 106 */ "literal ::= NK_INTEGER", - /* 107 */ "literal ::= NK_FLOAT", - /* 108 */ "literal ::= NK_STRING", - /* 109 */ "literal ::= NK_BOOL", - /* 110 */ "literal ::= TIMESTAMP NK_STRING", - /* 111 */ "literal ::= duration_literal", - /* 112 */ "duration_literal ::= NK_VARIABLE", - /* 113 */ "literal_list ::= literal", - /* 114 */ "literal_list ::= literal_list NK_COMMA literal", - /* 115 */ "db_name ::= NK_ID", - /* 116 */ "table_name ::= NK_ID", - /* 117 */ "column_name ::= NK_ID", - /* 118 */ "function_name ::= NK_ID", - /* 119 */ "table_alias ::= NK_ID", - /* 120 */ "column_alias ::= NK_ID", - /* 121 */ "user_name ::= NK_ID", - /* 122 */ "index_name ::= NK_ID", - /* 123 */ "expression ::= literal", - /* 124 */ "expression ::= column_reference", - /* 125 */ "expression ::= function_name NK_LP expression_list NK_RP", - /* 126 */ "expression ::= function_name NK_LP NK_STAR NK_RP", - /* 127 */ "expression ::= subquery", - /* 128 */ "expression ::= NK_LP expression NK_RP", - /* 129 */ "expression ::= NK_PLUS expression", - /* 130 */ "expression ::= NK_MINUS expression", - /* 131 */ "expression ::= expression NK_PLUS expression", - /* 132 */ "expression ::= expression NK_MINUS expression", - /* 133 */ "expression ::= expression NK_STAR expression", - /* 134 */ "expression ::= expression NK_SLASH expression", - /* 135 */ "expression ::= expression NK_REM expression", - /* 136 */ "expression_list ::= expression", - /* 137 */ "expression_list ::= expression_list NK_COMMA expression", - /* 138 */ "column_reference ::= column_name", - /* 139 */ "column_reference ::= table_name NK_DOT column_name", - /* 140 */ "predicate ::= expression compare_op expression", - /* 141 */ "predicate ::= expression BETWEEN expression AND expression", - /* 142 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 143 */ "predicate ::= expression IS NULL", - /* 144 */ "predicate ::= expression IS NOT NULL", - /* 145 */ "predicate ::= expression in_op in_predicate_value", - /* 146 */ "compare_op ::= NK_LT", - /* 147 */ "compare_op ::= NK_GT", - /* 148 */ "compare_op ::= NK_LE", - /* 149 */ "compare_op ::= NK_GE", - /* 150 */ "compare_op ::= NK_NE", - /* 151 */ "compare_op ::= NK_EQ", - /* 152 */ "compare_op ::= LIKE", - /* 153 */ "compare_op ::= NOT LIKE", - /* 154 */ "compare_op ::= MATCH", - /* 155 */ "compare_op ::= NMATCH", - /* 156 */ "in_op ::= IN", - /* 157 */ "in_op ::= NOT IN", - /* 158 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 159 */ "boolean_value_expression ::= boolean_primary", - /* 160 */ "boolean_value_expression ::= NOT boolean_primary", - /* 161 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 162 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 163 */ "boolean_primary ::= predicate", - /* 164 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 165 */ "common_expression ::= expression", - /* 166 */ "common_expression ::= boolean_value_expression", - /* 167 */ "from_clause ::= FROM table_reference_list", - /* 168 */ "table_reference_list ::= table_reference", - /* 169 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 170 */ "table_reference ::= table_primary", - /* 171 */ "table_reference ::= joined_table", - /* 172 */ "table_primary ::= table_name alias_opt", - /* 173 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 174 */ "table_primary ::= subquery alias_opt", - /* 175 */ "table_primary ::= parenthesized_joined_table", - /* 176 */ "alias_opt ::=", - /* 177 */ "alias_opt ::= table_alias", - /* 178 */ "alias_opt ::= AS table_alias", - /* 179 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 180 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 181 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 182 */ "join_type ::=", - /* 183 */ "join_type ::= INNER", - /* 184 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 185 */ "set_quantifier_opt ::=", - /* 186 */ "set_quantifier_opt ::= DISTINCT", - /* 187 */ "set_quantifier_opt ::= ALL", - /* 188 */ "select_list ::= NK_STAR", - /* 189 */ "select_list ::= select_sublist", - /* 190 */ "select_sublist ::= select_item", - /* 191 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 192 */ "select_item ::= common_expression", - /* 193 */ "select_item ::= common_expression column_alias", - /* 194 */ "select_item ::= common_expression AS column_alias", - /* 195 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 196 */ "where_clause_opt ::=", - /* 197 */ "where_clause_opt ::= WHERE search_condition", - /* 198 */ "partition_by_clause_opt ::=", - /* 199 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 200 */ "twindow_clause_opt ::=", - /* 201 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP", - /* 202 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", - /* 203 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 204 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 205 */ "sliding_opt ::=", - /* 206 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 207 */ "fill_opt ::=", - /* 208 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 209 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 210 */ "fill_mode ::= NONE", - /* 211 */ "fill_mode ::= PREV", - /* 212 */ "fill_mode ::= NULL", - /* 213 */ "fill_mode ::= LINEAR", - /* 214 */ "fill_mode ::= NEXT", - /* 215 */ "group_by_clause_opt ::=", - /* 216 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 217 */ "group_by_list ::= expression", - /* 218 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 219 */ "having_clause_opt ::=", - /* 220 */ "having_clause_opt ::= HAVING search_condition", - /* 221 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 222 */ "query_expression_body ::= query_primary", - /* 223 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 224 */ "query_primary ::= query_specification", - /* 225 */ "order_by_clause_opt ::=", - /* 226 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 227 */ "slimit_clause_opt ::=", - /* 228 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 229 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 230 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 231 */ "limit_clause_opt ::=", - /* 232 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 233 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 234 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 235 */ "subquery ::= NK_LP query_expression NK_RP", - /* 236 */ "search_condition ::= common_expression", - /* 237 */ "sort_specification_list ::= sort_specification", - /* 238 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 239 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 240 */ "ordering_specification_opt ::=", - /* 241 */ "ordering_specification_opt ::= ASC", - /* 242 */ "ordering_specification_opt ::= DESC", - /* 243 */ "null_ordering_opt ::=", - /* 244 */ "null_ordering_opt ::= NULLS FIRST", - /* 245 */ "null_ordering_opt ::= NULLS LAST", + /* 13 */ "cmd ::= CREATE QNODE ON DNODE NK_INTEGER", + /* 14 */ "cmd ::= SHOW QNODES", + /* 15 */ "cmd ::= CREATE DATABASE not_exists_opt db_name db_options", + /* 16 */ "cmd ::= DROP DATABASE exists_opt db_name", + /* 17 */ "cmd ::= SHOW DATABASES", + /* 18 */ "cmd ::= USE db_name", + /* 19 */ "not_exists_opt ::= IF NOT EXISTS", + /* 20 */ "not_exists_opt ::=", + /* 21 */ "exists_opt ::= IF EXISTS", + /* 22 */ "exists_opt ::=", + /* 23 */ "db_options ::=", + /* 24 */ "db_options ::= db_options BLOCKS NK_INTEGER", + /* 25 */ "db_options ::= db_options CACHE NK_INTEGER", + /* 26 */ "db_options ::= db_options CACHELAST NK_INTEGER", + /* 27 */ "db_options ::= db_options COMP NK_INTEGER", + /* 28 */ "db_options ::= db_options DAYS NK_INTEGER", + /* 29 */ "db_options ::= db_options FSYNC NK_INTEGER", + /* 30 */ "db_options ::= db_options MAXROWS NK_INTEGER", + /* 31 */ "db_options ::= db_options MINROWS NK_INTEGER", + /* 32 */ "db_options ::= db_options KEEP NK_INTEGER", + /* 33 */ "db_options ::= db_options PRECISION NK_STRING", + /* 34 */ "db_options ::= db_options QUORUM NK_INTEGER", + /* 35 */ "db_options ::= db_options REPLICA NK_INTEGER", + /* 36 */ "db_options ::= db_options TTL NK_INTEGER", + /* 37 */ "db_options ::= db_options WAL NK_INTEGER", + /* 38 */ "db_options ::= db_options VGROUPS NK_INTEGER", + /* 39 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", + /* 40 */ "db_options ::= db_options STREAM_MODE NK_INTEGER", + /* 41 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", + /* 42 */ "cmd ::= CREATE TABLE multi_create_clause", + /* 43 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", + /* 44 */ "cmd ::= DROP TABLE multi_drop_clause", + /* 45 */ "cmd ::= DROP STABLE exists_opt full_table_name", + /* 46 */ "cmd ::= SHOW TABLES", + /* 47 */ "cmd ::= SHOW STABLES", + /* 48 */ "multi_create_clause ::= create_subtable_clause", + /* 49 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", + /* 50 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP", + /* 51 */ "multi_drop_clause ::= drop_table_clause", + /* 52 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", + /* 53 */ "drop_table_clause ::= exists_opt full_table_name", + /* 54 */ "specific_tags_opt ::=", + /* 55 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", + /* 56 */ "full_table_name ::= table_name", + /* 57 */ "full_table_name ::= db_name NK_DOT table_name", + /* 58 */ "column_def_list ::= column_def", + /* 59 */ "column_def_list ::= column_def_list NK_COMMA column_def", + /* 60 */ "column_def ::= column_name type_name", + /* 61 */ "column_def ::= column_name type_name COMMENT NK_STRING", + /* 62 */ "type_name ::= BOOL", + /* 63 */ "type_name ::= TINYINT", + /* 64 */ "type_name ::= SMALLINT", + /* 65 */ "type_name ::= INT", + /* 66 */ "type_name ::= INTEGER", + /* 67 */ "type_name ::= BIGINT", + /* 68 */ "type_name ::= FLOAT", + /* 69 */ "type_name ::= DOUBLE", + /* 70 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", + /* 71 */ "type_name ::= TIMESTAMP", + /* 72 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", + /* 73 */ "type_name ::= TINYINT UNSIGNED", + /* 74 */ "type_name ::= SMALLINT UNSIGNED", + /* 75 */ "type_name ::= INT UNSIGNED", + /* 76 */ "type_name ::= BIGINT UNSIGNED", + /* 77 */ "type_name ::= JSON", + /* 78 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", + /* 79 */ "type_name ::= MEDIUMBLOB", + /* 80 */ "type_name ::= BLOB", + /* 81 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", + /* 82 */ "type_name ::= DECIMAL", + /* 83 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", + /* 84 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 85 */ "tags_def_opt ::=", + /* 86 */ "tags_def_opt ::= tags_def", + /* 87 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", + /* 88 */ "table_options ::=", + /* 89 */ "table_options ::= table_options COMMENT NK_STRING", + /* 90 */ "table_options ::= table_options KEEP NK_INTEGER", + /* 91 */ "table_options ::= table_options TTL NK_INTEGER", + /* 92 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 93 */ "col_name_list ::= col_name", + /* 94 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 95 */ "col_name ::= column_name", + /* 96 */ "cmd ::= CREATE SMA INDEX index_name ON table_name index_options", + /* 97 */ "cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP", + /* 98 */ "index_options ::=", + /* 99 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", + /* 100 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", + /* 101 */ "func_list ::= func", + /* 102 */ "func_list ::= func_list NK_COMMA func", + /* 103 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 104 */ "cmd ::= SHOW VGROUPS", + /* 105 */ "cmd ::= SHOW db_name NK_DOT VGROUPS", + /* 106 */ "cmd ::= SHOW MNODES", + /* 107 */ "cmd ::= query_expression", + /* 108 */ "literal ::= NK_INTEGER", + /* 109 */ "literal ::= NK_FLOAT", + /* 110 */ "literal ::= NK_STRING", + /* 111 */ "literal ::= NK_BOOL", + /* 112 */ "literal ::= TIMESTAMP NK_STRING", + /* 113 */ "literal ::= duration_literal", + /* 114 */ "duration_literal ::= NK_VARIABLE", + /* 115 */ "literal_list ::= literal", + /* 116 */ "literal_list ::= literal_list NK_COMMA literal", + /* 117 */ "db_name ::= NK_ID", + /* 118 */ "table_name ::= NK_ID", + /* 119 */ "column_name ::= NK_ID", + /* 120 */ "function_name ::= NK_ID", + /* 121 */ "table_alias ::= NK_ID", + /* 122 */ "column_alias ::= NK_ID", + /* 123 */ "user_name ::= NK_ID", + /* 124 */ "index_name ::= NK_ID", + /* 125 */ "expression ::= literal", + /* 126 */ "expression ::= column_reference", + /* 127 */ "expression ::= function_name NK_LP expression_list NK_RP", + /* 128 */ "expression ::= function_name NK_LP NK_STAR NK_RP", + /* 129 */ "expression ::= subquery", + /* 130 */ "expression ::= NK_LP expression NK_RP", + /* 131 */ "expression ::= NK_PLUS expression", + /* 132 */ "expression ::= NK_MINUS expression", + /* 133 */ "expression ::= expression NK_PLUS expression", + /* 134 */ "expression ::= expression NK_MINUS expression", + /* 135 */ "expression ::= expression NK_STAR expression", + /* 136 */ "expression ::= expression NK_SLASH expression", + /* 137 */ "expression ::= expression NK_REM expression", + /* 138 */ "expression_list ::= expression", + /* 139 */ "expression_list ::= expression_list NK_COMMA expression", + /* 140 */ "column_reference ::= column_name", + /* 141 */ "column_reference ::= table_name NK_DOT column_name", + /* 142 */ "predicate ::= expression compare_op expression", + /* 143 */ "predicate ::= expression BETWEEN expression AND expression", + /* 144 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 145 */ "predicate ::= expression IS NULL", + /* 146 */ "predicate ::= expression IS NOT NULL", + /* 147 */ "predicate ::= expression in_op in_predicate_value", + /* 148 */ "compare_op ::= NK_LT", + /* 149 */ "compare_op ::= NK_GT", + /* 150 */ "compare_op ::= NK_LE", + /* 151 */ "compare_op ::= NK_GE", + /* 152 */ "compare_op ::= NK_NE", + /* 153 */ "compare_op ::= NK_EQ", + /* 154 */ "compare_op ::= LIKE", + /* 155 */ "compare_op ::= NOT LIKE", + /* 156 */ "compare_op ::= MATCH", + /* 157 */ "compare_op ::= NMATCH", + /* 158 */ "in_op ::= IN", + /* 159 */ "in_op ::= NOT IN", + /* 160 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 161 */ "boolean_value_expression ::= boolean_primary", + /* 162 */ "boolean_value_expression ::= NOT boolean_primary", + /* 163 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 164 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 165 */ "boolean_primary ::= predicate", + /* 166 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 167 */ "common_expression ::= expression", + /* 168 */ "common_expression ::= boolean_value_expression", + /* 169 */ "from_clause ::= FROM table_reference_list", + /* 170 */ "table_reference_list ::= table_reference", + /* 171 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 172 */ "table_reference ::= table_primary", + /* 173 */ "table_reference ::= joined_table", + /* 174 */ "table_primary ::= table_name alias_opt", + /* 175 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 176 */ "table_primary ::= subquery alias_opt", + /* 177 */ "table_primary ::= parenthesized_joined_table", + /* 178 */ "alias_opt ::=", + /* 179 */ "alias_opt ::= table_alias", + /* 180 */ "alias_opt ::= AS table_alias", + /* 181 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 182 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 183 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 184 */ "join_type ::=", + /* 185 */ "join_type ::= INNER", + /* 186 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 187 */ "set_quantifier_opt ::=", + /* 188 */ "set_quantifier_opt ::= DISTINCT", + /* 189 */ "set_quantifier_opt ::= ALL", + /* 190 */ "select_list ::= NK_STAR", + /* 191 */ "select_list ::= select_sublist", + /* 192 */ "select_sublist ::= select_item", + /* 193 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 194 */ "select_item ::= common_expression", + /* 195 */ "select_item ::= common_expression column_alias", + /* 196 */ "select_item ::= common_expression AS column_alias", + /* 197 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 198 */ "where_clause_opt ::=", + /* 199 */ "where_clause_opt ::= WHERE search_condition", + /* 200 */ "partition_by_clause_opt ::=", + /* 201 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 202 */ "twindow_clause_opt ::=", + /* 203 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP", + /* 204 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", + /* 205 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 206 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 207 */ "sliding_opt ::=", + /* 208 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 209 */ "fill_opt ::=", + /* 210 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 211 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 212 */ "fill_mode ::= NONE", + /* 213 */ "fill_mode ::= PREV", + /* 214 */ "fill_mode ::= NULL", + /* 215 */ "fill_mode ::= LINEAR", + /* 216 */ "fill_mode ::= NEXT", + /* 217 */ "group_by_clause_opt ::=", + /* 218 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 219 */ "group_by_list ::= expression", + /* 220 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 221 */ "having_clause_opt ::=", + /* 222 */ "having_clause_opt ::= HAVING search_condition", + /* 223 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 224 */ "query_expression_body ::= query_primary", + /* 225 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 226 */ "query_primary ::= query_specification", + /* 227 */ "order_by_clause_opt ::=", + /* 228 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 229 */ "slimit_clause_opt ::=", + /* 230 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 231 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 232 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 233 */ "limit_clause_opt ::=", + /* 234 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 235 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 236 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 237 */ "subquery ::= NK_LP query_expression NK_RP", + /* 238 */ "search_condition ::= common_expression", + /* 239 */ "sort_specification_list ::= sort_specification", + /* 240 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 241 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 242 */ "ordering_specification_opt ::=", + /* 243 */ "ordering_specification_opt ::= ASC", + /* 244 */ "ordering_specification_opt ::= DESC", + /* 245 */ "null_ordering_opt ::=", + /* 246 */ "null_ordering_opt ::= NULLS FIRST", + /* 247 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -1219,120 +1212,120 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 138: /* cmd */ - case 144: /* db_options */ - case 146: /* full_table_name */ - case 149: /* table_options */ - case 153: /* create_subtable_clause */ - case 156: /* drop_table_clause */ - case 159: /* column_def */ - case 162: /* col_name */ - case 164: /* index_options */ - case 166: /* duration_literal */ - case 167: /* sliding_opt */ - case 168: /* func */ - case 171: /* query_expression */ - case 172: /* literal */ - case 175: /* expression */ - case 176: /* column_reference */ - case 177: /* subquery */ - case 178: /* predicate */ - case 181: /* in_predicate_value */ - case 182: /* boolean_value_expression */ - case 183: /* boolean_primary */ - case 184: /* common_expression */ - case 185: /* from_clause */ - case 186: /* table_reference_list */ - case 187: /* table_reference */ - case 188: /* table_primary */ - case 189: /* joined_table */ - case 191: /* parenthesized_joined_table */ - case 193: /* search_condition */ - case 194: /* query_specification */ - case 197: /* where_clause_opt */ - case 199: /* twindow_clause_opt */ - case 201: /* having_clause_opt */ - case 203: /* select_item */ - case 204: /* fill_opt */ - case 207: /* query_expression_body */ - case 209: /* slimit_clause_opt */ - case 210: /* limit_clause_opt */ - case 211: /* query_primary */ - case 213: /* sort_specification */ + case 140: /* cmd */ + case 146: /* db_options */ + case 148: /* full_table_name */ + case 151: /* table_options */ + case 155: /* create_subtable_clause */ + case 158: /* drop_table_clause */ + case 161: /* column_def */ + case 164: /* col_name */ + case 166: /* index_options */ + case 168: /* duration_literal */ + case 169: /* sliding_opt */ + case 170: /* func */ + case 173: /* query_expression */ + case 174: /* literal */ + case 177: /* expression */ + case 178: /* column_reference */ + case 179: /* subquery */ + case 180: /* predicate */ + case 183: /* in_predicate_value */ + case 184: /* boolean_value_expression */ + case 185: /* boolean_primary */ + case 186: /* common_expression */ + case 187: /* from_clause */ + case 188: /* table_reference_list */ + case 189: /* table_reference */ + case 190: /* table_primary */ + case 191: /* joined_table */ + case 193: /* parenthesized_joined_table */ + case 195: /* search_condition */ + case 196: /* query_specification */ + case 199: /* where_clause_opt */ + case 201: /* twindow_clause_opt */ + case 203: /* having_clause_opt */ + case 205: /* select_item */ + case 206: /* fill_opt */ + case 209: /* query_expression_body */ + case 211: /* slimit_clause_opt */ + case 212: /* limit_clause_opt */ + case 213: /* query_primary */ + case 215: /* sort_specification */ { - nodesDestroyNode((yypminor->yy344)); + nodesDestroyNode((yypminor->yy68)); } break; - case 139: /* user_name */ - case 140: /* dnode_endpoint */ - case 141: /* dnode_host_name */ - case 143: /* db_name */ - case 158: /* table_name */ - case 160: /* column_name */ - case 163: /* index_name */ - case 169: /* function_name */ - case 173: /* table_alias */ - case 174: /* column_alias */ - case 190: /* alias_opt */ + case 141: /* user_name */ + case 142: /* dnode_endpoint */ + case 143: /* dnode_host_name */ + case 145: /* db_name */ + case 160: /* table_name */ + case 162: /* column_name */ + case 165: /* index_name */ + case 171: /* function_name */ + case 175: /* table_alias */ + case 176: /* column_alias */ + case 192: /* alias_opt */ { } break; - case 142: /* not_exists_opt */ - case 145: /* exists_opt */ - case 195: /* set_quantifier_opt */ + case 144: /* not_exists_opt */ + case 147: /* exists_opt */ + case 197: /* set_quantifier_opt */ { } break; - case 147: /* column_def_list */ - case 148: /* tags_def_opt */ - case 150: /* multi_create_clause */ - case 151: /* tags_def */ - case 152: /* multi_drop_clause */ - case 154: /* specific_tags_opt */ - case 155: /* literal_list */ - case 157: /* col_name_list */ - case 165: /* func_list */ - case 170: /* expression_list */ - case 196: /* select_list */ - case 198: /* partition_by_clause_opt */ - case 200: /* group_by_clause_opt */ - case 202: /* select_sublist */ - case 206: /* group_by_list */ - case 208: /* order_by_clause_opt */ - case 212: /* sort_specification_list */ + case 149: /* column_def_list */ + case 150: /* tags_def_opt */ + case 152: /* multi_create_clause */ + case 153: /* tags_def */ + case 154: /* multi_drop_clause */ + case 156: /* specific_tags_opt */ + case 157: /* literal_list */ + case 159: /* col_name_list */ + case 167: /* func_list */ + case 172: /* expression_list */ + case 198: /* select_list */ + case 200: /* partition_by_clause_opt */ + case 202: /* group_by_clause_opt */ + case 204: /* select_sublist */ + case 208: /* group_by_list */ + case 210: /* order_by_clause_opt */ + case 214: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy280)); + nodesDestroyList((yypminor->yy40)); } break; - case 161: /* type_name */ + case 163: /* type_name */ { } break; - case 179: /* compare_op */ - case 180: /* in_op */ + case 181: /* compare_op */ + case 182: /* in_op */ { } break; - case 192: /* join_type */ + case 194: /* join_type */ { } break; - case 205: /* fill_mode */ + case 207: /* fill_mode */ { } break; - case 214: /* ordering_specification_opt */ + case 216: /* ordering_specification_opt */ { } break; - case 215: /* null_ordering_opt */ + case 217: /* null_ordering_opt */ { } @@ -1631,252 +1624,254 @@ static const struct { YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ signed char nrhs; /* Negative of the number of RHS symbols in the rule */ } yyRuleInfo[] = { - { 138, -5 }, /* (0) cmd ::= CREATE USER user_name PASS NK_STRING */ - { 138, -5 }, /* (1) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 138, -5 }, /* (2) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ - { 138, -3 }, /* (3) cmd ::= DROP USER user_name */ - { 138, -2 }, /* (4) cmd ::= SHOW USERS */ - { 138, -3 }, /* (5) cmd ::= CREATE DNODE dnode_endpoint */ - { 138, -5 }, /* (6) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ - { 138, -3 }, /* (7) cmd ::= DROP DNODE NK_INTEGER */ - { 138, -3 }, /* (8) cmd ::= DROP DNODE dnode_endpoint */ - { 138, -2 }, /* (9) cmd ::= SHOW DNODES */ - { 140, -1 }, /* (10) dnode_endpoint ::= NK_STRING */ - { 141, -1 }, /* (11) dnode_host_name ::= NK_ID */ - { 141, -1 }, /* (12) dnode_host_name ::= NK_IPTOKEN */ - { 138, -5 }, /* (13) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 138, -4 }, /* (14) cmd ::= DROP DATABASE exists_opt db_name */ - { 138, -2 }, /* (15) cmd ::= SHOW DATABASES */ - { 138, -2 }, /* (16) cmd ::= USE db_name */ - { 142, -3 }, /* (17) not_exists_opt ::= IF NOT EXISTS */ - { 142, 0 }, /* (18) not_exists_opt ::= */ - { 145, -2 }, /* (19) exists_opt ::= IF EXISTS */ - { 145, 0 }, /* (20) exists_opt ::= */ - { 144, 0 }, /* (21) db_options ::= */ - { 144, -3 }, /* (22) db_options ::= db_options BLOCKS NK_INTEGER */ - { 144, -3 }, /* (23) db_options ::= db_options CACHE NK_INTEGER */ - { 144, -3 }, /* (24) db_options ::= db_options CACHELAST NK_INTEGER */ - { 144, -3 }, /* (25) db_options ::= db_options COMP NK_INTEGER */ - { 144, -3 }, /* (26) db_options ::= db_options DAYS NK_INTEGER */ - { 144, -3 }, /* (27) db_options ::= db_options FSYNC NK_INTEGER */ - { 144, -3 }, /* (28) db_options ::= db_options MAXROWS NK_INTEGER */ - { 144, -3 }, /* (29) db_options ::= db_options MINROWS NK_INTEGER */ - { 144, -3 }, /* (30) db_options ::= db_options KEEP NK_INTEGER */ - { 144, -3 }, /* (31) db_options ::= db_options PRECISION NK_STRING */ - { 144, -3 }, /* (32) db_options ::= db_options QUORUM NK_INTEGER */ - { 144, -3 }, /* (33) db_options ::= db_options REPLICA NK_INTEGER */ - { 144, -3 }, /* (34) db_options ::= db_options TTL NK_INTEGER */ - { 144, -3 }, /* (35) db_options ::= db_options WAL NK_INTEGER */ - { 144, -3 }, /* (36) db_options ::= db_options VGROUPS NK_INTEGER */ - { 144, -3 }, /* (37) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 144, -3 }, /* (38) db_options ::= db_options STREAM_MODE NK_INTEGER */ - { 138, -9 }, /* (39) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 138, -3 }, /* (40) cmd ::= CREATE TABLE multi_create_clause */ - { 138, -9 }, /* (41) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 138, -3 }, /* (42) cmd ::= DROP TABLE multi_drop_clause */ - { 138, -4 }, /* (43) cmd ::= DROP STABLE exists_opt full_table_name */ - { 138, -2 }, /* (44) cmd ::= SHOW TABLES */ - { 138, -2 }, /* (45) cmd ::= SHOW STABLES */ - { 150, -1 }, /* (46) multi_create_clause ::= create_subtable_clause */ - { 150, -2 }, /* (47) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 153, -9 }, /* (48) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ - { 152, -1 }, /* (49) multi_drop_clause ::= drop_table_clause */ - { 152, -2 }, /* (50) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 156, -2 }, /* (51) drop_table_clause ::= exists_opt full_table_name */ - { 154, 0 }, /* (52) specific_tags_opt ::= */ - { 154, -3 }, /* (53) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - { 146, -1 }, /* (54) full_table_name ::= table_name */ - { 146, -3 }, /* (55) full_table_name ::= db_name NK_DOT table_name */ - { 147, -1 }, /* (56) column_def_list ::= column_def */ - { 147, -3 }, /* (57) column_def_list ::= column_def_list NK_COMMA column_def */ - { 159, -2 }, /* (58) column_def ::= column_name type_name */ - { 159, -4 }, /* (59) column_def ::= column_name type_name COMMENT NK_STRING */ - { 161, -1 }, /* (60) type_name ::= BOOL */ - { 161, -1 }, /* (61) type_name ::= TINYINT */ - { 161, -1 }, /* (62) type_name ::= SMALLINT */ - { 161, -1 }, /* (63) type_name ::= INT */ - { 161, -1 }, /* (64) type_name ::= INTEGER */ - { 161, -1 }, /* (65) type_name ::= BIGINT */ - { 161, -1 }, /* (66) type_name ::= FLOAT */ - { 161, -1 }, /* (67) type_name ::= DOUBLE */ - { 161, -4 }, /* (68) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 161, -1 }, /* (69) type_name ::= TIMESTAMP */ - { 161, -4 }, /* (70) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 161, -2 }, /* (71) type_name ::= TINYINT UNSIGNED */ - { 161, -2 }, /* (72) type_name ::= SMALLINT UNSIGNED */ - { 161, -2 }, /* (73) type_name ::= INT UNSIGNED */ - { 161, -2 }, /* (74) type_name ::= BIGINT UNSIGNED */ - { 161, -1 }, /* (75) type_name ::= JSON */ - { 161, -4 }, /* (76) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 161, -1 }, /* (77) type_name ::= MEDIUMBLOB */ - { 161, -1 }, /* (78) type_name ::= BLOB */ - { 161, -4 }, /* (79) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 161, -1 }, /* (80) type_name ::= DECIMAL */ - { 161, -4 }, /* (81) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 161, -6 }, /* (82) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 148, 0 }, /* (83) tags_def_opt ::= */ - { 148, -1 }, /* (84) tags_def_opt ::= tags_def */ - { 151, -4 }, /* (85) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 149, 0 }, /* (86) table_options ::= */ - { 149, -3 }, /* (87) table_options ::= table_options COMMENT NK_STRING */ - { 149, -3 }, /* (88) table_options ::= table_options KEEP NK_INTEGER */ - { 149, -3 }, /* (89) table_options ::= table_options TTL NK_INTEGER */ - { 149, -5 }, /* (90) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 157, -1 }, /* (91) col_name_list ::= col_name */ - { 157, -3 }, /* (92) col_name_list ::= col_name_list NK_COMMA col_name */ - { 162, -1 }, /* (93) col_name ::= column_name */ - { 138, -7 }, /* (94) cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ - { 138, -9 }, /* (95) cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ - { 164, 0 }, /* (96) index_options ::= */ - { 164, -9 }, /* (97) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ - { 164, -11 }, /* (98) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ - { 165, -1 }, /* (99) func_list ::= func */ - { 165, -3 }, /* (100) func_list ::= func_list NK_COMMA func */ - { 168, -4 }, /* (101) func ::= function_name NK_LP expression_list NK_RP */ - { 138, -2 }, /* (102) cmd ::= SHOW VGROUPS */ - { 138, -4 }, /* (103) cmd ::= SHOW db_name NK_DOT VGROUPS */ - { 138, -2 }, /* (104) cmd ::= SHOW MNODES */ - { 138, -1 }, /* (105) cmd ::= query_expression */ - { 172, -1 }, /* (106) literal ::= NK_INTEGER */ - { 172, -1 }, /* (107) literal ::= NK_FLOAT */ - { 172, -1 }, /* (108) literal ::= NK_STRING */ - { 172, -1 }, /* (109) literal ::= NK_BOOL */ - { 172, -2 }, /* (110) literal ::= TIMESTAMP NK_STRING */ - { 172, -1 }, /* (111) literal ::= duration_literal */ - { 166, -1 }, /* (112) duration_literal ::= NK_VARIABLE */ - { 155, -1 }, /* (113) literal_list ::= literal */ - { 155, -3 }, /* (114) literal_list ::= literal_list NK_COMMA literal */ - { 143, -1 }, /* (115) db_name ::= NK_ID */ - { 158, -1 }, /* (116) table_name ::= NK_ID */ - { 160, -1 }, /* (117) column_name ::= NK_ID */ - { 169, -1 }, /* (118) function_name ::= NK_ID */ - { 173, -1 }, /* (119) table_alias ::= NK_ID */ - { 174, -1 }, /* (120) column_alias ::= NK_ID */ - { 139, -1 }, /* (121) user_name ::= NK_ID */ - { 163, -1 }, /* (122) index_name ::= NK_ID */ - { 175, -1 }, /* (123) expression ::= literal */ - { 175, -1 }, /* (124) expression ::= column_reference */ - { 175, -4 }, /* (125) expression ::= function_name NK_LP expression_list NK_RP */ - { 175, -4 }, /* (126) expression ::= function_name NK_LP NK_STAR NK_RP */ - { 175, -1 }, /* (127) expression ::= subquery */ - { 175, -3 }, /* (128) expression ::= NK_LP expression NK_RP */ - { 175, -2 }, /* (129) expression ::= NK_PLUS expression */ - { 175, -2 }, /* (130) expression ::= NK_MINUS expression */ - { 175, -3 }, /* (131) expression ::= expression NK_PLUS expression */ - { 175, -3 }, /* (132) expression ::= expression NK_MINUS expression */ - { 175, -3 }, /* (133) expression ::= expression NK_STAR expression */ - { 175, -3 }, /* (134) expression ::= expression NK_SLASH expression */ - { 175, -3 }, /* (135) expression ::= expression NK_REM expression */ - { 170, -1 }, /* (136) expression_list ::= expression */ - { 170, -3 }, /* (137) expression_list ::= expression_list NK_COMMA expression */ - { 176, -1 }, /* (138) column_reference ::= column_name */ - { 176, -3 }, /* (139) column_reference ::= table_name NK_DOT column_name */ - { 178, -3 }, /* (140) predicate ::= expression compare_op expression */ - { 178, -5 }, /* (141) predicate ::= expression BETWEEN expression AND expression */ - { 178, -6 }, /* (142) predicate ::= expression NOT BETWEEN expression AND expression */ - { 178, -3 }, /* (143) predicate ::= expression IS NULL */ - { 178, -4 }, /* (144) predicate ::= expression IS NOT NULL */ - { 178, -3 }, /* (145) predicate ::= expression in_op in_predicate_value */ - { 179, -1 }, /* (146) compare_op ::= NK_LT */ - { 179, -1 }, /* (147) compare_op ::= NK_GT */ - { 179, -1 }, /* (148) compare_op ::= NK_LE */ - { 179, -1 }, /* (149) compare_op ::= NK_GE */ - { 179, -1 }, /* (150) compare_op ::= NK_NE */ - { 179, -1 }, /* (151) compare_op ::= NK_EQ */ - { 179, -1 }, /* (152) compare_op ::= LIKE */ - { 179, -2 }, /* (153) compare_op ::= NOT LIKE */ - { 179, -1 }, /* (154) compare_op ::= MATCH */ - { 179, -1 }, /* (155) compare_op ::= NMATCH */ - { 180, -1 }, /* (156) in_op ::= IN */ - { 180, -2 }, /* (157) in_op ::= NOT IN */ - { 181, -3 }, /* (158) in_predicate_value ::= NK_LP expression_list NK_RP */ - { 182, -1 }, /* (159) boolean_value_expression ::= boolean_primary */ - { 182, -2 }, /* (160) boolean_value_expression ::= NOT boolean_primary */ - { 182, -3 }, /* (161) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 182, -3 }, /* (162) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 183, -1 }, /* (163) boolean_primary ::= predicate */ - { 183, -3 }, /* (164) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 184, -1 }, /* (165) common_expression ::= expression */ - { 184, -1 }, /* (166) common_expression ::= boolean_value_expression */ - { 185, -2 }, /* (167) from_clause ::= FROM table_reference_list */ - { 186, -1 }, /* (168) table_reference_list ::= table_reference */ - { 186, -3 }, /* (169) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 187, -1 }, /* (170) table_reference ::= table_primary */ - { 187, -1 }, /* (171) table_reference ::= joined_table */ - { 188, -2 }, /* (172) table_primary ::= table_name alias_opt */ - { 188, -4 }, /* (173) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 188, -2 }, /* (174) table_primary ::= subquery alias_opt */ - { 188, -1 }, /* (175) table_primary ::= parenthesized_joined_table */ - { 190, 0 }, /* (176) alias_opt ::= */ - { 190, -1 }, /* (177) alias_opt ::= table_alias */ - { 190, -2 }, /* (178) alias_opt ::= AS table_alias */ - { 191, -3 }, /* (179) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 191, -3 }, /* (180) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 189, -6 }, /* (181) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 192, 0 }, /* (182) join_type ::= */ - { 192, -1 }, /* (183) join_type ::= INNER */ - { 194, -9 }, /* (184) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - { 195, 0 }, /* (185) set_quantifier_opt ::= */ - { 195, -1 }, /* (186) set_quantifier_opt ::= DISTINCT */ - { 195, -1 }, /* (187) set_quantifier_opt ::= ALL */ - { 196, -1 }, /* (188) select_list ::= NK_STAR */ - { 196, -1 }, /* (189) select_list ::= select_sublist */ - { 202, -1 }, /* (190) select_sublist ::= select_item */ - { 202, -3 }, /* (191) select_sublist ::= select_sublist NK_COMMA select_item */ - { 203, -1 }, /* (192) select_item ::= common_expression */ - { 203, -2 }, /* (193) select_item ::= common_expression column_alias */ - { 203, -3 }, /* (194) select_item ::= common_expression AS column_alias */ - { 203, -3 }, /* (195) select_item ::= table_name NK_DOT NK_STAR */ - { 197, 0 }, /* (196) where_clause_opt ::= */ - { 197, -2 }, /* (197) where_clause_opt ::= WHERE search_condition */ - { 198, 0 }, /* (198) partition_by_clause_opt ::= */ - { 198, -3 }, /* (199) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 199, 0 }, /* (200) twindow_clause_opt ::= */ - { 199, -6 }, /* (201) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ - { 199, -4 }, /* (202) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ - { 199, -6 }, /* (203) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 199, -8 }, /* (204) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 167, 0 }, /* (205) sliding_opt ::= */ - { 167, -4 }, /* (206) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 204, 0 }, /* (207) fill_opt ::= */ - { 204, -4 }, /* (208) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 204, -6 }, /* (209) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 205, -1 }, /* (210) fill_mode ::= NONE */ - { 205, -1 }, /* (211) fill_mode ::= PREV */ - { 205, -1 }, /* (212) fill_mode ::= NULL */ - { 205, -1 }, /* (213) fill_mode ::= LINEAR */ - { 205, -1 }, /* (214) fill_mode ::= NEXT */ - { 200, 0 }, /* (215) group_by_clause_opt ::= */ - { 200, -3 }, /* (216) group_by_clause_opt ::= GROUP BY group_by_list */ - { 206, -1 }, /* (217) group_by_list ::= expression */ - { 206, -3 }, /* (218) group_by_list ::= group_by_list NK_COMMA expression */ - { 201, 0 }, /* (219) having_clause_opt ::= */ - { 201, -2 }, /* (220) having_clause_opt ::= HAVING search_condition */ - { 171, -4 }, /* (221) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 207, -1 }, /* (222) query_expression_body ::= query_primary */ - { 207, -4 }, /* (223) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 211, -1 }, /* (224) query_primary ::= query_specification */ - { 208, 0 }, /* (225) order_by_clause_opt ::= */ - { 208, -3 }, /* (226) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 209, 0 }, /* (227) slimit_clause_opt ::= */ - { 209, -2 }, /* (228) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 209, -4 }, /* (229) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 209, -4 }, /* (230) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 210, 0 }, /* (231) limit_clause_opt ::= */ - { 210, -2 }, /* (232) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 210, -4 }, /* (233) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 210, -4 }, /* (234) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 177, -3 }, /* (235) subquery ::= NK_LP query_expression NK_RP */ - { 193, -1 }, /* (236) search_condition ::= common_expression */ - { 212, -1 }, /* (237) sort_specification_list ::= sort_specification */ - { 212, -3 }, /* (238) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 213, -3 }, /* (239) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 214, 0 }, /* (240) ordering_specification_opt ::= */ - { 214, -1 }, /* (241) ordering_specification_opt ::= ASC */ - { 214, -1 }, /* (242) ordering_specification_opt ::= DESC */ - { 215, 0 }, /* (243) null_ordering_opt ::= */ - { 215, -2 }, /* (244) null_ordering_opt ::= NULLS FIRST */ - { 215, -2 }, /* (245) null_ordering_opt ::= NULLS LAST */ + { 140, -5 }, /* (0) cmd ::= CREATE USER user_name PASS NK_STRING */ + { 140, -5 }, /* (1) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 140, -5 }, /* (2) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ + { 140, -3 }, /* (3) cmd ::= DROP USER user_name */ + { 140, -2 }, /* (4) cmd ::= SHOW USERS */ + { 140, -3 }, /* (5) cmd ::= CREATE DNODE dnode_endpoint */ + { 140, -5 }, /* (6) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ + { 140, -3 }, /* (7) cmd ::= DROP DNODE NK_INTEGER */ + { 140, -3 }, /* (8) cmd ::= DROP DNODE dnode_endpoint */ + { 140, -2 }, /* (9) cmd ::= SHOW DNODES */ + { 142, -1 }, /* (10) dnode_endpoint ::= NK_STRING */ + { 143, -1 }, /* (11) dnode_host_name ::= NK_ID */ + { 143, -1 }, /* (12) dnode_host_name ::= NK_IPTOKEN */ + { 140, -5 }, /* (13) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 140, -2 }, /* (14) cmd ::= SHOW QNODES */ + { 140, -5 }, /* (15) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 140, -4 }, /* (16) cmd ::= DROP DATABASE exists_opt db_name */ + { 140, -2 }, /* (17) cmd ::= SHOW DATABASES */ + { 140, -2 }, /* (18) cmd ::= USE db_name */ + { 144, -3 }, /* (19) not_exists_opt ::= IF NOT EXISTS */ + { 144, 0 }, /* (20) not_exists_opt ::= */ + { 147, -2 }, /* (21) exists_opt ::= IF EXISTS */ + { 147, 0 }, /* (22) exists_opt ::= */ + { 146, 0 }, /* (23) db_options ::= */ + { 146, -3 }, /* (24) db_options ::= db_options BLOCKS NK_INTEGER */ + { 146, -3 }, /* (25) db_options ::= db_options CACHE NK_INTEGER */ + { 146, -3 }, /* (26) db_options ::= db_options CACHELAST NK_INTEGER */ + { 146, -3 }, /* (27) db_options ::= db_options COMP NK_INTEGER */ + { 146, -3 }, /* (28) db_options ::= db_options DAYS NK_INTEGER */ + { 146, -3 }, /* (29) db_options ::= db_options FSYNC NK_INTEGER */ + { 146, -3 }, /* (30) db_options ::= db_options MAXROWS NK_INTEGER */ + { 146, -3 }, /* (31) db_options ::= db_options MINROWS NK_INTEGER */ + { 146, -3 }, /* (32) db_options ::= db_options KEEP NK_INTEGER */ + { 146, -3 }, /* (33) db_options ::= db_options PRECISION NK_STRING */ + { 146, -3 }, /* (34) db_options ::= db_options QUORUM NK_INTEGER */ + { 146, -3 }, /* (35) db_options ::= db_options REPLICA NK_INTEGER */ + { 146, -3 }, /* (36) db_options ::= db_options TTL NK_INTEGER */ + { 146, -3 }, /* (37) db_options ::= db_options WAL NK_INTEGER */ + { 146, -3 }, /* (38) db_options ::= db_options VGROUPS NK_INTEGER */ + { 146, -3 }, /* (39) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 146, -3 }, /* (40) db_options ::= db_options STREAM_MODE NK_INTEGER */ + { 140, -9 }, /* (41) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 140, -3 }, /* (42) cmd ::= CREATE TABLE multi_create_clause */ + { 140, -9 }, /* (43) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 140, -3 }, /* (44) cmd ::= DROP TABLE multi_drop_clause */ + { 140, -4 }, /* (45) cmd ::= DROP STABLE exists_opt full_table_name */ + { 140, -2 }, /* (46) cmd ::= SHOW TABLES */ + { 140, -2 }, /* (47) cmd ::= SHOW STABLES */ + { 152, -1 }, /* (48) multi_create_clause ::= create_subtable_clause */ + { 152, -2 }, /* (49) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 155, -9 }, /* (50) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ + { 154, -1 }, /* (51) multi_drop_clause ::= drop_table_clause */ + { 154, -2 }, /* (52) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 158, -2 }, /* (53) drop_table_clause ::= exists_opt full_table_name */ + { 156, 0 }, /* (54) specific_tags_opt ::= */ + { 156, -3 }, /* (55) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + { 148, -1 }, /* (56) full_table_name ::= table_name */ + { 148, -3 }, /* (57) full_table_name ::= db_name NK_DOT table_name */ + { 149, -1 }, /* (58) column_def_list ::= column_def */ + { 149, -3 }, /* (59) column_def_list ::= column_def_list NK_COMMA column_def */ + { 161, -2 }, /* (60) column_def ::= column_name type_name */ + { 161, -4 }, /* (61) column_def ::= column_name type_name COMMENT NK_STRING */ + { 163, -1 }, /* (62) type_name ::= BOOL */ + { 163, -1 }, /* (63) type_name ::= TINYINT */ + { 163, -1 }, /* (64) type_name ::= SMALLINT */ + { 163, -1 }, /* (65) type_name ::= INT */ + { 163, -1 }, /* (66) type_name ::= INTEGER */ + { 163, -1 }, /* (67) type_name ::= BIGINT */ + { 163, -1 }, /* (68) type_name ::= FLOAT */ + { 163, -1 }, /* (69) type_name ::= DOUBLE */ + { 163, -4 }, /* (70) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 163, -1 }, /* (71) type_name ::= TIMESTAMP */ + { 163, -4 }, /* (72) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 163, -2 }, /* (73) type_name ::= TINYINT UNSIGNED */ + { 163, -2 }, /* (74) type_name ::= SMALLINT UNSIGNED */ + { 163, -2 }, /* (75) type_name ::= INT UNSIGNED */ + { 163, -2 }, /* (76) type_name ::= BIGINT UNSIGNED */ + { 163, -1 }, /* (77) type_name ::= JSON */ + { 163, -4 }, /* (78) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 163, -1 }, /* (79) type_name ::= MEDIUMBLOB */ + { 163, -1 }, /* (80) type_name ::= BLOB */ + { 163, -4 }, /* (81) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 163, -1 }, /* (82) type_name ::= DECIMAL */ + { 163, -4 }, /* (83) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 163, -6 }, /* (84) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 150, 0 }, /* (85) tags_def_opt ::= */ + { 150, -1 }, /* (86) tags_def_opt ::= tags_def */ + { 153, -4 }, /* (87) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 151, 0 }, /* (88) table_options ::= */ + { 151, -3 }, /* (89) table_options ::= table_options COMMENT NK_STRING */ + { 151, -3 }, /* (90) table_options ::= table_options KEEP NK_INTEGER */ + { 151, -3 }, /* (91) table_options ::= table_options TTL NK_INTEGER */ + { 151, -5 }, /* (92) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 159, -1 }, /* (93) col_name_list ::= col_name */ + { 159, -3 }, /* (94) col_name_list ::= col_name_list NK_COMMA col_name */ + { 164, -1 }, /* (95) col_name ::= column_name */ + { 140, -7 }, /* (96) cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ + { 140, -9 }, /* (97) cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ + { 166, 0 }, /* (98) index_options ::= */ + { 166, -9 }, /* (99) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ + { 166, -11 }, /* (100) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ + { 167, -1 }, /* (101) func_list ::= func */ + { 167, -3 }, /* (102) func_list ::= func_list NK_COMMA func */ + { 170, -4 }, /* (103) func ::= function_name NK_LP expression_list NK_RP */ + { 140, -2 }, /* (104) cmd ::= SHOW VGROUPS */ + { 140, -4 }, /* (105) cmd ::= SHOW db_name NK_DOT VGROUPS */ + { 140, -2 }, /* (106) cmd ::= SHOW MNODES */ + { 140, -1 }, /* (107) cmd ::= query_expression */ + { 174, -1 }, /* (108) literal ::= NK_INTEGER */ + { 174, -1 }, /* (109) literal ::= NK_FLOAT */ + { 174, -1 }, /* (110) literal ::= NK_STRING */ + { 174, -1 }, /* (111) literal ::= NK_BOOL */ + { 174, -2 }, /* (112) literal ::= TIMESTAMP NK_STRING */ + { 174, -1 }, /* (113) literal ::= duration_literal */ + { 168, -1 }, /* (114) duration_literal ::= NK_VARIABLE */ + { 157, -1 }, /* (115) literal_list ::= literal */ + { 157, -3 }, /* (116) literal_list ::= literal_list NK_COMMA literal */ + { 145, -1 }, /* (117) db_name ::= NK_ID */ + { 160, -1 }, /* (118) table_name ::= NK_ID */ + { 162, -1 }, /* (119) column_name ::= NK_ID */ + { 171, -1 }, /* (120) function_name ::= NK_ID */ + { 175, -1 }, /* (121) table_alias ::= NK_ID */ + { 176, -1 }, /* (122) column_alias ::= NK_ID */ + { 141, -1 }, /* (123) user_name ::= NK_ID */ + { 165, -1 }, /* (124) index_name ::= NK_ID */ + { 177, -1 }, /* (125) expression ::= literal */ + { 177, -1 }, /* (126) expression ::= column_reference */ + { 177, -4 }, /* (127) expression ::= function_name NK_LP expression_list NK_RP */ + { 177, -4 }, /* (128) expression ::= function_name NK_LP NK_STAR NK_RP */ + { 177, -1 }, /* (129) expression ::= subquery */ + { 177, -3 }, /* (130) expression ::= NK_LP expression NK_RP */ + { 177, -2 }, /* (131) expression ::= NK_PLUS expression */ + { 177, -2 }, /* (132) expression ::= NK_MINUS expression */ + { 177, -3 }, /* (133) expression ::= expression NK_PLUS expression */ + { 177, -3 }, /* (134) expression ::= expression NK_MINUS expression */ + { 177, -3 }, /* (135) expression ::= expression NK_STAR expression */ + { 177, -3 }, /* (136) expression ::= expression NK_SLASH expression */ + { 177, -3 }, /* (137) expression ::= expression NK_REM expression */ + { 172, -1 }, /* (138) expression_list ::= expression */ + { 172, -3 }, /* (139) expression_list ::= expression_list NK_COMMA expression */ + { 178, -1 }, /* (140) column_reference ::= column_name */ + { 178, -3 }, /* (141) column_reference ::= table_name NK_DOT column_name */ + { 180, -3 }, /* (142) predicate ::= expression compare_op expression */ + { 180, -5 }, /* (143) predicate ::= expression BETWEEN expression AND expression */ + { 180, -6 }, /* (144) predicate ::= expression NOT BETWEEN expression AND expression */ + { 180, -3 }, /* (145) predicate ::= expression IS NULL */ + { 180, -4 }, /* (146) predicate ::= expression IS NOT NULL */ + { 180, -3 }, /* (147) predicate ::= expression in_op in_predicate_value */ + { 181, -1 }, /* (148) compare_op ::= NK_LT */ + { 181, -1 }, /* (149) compare_op ::= NK_GT */ + { 181, -1 }, /* (150) compare_op ::= NK_LE */ + { 181, -1 }, /* (151) compare_op ::= NK_GE */ + { 181, -1 }, /* (152) compare_op ::= NK_NE */ + { 181, -1 }, /* (153) compare_op ::= NK_EQ */ + { 181, -1 }, /* (154) compare_op ::= LIKE */ + { 181, -2 }, /* (155) compare_op ::= NOT LIKE */ + { 181, -1 }, /* (156) compare_op ::= MATCH */ + { 181, -1 }, /* (157) compare_op ::= NMATCH */ + { 182, -1 }, /* (158) in_op ::= IN */ + { 182, -2 }, /* (159) in_op ::= NOT IN */ + { 183, -3 }, /* (160) in_predicate_value ::= NK_LP expression_list NK_RP */ + { 184, -1 }, /* (161) boolean_value_expression ::= boolean_primary */ + { 184, -2 }, /* (162) boolean_value_expression ::= NOT boolean_primary */ + { 184, -3 }, /* (163) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 184, -3 }, /* (164) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 185, -1 }, /* (165) boolean_primary ::= predicate */ + { 185, -3 }, /* (166) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 186, -1 }, /* (167) common_expression ::= expression */ + { 186, -1 }, /* (168) common_expression ::= boolean_value_expression */ + { 187, -2 }, /* (169) from_clause ::= FROM table_reference_list */ + { 188, -1 }, /* (170) table_reference_list ::= table_reference */ + { 188, -3 }, /* (171) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 189, -1 }, /* (172) table_reference ::= table_primary */ + { 189, -1 }, /* (173) table_reference ::= joined_table */ + { 190, -2 }, /* (174) table_primary ::= table_name alias_opt */ + { 190, -4 }, /* (175) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 190, -2 }, /* (176) table_primary ::= subquery alias_opt */ + { 190, -1 }, /* (177) table_primary ::= parenthesized_joined_table */ + { 192, 0 }, /* (178) alias_opt ::= */ + { 192, -1 }, /* (179) alias_opt ::= table_alias */ + { 192, -2 }, /* (180) alias_opt ::= AS table_alias */ + { 193, -3 }, /* (181) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 193, -3 }, /* (182) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 191, -6 }, /* (183) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 194, 0 }, /* (184) join_type ::= */ + { 194, -1 }, /* (185) join_type ::= INNER */ + { 196, -9 }, /* (186) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + { 197, 0 }, /* (187) set_quantifier_opt ::= */ + { 197, -1 }, /* (188) set_quantifier_opt ::= DISTINCT */ + { 197, -1 }, /* (189) set_quantifier_opt ::= ALL */ + { 198, -1 }, /* (190) select_list ::= NK_STAR */ + { 198, -1 }, /* (191) select_list ::= select_sublist */ + { 204, -1 }, /* (192) select_sublist ::= select_item */ + { 204, -3 }, /* (193) select_sublist ::= select_sublist NK_COMMA select_item */ + { 205, -1 }, /* (194) select_item ::= common_expression */ + { 205, -2 }, /* (195) select_item ::= common_expression column_alias */ + { 205, -3 }, /* (196) select_item ::= common_expression AS column_alias */ + { 205, -3 }, /* (197) select_item ::= table_name NK_DOT NK_STAR */ + { 199, 0 }, /* (198) where_clause_opt ::= */ + { 199, -2 }, /* (199) where_clause_opt ::= WHERE search_condition */ + { 200, 0 }, /* (200) partition_by_clause_opt ::= */ + { 200, -3 }, /* (201) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 201, 0 }, /* (202) twindow_clause_opt ::= */ + { 201, -6 }, /* (203) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ + { 201, -4 }, /* (204) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ + { 201, -6 }, /* (205) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 201, -8 }, /* (206) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 169, 0 }, /* (207) sliding_opt ::= */ + { 169, -4 }, /* (208) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 206, 0 }, /* (209) fill_opt ::= */ + { 206, -4 }, /* (210) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 206, -6 }, /* (211) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 207, -1 }, /* (212) fill_mode ::= NONE */ + { 207, -1 }, /* (213) fill_mode ::= PREV */ + { 207, -1 }, /* (214) fill_mode ::= NULL */ + { 207, -1 }, /* (215) fill_mode ::= LINEAR */ + { 207, -1 }, /* (216) fill_mode ::= NEXT */ + { 202, 0 }, /* (217) group_by_clause_opt ::= */ + { 202, -3 }, /* (218) group_by_clause_opt ::= GROUP BY group_by_list */ + { 208, -1 }, /* (219) group_by_list ::= expression */ + { 208, -3 }, /* (220) group_by_list ::= group_by_list NK_COMMA expression */ + { 203, 0 }, /* (221) having_clause_opt ::= */ + { 203, -2 }, /* (222) having_clause_opt ::= HAVING search_condition */ + { 173, -4 }, /* (223) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 209, -1 }, /* (224) query_expression_body ::= query_primary */ + { 209, -4 }, /* (225) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 213, -1 }, /* (226) query_primary ::= query_specification */ + { 210, 0 }, /* (227) order_by_clause_opt ::= */ + { 210, -3 }, /* (228) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 211, 0 }, /* (229) slimit_clause_opt ::= */ + { 211, -2 }, /* (230) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 211, -4 }, /* (231) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 211, -4 }, /* (232) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 212, 0 }, /* (233) limit_clause_opt ::= */ + { 212, -2 }, /* (234) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 212, -4 }, /* (235) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 212, -4 }, /* (236) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 179, -3 }, /* (237) subquery ::= NK_LP query_expression NK_RP */ + { 195, -1 }, /* (238) search_condition ::= common_expression */ + { 214, -1 }, /* (239) sort_specification_list ::= sort_specification */ + { 214, -3 }, /* (240) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 215, -3 }, /* (241) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 216, 0 }, /* (242) ordering_specification_opt ::= */ + { 216, -1 }, /* (243) ordering_specification_opt ::= ASC */ + { 216, -1 }, /* (244) ordering_specification_opt ::= DESC */ + { 217, 0 }, /* (245) null_ordering_opt ::= */ + { 217, -2 }, /* (246) null_ordering_opt ::= NULLS FIRST */ + { 217, -2 }, /* (247) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -1964,31 +1959,31 @@ static YYACTIONTYPE yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy0);} break; case 1: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy209, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy5, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0);} break; case 2: /* cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy209, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy5, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0);} break; case 3: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy209); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy5); } break; case 4: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL); } break; case 5: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy209, NULL);} +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy5, NULL);} break; case 6: /* cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy0);} break; case 7: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0);} break; case 8: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy209);} +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy5);} break; case 9: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL); } @@ -1996,736 +1991,742 @@ static YYACTIONTYPE yy_reduce( case 10: /* dnode_endpoint ::= NK_STRING */ case 11: /* dnode_host_name ::= NK_ID */ yytestcase(yyruleno==11); case 12: /* dnode_host_name ::= NK_IPTOKEN */ yytestcase(yyruleno==12); - case 115: /* db_name ::= NK_ID */ yytestcase(yyruleno==115); - case 116: /* table_name ::= NK_ID */ yytestcase(yyruleno==116); - case 117: /* column_name ::= NK_ID */ yytestcase(yyruleno==117); - case 118: /* function_name ::= NK_ID */ yytestcase(yyruleno==118); - case 119: /* table_alias ::= NK_ID */ yytestcase(yyruleno==119); - case 120: /* column_alias ::= NK_ID */ yytestcase(yyruleno==120); - case 121: /* user_name ::= NK_ID */ yytestcase(yyruleno==121); - case 122: /* index_name ::= NK_ID */ yytestcase(yyruleno==122); -{ yylhsminor.yy209 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy209 = yylhsminor.yy209; + case 117: /* db_name ::= NK_ID */ yytestcase(yyruleno==117); + case 118: /* table_name ::= NK_ID */ yytestcase(yyruleno==118); + case 119: /* column_name ::= NK_ID */ yytestcase(yyruleno==119); + case 120: /* function_name ::= NK_ID */ yytestcase(yyruleno==120); + case 121: /* table_alias ::= NK_ID */ yytestcase(yyruleno==121); + case 122: /* column_alias ::= NK_ID */ yytestcase(yyruleno==122); + case 123: /* user_name ::= NK_ID */ yytestcase(yyruleno==123); + case 124: /* index_name ::= NK_ID */ yytestcase(yyruleno==124); +{ yylhsminor.yy5 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy5 = yylhsminor.yy5; break; - case 13: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy281, &yymsp[-1].minor.yy209, yymsp[0].minor.yy344);} + case 13: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ +{ pCxt->pRootNode = createCreateQnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 14: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy281, &yymsp[0].minor.yy209); } + case 14: /* cmd ::= SHOW QNODES */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT, NULL); } break; - case 15: /* cmd ::= SHOW DATABASES */ + case 15: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy25, &yymsp[-1].minor.yy5, yymsp[0].minor.yy68);} + break; + case 16: /* cmd ::= DROP DATABASE exists_opt db_name */ +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy25, &yymsp[0].minor.yy5); } + break; + case 17: /* cmd ::= SHOW DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL); } break; - case 16: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy209);} + case 18: /* cmd ::= USE db_name */ +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy5);} break; - case 17: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy281 = true; } + case 19: /* not_exists_opt ::= IF NOT EXISTS */ +{ yymsp[-2].minor.yy25 = true; } break; - case 18: /* not_exists_opt ::= */ - case 20: /* exists_opt ::= */ yytestcase(yyruleno==20); - case 185: /* set_quantifier_opt ::= */ yytestcase(yyruleno==185); -{ yymsp[1].minor.yy281 = false; } + case 20: /* not_exists_opt ::= */ + case 22: /* exists_opt ::= */ yytestcase(yyruleno==22); + case 187: /* set_quantifier_opt ::= */ yytestcase(yyruleno==187); +{ yymsp[1].minor.yy25 = false; } break; - case 19: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy281 = true; } + case 21: /* exists_opt ::= IF EXISTS */ +{ yymsp[-1].minor.yy25 = true; } break; - case 21: /* db_options ::= */ -{ yymsp[1].minor.yy344 = createDefaultDatabaseOptions(pCxt); } + case 23: /* db_options ::= */ +{ yymsp[1].minor.yy68 = createDefaultDatabaseOptions(pCxt); } break; - case 22: /* db_options ::= db_options BLOCKS NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 24: /* db_options ::= db_options BLOCKS NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 23: /* db_options ::= db_options CACHE NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 25: /* db_options ::= db_options CACHE NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 24: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 26: /* db_options ::= db_options CACHELAST NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 25: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 27: /* db_options ::= db_options COMP NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 26: /* db_options ::= db_options DAYS NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 28: /* db_options ::= db_options DAYS NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 27: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 29: /* db_options ::= db_options FSYNC NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 28: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 30: /* db_options ::= db_options MAXROWS NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 29: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 31: /* db_options ::= db_options MINROWS NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 30: /* db_options ::= db_options KEEP NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 32: /* db_options ::= db_options KEEP NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_KEEP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 31: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 33: /* db_options ::= db_options PRECISION NK_STRING */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 32: /* db_options ::= db_options QUORUM NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 34: /* db_options ::= db_options QUORUM NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 33: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 35: /* db_options ::= db_options REPLICA NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 34: /* db_options ::= db_options TTL NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 36: /* db_options ::= db_options TTL NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 35: /* db_options ::= db_options WAL NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 37: /* db_options ::= db_options WAL NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 36: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 38: /* db_options ::= db_options VGROUPS NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 37: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_SINGLESTABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 39: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_SINGLESTABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 38: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ -{ yylhsminor.yy344 = setDatabaseOption(pCxt, yymsp[-2].minor.yy344, DB_OPTION_STREAMMODE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 40: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ +{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_STREAMMODE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 39: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - case 41: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==41); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy281, yymsp[-5].minor.yy344, yymsp[-3].minor.yy280, yymsp[-1].minor.yy280, yymsp[0].minor.yy344);} + case 41: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + case 43: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==43); +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy25, yymsp[-5].minor.yy68, yymsp[-3].minor.yy40, yymsp[-1].minor.yy40, yymsp[0].minor.yy68);} break; - case 40: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy280);} + case 42: /* cmd ::= CREATE TABLE multi_create_clause */ +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy40);} break; - case 42: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy280); } + case 44: /* cmd ::= DROP TABLE multi_drop_clause */ +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy40); } break; - case 43: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy281, yymsp[0].minor.yy344); } + case 45: /* cmd ::= DROP STABLE exists_opt full_table_name */ +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy25, yymsp[0].minor.yy68); } break; - case 44: /* cmd ::= SHOW TABLES */ + case 46: /* cmd ::= SHOW TABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, NULL); } break; - case 45: /* cmd ::= SHOW STABLES */ + case 47: /* cmd ::= SHOW STABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, NULL); } break; - case 46: /* multi_create_clause ::= create_subtable_clause */ - case 49: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==49); - case 56: /* column_def_list ::= column_def */ yytestcase(yyruleno==56); - case 91: /* col_name_list ::= col_name */ yytestcase(yyruleno==91); - case 99: /* func_list ::= func */ yytestcase(yyruleno==99); - case 190: /* select_sublist ::= select_item */ yytestcase(yyruleno==190); - case 237: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==237); -{ yylhsminor.yy280 = createNodeList(pCxt, yymsp[0].minor.yy344); } - yymsp[0].minor.yy280 = yylhsminor.yy280; + case 48: /* multi_create_clause ::= create_subtable_clause */ + case 51: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==51); + case 58: /* column_def_list ::= column_def */ yytestcase(yyruleno==58); + case 93: /* col_name_list ::= col_name */ yytestcase(yyruleno==93); + case 101: /* func_list ::= func */ yytestcase(yyruleno==101); + case 192: /* select_sublist ::= select_item */ yytestcase(yyruleno==192); + case 239: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==239); +{ yylhsminor.yy40 = createNodeList(pCxt, yymsp[0].minor.yy68); } + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 47: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 50: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==50); -{ yylhsminor.yy280 = addNodeToList(pCxt, yymsp[-1].minor.yy280, yymsp[0].minor.yy344); } - yymsp[-1].minor.yy280 = yylhsminor.yy280; + case 49: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ + case 52: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==52); +{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-1].minor.yy40, yymsp[0].minor.yy68); } + yymsp[-1].minor.yy40 = yylhsminor.yy40; break; - case 48: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ -{ yylhsminor.yy344 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy281, yymsp[-7].minor.yy344, yymsp[-5].minor.yy344, yymsp[-4].minor.yy280, yymsp[-1].minor.yy280); } - yymsp[-8].minor.yy344 = yylhsminor.yy344; + case 50: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ +{ yylhsminor.yy68 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy25, yymsp[-7].minor.yy68, yymsp[-5].minor.yy68, yymsp[-4].minor.yy40, yymsp[-1].minor.yy40); } + yymsp[-8].minor.yy68 = yylhsminor.yy68; break; - case 51: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy344 = createDropTableClause(pCxt, yymsp[-1].minor.yy281, yymsp[0].minor.yy344); } - yymsp[-1].minor.yy344 = yylhsminor.yy344; + case 53: /* drop_table_clause ::= exists_opt full_table_name */ +{ yylhsminor.yy68 = createDropTableClause(pCxt, yymsp[-1].minor.yy25, yymsp[0].minor.yy68); } + yymsp[-1].minor.yy68 = yylhsminor.yy68; break; - case 52: /* specific_tags_opt ::= */ - case 83: /* tags_def_opt ::= */ yytestcase(yyruleno==83); - case 198: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==198); - case 215: /* group_by_clause_opt ::= */ yytestcase(yyruleno==215); - case 225: /* order_by_clause_opt ::= */ yytestcase(yyruleno==225); -{ yymsp[1].minor.yy280 = NULL; } + case 54: /* specific_tags_opt ::= */ + case 85: /* tags_def_opt ::= */ yytestcase(yyruleno==85); + case 200: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==200); + case 217: /* group_by_clause_opt ::= */ yytestcase(yyruleno==217); + case 227: /* order_by_clause_opt ::= */ yytestcase(yyruleno==227); +{ yymsp[1].minor.yy40 = NULL; } break; - case 53: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy280 = yymsp[-1].minor.yy280; } + case 55: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ +{ yymsp[-2].minor.yy40 = yymsp[-1].minor.yy40; } break; - case 54: /* full_table_name ::= table_name */ -{ yylhsminor.yy344 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy209, NULL); } - yymsp[0].minor.yy344 = yylhsminor.yy344; + case 56: /* full_table_name ::= table_name */ +{ yylhsminor.yy68 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy5, NULL); } + yymsp[0].minor.yy68 = yylhsminor.yy68; break; - case 55: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy344 = createRealTableNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209, NULL); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 57: /* full_table_name ::= db_name NK_DOT table_name */ +{ yylhsminor.yy68 = createRealTableNode(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy5, NULL); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 57: /* column_def_list ::= column_def_list NK_COMMA column_def */ - case 92: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==92); - case 100: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==100); - case 191: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==191); - case 238: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==238); -{ yylhsminor.yy280 = addNodeToList(pCxt, yymsp[-2].minor.yy280, yymsp[0].minor.yy344); } - yymsp[-2].minor.yy280 = yylhsminor.yy280; + case 59: /* column_def_list ::= column_def_list NK_COMMA column_def */ + case 94: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==94); + case 102: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==102); + case 193: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==193); + case 240: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==240); +{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-2].minor.yy40, yymsp[0].minor.yy68); } + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 58: /* column_def ::= column_name type_name */ -{ yylhsminor.yy344 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy209, yymsp[0].minor.yy304, NULL); } - yymsp[-1].minor.yy344 = yylhsminor.yy344; + case 60: /* column_def ::= column_name type_name */ +{ yylhsminor.yy68 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy5, yymsp[0].minor.yy372, NULL); } + yymsp[-1].minor.yy68 = yylhsminor.yy68; break; - case 59: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy344 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-2].minor.yy304, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy344 = yylhsminor.yy344; + case 61: /* column_def ::= column_name type_name COMMENT NK_STRING */ +{ yylhsminor.yy68 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy5, yymsp[-2].minor.yy372, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy68 = yylhsminor.yy68; break; - case 60: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_BOOL); } + case 62: /* type_name ::= BOOL */ +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_BOOL); } break; - case 61: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_TINYINT); } + case 63: /* type_name ::= TINYINT */ +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; - case 62: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_SMALLINT); } + case 64: /* type_name ::= SMALLINT */ +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; - case 63: /* type_name ::= INT */ - case 64: /* type_name ::= INTEGER */ yytestcase(yyruleno==64); -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_INT); } + case 65: /* type_name ::= INT */ + case 66: /* type_name ::= INTEGER */ yytestcase(yyruleno==66); +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_INT); } break; - case 65: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_BIGINT); } + case 67: /* type_name ::= BIGINT */ +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; - case 66: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_FLOAT); } + case 68: /* type_name ::= FLOAT */ +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; - case 67: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_DOUBLE); } + case 69: /* type_name ::= DOUBLE */ +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; - case 68: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } + case 70: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy372 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; - case 69: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } + case 71: /* type_name ::= TIMESTAMP */ +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; - case 70: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } + case 72: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy372 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; - case 71: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_UTINYINT); } + case 73: /* type_name ::= TINYINT UNSIGNED */ +{ yymsp[-1].minor.yy372 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; - case 72: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_USMALLINT); } + case 74: /* type_name ::= SMALLINT UNSIGNED */ +{ yymsp[-1].minor.yy372 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; - case 73: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_UINT); } + case 75: /* type_name ::= INT UNSIGNED */ +{ yymsp[-1].minor.yy372 = createDataType(TSDB_DATA_TYPE_UINT); } break; - case 74: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy304 = createDataType(TSDB_DATA_TYPE_UBIGINT); } + case 76: /* type_name ::= BIGINT UNSIGNED */ +{ yymsp[-1].minor.yy372 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; - case 75: /* type_name ::= JSON */ -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_JSON); } + case 77: /* type_name ::= JSON */ +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_JSON); } break; - case 76: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } + case 78: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy372 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; - case 77: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } + case 79: /* type_name ::= MEDIUMBLOB */ +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; - case 78: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_BLOB); } + case 80: /* type_name ::= BLOB */ +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_BLOB); } break; - case 79: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy304 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } + case 81: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy372 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; - case 80: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy304 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 82: /* type_name ::= DECIMAL */ +{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 81: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy304 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 83: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy372 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 82: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy304 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 84: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy372 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 84: /* tags_def_opt ::= tags_def */ - case 189: /* select_list ::= select_sublist */ yytestcase(yyruleno==189); -{ yylhsminor.yy280 = yymsp[0].minor.yy280; } - yymsp[0].minor.yy280 = yylhsminor.yy280; + case 86: /* tags_def_opt ::= tags_def */ + case 191: /* select_list ::= select_sublist */ yytestcase(yyruleno==191); +{ yylhsminor.yy40 = yymsp[0].minor.yy40; } + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 85: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy280 = yymsp[-1].minor.yy280; } + case 87: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ +{ yymsp[-3].minor.yy40 = yymsp[-1].minor.yy40; } break; - case 86: /* table_options ::= */ -{ yymsp[1].minor.yy344 = createDefaultTableOptions(pCxt);} + case 88: /* table_options ::= */ +{ yymsp[1].minor.yy68 = createDefaultTableOptions(pCxt);} break; - case 87: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy344 = setTableOption(pCxt, yymsp[-2].minor.yy344, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 89: /* table_options ::= table_options COMMENT NK_STRING */ +{ yylhsminor.yy68 = setTableOption(pCxt, yymsp[-2].minor.yy68, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 88: /* table_options ::= table_options KEEP NK_INTEGER */ -{ yylhsminor.yy344 = setTableOption(pCxt, yymsp[-2].minor.yy344, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 90: /* table_options ::= table_options KEEP NK_INTEGER */ +{ yylhsminor.yy68 = setTableOption(pCxt, yymsp[-2].minor.yy68, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 89: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy344 = setTableOption(pCxt, yymsp[-2].minor.yy344, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 91: /* table_options ::= table_options TTL NK_INTEGER */ +{ yylhsminor.yy68 = setTableOption(pCxt, yymsp[-2].minor.yy68, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 90: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy344 = setTableSmaOption(pCxt, yymsp[-4].minor.yy344, yymsp[-1].minor.yy280); } - yymsp[-4].minor.yy344 = yylhsminor.yy344; + case 92: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ +{ yylhsminor.yy68 = setTableSmaOption(pCxt, yymsp[-4].minor.yy68, yymsp[-1].minor.yy40); } + yymsp[-4].minor.yy68 = yylhsminor.yy68; break; - case 93: /* col_name ::= column_name */ -{ yylhsminor.yy344 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy209); } - yymsp[0].minor.yy344 = yylhsminor.yy344; + case 95: /* col_name ::= column_name */ +{ yylhsminor.yy68 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy5); } + yymsp[0].minor.yy68 = yylhsminor.yy68; break; - case 94: /* cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &yymsp[-3].minor.yy209, &yymsp[-1].minor.yy209, NULL, yymsp[0].minor.yy344); } + case 96: /* cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &yymsp[-3].minor.yy5, &yymsp[-1].minor.yy5, NULL, yymsp[0].minor.yy68); } break; - case 95: /* cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &yymsp[-5].minor.yy209, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy280, NULL); } + case 97: /* cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &yymsp[-5].minor.yy5, &yymsp[-3].minor.yy5, yymsp[-1].minor.yy40, NULL); } break; - case 96: /* index_options ::= */ - case 196: /* where_clause_opt ::= */ yytestcase(yyruleno==196); - case 200: /* twindow_clause_opt ::= */ yytestcase(yyruleno==200); - case 205: /* sliding_opt ::= */ yytestcase(yyruleno==205); - case 207: /* fill_opt ::= */ yytestcase(yyruleno==207); - case 219: /* having_clause_opt ::= */ yytestcase(yyruleno==219); - case 227: /* slimit_clause_opt ::= */ yytestcase(yyruleno==227); - case 231: /* limit_clause_opt ::= */ yytestcase(yyruleno==231); -{ yymsp[1].minor.yy344 = NULL; } + case 98: /* index_options ::= */ + case 198: /* where_clause_opt ::= */ yytestcase(yyruleno==198); + case 202: /* twindow_clause_opt ::= */ yytestcase(yyruleno==202); + case 207: /* sliding_opt ::= */ yytestcase(yyruleno==207); + case 209: /* fill_opt ::= */ yytestcase(yyruleno==209); + case 221: /* having_clause_opt ::= */ yytestcase(yyruleno==221); + case 229: /* slimit_clause_opt ::= */ yytestcase(yyruleno==229); + case 233: /* limit_clause_opt ::= */ yytestcase(yyruleno==233); +{ yymsp[1].minor.yy68 = NULL; } break; - case 97: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ -{ yymsp[-8].minor.yy344 = createIndexOption(pCxt, yymsp[-6].minor.yy280, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), NULL, yymsp[0].minor.yy344); } + case 99: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ +{ yymsp[-8].minor.yy68 = createIndexOption(pCxt, yymsp[-6].minor.yy40, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), NULL, yymsp[0].minor.yy68); } break; - case 98: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ -{ yymsp[-10].minor.yy344 = createIndexOption(pCxt, yymsp[-8].minor.yy280, releaseRawExprNode(pCxt, yymsp[-4].minor.yy344), releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), yymsp[0].minor.yy344); } + case 100: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ +{ yymsp[-10].minor.yy68 = createIndexOption(pCxt, yymsp[-8].minor.yy40, releaseRawExprNode(pCxt, yymsp[-4].minor.yy68), releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), yymsp[0].minor.yy68); } break; - case 101: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy344 = createFunctionNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy280); } - yymsp[-3].minor.yy344 = yylhsminor.yy344; + case 103: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy68 = createFunctionNode(pCxt, &yymsp[-3].minor.yy5, yymsp[-1].minor.yy40); } + yymsp[-3].minor.yy68 = yylhsminor.yy68; break; - case 102: /* cmd ::= SHOW VGROUPS */ + case 104: /* cmd ::= SHOW VGROUPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, NULL); } break; - case 103: /* cmd ::= SHOW db_name NK_DOT VGROUPS */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &yymsp[-2].minor.yy209); } + case 105: /* cmd ::= SHOW db_name NK_DOT VGROUPS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &yymsp[-2].minor.yy5); } break; - case 104: /* cmd ::= SHOW MNODES */ + case 106: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL); } break; - case 105: /* cmd ::= query_expression */ -{ pCxt->pRootNode = yymsp[0].minor.yy344; } + case 107: /* cmd ::= query_expression */ +{ pCxt->pRootNode = yymsp[0].minor.yy68; } break; - case 106: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy344 = yylhsminor.yy344; + case 108: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy68 = yylhsminor.yy68; break; - case 107: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy344 = yylhsminor.yy344; + case 109: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy68 = yylhsminor.yy68; break; - case 108: /* literal ::= NK_STRING */ -{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy344 = yylhsminor.yy344; + case 110: /* literal ::= NK_STRING */ +{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy68 = yylhsminor.yy68; break; - case 109: /* literal ::= NK_BOOL */ -{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy344 = yylhsminor.yy344; + case 111: /* literal ::= NK_BOOL */ +{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy68 = yylhsminor.yy68; break; - case 110: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy344 = yylhsminor.yy344; + case 112: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy68 = yylhsminor.yy68; break; - case 111: /* literal ::= duration_literal */ - case 123: /* expression ::= literal */ yytestcase(yyruleno==123); - case 124: /* expression ::= column_reference */ yytestcase(yyruleno==124); - case 127: /* expression ::= subquery */ yytestcase(yyruleno==127); - case 159: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==159); - case 163: /* boolean_primary ::= predicate */ yytestcase(yyruleno==163); - case 165: /* common_expression ::= expression */ yytestcase(yyruleno==165); - case 166: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==166); - case 168: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==168); - case 170: /* table_reference ::= table_primary */ yytestcase(yyruleno==170); - case 171: /* table_reference ::= joined_table */ yytestcase(yyruleno==171); - case 175: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==175); - case 222: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==222); - case 224: /* query_primary ::= query_specification */ yytestcase(yyruleno==224); -{ yylhsminor.yy344 = yymsp[0].minor.yy344; } - yymsp[0].minor.yy344 = yylhsminor.yy344; + case 113: /* literal ::= duration_literal */ + case 125: /* expression ::= literal */ yytestcase(yyruleno==125); + case 126: /* expression ::= column_reference */ yytestcase(yyruleno==126); + case 129: /* expression ::= subquery */ yytestcase(yyruleno==129); + case 161: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==161); + case 165: /* boolean_primary ::= predicate */ yytestcase(yyruleno==165); + case 167: /* common_expression ::= expression */ yytestcase(yyruleno==167); + case 168: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==168); + case 170: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==170); + case 172: /* table_reference ::= table_primary */ yytestcase(yyruleno==172); + case 173: /* table_reference ::= joined_table */ yytestcase(yyruleno==173); + case 177: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==177); + case 224: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==224); + case 226: /* query_primary ::= query_specification */ yytestcase(yyruleno==226); +{ yylhsminor.yy68 = yymsp[0].minor.yy68; } + yymsp[0].minor.yy68 = yylhsminor.yy68; break; - case 112: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy344 = yylhsminor.yy344; + case 114: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy68 = yylhsminor.yy68; break; - case 113: /* literal_list ::= literal */ - case 136: /* expression_list ::= expression */ yytestcase(yyruleno==136); -{ yylhsminor.yy280 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy344)); } - yymsp[0].minor.yy280 = yylhsminor.yy280; + case 115: /* literal_list ::= literal */ + case 138: /* expression_list ::= expression */ yytestcase(yyruleno==138); +{ yylhsminor.yy40 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy68)); } + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 114: /* literal_list ::= literal_list NK_COMMA literal */ - case 137: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==137); -{ yylhsminor.yy280 = addNodeToList(pCxt, yymsp[-2].minor.yy280, releaseRawExprNode(pCxt, yymsp[0].minor.yy344)); } - yymsp[-2].minor.yy280 = yylhsminor.yy280; + case 116: /* literal_list ::= literal_list NK_COMMA literal */ + case 139: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==139); +{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-2].minor.yy40, releaseRawExprNode(pCxt, yymsp[0].minor.yy68)); } + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 125: /* expression ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy209, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy209, yymsp[-1].minor.yy280)); } - yymsp[-3].minor.yy344 = yylhsminor.yy344; + case 127: /* expression ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy5, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy5, yymsp[-1].minor.yy40)); } + yymsp[-3].minor.yy68 = yylhsminor.yy68; break; - case 126: /* expression ::= function_name NK_LP NK_STAR NK_RP */ -{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy209, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy209, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } - yymsp[-3].minor.yy344 = yylhsminor.yy344; + case 128: /* expression ::= function_name NK_LP NK_STAR NK_RP */ +{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy5, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy5, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } + yymsp[-3].minor.yy68 = yylhsminor.yy68; break; - case 128: /* expression ::= NK_LP expression NK_RP */ - case 164: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==164); -{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy344)); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 130: /* expression ::= NK_LP expression NK_RP */ + case 166: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==166); +{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy68)); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 129: /* expression ::= NK_PLUS expression */ + case 131: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy344)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy68)); } - yymsp[-1].minor.yy344 = yylhsminor.yy344; + yymsp[-1].minor.yy68 = yylhsminor.yy68; break; - case 130: /* expression ::= NK_MINUS expression */ + case 132: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy344), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy68), NULL)); } - yymsp[-1].minor.yy344 = yylhsminor.yy344; + yymsp[-1].minor.yy68 = yylhsminor.yy68; break; - case 131: /* expression ::= expression NK_PLUS expression */ + case 133: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 132: /* expression ::= expression NK_MINUS expression */ + case 134: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 133: /* expression ::= expression NK_STAR expression */ + case 135: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 134: /* expression ::= expression NK_SLASH expression */ + case 136: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 135: /* expression ::= expression NK_REM expression */ + case 137: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 138: /* column_reference ::= column_name */ -{ yylhsminor.yy344 = createRawExprNode(pCxt, &yymsp[0].minor.yy209, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy209)); } - yymsp[0].minor.yy344 = yylhsminor.yy344; + case 140: /* column_reference ::= column_name */ +{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy5, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy5)); } + yymsp[0].minor.yy68 = yylhsminor.yy68; break; - case 139: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209, createColumnNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy209)); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 141: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy5, createColumnNode(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy5)); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 140: /* predicate ::= expression compare_op expression */ - case 145: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==145); + case 142: /* predicate ::= expression compare_op expression */ + case 147: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==147); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy236, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy416, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 141: /* predicate ::= expression BETWEEN expression AND expression */ + case 143: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy344); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy344), releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy68); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy68), releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-4].minor.yy344 = yylhsminor.yy344; + yymsp[-4].minor.yy68 = yylhsminor.yy68; break; - case 142: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 144: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy344); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[-5].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy68); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[-5].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-5].minor.yy344 = yylhsminor.yy344; + yymsp[-5].minor.yy68 = yylhsminor.yy68; break; - case 143: /* predicate ::= expression IS NULL */ + case 145: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), NULL)); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 144: /* predicate ::= expression IS NOT NULL */ + case 146: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy344), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy68), NULL)); } - yymsp[-3].minor.yy344 = yylhsminor.yy344; + yymsp[-3].minor.yy68 = yylhsminor.yy68; break; - case 146: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy236 = OP_TYPE_LOWER_THAN; } + case 148: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy416 = OP_TYPE_LOWER_THAN; } break; - case 147: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy236 = OP_TYPE_GREATER_THAN; } + case 149: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy416 = OP_TYPE_GREATER_THAN; } break; - case 148: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy236 = OP_TYPE_LOWER_EQUAL; } + case 150: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy416 = OP_TYPE_LOWER_EQUAL; } break; - case 149: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy236 = OP_TYPE_GREATER_EQUAL; } + case 151: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy416 = OP_TYPE_GREATER_EQUAL; } break; - case 150: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy236 = OP_TYPE_NOT_EQUAL; } + case 152: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy416 = OP_TYPE_NOT_EQUAL; } break; - case 151: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy236 = OP_TYPE_EQUAL; } + case 153: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy416 = OP_TYPE_EQUAL; } break; - case 152: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy236 = OP_TYPE_LIKE; } + case 154: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy416 = OP_TYPE_LIKE; } break; - case 153: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy236 = OP_TYPE_NOT_LIKE; } + case 155: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy416 = OP_TYPE_NOT_LIKE; } break; - case 154: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy236 = OP_TYPE_MATCH; } + case 156: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy416 = OP_TYPE_MATCH; } break; - case 155: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy236 = OP_TYPE_NMATCH; } + case 157: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy416 = OP_TYPE_NMATCH; } break; - case 156: /* in_op ::= IN */ -{ yymsp[0].minor.yy236 = OP_TYPE_IN; } + case 158: /* in_op ::= IN */ +{ yymsp[0].minor.yy416 = OP_TYPE_IN; } break; - case 157: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy236 = OP_TYPE_NOT_IN; } + case 159: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy416 = OP_TYPE_NOT_IN; } break; - case 158: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy280)); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 160: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy40)); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 160: /* boolean_value_expression ::= NOT boolean_primary */ + case 162: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy344), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy68), NULL)); } - yymsp[-1].minor.yy344 = yylhsminor.yy344; + yymsp[-1].minor.yy68 = yylhsminor.yy68; break; - case 161: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 163: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 162: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 164: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy344); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 167: /* from_clause ::= FROM table_reference_list */ - case 197: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==197); - case 220: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==220); -{ yymsp[-1].minor.yy344 = yymsp[0].minor.yy344; } + case 169: /* from_clause ::= FROM table_reference_list */ + case 199: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==199); + case 222: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==222); +{ yymsp[-1].minor.yy68 = yymsp[0].minor.yy68; } break; - case 169: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy344 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy344, yymsp[0].minor.yy344, NULL); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 171: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy68 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy68, yymsp[0].minor.yy68, NULL); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 172: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy344 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy209, &yymsp[0].minor.yy209); } - yymsp[-1].minor.yy344 = yylhsminor.yy344; + case 174: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy68 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy5, &yymsp[0].minor.yy5); } + yymsp[-1].minor.yy68 = yylhsminor.yy68; break; - case 173: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy344 = createRealTableNode(pCxt, &yymsp[-3].minor.yy209, &yymsp[-1].minor.yy209, &yymsp[0].minor.yy209); } - yymsp[-3].minor.yy344 = yylhsminor.yy344; + case 175: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy68 = createRealTableNode(pCxt, &yymsp[-3].minor.yy5, &yymsp[-1].minor.yy5, &yymsp[0].minor.yy5); } + yymsp[-3].minor.yy68 = yylhsminor.yy68; break; - case 174: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy344 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy344), &yymsp[0].minor.yy209); } - yymsp[-1].minor.yy344 = yylhsminor.yy344; + case 176: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy68 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy68), &yymsp[0].minor.yy5); } + yymsp[-1].minor.yy68 = yylhsminor.yy68; break; - case 176: /* alias_opt ::= */ -{ yymsp[1].minor.yy209 = nil_token; } + case 178: /* alias_opt ::= */ +{ yymsp[1].minor.yy5 = nil_token; } break; - case 177: /* alias_opt ::= table_alias */ -{ yylhsminor.yy209 = yymsp[0].minor.yy209; } - yymsp[0].minor.yy209 = yylhsminor.yy209; + case 179: /* alias_opt ::= table_alias */ +{ yylhsminor.yy5 = yymsp[0].minor.yy5; } + yymsp[0].minor.yy5 = yylhsminor.yy5; break; - case 178: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy209 = yymsp[0].minor.yy209; } + case 180: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy5 = yymsp[0].minor.yy5; } break; - case 179: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 180: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==180); -{ yymsp[-2].minor.yy344 = yymsp[-1].minor.yy344; } + case 181: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 182: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==182); +{ yymsp[-2].minor.yy68 = yymsp[-1].minor.yy68; } break; - case 181: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy344 = createJoinTableNode(pCxt, yymsp[-4].minor.yy36, yymsp[-5].minor.yy344, yymsp[-2].minor.yy344, yymsp[0].minor.yy344); } - yymsp[-5].minor.yy344 = yylhsminor.yy344; + case 183: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy68 = createJoinTableNode(pCxt, yymsp[-4].minor.yy92, yymsp[-5].minor.yy68, yymsp[-2].minor.yy68, yymsp[0].minor.yy68); } + yymsp[-5].minor.yy68 = yylhsminor.yy68; break; - case 182: /* join_type ::= */ -{ yymsp[1].minor.yy36 = JOIN_TYPE_INNER; } + case 184: /* join_type ::= */ +{ yymsp[1].minor.yy92 = JOIN_TYPE_INNER; } break; - case 183: /* join_type ::= INNER */ -{ yymsp[0].minor.yy36 = JOIN_TYPE_INNER; } + case 185: /* join_type ::= INNER */ +{ yymsp[0].minor.yy92 = JOIN_TYPE_INNER; } break; - case 184: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 186: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { - yymsp[-8].minor.yy344 = createSelectStmt(pCxt, yymsp[-7].minor.yy281, yymsp[-6].minor.yy280, yymsp[-5].minor.yy344); - yymsp[-8].minor.yy344 = addWhereClause(pCxt, yymsp[-8].minor.yy344, yymsp[-4].minor.yy344); - yymsp[-8].minor.yy344 = addPartitionByClause(pCxt, yymsp[-8].minor.yy344, yymsp[-3].minor.yy280); - yymsp[-8].minor.yy344 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy344, yymsp[-2].minor.yy344); - yymsp[-8].minor.yy344 = addGroupByClause(pCxt, yymsp[-8].minor.yy344, yymsp[-1].minor.yy280); - yymsp[-8].minor.yy344 = addHavingClause(pCxt, yymsp[-8].minor.yy344, yymsp[0].minor.yy344); + yymsp[-8].minor.yy68 = createSelectStmt(pCxt, yymsp[-7].minor.yy25, yymsp[-6].minor.yy40, yymsp[-5].minor.yy68); + yymsp[-8].minor.yy68 = addWhereClause(pCxt, yymsp[-8].minor.yy68, yymsp[-4].minor.yy68); + yymsp[-8].minor.yy68 = addPartitionByClause(pCxt, yymsp[-8].minor.yy68, yymsp[-3].minor.yy40); + yymsp[-8].minor.yy68 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy68, yymsp[-2].minor.yy68); + yymsp[-8].minor.yy68 = addGroupByClause(pCxt, yymsp[-8].minor.yy68, yymsp[-1].minor.yy40); + yymsp[-8].minor.yy68 = addHavingClause(pCxt, yymsp[-8].minor.yy68, yymsp[0].minor.yy68); } break; - case 186: /* set_quantifier_opt ::= DISTINCT */ -{ yymsp[0].minor.yy281 = true; } + case 188: /* set_quantifier_opt ::= DISTINCT */ +{ yymsp[0].minor.yy25 = true; } break; - case 187: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy281 = false; } + case 189: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy25 = false; } break; - case 188: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy280 = NULL; } + case 190: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy40 = NULL; } break; - case 192: /* select_item ::= common_expression */ + case 194: /* select_item ::= common_expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy344); - yylhsminor.yy344 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy344), &t); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); + yylhsminor.yy68 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy68), &t); } - yymsp[0].minor.yy344 = yylhsminor.yy344; + yymsp[0].minor.yy68 = yylhsminor.yy68; break; - case 193: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy344 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy344), &yymsp[0].minor.yy209); } - yymsp[-1].minor.yy344 = yylhsminor.yy344; + case 195: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy68 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy68), &yymsp[0].minor.yy5); } + yymsp[-1].minor.yy68 = yylhsminor.yy68; break; - case 194: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy344 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), &yymsp[0].minor.yy209); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 196: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy68 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), &yymsp[0].minor.yy5); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 195: /* select_item ::= table_name NK_DOT NK_STAR */ -{ yylhsminor.yy344 = createColumnNode(pCxt, &yymsp[-2].minor.yy209, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 197: /* select_item ::= table_name NK_DOT NK_STAR */ +{ yylhsminor.yy68 = createColumnNode(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 199: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 216: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==216); - case 226: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==226); -{ yymsp[-2].minor.yy280 = yymsp[0].minor.yy280; } + case 201: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 218: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==218); + case 228: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==228); +{ yymsp[-2].minor.yy40 = yymsp[0].minor.yy40; } break; - case 201: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy344 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy344), &yymsp[-1].minor.yy0); } + case 203: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy68 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy68), &yymsp[-1].minor.yy0); } break; - case 202: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ -{ yymsp[-3].minor.yy344 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy344)); } + case 204: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ +{ yymsp[-3].minor.yy68 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy68)); } break; - case 203: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy344 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy344), NULL, yymsp[-1].minor.yy344, yymsp[0].minor.yy344); } + case 205: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy68 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy68), NULL, yymsp[-1].minor.yy68, yymsp[0].minor.yy68); } break; - case 204: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy344 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy344), releaseRawExprNode(pCxt, yymsp[-3].minor.yy344), yymsp[-1].minor.yy344, yymsp[0].minor.yy344); } + case 206: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy68 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy68), releaseRawExprNode(pCxt, yymsp[-3].minor.yy68), yymsp[-1].minor.yy68, yymsp[0].minor.yy68); } break; - case 206: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ -{ yymsp[-3].minor.yy344 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy344); } + case 208: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ +{ yymsp[-3].minor.yy68 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy68); } break; - case 208: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy344 = createFillNode(pCxt, yymsp[-1].minor.yy342, NULL); } + case 210: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy68 = createFillNode(pCxt, yymsp[-1].minor.yy94, NULL); } break; - case 209: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy344 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy280)); } + case 211: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy68 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy40)); } break; - case 210: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy342 = FILL_MODE_NONE; } + case 212: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy94 = FILL_MODE_NONE; } break; - case 211: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy342 = FILL_MODE_PREV; } + case 213: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy94 = FILL_MODE_PREV; } break; - case 212: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy342 = FILL_MODE_NULL; } + case 214: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy94 = FILL_MODE_NULL; } break; - case 213: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy342 = FILL_MODE_LINEAR; } + case 215: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy94 = FILL_MODE_LINEAR; } break; - case 214: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy342 = FILL_MODE_NEXT; } + case 216: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy94 = FILL_MODE_NEXT; } break; - case 217: /* group_by_list ::= expression */ -{ yylhsminor.yy280 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[0].minor.yy280 = yylhsminor.yy280; + case 219: /* group_by_list ::= expression */ +{ yylhsminor.yy40 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 218: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy280 = addNodeToList(pCxt, yymsp[-2].minor.yy280, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy344))); } - yymsp[-2].minor.yy280 = yylhsminor.yy280; + case 220: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-2].minor.yy40, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 221: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 223: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy344 = addOrderByClause(pCxt, yymsp[-3].minor.yy344, yymsp[-2].minor.yy280); - yylhsminor.yy344 = addSlimitClause(pCxt, yylhsminor.yy344, yymsp[-1].minor.yy344); - yylhsminor.yy344 = addLimitClause(pCxt, yylhsminor.yy344, yymsp[0].minor.yy344); + yylhsminor.yy68 = addOrderByClause(pCxt, yymsp[-3].minor.yy68, yymsp[-2].minor.yy40); + yylhsminor.yy68 = addSlimitClause(pCxt, yylhsminor.yy68, yymsp[-1].minor.yy68); + yylhsminor.yy68 = addLimitClause(pCxt, yylhsminor.yy68, yymsp[0].minor.yy68); } - yymsp[-3].minor.yy344 = yylhsminor.yy344; + yymsp[-3].minor.yy68 = yylhsminor.yy68; break; - case 223: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy344 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy344, yymsp[0].minor.yy344); } - yymsp[-3].minor.yy344 = yylhsminor.yy344; + case 225: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy68 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy68, yymsp[0].minor.yy68); } + yymsp[-3].minor.yy68 = yylhsminor.yy68; break; - case 228: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 232: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==232); -{ yymsp[-1].minor.yy344 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 230: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 234: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==234); +{ yymsp[-1].minor.yy68 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 229: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 233: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==233); -{ yymsp[-3].minor.yy344 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 231: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 235: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==235); +{ yymsp[-3].minor.yy68 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 230: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 234: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==234); -{ yymsp[-3].minor.yy344 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 232: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 236: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==236); +{ yymsp[-3].minor.yy68 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 235: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy344 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy344); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 237: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy68); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 236: /* search_condition ::= common_expression */ -{ yylhsminor.yy344 = releaseRawExprNode(pCxt, yymsp[0].minor.yy344); } - yymsp[0].minor.yy344 = yylhsminor.yy344; + case 238: /* search_condition ::= common_expression */ +{ yylhsminor.yy68 = releaseRawExprNode(pCxt, yymsp[0].minor.yy68); } + yymsp[0].minor.yy68 = yylhsminor.yy68; break; - case 239: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy344 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy344), yymsp[-1].minor.yy2, yymsp[0].minor.yy217); } - yymsp[-2].minor.yy344 = yylhsminor.yy344; + case 241: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy68 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), yymsp[-1].minor.yy54, yymsp[0].minor.yy53); } + yymsp[-2].minor.yy68 = yylhsminor.yy68; break; - case 240: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy2 = ORDER_ASC; } + case 242: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy54 = ORDER_ASC; } break; - case 241: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy2 = ORDER_ASC; } + case 243: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy54 = ORDER_ASC; } break; - case 242: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy2 = ORDER_DESC; } + case 244: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy54 = ORDER_DESC; } break; - case 243: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy217 = NULL_ORDER_DEFAULT; } + case 245: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy53 = NULL_ORDER_DEFAULT; } break; - case 244: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy217 = NULL_ORDER_FIRST; } + case 246: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy53 = NULL_ORDER_FIRST; } break; - case 245: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy217 = NULL_ORDER_LAST; } + case 247: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy53 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/parserAstTest.cpp b/source/libs/parser/test/parserAstTest.cpp index 119e94dde9..259c4712ba 100644 --- a/source/libs/parser/test/parserAstTest.cpp +++ b/source/libs/parser/test/parserAstTest.cpp @@ -405,3 +405,10 @@ TEST_F(ParserTest, createSmaIndex) { bind("create sma index index1 on t1 function(max(c1), min(c3 + 10), sum(c4)) INTERVAL(10s)"); ASSERT_TRUE(run()); } + +TEST_F(ParserTest, createQnode) { + setDatabase("root", "test"); + + bind("create qnode on dnode 1"); + ASSERT_TRUE(run()); +} From da65b721d6ea0efd1b0360a406f36cd3f94e9b67 Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Tue, 15 Mar 2022 20:07:48 +0800 Subject: [PATCH 07/37] rename --- source/util/src/tuuid.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/source/util/src/tuuid.c b/source/util/src/tuuid.c index ceca33436a..69cf7baaad 100644 --- a/source/util/src/tuuid.c +++ b/source/util/src/tuuid.c @@ -15,43 +15,43 @@ #include "tuuid.h" -static int64_t hashId = 0; -static int32_t SerialNo = 0; +static int64_t tUUIDHashId = 0; +static int32_t tUUIDSerialNo = 0; int32_t tGenIdPI32(void) { - if (hashId == 0) { + if (tUUIDHashId == 0) { char uid[64]; int32_t code = taosGetSystemUUID(uid, tListLen(uid)); if (code != TSDB_CODE_SUCCESS) { terrno = TAOS_SYSTEM_ERROR(errno); } else { - hashId = MurmurHash3_32(uid, strlen(uid)); + tUUIDHashId = MurmurHash3_32(uid, strlen(uid)); } } int64_t ts = taosGetTimestampMs(); uint64_t pid = taosGetPId(); - int32_t val = atomic_add_fetch_32(&SerialNo, 1); + int32_t val = atomic_add_fetch_32(&tUUIDSerialNo, 1); - int32_t id = ((hashId & 0x1F) << 26) | ((pid & 0x3F) << 20) | ((ts & 0xFFF) << 8) | (val & 0xFF); + int32_t id = ((tUUIDHashId & 0x1F) << 26) | ((pid & 0x3F) << 20) | ((ts & 0xFFF) << 8) | (val & 0xFF); return id; } int64_t tGenIdPI64(void) { - if (hashId == 0) { + if (tUUIDHashId == 0) { char uid[64]; int32_t code = taosGetSystemUUID(uid, tListLen(uid)); if (code != TSDB_CODE_SUCCESS) { terrno = TAOS_SYSTEM_ERROR(errno); } else { - hashId = MurmurHash3_32(uid, strlen(uid)); + tUUIDHashId = MurmurHash3_32(uid, strlen(uid)); } } int64_t ts = taosGetTimestampMs(); uint64_t pid = taosGetPId(); - int32_t val = atomic_add_fetch_32(&SerialNo, 1); + int32_t val = atomic_add_fetch_32(&tUUIDSerialNo, 1); - int64_t id = ((hashId & 0x07FF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF); + int64_t id = ((tUUIDHashId & 0x07FF) << 52) | ((pid & 0x0FFF) << 40) | ((ts & 0xFFFFFF) << 16) | (val & 0xFFFF); return id; } From 23bef711fca8a687246a42296c91467c1a14df58 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Tue, 15 Mar 2022 21:35:04 +0800 Subject: [PATCH 08/37] Feature/sangshuduo/td 13063 3.0 windows (#10720) * [TD-13063]: 3.0 on Windows * add pthread in contrib * fix linux compile * fix osSemaphore * add gnu regex for Windows * fix compile error for Windows * support arm platform * port more OS files * fix for Windows compile * port more files * fix macOS on x86_64 * port osFile * port osSemaphone.h * port osSocket.c * port tconfig.c * port ttimer.c * add couple files --- Jenkinsfile2 | 3 +- cmake/cmake.define | 11 ++- cmake/cmake.platform | 57 +++++++++---- include/os/os.h | 10 +++ include/os/osEok.h | 93 ++++++++++++++++++++++ include/os/osFile.h | 19 ++++- include/os/osSemaphore.h | 12 +-- include/os/osSocket.h | 35 +++++++- include/os/osSysinfo.h | 3 +- source/common/src/tdatablock.c | 9 ++- source/common/src/ttszip.c | 4 + source/libs/catalog/src/catalog.c | 8 +- source/libs/index/src/index.c | 1 + source/libs/index/src/index_cache.c | 3 + source/libs/index/src/index_fst.c | 6 ++ source/libs/parser/src/parInsert.c | 2 + source/libs/planner/src/planLogicCreater.c | 1 + source/libs/scalar/src/filter.c | 4 +- source/libs/scalar/src/scalar.c | 3 + source/libs/scheduler/src/schFlowCtrl.c | 4 +- source/libs/sync/src/syncRaftEntry.c | 16 ++-- source/libs/sync/src/syncVoteMgr.c | 22 ++--- source/libs/tfs/src/tfs.c | 4 +- source/libs/transport/src/transCli.c | 3 + source/libs/transport/src/transComm.c | 6 +- source/libs/transport/src/transSrv.c | 4 + source/libs/wal/src/walRead.c | 2 +- source/os/src/osFile.c | 17 ++-- source/os/src/osSocket.c | 12 ++- source/util/src/tconfig.c | 3 +- source/util/src/ttimer.c | 2 +- 31 files changed, 297 insertions(+), 82 deletions(-) create mode 100644 include/os/osEok.h diff --git a/Jenkinsfile2 b/Jenkinsfile2 index ad62fa7044..bf55e016b6 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -60,8 +60,9 @@ def pre_test(){ sh ''' cd ${WKC} git checkout 3.0 + [ -d contrib/bdb ] && cd contrib/bdb && git clean -fxd && cd ../.. ''' - } + } else{ sh ''' cd ${WKC} diff --git a/cmake/cmake.define b/cmake/cmake.define index b97c10a4b7..9c2d5dc04c 100644 --- a/cmake/cmake.define +++ b/cmake/cmake.define @@ -36,7 +36,14 @@ IF (TD_WINDOWS) ENDIF () ELSE () - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -fPIC -gdwarf-2 -msse4.2 -mfma -g3") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fPIC -gdwarf-2 -msse4.2 -mfma -g3") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -fPIC -gdwarf-2 -g3") + SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -fPIC -gdwarf-2 -g3") + +MESSAGE("System processor ID: ${CMAKE_SYSTEM_PROCESSOR}") +IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64") + ADD_DEFINITIONS("-D_TD_ARM_") +ELSE () + ADD_DEFINITIONS("-msse4.2 -mfma") +ENDIF () ENDIF () diff --git a/cmake/cmake.platform b/cmake/cmake.platform index 7ef259ba54..0312f92a5b 100644 --- a/cmake/cmake.platform +++ b/cmake/cmake.platform @@ -7,31 +7,53 @@ SET(TD_LINUX FALSE) SET(TD_WINDOWS FALSE) SET(TD_DARWIN FALSE) -IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") +MESSAGE("Compiler ID: ${CMAKE_CXX_COMPILER_ID}") +if(CMAKE_COMPILER_IS_GNUCXX MATCHES 1) + set(CXX_COMPILER_IS_GNU TRUE) +else() + set(CXX_COMPILER_IS_GNU FALSE) +endif() - SET(TD_LINUX TRUE) - SET(OSTYPE "Linux") - ADD_DEFINITIONS("-DLINUX") +MESSAGE("Current system name is ${CMAKE_SYSTEM_NAME}.") - IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8) - SET(TD_LINUX_64 TRUE) +IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + + IF (${CXX_COMPILER_IS_GNU}) + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") ELSE () - SET(TD_LINUX_32 TRUE) + ADD_DEFINITIONS("-Wno-tautological-constant-out-of-range-compare -Wno-pointer-sign -Wno-unknown-warning-option") + set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -undefined dynamic_lookup") + set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -undefined dynamic_lookup") ENDIF () -ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux") - SET(TD_DARWIN TRUE) - SET(OSTYPE "macOS") - ADD_DEFINITIONS("-DDARWIN") - IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64") - MESSAGE("Current system arch is arm64") - SET(TD_DARWIN_64 TRUE) - ADD_DEFINITIONS("-D_TD_DARWIN_64") + SET(TD_LINUX TRUE) + SET(OSTYPE "Linux") + ADD_DEFINITIONS("-DLINUX") + + IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8) + SET(TD_LINUX_64 TRUE) + ELSE () + SET(TD_LINUX_32 TRUE) + ENDIF () + + ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + + SET(TD_DARWIN TRUE) + SET(OSTYPE "macOS") + ADD_DEFINITIONS("-DDARWIN -Wno-tautological-pointer-compare") + + MESSAGE("Current system processor is ${CMAKE_SYSTEM_PROCESSOR}.") + IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") + MESSAGE("Current system arch is arm64") + SET(TD_DARWIN_64 TRUE) + ADD_DEFINITIONS("-D_TD_DARWIN_64") + ENDIF () + + ADD_DEFINITIONS("-DHAVE_UNISTD_H") ENDIF () - ADD_DEFINITIONS("-DHAVE_UNISTD_H") - ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Windows") SET(TD_WINDOWS TRUE) @@ -45,6 +67,7 @@ ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Windows") SET(TD_WINDOWS_32 TRUE) ADD_DEFINITIONS("-D_TD_WINDOWS_32") ENDIF () + ENDIF() MESSAGE("C Compiler ID: ${CMAKE_C_COMPILER_ID}") diff --git a/include/os/os.h b/include/os/os.h index fd272b15a3..12f4e733c2 100644 --- a/include/os/os.h +++ b/include/os/os.h @@ -22,6 +22,8 @@ extern "C" { #include #include +#include +#include #if !defined(WINDOWS) #include @@ -34,7 +36,12 @@ extern "C" { #include #include #include + +#if defined(DARWIN) +#else #include +#include +#endif #endif @@ -54,9 +61,12 @@ extern "C" { #include #include #include +#include #include +#include #include #include +#include #include diff --git a/include/os/osEok.h b/include/os/osEok.h new file mode 100644 index 0000000000..3ca476f840 --- /dev/null +++ b/include/os/osEok.h @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef TDENGINE_OS_EOK_H +#define TDENGINE_OS_EOK_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __APPLE__ + +enum EPOLL_EVENTS + { + EPOLLIN = 0x001, +#define EPOLLIN EPOLLIN + EPOLLPRI = 0x002, +#define EPOLLPRI EPOLLPRI + EPOLLOUT = 0x004, +#define EPOLLOUT EPOLLOUT + EPOLLRDNORM = 0x040, +#define EPOLLRDNORM EPOLLRDNORM + EPOLLRDBAND = 0x080, +#define EPOLLRDBAND EPOLLRDBAND + EPOLLWRNORM = 0x100, +#define EPOLLWRNORM EPOLLWRNORM + EPOLLWRBAND = 0x200, +#define EPOLLWRBAND EPOLLWRBAND + EPOLLMSG = 0x400, +#define EPOLLMSG EPOLLMSG + EPOLLERR = 0x008, +#define EPOLLERR EPOLLERR + EPOLLHUP = 0x010, +#define EPOLLHUP EPOLLHUP + EPOLLRDHUP = 0x2000, +#define EPOLLRDHUP EPOLLRDHUP + EPOLLEXCLUSIVE = 1u << 28, +#define EPOLLEXCLUSIVE EPOLLEXCLUSIVE + EPOLLWAKEUP = 1u << 29, +#define EPOLLWAKEUP EPOLLWAKEUP + EPOLLONESHOT = 1u << 30, +#define EPOLLONESHOT EPOLLONESHOT + EPOLLET = 1u << 31 +#define EPOLLET EPOLLET + }; + +/* Valid opcodes ( "op" parameter ) to issue to epoll_ctl(). */ +#define EPOLL_CTL_ADD 1 /* Add a file descriptor to the interface. */ +#define EPOLL_CTL_DEL 2 /* Remove a file descriptor from the interface. */ +#define EPOLL_CTL_MOD 3 /* Change file descriptor epoll_event structure. */ + + +typedef union epoll_data +{ + void *ptr; + int fd; + uint32_t u32; + uint64_t u64; +} epoll_data_t; + +struct epoll_event +{ + uint32_t events; /* Epoll events */ + epoll_data_t data; /* User data variable */ +}; + +int epoll_create(int size); +int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event); +int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout); +int epoll_close(int epfd); + +#endif // __APPLE__ + +#ifdef __cplusplus +} +#endif + +#endif // _eok_h_fd274616_996c_400e_9023_ae70be881fa3_ + diff --git a/include/os/osFile.h b/include/os/osFile.h index b0e97e7b54..58a9df2504 100644 --- a/include/os/osFile.h +++ b/include/os/osFile.h @@ -49,6 +49,15 @@ int64_t taosRead(FileFd fd, void *buf, int64_t count); #define PATH_MAX 256 #endif +typedef int32_t FileFd; + +typedef struct TdFile { + pthread_rwlock_t rwlock; + int refId; + FileFd fd; + FILE *fp; +} * TdFilePtr, TdFile; + typedef struct TdFile *TdFilePtr; #define TD_FILE_CTEATE 0x0001 @@ -101,8 +110,16 @@ int64_t taosCopyFile(const char *from, const char *to); int32_t taosRemoveFile(const char *path); void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath); - + +#if defined(_TD_DARWIN_64) +typedef int32_t SocketFd; + +int64_t taosSendFile(SocketFd fdDst, FileFd pFileSrc, int64_t *offset, int64_t size); +int64_t taosFSendFile(FILE *pFileOut, FILE *pFileIn, int64_t *offset, int64_t size); +#else +int64_t taosSendFile(SocketFd fdDst, TdFilePtr pFileSrc, int64_t *offset, int64_t size); int64_t taosFSendFile(TdFilePtr pFileOut, TdFilePtr pFileIn, int64_t *offset, int64_t size); +#endif void *taosMmapReadOnlyFile(TdFilePtr pFile, int64_t length); bool taosValidFile(TdFilePtr pFile); diff --git a/include/os/osSemaphore.h b/include/os/osSemaphore.h index 9904170d61..4bac81754d 100644 --- a/include/os/osSemaphore.h +++ b/include/os/osSemaphore.h @@ -38,12 +38,12 @@ extern "C" { #endif #if defined (_TD_DARWIN_64) - #define pthread_rwlock_t pthread_mutex_t - #define pthread_rwlock_init(lock, NULL) pthread_mutex_init(lock, NULL) - #define pthread_rwlock_destroy(lock) pthread_mutex_destroy(lock) - #define pthread_rwlock_wrlock(lock) pthread_mutex_lock(lock) - #define pthread_rwlock_rdlock(lock) pthread_mutex_lock(lock) - #define pthread_rwlock_unlock(lock) pthread_mutex_unlock(lock) +// #define pthread_rwlock_t pthread_mutex_t +// #define pthread_rwlock_init(lock, NULL) pthread_mutex_init(lock, NULL) +// #define pthread_rwlock_destroy(lock) pthread_mutex_destroy(lock) +// #define pthread_rwlock_wrlock(lock) pthread_mutex_lock(lock) +// #define pthread_rwlock_rdlock(lock) pthread_mutex_lock(lock) +// #define pthread_rwlock_unlock(lock) pthread_mutex_unlock(lock) #define pthread_spinlock_t pthread_mutex_t #define pthread_spin_init(lock, NULL) pthread_mutex_init(lock, NULL) diff --git a/include/os/osSocket.h b/include/os/osSocket.h index 3faed855ba..520d3af331 100644 --- a/include/os/osSocket.h +++ b/include/os/osSocket.h @@ -33,8 +33,15 @@ #include #include #else - #include - #include + #include + #include + + #if defined(_TD_DARWIN_64) + #include + #else + #include + #include + #endif #endif #ifdef __cplusplus @@ -49,7 +56,29 @@ extern "C" { #endif #if defined(_TD_DARWIN_64) - #define htobe64 htonll +// #define htobe64 htonll + +# include + +# define htobe16(x) OSSwapHostToBigInt16(x) +# define htole16(x) OSSwapHostToLittleInt16(x) +# define be16toh(x) OSSwapBigToHostInt16(x) +# define le16toh(x) OSSwapLittleToHostInt16(x) + +# define htobe32(x) OSSwapHostToBigInt32(x) +# define htole32(x) OSSwapHostToLittleInt32(x) +# define be32toh(x) OSSwapBigToHostInt32(x) +# define le32toh(x) OSSwapLittleToHostInt32(x) + +# define htobe64(x) OSSwapHostToBigInt64(x) +# define htole64(x) OSSwapHostToLittleInt64(x) +# define be64toh(x) OSSwapBigToHostInt64(x) +# define le64toh(x) OSSwapLittleToHostInt64(x) + +# define __BYTE_ORDER BYTE_ORDER +# define __BIG_ENDIAN BIG_ENDIAN +# define __LITTLE_ENDIAN LITTLE_ENDIAN +# define __PDP_ENDIAN PDP_ENDIAN #endif #define TAOS_EPOLL_WAIT_TIME 500 diff --git a/include/os/osSysinfo.h b/include/os/osSysinfo.h index d7cf05a594..7777466973 100644 --- a/include/os/osSysinfo.h +++ b/include/os/osSysinfo.h @@ -16,6 +16,7 @@ #ifndef _TD_OS_SYSINFO_H_ #define _TD_OS_SYSINFO_H_ +#include #include "os.h" #ifdef __cplusplus @@ -52,7 +53,7 @@ int32_t taosGetSystemUUID(char *uid, int32_t uidlen); char *taosGetCmdlineByPID(int32_t pid); void taosSetCoreDump(bool enable); -#if defined(WINDOWS) +#if !defined(LINUX) #define _UTSNAME_LENGTH 65 #define _UTSNAME_MACHINE_LENGTH _UTSNAME_LENGTH diff --git a/source/common/src/tdatablock.c b/source/common/src/tdatablock.c index 7e4f1d9025..0d1f762db6 100644 --- a/source/common/src/tdatablock.c +++ b/source/common/src/tdatablock.c @@ -864,7 +864,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullFirs qsort(pColInfoData->pData, pDataBlock->info.rows, pColInfoData->info.bytes, fn); int64_t p1 = taosGetTimestampUs(); - printf("sort:%ld, rows:%d\n", p1 - p0, pDataBlock->info.rows); + printf("sort:%" PRId64 ", rows:%d\n", p1 - p0, pDataBlock->info.rows); return TSDB_CODE_SUCCESS; } else { // var data type @@ -912,7 +912,7 @@ int32_t blockDataSort(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullFirs copyBackToBlock(pDataBlock, pCols); int64_t p4 = taosGetTimestampUs(); - printf("sort:%ld, create:%ld, assign:%ld, copyback:%ld, rows:%d\n", p1-p0, p2 - p1, p3 - p2, p4-p3, rows); + printf("sort:%" PRId64 ", create:%" PRId64 ", assign:%" PRId64 ", copyback:%" PRId64 ", rows:%d\n", p1-p0, p2 - p1, p3 - p2, p4-p3, rows); destroyTupleIndex(index); return TSDB_CODE_SUCCESS; @@ -1017,7 +1017,7 @@ int32_t dataBlockCompar_rv(const void* p1, const void* p2, const void* param) { } int32_t varColSort(SColumnInfoData* pColumnInfoData, SBlockOrderInfo* pOrder) { - + return 0; } int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullFirst) { @@ -1055,8 +1055,9 @@ int32_t blockDataSort_rv(SSDataBlock* pDataBlock, SArray* pOrderInfo, bool nullF copyBackToBlock(pDataBlock, pCols); int64_t p4 = taosGetTimestampUs(); - printf("sort:%ld, create:%ld, assign:%ld, copyback:%ld, rows:%d\n", p1 - p0, p2 - p1, p3 - p2, p4 - p3, rows); + printf("sort:%" PRId64 ", create:%" PRId64", assign:%" PRId64 ", copyback:%" PRId64 ", rows:%d\n", p1 - p0, p2 - p1, p3 - p2, p4 - p3, rows); // destroyTupleIndex(index); + return 0; } void blockDataClearup(SSDataBlock* pDataBlock) { diff --git a/source/common/src/ttszip.c b/source/common/src/ttszip.c index 464c29d287..5f0a353226 100644 --- a/source/common/src/ttszip.c +++ b/source/common/src/ttszip.c @@ -845,7 +845,11 @@ int32_t tsBufMerge(STSBuf* pDestBuf, const STSBuf* pSrcBuf) { int64_t offset = getDataStartOffset(); int32_t size = (int32_t)pSrcBuf->fileSize - (int32_t)offset; +#if defined(_TD_DARWIN_64) + int64_t written = taosFSendFile(pDestBuf->pFile->fp, pSrcBuf->pFile->fp, &offset, size); +#else int64_t written = taosFSendFile(pDestBuf->pFile, pSrcBuf->pFile, &offset, size); +#endif if (written == -1 || written != size) { return -1; diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index e1ccb03c66..80a0b3554c 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -1062,7 +1062,7 @@ int32_t ctgMetaRentInit(SCtgRentMgmt *mgmt, uint32_t rentSec, int8_t type) { int32_t ctgMetaRentAdd(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size) { - int16_t widx = abs(id % mgmt->slotNum); + int16_t widx = abs((int)(id % mgmt->slotNum)); SCtgRentSlot *slot = &mgmt->slots[widx]; int32_t code = 0; @@ -1092,11 +1092,11 @@ _return: } int32_t ctgMetaRentUpdate(SCtgRentMgmt *mgmt, void *meta, int64_t id, int32_t size, __compar_fn_t sortCompare, __compar_fn_t searchCompare) { - int16_t widx = abs(id % mgmt->slotNum); + int16_t widx = abs((int)(id % mgmt->slotNum)); SCtgRentSlot *slot = &mgmt->slots[widx]; int32_t code = 0; - + CTG_LOCK(CTG_WRITE, &slot->lock); if (NULL == slot->meta) { qError("empty meta slot, id:%"PRIx64", slot idx:%d, type:%d", id, widx, mgmt->type); @@ -1133,7 +1133,7 @@ _return: } int32_t ctgMetaRentRemove(SCtgRentMgmt *mgmt, int64_t id, __compar_fn_t sortCompare, __compar_fn_t searchCompare) { - int16_t widx = abs(id % mgmt->slotNum); + int16_t widx = abs((int)(id % mgmt->slotNum)); SCtgRentSlot *slot = &mgmt->slots[widx]; int32_t code = 0; diff --git a/source/libs/index/src/index.c b/source/libs/index/src/index.c index 744f6ca70b..d25fed6816 100644 --- a/source/libs/index/src/index.c +++ b/source/libs/index/src/index.c @@ -240,6 +240,7 @@ int indexRebuild(SIndex* index, SIndexOpts* opts){ #ifdef USE_INVERTED_INDEX #endif + return 0; } SIndexOpts* indexOptsCreate() { diff --git a/source/libs/index/src/index_cache.c b/source/libs/index/src/index_cache.c index b40ded9e9a..34f009dd7e 100644 --- a/source/libs/index/src/index_cache.c +++ b/source/libs/index/src/index_cache.c @@ -190,7 +190,10 @@ int indexCacheSchedToMerge(IndexCache* pCache) { schedMsg.msg = NULL; taosScheduleTask(indexQhandle, &schedMsg); + + return 0; } + static void indexCacheMakeRoomForWrite(IndexCache* cache) { while (true) { if (cache->occupiedMem * MEM_ESTIMATE_RADIO < MEM_THRESHOLD) { diff --git a/source/libs/index/src/index_fst.c b/source/libs/index/src/index_fst.c index a6cabbd439..18cde151d2 100644 --- a/source/libs/index/src/index_fst.c +++ b/source/libs/index/src/index_fst.c @@ -571,6 +571,8 @@ uint64_t fstStateFindInput(FstState* s, FstNode* node, uint8_t b, bool* null) { } fstSliceDestroy(&t); } + + return 0; } // fst node function @@ -1027,6 +1029,8 @@ Fst* fstCreate(FstSlice* slice) { FST_CREAT_FAILED: free(fst->meta); free(fst); + + return NULL; } void fstDestroy(Fst* fst) { if (fst) { @@ -1286,6 +1290,8 @@ bool streamWithStateSeekMin(StreamWithState* sws, FstBoundWithData* min) { } return false; } + + return false; } StreamWithStateResult* streamWithStateNextWith(StreamWithState* sws, StreamCallback callback) { diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 43cc308483..28f680cfbb 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -763,6 +763,8 @@ static int32_t parseTagsClause(SInsertParseContext* pCxt, SSchema* pTagsSchema, // todo construct payload tfree(row); + + return 0; } // pSql -> stb_name [(tag1_name, ...)] TAGS (tag1_value, ...) diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 3fae580de9..cd9857c7f6 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -425,6 +425,7 @@ static SLogicNode* createQueryLogicNode(SLogicPlanContext* pCxt, SNode* pStmt) { default: break; } + return NULL; // to avoid compiler error } int32_t createLogicPlan(SPlanContext* pCxt, SLogicNode** pLogicNode) { diff --git a/source/libs/scalar/src/filter.c b/source/libs/scalar/src/filter.c index a7aea5a7e5..33ec8ab6ef 100644 --- a/source/libs/scalar/src/filter.c +++ b/source/libs/scalar/src/filter.c @@ -792,7 +792,7 @@ int32_t filterDetachCnfGroups(SArray* group, SArray* left, SArray* right) { } SFilterGroup *gp = NULL; - while (gp = (SFilterGroup *)taosArrayPop(right)) { + while ((gp = (SFilterGroup *)taosArrayPop(right)) != NULL) { taosArrayPush(group, gp); } @@ -801,7 +801,7 @@ int32_t filterDetachCnfGroups(SArray* group, SArray* left, SArray* right) { if (taosArrayGetSize(right) <= 0) { SFilterGroup *gp = NULL; - while (gp = (SFilterGroup *)taosArrayPop(left)) { + while ((gp = (SFilterGroup *)taosArrayPop(left)) != NULL) { taosArrayPush(group, gp); } diff --git a/source/libs/scalar/src/scalar.c b/source/libs/scalar/src/scalar.c index b8cdda9ed1..8e7eaa0f8c 100644 --- a/source/libs/scalar/src/scalar.c +++ b/source/libs/scalar/src/scalar.c @@ -239,6 +239,9 @@ int32_t sclInitParam(SNode* node, SScalarParam *param, SScalarCtx *ctx, int32_t break; } + + default: + break; } if (param->num > *rowNum) { diff --git a/source/libs/scheduler/src/schFlowCtrl.c b/source/libs/scheduler/src/schFlowCtrl.c index 9fba6523b6..993521da87 100644 --- a/source/libs/scheduler/src/schFlowCtrl.c +++ b/source/libs/scheduler/src/schFlowCtrl.c @@ -282,8 +282,10 @@ int32_t schLaunchTasksInFlowCtrlList(SSchJob *pJob, SSchTask *pTask) { SCH_ERR_RET(TSDB_CODE_SCH_INTERNAL_ERROR); } - SCH_ERR_RET(schLaunchTasksInFlowCtrlListImpl(pJob, ctrl)); + int32_t code = schLaunchTasksInFlowCtrlListImpl(pJob, ctrl);; + SCH_ERR_RET(code); + return code; // to avoid compiler error } diff --git a/source/libs/sync/src/syncRaftEntry.c b/source/libs/sync/src/syncRaftEntry.c index f29b3022d8..7ececf285a 100644 --- a/source/libs/sync/src/syncRaftEntry.c +++ b/source/libs/sync/src/syncRaftEntry.c @@ -74,12 +74,12 @@ cJSON* syncEntry2Json(const SSyncRaftEntry* pEntry) { cJSON_AddNumberToObject(pRoot, "bytes", pEntry->bytes); cJSON_AddNumberToObject(pRoot, "msgType", pEntry->msgType); cJSON_AddNumberToObject(pRoot, "originalRpcType", pEntry->originalRpcType); - snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->seqNum); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pEntry->seqNum); cJSON_AddStringToObject(pRoot, "seqNum", u64buf); cJSON_AddNumberToObject(pRoot, "isWeak", pEntry->isWeak); - snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pEntry->term); cJSON_AddStringToObject(pRoot, "term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->index); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pEntry->index); cJSON_AddStringToObject(pRoot, "index", u64buf); cJSON_AddNumberToObject(pRoot, "dataLen", pEntry->dataLen); @@ -107,26 +107,26 @@ char* syncEntry2Str(const SSyncRaftEntry* pEntry) { // for debug ---------------------- void syncEntryPrint(const SSyncRaftEntry* pObj) { char* serialized = syncEntry2Str(pObj); - printf("syncEntryPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncEntryPrint | len:%zu | %s \n", strlen(serialized), serialized); fflush(NULL); free(serialized); } void syncEntryPrint2(char* s, const SSyncRaftEntry* pObj) { char* serialized = syncEntry2Str(pObj); - printf("syncEntryPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncEntryPrint2 | len:%zu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); free(serialized); } void syncEntryLog(const SSyncRaftEntry* pObj) { char* serialized = syncEntry2Str(pObj); - sTrace("syncEntryLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("syncEntryLog | len:%zu | %s", strlen(serialized), serialized); free(serialized); } void syncEntryLog2(char* s, const SSyncRaftEntry* pObj) { char* serialized = syncEntry2Str(pObj); - sTrace("syncEntryLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("syncEntryLog2 | len:%zu | %s | %s", strlen(serialized), s, serialized); free(serialized); -} \ No newline at end of file +} diff --git a/source/libs/sync/src/syncVoteMgr.c b/source/libs/sync/src/syncVoteMgr.c index 5c8e70979c..6cb6a28805 100644 --- a/source/libs/sync/src/syncVoteMgr.c +++ b/source/libs/sync/src/syncVoteMgr.c @@ -97,7 +97,7 @@ cJSON *voteGranted2Json(SVotesGranted *pVotesGranted) { cJSON_AddItemToObject(pRoot, "isGranted", pIsGranted); cJSON_AddNumberToObject(pRoot, "votes", pVotesGranted->votes); - snprintf(u64buf, sizeof(u64buf), "%lu", pVotesGranted->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pVotesGranted->term); cJSON_AddStringToObject(pRoot, "term", u64buf); cJSON_AddNumberToObject(pRoot, "quorum", pVotesGranted->quorum); cJSON_AddNumberToObject(pRoot, "toLeader", pVotesGranted->toLeader); @@ -122,27 +122,27 @@ char *voteGranted2Str(SVotesGranted *pVotesGranted) { // for debug ------------------- void voteGrantedPrint(SVotesGranted *pObj) { char *serialized = voteGranted2Str(pObj); - printf("voteGrantedPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("voteGrantedPrint | len:%zu | %s \n", strlen(serialized), serialized); fflush(NULL); free(serialized); } void voteGrantedPrint2(char *s, SVotesGranted *pObj) { char *serialized = voteGranted2Str(pObj); - printf("voteGrantedPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("voteGrantedPrint2 | len:%zu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); free(serialized); } void voteGrantedLog(SVotesGranted *pObj) { char *serialized = voteGranted2Str(pObj); - sTrace("voteGrantedLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("voteGrantedLog | len:%zu | %s", strlen(serialized), serialized); free(serialized); } void voteGrantedLog2(char *s, SVotesGranted *pObj) { char *serialized = voteGranted2Str(pObj); - sTrace("voteGrantedLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("voteGrantedLog2 | len:%zu | %s | %s", strlen(serialized), s, serialized); free(serialized); } @@ -222,7 +222,7 @@ cJSON *votesRespond2Json(SVotesRespond *pVotesRespond) { cJSON_AddItemToObject(pRoot, "isRespond", pIsRespond); cJSON_AddNumberToObject(pRoot, "respondNum", respondNum); - snprintf(u64buf, sizeof(u64buf), "%lu", pVotesRespond->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pVotesRespond->term); cJSON_AddStringToObject(pRoot, "term", u64buf); snprintf(u64buf, sizeof(u64buf), "%p", pVotesRespond->pSyncNode); cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); @@ -242,26 +242,26 @@ char *votesRespond2Str(SVotesRespond *pVotesRespond) { // for debug ------------------- void votesRespondPrint(SVotesRespond *pObj) { char *serialized = votesRespond2Str(pObj); - printf("votesRespondPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("votesRespondPrint | len:%zu | %s \n", strlen(serialized), serialized); fflush(NULL); free(serialized); } void votesRespondPrint2(char *s, SVotesRespond *pObj) { char *serialized = votesRespond2Str(pObj); - printf("votesRespondPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("votesRespondPrint2 | len:%zu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); free(serialized); } void votesRespondLog(SVotesRespond *pObj) { char *serialized = votesRespond2Str(pObj); - sTrace("votesRespondLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("votesRespondLog | len:%zu | %s", strlen(serialized), serialized); free(serialized); } void votesRespondLog2(char *s, SVotesRespond *pObj) { char *serialized = votesRespond2Str(pObj); - sTrace("votesRespondLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("votesRespondLog2 | len:%zu | %s | %s", strlen(serialized), s, serialized); free(serialized); -} \ No newline at end of file +} diff --git a/source/libs/tfs/src/tfs.c b/source/libs/tfs/src/tfs.c index c46989dc5d..01e9808aa6 100644 --- a/source/libs/tfs/src/tfs.c +++ b/source/libs/tfs/src/tfs.c @@ -558,4 +558,6 @@ int32_t tfsGetMonitorInfo(STfs *pTfs, SMonDiskInfo *pInfo) { } } tfsUnLock(pTfs); -} \ No newline at end of file + + return 0; +} diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 2f6ff3763f..5be1b7ea90 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -291,6 +291,7 @@ void* destroyConnPool(void* pool) { connList = taosHashIterate((SHashObj*)pool, connList); } taosHashCleanup(pool); + return NULL; } static SCliConn* getConnFromPool(void* pool, char* ip, uint32_t port) { @@ -576,6 +577,8 @@ static void* cliWorkThread(void* arg) { SCliThrdObj* pThrd = (SCliThrdObj*)arg; setThreadName("trans-cli-work"); uv_run(pThrd->loop, UV_RUN_DEFAULT); + + return NULL; } void* transInitClient(uint32_t ip, uint32_t port, char* label, int numOfThreads, void* fp, void* shandle) { diff --git a/source/libs/transport/src/transComm.c b/source/libs/transport/src/transComm.c index 367cb33fc9..7123593a33 100644 --- a/source/libs/transport/src/transComm.c +++ b/source/libs/transport/src/transComm.c @@ -155,14 +155,16 @@ bool transReadComplete(SConnBuffer* connBuf) { } return false; } -int transPackMsg(STransMsgHead* msgHead, bool sercured, bool auth) {} +int transPackMsg(STransMsgHead* msgHead, bool sercured, bool auth) {return 0;} -int transUnpackMsg(STransMsgHead* msgHead) {} +int transUnpackMsg(STransMsgHead* msgHead) {return 0;} int transDestroyBuffer(SConnBuffer* buf) { if (buf->cap > 0) { tfree(buf->buf); } transClearBuffer(buf); + + return 0; } int transSetConnOption(uv_tcp_t* stream) { diff --git a/source/libs/transport/src/transSrv.c b/source/libs/transport/src/transSrv.c index cb3bbaefec..d26c5ec0f4 100644 --- a/source/libs/transport/src/transSrv.c +++ b/source/libs/transport/src/transSrv.c @@ -538,6 +538,8 @@ void* acceptThread(void* arg) { setThreadName("trans-accept"); SServerObj* srv = (SServerObj*)arg; uv_run(srv->loop, UV_RUN_DEFAULT); + + return NULL; } static bool addHandleToWorkloop(void* arg) { SWorkThrdObj* pThrd = arg; @@ -593,6 +595,8 @@ void* workerThread(void* arg) { setThreadName("trans-worker"); SWorkThrdObj* pThrd = (SWorkThrdObj*)arg; uv_run(pThrd->loop, UV_RUN_DEFAULT); + + return NULL; } static SSrvConn* createConn(void* hThrd) { diff --git a/source/libs/wal/src/walRead.c b/source/libs/wal/src/walRead.c index 9e1ffeae7f..8d3acef9e7 100644 --- a/source/libs/wal/src/walRead.c +++ b/source/libs/wal/src/walRead.c @@ -169,7 +169,7 @@ int32_t walReadWithHandle(SWalReadHandle *pRead, int64_t ver) { } if (pRead->pHead->head.version != ver) { - wError("unexpected wal log version: %ld, read request version:%ld", pRead->pHead->head.version, ver); + wError("unexpected wal log version: %" PRId64 ", read request version:%" PRId64 "", pRead->pHead->head.version, ver); pRead->curVersion = -1; terrno = TSDB_CODE_WAL_FILE_CORRUPTED; return -1; diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c index 6472202bf9..bcbd95e160 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -14,6 +14,7 @@ */ #define ALLOW_FORBID_FUNC #include "os.h" +#include "osSemaphore.h" #if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) #include @@ -35,26 +36,18 @@ extern int openU(const char *, int, ...); /* MsvcLibX UTF-8 version of open */ #else #include #include -#include + +#if !defined(_TD_DARWIN_64) + #include +#endif #include #include #define LINUX_FILE_NO_TEXT_OPTION 0 #define O_TEXT LINUX_FILE_NO_TEXT_OPTION #endif -typedef int32_t FileFd; - #define FILE_WITH_LOCK 1 -typedef struct TdFile { -#if FILE_WITH_LOCK - pthread_rwlock_t rwlock; -#endif - int refId; - FileFd fd; - FILE *fp; -} * TdFilePtr, TdFile; - void taosGetTmpfilePath(const char *inputTmpDir, const char *fileNamePrefix, char *dstPath) { #if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) const char *tdengineTmpFileNamePrefix = "tdengine-"; diff --git a/source/os/src/osSocket.c b/source/os/src/osSocket.c index 698ceded16..e3b1015d88 100644 --- a/source/os/src/osSocket.c +++ b/source/os/src/osSocket.c @@ -17,7 +17,7 @@ #define ALLOW_FORBID_FUNC #include "os.h" -#if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) +#if defined(WINDOWS) #include #include #include @@ -37,8 +37,14 @@ #include #include #include -#include #include + +#if defined(DARWIN) + #include + #include "osEok.h" +#else + #include +#endif #endif typedef int32_t SocketFd; @@ -210,7 +216,7 @@ int32_t taosShutDownSocketServerRDWR(TdSocketServerPtr pSocketServer) { #endif } -#if (defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)) +#if (defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32)) #if defined(_TD_GO_DLL_) uint64_t htonll(uint64_t val) { return (((uint64_t)htonl(val)) << 32) + htonl(val >> 32); } #endif diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index d4bcc27f60..404c9c8f71 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -570,6 +570,7 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) { case CFG_DTYPE_LOCALE: case CFG_DTYPE_CHARSET: case CFG_DTYPE_TIMEZONE: + case CFG_DTYPE_NONE: if (dump) { printf("%s %s %s", src, name, pItem->str); printf("\n"); @@ -655,4 +656,4 @@ int32_t cfgLoadFromCfgFile(SConfig *pConfig, const char *filepath) { int32_t cfgLoadFromApollUrl(SConfig *pConfig, const char *url) { uInfo("load from apoll url %s", url); return 0; -} \ No newline at end of file +} diff --git a/source/util/src/ttimer.c b/source/util/src/ttimer.c index 7bdcf3cc64..46bca6e6cb 100644 --- a/source/util/src/ttimer.c +++ b/source/util/src/ttimer.c @@ -628,7 +628,7 @@ void taosTmrCleanUp(void* handle) { tmrCtrls = NULL; unusedTmrCtrl = NULL; -#if !defined(WINDOWS) +#if defined(LINUX) tmrModuleInit = PTHREAD_ONCE_INIT; // to support restart #endif } From 4f330fab1fe48f8eb925a2f57e6b9f7d71de6422 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Tue, 15 Mar 2022 23:47:37 +0800 Subject: [PATCH 09/37] handle except --- include/libs/transport/trpc.h | 2 +- source/libs/transport/inc/transComm.h | 3 ++ source/libs/transport/src/trans.c | 13 ++++-- source/libs/transport/src/transCli.c | 63 +++++++++++++++++++++++---- source/libs/transport/src/transSrv.c | 7 ++- source/libs/transport/test/transUT.cc | 53 +++++++++++++++++++++- 6 files changed, 126 insertions(+), 15 deletions(-) diff --git a/include/libs/transport/trpc.h b/include/libs/transport/trpc.h index 231bc4af45..b5b8d6ab66 100644 --- a/include/libs/transport/trpc.h +++ b/include/libs/transport/trpc.h @@ -94,7 +94,7 @@ int rpcReportProgress(void *pConn, char *pCont, int contLen); void rpcCancelRequest(int64_t rid); // just release client conn to rpc instance, no close sock -void rpcReleaseHandle(void *handle); +void rpcReleaseHandle(void *handle, int8_t type); void rpcRefHandle(void *handle, int8_t type); void rpcUnrefHandle(void *handle, int8_t type); diff --git a/source/libs/transport/inc/transComm.h b/source/libs/transport/inc/transComm.h index 76347cdba2..8ea65b193d 100644 --- a/source/libs/transport/inc/transComm.h +++ b/source/libs/transport/inc/transComm.h @@ -252,6 +252,9 @@ void transUnrefSrvHandle(void* handle); void transRefCliHandle(void* handle); void transUnrefCliHandle(void* handle); +void transReleaseCliHandle(void* handle); +void transReleaseSrvHandle(void* handle); + void transSendRequest(void* shandle, const char* ip, uint32_t port, STransMsg* pMsg); void transSendRecv(void* shandle, const char* ip, uint32_t port, STransMsg* pMsg, STransMsg* pRsp); void transSendResponse(const STransMsg* pMsg); diff --git a/source/libs/transport/src/trans.c b/source/libs/transport/src/trans.c index 213782c5bd..2cab03f133 100644 --- a/source/libs/transport/src/trans.c +++ b/source/libs/transport/src/trans.c @@ -22,6 +22,11 @@ void* (*taosInitHandle[])(uint32_t ip, uint32_t port, char* label, int numOfThre void (*taosCloseHandle[])(void* arg) = {transCloseServer, transCloseClient}; +void (*taosRefHandle[])(void* handle) = {transRefSrvHandle, transRefCliHandle}; +void (*taosUnRefHandle[])(void* handle) = {transUnrefSrvHandle, transUnrefCliHandle}; + +void (*transReleaseHandle[])(void* handle) = {transReleaseSrvHandle, transReleaseCliHandle}; + void* rpcOpen(const SRpcInit* pInit) { SRpcInfo* pRpc = calloc(1, sizeof(SRpcInfo)); if (pRpc == NULL) { @@ -127,9 +132,6 @@ void rpcSendRecv(void* shandle, SEpSet* pEpSet, SRpcMsg* pMsg, SRpcMsg* pRsp) { void rpcSendResponse(const SRpcMsg* pMsg) { transSendResponse(pMsg); } int rpcGetConnInfo(void* thandle, SRpcConnInfo* pInfo) { return transGetConnInfo((void*)thandle, pInfo); } -void (*taosRefHandle[])(void* handle) = {transRefSrvHandle, transRefCliHandle}; -void (*taosUnRefHandle[])(void* handle) = {transUnrefSrvHandle, transUnrefCliHandle}; - void rpcRefHandle(void* handle, int8_t type) { assert(type == TAOS_CONN_SERVER || type == TAOS_CONN_CLIENT); (*taosRefHandle[type])(handle); @@ -140,6 +142,11 @@ void rpcUnrefHandle(void* handle, int8_t type) { (*taosUnRefHandle[type])(handle); } +void rpcReleaseHandle(void* handle, int8_t type) { + assert(type == TAOS_CONN_SERVER || type == TAOS_CONN_CLIENT); + (*transReleaseHandle[type])(handle); +} + int32_t rpcInit() { // impl later return 0; diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 5c50ca2bc3..931f58097e 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -17,6 +17,11 @@ #include "transComm.h" +// Normal(default): send/recv msg +// Quit: quit rpc inst +// Release: release handle to rpc inst +typedef enum { Normal, Quit, Release } SCliMsgType; + typedef struct SCliConn { T_REF_DECLARE() uv_connect_t connReq; @@ -49,6 +54,7 @@ typedef struct SCliMsg { STransMsg msg; queue q; uint64_t st; + SCliMsgType type; } SCliMsg; typedef struct SCliThrdObj { @@ -108,6 +114,8 @@ static void cliHandleExcept(SCliConn* conn); // handle req from app static void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd); static void cliHandleQuit(SCliMsg* pMsg, SCliThrdObj* pThrd); +static void cliHandleRelease(SCliMsg* pMsg, SCliThrdObj* pThrd); + static void cliSendQuit(SCliThrdObj* thrd); static void destroyUserdata(STransMsg* userdata); @@ -121,8 +129,8 @@ static void destroyThrdObj(SCliThrdObj* pThrd); #define CONN_HOST_THREAD_INDEX(conn) (conn ? ((SCliConn*)conn)->hThrdIdx : -1) #define CONN_PERSIST_TIME(para) (para * 1000 * 10) - -#define CONN_GET_INST_LABEL(conn) (((STrans*)(((SCliThrdObj*)conn->hostThrd)->pTransInst))->label) +#define CONN_GET_HOST_THREAD(conn) (conn ? ((SCliConn*)conn)->hostThrd : NULL) +#define CONN_GET_INST_LABEL(conn) (((STrans*)(((SCliThrdObj*)(conn)->hostThrd)->pTransInst))->label) #define CONN_HANDLE_THREAD_QUIT(conn, thrd) \ do { \ if (thrd->quit) { \ @@ -344,6 +352,8 @@ static void addConnToPool(void* pool, SCliConn* conn) { static void cliAllocRecvBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) { SCliConn* conn = handle->data; SConnBuffer* pBuf = &conn->readBuf; + // avoid conn + QUEUE_REMOVE(&conn->conn); transAllocBuffer(pBuf, buf); } static void cliRecvCb(uv_stream_t* handle, ssize_t nread, const uv_buf_t* buf) { @@ -506,6 +516,21 @@ static void cliHandleQuit(SCliMsg* pMsg, SCliThrdObj* pThrd) { pThrd->quit = true; uv_stop(pThrd->loop); } +static void cliHandleRelease(SCliMsg* pMsg, SCliThrdObj* pThrd) { + SCliConn* conn = pMsg->msg.handle; + tDebug("%s cli conn %p release to inst", CONN_GET_INST_LABEL(conn), conn); + + destroyCmsg(pMsg); + conn->data = NULL; + + transDestroyBuffer(&conn->readBuf); + if (conn->persist && T_REF_VAL_GET(conn) >= 2) { + transUnrefCliHandle(conn); + addConnToPool(pThrd->pool, conn); + } else { + transUnrefCliHandle(conn); + } +} SCliConn* cliGetConn(SCliMsg* pMsg, SCliThrdObj* pThrd) { SCliConn* conn = NULL; @@ -517,7 +542,9 @@ SCliConn* cliGetConn(SCliMsg* pMsg, SCliThrdObj* pThrd) { } else { STransConnCtx* pCtx = pMsg->ctx; conn = getConnFromPool(pThrd->pool, pCtx->ip, pCtx->port); - if (conn != NULL) tTrace("%s cli conn %p get from conn pool", CONN_GET_INST_LABEL(conn), conn); + if (conn != NULL) { + tTrace("%s cli conn %p get from conn pool", CONN_GET_INST_LABEL(conn), conn); + } } return conn; } @@ -572,10 +599,13 @@ static void cliAsyncCb(uv_async_t* handle) { QUEUE_REMOVE(h); SCliMsg* pMsg = QUEUE_DATA(h, SCliMsg, q); - if (pMsg->ctx == NULL) { - cliHandleQuit(pMsg, pThrd); - } else { + + if (pMsg->type == Normal) { cliHandleReq(pMsg, pThrd); + } else if (pMsg->type == Quit) { + cliHandleQuit(pMsg, pThrd); + } else if (pMsg->type == Release) { + cliHandleRelease(pMsg, pThrd); } count++; } @@ -671,8 +701,10 @@ static void transDestroyConnCtx(STransConnCtx* ctx) { void cliSendQuit(SCliThrdObj* thrd) { // cli can stop gracefully SCliMsg* msg = calloc(1, sizeof(SCliMsg)); + msg->type = Quit; transSendAsync(thrd->asyncPool, &msg->q); } + int cliRBChoseIdx(STrans* pTransInst) { int64_t index = pTransInst->index; if (pTransInst->index++ >= pTransInst->numOfThreads) { @@ -702,10 +734,25 @@ void transUnrefCliHandle(void* handle) { return; } int ref = T_REF_DEC((SCliConn*)handle); + tDebug("%s cli conn %p ref %d", CONN_GET_INST_LABEL((SCliConn*)handle), handle, ref); if (ref == 0) { cliDestroyConn((SCliConn*)handle, true); } } +void transReleaseCliHandle(void* handle) { + SCliThrdObj* thrd = CONN_GET_HOST_THREAD(handle); + if (thrd == NULL) { + return; + } + + STransMsg tmsg = {.handle = handle}; + + SCliMsg* cmsg = calloc(1, sizeof(SCliMsg)); + cmsg->type = Release; + cmsg->msg = tmsg; + + transSendAsync(thrd->asyncPool, &cmsg->q); +} void transSendRequest(void* shandle, const char* ip, uint32_t port, STransMsg* pMsg) { STrans* pTransInst = (STrans*)shandle; @@ -728,7 +775,7 @@ void transSendRequest(void* shandle, const char* ip, uint32_t port, STransMsg* p assert(pTransInst->connType == TAOS_CONN_CLIENT); // atomic or not - SCliMsg* cliMsg = malloc(sizeof(SCliMsg)); + SCliMsg* cliMsg = calloc(1, sizeof(SCliMsg)); cliMsg->ctx = pCtx; cliMsg->msg = *pMsg; cliMsg->st = taosGetTimestampUs(); @@ -753,7 +800,7 @@ void transSendRecv(void* shandle, const char* ip, uint32_t port, STransMsg* pReq pCtx->pRsp = pRsp; tsem_init(pCtx->pSem, 0, 0); - SCliMsg* cliMsg = malloc(sizeof(SCliMsg)); + SCliMsg* cliMsg = calloc(1, sizeof(SCliMsg)); cliMsg->ctx = pCtx; cliMsg->msg = *pReq; cliMsg->st = taosGetTimestampUs(); diff --git a/source/libs/transport/src/transSrv.c b/source/libs/transport/src/transSrv.c index a3cc6b6181..960e064b8f 100644 --- a/source/libs/transport/src/transSrv.c +++ b/source/libs/transport/src/transSrv.c @@ -641,7 +641,7 @@ static void uvDestroyConn(uv_handle_t* handle) { uv_timer_stop(&conn->pTimer); QUEUE_REMOVE(&conn->queue); free(conn->pTcp); - free(conn); + // free(conn); if (thrd->quit && QUEUE_IS_EMPTY(&thrd->conn)) { uv_loop_close(thrd->loop); @@ -786,6 +786,11 @@ void transUnrefSrvHandle(void* handle) { } // unref srv handle } + +void transReleaseSrvHandle(void* handle) { + // do nothing currently + // +} void transSendResponse(const STransMsg* pMsg) { if (pMsg->handle == NULL) { return; diff --git a/source/libs/transport/test/transUT.cc b/source/libs/transport/test/transUT.cc index b0fae2f8b4..46f6424b0b 100644 --- a/source/libs/transport/test/transUT.cc +++ b/source/libs/transport/test/transUT.cc @@ -110,6 +110,14 @@ class Client { SemWait(); *resp = this->resp; } + void SendAndRecvNoHandle(SRpcMsg *req, SRpcMsg *resp) { + if (req->handle != NULL) { + rpcReleaseHandle(req->handle, TAOS_CONN_CLIENT); + req->handle = NULL; + } + SendAndRecv(req, resp); + } + void SendWithHandle(SRpcMsg *req, SRpcMsg *resp) {} void SemWait() { tsem_wait(&this->sem); } void SemPost() { tsem_post(&this->sem); } @@ -268,6 +276,7 @@ class TransObj { } void RestartSrv() { srv->Restart(); } void cliSendAndRecv(SRpcMsg *req, SRpcMsg *resp) { cli->SendAndRecv(req, resp); } + void cliSendAndRecvNoHandle(SRpcMsg *req, SRpcMsg *resp) { cli->SendAndRecvNoHandle(req, resp); } ~TransObj() { delete cli; @@ -352,7 +361,47 @@ TEST_F(TransEnv, cliPersistHandle) { EXPECT_TRUE(resp.code != 0); } } + ////////////////// +} +TEST_F(TransEnv, cliReleaseHandle) { + tr->SetCliPersistFp(cliPersistHandle); + + SRpcMsg resp = {0}; + for (int i = 0; i < 10; i++) { + SRpcMsg req = {.handle = resp.handle}; + req.msgType = 1; + req.pCont = rpcMallocCont(10); + req.contLen = 10; + tr->cliSendAndRecvNoHandle(&req, &resp); + // if (i == 5) { + // std::cout << "stop server" << std::endl; + // tr->StopSrv(); + //} + // if (i >= 6) { + EXPECT_TRUE(resp.code == 0); + //} + } + ////////////////// +} +TEST_F(TransEnv, cliReleaseHandleExcept) { + tr->SetCliPersistFp(cliPersistHandle); + + SRpcMsg resp = {0}; + for (int i = 0; i < 10; i++) { + SRpcMsg req = {.handle = resp.handle}; + req.msgType = 1; + req.pCont = rpcMallocCont(10); + req.contLen = 10; + tr->cliSendAndRecvNoHandle(&req, &resp); + if (i == 5) { + std::cout << "stop server" << std::endl; + tr->StopSrv(); + } + if (i >= 6) { + EXPECT_TRUE(resp.code != 0); + } + } ////////////////// } TEST_F(TransEnv, srvContinueSend) { @@ -367,11 +416,11 @@ TEST_F(TransEnv, srvContinueSend) { taosMsleep(2000); } -TEST_F(TransEnv, srvPersisHandleExcept) { +TEST_F(TransEnv, srvPersistHandleExcept) { // conn breken // } -TEST_F(TransEnv, cliPersisHandleExcept) { +TEST_F(TransEnv, cliPersistHandleExcept) { // conn breken } From 6e9bc0cbd9c6d4bd88a572ca877b2ad8286f20bd Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 16 Mar 2022 09:08:42 +0800 Subject: [PATCH 10/37] handle except --- source/libs/transport/src/transCli.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 931f58097e..3696e86d22 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -525,6 +525,7 @@ static void cliHandleRelease(SCliMsg* pMsg, SCliThrdObj* pThrd) { transDestroyBuffer(&conn->readBuf); if (conn->persist && T_REF_VAL_GET(conn) >= 2) { + conn->persist = false; transUnrefCliHandle(conn); addConnToPool(pThrd->pool, conn); } else { @@ -746,8 +747,7 @@ void transReleaseCliHandle(void* handle) { } STransMsg tmsg = {.handle = handle}; - - SCliMsg* cmsg = calloc(1, sizeof(SCliMsg)); + SCliMsg* cmsg = calloc(1, sizeof(SCliMsg)); cmsg->type = Release; cmsg->msg = tmsg; From b5b1417a8b0b3d9e5b19d6845b1625de817ff8d4 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 16 Mar 2022 10:54:06 +0800 Subject: [PATCH 11/37] sync append entries (sync-io) --- source/libs/sync/inc/syncRaftStore.h | 12 +- source/libs/sync/src/syncIndexMgr.c | 34 +- source/libs/sync/src/syncMain.c | 235 +++++------ source/libs/sync/src/syncMessage.c | 560 +++++++++++++------------ source/libs/sync/src/syncRaftEntry.c | 42 +- source/libs/sync/src/syncRaftLog.c | 36 +- source/libs/sync/src/syncRaftStore.c | 53 ++- source/libs/sync/src/syncVoteMgr.c | 94 +++-- source/libs/sync/test/syncInitTest.cpp | 1 + 9 files changed, 565 insertions(+), 502 deletions(-) diff --git a/source/libs/sync/inc/syncRaftStore.h b/source/libs/sync/inc/syncRaftStore.h index 30f7c5d9f7..62bb94c834 100644 --- a/source/libs/sync/inc/syncRaftStore.h +++ b/source/libs/sync/inc/syncRaftStore.h @@ -43,11 +43,13 @@ int32_t raftStorePersist(SRaftStore *pRaftStore); int32_t raftStoreSerialize(SRaftStore *pRaftStore, char *buf, size_t len); int32_t raftStoreDeserialize(SRaftStore *pRaftStore, char *buf, size_t len); -bool raftStoreHasVoted(SRaftStore *pRaftStore); -void raftStoreVote(SRaftStore *pRaftStore, SRaftId *pRaftId); -void raftStoreClearVote(SRaftStore *pRaftStore); -void raftStoreNextTerm(SRaftStore *pRaftStore); -void raftStoreSetTerm(SRaftStore *pRaftStore, SyncTerm term); +bool raftStoreHasVoted(SRaftStore *pRaftStore); +void raftStoreVote(SRaftStore *pRaftStore, SRaftId *pRaftId); +void raftStoreClearVote(SRaftStore *pRaftStore); +void raftStoreNextTerm(SRaftStore *pRaftStore); +void raftStoreSetTerm(SRaftStore *pRaftStore, SyncTerm term); +cJSON *raftStore2Json(SRaftStore *pRaftStore); +char *raftStore2Str(SRaftStore *pRaftStore); // for debug ------------------- void raftStorePrint(SRaftStore *pObj); diff --git a/source/libs/sync/src/syncIndexMgr.c b/source/libs/sync/src/syncIndexMgr.c index 9567938197..58a61ba77e 100644 --- a/source/libs/sync/src/syncIndexMgr.c +++ b/source/libs/sync/src/syncIndexMgr.c @@ -70,22 +70,24 @@ cJSON *syncIndexMgr2Json(SSyncIndexMgr *pSyncIndexMgr) { char u64buf[128]; cJSON *pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "replicaNum", pSyncIndexMgr->replicaNum); - cJSON *pReplicas = cJSON_CreateArray(); - cJSON_AddItemToObject(pRoot, "replicas", pReplicas); - for (int i = 0; i < pSyncIndexMgr->replicaNum; ++i) { - cJSON_AddItemToArray(pReplicas, syncUtilRaftId2Json(&(*(pSyncIndexMgr->replicas))[i])); + if (pSyncIndexMgr != NULL) { + cJSON_AddNumberToObject(pRoot, "replicaNum", pSyncIndexMgr->replicaNum); + cJSON *pReplicas = cJSON_CreateArray(); + cJSON_AddItemToObject(pRoot, "replicas", pReplicas); + for (int i = 0; i < pSyncIndexMgr->replicaNum; ++i) { + cJSON_AddItemToArray(pReplicas, syncUtilRaftId2Json(&(*(pSyncIndexMgr->replicas))[i])); + } + int respondNum = 0; + int *arr = (int *)malloc(sizeof(int) * pSyncIndexMgr->replicaNum); + for (int i = 0; i < pSyncIndexMgr->replicaNum; ++i) { + arr[i] = pSyncIndexMgr->index[i]; + } + cJSON *pIndex = cJSON_CreateIntArray(arr, pSyncIndexMgr->replicaNum); + free(arr); + cJSON_AddItemToObject(pRoot, "index", pIndex); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncIndexMgr->pSyncNode); + cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); } - int respondNum = 0; - int *arr = (int *)malloc(sizeof(int) * pSyncIndexMgr->replicaNum); - for (int i = 0; i < pSyncIndexMgr->replicaNum; ++i) { - arr[i] = pSyncIndexMgr->index[i]; - } - cJSON *pIndex = cJSON_CreateIntArray(arr, pSyncIndexMgr->replicaNum); - free(arr); - cJSON_AddItemToObject(pRoot, "index", pIndex); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncIndexMgr->pSyncNode); - cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); cJSON *pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "pSyncIndexMgr", pRoot); @@ -94,7 +96,7 @@ cJSON *syncIndexMgr2Json(SSyncIndexMgr *pSyncIndexMgr) { char *syncIndexMgr2Str(SSyncIndexMgr *pSyncIndexMgr) { cJSON *pJson = syncIndexMgr2Json(pSyncIndexMgr); - char * serialized = cJSON_Print(pJson); + char *serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index dd2c142104..48a57dc0fb 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -355,128 +355,129 @@ cJSON* syncNode2Json(const SSyncNode* pSyncNode) { char u64buf[128]; cJSON* pRoot = cJSON_CreateObject(); - // init by SSyncInfo - cJSON_AddNumberToObject(pRoot, "vgId", pSyncNode->vgId); - cJSON_AddStringToObject(pRoot, "path", pSyncNode->path); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pWal); - cJSON_AddStringToObject(pRoot, "pWal", u64buf); + if (pSyncNode != NULL) { + // init by SSyncInfo + cJSON_AddNumberToObject(pRoot, "vgId", pSyncNode->vgId); + cJSON_AddStringToObject(pRoot, "path", pSyncNode->path); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pWal); + cJSON_AddStringToObject(pRoot, "pWal", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->rpcClient); - cJSON_AddStringToObject(pRoot, "rpcClient", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpSendMsg); - cJSON_AddStringToObject(pRoot, "FpSendMsg", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->rpcClient); + cJSON_AddStringToObject(pRoot, "rpcClient", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpSendMsg); + cJSON_AddStringToObject(pRoot, "FpSendMsg", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->queue); - cJSON_AddStringToObject(pRoot, "queue", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpEqMsg); - cJSON_AddStringToObject(pRoot, "FpEqMsg", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->queue); + cJSON_AddStringToObject(pRoot, "queue", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpEqMsg); + cJSON_AddStringToObject(pRoot, "FpEqMsg", u64buf); - // init internal - cJSON* pMe = syncUtilNodeInfo2Json(&pSyncNode->myNodeInfo); - cJSON_AddItemToObject(pRoot, "myNodeInfo", pMe); - cJSON* pRaftId = syncUtilRaftId2Json(&pSyncNode->myRaftId); - cJSON_AddItemToObject(pRoot, "myRaftId", pRaftId); + // init internal + cJSON* pMe = syncUtilNodeInfo2Json(&pSyncNode->myNodeInfo); + cJSON_AddItemToObject(pRoot, "myNodeInfo", pMe); + cJSON* pRaftId = syncUtilRaftId2Json(&pSyncNode->myRaftId); + cJSON_AddItemToObject(pRoot, "myRaftId", pRaftId); - cJSON_AddNumberToObject(pRoot, "peersNum", pSyncNode->peersNum); - cJSON* pPeers = cJSON_CreateArray(); - cJSON_AddItemToObject(pRoot, "peersNodeInfo", pPeers); - for (int i = 0; i < pSyncNode->peersNum; ++i) { - cJSON_AddItemToArray(pPeers, syncUtilNodeInfo2Json(&pSyncNode->peersNodeInfo[i])); + cJSON_AddNumberToObject(pRoot, "peersNum", pSyncNode->peersNum); + cJSON* pPeers = cJSON_CreateArray(); + cJSON_AddItemToObject(pRoot, "peersNodeInfo", pPeers); + for (int i = 0; i < pSyncNode->peersNum; ++i) { + cJSON_AddItemToArray(pPeers, syncUtilNodeInfo2Json(&pSyncNode->peersNodeInfo[i])); + } + cJSON* pPeersId = cJSON_CreateArray(); + cJSON_AddItemToObject(pRoot, "peersId", pPeersId); + for (int i = 0; i < pSyncNode->peersNum; ++i) { + cJSON_AddItemToArray(pPeersId, syncUtilRaftId2Json(&pSyncNode->peersId[i])); + } + + cJSON_AddNumberToObject(pRoot, "replicaNum", pSyncNode->replicaNum); + cJSON* pReplicasId = cJSON_CreateArray(); + cJSON_AddItemToObject(pRoot, "replicasId", pReplicasId); + for (int i = 0; i < pSyncNode->replicaNum; ++i) { + cJSON_AddItemToArray(pReplicasId, syncUtilRaftId2Json(&pSyncNode->replicasId[i])); + } + + // raft algorithm + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pFsm); + cJSON_AddStringToObject(pRoot, "pFsm", u64buf); + cJSON_AddNumberToObject(pRoot, "quorum", pSyncNode->quorum); + cJSON* pLaderCache = syncUtilRaftId2Json(&pSyncNode->leaderCache); + cJSON_AddItemToObject(pRoot, "leaderCache", pLaderCache); + + // tla+ server vars + cJSON_AddNumberToObject(pRoot, "state", pSyncNode->state); + cJSON_AddStringToObject(pRoot, "state_str", syncUtilState2String(pSyncNode->state)); + cJSON* pRaftStore = raftStore2Json(pSyncNode->pRaftStore); + cJSON_AddItemToObject(pRoot, "pRaftStore", pRaftStore); + + // tla+ candidate vars + cJSON_AddItemToObject(pRoot, "pVotesGranted", voteGranted2Json(pSyncNode->pVotesGranted)); + cJSON_AddItemToObject(pRoot, "pVotesRespond", votesRespond2Json(pSyncNode->pVotesRespond)); + + // tla+ leader vars + cJSON_AddItemToObject(pRoot, "pNextIndex", syncIndexMgr2Json(pSyncNode->pNextIndex)); + cJSON_AddItemToObject(pRoot, "pMatchIndex", syncIndexMgr2Json(pSyncNode->pMatchIndex)); + + // tla+ log vars + cJSON_AddItemToObject(pRoot, "pLogStore", logStore2Json(pSyncNode->pLogStore)); + snprintf(u64buf, sizeof(u64buf), "%ld", pSyncNode->commitIndex); + cJSON_AddStringToObject(pRoot, "commitIndex", u64buf); + + // ping timer + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pPingTimer); + cJSON_AddStringToObject(pRoot, "pPingTimer", u64buf); + cJSON_AddNumberToObject(pRoot, "pingTimerMS", pSyncNode->pingTimerMS); + snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->pingTimerLogicClock); + cJSON_AddStringToObject(pRoot, "pingTimerLogicClock", u64buf); + snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->pingTimerLogicClockUser); + cJSON_AddStringToObject(pRoot, "pingTimerLogicClockUser", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpPingTimerCB); + cJSON_AddStringToObject(pRoot, "FpPingTimerCB", u64buf); + snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->pingTimerCounter); + cJSON_AddStringToObject(pRoot, "pingTimerCounter", u64buf); + + // elect timer + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pElectTimer); + cJSON_AddStringToObject(pRoot, "pElectTimer", u64buf); + cJSON_AddNumberToObject(pRoot, "electTimerMS", pSyncNode->electTimerMS); + snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->electTimerLogicClock); + cJSON_AddStringToObject(pRoot, "electTimerLogicClock", u64buf); + snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->electTimerLogicClockUser); + cJSON_AddStringToObject(pRoot, "electTimerLogicClockUser", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpElectTimerCB); + cJSON_AddStringToObject(pRoot, "FpElectTimerCB", u64buf); + snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->electTimerCounter); + cJSON_AddStringToObject(pRoot, "electTimerCounter", u64buf); + + // heartbeat timer + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pHeartbeatTimer); + cJSON_AddStringToObject(pRoot, "pHeartbeatTimer", u64buf); + cJSON_AddNumberToObject(pRoot, "heartbeatTimerMS", pSyncNode->heartbeatTimerMS); + snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->heartbeatTimerLogicClock); + cJSON_AddStringToObject(pRoot, "heartbeatTimerLogicClock", u64buf); + snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->heartbeatTimerLogicClockUser); + cJSON_AddStringToObject(pRoot, "heartbeatTimerLogicClockUser", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpHeartbeatTimerCB); + cJSON_AddStringToObject(pRoot, "FpHeartbeatTimerCB", u64buf); + snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->heartbeatTimerCounter); + cJSON_AddStringToObject(pRoot, "heartbeatTimerCounter", u64buf); + + // callback + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnPing); + cJSON_AddStringToObject(pRoot, "FpOnPing", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnPingReply); + cJSON_AddStringToObject(pRoot, "FpOnPingReply", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnRequestVote); + cJSON_AddStringToObject(pRoot, "FpOnRequestVote", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnRequestVoteReply); + cJSON_AddStringToObject(pRoot, "FpOnRequestVoteReply", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnAppendEntries); + cJSON_AddStringToObject(pRoot, "FpOnAppendEntries", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnAppendEntriesReply); + cJSON_AddStringToObject(pRoot, "FpOnAppendEntriesReply", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnTimeout); + cJSON_AddStringToObject(pRoot, "FpOnTimeout", u64buf); } - cJSON* pPeersId = cJSON_CreateArray(); - cJSON_AddItemToObject(pRoot, "peersId", pPeersId); - for (int i = 0; i < pSyncNode->peersNum; ++i) { - cJSON_AddItemToArray(pPeersId, syncUtilRaftId2Json(&pSyncNode->peersId[i])); - } - - cJSON_AddNumberToObject(pRoot, "replicaNum", pSyncNode->replicaNum); - cJSON* pReplicasId = cJSON_CreateArray(); - cJSON_AddItemToObject(pRoot, "replicasId", pReplicasId); - for (int i = 0; i < pSyncNode->replicaNum; ++i) { - cJSON_AddItemToArray(pReplicasId, syncUtilRaftId2Json(&pSyncNode->replicasId[i])); - } - - // raft algorithm - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pFsm); - cJSON_AddStringToObject(pRoot, "pFsm", u64buf); - cJSON_AddNumberToObject(pRoot, "quorum", pSyncNode->quorum); - cJSON* pLaderCache = syncUtilRaftId2Json(&pSyncNode->leaderCache); - cJSON_AddItemToObject(pRoot, "leaderCache", pLaderCache); - - // tla+ server vars - cJSON_AddNumberToObject(pRoot, "state", pSyncNode->state); - cJSON_AddStringToObject(pRoot, "state_str", syncUtilState2String(pSyncNode->state)); - char tmpBuf[RAFT_STORE_BLOCK_SIZE]; - raftStoreSerialize(pSyncNode->pRaftStore, tmpBuf, sizeof(tmpBuf)); - cJSON_AddStringToObject(pRoot, "pRaftStore", tmpBuf); - - // tla+ candidate vars - cJSON_AddItemToObject(pRoot, "pVotesGranted", voteGranted2Json(pSyncNode->pVotesGranted)); - cJSON_AddItemToObject(pRoot, "pVotesRespond", votesRespond2Json(pSyncNode->pVotesRespond)); - - // tla+ leader vars - cJSON_AddItemToObject(pRoot, "pNextIndex", syncIndexMgr2Json(pSyncNode->pNextIndex)); - cJSON_AddItemToObject(pRoot, "pMatchIndex", syncIndexMgr2Json(pSyncNode->pMatchIndex)); - - // tla+ log vars - cJSON_AddItemToObject(pRoot, "pLogStore", logStore2Json(pSyncNode->pLogStore)); - snprintf(u64buf, sizeof(u64buf), "%ld", pSyncNode->commitIndex); - cJSON_AddStringToObject(pRoot, "commitIndex", u64buf); - - // ping timer - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pPingTimer); - cJSON_AddStringToObject(pRoot, "pPingTimer", u64buf); - cJSON_AddNumberToObject(pRoot, "pingTimerMS", pSyncNode->pingTimerMS); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->pingTimerLogicClock); - cJSON_AddStringToObject(pRoot, "pingTimerLogicClock", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->pingTimerLogicClockUser); - cJSON_AddStringToObject(pRoot, "pingTimerLogicClockUser", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpPingTimerCB); - cJSON_AddStringToObject(pRoot, "FpPingTimerCB", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->pingTimerCounter); - cJSON_AddStringToObject(pRoot, "pingTimerCounter", u64buf); - - // elect timer - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pElectTimer); - cJSON_AddStringToObject(pRoot, "pElectTimer", u64buf); - cJSON_AddNumberToObject(pRoot, "electTimerMS", pSyncNode->electTimerMS); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->electTimerLogicClock); - cJSON_AddStringToObject(pRoot, "electTimerLogicClock", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->electTimerLogicClockUser); - cJSON_AddStringToObject(pRoot, "electTimerLogicClockUser", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpElectTimerCB); - cJSON_AddStringToObject(pRoot, "FpElectTimerCB", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->electTimerCounter); - cJSON_AddStringToObject(pRoot, "electTimerCounter", u64buf); - - // heartbeat timer - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pHeartbeatTimer); - cJSON_AddStringToObject(pRoot, "pHeartbeatTimer", u64buf); - cJSON_AddNumberToObject(pRoot, "heartbeatTimerMS", pSyncNode->heartbeatTimerMS); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->heartbeatTimerLogicClock); - cJSON_AddStringToObject(pRoot, "heartbeatTimerLogicClock", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->heartbeatTimerLogicClockUser); - cJSON_AddStringToObject(pRoot, "heartbeatTimerLogicClockUser", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpHeartbeatTimerCB); - cJSON_AddStringToObject(pRoot, "FpHeartbeatTimerCB", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->heartbeatTimerCounter); - cJSON_AddStringToObject(pRoot, "heartbeatTimerCounter", u64buf); - - // callback - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnPing); - cJSON_AddStringToObject(pRoot, "FpOnPing", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnPingReply); - cJSON_AddStringToObject(pRoot, "FpOnPingReply", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnRequestVote); - cJSON_AddStringToObject(pRoot, "FpOnRequestVote", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnRequestVoteReply); - cJSON_AddStringToObject(pRoot, "FpOnRequestVoteReply", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnAppendEntries); - cJSON_AddStringToObject(pRoot, "FpOnAppendEntries", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnAppendEntriesReply); - cJSON_AddStringToObject(pRoot, "FpOnAppendEntriesReply", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpOnTimeout); - cJSON_AddStringToObject(pRoot, "FpOnTimeout", u64buf); cJSON* pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SSyncNode", pRoot); diff --git a/source/libs/sync/src/syncMessage.c b/source/libs/sync/src/syncMessage.c index 509ede274b..ac7cbe9ca4 100644 --- a/source/libs/sync/src/syncMessage.c +++ b/source/libs/sync/src/syncMessage.c @@ -212,17 +212,19 @@ SyncTimeout* syncTimeoutFromRpcMsg2(const SRpcMsg* pRpcMsg) { } cJSON* syncTimeout2Json(const SyncTimeout* pMsg) { - char u64buf[128]; - + char u64buf[128]; cJSON* pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); - cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); - cJSON_AddNumberToObject(pRoot, "timeoutType", pMsg->timeoutType); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->logicClock); - cJSON_AddStringToObject(pRoot, "logicClock", u64buf); - cJSON_AddNumberToObject(pRoot, "timerMS", pMsg->timerMS); - snprintf(u64buf, sizeof(u64buf), "%p", pMsg->data); - cJSON_AddStringToObject(pRoot, "data", u64buf); + + if (pMsg != NULL) { + cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); + cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); + cJSON_AddNumberToObject(pRoot, "timeoutType", pMsg->timeoutType); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->logicClock); + cJSON_AddStringToObject(pRoot, "logicClock", u64buf); + cJSON_AddNumberToObject(pRoot, "timerMS", pMsg->timerMS); + snprintf(u64buf, sizeof(u64buf), "%p", pMsg->data); + cJSON_AddStringToObject(pRoot, "data", u64buf); + } cJSON* pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SyncTimeout", pRoot); @@ -342,50 +344,52 @@ SyncPing* syncPingFromRpcMsg2(const SRpcMsg* pRpcMsg) { } cJSON* syncPing2Json(const SyncPing* pMsg) { - char u64buf[128]; - + char u64buf[128]; cJSON* pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); - cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); - cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); - cJSON_AddStringToObject(pSrcId, "addr", u64buf); - { - uint64_t u64 = pMsg->srcId.addr; - cJSON* pTmp = pSrcId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); + if (pMsg != NULL) { + cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); + cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); + + cJSON* pSrcId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + cJSON_AddStringToObject(pSrcId, "addr", u64buf); + { + uint64_t u64 = pMsg->srcId.addr; + cJSON* pTmp = pSrcId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); + cJSON_AddItemToObject(pRoot, "srcId", pSrcId); + + cJSON* pDestId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + cJSON_AddStringToObject(pDestId, "addr", u64buf); + { + uint64_t u64 = pMsg->destId.addr; + cJSON* pTmp = pDestId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); + cJSON_AddItemToObject(pRoot, "destId", pDestId); + + cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); + char* s; + s = syncUtilprintBin((char*)(pMsg->data), pMsg->dataLen); + cJSON_AddStringToObject(pRoot, "data", s); + free(s); + s = syncUtilprintBin2((char*)(pMsg->data), pMsg->dataLen); + cJSON_AddStringToObject(pRoot, "data2", s); + free(s); } - cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); - cJSON_AddItemToObject(pRoot, "srcId", pSrcId); - - cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); - cJSON_AddStringToObject(pDestId, "addr", u64buf); - { - uint64_t u64 = pMsg->destId.addr; - cJSON* pTmp = pDestId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); - } - cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); - cJSON_AddItemToObject(pRoot, "destId", pDestId); - - cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); - char* s; - s = syncUtilprintBin((char*)(pMsg->data), pMsg->dataLen); - cJSON_AddStringToObject(pRoot, "data", s); - free(s); - s = syncUtilprintBin2((char*)(pMsg->data), pMsg->dataLen); - cJSON_AddStringToObject(pRoot, "data2", s); - free(s); cJSON* pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SyncPing", pRoot); @@ -505,50 +509,52 @@ SyncPingReply* syncPingReplyFromRpcMsg2(const SRpcMsg* pRpcMsg) { } cJSON* syncPingReply2Json(const SyncPingReply* pMsg) { - char u64buf[128]; - + char u64buf[128]; cJSON* pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); - cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); - cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); - cJSON_AddStringToObject(pSrcId, "addr", u64buf); - { - uint64_t u64 = pMsg->srcId.addr; - cJSON* pTmp = pSrcId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); + if (pMsg != NULL) { + cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); + cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); + + cJSON* pSrcId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + cJSON_AddStringToObject(pSrcId, "addr", u64buf); + { + uint64_t u64 = pMsg->srcId.addr; + cJSON* pTmp = pSrcId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); + cJSON_AddItemToObject(pRoot, "srcId", pSrcId); + + cJSON* pDestId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + cJSON_AddStringToObject(pDestId, "addr", u64buf); + { + uint64_t u64 = pMsg->destId.addr; + cJSON* pTmp = pDestId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); + cJSON_AddItemToObject(pRoot, "destId", pDestId); + + cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); + char* s; + s = syncUtilprintBin((char*)(pMsg->data), pMsg->dataLen); + cJSON_AddStringToObject(pRoot, "data", s); + free(s); + s = syncUtilprintBin2((char*)(pMsg->data), pMsg->dataLen); + cJSON_AddStringToObject(pRoot, "data2", s); + free(s); } - cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); - cJSON_AddItemToObject(pRoot, "srcId", pSrcId); - - cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); - cJSON_AddStringToObject(pDestId, "addr", u64buf); - { - uint64_t u64 = pMsg->destId.addr; - cJSON* pTmp = pDestId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); - } - cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); - cJSON_AddItemToObject(pRoot, "destId", pDestId); - - cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); - char* s; - s = syncUtilprintBin((char*)(pMsg->data), pMsg->dataLen); - cJSON_AddStringToObject(pRoot, "data", s); - free(s); - s = syncUtilprintBin2((char*)(pMsg->data), pMsg->dataLen); - cJSON_AddStringToObject(pRoot, "data2", s); - free(s); cJSON* pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SyncPingReply", pRoot); @@ -664,24 +670,26 @@ SyncClientRequest* syncClientRequestFromRpcMsg2(const SRpcMsg* pRpcMsg) { } cJSON* syncClientRequest2Json(const SyncClientRequest* pMsg) { - char u64buf[128]; - + char u64buf[128]; cJSON* pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); - cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); - cJSON_AddNumberToObject(pRoot, "originalRpcType", pMsg->originalRpcType); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->seqNum); - cJSON_AddStringToObject(pRoot, "seqNum", u64buf); - cJSON_AddNumberToObject(pRoot, "isWeak", pMsg->isWeak); - cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); - char* s; - s = syncUtilprintBin((char*)(pMsg->data), pMsg->dataLen); - cJSON_AddStringToObject(pRoot, "data", s); - free(s); - s = syncUtilprintBin2((char*)(pMsg->data), pMsg->dataLen); - cJSON_AddStringToObject(pRoot, "data2", s); - free(s); + if (pMsg != NULL) { + cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); + cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); + cJSON_AddNumberToObject(pRoot, "originalRpcType", pMsg->originalRpcType); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->seqNum); + cJSON_AddStringToObject(pRoot, "seqNum", u64buf); + cJSON_AddNumberToObject(pRoot, "isWeak", pMsg->isWeak); + cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); + + char* s; + s = syncUtilprintBin((char*)(pMsg->data), pMsg->dataLen); + cJSON_AddStringToObject(pRoot, "data", s); + free(s); + s = syncUtilprintBin2((char*)(pMsg->data), pMsg->dataLen); + cJSON_AddStringToObject(pRoot, "data2", s); + free(s); + } cJSON* pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SyncClientRequest", pRoot); @@ -785,47 +793,49 @@ SyncRequestVote* syncRequestVoteFromRpcMsg2(const SRpcMsg* pRpcMsg) { } cJSON* syncRequestVote2Json(const SyncRequestVote* pMsg) { - char u64buf[128]; - + char u64buf[128]; cJSON* pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); - cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); - cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); - cJSON_AddStringToObject(pSrcId, "addr", u64buf); - { - uint64_t u64 = pMsg->srcId.addr; - cJSON* pTmp = pSrcId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); + if (pMsg != NULL) { + cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); + cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); + + cJSON* pSrcId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + cJSON_AddStringToObject(pSrcId, "addr", u64buf); + { + uint64_t u64 = pMsg->srcId.addr; + cJSON* pTmp = pSrcId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); + cJSON_AddItemToObject(pRoot, "srcId", pSrcId); + + cJSON* pDestId = cJSON_CreateObject(); + cJSON_AddNumberToObject(pDestId, "addr", pMsg->destId.addr); + { + uint64_t u64 = pMsg->destId.addr; + cJSON* pTmp = pDestId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); + cJSON_AddItemToObject(pRoot, "destId", pDestId); + + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + cJSON_AddStringToObject(pRoot, "term", u64buf); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->lastLogIndex); + cJSON_AddStringToObject(pRoot, "lastLogIndex", u64buf); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->lastLogTerm); + cJSON_AddStringToObject(pRoot, "lastLogTerm", u64buf); } - cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); - cJSON_AddItemToObject(pRoot, "srcId", pSrcId); - - cJSON* pDestId = cJSON_CreateObject(); - cJSON_AddNumberToObject(pDestId, "addr", pMsg->destId.addr); - { - uint64_t u64 = pMsg->destId.addr; - cJSON* pTmp = pDestId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); - } - cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); - cJSON_AddItemToObject(pRoot, "destId", pDestId); - - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); - cJSON_AddStringToObject(pRoot, "term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->lastLogIndex); - cJSON_AddStringToObject(pRoot, "lastLogIndex", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->lastLogTerm); - cJSON_AddStringToObject(pRoot, "lastLogTerm", u64buf); cJSON* pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SyncRequestVote", pRoot); @@ -929,44 +939,46 @@ SyncRequestVoteReply* syncRequestVoteReplyFromRpcMsg2(const SRpcMsg* pRpcMsg) { } cJSON* syncRequestVoteReply2Json(const SyncRequestVoteReply* pMsg) { - char u64buf[128]; - + char u64buf[128]; cJSON* pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); - cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); - cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); - cJSON_AddStringToObject(pSrcId, "addr", u64buf); - { - uint64_t u64 = pMsg->srcId.addr; - cJSON* pTmp = pSrcId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); + if (pMsg != NULL) { + cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); + cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); + + cJSON* pSrcId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + cJSON_AddStringToObject(pSrcId, "addr", u64buf); + { + uint64_t u64 = pMsg->srcId.addr; + cJSON* pTmp = pSrcId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); + cJSON_AddItemToObject(pRoot, "srcId", pSrcId); + + cJSON* pDestId = cJSON_CreateObject(); + cJSON_AddNumberToObject(pDestId, "addr", pMsg->destId.addr); + { + uint64_t u64 = pMsg->destId.addr; + cJSON* pTmp = pDestId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); + cJSON_AddItemToObject(pRoot, "destId", pDestId); + + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + cJSON_AddStringToObject(pRoot, "term", u64buf); + cJSON_AddNumberToObject(pRoot, "vote_granted", pMsg->voteGranted); } - cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); - cJSON_AddItemToObject(pRoot, "srcId", pSrcId); - - cJSON* pDestId = cJSON_CreateObject(); - cJSON_AddNumberToObject(pDestId, "addr", pMsg->destId.addr); - { - uint64_t u64 = pMsg->destId.addr; - cJSON* pTmp = pDestId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); - } - cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); - cJSON_AddItemToObject(pRoot, "destId", pDestId); - - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); - cJSON_AddStringToObject(pRoot, "term", u64buf); - cJSON_AddNumberToObject(pRoot, "vote_granted", pMsg->voteGranted); cJSON* pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SyncRequestVoteReply", pRoot); @@ -1072,62 +1084,64 @@ SyncAppendEntries* syncAppendEntriesFromRpcMsg2(const SRpcMsg* pRpcMsg) { } cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) { - char u64buf[128]; - + char u64buf[128]; cJSON* pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); - cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); - cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); - cJSON_AddStringToObject(pSrcId, "addr", u64buf); - { - uint64_t u64 = pMsg->srcId.addr; - cJSON* pTmp = pSrcId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); + if (pMsg != NULL) { + cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); + cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); + + cJSON* pSrcId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + cJSON_AddStringToObject(pSrcId, "addr", u64buf); + { + uint64_t u64 = pMsg->srcId.addr; + cJSON* pTmp = pSrcId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); + cJSON_AddItemToObject(pRoot, "srcId", pSrcId); + + cJSON* pDestId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + cJSON_AddStringToObject(pDestId, "addr", u64buf); + { + uint64_t u64 = pMsg->destId.addr; + cJSON* pTmp = pDestId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); + cJSON_AddItemToObject(pRoot, "destId", pDestId); + + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + cJSON_AddStringToObject(pRoot, "term", u64buf); + + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->prevLogIndex); + cJSON_AddStringToObject(pRoot, "pre_log_index", u64buf); + + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->prevLogTerm); + cJSON_AddStringToObject(pRoot, "pre_log_term", u64buf); + + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->commitIndex); + cJSON_AddStringToObject(pRoot, "commit_index", u64buf); + + cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); + char* s; + s = syncUtilprintBin((char*)(pMsg->data), pMsg->dataLen); + cJSON_AddStringToObject(pRoot, "data", s); + free(s); + s = syncUtilprintBin2((char*)(pMsg->data), pMsg->dataLen); + cJSON_AddStringToObject(pRoot, "data2", s); + free(s); } - cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); - cJSON_AddItemToObject(pRoot, "srcId", pSrcId); - - cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); - cJSON_AddStringToObject(pDestId, "addr", u64buf); - { - uint64_t u64 = pMsg->destId.addr; - cJSON* pTmp = pDestId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); - } - cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); - cJSON_AddItemToObject(pRoot, "destId", pDestId); - - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); - cJSON_AddStringToObject(pRoot, "term", u64buf); - - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->prevLogIndex); - cJSON_AddStringToObject(pRoot, "pre_log_index", u64buf); - - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->prevLogTerm); - cJSON_AddStringToObject(pRoot, "pre_log_term", u64buf); - - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->commitIndex); - cJSON_AddStringToObject(pRoot, "commit_index", u64buf); - - cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); - char* s; - s = syncUtilprintBin((char*)(pMsg->data), pMsg->dataLen); - cJSON_AddStringToObject(pRoot, "data", s); - free(s); - s = syncUtilprintBin2((char*)(pMsg->data), pMsg->dataLen); - cJSON_AddStringToObject(pRoot, "data2", s); - free(s); cJSON* pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SyncAppendEntries", pRoot); @@ -1231,47 +1245,49 @@ SyncAppendEntriesReply* syncAppendEntriesReplyFromRpcMsg2(const SRpcMsg* pRpcMsg } cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) { - char u64buf[128]; - + char u64buf[128]; cJSON* pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); - cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); - cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); - cJSON_AddStringToObject(pSrcId, "addr", u64buf); - { - uint64_t u64 = pMsg->srcId.addr; - cJSON* pTmp = pSrcId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); + if (pMsg != NULL) { + cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); + cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); + + cJSON* pSrcId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + cJSON_AddStringToObject(pSrcId, "addr", u64buf); + { + uint64_t u64 = pMsg->srcId.addr; + cJSON* pTmp = pSrcId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); + cJSON_AddItemToObject(pRoot, "srcId", pSrcId); + + cJSON* pDestId = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + cJSON_AddStringToObject(pDestId, "addr", u64buf); + { + uint64_t u64 = pMsg->destId.addr; + cJSON* pTmp = pDestId; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pTmp, "addr_host", host); + cJSON_AddNumberToObject(pTmp, "addr_port", port); + } + cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); + cJSON_AddItemToObject(pRoot, "destId", pDestId); + + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + cJSON_AddStringToObject(pRoot, "term", u64buf); + cJSON_AddNumberToObject(pRoot, "success", pMsg->success); + snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->matchIndex); + cJSON_AddStringToObject(pRoot, "matchIndex", u64buf); } - cJSON_AddNumberToObject(pSrcId, "vgId", pMsg->srcId.vgId); - cJSON_AddItemToObject(pRoot, "srcId", pSrcId); - - cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); - cJSON_AddStringToObject(pDestId, "addr", u64buf); - { - uint64_t u64 = pMsg->destId.addr; - cJSON* pTmp = pDestId; - char host[128]; - uint16_t port; - syncUtilU642Addr(u64, host, sizeof(host), &port); - cJSON_AddStringToObject(pTmp, "addr_host", host); - cJSON_AddNumberToObject(pTmp, "addr_port", port); - } - cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); - cJSON_AddItemToObject(pRoot, "destId", pDestId); - - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); - cJSON_AddStringToObject(pRoot, "term", u64buf); - cJSON_AddNumberToObject(pRoot, "success", pMsg->success); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->matchIndex); - cJSON_AddStringToObject(pRoot, "matchIndex", u64buf); cJSON* pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SyncAppendEntriesReply", pRoot); diff --git a/source/libs/sync/src/syncRaftEntry.c b/source/libs/sync/src/syncRaftEntry.c index f29b3022d8..41bfd7da1f 100644 --- a/source/libs/sync/src/syncRaftEntry.c +++ b/source/libs/sync/src/syncRaftEntry.c @@ -68,29 +68,31 @@ SSyncRaftEntry* syncEntryDeserialize(const char* buf, uint32_t len) { } cJSON* syncEntry2Json(const SSyncRaftEntry* pEntry) { - char u64buf[128]; - + char u64buf[128]; cJSON* pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "bytes", pEntry->bytes); - cJSON_AddNumberToObject(pRoot, "msgType", pEntry->msgType); - cJSON_AddNumberToObject(pRoot, "originalRpcType", pEntry->originalRpcType); - snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->seqNum); - cJSON_AddStringToObject(pRoot, "seqNum", u64buf); - cJSON_AddNumberToObject(pRoot, "isWeak", pEntry->isWeak); - snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->term); - cJSON_AddStringToObject(pRoot, "term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->index); - cJSON_AddStringToObject(pRoot, "index", u64buf); - cJSON_AddNumberToObject(pRoot, "dataLen", pEntry->dataLen); - char* s; - s = syncUtilprintBin((char*)(pEntry->data), pEntry->dataLen); - cJSON_AddStringToObject(pRoot, "data", s); - free(s); + if (pEntry != NULL) { + cJSON_AddNumberToObject(pRoot, "bytes", pEntry->bytes); + cJSON_AddNumberToObject(pRoot, "msgType", pEntry->msgType); + cJSON_AddNumberToObject(pRoot, "originalRpcType", pEntry->originalRpcType); + snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->seqNum); + cJSON_AddStringToObject(pRoot, "seqNum", u64buf); + cJSON_AddNumberToObject(pRoot, "isWeak", pEntry->isWeak); + snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->term); + cJSON_AddStringToObject(pRoot, "term", u64buf); + snprintf(u64buf, sizeof(u64buf), "%lu", pEntry->index); + cJSON_AddStringToObject(pRoot, "index", u64buf); + cJSON_AddNumberToObject(pRoot, "dataLen", pEntry->dataLen); - s = syncUtilprintBin2((char*)(pEntry->data), pEntry->dataLen); - cJSON_AddStringToObject(pRoot, "data2", s); - free(s); + char* s; + s = syncUtilprintBin((char*)(pEntry->data), pEntry->dataLen); + cJSON_AddStringToObject(pRoot, "data", s); + free(s); + + s = syncUtilprintBin2((char*)(pEntry->data), pEntry->dataLen); + cJSON_AddStringToObject(pRoot, "data2", s); + free(s); + } cJSON* pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SSyncRaftEntry", pRoot); diff --git a/source/libs/sync/src/syncRaftLog.c b/source/libs/sync/src/syncRaftLog.c index 6ebeba1991..f3fd7f84a2 100644 --- a/source/libs/sync/src/syncRaftLog.c +++ b/source/libs/sync/src/syncRaftLog.c @@ -122,26 +122,28 @@ SSyncRaftEntry* logStoreGetLastEntry(SSyncLogStore* pLogStore) { } cJSON* logStore2Json(SSyncLogStore* pLogStore) { - char u64buf[128]; - + char u64buf[128]; SSyncLogStoreData* pData = (SSyncLogStoreData*)pLogStore->data; cJSON* pRoot = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%p", pData->pSyncNode); - cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pData->pWal); - cJSON_AddStringToObject(pRoot, "pWal", u64buf); - snprintf(u64buf, sizeof(u64buf), "%ld", logStoreLastIndex(pLogStore)); - cJSON_AddStringToObject(pRoot, "LastIndex", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", logStoreLastTerm(pLogStore)); - cJSON_AddStringToObject(pRoot, "LastTerm", u64buf); - cJSON* pEntries = cJSON_CreateArray(); - cJSON_AddItemToObject(pRoot, "pEntries", pEntries); - SyncIndex lastIndex = logStoreLastIndex(pLogStore); - for (SyncIndex i = 0; i <= lastIndex; ++i) { - SSyncRaftEntry* pEntry = logStoreGetEntry(pLogStore, i); - cJSON_AddItemToArray(pEntries, syncEntry2Json(pEntry)); - syncEntryDestory(pEntry); + if (pData != NULL && pData->pWal != NULL) { + snprintf(u64buf, sizeof(u64buf), "%p", pData->pSyncNode); + cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pData->pWal); + cJSON_AddStringToObject(pRoot, "pWal", u64buf); + snprintf(u64buf, sizeof(u64buf), "%ld", logStoreLastIndex(pLogStore)); + cJSON_AddStringToObject(pRoot, "LastIndex", u64buf); + snprintf(u64buf, sizeof(u64buf), "%lu", logStoreLastTerm(pLogStore)); + cJSON_AddStringToObject(pRoot, "LastTerm", u64buf); + + cJSON* pEntries = cJSON_CreateArray(); + cJSON_AddItemToObject(pRoot, "pEntries", pEntries); + SyncIndex lastIndex = logStoreLastIndex(pLogStore); + for (SyncIndex i = 0; i <= lastIndex; ++i) { + SSyncRaftEntry* pEntry = logStoreGetEntry(pLogStore, i); + cJSON_AddItemToArray(pEntries, syncEntry2Json(pEntry)); + syncEntryDestory(pEntry); + } } cJSON* pJson = cJSON_CreateObject(); diff --git a/source/libs/sync/src/syncRaftStore.c b/source/libs/sync/src/syncRaftStore.c index 5ad618b9c0..9a5401e3f1 100644 --- a/source/libs/sync/src/syncRaftStore.c +++ b/source/libs/sync/src/syncRaftStore.c @@ -164,30 +164,63 @@ void raftStoreSetTerm(SRaftStore *pRaftStore, SyncTerm term) { raftStorePersist(pRaftStore); } +cJSON *raftStore2Json(SRaftStore *pRaftStore) { + char u64buf[128]; + cJSON *pRoot = cJSON_CreateObject(); + + if (pRaftStore != NULL) { + snprintf(u64buf, sizeof(u64buf), "%lu", pRaftStore->currentTerm); + cJSON_AddStringToObject(pRoot, "currentTerm", u64buf); + + cJSON *pVoteFor = cJSON_CreateObject(); + snprintf(u64buf, sizeof(u64buf), "%lu", pRaftStore->voteFor.addr); + cJSON_AddStringToObject(pVoteFor, "addr", u64buf); + { + uint64_t u64 = pRaftStore->voteFor.addr; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pVoteFor, "addr_host", host); + cJSON_AddNumberToObject(pVoteFor, "addr_port", port); + } + cJSON_AddNumberToObject(pVoteFor, "vgId", pRaftStore->voteFor.vgId); + cJSON_AddItemToObject(pRoot, "voteFor", pVoteFor); + } + + cJSON *pJson = cJSON_CreateObject(); + cJSON_AddItemToObject(pJson, "SRaftStore", pRoot); + return pJson; +} + +char *raftStore2Str(SRaftStore *pRaftStore) { + cJSON *pJson = raftStore2Json(pRaftStore); + char *serialized = cJSON_Print(pJson); + cJSON_Delete(pJson); + return serialized; +} + // for debug ------------------- void raftStorePrint(SRaftStore *pObj) { - char serialized[RAFT_STORE_BLOCK_SIZE]; - raftStoreSerialize(pObj, serialized, sizeof(serialized)); + char *serialized = raftStore2Str(pObj); printf("raftStorePrint | len:%lu | %s \n", strlen(serialized), serialized); fflush(NULL); + free(serialized); } void raftStorePrint2(char *s, SRaftStore *pObj) { - char serialized[RAFT_STORE_BLOCK_SIZE]; - raftStoreSerialize(pObj, serialized, sizeof(serialized)); + char *serialized = raftStore2Str(pObj); printf("raftStorePrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); + free(serialized); } void raftStoreLog(SRaftStore *pObj) { - char serialized[RAFT_STORE_BLOCK_SIZE]; - raftStoreSerialize(pObj, serialized, sizeof(serialized)); + char *serialized = raftStore2Str(pObj); sTrace("raftStoreLog | len:%lu | %s", strlen(serialized), serialized); - fflush(NULL); + free(serialized); } void raftStoreLog2(char *s, SRaftStore *pObj) { - char serialized[RAFT_STORE_BLOCK_SIZE]; - raftStoreSerialize(pObj, serialized, sizeof(serialized)); + char *serialized = raftStore2Str(pObj); sTrace("raftStoreLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); - fflush(NULL); + free(serialized); } diff --git a/source/libs/sync/src/syncVoteMgr.c b/source/libs/sync/src/syncVoteMgr.c index 5c8e70979c..5830a0a54f 100644 --- a/source/libs/sync/src/syncVoteMgr.c +++ b/source/libs/sync/src/syncVoteMgr.c @@ -82,30 +82,32 @@ cJSON *voteGranted2Json(SVotesGranted *pVotesGranted) { char u64buf[128]; cJSON *pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "replicaNum", pVotesGranted->replicaNum); - cJSON *pReplicas = cJSON_CreateArray(); - cJSON_AddItemToObject(pRoot, "replicas", pReplicas); - for (int i = 0; i < pVotesGranted->replicaNum; ++i) { - cJSON_AddItemToArray(pReplicas, syncUtilRaftId2Json(&(*(pVotesGranted->replicas))[i])); - } - int *arr = (int *)malloc(sizeof(int) * pVotesGranted->replicaNum); - for (int i = 0; i < pVotesGranted->replicaNum; ++i) { - arr[i] = pVotesGranted->isGranted[i]; - } - cJSON *pIsGranted = cJSON_CreateIntArray(arr, pVotesGranted->replicaNum); - free(arr); - cJSON_AddItemToObject(pRoot, "isGranted", pIsGranted); + if (pVotesGranted != NULL) { + cJSON_AddNumberToObject(pRoot, "replicaNum", pVotesGranted->replicaNum); + cJSON *pReplicas = cJSON_CreateArray(); + cJSON_AddItemToObject(pRoot, "replicas", pReplicas); + for (int i = 0; i < pVotesGranted->replicaNum; ++i) { + cJSON_AddItemToArray(pReplicas, syncUtilRaftId2Json(&(*(pVotesGranted->replicas))[i])); + } + int *arr = (int *)malloc(sizeof(int) * pVotesGranted->replicaNum); + for (int i = 0; i < pVotesGranted->replicaNum; ++i) { + arr[i] = pVotesGranted->isGranted[i]; + } + cJSON *pIsGranted = cJSON_CreateIntArray(arr, pVotesGranted->replicaNum); + free(arr); + cJSON_AddItemToObject(pRoot, "isGranted", pIsGranted); - cJSON_AddNumberToObject(pRoot, "votes", pVotesGranted->votes); - snprintf(u64buf, sizeof(u64buf), "%lu", pVotesGranted->term); - cJSON_AddStringToObject(pRoot, "term", u64buf); - cJSON_AddNumberToObject(pRoot, "quorum", pVotesGranted->quorum); - cJSON_AddNumberToObject(pRoot, "toLeader", pVotesGranted->toLeader); - snprintf(u64buf, sizeof(u64buf), "%p", pVotesGranted->pSyncNode); - cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); + cJSON_AddNumberToObject(pRoot, "votes", pVotesGranted->votes); + snprintf(u64buf, sizeof(u64buf), "%lu", pVotesGranted->term); + cJSON_AddStringToObject(pRoot, "term", u64buf); + cJSON_AddNumberToObject(pRoot, "quorum", pVotesGranted->quorum); + cJSON_AddNumberToObject(pRoot, "toLeader", pVotesGranted->toLeader); + snprintf(u64buf, sizeof(u64buf), "%p", pVotesGranted->pSyncNode); + cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); - bool majority = voteGrantedMajority(pVotesGranted); - cJSON_AddNumberToObject(pRoot, "majority", majority); + bool majority = voteGrantedMajority(pVotesGranted); + cJSON_AddNumberToObject(pRoot, "majority", majority); + } cJSON *pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SVotesGranted", pRoot); @@ -114,7 +116,7 @@ cJSON *voteGranted2Json(SVotesGranted *pVotesGranted) { char *voteGranted2Str(SVotesGranted *pVotesGranted) { cJSON *pJson = voteGranted2Json(pVotesGranted); - char * serialized = cJSON_Print(pJson); + char *serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } @@ -203,29 +205,31 @@ cJSON *votesRespond2Json(SVotesRespond *pVotesRespond) { char u64buf[128]; cJSON *pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "replicaNum", pVotesRespond->replicaNum); - cJSON *pReplicas = cJSON_CreateArray(); - cJSON_AddItemToObject(pRoot, "replicas", pReplicas); - for (int i = 0; i < pVotesRespond->replicaNum; ++i) { - cJSON_AddItemToArray(pReplicas, syncUtilRaftId2Json(&(*(pVotesRespond->replicas))[i])); - } - int respondNum = 0; - int *arr = (int *)malloc(sizeof(int) * pVotesRespond->replicaNum); - for (int i = 0; i < pVotesRespond->replicaNum; ++i) { - arr[i] = pVotesRespond->isRespond[i]; - if (pVotesRespond->isRespond[i]) { - respondNum++; + if (pVotesRespond != NULL) { + cJSON_AddNumberToObject(pRoot, "replicaNum", pVotesRespond->replicaNum); + cJSON *pReplicas = cJSON_CreateArray(); + cJSON_AddItemToObject(pRoot, "replicas", pReplicas); + for (int i = 0; i < pVotesRespond->replicaNum; ++i) { + cJSON_AddItemToArray(pReplicas, syncUtilRaftId2Json(&(*(pVotesRespond->replicas))[i])); } - } - cJSON *pIsRespond = cJSON_CreateIntArray(arr, pVotesRespond->replicaNum); - free(arr); - cJSON_AddItemToObject(pRoot, "isRespond", pIsRespond); - cJSON_AddNumberToObject(pRoot, "respondNum", respondNum); + int respondNum = 0; + int *arr = (int *)malloc(sizeof(int) * pVotesRespond->replicaNum); + for (int i = 0; i < pVotesRespond->replicaNum; ++i) { + arr[i] = pVotesRespond->isRespond[i]; + if (pVotesRespond->isRespond[i]) { + respondNum++; + } + } + cJSON *pIsRespond = cJSON_CreateIntArray(arr, pVotesRespond->replicaNum); + free(arr); + cJSON_AddItemToObject(pRoot, "isRespond", pIsRespond); + cJSON_AddNumberToObject(pRoot, "respondNum", respondNum); - snprintf(u64buf, sizeof(u64buf), "%lu", pVotesRespond->term); - cJSON_AddStringToObject(pRoot, "term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%p", pVotesRespond->pSyncNode); - cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); + snprintf(u64buf, sizeof(u64buf), "%lu", pVotesRespond->term); + cJSON_AddStringToObject(pRoot, "term", u64buf); + snprintf(u64buf, sizeof(u64buf), "%p", pVotesRespond->pSyncNode); + cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); + } cJSON *pJson = cJSON_CreateObject(); cJSON_AddItemToObject(pJson, "SVotesRespond", pRoot); @@ -234,7 +238,7 @@ cJSON *votesRespond2Json(SVotesRespond *pVotesRespond) { char *votesRespond2Str(SVotesRespond *pVotesRespond) { cJSON *pJson = votesRespond2Json(pVotesRespond); - char * serialized = cJSON_Print(pJson); + char *serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } diff --git a/source/libs/sync/test/syncInitTest.cpp b/source/libs/sync/test/syncInitTest.cpp index 7898fda8c0..c0d2336ba7 100644 --- a/source/libs/sync/test/syncInitTest.cpp +++ b/source/libs/sync/test/syncInitTest.cpp @@ -47,6 +47,7 @@ SSyncNode* syncNodeInit() { gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing; gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply; + gSyncIO->FpOnSyncClientRequest = pSyncNode->FpOnClientRequest; gSyncIO->FpOnSyncRequestVote = pSyncNode->FpOnRequestVote; gSyncIO->FpOnSyncRequestVoteReply = pSyncNode->FpOnRequestVoteReply; gSyncIO->FpOnSyncAppendEntries = pSyncNode->FpOnAppendEntries; From 3c6c518470772adbf44695d826e86347e9eff533 Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Wed, 16 Mar 2022 11:37:31 +0800 Subject: [PATCH 12/37] [TD-13063]: 3.0 on windows (#10765) * [TD-13063]: 3.0 on Windows * add pthread in contrib * fix linux compile * fix osSemaphore * add gnu regex for Windows * fix compile error for Windows * support arm platform * port more OS files * fix for Windows compile * port more files * fix macOS on x86_64 * port osFile * port osSemaphone.h * port osSocket.c * port tconfig.c * port ttimer.c * add couple files * merge with 3.0 --- cmake/cmake.platform | 2 +- source/client/src/clientMsgHandler.c | 6 +-- source/dnode/mnode/impl/src/mndConsumer.c | 12 ++--- source/dnode/mnode/impl/src/mndSubscribe.c | 14 ++--- source/dnode/mnode/sdb/src/sdbFile.c | 2 +- source/libs/executor/src/dataSinkMgt.c | 1 + source/libs/executor/src/tlinearhash.c | 4 +- source/libs/sync/src/syncAppendEntriesReply.c | 2 +- source/libs/sync/src/syncEnv.c | 6 +-- source/libs/sync/src/syncMain.c | 28 +++++----- source/libs/sync/src/syncMessage.c | 54 +++++++++---------- source/libs/sync/src/syncRaftLog.c | 10 ++-- source/libs/sync/src/syncRequestVoteReply.c | 2 +- source/libs/sync/src/syncUtil.c | 4 +- 14 files changed, 76 insertions(+), 71 deletions(-) diff --git a/cmake/cmake.platform b/cmake/cmake.platform index 0312f92a5b..dfb79c0fae 100644 --- a/cmake/cmake.platform +++ b/cmake/cmake.platform @@ -42,7 +42,7 @@ IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "Darwin SET(TD_DARWIN TRUE) SET(OSTYPE "macOS") - ADD_DEFINITIONS("-DDARWIN -Wno-tautological-pointer-compare") + ADD_DEFINITIONS("-DDARWIN -Wno-tautological-pointer-compare -Wno-return-type") MESSAGE("Current system processor is ${CMAKE_SYSTEM_PROCESSOR}.") IF (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm64" OR ${CMAKE_SYSTEM_PROCESSOR} MATCHES "x86_64") diff --git a/source/client/src/clientMsgHandler.c b/source/client/src/clientMsgHandler.c index 9534c11646..010f4e6c12 100644 --- a/source/client/src/clientMsgHandler.c +++ b/source/client/src/clientMsgHandler.c @@ -33,7 +33,7 @@ int32_t genericRspCallback(void* param, const SDataBuf* pMsg, int32_t code) { setErrno(pRequest, code); free(pMsg->pData); - sem_post(&pRequest->body.rspSem); + tsem_post(&pRequest->body.rspSem); return code; } @@ -42,7 +42,7 @@ int32_t processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) { if (code != TSDB_CODE_SUCCESS) { free(pMsg->pData); setErrno(pRequest, code); - sem_post(&pRequest->body.rspSem); + tsem_post(&pRequest->body.rspSem); return code; } @@ -78,7 +78,7 @@ int32_t processConnectRsp(void* param, const SDataBuf* pMsg, int32_t code) { pTscObj->pAppInfo->numOfConns); free(pMsg->pData); - sem_post(&pRequest->body.rspSem); + tsem_post(&pRequest->body.rspSem); return 0; } diff --git a/source/dnode/mnode/impl/src/mndConsumer.c b/source/dnode/mnode/impl/src/mndConsumer.c index 0f4b538cde..4a9d23aa15 100644 --- a/source/dnode/mnode/impl/src/mndConsumer.c +++ b/source/dnode/mnode/impl/src/mndConsumer.c @@ -96,12 +96,12 @@ SSdbRaw *mndConsumerActionEncode(SMqConsumerObj *pConsumer) { CM_ENCODE_OVER: tfree(buf); if (terrno != 0) { - mError("consumer:%ld, failed to encode to raw:%p since %s", pConsumer->consumerId, pRaw, terrstr()); + mError("consumer:%" PRId64 ", failed to encode to raw:%p since %s", pConsumer->consumerId, pRaw, terrstr()); sdbFreeRaw(pRaw); return NULL; } - mTrace("consumer:%ld, encode to raw:%p, row:%p", pConsumer->consumerId, pRaw, pConsumer); + mTrace("consumer:%" PRId64 ", encode to raw:%p, row:%p", pConsumer->consumerId, pRaw, pConsumer); return pRaw; } @@ -140,7 +140,7 @@ SSdbRow *mndConsumerActionDecode(SSdbRaw *pRaw) { CM_DECODE_OVER: tfree(buf); if (terrno != TSDB_CODE_SUCCESS) { - mError("consumer:%ld, failed to decode from raw:%p since %s", pConsumer->consumerId, pRaw, terrstr()); + mError("consumer:%" PRId64 ", failed to decode from raw:%p since %s", pConsumer->consumerId, pRaw, terrstr()); tfree(pRow); return NULL; } @@ -149,17 +149,17 @@ CM_DECODE_OVER: } static int32_t mndConsumerActionInsert(SSdb *pSdb, SMqConsumerObj *pConsumer) { - mTrace("consumer:%ld, perform insert action", pConsumer->consumerId); + mTrace("consumer:%" PRId64 ", perform insert action", pConsumer->consumerId); return 0; } static int32_t mndConsumerActionDelete(SSdb *pSdb, SMqConsumerObj *pConsumer) { - mTrace("consumer:%ld, perform delete action", pConsumer->consumerId); + mTrace("consumer:%" PRId64 ", perform delete action", pConsumer->consumerId); return 0; } static int32_t mndConsumerActionUpdate(SSdb *pSdb, SMqConsumerObj *pOldConsumer, SMqConsumerObj *pNewConsumer) { - mTrace("consumer:%ld, perform update action", pOldConsumer->consumerId); + mTrace("consumer:%" PRId64 ", perform update action", pOldConsumer->consumerId); // TODO handle update /*taosWLockLatch(&pOldConsumer->lock);*/ diff --git a/source/dnode/mnode/impl/src/mndSubscribe.c b/source/dnode/mnode/impl/src/mndSubscribe.c index fa4fed59d0..1dcd07829d 100644 --- a/source/dnode/mnode/impl/src/mndSubscribe.c +++ b/source/dnode/mnode/impl/src/mndSubscribe.c @@ -448,7 +448,7 @@ static int32_t mndProcessDoRebalanceMsg(SMnodeMsg *pMsg) { for (int32_t i = 0; i < taosArrayGetSize(pRebSub->lostConsumers); i++) { int64_t lostConsumerId = *(int64_t *)taosArrayGet(pRebSub->lostConsumers, i); - mInfo("mq remove lost consumer %ld", lostConsumerId); + mInfo("mq remove lost consumer %" PRId64 "", lostConsumerId); for (int32_t j = 0; j < taosArrayGetSize(pSub->consumers); j++) { SMqSubConsumer *pSubConsumer = taosArrayGet(pSub->consumers, j); @@ -479,7 +479,7 @@ static int32_t mndProcessDoRebalanceMsg(SMnodeMsg *pMsg) { else vgThisConsumerAfterRb = vgEachConsumer; - mInfo("mq consumer:%ld, connectted vgroup number change from %d to %d", pSubConsumer->consumerId, + mInfo("mq consumer:%" PRId64 ", connectted vgroup number change from %d to %d", pSubConsumer->consumerId, vgThisConsumerBeforeRb, vgThisConsumerAfterRb); while (taosArrayGetSize(pSubConsumer->vgInfo) > vgThisConsumerAfterRb) { @@ -503,7 +503,7 @@ static int32_t mndProcessDoRebalanceMsg(SMnodeMsg *pMsg) { atomic_store_32(&pRebConsumer->status, MQ_CONSUMER_STATUS__IDLE); } - mInfo("mq consumer:%ld, status change from %d to %d", pRebConsumer->consumerId, status, pRebConsumer->status); + mInfo("mq consumer:%" PRId64 ", status change from %d to %d", pRebConsumer->consumerId, status, pRebConsumer->status); SSdbRaw *pConsumerRaw = mndConsumerActionEncode(pRebConsumer); sdbSetRawStatus(pConsumerRaw, SDB_STATUS_READY); @@ -537,13 +537,13 @@ static int32_t mndProcessDoRebalanceMsg(SMnodeMsg *pMsg) { mndSplitSubscribeKey(pSub->key, topic, cgroup); SMqTopicObj *pTopic = mndAcquireTopic(pMnode, topic); - mInfo("mq set conn: assign vgroup %d of topic %s to consumer %ld", pConsumerEp->vgId, topic, + mInfo("mq set conn: assign vgroup %d of topic %s to consumer %" PRId64 "", pConsumerEp->vgId, topic, pConsumerEp->consumerId); mndPersistMqSetConnReq(pMnode, pTrans, pTopic, cgroup, pConsumerEp); mndReleaseTopic(pMnode, pTopic); } else { - mInfo("mq rebalance: assign vgroup %d, from consumer %ld to consumer %ld", pConsumerEp->vgId, + mInfo("mq rebalance: assign vgroup %d, from consumer %" PRId64 " to consumer %" PRId64 "", pConsumerEp->vgId, pConsumerEp->oldConsumerId, pConsumerEp->consumerId); mndPersistRebalanceMsg(pMnode, pTrans, pConsumerEp); @@ -1099,7 +1099,7 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) { SMqSubscribeObj *pSub = mndAcquireSubscribe(pMnode, cgroup, newTopicName); bool createSub = false; if (pSub == NULL) { - mDebug("create new subscription by consumer %ld, group: %s, topic %s", consumerId, cgroup, newTopicName); + mDebug("create new subscription by consumer %" PRId64 ", group: %s, topic %s", consumerId, cgroup, newTopicName); pSub = mndCreateSubscription(pMnode, pTopic, cgroup); createSub = true; @@ -1118,7 +1118,7 @@ static int32_t mndProcessSubscribeReq(SMnodeMsg *pMsg) { pConsumerEp->consumerId = consumerId; taosArrayPush(mqSubConsumer.vgInfo, pConsumerEp); if (pConsumerEp->oldConsumerId == -1) { - mInfo("mq set conn: assign vgroup %d of topic %s to consumer %ld", pConsumerEp->vgId, newTopicName, + mInfo("mq set conn: assign vgroup %d of topic %s to consumer %" PRId64 "", pConsumerEp->vgId, newTopicName, pConsumerEp->consumerId); mndPersistMqSetConnReq(pMnode, pTrans, pTopic, cgroup, pConsumerEp); } else { diff --git a/source/dnode/mnode/sdb/src/sdbFile.c b/source/dnode/mnode/sdb/src/sdbFile.c index a3fe4dfb14..2849da5c2e 100644 --- a/source/dnode/mnode/sdb/src/sdbFile.c +++ b/source/dnode/mnode/sdb/src/sdbFile.c @@ -196,7 +196,7 @@ int32_t sdbReadFile(SSdb *pSdb) { } int32_t totalLen = sizeof(SSdbRaw) + pRaw->dataLen + sizeof(int32_t); - if (!taosCheckChecksumWhole((const uint8_t *)pRaw, totalLen) != 0) { + if ((!taosCheckChecksumWhole((const uint8_t *)pRaw, totalLen)) != 0) { code = TSDB_CODE_CHECKSUM_ERROR; mError("failed to read file:%s since %s", file, tstrerror(code)); break; diff --git a/source/libs/executor/src/dataSinkMgt.c b/source/libs/executor/src/dataSinkMgt.c index 343b3a3c95..4e8583eb2a 100644 --- a/source/libs/executor/src/dataSinkMgt.c +++ b/source/libs/executor/src/dataSinkMgt.c @@ -23,6 +23,7 @@ static SDataSinkManager gDataSinkManager = {0}; int32_t dsDataSinkMgtInit(SDataSinkMgtCfg *cfg) { gDataSinkManager.cfg = *cfg; pthread_mutex_init(&gDataSinkManager.mutex, NULL); + return 0; // to avoid compiler eror } int32_t dsCreateDataSinker(const SDataSinkNode *pDataSink, DataSinkHandle* pHandle) { diff --git a/source/libs/executor/src/tlinearhash.c b/source/libs/executor/src/tlinearhash.c index 9f3d694c42..28319469cc 100644 --- a/source/libs/executor/src/tlinearhash.c +++ b/source/libs/executor/src/tlinearhash.c @@ -413,7 +413,7 @@ int32_t tHashRemove(SLHashObj* pHashObj, const void *key, size_t keyLen) { void tHashPrint(const SLHashObj* pHashObj, int32_t type) { printf("==================== linear hash ====================\n"); - printf("total bucket:%d, size:%ld, ratio:%.2f\n", pHashObj->numOfBuckets, pHashObj->size, LHASH_CAP_RATIO); + printf("total bucket:%d, size:%" PRId64 ", ratio:%.2f\n", pHashObj->numOfBuckets, pHashObj->size, LHASH_CAP_RATIO); dBufSetPrintInfo(pHashObj->pBuf); @@ -425,4 +425,4 @@ void tHashPrint(const SLHashObj* pHashObj, int32_t type) { } else { dBufPrintStatis(pHashObj->pBuf); } -} \ No newline at end of file +} diff --git a/source/libs/sync/src/syncAppendEntriesReply.c b/source/libs/sync/src/syncAppendEntriesReply.c index 61eb4884e2..a75e85601f 100644 --- a/source/libs/sync/src/syncAppendEntriesReply.c +++ b/source/libs/sync/src/syncAppendEntriesReply.c @@ -39,7 +39,7 @@ int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* p syncAppendEntriesReplyLog2("==syncNodeOnAppendEntriesReplyCb==", pMsg); if (pMsg->term < ths->pRaftStore->currentTerm) { - sTrace("DropStaleResponse, receive term:%lu, current term:%lu", pMsg->term, ths->pRaftStore->currentTerm); + sTrace("DropStaleResponse, receive term:%" PRIu64 ", current term:%" PRIu64 "", pMsg->term, ths->pRaftStore->currentTerm); return ret; } diff --git a/source/libs/sync/src/syncEnv.c b/source/libs/sync/src/syncEnv.c index dd7161800d..4b650ec087 100644 --- a/source/libs/sync/src/syncEnv.c +++ b/source/libs/sync/src/syncEnv.c @@ -55,7 +55,7 @@ static void syncEnvTick(void *param, void *tmrId) { if (atomic_load_64(&pSyncEnv->envTickTimerLogicClockUser) <= atomic_load_64(&pSyncEnv->envTickTimerLogicClock)) { ++(pSyncEnv->envTickTimerCounter); sTrace( - "syncEnvTick do ... envTickTimerLogicClockUser:%lu, envTickTimerLogicClock:%lu, envTickTimerCounter:%lu, " + "syncEnvTick do ... envTickTimerLogicClockUser:%" PRIu64 ", envTickTimerLogicClock:%" PRIu64 ", envTickTimerCounter:%" PRIu64 ", " "envTickTimerMS:%d, tmrId:%p", pSyncEnv->envTickTimerLogicClockUser, pSyncEnv->envTickTimerLogicClock, pSyncEnv->envTickTimerCounter, pSyncEnv->envTickTimerMS, tmrId); @@ -64,7 +64,7 @@ static void syncEnvTick(void *param, void *tmrId) { taosTmrReset(syncEnvTick, pSyncEnv->envTickTimerMS, pSyncEnv, pSyncEnv->pTimerManager, &pSyncEnv->pEnvTickTimer); } else { sTrace( - "syncEnvTick pass ... envTickTimerLogicClockUser:%lu, envTickTimerLogicClock:%lu, envTickTimerCounter:%lu, " + "syncEnvTick pass ... envTickTimerLogicClockUser:%" PRIu64 ", envTickTimerLogicClock:%" PRIu64 ", envTickTimerCounter:%" PRIu64 ", " "envTickTimerMS:%d, tmrId:%p", pSyncEnv->envTickTimerLogicClockUser, pSyncEnv->envTickTimerLogicClock, pSyncEnv->envTickTimerCounter, pSyncEnv->envTickTimerMS, tmrId); @@ -74,7 +74,7 @@ static void syncEnvTick(void *param, void *tmrId) { static SSyncEnv *doSyncEnvStart() { SSyncEnv *pSyncEnv = (SSyncEnv *)malloc(sizeof(SSyncEnv)); assert(pSyncEnv != NULL); - memset(pSyncEnv, 0, sizeof(pSyncEnv)); + memset(pSyncEnv, 0, sizeof(SSyncEnv)); pSyncEnv->envTickTimerCounter = 0; pSyncEnv->envTickTimerMS = ENV_TICK_TIMER_MS; diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index dd2c142104..b919e014a0 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -420,46 +420,46 @@ cJSON* syncNode2Json(const SSyncNode* pSyncNode) { // tla+ log vars cJSON_AddItemToObject(pRoot, "pLogStore", logStore2Json(pSyncNode->pLogStore)); - snprintf(u64buf, sizeof(u64buf), "%ld", pSyncNode->commitIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRId64 "", pSyncNode->commitIndex); cJSON_AddStringToObject(pRoot, "commitIndex", u64buf); // ping timer snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pPingTimer); cJSON_AddStringToObject(pRoot, "pPingTimer", u64buf); cJSON_AddNumberToObject(pRoot, "pingTimerMS", pSyncNode->pingTimerMS); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->pingTimerLogicClock); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->pingTimerLogicClock); cJSON_AddStringToObject(pRoot, "pingTimerLogicClock", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->pingTimerLogicClockUser); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->pingTimerLogicClockUser); cJSON_AddStringToObject(pRoot, "pingTimerLogicClockUser", u64buf); snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpPingTimerCB); cJSON_AddStringToObject(pRoot, "FpPingTimerCB", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->pingTimerCounter); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->pingTimerCounter); cJSON_AddStringToObject(pRoot, "pingTimerCounter", u64buf); // elect timer snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pElectTimer); cJSON_AddStringToObject(pRoot, "pElectTimer", u64buf); cJSON_AddNumberToObject(pRoot, "electTimerMS", pSyncNode->electTimerMS); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->electTimerLogicClock); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->electTimerLogicClock); cJSON_AddStringToObject(pRoot, "electTimerLogicClock", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->electTimerLogicClockUser); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->electTimerLogicClockUser); cJSON_AddStringToObject(pRoot, "electTimerLogicClockUser", u64buf); snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpElectTimerCB); cJSON_AddStringToObject(pRoot, "FpElectTimerCB", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->electTimerCounter); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->electTimerCounter); cJSON_AddStringToObject(pRoot, "electTimerCounter", u64buf); // heartbeat timer snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->pHeartbeatTimer); cJSON_AddStringToObject(pRoot, "pHeartbeatTimer", u64buf); cJSON_AddNumberToObject(pRoot, "heartbeatTimerMS", pSyncNode->heartbeatTimerMS); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->heartbeatTimerLogicClock); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->heartbeatTimerLogicClock); cJSON_AddStringToObject(pRoot, "heartbeatTimerLogicClock", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->heartbeatTimerLogicClockUser); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->heartbeatTimerLogicClockUser); cJSON_AddStringToObject(pRoot, "heartbeatTimerLogicClockUser", u64buf); snprintf(u64buf, sizeof(u64buf), "%p", pSyncNode->FpHeartbeatTimerCB); cJSON_AddStringToObject(pRoot, "FpHeartbeatTimerCB", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pSyncNode->heartbeatTimerCounter); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pSyncNode->heartbeatTimerCounter); cJSON_AddStringToObject(pRoot, "heartbeatTimerCounter", u64buf); // callback @@ -634,7 +634,7 @@ static void syncNodeEqPingTimer(void* param, void* tmrId) { taosTmrReset(syncNodeEqPingTimer, pSyncNode->pingTimerMS, pSyncNode, gSyncEnv->pTimerManager, &pSyncNode->pPingTimer); } else { - sTrace("==syncNodeEqPingTimer== pingTimerLogicClock:%lu, pingTimerLogicClockUser:%lu", + sTrace("==syncNodeEqPingTimer== pingTimerLogicClock:%" PRIu64 ", pingTimerLogicClockUser:%" PRIu64 "", pSyncNode->pingTimerLogicClock, pSyncNode->pingTimerLogicClockUser); } } @@ -655,7 +655,7 @@ static void syncNodeEqElectTimer(void* param, void* tmrId) { taosTmrReset(syncNodeEqPingTimer, pSyncNode->pingTimerMS, pSyncNode, gSyncEnv->pTimerManager, &pSyncNode->pPingTimer); } else { - sTrace("==syncNodeEqElectTimer== electTimerLogicClock:%lu, electTimerLogicClockUser:%lu", + sTrace("==syncNodeEqElectTimer== electTimerLogicClock:%" PRIu64 ", electTimerLogicClockUser:%" PRIu64 "", pSyncNode->electTimerLogicClock, pSyncNode->electTimerLogicClockUser); } } @@ -676,7 +676,7 @@ static void syncNodeEqHeartbeatTimer(void* param, void* tmrId) { taosTmrReset(syncNodeEqHeartbeatTimer, pSyncNode->heartbeatTimerMS, pSyncNode, gSyncEnv->pTimerManager, &pSyncNode->pHeartbeatTimer); } else { - sTrace("==syncNodeEqHeartbeatTimer== heartbeatTimerLogicClock:%lu, heartbeatTimerLogicClockUser:%lu", + sTrace("==syncNodeEqHeartbeatTimer== heartbeatTimerLogicClock:%" PRIu64 ", heartbeatTimerLogicClockUser:%" PRIu64 "", pSyncNode->heartbeatTimerLogicClock, pSyncNode->heartbeatTimerLogicClockUser); } } @@ -713,4 +713,4 @@ static int32_t syncNodeOnClientRequestCb(SSyncNode* ths, SyncClientRequest* pMsg } return ret; -} \ No newline at end of file +} diff --git a/source/libs/sync/src/syncMessage.c b/source/libs/sync/src/syncMessage.c index 509ede274b..e28f780831 100644 --- a/source/libs/sync/src/syncMessage.c +++ b/source/libs/sync/src/syncMessage.c @@ -218,7 +218,7 @@ cJSON* syncTimeout2Json(const SyncTimeout* pMsg) { cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON_AddNumberToObject(pRoot, "timeoutType", pMsg->timeoutType); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->logicClock); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->logicClock); cJSON_AddStringToObject(pRoot, "logicClock", u64buf); cJSON_AddNumberToObject(pRoot, "timerMS", pMsg->timerMS); snprintf(u64buf, sizeof(u64buf), "%p", pMsg->data); @@ -239,7 +239,7 @@ char* syncTimeout2Str(const SyncTimeout* pMsg) { // for debug ---------------------- void syncTimeoutPrint(const SyncTimeout* pMsg) { char* serialized = syncTimeout2Str(pMsg); - printf("syncTimeoutPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncTimeoutPrint | len:%zu | %s \n", strlen(serialized), serialized); fflush(NULL); free(serialized); } @@ -349,7 +349,7 @@ cJSON* syncPing2Json(const SyncPing* pMsg) { cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->srcId.addr); cJSON_AddStringToObject(pSrcId, "addr", u64buf); { uint64_t u64 = pMsg->srcId.addr; @@ -364,7 +364,7 @@ cJSON* syncPing2Json(const SyncPing* pMsg) { cJSON_AddItemToObject(pRoot, "srcId", pSrcId); cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->destId.addr); cJSON_AddStringToObject(pDestId, "addr", u64buf); { uint64_t u64 = pMsg->destId.addr; @@ -512,7 +512,7 @@ cJSON* syncPingReply2Json(const SyncPingReply* pMsg) { cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->srcId.addr); cJSON_AddStringToObject(pSrcId, "addr", u64buf); { uint64_t u64 = pMsg->srcId.addr; @@ -527,7 +527,7 @@ cJSON* syncPingReply2Json(const SyncPingReply* pMsg) { cJSON_AddItemToObject(pRoot, "srcId", pSrcId); cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->destId.addr); cJSON_AddStringToObject(pDestId, "addr", u64buf); { uint64_t u64 = pMsg->destId.addr; @@ -565,27 +565,27 @@ char* syncPingReply2Str(const SyncPingReply* pMsg) { // for debug ---------------------- void syncPingReplyPrint(const SyncPingReply* pMsg) { char* serialized = syncPingReply2Str(pMsg); - printf("syncPingReplyPrint | len:%lu | %s \n", strlen(serialized), serialized); + printf("syncPingReplyPrint | len:%zu | %s \n", strlen(serialized), serialized); fflush(NULL); free(serialized); } void syncPingReplyPrint2(char* s, const SyncPingReply* pMsg) { char* serialized = syncPingReply2Str(pMsg); - printf("syncPingReplyPrint2 | len:%lu | %s | %s \n", strlen(serialized), s, serialized); + printf("syncPingReplyPrint2 | len:%zu | %s | %s \n", strlen(serialized), s, serialized); fflush(NULL); free(serialized); } void syncPingReplyLog(const SyncPingReply* pMsg) { char* serialized = syncPingReply2Str(pMsg); - sTrace("syncPingReplyLog | len:%lu | %s", strlen(serialized), serialized); + sTrace("syncPingReplyLog | len:%zu | %s", strlen(serialized), serialized); free(serialized); } void syncPingReplyLog2(char* s, const SyncPingReply* pMsg) { char* serialized = syncPingReply2Str(pMsg); - sTrace("syncPingReplyLog2 | len:%lu | %s | %s", strlen(serialized), s, serialized); + sTrace("syncPingReplyLog2 | len:%zu | %s | %s", strlen(serialized), s, serialized); free(serialized); } @@ -670,7 +670,7 @@ cJSON* syncClientRequest2Json(const SyncClientRequest* pMsg) { cJSON_AddNumberToObject(pRoot, "bytes", pMsg->bytes); cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON_AddNumberToObject(pRoot, "originalRpcType", pMsg->originalRpcType); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->seqNum); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->seqNum); cJSON_AddStringToObject(pRoot, "seqNum", u64buf); cJSON_AddNumberToObject(pRoot, "isWeak", pMsg->isWeak); cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); @@ -792,7 +792,7 @@ cJSON* syncRequestVote2Json(const SyncRequestVote* pMsg) { cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->srcId.addr); cJSON_AddStringToObject(pSrcId, "addr", u64buf); { uint64_t u64 = pMsg->srcId.addr; @@ -820,11 +820,11 @@ cJSON* syncRequestVote2Json(const SyncRequestVote* pMsg) { cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); cJSON_AddItemToObject(pRoot, "destId", pDestId); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->term); cJSON_AddStringToObject(pRoot, "term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->lastLogIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->lastLogIndex); cJSON_AddStringToObject(pRoot, "lastLogIndex", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->lastLogTerm); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->lastLogTerm); cJSON_AddStringToObject(pRoot, "lastLogTerm", u64buf); cJSON* pJson = cJSON_CreateObject(); @@ -936,7 +936,7 @@ cJSON* syncRequestVoteReply2Json(const SyncRequestVoteReply* pMsg) { cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->srcId.addr); cJSON_AddStringToObject(pSrcId, "addr", u64buf); { uint64_t u64 = pMsg->srcId.addr; @@ -964,7 +964,7 @@ cJSON* syncRequestVoteReply2Json(const SyncRequestVoteReply* pMsg) { cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); cJSON_AddItemToObject(pRoot, "destId", pDestId); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->term); cJSON_AddStringToObject(pRoot, "term", u64buf); cJSON_AddNumberToObject(pRoot, "vote_granted", pMsg->voteGranted); @@ -1079,7 +1079,7 @@ cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) { cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->srcId.addr); cJSON_AddStringToObject(pSrcId, "addr", u64buf); { uint64_t u64 = pMsg->srcId.addr; @@ -1094,7 +1094,7 @@ cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) { cJSON_AddItemToObject(pRoot, "srcId", pSrcId); cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->destId.addr); cJSON_AddStringToObject(pDestId, "addr", u64buf); { uint64_t u64 = pMsg->destId.addr; @@ -1108,16 +1108,16 @@ cJSON* syncAppendEntries2Json(const SyncAppendEntries* pMsg) { cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); cJSON_AddItemToObject(pRoot, "destId", pDestId); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->term); cJSON_AddStringToObject(pRoot, "term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->prevLogIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->prevLogIndex); cJSON_AddStringToObject(pRoot, "pre_log_index", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->prevLogTerm); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->prevLogTerm); cJSON_AddStringToObject(pRoot, "pre_log_term", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->commitIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->commitIndex); cJSON_AddStringToObject(pRoot, "commit_index", u64buf); cJSON_AddNumberToObject(pRoot, "dataLen", pMsg->dataLen); @@ -1238,7 +1238,7 @@ cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) { cJSON_AddNumberToObject(pRoot, "msgType", pMsg->msgType); cJSON* pSrcId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->srcId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->srcId.addr); cJSON_AddStringToObject(pSrcId, "addr", u64buf); { uint64_t u64 = pMsg->srcId.addr; @@ -1253,7 +1253,7 @@ cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) { cJSON_AddItemToObject(pRoot, "srcId", pSrcId); cJSON* pDestId = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->destId.addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->destId.addr); cJSON_AddStringToObject(pDestId, "addr", u64buf); { uint64_t u64 = pMsg->destId.addr; @@ -1267,10 +1267,10 @@ cJSON* syncAppendEntriesReply2Json(const SyncAppendEntriesReply* pMsg) { cJSON_AddNumberToObject(pDestId, "vgId", pMsg->destId.vgId); cJSON_AddItemToObject(pRoot, "destId", pDestId); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->term); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->term); cJSON_AddStringToObject(pRoot, "term", u64buf); cJSON_AddNumberToObject(pRoot, "success", pMsg->success); - snprintf(u64buf, sizeof(u64buf), "%lu", pMsg->matchIndex); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", pMsg->matchIndex); cJSON_AddStringToObject(pRoot, "matchIndex", u64buf); cJSON* pJson = cJSON_CreateObject(); diff --git a/source/libs/sync/src/syncRaftLog.c b/source/libs/sync/src/syncRaftLog.c index 6ebeba1991..3ae2fc4721 100644 --- a/source/libs/sync/src/syncRaftLog.c +++ b/source/libs/sync/src/syncRaftLog.c @@ -34,6 +34,7 @@ SSyncLogStore* logStoreCreate(SSyncNode* pSyncNode) { pLogStore->getLastTerm = logStoreLastTerm; pLogStore->updateCommitIndex = logStoreUpdateCommitIndex; pLogStore->getCommitIndex = logStoreGetCommitIndex; + return pLogStore; // to avoid compiler error } void logStoreDestory(SSyncLogStore* pLogStore) { @@ -58,6 +59,7 @@ int32_t logStoreAppendEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry) { walFsync(pWal, true); free(serialized); + return code; // to avoid compiler error } SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) { @@ -79,6 +81,7 @@ int32_t logStoreTruncate(SSyncLogStore* pLogStore, SyncIndex fromIndex) { SSyncLogStoreData* pData = pLogStore->data; SWal* pWal = pData->pWal; walRollback(pWal, fromIndex); + return 0; // to avoid compiler error } SyncIndex logStoreLastIndex(SSyncLogStore* pLogStore) { @@ -102,6 +105,7 @@ int32_t logStoreUpdateCommitIndex(SSyncLogStore* pLogStore, SyncIndex index) { SSyncLogStoreData* pData = pLogStore->data; SWal* pWal = pData->pWal; walCommit(pWal, index); + return 0; // to avoid compiler error } SyncIndex logStoreGetCommitIndex(SSyncLogStore* pLogStore) { @@ -130,9 +134,9 @@ cJSON* logStore2Json(SSyncLogStore* pLogStore) { cJSON_AddStringToObject(pRoot, "pSyncNode", u64buf); snprintf(u64buf, sizeof(u64buf), "%p", pData->pWal); cJSON_AddStringToObject(pRoot, "pWal", u64buf); - snprintf(u64buf, sizeof(u64buf), "%ld", logStoreLastIndex(pLogStore)); + snprintf(u64buf, sizeof(u64buf), "%" PRId64 "", logStoreLastIndex(pLogStore)); cJSON_AddStringToObject(pRoot, "LastIndex", u64buf); - snprintf(u64buf, sizeof(u64buf), "%lu", logStoreLastTerm(pLogStore)); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", logStoreLastTerm(pLogStore)); cJSON_AddStringToObject(pRoot, "LastTerm", u64buf); cJSON* pEntries = cJSON_CreateArray(); @@ -181,4 +185,4 @@ void logStoreLog2(char* s, SSyncLogStore* pLogStore) { char* serialized = logStore2Str(pLogStore); sTrace("logStorePrint | len:%lu | %s | %s", strlen(serialized), s, serialized); free(serialized); -} \ No newline at end of file +} diff --git a/source/libs/sync/src/syncRequestVoteReply.c b/source/libs/sync/src/syncRequestVoteReply.c index 7cdeace166..60a2c008fe 100644 --- a/source/libs/sync/src/syncRequestVoteReply.c +++ b/source/libs/sync/src/syncRequestVoteReply.c @@ -41,7 +41,7 @@ int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg) syncRequestVoteReplyLog2("==syncNodeOnRequestVoteReplyCb==", pMsg); if (pMsg->term < ths->pRaftStore->currentTerm) { - sTrace("DropStaleResponse, receive term:%lu, current term:%lu", pMsg->term, ths->pRaftStore->currentTerm); + sTrace("DropStaleResponse, receive term:%" PRIu64 ", current term:%" PRIu64 "", pMsg->term, ths->pRaftStore->currentTerm); return ret; } diff --git a/source/libs/sync/src/syncUtil.c b/source/libs/sync/src/syncUtil.c index ba8a76c190..90889a7af0 100644 --- a/source/libs/sync/src/syncUtil.c +++ b/source/libs/sync/src/syncUtil.c @@ -119,7 +119,7 @@ cJSON* syncUtilRaftId2Json(const SRaftId* p) { char u64buf[128]; cJSON* pRoot = cJSON_CreateObject(); - snprintf(u64buf, sizeof(u64buf), "%lu", p->addr); + snprintf(u64buf, sizeof(u64buf), "%" PRIu64 "", p->addr); cJSON_AddStringToObject(pRoot, "addr", u64buf); char host[128]; uint16_t port; @@ -196,4 +196,4 @@ SyncIndex syncUtilMinIndex(SyncIndex a, SyncIndex b) { SyncIndex syncUtilMaxIndex(SyncIndex a, SyncIndex b) { SyncIndex r = a > b ? a : b; return r; -} \ No newline at end of file +} From 6fcbca5b395b27d54c96c7c696e845b63272137d Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 16 Mar 2022 11:45:12 +0800 Subject: [PATCH 13/37] sync ping --- source/libs/sync/src/syncTimeout.c | 3 +- source/libs/sync/test/CMakeLists.txt | 28 +++++ source/libs/sync/test/syncInitTest.cpp | 2 - source/libs/sync/test/syncPingSelfTest.cpp | 102 ++++++++++++++++++ source/libs/sync/test/syncPingTimerTest.cpp | 1 + source/libs/sync/test/syncPingTimerTest2.cpp | 106 +++++++++++++++++++ 6 files changed, 239 insertions(+), 3 deletions(-) create mode 100644 source/libs/sync/test/syncPingSelfTest.cpp create mode 100644 source/libs/sync/test/syncPingTimerTest2.cpp diff --git a/source/libs/sync/src/syncTimeout.c b/source/libs/sync/src/syncTimeout.c index 3a48b0cbb3..0d3a3c3cc5 100644 --- a/source/libs/sync/src/syncTimeout.c +++ b/source/libs/sync/src/syncTimeout.c @@ -24,7 +24,8 @@ int32_t syncNodeOnTimeoutCb(SSyncNode* ths, SyncTimeout* pMsg) { if (pMsg->timeoutType == SYNC_TIMEOUT_PING) { if (atomic_load_64(&ths->pingTimerLogicClockUser) <= pMsg->logicClock) { ++(ths->pingTimerCounter); - syncNodePingAll(ths); + // syncNodePingAll(ths); + syncNodePingPeers(ths); } } else if (pMsg->timeoutType == SYNC_TIMEOUT_ELECTION) { diff --git a/source/libs/sync/test/CMakeLists.txt b/source/libs/sync/test/CMakeLists.txt index 6ade78936d..b542f55ec3 100644 --- a/source/libs/sync/test/CMakeLists.txt +++ b/source/libs/sync/test/CMakeLists.txt @@ -25,6 +25,8 @@ add_executable(syncTimeoutTest "") add_executable(syncPingTest "") add_executable(syncPingReplyTest "") add_executable(syncRpcMsgTest "") +add_executable(syncPingTimerTest2 "") +add_executable(syncPingSelfTest "") target_sources(syncTest @@ -135,6 +137,14 @@ target_sources(syncRpcMsgTest PRIVATE "syncRpcMsgTest.cpp" ) +target_sources(syncPingTimerTest2 + PRIVATE + "syncPingTimerTest2.cpp" +) +target_sources(syncPingSelfTest + PRIVATE + "syncPingSelfTest.cpp" +) target_include_directories(syncTest @@ -272,6 +282,16 @@ target_include_directories(syncRpcMsgTest "${CMAKE_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) +target_include_directories(syncPingTimerTest2 + PUBLIC + "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) +target_include_directories(syncPingSelfTest + PUBLIC + "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) target_link_libraries(syncTest @@ -382,6 +402,14 @@ target_link_libraries(syncRpcMsgTest sync gtest_main ) +target_link_libraries(syncPingTimerTest2 + sync + gtest_main +) +target_link_libraries(syncPingSelfTest + sync + gtest_main +) enable_testing() diff --git a/source/libs/sync/test/syncInitTest.cpp b/source/libs/sync/test/syncInitTest.cpp index c0d2336ba7..a3e5f41c85 100644 --- a/source/libs/sync/test/syncInitTest.cpp +++ b/source/libs/sync/test/syncInitTest.cpp @@ -52,8 +52,6 @@ SSyncNode* syncNodeInit() { gSyncIO->FpOnSyncRequestVoteReply = pSyncNode->FpOnRequestVoteReply; gSyncIO->FpOnSyncAppendEntries = pSyncNode->FpOnAppendEntries; gSyncIO->FpOnSyncAppendEntriesReply = pSyncNode->FpOnAppendEntriesReply; - gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing; - gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply; gSyncIO->FpOnSyncTimeout = pSyncNode->FpOnTimeout; gSyncIO->pSyncNode = pSyncNode; diff --git a/source/libs/sync/test/syncPingSelfTest.cpp b/source/libs/sync/test/syncPingSelfTest.cpp new file mode 100644 index 0000000000..05e4d99cb0 --- /dev/null +++ b/source/libs/sync/test/syncPingSelfTest.cpp @@ -0,0 +1,102 @@ +#include +#include +#include "syncEnv.h" +#include "syncIO.h" +#include "syncInt.h" +#include "syncRaftStore.h" +#include "syncUtil.h" + +void logTest() { + sTrace("--- sync log test: trace"); + sDebug("--- sync log test: debug"); + sInfo("--- sync log test: info"); + sWarn("--- sync log test: warn"); + sError("--- sync log test: error"); + sFatal("--- sync log test: fatal"); +} + +uint16_t ports[] = {7010, 7110, 7210, 7310, 7410}; +int32_t replicaNum = 3; +int32_t myIndex = 0; + +SRaftId ids[TSDB_MAX_REPLICA]; +SSyncInfo syncInfo; +SSyncFSM* pFsm; + +SSyncNode* syncNodeInit() { + syncInfo.vgId = 1234; + syncInfo.rpcClient = gSyncIO->clientRpc; + syncInfo.FpSendMsg = syncIOSendMsg; + syncInfo.queue = gSyncIO->pMsgQ; + syncInfo.FpEqMsg = syncIOEqMsg; + syncInfo.pFsm = pFsm; + snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", "./"); + + SSyncCfg* pCfg = &syncInfo.syncCfg; + pCfg->myIndex = myIndex; + pCfg->replicaNum = replicaNum; + + for (int i = 0; i < replicaNum; ++i) { + pCfg->nodeInfo[i].nodePort = ports[i]; + snprintf(pCfg->nodeInfo[i].nodeFqdn, sizeof(pCfg->nodeInfo[i].nodeFqdn), "%s", "127.0.0.1"); + // taosGetFqdn(pCfg->nodeInfo[0].nodeFqdn); + } + + SSyncNode* pSyncNode = syncNodeOpen(&syncInfo); + assert(pSyncNode != NULL); + + gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing; + gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply; + gSyncIO->FpOnSyncClientRequest = pSyncNode->FpOnClientRequest; + gSyncIO->FpOnSyncRequestVote = pSyncNode->FpOnRequestVote; + gSyncIO->FpOnSyncRequestVoteReply = pSyncNode->FpOnRequestVoteReply; + gSyncIO->FpOnSyncAppendEntries = pSyncNode->FpOnAppendEntries; + gSyncIO->FpOnSyncAppendEntriesReply = pSyncNode->FpOnAppendEntriesReply; + gSyncIO->FpOnSyncTimeout = pSyncNode->FpOnTimeout; + gSyncIO->pSyncNode = pSyncNode; + + return pSyncNode; +} + +SSyncNode* syncInitTest() { return syncNodeInit(); } + +void initRaftId(SSyncNode* pSyncNode) { + for (int i = 0; i < replicaNum; ++i) { + ids[i] = pSyncNode->replicasId[i]; + char* s = syncUtilRaftId2Str(&ids[i]); + printf("raftId[%d] : %s\n", i, s); + free(s); + } +} + +int main(int argc, char** argv) { + // taosInitLog((char *)"syncTest.log", 100000, 10); + tsAsyncLog = 0; + sDebugFlag = 143 + 64; + + myIndex = 0; + if (argc >= 2) { + myIndex = atoi(argv[1]); + } + + int32_t ret = syncIOStart((char*)"127.0.0.1", ports[myIndex]); + assert(ret == 0); + + ret = syncEnvStart(); + assert(ret == 0); + + SSyncNode* pSyncNode = syncInitTest(); + assert(pSyncNode != NULL); + syncNodePrint2((char*)"", pSyncNode); + + initRaftId(pSyncNode); + + //--------------------------- + + while (1) { + syncNodePingSelf(pSyncNode); + taosMsleep(1000); + } + + return 0; +} diff --git a/source/libs/sync/test/syncPingTimerTest.cpp b/source/libs/sync/test/syncPingTimerTest.cpp index e69878632f..20d4a9ce58 100644 --- a/source/libs/sync/test/syncPingTimerTest.cpp +++ b/source/libs/sync/test/syncPingTimerTest.cpp @@ -47,6 +47,7 @@ SSyncNode* syncNodeInit() { gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing; gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply; + gSyncIO->FpOnSyncClientRequest = pSyncNode->FpOnClientRequest; gSyncIO->FpOnSyncRequestVote = pSyncNode->FpOnRequestVote; gSyncIO->FpOnSyncRequestVoteReply = pSyncNode->FpOnRequestVoteReply; gSyncIO->FpOnSyncAppendEntries = pSyncNode->FpOnAppendEntries; diff --git a/source/libs/sync/test/syncPingTimerTest2.cpp b/source/libs/sync/test/syncPingTimerTest2.cpp new file mode 100644 index 0000000000..2a041f3f5d --- /dev/null +++ b/source/libs/sync/test/syncPingTimerTest2.cpp @@ -0,0 +1,106 @@ +#include +#include +#include "syncEnv.h" +#include "syncIO.h" +#include "syncInt.h" +#include "syncRaftStore.h" +#include "syncUtil.h" + +void logTest() { + sTrace("--- sync log test: trace"); + sDebug("--- sync log test: debug"); + sInfo("--- sync log test: info"); + sWarn("--- sync log test: warn"); + sError("--- sync log test: error"); + sFatal("--- sync log test: fatal"); +} + +uint16_t ports[] = {7010, 7110, 7210, 7310, 7410}; +int32_t replicaNum = 3; +int32_t myIndex = 0; + +SRaftId ids[TSDB_MAX_REPLICA]; +SSyncInfo syncInfo; +SSyncFSM* pFsm; + +SSyncNode* syncNodeInit() { + syncInfo.vgId = 1234; + syncInfo.rpcClient = gSyncIO->clientRpc; + syncInfo.FpSendMsg = syncIOSendMsg; + syncInfo.queue = gSyncIO->pMsgQ; + syncInfo.FpEqMsg = syncIOEqMsg; + syncInfo.pFsm = pFsm; + snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", "./"); + + SSyncCfg* pCfg = &syncInfo.syncCfg; + pCfg->myIndex = myIndex; + pCfg->replicaNum = replicaNum; + + for (int i = 0; i < replicaNum; ++i) { + pCfg->nodeInfo[i].nodePort = ports[i]; + snprintf(pCfg->nodeInfo[i].nodeFqdn, sizeof(pCfg->nodeInfo[i].nodeFqdn), "%s", "127.0.0.1"); + // taosGetFqdn(pCfg->nodeInfo[0].nodeFqdn); + } + + SSyncNode* pSyncNode = syncNodeOpen(&syncInfo); + assert(pSyncNode != NULL); + + gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing; + gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply; + gSyncIO->FpOnSyncClientRequest = pSyncNode->FpOnClientRequest; + gSyncIO->FpOnSyncRequestVote = pSyncNode->FpOnRequestVote; + gSyncIO->FpOnSyncRequestVoteReply = pSyncNode->FpOnRequestVoteReply; + gSyncIO->FpOnSyncAppendEntries = pSyncNode->FpOnAppendEntries; + gSyncIO->FpOnSyncAppendEntriesReply = pSyncNode->FpOnAppendEntriesReply; + gSyncIO->FpOnSyncTimeout = pSyncNode->FpOnTimeout; + gSyncIO->pSyncNode = pSyncNode; + + return pSyncNode; +} + +SSyncNode* syncInitTest() { return syncNodeInit(); } + +void initRaftId(SSyncNode* pSyncNode) { + for (int i = 0; i < replicaNum; ++i) { + ids[i] = pSyncNode->replicasId[i]; + char* s = syncUtilRaftId2Str(&ids[i]); + printf("raftId[%d] : %s\n", i, s); + free(s); + } +} + +int main(int argc, char** argv) { + // taosInitLog((char *)"syncTest.log", 100000, 10); + tsAsyncLog = 0; + sDebugFlag = 143 + 64; + + myIndex = 0; + if (argc >= 2) { + myIndex = atoi(argv[1]); + } + + int32_t ret = syncIOStart((char*)"127.0.0.1", ports[myIndex]); + assert(ret == 0); + + ret = syncEnvStart(); + assert(ret == 0); + + SSyncNode* pSyncNode = syncInitTest(); + assert(pSyncNode != NULL); + syncNodePrint2((char*)"", pSyncNode); + + initRaftId(pSyncNode); + + //--------------------------- + + sTrace("syncNodeStartPingTimer ..."); + ret = syncNodeStartPingTimer(pSyncNode); + assert(ret == 0); + + while (1) { + sTrace("while 1 sleep ..."); + taosMsleep(1000); + } + + return 0; +} From f43efb9fea446835bdd5613fa9cc2f5a867d583a Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 16 Mar 2022 13:30:03 +0800 Subject: [PATCH 14/37] handle except and update UT --- include/libs/transport/trpc.h | 2 +- source/libs/transport/inc/transportInt.h | 2 +- source/libs/transport/src/transSrv.c | 24 +++++++++--- source/libs/transport/test/transUT.cc | 47 ++++++++++++++++++------ 4 files changed, 55 insertions(+), 20 deletions(-) diff --git a/include/libs/transport/trpc.h b/include/libs/transport/trpc.h index b5b8d6ab66..5795cdd919 100644 --- a/include/libs/transport/trpc.h +++ b/include/libs/transport/trpc.h @@ -73,7 +73,7 @@ typedef struct SRpcInit { void *(*mfp)(void *parent, tmsg_t msgType); // call back to handle except when query/fetch in progress - void (*efp)(void *parent, tmsg_t msgType); + bool (*efp)(void *parent, tmsg_t msgType); void *parent; } SRpcInit; diff --git a/source/libs/transport/inc/transportInt.h b/source/libs/transport/inc/transportInt.h index e760fe1de9..e739380467 100644 --- a/source/libs/transport/inc/transportInt.h +++ b/source/libs/transport/inc/transportInt.h @@ -65,7 +65,7 @@ typedef struct { int (*afp)(void* parent, char* user, char* spi, char* encrypt, char* secret, char* ckey); bool (*pfp)(void* parent, tmsg_t msgType); void* (*mfp)(void* parent, tmsg_t msgType); - void (*efp)(void* parent, tmsg_t msgType); + bool (*efp)(void* parent, tmsg_t msgType); int32_t refCount; void* parent; diff --git a/source/libs/transport/src/transSrv.c b/source/libs/transport/src/transSrv.c index 960e064b8f..59bc85e91d 100644 --- a/source/libs/transport/src/transSrv.c +++ b/source/libs/transport/src/transSrv.c @@ -106,6 +106,8 @@ static void uvStartSendRespInternal(SSrvMsg* smsg); static void uvPrepareSendData(SSrvMsg* msg, uv_buf_t* wb); static void uvStartSendResp(SSrvMsg* msg); +static void uvNotifyLinkBrokenToApp(SSrvConn* conn); + static void destroySmsg(SSrvMsg* smsg); // check whether already read complete packet static SSrvConn* createConn(void* hThrd); @@ -233,7 +235,7 @@ static void uvHandleReq(SSrvConn* pConn) { ntohs(pConn->locaddr.sin_port), transMsg.contLen); STrans* pTransInst = (STrans*)p->shandle; - (*((STrans*)p->shandle)->cfp)(pTransInst->parent, &transMsg, NULL); + (*pTransInst->cfp)(pTransInst->parent, &transMsg, NULL); // uv_timer_start(&pConn->pTimer, uvHandleActivityTimeout, pRpc->idleTime * 10000, 0); // auth // validate msg type @@ -261,13 +263,12 @@ void uvOnRecvCb(uv_stream_t* cli, ssize_t nread, const uv_buf_t* buf) { tError("server conn %p read error: %s", conn, uv_err_name(nread)); if (nread < 0) { conn->broken = true; - transUnrefSrvHandle(conn); + uvNotifyLinkBrokenToApp(conn); - // if (conn->ref > 1) { - // conn->ref++; // ref > 1 signed that write is in progress + // STrans* pTransInst = conn->pTransInst; + // if (pTransInst->efp != NULL && (pTransInst->efp)(NULL, conn->inType)) { //} - // tError("server conn %p read error: %s", conn, uv_err_name(nread)); - // destroyConn(conn, true); + transUnrefSrvHandle(conn); } } void uvAllocConnBufferCb(uv_handle_t* handle, size_t suggested_size, uv_buf_t* buf) { @@ -373,6 +374,17 @@ static void uvStartSendResp(SSrvMsg* smsg) { uvStartSendRespInternal(smsg); return; } + +static void uvNotifyLinkBrokenToApp(SSrvConn* conn) { + STrans* pTransInst = conn->pTransInst; + if (pTransInst->efp != NULL && (*pTransInst->efp)(NULL, conn->inType) && T_REF_VAL_GET(conn) >= 2) { + STransMsg transMsg = {0}; + transMsg.msgType = conn->inType; + transMsg.code = TSDB_CODE_RPC_NETWORK_UNAVAIL; + // transRefSrvHandle(conn); + (*pTransInst->cfp)(pTransInst->parent, &transMsg, 0); + } +} static void destroySmsg(SSrvMsg* smsg) { if (smsg == NULL) { return; diff --git a/source/libs/transport/test/transUT.cc b/source/libs/transport/test/transUT.cc index 46f6424b0b..b3fbade050 100644 --- a/source/libs/transport/test/transUT.cc +++ b/source/libs/transport/test/transUT.cc @@ -15,6 +15,7 @@ #include #include #include +#include "rpcLog.h" #include "tdatablock.h" #include "tglobal.h" #include "tlog.h" @@ -48,7 +49,9 @@ static void *ConstructArgForSpecificMsgType(void *parent, tmsg_t msgType) { return NULL; } // server except -static void NotifyAppLinkBroken(void *parent, tmsg_t msgType) {} +static bool handleExcept(void *parent, tmsg_t msgType) { + return msgType == TDMT_VND_QUERY || msgType == TDMT_VND_FETCH_RSP || msgType == TDMT_VND_RES_READY_RSP; +} typedef void (*CB)(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet); static void processContinueSend(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet); @@ -83,6 +86,10 @@ class Client { rpcInit_.cfp = cb; this->transCli = rpcOpen(&rpcInit_); } + void Stop() { + rpcClose(this->transCli); + this->transCli = NULL; + } void SetPersistFP(bool (*pfp)(void *parent, tmsg_t msgType)) { rpcClose(this->transCli); rpcInit_.pfp = pfp; @@ -157,7 +164,7 @@ class Server { rpcClose(this->transSrv); this->transSrv = NULL; } - void SetExceptFp(void (*efp)(void *parent, tmsg_t msgType)) { + void SetExceptFp(bool (*efp)(void *parent, tmsg_t msgType)) { this->Stop(); rpcInit_.efp = efp; this->Start(); @@ -207,6 +214,7 @@ static void processResp(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) { Client *client = (Client *)parent; client->SetResp(pMsg); client->SemPost(); + tDebug("received resp"); } static void initEnv() { @@ -266,7 +274,7 @@ class TransObj { cli->SetPAndMFp(pfp, mfp); } // call when link broken, and notify query or fetch stop - void SetSrvExceptFp(void (*efp)(void *parent, tmsg_t msgType)) { + void SetSrvExceptFp(bool (*efp)(void *parent, tmsg_t msgType)) { //////// srv->SetExceptFp(efp); } @@ -275,6 +283,10 @@ class TransObj { srv->SetSrvContinueSend(cfp); } void RestartSrv() { srv->Restart(); } + void cliStop() { + /////// + cli->Stop(); + } void cliSendAndRecv(SRpcMsg *req, SRpcMsg *resp) { cli->SendAndRecv(req, resp); } void cliSendAndRecvNoHandle(SRpcMsg *req, SRpcMsg *resp) { cli->SendAndRecvNoHandle(req, resp); } @@ -417,20 +429,31 @@ TEST_F(TransEnv, srvContinueSend) { } TEST_F(TransEnv, srvPersistHandleExcept) { - // conn breken + tr->SetSrvContinueSend(processContinueSend); + tr->SetCliPersistFp(cliPersistHandle); + SRpcMsg resp = {0}; + for (int i = 0; i < 5; i++) { + SRpcMsg req = {.handle = resp.handle}; + req.msgType = 1; + req.pCont = rpcMallocCont(10); + req.contLen = 10; + tr->cliSendAndRecv(&req, &resp); + if (i > 2) { + tr->cliStop(); + break; + } + } + taosMsleep(2000); + // conn broken // } -TEST_F(TransEnv, cliPersistHandleExcept) { - // conn breken -} -TEST_F(TransEnv, multiCliPersisHandleExcept) { - // conn breken -} -TEST_F(TransEnv, multiSrvPersisHandleExcept) { - // conn breken +TEST_F(TransEnv, multiCliPersistHandleExcept) { + // conn broken } TEST_F(TransEnv, queryExcept) { + tr->SetSrvExceptFp(handleExcept); + // query and conn is broken } TEST_F(TransEnv, noResp) { From 8286d6efcffc13a835f185a607a4b814dd2e7957 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Wed, 16 Mar 2022 14:00:41 +0800 Subject: [PATCH 15/37] migrate TS-1278 from 2.x --- source/common/src/trow.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/common/src/trow.c b/source/common/src/trow.c index 861b4dc093..db4bc49425 100644 --- a/source/common/src/trow.c +++ b/source/common/src/trow.c @@ -353,10 +353,10 @@ static void tdMergeTwoDataCols(SDataCols *target, SDataCols *src1, int *iter1, i for (int i = 0; i < src2->numOfCols; i++) { SCellVal sVal = {0}; ASSERT(target->cols[i].type == src2->cols[i].type); - if (src2->cols[i].len > 0 && !isNull(src2->cols[i].pData, src2->cols[i].type)) { - if (tdGetColDataOfRow(&sVal, src1->cols + i, *iter1) < 0) { - TASSERT(0); - } + if (tdGetColDataOfRow(&sVal, src2->cols + i, *iter2) < 0) { + TASSERT(0); + } + if (src2->cols[i].len > 0 && !tdValTypeIsNull(sVal.valType)) { tdAppendValToDataCol(&(target->cols[i]), sVal.valType, sVal.val, target->numOfRows, target->maxPoints); } else if (!forceSetNull && key1 == key2 && src1->cols[i].len > 0) { if (tdGetColDataOfRow(&sVal, src1->cols + i, *iter1) < 0) { From f8f7aabfd9ddf41338016a038f80cfac279204ab Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Wed, 16 Mar 2022 02:08:59 -0400 Subject: [PATCH 16/37] TD-13597 create/drop topic, alter database, drop index, drop qnode statement implement --- include/common/tmsg.h | 4 +- include/common/ttokendef.h | 95 +- include/libs/nodes/cmdnodes.h | 31 + include/libs/nodes/nodes.h | 5 + source/client/src/tmq.c | 4 +- source/common/src/tmsg.c | 41 +- source/dnode/mnode/impl/src/mndTopic.c | 27 +- source/dnode/mnode/impl/test/topic/topic.cpp | 3 +- source/libs/nodes/src/nodesCodeFuncs.c | 7 +- source/libs/nodes/src/nodesUtilFuncs.c | 10 + source/libs/parser/inc/parAst.h | 5 + source/libs/parser/inc/sql.y | 32 +- source/libs/parser/src/parAstCreater.c | 49 + source/libs/parser/src/parTokenizer.c | 2 +- source/libs/parser/src/parTranslater.c | 175 +- source/libs/parser/src/sql.c | 3099 +++++++++--------- source/libs/parser/test/parserAstTest.cpp | 57 + 17 files changed, 2024 insertions(+), 1622 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index f0718900c0..dc418147b0 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1157,8 +1157,8 @@ typedef struct { char name[TSDB_TOPIC_FNAME_LEN]; int8_t igExists; char* sql; - char* physicalPlan; - char* logicalPlan; + char* ast; + char subscribeDbName[TSDB_DB_NAME_LEN]; } SCMCreateTopicReq; int32_t tSerializeSCMCreateTopicReq(void* buf, int32_t bufLen, const SCMCreateTopicReq* pReq); diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 5693091bd5..167c72a778 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -108,53 +108,54 @@ #define TK_FULLTEXT 90 #define TK_FUNCTION 91 #define TK_INTERVAL 92 -#define TK_MNODES 93 -#define TK_NK_FLOAT 94 -#define TK_NK_BOOL 95 -#define TK_NK_VARIABLE 96 -#define TK_BETWEEN 97 -#define TK_IS 98 -#define TK_NULL 99 -#define TK_NK_LT 100 -#define TK_NK_GT 101 -#define TK_NK_LE 102 -#define TK_NK_GE 103 -#define TK_NK_NE 104 -#define TK_NK_EQ 105 -#define TK_LIKE 106 -#define TK_MATCH 107 -#define TK_NMATCH 108 -#define TK_IN 109 -#define TK_FROM 110 -#define TK_AS 111 -#define TK_JOIN 112 -#define TK_INNER 113 -#define TK_SELECT 114 -#define TK_DISTINCT 115 -#define TK_WHERE 116 -#define TK_PARTITION 117 -#define TK_BY 118 -#define TK_SESSION 119 -#define TK_STATE_WINDOW 120 -#define TK_SLIDING 121 -#define TK_FILL 122 -#define TK_VALUE 123 -#define TK_NONE 124 -#define TK_PREV 125 -#define TK_LINEAR 126 -#define TK_NEXT 127 -#define TK_GROUP 128 -#define TK_HAVING 129 -#define TK_ORDER 130 -#define TK_SLIMIT 131 -#define TK_SOFFSET 132 -#define TK_LIMIT 133 -#define TK_OFFSET 134 -#define TK_ASC 135 -#define TK_DESC 136 -#define TK_NULLS 137 -#define TK_FIRST 138 -#define TK_LAST 139 +#define TK_TOPIC 93 +#define TK_AS 94 +#define TK_MNODES 95 +#define TK_NK_FLOAT 96 +#define TK_NK_BOOL 97 +#define TK_NK_VARIABLE 98 +#define TK_BETWEEN 99 +#define TK_IS 100 +#define TK_NULL 101 +#define TK_NK_LT 102 +#define TK_NK_GT 103 +#define TK_NK_LE 104 +#define TK_NK_GE 105 +#define TK_NK_NE 106 +#define TK_NK_EQ 107 +#define TK_LIKE 108 +#define TK_MATCH 109 +#define TK_NMATCH 110 +#define TK_IN 111 +#define TK_FROM 112 +#define TK_JOIN 113 +#define TK_INNER 114 +#define TK_SELECT 115 +#define TK_DISTINCT 116 +#define TK_WHERE 117 +#define TK_PARTITION 118 +#define TK_BY 119 +#define TK_SESSION 120 +#define TK_STATE_WINDOW 121 +#define TK_SLIDING 122 +#define TK_FILL 123 +#define TK_VALUE 124 +#define TK_NONE 125 +#define TK_PREV 126 +#define TK_LINEAR 127 +#define TK_NEXT 128 +#define TK_GROUP 129 +#define TK_HAVING 130 +#define TK_ORDER 131 +#define TK_SLIMIT 132 +#define TK_SOFFSET 133 +#define TK_LIMIT 134 +#define TK_OFFSET 135 +#define TK_ASC 136 +#define TK_DESC 137 +#define TK_NULLS 138 +#define TK_FIRST 139 +#define TK_LAST 140 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 21d9ff83c8..5d7174fc08 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -61,6 +61,12 @@ typedef struct SDropDatabaseStmt { bool ignoreNotExists; } SDropDatabaseStmt; +typedef struct SAlterDatabaseStmt { + ENodeType type; + char dbName[TSDB_DB_NAME_LEN]; + SDatabaseOptions* pOptions; +} SAlterDatabaseStmt; + typedef struct STableOptions { ENodeType type; int32_t keep; @@ -179,11 +185,36 @@ typedef struct SCreateIndexStmt { SIndexOptions* pOptions; } SCreateIndexStmt; +typedef struct SDropIndexStmt { + ENodeType type; + char indexName[TSDB_INDEX_NAME_LEN]; + char tableName[TSDB_TABLE_NAME_LEN]; +} SDropIndexStmt; + typedef struct SCreateQnodeStmt { ENodeType type; int32_t dnodeId; } SCreateQnodeStmt; +typedef struct SDropQnodeStmt { + ENodeType type; + int32_t dnodeId; +} SDropQnodeStmt; + +typedef struct SCreateTopicStmt { + ENodeType type; + char topicName[TSDB_TABLE_NAME_LEN]; + char subscribeDbName[TSDB_DB_NAME_LEN]; + bool ignoreExists; + SNode* pQuery; +} SCreateTopicStmt; + +typedef struct SDropTopicStmt { + ENodeType type; + char topicName[TSDB_TABLE_NAME_LEN]; + bool ignoreNotExists; +} SDropTopicStmt; + #ifdef __cplusplus } #endif diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index cf34c6665a..4ef70fc7ab 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -77,6 +77,7 @@ typedef enum ENodeType { QUERY_NODE_VNODE_MODIF_STMT, QUERY_NODE_CREATE_DATABASE_STMT, QUERY_NODE_DROP_DATABASE_STMT, + QUERY_NODE_ALTER_DATABASE_STMT, QUERY_NODE_SHOW_DATABASES_STMT, // temp QUERY_NODE_CREATE_TABLE_STMT, QUERY_NODE_CREATE_SUBTABLE_CLAUSE, @@ -98,7 +99,11 @@ typedef enum ENodeType { QUERY_NODE_SHOW_MNODES_STMT, QUERY_NODE_SHOW_QNODES_STMT, QUERY_NODE_CREATE_INDEX_STMT, + QUERY_NODE_DROP_INDEX_STMT, QUERY_NODE_CREATE_QNODE_STMT, + QUERY_NODE_DROP_QNODE_STMT, + QUERY_NODE_CREATE_TOPIC_STMT, + QUERY_NODE_DROP_TOPIC_STMT, // logic plan node QUERY_NODE_LOGIC_PLAN_SCAN, diff --git a/source/client/src/tmq.c b/source/client/src/tmq.c index b3f71c1075..0ddd53be08 100644 --- a/source/client/src/tmq.c +++ b/source/client/src/tmq.c @@ -482,7 +482,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i } tscDebug("start to create topic, %s", topicName); - +#if 0 CHECK_CODE_GOTO(buildRequest(pTscObj, sql, sqlLen, &pRequest), _return); CHECK_CODE_GOTO(parseSql(pRequest, &pQueryNode), _return); @@ -536,7 +536,7 @@ TAOS_RES* tmq_create_topic(TAOS* taos, const char* topicName, const char* sql, i asyncSendMsgToServer(pTscObj->pAppInfo->pTransporter, &epSet, &transporterId, sendInfo); tsem_wait(&pRequest->body.rspSem); - +#endif _return: qDestroyQuery(pQueryNode); /*if (sendInfo != NULL) {*/ diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index f26f19f3b2..abd341557f 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -1990,11 +1990,9 @@ int32_t tDeserializeSMDropTopicReq(void *buf, int32_t bufLen, SMDropTopicReq *pR int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTopicReq *pReq) { int32_t sqlLen = 0; - int32_t physicalPlanLen = 0; - int32_t logicalPlanLen = 0; + int32_t astLen = 0; if (pReq->sql != NULL) sqlLen = (int32_t)strlen(pReq->sql); - if (pReq->physicalPlan != NULL) physicalPlanLen = (int32_t)strlen(pReq->physicalPlan); - if (pReq->logicalPlan != NULL) logicalPlanLen = (int32_t)strlen(pReq->logicalPlan); + if (pReq->ast != NULL) astLen = (int32_t)strlen(pReq->ast); SCoder encoder = {0}; tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); @@ -2003,11 +2001,9 @@ int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTo if (tEncodeCStr(&encoder, pReq->name) < 0) return -1; if (tEncodeI8(&encoder, pReq->igExists) < 0) return -1; if (tEncodeI32(&encoder, sqlLen) < 0) return -1; - if (tEncodeI32(&encoder, physicalPlanLen) < 0) return -1; - if (tEncodeI32(&encoder, logicalPlanLen) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->sql) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->physicalPlan) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->logicalPlan) < 0) return -1; + if (tEncodeI32(&encoder, astLen) < 0) return -1; + if (sqlLen > 0 && tEncodeCStr(&encoder, pReq->sql) < 0) return -1; + if (astLen > 0 && tEncodeCStr(&encoder, pReq->ast) < 0) return -1; tEndEncode(&encoder); @@ -2018,8 +2014,7 @@ int32_t tSerializeSCMCreateTopicReq(void *buf, int32_t bufLen, const SCMCreateTo int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicReq *pReq) { int32_t sqlLen = 0; - int32_t physicalPlanLen = 0; - int32_t logicalPlanLen = 0; + int32_t astLen = 0; SCoder decoder = {0}; tCoderInit(&decoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_DECODER); @@ -2028,17 +2023,20 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1; if (tDecodeI8(&decoder, &pReq->igExists) < 0) return -1; if (tDecodeI32(&decoder, &sqlLen) < 0) return -1; - if (tDecodeI32(&decoder, &physicalPlanLen) < 0) return -1; - if (tDecodeI32(&decoder, &logicalPlanLen) < 0) return -1; + if (tDecodeI32(&decoder, &astLen) < 0) return -1; - pReq->sql = calloc(1, sqlLen + 1); - pReq->physicalPlan = calloc(1, physicalPlanLen + 1); - pReq->logicalPlan = calloc(1, logicalPlanLen + 1); - if (pReq->sql == NULL || pReq->physicalPlan == NULL || pReq->logicalPlan == NULL) return -1; + if (sqlLen > 0) { + pReq->sql = calloc(1, sqlLen + 1); + if (pReq->sql == NULL) return -1; + if (tDecodeCStrTo(&decoder, pReq->sql) < 0) return -1; + } + + if (astLen > 0) { + pReq->ast = calloc(1, astLen + 1); + if (pReq->ast == NULL) return -1; + if (tDecodeCStrTo(&decoder, pReq->ast) < 0) return -1; + } - if (tDecodeCStrTo(&decoder, pReq->sql) < 0) return -1; - if (tDecodeCStrTo(&decoder, pReq->physicalPlan) < 0) return -1; - if (tDecodeCStrTo(&decoder, pReq->logicalPlan) < 0) return -1; tEndDecode(&decoder); tCoderClear(&decoder); @@ -2047,8 +2045,7 @@ int32_t tDeserializeSCMCreateTopicReq(void *buf, int32_t bufLen, SCMCreateTopicR void tFreeSCMCreateTopicReq(SCMCreateTopicReq *pReq) { tfree(pReq->sql); - tfree(pReq->physicalPlan); - tfree(pReq->logicalPlan); + tfree(pReq->ast); } int32_t tSerializeSCMCreateTopicRsp(void *buf, int32_t bufLen, const SCMCreateTopicRsp *pRsp) { diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index 7d7c5f9975..32fa3df910 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -236,6 +236,25 @@ static int32_t mndCheckCreateTopicReq(SCMCreateTopicReq *pCreate) { return 0; } +static int32_t mndGetPlanString(SCMCreateTopicReq *pCreate, char **pStr) { + SNode* pAst = NULL; + int32_t code = nodesStringToNode(pCreate->ast, &pAst); + + SQueryPlan* pPlan = NULL; + if (TSDB_CODE_SUCCESS == code) { + SPlanContext cxt = { .pAstRoot = pAst, .streamQuery = true }; + code = qCreateQueryPlan(&cxt, &pPlan, NULL); + } + + if (TSDB_CODE_SUCCESS == code) { + code = nodesNodeToString(pPlan, false, pStr, NULL); + } + nodesDestroyNode(pAst); + nodesDestroyNode(pPlan); + terrno = code; + return code; +} + static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateTopicReq *pCreate, SDbObj *pDb) { mDebug("topic:%s to create", pCreate->name); SMqTopicObj topicObj = {0}; @@ -247,10 +266,14 @@ static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateTopicReq topicObj.dbUid = pDb->uid; topicObj.version = 1; topicObj.sql = pCreate->sql; - topicObj.physicalPlan = pCreate->physicalPlan; - topicObj.logicalPlan = pCreate->logicalPlan; + topicObj.logicalPlan = NULL; topicObj.sqlLen = strlen(pCreate->sql); + if (TSDB_CODE_SUCCESS != mndGetPlanString(pCreate, &topicObj.physicalPlan)) { + mError("topic:%s, failed to get plan since %s", pCreate->name, terrstr()); + return -1; + } + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_TYPE_CREATE_TOPIC, &pReq->rpcMsg); if (pTrans == NULL) { mError("topic:%s, failed to create since %s", pCreate->name, terrstr()); diff --git a/source/dnode/mnode/impl/test/topic/topic.cpp b/source/dnode/mnode/impl/test/topic/topic.cpp index f58d0a6771..79f353a4d6 100644 --- a/source/dnode/mnode/impl/test/topic/topic.cpp +++ b/source/dnode/mnode/impl/test/topic/topic.cpp @@ -65,8 +65,7 @@ void* MndTestTopic::BuildCreateTopicReq(const char* topicName, const char* sql, strcpy(createReq.name, topicName); createReq.igExists = 0; createReq.sql = (char*)sql; - createReq.physicalPlan = (char*)"physicalPlan"; - createReq.logicalPlan = (char*)"logicalPlan"; + createReq.ast = (char*)"ast"; int32_t contLen = tSerializeSCMCreateTopicReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index 457f863a5e..a2fd32d238 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -1730,7 +1730,7 @@ static int32_t jsonToNodeObject(const SJson* pJson, const char* pName, SNode** p } int32_t nodesNodeToString(const SNodeptr pNode, bool format, char** pStr, int32_t* pLen) { - if (NULL == pNode || NULL == pStr || NULL == pLen) { + if (NULL == pNode || NULL == pStr) { terrno = TSDB_CODE_FAILED; return TSDB_CODE_FAILED; } @@ -1750,7 +1750,10 @@ int32_t nodesNodeToString(const SNodeptr pNode, bool format, char** pStr, int32_ *pStr = format ? tjsonToString(pJson) : tjsonToUnformattedString(pJson); tjsonDelete(pJson); - *pLen = strlen(*pStr) + 1; + if (NULL != pLen) { + *pLen = strlen(*pStr) + 1; + } + return TSDB_CODE_SUCCESS; } diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index b17a4904da..75568019cb 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -92,6 +92,8 @@ SNodeptr nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SCreateDatabaseStmt)); case QUERY_NODE_DROP_DATABASE_STMT: return makeNode(type, sizeof(SDropDatabaseStmt)); + case QUERY_NODE_ALTER_DATABASE_STMT: + return makeNode(type, sizeof(SAlterDatabaseStmt)); case QUERY_NODE_SHOW_DATABASES_STMT: return makeNode(type, sizeof(SShowStmt)); case QUERY_NODE_CREATE_TABLE_STMT: @@ -131,8 +133,16 @@ SNodeptr nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SShowStmt)); case QUERY_NODE_CREATE_INDEX_STMT: return makeNode(type, sizeof(SCreateIndexStmt)); + case QUERY_NODE_DROP_INDEX_STMT: + return makeNode(type, sizeof(SDropIndexStmt)); case QUERY_NODE_CREATE_QNODE_STMT: return makeNode(type, sizeof(SCreateQnodeStmt)); + case QUERY_NODE_DROP_QNODE_STMT: + return makeNode(type, sizeof(SDropQnodeStmt)); + case QUERY_NODE_CREATE_TOPIC_STMT: + return makeNode(type, sizeof(SCreateTopicStmt)); + case QUERY_NODE_DROP_TOPIC_STMT: + return makeNode(type, sizeof(SDropTopicStmt)); case QUERY_NODE_LOGIC_PLAN_SCAN: return makeNode(type, sizeof(SScanLogicNode)); case QUERY_NODE_LOGIC_PLAN_JOIN: diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index f2fcced1a9..31d7331d0e 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -113,6 +113,7 @@ SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt); SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, const SToken* pVal); SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pDbName, SNode* pOptions); SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pDbName); +SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName, SNode* pOptions); SNode* createDefaultTableOptions(SAstCreateContext* pCxt); SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, const SToken* pVal); SNode* setTableSmaOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pSma); @@ -134,7 +135,11 @@ SNode* createCreateDnodeStmt(SAstCreateContext* pCxt, const SToken* pFqdn, const SNode* createDropDnodeStmt(SAstCreateContext* pCxt, const SToken* pDnode); SNode* createCreateIndexStmt(SAstCreateContext* pCxt, EIndexType type, const SToken* pIndexName, const SToken* pTableName, SNodeList* pCols, SNode* pOptions); SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInterval, SNode* pOffset, SNode* pSliding); +SNode* createDropIndexStmt(SAstCreateContext* pCxt, const SToken* pIndexName, const SToken* pTableName); SNode* createCreateQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId); +SNode* createDropQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId); +SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pQuery, const SToken* pSubscribeDbName); +SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName); #ifdef __cplusplus } diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index af2fb12c52..31c26e1e40 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -42,17 +42,17 @@ //%right NK_BITNOT. /************************************************ create/alter/drop/show user *****************************************/ -cmd ::= CREATE USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createCreateUserStmt(pCxt, &A, &B);} -cmd ::= ALTER USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PASSWD, &B);} -cmd ::= ALTER USER user_name(A) PRIVILEGE NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PRIVILEGES, &B);} +cmd ::= CREATE USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createCreateUserStmt(pCxt, &A, &B); } +cmd ::= ALTER USER user_name(A) PASS NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PASSWD, &B); } +cmd ::= ALTER USER user_name(A) PRIVILEGE NK_STRING(B). { pCxt->pRootNode = createAlterUserStmt(pCxt, &A, TSDB_ALTER_USER_PRIVILEGES, &B); } cmd ::= DROP USER user_name(A). { pCxt->pRootNode = createDropUserStmt(pCxt, &A); } cmd ::= SHOW USERS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL); } /************************************************ create/drop/show dnode **********************************************/ -cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL);} -cmd ::= CREATE DNODE dnode_host_name(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B);} -cmd ::= DROP DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A);} -cmd ::= DROP DNODE dnode_endpoint(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A);} +cmd ::= CREATE DNODE dnode_endpoint(A). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, NULL); } +cmd ::= CREATE DNODE dnode_host_name(A) PORT NK_INTEGER(B). { pCxt->pRootNode = createCreateDnodeStmt(pCxt, &A, &B); } +cmd ::= DROP DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A); } +cmd ::= DROP DNODE dnode_endpoint(A). { pCxt->pRootNode = createDropDnodeStmt(pCxt, &A); } cmd ::= SHOW DNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL); } %type dnode_endpoint { SToken } @@ -64,15 +64,17 @@ dnode_endpoint(A) ::= NK_STRING(B). dnode_host_name(A) ::= NK_ID(B). { A = B; } dnode_host_name(A) ::= NK_IPTOKEN(B). { A = B; } -/************************************************ create qnode ********************************************************/ +/************************************************ create/drop qnode ***************************************************/ cmd ::= CREATE QNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createCreateQnodeStmt(pCxt, &A); } +cmd ::= DROP QNODE ON DNODE NK_INTEGER(A). { pCxt->pRootNode = createDropQnodeStmt(pCxt, &A); } cmd ::= SHOW QNODES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT, NULL); } /************************************************ create/drop/show/use database ***************************************/ -cmd ::= CREATE DATABASE not_exists_opt(A) db_name(B) db_options(C). { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, A, &B, C);} +cmd ::= CREATE DATABASE not_exists_opt(A) db_name(B) db_options(C). { pCxt->pRootNode = createCreateDatabaseStmt(pCxt, A, &B, C); } cmd ::= DROP DATABASE exists_opt(A) db_name(B). { pCxt->pRootNode = createDropDatabaseStmt(pCxt, A, &B); } cmd ::= SHOW DATABASES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL); } -cmd ::= USE db_name(A). { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &A);} +cmd ::= USE db_name(A). { pCxt->pRootNode = createUseDatabaseStmt(pCxt, &A); } +cmd ::= ALTER DATABASE db_name(A) db_options(B). { pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &A, B); } %type not_exists_opt { bool } %destructor not_exists_opt { } @@ -198,6 +200,7 @@ col_name(A) ::= column_name(B). cmd ::= CREATE SMA INDEX index_name(A) ON table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &A, &B, NULL, C); } cmd ::= CREATE FULLTEXT INDEX index_name(A) ON table_name(B) NK_LP col_name_list(C) NK_RP. { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &A, &B, C, NULL); } +cmd ::= DROP INDEX index_name(A) ON table_name(B). { pCxt->pRootNode = createDropIndexStmt(pCxt, &A, &B); } index_options(A) ::= . { A = NULL; } index_options(A) ::= FUNCTION NK_LP func_list(B) NK_RP INTERVAL @@ -212,6 +215,11 @@ func_list(A) ::= func_list(B) NK_COMMA func(C). func(A) ::= function_name(B) NK_LP expression_list(C) NK_RP. { A = createFunctionNode(pCxt, &B, C); } +/************************************************ create/drop topic ***************************************************/ +cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS query_expression(C). { pCxt->pRootNode = createCreateTopicStmt(pCxt, A, &B, C, NULL); } +cmd ::= CREATE TOPIC not_exists_opt(A) topic_name(B) AS db_name(C). { pCxt->pRootNode = createCreateTopicStmt(pCxt, A, &B, NULL, &C); } +cmd ::= DROP TOPIC exists_opt(A) topic_name(B). { pCxt->pRootNode = createDropTopicStmt(pCxt, A, &B); } + /************************************************ show vgroups ********************************************************/ cmd ::= SHOW VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, NULL); } cmd ::= SHOW db_name(B) NK_DOT VGROUPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &B); } @@ -270,6 +278,10 @@ user_name(A) ::= NK_ID(B). %destructor index_name { } index_name(A) ::= NK_ID(B). { A = B; } +%type topic_name { SToken } +%destructor topic_name { } +topic_name(A) ::= NK_ID(B). { A = B; } + /************************************************ expression **********************************************************/ expression(A) ::= literal(B). { A = B; } //expression(A) ::= NK_QUESTION(B). { A = B; } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index b7ecf160fd..034346362c 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -799,6 +799,17 @@ SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, con return (SNode*)pStmt; } +SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName, SNode* pOptions) { + if (!checkDbName(pCxt, pDbName)) { + return NULL; + } + SAlterDatabaseStmt* pStmt = nodesMakeNode(QUERY_NODE_ALTER_DATABASE_STMT); + CHECK_OUT_OF_MEM(pStmt); + strncpy(pStmt->dbName, pDbName->z, pDbName->n); + pStmt->pOptions = (SDatabaseOptions*)pOptions; + return (SNode*)pStmt; +} + SNode* createDefaultTableOptions(SAstCreateContext* pCxt) { STableOptions* pOptions = nodesMakeNode(QUERY_NODE_TABLE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); @@ -1022,9 +1033,47 @@ SNode* createIndexOption(SAstCreateContext* pCxt, SNodeList* pFuncs, SNode* pInt return (SNode*)pOptions; } +SNode* createDropIndexStmt(SAstCreateContext* pCxt, const SToken* pIndexName, const SToken* pTableName) { + if (!checkIndexName(pCxt, pIndexName) || !checkTableName(pCxt, pTableName)) { + return NULL; + } + SDropIndexStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_INDEX_STMT); + CHECK_OUT_OF_MEM(pStmt); + strncpy(pStmt->indexName, pIndexName->z, pIndexName->n); + strncpy(pStmt->tableName, pTableName->z, pTableName->n); + return (SNode*)pStmt; +} + SNode* createCreateQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId) { SCreateQnodeStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_QNODE_STMT); CHECK_OUT_OF_MEM(pStmt); pStmt->dnodeId = strtol(pDnodeId->z, NULL, 10);; return (SNode*)pStmt; } + +SNode* createDropQnodeStmt(SAstCreateContext* pCxt, const SToken* pDnodeId) { + SDropQnodeStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_QNODE_STMT); + CHECK_OUT_OF_MEM(pStmt); + pStmt->dnodeId = strtol(pDnodeId->z, NULL, 10);; + return (SNode*)pStmt; +} + +SNode* createCreateTopicStmt(SAstCreateContext* pCxt, bool ignoreExists, const SToken* pTopicName, SNode* pQuery, const SToken* pSubscribeDbName) { + SCreateTopicStmt* pStmt = nodesMakeNode(QUERY_NODE_CREATE_TOPIC_STMT); + CHECK_OUT_OF_MEM(pStmt); + strncpy(pStmt->topicName, pTopicName->z, pTopicName->n); + pStmt->ignoreExists = ignoreExists; + pStmt->pQuery = pQuery; + if (NULL != pSubscribeDbName) { + strncpy(pStmt->subscribeDbName, pSubscribeDbName->z, pSubscribeDbName->n); + } + return (SNode*)pStmt; +} + +SNode* createDropTopicStmt(SAstCreateContext* pCxt, bool ignoreNotExists, const SToken* pTopicName) { + SDropTopicStmt* pStmt = nodesMakeNode(QUERY_NODE_DROP_TOPIC_STMT); + CHECK_OUT_OF_MEM(pStmt); + strncpy(pStmt->topicName, pTopicName->z, pTopicName->n); + pStmt->ignoreNotExists = ignoreNotExists; + return (SNode*)pStmt; +} diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 4d50d92d9e..2d58d4e1e3 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -121,6 +121,7 @@ static SKeyword keywordTable[] = { {"TAGS", TK_TAGS}, {"TIMESTAMP", TK_TIMESTAMP}, {"TINYINT", TK_TINYINT}, + {"TOPIC", TK_TOPIC}, {"TTL", TK_TTL}, {"UNION", TK_UNION}, {"UNSIGNED", TK_UNSIGNED}, @@ -230,7 +231,6 @@ static SKeyword keywordTable[] = { // {"TBNAME", TK_TBNAME}, // {"VNODES", TK_VNODES}, // {"PARTITIONS", TK_PARTITIONS}, - // {"TOPIC", TK_TOPIC}, // {"TOPICS", TK_TOPICS}, // {"COMPACT", TK_COMPACT}, // {"MODIFY", TK_MODIFY}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index 4f89e7e703..af7a38b702 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -21,14 +21,6 @@ #include "parUtil.h" #include "ttime.h" -static bool afterGroupBy(ESqlClause clause) { - return clause > SQL_CLAUSE_GROUP_BY; -} - -static bool beforeHaving(ESqlClause clause) { - return clause < SQL_CLAUSE_HAVING; -} - typedef struct STranslateContext { SParseContext* pParseCxt; int32_t errCode; @@ -41,6 +33,15 @@ typedef struct STranslateContext { } STranslateContext; static int32_t translateSubquery(STranslateContext* pCxt, SNode* pNode); +static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode); + +static bool afterGroupBy(ESqlClause clause) { + return clause > SQL_CLAUSE_GROUP_BY; +} + +static bool beforeHaving(ESqlClause clause) { + return clause < SQL_CLAUSE_HAVING; +} static EDealRes generateDealNodeErrMsg(STranslateContext* pCxt, int32_t errCode, ...) { va_list vArgList; @@ -833,6 +834,41 @@ static int32_t translateDropDatabase(STranslateContext* pCxt, SDropDatabaseStmt* return TSDB_CODE_SUCCESS; } +static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt, SAlterDbReq* pReq) { + SName name = {0}; + tNameSetDbName(&name, pCxt->pParseCxt->acctId, pStmt->dbName, strlen(pStmt->dbName)); + tNameGetFullDbName(&name, pReq->db); + pReq->totalBlocks = pStmt->pOptions->numOfBlocks; + pReq->daysToKeep0 = pStmt->pOptions->keep; + pReq->daysToKeep1 = -1; + pReq->daysToKeep2 = -1; + pReq->fsyncPeriod = pStmt->pOptions->fsyncPeriod; + pReq->walLevel = pStmt->pOptions->walLevel; + pReq->quorum = pStmt->pOptions->quorum; + pReq->cacheLastRow = pStmt->pOptions->cachelast; + return; +} + +static int32_t translateAlterDatabase(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt) { + SAlterDbReq alterReq = {0}; + buildAlterDbReq(pCxt, pStmt, &alterReq); + + pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); + if (NULL == pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_MND_ALTER_DB; + pCxt->pCmdMsg->msgLen = tSerializeSAlterDbReq(NULL, 0, &alterReq); + pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); + if (NULL == pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + tSerializeSAlterDbReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &alterReq); + + return TSDB_CODE_SUCCESS; +} + static int32_t columnNodeToField(SNodeList* pList, SArray** pArray) { *pArray = taosArrayInit(LIST_LENGTH(pList), sizeof(SField)); SNode* pNode; @@ -1201,6 +1237,27 @@ static int32_t translateCreateIndex(STranslateContext* pCxt, SCreateIndexStmt* p } } +static int32_t translateDropIndex(STranslateContext* pCxt, SDropIndexStmt* pStmt) { + SVDropTSmaReq dropSmaReq = {0}; + strcpy(dropSmaReq.indexName, pStmt->indexName); + + pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); + if (NULL == pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_VND_DROP_SMA; + pCxt->pCmdMsg->msgLen = tSerializeSVDropTSmaReq(NULL, &dropSmaReq); + pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); + if (NULL == pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + void* pBuf = pCxt->pCmdMsg->pMsg; + tSerializeSVDropTSmaReq(&pBuf, &dropSmaReq); + + return TSDB_CODE_SUCCESS; +} + static int32_t translateCreateQnode(STranslateContext* pCxt, SCreateQnodeStmt* pStmt) { SMCreateQnodeReq createReq = { .dnodeId = pStmt->dnodeId }; @@ -1220,6 +1277,93 @@ static int32_t translateCreateQnode(STranslateContext* pCxt, SCreateQnodeStmt* p return TSDB_CODE_SUCCESS; } +static int32_t translateDropQnode(STranslateContext* pCxt, SDropQnodeStmt* pStmt) { + SDDropQnodeReq dropReq = { .dnodeId = pStmt->dnodeId }; + + pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); + if (NULL == pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_DND_DROP_QNODE; + pCxt->pCmdMsg->msgLen = tSerializeSMCreateDropQSBNodeReq(NULL, 0, &dropReq); + pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); + if (NULL == pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + tSerializeSMCreateDropQSBNodeReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq); + + return TSDB_CODE_SUCCESS; +} + +static int32_t translateCreateTopic(STranslateContext* pCxt, SCreateTopicStmt* pStmt) { + SCMCreateTopicReq createReq = {0}; + + if (NULL != pStmt->pQuery) { + int32_t code = translateQuery(pCxt, pStmt->pQuery); + if (TSDB_CODE_SUCCESS == code) { + code = nodesNodeToString(pStmt->pQuery, false, &createReq.ast, NULL); + } + if (TSDB_CODE_SUCCESS != code ) { + return code; + } + } else { + strcpy(createReq.subscribeDbName, pStmt->subscribeDbName); + } + + createReq.sql = strdup(pCxt->pParseCxt->pSql); + if (NULL == createReq.sql) { + return TSDB_CODE_OUT_OF_MEMORY; + } + + SName name = { .type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId }; + strcpy(name.dbname, pCxt->pParseCxt->db); + strcpy(name.tname, pStmt->topicName); + tNameExtractFullName(&name, createReq.name); + createReq.igExists = pStmt->ignoreExists; + + pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); + if (NULL == pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_MND_CREATE_TOPIC; + pCxt->pCmdMsg->msgLen = tSerializeSCMCreateTopicReq(NULL, 0, &createReq); + pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); + if (NULL == pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + tSerializeSCMCreateTopicReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &createReq); + tFreeSCMCreateTopicReq(&createReq); + + return TSDB_CODE_SUCCESS; +} + +static int32_t translateDropTopic(STranslateContext* pCxt, SDropTopicStmt* pStmt) { + SMDropTopicReq dropReq = {0}; + + SName name = { .type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId }; + strcpy(name.dbname, pCxt->pParseCxt->db); + strcpy(name.tname, pStmt->topicName); + tNameExtractFullName(&name, dropReq.name); + dropReq.igNotExists = pStmt->ignoreNotExists; + + pCxt->pCmdMsg = malloc(sizeof(SCmdMsgInfo)); + if (NULL == pCxt->pCmdMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pCxt->pCmdMsg->epSet = pCxt->pParseCxt->mgmtEpSet; + pCxt->pCmdMsg->msgType = TDMT_MND_DROP_TOPIC; + pCxt->pCmdMsg->msgLen = tSerializeSMDropTopicReq(NULL, 0, &dropReq); + pCxt->pCmdMsg->pMsg = malloc(pCxt->pCmdMsg->msgLen); + if (NULL == pCxt->pCmdMsg->pMsg) { + return TSDB_CODE_OUT_OF_MEMORY; + } + tSerializeSMDropTopicReq(pCxt->pCmdMsg->pMsg, pCxt->pCmdMsg->msgLen, &dropReq); + + return TSDB_CODE_SUCCESS; +} + static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pNode)) { @@ -1232,6 +1376,9 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_DROP_DATABASE_STMT: code = translateDropDatabase(pCxt, (SDropDatabaseStmt*)pNode); break; + case QUERY_NODE_ALTER_DATABASE_STMT: + code = translateAlterDatabase(pCxt, (SAlterDatabaseStmt*)pNode); + break; case QUERY_NODE_CREATE_TABLE_STMT: code = translateCreateSuperTable(pCxt, (SCreateTableStmt*)pNode); break; @@ -1274,9 +1421,21 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_CREATE_INDEX_STMT: code = translateCreateIndex(pCxt, (SCreateIndexStmt*)pNode); break; + case QUERY_NODE_DROP_INDEX_STMT: + code = translateDropIndex(pCxt, (SDropIndexStmt*)pNode); + break; case QUERY_NODE_CREATE_QNODE_STMT: code = translateCreateQnode(pCxt, (SCreateQnodeStmt*)pNode); break; + case QUERY_NODE_DROP_QNODE_STMT: + code = translateDropQnode(pCxt, (SDropQnodeStmt*)pNode); + break; + case QUERY_NODE_CREATE_TOPIC_STMT: + code = translateCreateTopic(pCxt, (SCreateTopicStmt*)pNode); + break; + case QUERY_NODE_DROP_TOPIC_STMT: + code = translateDropTopic(pCxt, (SDropTopicStmt*)pNode); + break; default: break; } diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 8b46d3600b..18b507c1b0 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -99,22 +99,22 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned char -#define YYNOCODE 218 +#define YYNOCODE 220 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SToken yy5; - bool yy25; - SNodeList* yy40; - ENullOrder yy53; - EOrder yy54; - SNode* yy68; - EJoinType yy92; - EFillMode yy94; - SDataType yy372; - EOperatorType yy416; + SNodeList* yy24; + bool yy97; + SToken yy129; + SDataType yy224; + ENullOrder yy257; + EOperatorType yy260; + EFillMode yy294; + EJoinType yy332; + EOrder yy378; + SNode* yy432; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -129,17 +129,17 @@ typedef union { #define ParseCTX_PARAM #define ParseCTX_FETCH #define ParseCTX_STORE -#define YYNSTATE 313 -#define YYNRULE 248 -#define YYNTOKEN 140 -#define YY_MAX_SHIFT 312 -#define YY_MIN_SHIFTREDUCE 480 -#define YY_MAX_SHIFTREDUCE 727 -#define YY_ERROR_ACTION 728 -#define YY_ACCEPT_ACTION 729 -#define YY_NO_ACTION 730 -#define YY_MIN_REDUCE 731 -#define YY_MAX_REDUCE 978 +#define YYNSTATE 333 +#define YYNRULE 255 +#define YYNTOKEN 141 +#define YY_MAX_SHIFT 332 +#define YY_MIN_SHIFTREDUCE 501 +#define YY_MAX_SHIFTREDUCE 755 +#define YY_ERROR_ACTION 756 +#define YY_ACCEPT_ACTION 757 +#define YY_NO_ACTION 758 +#define YY_MIN_REDUCE 759 +#define YY_MAX_REDUCE 1013 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -206,307 +206,322 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (963) +#define YY_ACTTAB_COUNT (1012) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 152, 236, 277, 871, 844, 252, 252, 167, 186, 784, - /* 10 */ 847, 844, 31, 29, 27, 26, 25, 846, 844, 209, - /* 20 */ 787, 787, 309, 308, 846, 31, 29, 27, 26, 25, - /* 30 */ 746, 236, 151, 871, 106, 826, 39, 824, 251, 844, - /* 40 */ 145, 957, 238, 61, 236, 856, 871, 782, 57, 857, - /* 50 */ 860, 896, 910, 145, 956, 154, 892, 969, 955, 187, - /* 60 */ 164, 610, 213, 832, 239, 166, 930, 10, 826, 907, - /* 70 */ 824, 251, 301, 300, 299, 298, 297, 296, 295, 294, - /* 80 */ 293, 292, 291, 290, 289, 288, 287, 286, 285, 599, - /* 90 */ 31, 29, 27, 26, 25, 24, 109, 23, 159, 228, - /* 100 */ 628, 629, 630, 631, 632, 633, 634, 636, 637, 638, - /* 110 */ 23, 159, 39, 628, 629, 630, 631, 632, 633, 634, - /* 120 */ 636, 637, 638, 783, 542, 275, 274, 273, 546, 272, - /* 130 */ 548, 549, 271, 551, 268, 165, 557, 265, 559, 560, - /* 140 */ 262, 259, 236, 54, 871, 694, 251, 789, 70, 252, - /* 150 */ 844, 65, 249, 238, 779, 224, 856, 208, 214, 56, - /* 160 */ 857, 860, 896, 229, 787, 601, 144, 892, 775, 205, - /* 170 */ 692, 693, 695, 696, 220, 10, 910, 82, 957, 31, - /* 180 */ 29, 27, 26, 25, 215, 210, 223, 170, 871, 64, - /* 190 */ 826, 81, 824, 906, 844, 955, 600, 238, 773, 826, - /* 200 */ 856, 825, 224, 57, 857, 860, 896, 187, 62, 910, - /* 210 */ 154, 892, 76, 723, 724, 27, 26, 25, 102, 903, - /* 220 */ 219, 220, 218, 284, 105, 957, 905, 729, 610, 82, - /* 230 */ 201, 923, 87, 223, 21, 871, 64, 284, 81, 227, - /* 240 */ 75, 844, 955, 635, 238, 104, 639, 856, 490, 86, - /* 250 */ 57, 857, 860, 896, 197, 62, 190, 154, 892, 76, - /* 260 */ 173, 68, 236, 278, 871, 78, 903, 904, 127, 908, - /* 270 */ 844, 817, 40, 238, 252, 84, 856, 250, 924, 57, - /* 280 */ 857, 860, 896, 957, 9, 8, 154, 892, 969, 787, - /* 290 */ 236, 48, 871, 178, 30, 28, 81, 953, 844, 206, - /* 300 */ 955, 238, 780, 590, 856, 833, 239, 57, 857, 860, - /* 310 */ 896, 588, 6, 161, 154, 892, 969, 30, 28, 670, - /* 320 */ 169, 99, 12, 790, 70, 914, 590, 31, 29, 27, - /* 330 */ 26, 25, 789, 70, 588, 774, 161, 189, 490, 236, - /* 340 */ 602, 871, 1, 677, 646, 12, 53, 844, 491, 492, - /* 350 */ 238, 50, 224, 856, 30, 28, 133, 857, 860, 252, - /* 360 */ 599, 253, 122, 590, 252, 1, 226, 172, 915, 665, - /* 370 */ 235, 588, 590, 161, 787, 957, 589, 591, 594, 787, - /* 380 */ 588, 171, 12, 926, 253, 281, 30, 28, 81, 280, - /* 390 */ 669, 665, 955, 789, 70, 590, 82, 9, 8, 589, - /* 400 */ 591, 594, 1, 588, 282, 161, 691, 96, 236, 195, - /* 410 */ 871, 130, 193, 59, 94, 196, 844, 134, 71, 238, - /* 420 */ 91, 253, 856, 279, 221, 58, 857, 860, 896, 625, - /* 430 */ 253, 83, 895, 892, 7, 872, 589, 591, 594, 108, - /* 440 */ 236, 2, 871, 597, 174, 589, 591, 594, 844, 772, - /* 450 */ 231, 238, 188, 253, 856, 38, 640, 58, 857, 860, - /* 460 */ 896, 726, 727, 32, 234, 892, 30, 28, 589, 591, - /* 470 */ 594, 85, 30, 28, 237, 590, 236, 603, 871, 607, - /* 480 */ 191, 590, 150, 588, 844, 161, 32, 238, 82, 588, - /* 490 */ 856, 161, 198, 72, 857, 860, 30, 28, 20, 281, - /* 500 */ 598, 668, 604, 280, 602, 590, 207, 82, 31, 29, - /* 510 */ 27, 26, 25, 588, 7, 161, 232, 199, 282, 927, - /* 520 */ 7, 851, 242, 92, 236, 937, 871, 583, 849, 594, - /* 530 */ 225, 970, 844, 253, 32, 238, 160, 279, 856, 253, - /* 540 */ 114, 138, 857, 860, 1, 204, 936, 112, 589, 591, - /* 550 */ 594, 244, 95, 119, 589, 591, 594, 236, 66, 871, - /* 560 */ 67, 5, 153, 253, 917, 844, 217, 98, 238, 203, - /* 570 */ 74, 856, 4, 63, 58, 857, 860, 896, 589, 591, - /* 580 */ 594, 665, 893, 236, 220, 871, 535, 100, 601, 530, - /* 590 */ 911, 844, 33, 68, 238, 202, 59, 856, 101, 64, - /* 600 */ 138, 857, 860, 236, 155, 871, 563, 972, 233, 567, - /* 610 */ 954, 844, 572, 257, 238, 107, 67, 856, 62, 68, - /* 620 */ 137, 857, 860, 17, 230, 236, 831, 871, 79, 903, - /* 630 */ 904, 878, 908, 844, 245, 47, 238, 49, 240, 856, - /* 640 */ 241, 69, 72, 857, 860, 236, 830, 871, 67, 163, - /* 650 */ 126, 216, 246, 844, 116, 788, 238, 158, 236, 856, - /* 660 */ 871, 255, 138, 857, 860, 247, 844, 128, 123, 238, - /* 670 */ 162, 312, 856, 125, 185, 138, 857, 860, 184, 597, - /* 680 */ 971, 60, 129, 183, 22, 182, 142, 305, 143, 838, - /* 690 */ 124, 236, 749, 871, 31, 29, 27, 26, 25, 844, - /* 700 */ 176, 177, 238, 837, 179, 856, 836, 835, 136, 857, - /* 710 */ 860, 181, 180, 55, 778, 236, 120, 871, 777, 748, - /* 720 */ 745, 740, 735, 844, 776, 501, 238, 747, 739, 856, - /* 730 */ 738, 734, 139, 857, 860, 236, 733, 871, 192, 732, - /* 740 */ 828, 175, 248, 844, 200, 41, 238, 194, 88, 856, - /* 750 */ 89, 90, 131, 857, 860, 236, 3, 871, 32, 14, - /* 760 */ 93, 36, 690, 844, 73, 97, 238, 211, 42, 856, - /* 770 */ 212, 684, 140, 857, 860, 236, 683, 871, 849, 15, - /* 780 */ 19, 34, 11, 844, 662, 43, 238, 44, 236, 856, - /* 790 */ 871, 712, 132, 857, 860, 661, 844, 711, 156, 238, - /* 800 */ 35, 716, 856, 717, 103, 141, 857, 860, 80, 715, - /* 810 */ 157, 16, 236, 8, 871, 110, 608, 13, 18, 113, - /* 820 */ 844, 111, 688, 238, 115, 236, 856, 871, 827, 868, - /* 830 */ 857, 860, 117, 844, 626, 45, 238, 243, 236, 856, - /* 840 */ 871, 118, 867, 857, 860, 46, 844, 50, 592, 238, - /* 850 */ 37, 848, 856, 121, 220, 866, 857, 860, 254, 256, - /* 860 */ 236, 564, 871, 168, 258, 260, 561, 261, 844, 64, - /* 870 */ 558, 238, 263, 236, 856, 871, 264, 148, 857, 860, - /* 880 */ 552, 844, 266, 267, 238, 550, 269, 856, 62, 270, - /* 890 */ 147, 857, 860, 236, 556, 871, 555, 222, 77, 903, - /* 900 */ 904, 844, 908, 554, 238, 541, 553, 856, 276, 51, - /* 910 */ 149, 857, 860, 236, 52, 871, 571, 570, 569, 499, - /* 920 */ 283, 844, 520, 519, 238, 518, 744, 856, 517, 516, - /* 930 */ 146, 857, 860, 236, 515, 871, 514, 513, 512, 511, - /* 940 */ 510, 844, 509, 508, 238, 303, 507, 856, 506, 505, - /* 950 */ 135, 857, 860, 504, 302, 304, 737, 306, 307, 736, - /* 960 */ 731, 310, 311, + /* 0 */ 163, 856, 240, 855, 272, 162, 272, 200, 856, 814, + /* 10 */ 854, 878, 31, 29, 27, 26, 25, 65, 880, 817, + /* 20 */ 178, 817, 256, 176, 906, 31, 29, 27, 26, 25, + /* 30 */ 779, 878, 40, 705, 55, 819, 71, 63, 880, 62, + /* 40 */ 155, 229, 66, 812, 243, 809, 906, 79, 938, 939, + /* 50 */ 626, 943, 878, 155, 175, 258, 511, 863, 259, 891, + /* 60 */ 511, 638, 58, 892, 895, 931, 512, 513, 208, 165, + /* 70 */ 927, 77, 321, 320, 319, 318, 317, 316, 315, 314, + /* 80 */ 313, 312, 311, 310, 309, 308, 307, 306, 305, 775, + /* 90 */ 959, 27, 26, 25, 31, 29, 27, 26, 25, 23, + /* 100 */ 170, 271, 656, 657, 658, 659, 660, 661, 662, 664, + /* 110 */ 665, 666, 23, 170, 271, 656, 657, 658, 659, 660, + /* 120 */ 661, 662, 664, 665, 666, 31, 29, 27, 26, 25, + /* 130 */ 10, 321, 320, 319, 318, 317, 316, 315, 314, 313, + /* 140 */ 312, 311, 310, 309, 308, 307, 306, 305, 565, 295, + /* 150 */ 294, 293, 569, 292, 571, 572, 291, 574, 288, 804, + /* 160 */ 580, 285, 582, 583, 282, 279, 24, 117, 256, 196, + /* 170 */ 906, 992, 626, 195, 624, 256, 177, 906, 194, 856, + /* 180 */ 193, 854, 83, 878, 991, 83, 258, 233, 990, 244, + /* 190 */ 891, 180, 271, 57, 892, 895, 931, 54, 182, 190, + /* 200 */ 154, 927, 51, 819, 71, 272, 192, 191, 269, 301, + /* 210 */ 819, 71, 992, 300, 805, 243, 624, 906, 751, 752, + /* 220 */ 817, 10, 234, 878, 298, 82, 258, 945, 302, 990, + /* 230 */ 891, 757, 627, 58, 892, 895, 931, 256, 186, 906, + /* 240 */ 165, 927, 77, 228, 942, 878, 201, 299, 258, 628, + /* 250 */ 30, 28, 891, 201, 113, 58, 892, 895, 931, 617, + /* 260 */ 221, 958, 165, 927, 1004, 184, 256, 615, 906, 172, + /* 270 */ 629, 235, 230, 965, 878, 304, 878, 258, 12, 272, + /* 280 */ 297, 891, 270, 881, 58, 892, 895, 931, 992, 9, + /* 290 */ 8, 165, 927, 1004, 817, 256, 272, 906, 1, 130, + /* 300 */ 83, 82, 988, 878, 181, 990, 258, 856, 40, 854, + /* 310 */ 891, 817, 112, 58, 892, 895, 931, 273, 21, 813, + /* 320 */ 165, 927, 1004, 30, 28, 698, 272, 663, 189, 183, + /* 330 */ 667, 949, 617, 99, 616, 618, 621, 114, 30, 28, + /* 340 */ 615, 817, 172, 329, 328, 803, 247, 617, 256, 674, + /* 350 */ 906, 12, 722, 83, 140, 615, 878, 172, 161, 258, + /* 360 */ 141, 72, 244, 891, 30, 28, 144, 892, 895, 49, + /* 370 */ 945, 1, 945, 617, 84, 225, 720, 721, 723, 724, + /* 380 */ 810, 615, 226, 172, 304, 992, 7, 941, 6, 940, + /* 390 */ 273, 697, 12, 864, 259, 256, 248, 906, 82, 820, + /* 400 */ 71, 136, 990, 878, 847, 273, 258, 616, 618, 621, + /* 410 */ 891, 240, 1, 59, 892, 895, 931, 256, 107, 906, + /* 420 */ 930, 927, 616, 618, 621, 878, 65, 217, 258, 950, + /* 430 */ 693, 273, 891, 251, 69, 59, 892, 895, 931, 207, + /* 440 */ 244, 83, 254, 927, 213, 961, 63, 211, 616, 618, + /* 450 */ 621, 83, 94, 30, 28, 257, 110, 938, 239, 241, + /* 460 */ 238, 249, 617, 992, 719, 617, 30, 28, 693, 93, + /* 470 */ 615, 60, 172, 615, 246, 617, 82, 104, 907, 256, + /* 480 */ 990, 906, 668, 615, 102, 172, 116, 878, 255, 32, + /* 490 */ 258, 2, 754, 755, 891, 635, 624, 73, 892, 895, + /* 500 */ 252, 7, 32, 696, 607, 9, 8, 30, 28, 185, + /* 510 */ 256, 32, 906, 632, 7, 885, 617, 625, 878, 85, + /* 520 */ 273, 258, 883, 273, 615, 891, 172, 631, 59, 892, + /* 530 */ 895, 931, 214, 273, 245, 1005, 928, 616, 618, 621, + /* 540 */ 616, 618, 621, 197, 198, 256, 199, 906, 39, 653, + /* 550 */ 616, 618, 621, 878, 202, 1, 258, 171, 90, 122, + /* 560 */ 891, 215, 209, 148, 892, 895, 120, 256, 630, 906, + /* 570 */ 264, 134, 160, 127, 273, 878, 558, 67, 258, 222, + /* 580 */ 68, 216, 891, 69, 992, 148, 892, 895, 256, 218, + /* 590 */ 906, 616, 618, 621, 629, 553, 878, 82, 95, 258, + /* 600 */ 962, 990, 60, 891, 586, 133, 147, 892, 895, 590, + /* 610 */ 256, 277, 906, 61, 802, 227, 68, 219, 878, 325, + /* 620 */ 972, 258, 132, 262, 256, 891, 906, 100, 73, 892, + /* 630 */ 895, 621, 878, 224, 971, 258, 169, 236, 256, 891, + /* 640 */ 906, 103, 148, 892, 895, 56, 878, 164, 128, 258, + /* 650 */ 173, 5, 256, 891, 906, 952, 148, 892, 895, 237, + /* 660 */ 878, 75, 106, 258, 301, 223, 1006, 891, 300, 108, + /* 670 */ 146, 892, 895, 240, 268, 4, 220, 64, 256, 96, + /* 680 */ 906, 693, 628, 302, 595, 946, 878, 33, 65, 258, + /* 690 */ 253, 69, 256, 891, 906, 109, 149, 892, 895, 70, + /* 700 */ 878, 989, 299, 258, 1007, 250, 68, 891, 63, 166, + /* 710 */ 142, 892, 895, 256, 17, 906, 115, 242, 78, 938, + /* 720 */ 939, 878, 943, 913, 258, 862, 260, 256, 891, 906, + /* 730 */ 261, 150, 892, 895, 861, 878, 265, 174, 258, 266, + /* 740 */ 124, 256, 891, 906, 267, 143, 892, 895, 48, 878, + /* 750 */ 135, 818, 258, 50, 275, 256, 891, 906, 137, 151, + /* 760 */ 892, 895, 131, 878, 872, 138, 258, 332, 152, 256, + /* 770 */ 891, 906, 153, 903, 892, 895, 139, 878, 778, 871, + /* 780 */ 258, 870, 187, 256, 891, 906, 188, 902, 892, 895, + /* 790 */ 869, 878, 808, 807, 258, 777, 774, 256, 891, 906, + /* 800 */ 768, 901, 892, 895, 763, 878, 868, 859, 258, 87, + /* 810 */ 806, 256, 891, 906, 524, 158, 892, 895, 776, 878, + /* 820 */ 773, 205, 258, 203, 204, 256, 891, 906, 767, 157, + /* 830 */ 892, 895, 766, 878, 762, 761, 258, 210, 760, 867, + /* 840 */ 891, 866, 212, 159, 892, 895, 36, 858, 256, 42, + /* 850 */ 906, 97, 98, 3, 240, 14, 878, 15, 74, 258, + /* 860 */ 101, 105, 256, 891, 906, 43, 156, 892, 895, 65, + /* 870 */ 878, 32, 231, 258, 718, 712, 92, 891, 34, 37, + /* 880 */ 145, 892, 895, 711, 76, 44, 11, 232, 690, 63, + /* 890 */ 206, 883, 689, 91, 19, 45, 20, 111, 745, 80, + /* 900 */ 938, 939, 740, 943, 35, 739, 31, 29, 27, 26, + /* 910 */ 25, 22, 81, 167, 16, 744, 41, 743, 168, 89, + /* 920 */ 8, 31, 29, 27, 26, 25, 118, 636, 13, 31, + /* 930 */ 29, 27, 26, 25, 654, 18, 263, 857, 119, 716, + /* 940 */ 121, 123, 46, 126, 125, 47, 88, 619, 51, 276, + /* 950 */ 86, 179, 38, 280, 882, 579, 587, 129, 278, 274, + /* 960 */ 584, 281, 283, 581, 284, 286, 575, 287, 289, 573, + /* 970 */ 564, 290, 52, 53, 594, 296, 593, 578, 638, 592, + /* 980 */ 303, 577, 522, 543, 576, 542, 541, 536, 540, 539, + /* 990 */ 538, 537, 535, 534, 533, 772, 532, 531, 530, 529, + /* 1000 */ 528, 527, 322, 323, 765, 764, 326, 327, 324, 759, + /* 1010 */ 330, 331, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 157, 160, 163, 162, 168, 145, 145, 157, 148, 148, - /* 10 */ 174, 168, 12, 13, 14, 15, 16, 174, 168, 178, - /* 20 */ 160, 160, 142, 143, 174, 12, 13, 14, 15, 16, - /* 30 */ 0, 160, 159, 162, 216, 162, 147, 164, 31, 168, - /* 40 */ 40, 196, 171, 154, 160, 174, 162, 158, 177, 178, - /* 50 */ 179, 180, 175, 40, 209, 184, 185, 186, 213, 39, - /* 60 */ 167, 61, 178, 170, 171, 159, 195, 60, 162, 192, - /* 70 */ 164, 31, 42, 43, 44, 45, 46, 47, 48, 49, - /* 80 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 31, - /* 90 */ 12, 13, 14, 15, 16, 181, 182, 97, 98, 68, - /* 100 */ 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, - /* 110 */ 97, 98, 147, 100, 101, 102, 103, 104, 105, 106, - /* 120 */ 107, 108, 109, 158, 70, 71, 72, 73, 74, 75, - /* 130 */ 76, 77, 78, 79, 80, 149, 82, 83, 84, 85, - /* 140 */ 86, 87, 160, 144, 162, 99, 31, 161, 162, 145, - /* 150 */ 168, 152, 148, 171, 155, 173, 174, 92, 31, 177, - /* 160 */ 178, 179, 180, 132, 160, 31, 184, 185, 0, 123, - /* 170 */ 124, 125, 126, 127, 145, 60, 175, 114, 196, 12, - /* 180 */ 13, 14, 15, 16, 119, 120, 160, 159, 162, 160, - /* 190 */ 162, 209, 164, 192, 168, 213, 31, 171, 0, 162, - /* 200 */ 174, 164, 173, 177, 178, 179, 180, 39, 179, 175, - /* 210 */ 184, 185, 186, 135, 136, 14, 15, 16, 189, 190, - /* 220 */ 191, 145, 193, 39, 198, 196, 192, 140, 61, 114, - /* 230 */ 204, 205, 19, 160, 97, 162, 160, 39, 209, 3, - /* 240 */ 27, 168, 213, 106, 171, 111, 109, 174, 21, 36, - /* 250 */ 177, 178, 179, 180, 61, 179, 29, 184, 185, 186, - /* 260 */ 173, 68, 160, 66, 162, 189, 190, 191, 150, 193, - /* 270 */ 168, 153, 59, 171, 145, 62, 174, 148, 205, 177, - /* 280 */ 178, 179, 180, 196, 1, 2, 184, 185, 186, 160, - /* 290 */ 160, 144, 162, 145, 12, 13, 209, 195, 168, 207, - /* 300 */ 213, 171, 155, 21, 174, 170, 171, 177, 178, 179, - /* 310 */ 180, 29, 34, 31, 184, 185, 186, 12, 13, 14, - /* 320 */ 149, 201, 40, 161, 162, 195, 21, 12, 13, 14, - /* 330 */ 15, 16, 161, 162, 29, 0, 31, 142, 21, 160, - /* 340 */ 31, 162, 60, 14, 61, 40, 60, 168, 31, 32, - /* 350 */ 171, 65, 173, 174, 12, 13, 177, 178, 179, 145, - /* 360 */ 31, 79, 148, 21, 145, 60, 130, 148, 112, 113, - /* 370 */ 40, 29, 21, 31, 160, 196, 94, 95, 96, 160, - /* 380 */ 29, 149, 40, 176, 79, 50, 12, 13, 209, 54, - /* 390 */ 4, 113, 213, 161, 162, 21, 114, 1, 2, 94, - /* 400 */ 95, 96, 60, 29, 69, 31, 61, 61, 160, 20, - /* 410 */ 162, 18, 23, 68, 68, 22, 168, 24, 25, 171, - /* 420 */ 111, 79, 174, 88, 194, 177, 178, 179, 180, 99, - /* 430 */ 79, 38, 184, 185, 60, 162, 94, 95, 96, 210, - /* 440 */ 160, 197, 162, 31, 145, 94, 95, 96, 168, 0, - /* 450 */ 68, 171, 145, 79, 174, 147, 61, 177, 178, 179, - /* 460 */ 180, 138, 139, 68, 184, 185, 12, 13, 94, 95, - /* 470 */ 96, 147, 12, 13, 14, 21, 160, 31, 162, 61, - /* 480 */ 141, 21, 141, 29, 168, 31, 68, 171, 114, 29, - /* 490 */ 174, 31, 160, 177, 178, 179, 12, 13, 2, 50, - /* 500 */ 31, 115, 31, 54, 31, 21, 122, 114, 12, 13, - /* 510 */ 14, 15, 16, 29, 60, 31, 134, 165, 69, 176, - /* 520 */ 60, 60, 121, 169, 160, 206, 162, 61, 67, 96, - /* 530 */ 214, 215, 168, 79, 68, 171, 172, 88, 174, 79, - /* 540 */ 61, 177, 178, 179, 60, 168, 206, 68, 94, 95, - /* 550 */ 96, 61, 169, 61, 94, 95, 96, 160, 68, 162, - /* 560 */ 68, 129, 168, 79, 203, 168, 128, 202, 171, 117, - /* 570 */ 200, 174, 116, 160, 177, 178, 179, 180, 94, 95, - /* 580 */ 96, 113, 185, 160, 145, 162, 61, 199, 31, 61, - /* 590 */ 175, 168, 110, 68, 171, 172, 68, 174, 187, 160, - /* 600 */ 177, 178, 179, 160, 137, 162, 61, 217, 133, 61, - /* 610 */ 212, 168, 61, 68, 171, 211, 68, 174, 179, 68, - /* 620 */ 177, 178, 179, 60, 131, 160, 169, 162, 189, 190, - /* 630 */ 191, 183, 193, 168, 91, 144, 171, 60, 168, 174, - /* 640 */ 168, 61, 177, 178, 179, 160, 169, 162, 68, 168, - /* 650 */ 153, 208, 166, 168, 160, 160, 171, 172, 160, 174, - /* 660 */ 162, 156, 177, 178, 179, 165, 168, 145, 144, 171, - /* 670 */ 172, 141, 174, 19, 26, 177, 178, 179, 30, 31, - /* 680 */ 215, 27, 146, 35, 2, 37, 151, 33, 151, 0, - /* 690 */ 36, 160, 0, 162, 12, 13, 14, 15, 16, 168, - /* 700 */ 56, 67, 171, 0, 56, 174, 0, 0, 177, 178, - /* 710 */ 179, 63, 64, 59, 0, 160, 62, 162, 0, 0, - /* 720 */ 0, 0, 0, 168, 0, 41, 171, 0, 0, 174, - /* 730 */ 0, 0, 177, 178, 179, 160, 0, 162, 21, 0, - /* 740 */ 0, 93, 88, 168, 90, 60, 171, 21, 19, 174, - /* 750 */ 34, 89, 177, 178, 179, 160, 68, 162, 68, 118, - /* 760 */ 61, 68, 61, 168, 60, 60, 171, 29, 60, 174, - /* 770 */ 68, 61, 177, 178, 179, 160, 61, 162, 67, 118, - /* 780 */ 68, 112, 118, 168, 61, 60, 171, 4, 160, 174, - /* 790 */ 162, 29, 177, 178, 179, 61, 168, 29, 29, 171, - /* 800 */ 68, 29, 174, 61, 67, 177, 178, 179, 67, 29, - /* 810 */ 29, 68, 160, 2, 162, 67, 61, 60, 60, 60, - /* 820 */ 168, 61, 61, 171, 60, 160, 174, 162, 0, 177, - /* 830 */ 178, 179, 34, 168, 99, 60, 171, 92, 160, 174, - /* 840 */ 162, 89, 177, 178, 179, 60, 168, 65, 21, 171, - /* 850 */ 60, 67, 174, 67, 145, 177, 178, 179, 66, 29, - /* 860 */ 160, 61, 162, 29, 60, 29, 61, 60, 168, 160, - /* 870 */ 61, 171, 29, 160, 174, 162, 60, 177, 178, 179, - /* 880 */ 61, 168, 29, 60, 171, 61, 29, 174, 179, 60, - /* 890 */ 177, 178, 179, 160, 81, 162, 81, 188, 189, 190, - /* 900 */ 191, 168, 193, 81, 171, 21, 81, 174, 69, 60, - /* 910 */ 177, 178, 179, 160, 60, 162, 29, 29, 21, 41, - /* 920 */ 40, 168, 29, 29, 171, 29, 0, 174, 29, 29, - /* 930 */ 177, 178, 179, 160, 29, 162, 29, 21, 29, 29, - /* 940 */ 29, 168, 29, 29, 171, 27, 29, 174, 29, 29, - /* 950 */ 177, 178, 179, 29, 29, 34, 0, 29, 28, 0, - /* 960 */ 0, 21, 20, 218, 218, 218, 218, 218, 218, 218, - /* 970 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 980 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 990 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1000 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1010 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1020 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1030 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1040 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1050 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1060 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1070 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1080 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1090 */ 218, 218, 218, 218, 218, 218, 218, 218, 218, 218, - /* 1100 */ 218, 218, 218, + /* 0 */ 158, 163, 146, 165, 146, 160, 146, 149, 163, 149, + /* 10 */ 165, 169, 12, 13, 14, 15, 16, 161, 176, 161, + /* 20 */ 158, 161, 161, 150, 163, 12, 13, 14, 15, 16, + /* 30 */ 0, 169, 148, 14, 145, 162, 163, 181, 176, 155, + /* 40 */ 40, 180, 153, 159, 161, 156, 163, 191, 192, 193, + /* 50 */ 31, 195, 169, 40, 168, 172, 21, 171, 172, 176, + /* 60 */ 21, 61, 179, 180, 181, 182, 31, 32, 29, 186, + /* 70 */ 187, 188, 42, 43, 44, 45, 46, 47, 48, 49, + /* 80 */ 50, 51, 52, 53, 54, 55, 56, 57, 58, 0, + /* 90 */ 207, 14, 15, 16, 12, 13, 14, 15, 16, 99, + /* 100 */ 100, 31, 102, 103, 104, 105, 106, 107, 108, 109, + /* 110 */ 110, 111, 99, 100, 31, 102, 103, 104, 105, 106, + /* 120 */ 107, 108, 109, 110, 111, 12, 13, 14, 15, 16, + /* 130 */ 60, 42, 43, 44, 45, 46, 47, 48, 49, 50, + /* 140 */ 51, 52, 53, 54, 55, 56, 57, 58, 70, 71, + /* 150 */ 72, 73, 74, 75, 76, 77, 78, 79, 80, 0, + /* 160 */ 82, 83, 84, 85, 86, 87, 183, 184, 161, 26, + /* 170 */ 163, 198, 31, 30, 31, 161, 160, 163, 35, 163, + /* 180 */ 37, 165, 115, 169, 211, 115, 172, 180, 215, 175, + /* 190 */ 176, 150, 31, 179, 180, 181, 182, 60, 150, 56, + /* 200 */ 186, 187, 65, 162, 163, 146, 63, 64, 149, 50, + /* 210 */ 162, 163, 198, 54, 0, 161, 31, 163, 136, 137, + /* 220 */ 161, 60, 31, 169, 66, 211, 172, 177, 69, 215, + /* 230 */ 176, 141, 31, 179, 180, 181, 182, 161, 95, 163, + /* 240 */ 186, 187, 188, 92, 194, 169, 39, 88, 172, 31, + /* 250 */ 12, 13, 176, 39, 200, 179, 180, 181, 182, 21, + /* 260 */ 206, 207, 186, 187, 188, 175, 161, 29, 163, 31, + /* 270 */ 31, 120, 121, 197, 169, 39, 169, 172, 40, 146, + /* 280 */ 164, 176, 149, 176, 179, 180, 181, 182, 198, 1, + /* 290 */ 2, 186, 187, 188, 161, 161, 146, 163, 60, 149, + /* 300 */ 115, 211, 197, 169, 160, 215, 172, 163, 148, 165, + /* 310 */ 176, 161, 94, 179, 180, 181, 182, 79, 99, 159, + /* 320 */ 186, 187, 188, 12, 13, 14, 146, 108, 146, 149, + /* 330 */ 111, 197, 21, 94, 96, 97, 98, 218, 12, 13, + /* 340 */ 29, 161, 31, 143, 144, 0, 3, 21, 161, 61, + /* 350 */ 163, 40, 101, 115, 18, 29, 169, 31, 22, 172, + /* 360 */ 24, 25, 175, 176, 12, 13, 179, 180, 181, 145, + /* 370 */ 177, 60, 177, 21, 38, 124, 125, 126, 127, 128, + /* 380 */ 156, 29, 209, 31, 39, 198, 60, 194, 34, 194, + /* 390 */ 79, 4, 40, 171, 172, 161, 68, 163, 211, 162, + /* 400 */ 163, 151, 215, 169, 154, 79, 172, 96, 97, 98, + /* 410 */ 176, 146, 60, 179, 180, 181, 182, 161, 203, 163, + /* 420 */ 186, 187, 96, 97, 98, 169, 161, 61, 172, 113, + /* 430 */ 114, 79, 176, 68, 68, 179, 180, 181, 182, 143, + /* 440 */ 175, 115, 186, 187, 20, 178, 181, 23, 96, 97, + /* 450 */ 98, 115, 19, 12, 13, 14, 191, 192, 193, 196, + /* 460 */ 195, 133, 21, 198, 61, 21, 12, 13, 114, 36, + /* 470 */ 29, 68, 31, 29, 131, 21, 211, 61, 163, 161, + /* 480 */ 215, 163, 61, 29, 68, 31, 212, 169, 40, 68, + /* 490 */ 172, 199, 139, 140, 176, 61, 31, 179, 180, 181, + /* 500 */ 135, 60, 68, 116, 61, 1, 2, 12, 13, 146, + /* 510 */ 161, 68, 163, 31, 60, 60, 21, 31, 169, 148, + /* 520 */ 79, 172, 67, 79, 29, 176, 31, 31, 179, 180, + /* 530 */ 181, 182, 146, 79, 216, 217, 187, 96, 97, 98, + /* 540 */ 96, 97, 98, 174, 161, 161, 166, 163, 148, 101, + /* 550 */ 96, 97, 98, 169, 146, 60, 172, 173, 148, 61, + /* 560 */ 176, 175, 142, 179, 180, 181, 68, 161, 31, 163, + /* 570 */ 61, 146, 142, 61, 79, 169, 61, 68, 172, 173, + /* 580 */ 68, 174, 176, 68, 198, 179, 180, 181, 161, 161, + /* 590 */ 163, 96, 97, 98, 31, 61, 169, 211, 145, 172, + /* 600 */ 178, 215, 68, 176, 61, 19, 179, 180, 181, 61, + /* 610 */ 161, 68, 163, 27, 0, 123, 68, 166, 169, 33, + /* 620 */ 208, 172, 36, 122, 161, 176, 163, 170, 179, 180, + /* 630 */ 181, 98, 169, 169, 208, 172, 173, 210, 161, 176, + /* 640 */ 163, 170, 179, 180, 181, 59, 169, 169, 62, 172, + /* 650 */ 173, 130, 161, 176, 163, 205, 179, 180, 181, 129, + /* 660 */ 169, 202, 204, 172, 50, 118, 217, 176, 54, 201, + /* 670 */ 179, 180, 181, 146, 88, 117, 90, 161, 161, 93, + /* 680 */ 163, 114, 31, 69, 61, 177, 169, 112, 161, 172, + /* 690 */ 134, 68, 161, 176, 163, 189, 179, 180, 181, 61, + /* 700 */ 169, 214, 88, 172, 219, 132, 68, 176, 181, 138, + /* 710 */ 179, 180, 181, 161, 60, 163, 213, 190, 191, 192, + /* 720 */ 193, 169, 195, 185, 172, 170, 169, 161, 176, 163, + /* 730 */ 169, 179, 180, 181, 170, 169, 91, 169, 172, 167, + /* 740 */ 161, 161, 176, 163, 166, 179, 180, 181, 145, 169, + /* 750 */ 154, 161, 172, 60, 157, 161, 176, 163, 146, 179, + /* 760 */ 180, 181, 145, 169, 0, 147, 172, 142, 152, 161, + /* 770 */ 176, 163, 152, 179, 180, 181, 147, 169, 0, 0, + /* 780 */ 172, 0, 56, 161, 176, 163, 67, 179, 180, 181, + /* 790 */ 0, 169, 0, 0, 172, 0, 0, 161, 176, 163, + /* 800 */ 0, 179, 180, 181, 0, 169, 0, 0, 172, 34, + /* 810 */ 0, 161, 176, 163, 41, 179, 180, 181, 0, 169, + /* 820 */ 0, 34, 172, 29, 27, 161, 176, 163, 0, 179, + /* 830 */ 180, 181, 0, 169, 0, 0, 172, 21, 0, 0, + /* 840 */ 176, 0, 21, 179, 180, 181, 94, 0, 161, 60, + /* 850 */ 163, 34, 89, 68, 146, 119, 169, 119, 60, 172, + /* 860 */ 61, 60, 161, 176, 163, 60, 179, 180, 181, 161, + /* 870 */ 169, 68, 29, 172, 61, 61, 19, 176, 113, 68, + /* 880 */ 179, 180, 181, 61, 27, 60, 119, 68, 61, 181, + /* 890 */ 33, 67, 61, 36, 68, 4, 2, 67, 61, 191, + /* 900 */ 192, 193, 29, 195, 68, 29, 12, 13, 14, 15, + /* 910 */ 16, 2, 67, 29, 68, 29, 59, 29, 29, 62, + /* 920 */ 2, 12, 13, 14, 15, 16, 67, 61, 60, 12, + /* 930 */ 13, 14, 15, 16, 101, 60, 92, 0, 61, 61, + /* 940 */ 60, 60, 60, 89, 34, 60, 89, 21, 65, 29, + /* 950 */ 93, 29, 60, 29, 67, 81, 61, 67, 60, 66, + /* 960 */ 61, 60, 29, 61, 60, 29, 61, 60, 29, 61, + /* 970 */ 21, 60, 60, 60, 29, 69, 29, 81, 61, 21, + /* 980 */ 40, 81, 41, 29, 81, 29, 29, 21, 29, 29, + /* 990 */ 29, 29, 29, 29, 29, 0, 29, 29, 29, 29, + /* 1000 */ 29, 29, 29, 27, 0, 0, 29, 28, 34, 0, + /* 1010 */ 21, 20, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1020 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1030 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1040 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1050 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1060 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1070 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1080 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1090 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1100 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1110 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1120 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1130 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1140 */ 220, 220, 220, 220, 220, 220, 220, 220, 220, 220, + /* 1150 */ 220, 220, 220, }; -#define YY_SHIFT_COUNT (312) +#define YY_SHIFT_COUNT (332) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (960) +#define YY_SHIFT_MAX (1009) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 393, 282, 305, 342, 342, 342, 342, 374, 342, 342, - /* 10 */ 115, 454, 484, 460, 454, 454, 454, 454, 454, 454, + /* 0 */ 336, 238, 311, 352, 352, 352, 352, 326, 352, 352, + /* 10 */ 70, 454, 495, 441, 454, 454, 454, 454, 454, 454, /* 20 */ 454, 454, 454, 454, 454, 454, 454, 454, 454, 454, - /* 30 */ 454, 454, 454, 7, 7, 7, 351, 351, 40, 40, - /* 40 */ 20, 58, 127, 127, 63, 165, 58, 40, 40, 58, - /* 50 */ 40, 58, 58, 58, 40, 184, 0, 13, 13, 351, - /* 60 */ 317, 168, 134, 134, 134, 198, 165, 58, 58, 197, - /* 70 */ 54, 648, 78, 46, 65, 227, 309, 256, 278, 256, - /* 80 */ 329, 236, 386, 412, 20, 412, 20, 446, 446, 469, - /* 90 */ 471, 473, 384, 401, 433, 384, 401, 433, 432, 438, - /* 100 */ 452, 456, 468, 469, 557, 482, 467, 475, 493, 563, - /* 110 */ 58, 401, 433, 433, 401, 433, 543, 469, 471, 197, - /* 120 */ 184, 469, 577, 412, 184, 446, 963, 963, 963, 30, - /* 130 */ 654, 496, 682, 167, 213, 315, 315, 315, 315, 315, - /* 140 */ 315, 315, 335, 449, 283, 137, 201, 201, 201, 201, - /* 150 */ 389, 193, 345, 346, 396, 323, 31, 382, 395, 330, - /* 160 */ 418, 461, 466, 479, 490, 492, 525, 528, 545, 548, - /* 170 */ 551, 580, 286, 689, 692, 703, 706, 644, 634, 707, - /* 180 */ 714, 718, 719, 720, 721, 722, 724, 684, 727, 728, - /* 190 */ 730, 731, 736, 717, 739, 726, 729, 740, 685, 716, - /* 200 */ 662, 688, 690, 641, 699, 693, 701, 704, 705, 710, - /* 210 */ 708, 715, 738, 702, 711, 725, 712, 661, 723, 734, - /* 220 */ 737, 669, 732, 741, 742, 743, 664, 783, 762, 768, - /* 230 */ 769, 772, 780, 781, 811, 735, 748, 755, 757, 758, - /* 240 */ 760, 761, 759, 764, 745, 775, 828, 798, 752, 785, - /* 250 */ 782, 784, 786, 827, 790, 792, 800, 830, 834, 804, - /* 260 */ 805, 836, 807, 809, 843, 816, 819, 853, 823, 824, - /* 270 */ 857, 829, 813, 815, 822, 825, 884, 839, 849, 854, - /* 280 */ 887, 888, 897, 878, 880, 893, 894, 896, 899, 900, - /* 290 */ 905, 907, 916, 909, 910, 911, 913, 914, 917, 919, - /* 300 */ 920, 924, 926, 925, 918, 921, 956, 928, 930, 959, - /* 310 */ 960, 940, 942, + /* 30 */ 454, 454, 454, 161, 161, 161, 185, 444, 444, 83, + /* 40 */ 83, 207, 141, 191, 191, 67, 201, 141, 83, 83, + /* 50 */ 141, 83, 141, 141, 141, 83, 236, 0, 13, 13, + /* 60 */ 444, 35, 214, 218, 218, 218, 345, 201, 141, 141, + /* 70 */ 158, 78, 143, 82, 251, 151, 39, 239, 316, 354, + /* 80 */ 316, 19, 343, 387, 465, 482, 207, 486, 496, 207, + /* 90 */ 465, 207, 537, 465, 537, 482, 236, 486, 496, 563, + /* 100 */ 492, 501, 533, 492, 501, 533, 521, 530, 547, 558, + /* 110 */ 567, 486, 651, 575, 571, 556, 573, 654, 141, 501, + /* 120 */ 533, 533, 501, 533, 645, 486, 496, 158, 236, 486, + /* 130 */ 693, 465, 236, 537, 1012, 1012, 1012, 1012, 30, 89, + /* 140 */ 586, 857, 894, 909, 917, 113, 113, 113, 113, 113, + /* 150 */ 113, 113, 159, 614, 288, 219, 77, 77, 77, 77, + /* 160 */ 424, 433, 366, 403, 416, 504, 353, 328, 365, 421, + /* 170 */ 448, 434, 455, 443, 498, 509, 512, 515, 534, 543, + /* 180 */ 548, 623, 638, 137, 764, 778, 779, 781, 726, 719, + /* 190 */ 790, 792, 793, 795, 796, 800, 804, 806, 807, 775, + /* 200 */ 810, 773, 818, 820, 794, 797, 787, 828, 832, 834, + /* 210 */ 835, 816, 838, 821, 839, 841, 752, 847, 789, 817, + /* 220 */ 763, 785, 803, 736, 799, 811, 813, 798, 801, 814, + /* 230 */ 805, 822, 843, 819, 824, 825, 826, 738, 827, 831, + /* 240 */ 830, 765, 836, 845, 837, 846, 767, 891, 873, 876, + /* 250 */ 884, 886, 888, 889, 918, 833, 859, 866, 868, 875, + /* 260 */ 877, 878, 880, 881, 844, 882, 937, 910, 854, 885, + /* 270 */ 883, 887, 890, 926, 892, 893, 895, 920, 922, 898, + /* 280 */ 899, 924, 901, 902, 933, 904, 905, 936, 907, 908, + /* 290 */ 939, 911, 874, 896, 900, 903, 949, 906, 912, 913, + /* 300 */ 945, 947, 958, 941, 940, 954, 956, 957, 959, 960, + /* 310 */ 961, 962, 966, 963, 964, 965, 967, 968, 969, 970, + /* 320 */ 971, 972, 995, 973, 976, 974, 1004, 977, 979, 1005, + /* 330 */ 1009, 989, 991, }; -#define YY_REDUCE_COUNT (128) -#define YY_REDUCE_MIN (-182) -#define YY_REDUCE_MAX (773) +#define YY_REDUCE_COUNT (137) +#define YY_REDUCE_MIN (-162) +#define YY_REDUCE_MAX (708) static const short yy_reduce_ofst[] = { - /* 0 */ 87, -18, 26, 73, -129, 102, 130, 179, 248, 280, - /* 10 */ 29, 316, 397, 364, 423, 443, 465, 485, 498, 531, - /* 20 */ 555, 575, 595, 615, 628, 652, 665, 678, 700, 713, - /* 30 */ 733, 753, 773, 709, 76, 439, -157, -150, -140, -139, - /* 40 */ -111, -127, -159, -116, -155, -107, -14, 4, 129, -94, - /* 50 */ 214, 171, 28, 232, 219, -1, -86, -86, -86, -164, - /* 60 */ -120, -35, -123, 1, 34, 147, 135, 162, 37, 118, - /* 70 */ -161, 148, -182, 92, 120, 195, 207, 230, 230, 230, - /* 80 */ 273, 229, 244, 299, 308, 307, 324, 339, 341, 332, - /* 90 */ 352, 343, 319, 354, 377, 340, 383, 394, 361, 365, - /* 100 */ 370, 388, 230, 413, 415, 411, 390, 398, 404, 448, - /* 110 */ 273, 457, 470, 472, 477, 481, 486, 494, 500, 497, - /* 120 */ 491, 495, 505, 522, 524, 530, 535, 537, 536, + /* 0 */ 90, 14, 54, -117, 76, 105, 134, 187, 234, 256, + /* 10 */ 265, 318, 349, 384, 406, 427, 449, 463, 477, 491, + /* 20 */ 517, 531, 552, 566, 580, 594, 608, 622, 636, 650, + /* 30 */ 664, 687, 701, 527, -144, 708, 386, -158, -138, -142, + /* 40 */ -140, -116, -155, -139, 7, -27, -114, -127, 59, 133, + /* 50 */ 16, 150, 41, 144, 48, 180, -111, -17, -17, -17, + /* 60 */ 107, 200, 160, 50, 193, 195, 224, 222, 237, -162, + /* 70 */ 250, 116, 182, 119, 173, 215, 296, 267, 263, 263, + /* 80 */ 263, 315, 274, 292, 363, 369, 371, 383, 380, 400, + /* 90 */ 408, 410, 420, 425, 430, 407, 453, 428, 451, 422, + /* 100 */ 412, 457, 464, 426, 471, 478, 450, 458, 459, 468, + /* 110 */ 263, 516, 508, 506, 485, 487, 503, 538, 315, 555, + /* 120 */ 557, 561, 564, 568, 572, 579, 578, 596, 603, 590, + /* 130 */ 597, 612, 617, 625, 618, 616, 620, 629, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 10 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 20 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 30 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 40 */ 753, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 50 */ 728, 728, 728, 728, 728, 751, 728, 898, 728, 728, - /* 60 */ 728, 753, 909, 909, 909, 751, 728, 728, 728, 816, - /* 70 */ 728, 728, 973, 728, 933, 728, 925, 901, 915, 902, - /* 80 */ 728, 958, 918, 728, 753, 728, 753, 728, 728, 728, - /* 90 */ 728, 728, 940, 938, 728, 940, 938, 728, 952, 948, - /* 100 */ 931, 929, 915, 728, 728, 728, 976, 964, 960, 728, - /* 110 */ 728, 938, 728, 728, 938, 728, 829, 728, 728, 728, - /* 120 */ 751, 728, 785, 728, 751, 728, 819, 819, 754, 728, - /* 130 */ 728, 728, 728, 728, 728, 870, 951, 950, 869, 875, - /* 140 */ 874, 873, 728, 728, 728, 728, 864, 865, 863, 862, - /* 150 */ 728, 728, 728, 728, 899, 728, 961, 965, 728, 728, - /* 160 */ 728, 850, 728, 728, 728, 728, 728, 728, 728, 728, - /* 170 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 180 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 190 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 200 */ 728, 922, 932, 728, 728, 728, 728, 728, 728, 728, - /* 210 */ 728, 728, 728, 728, 850, 728, 949, 728, 908, 904, - /* 220 */ 728, 728, 900, 728, 728, 959, 728, 728, 728, 728, - /* 230 */ 728, 728, 728, 728, 894, 728, 728, 728, 728, 728, - /* 240 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 250 */ 728, 849, 728, 728, 728, 728, 728, 728, 728, 813, - /* 260 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 270 */ 728, 728, 798, 796, 795, 794, 728, 791, 728, 728, - /* 280 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 290 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 300 */ 728, 728, 728, 728, 728, 728, 728, 728, 728, 728, - /* 310 */ 728, 728, 728, + /* 0 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 10 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 20 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 30 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 40 */ 756, 783, 756, 756, 756, 756, 756, 756, 756, 756, + /* 50 */ 756, 756, 756, 756, 756, 756, 781, 756, 933, 756, + /* 60 */ 756, 756, 783, 944, 944, 944, 781, 756, 756, 756, + /* 70 */ 846, 756, 756, 1008, 756, 968, 756, 960, 936, 950, + /* 80 */ 937, 756, 993, 953, 756, 756, 783, 756, 756, 783, + /* 90 */ 756, 783, 756, 756, 756, 756, 781, 756, 756, 756, + /* 100 */ 975, 973, 756, 975, 973, 756, 987, 983, 966, 964, + /* 110 */ 950, 756, 756, 756, 1011, 999, 995, 756, 756, 973, + /* 120 */ 756, 756, 973, 756, 860, 756, 756, 756, 781, 756, + /* 130 */ 815, 756, 781, 756, 784, 849, 849, 784, 756, 756, + /* 140 */ 756, 756, 756, 756, 756, 905, 986, 985, 904, 910, + /* 150 */ 909, 908, 756, 756, 756, 756, 899, 900, 898, 897, + /* 160 */ 756, 756, 756, 756, 756, 934, 756, 996, 1000, 756, + /* 170 */ 756, 756, 884, 756, 756, 756, 756, 756, 756, 756, + /* 180 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 190 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 200 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 210 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 220 */ 756, 957, 967, 756, 756, 756, 756, 756, 756, 756, + /* 230 */ 756, 756, 756, 756, 884, 756, 984, 756, 943, 939, + /* 240 */ 756, 756, 935, 756, 756, 994, 756, 756, 756, 756, + /* 250 */ 756, 756, 756, 756, 929, 756, 756, 756, 756, 756, + /* 260 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 270 */ 756, 883, 756, 756, 756, 756, 756, 756, 756, 843, + /* 280 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 290 */ 756, 756, 828, 826, 825, 824, 756, 821, 756, 756, + /* 300 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 310 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 320 */ 756, 756, 756, 756, 756, 756, 756, 756, 756, 756, + /* 330 */ 756, 756, 756, }; /********** End of lemon-generated parsing tables *****************************/ @@ -706,131 +721,133 @@ static const char *const yyTokenName[] = { /* 90 */ "FULLTEXT", /* 91 */ "FUNCTION", /* 92 */ "INTERVAL", - /* 93 */ "MNODES", - /* 94 */ "NK_FLOAT", - /* 95 */ "NK_BOOL", - /* 96 */ "NK_VARIABLE", - /* 97 */ "BETWEEN", - /* 98 */ "IS", - /* 99 */ "NULL", - /* 100 */ "NK_LT", - /* 101 */ "NK_GT", - /* 102 */ "NK_LE", - /* 103 */ "NK_GE", - /* 104 */ "NK_NE", - /* 105 */ "NK_EQ", - /* 106 */ "LIKE", - /* 107 */ "MATCH", - /* 108 */ "NMATCH", - /* 109 */ "IN", - /* 110 */ "FROM", - /* 111 */ "AS", - /* 112 */ "JOIN", - /* 113 */ "INNER", - /* 114 */ "SELECT", - /* 115 */ "DISTINCT", - /* 116 */ "WHERE", - /* 117 */ "PARTITION", - /* 118 */ "BY", - /* 119 */ "SESSION", - /* 120 */ "STATE_WINDOW", - /* 121 */ "SLIDING", - /* 122 */ "FILL", - /* 123 */ "VALUE", - /* 124 */ "NONE", - /* 125 */ "PREV", - /* 126 */ "LINEAR", - /* 127 */ "NEXT", - /* 128 */ "GROUP", - /* 129 */ "HAVING", - /* 130 */ "ORDER", - /* 131 */ "SLIMIT", - /* 132 */ "SOFFSET", - /* 133 */ "LIMIT", - /* 134 */ "OFFSET", - /* 135 */ "ASC", - /* 136 */ "DESC", - /* 137 */ "NULLS", - /* 138 */ "FIRST", - /* 139 */ "LAST", - /* 140 */ "cmd", - /* 141 */ "user_name", - /* 142 */ "dnode_endpoint", - /* 143 */ "dnode_host_name", - /* 144 */ "not_exists_opt", - /* 145 */ "db_name", - /* 146 */ "db_options", - /* 147 */ "exists_opt", - /* 148 */ "full_table_name", - /* 149 */ "column_def_list", - /* 150 */ "tags_def_opt", - /* 151 */ "table_options", - /* 152 */ "multi_create_clause", - /* 153 */ "tags_def", - /* 154 */ "multi_drop_clause", - /* 155 */ "create_subtable_clause", - /* 156 */ "specific_tags_opt", - /* 157 */ "literal_list", - /* 158 */ "drop_table_clause", - /* 159 */ "col_name_list", - /* 160 */ "table_name", - /* 161 */ "column_def", - /* 162 */ "column_name", - /* 163 */ "type_name", - /* 164 */ "col_name", - /* 165 */ "index_name", - /* 166 */ "index_options", - /* 167 */ "func_list", - /* 168 */ "duration_literal", - /* 169 */ "sliding_opt", - /* 170 */ "func", - /* 171 */ "function_name", - /* 172 */ "expression_list", - /* 173 */ "query_expression", - /* 174 */ "literal", - /* 175 */ "table_alias", - /* 176 */ "column_alias", - /* 177 */ "expression", - /* 178 */ "column_reference", - /* 179 */ "subquery", - /* 180 */ "predicate", - /* 181 */ "compare_op", - /* 182 */ "in_op", - /* 183 */ "in_predicate_value", - /* 184 */ "boolean_value_expression", - /* 185 */ "boolean_primary", - /* 186 */ "common_expression", - /* 187 */ "from_clause", - /* 188 */ "table_reference_list", - /* 189 */ "table_reference", - /* 190 */ "table_primary", - /* 191 */ "joined_table", - /* 192 */ "alias_opt", - /* 193 */ "parenthesized_joined_table", - /* 194 */ "join_type", - /* 195 */ "search_condition", - /* 196 */ "query_specification", - /* 197 */ "set_quantifier_opt", - /* 198 */ "select_list", - /* 199 */ "where_clause_opt", - /* 200 */ "partition_by_clause_opt", - /* 201 */ "twindow_clause_opt", - /* 202 */ "group_by_clause_opt", - /* 203 */ "having_clause_opt", - /* 204 */ "select_sublist", - /* 205 */ "select_item", - /* 206 */ "fill_opt", - /* 207 */ "fill_mode", - /* 208 */ "group_by_list", - /* 209 */ "query_expression_body", - /* 210 */ "order_by_clause_opt", - /* 211 */ "slimit_clause_opt", - /* 212 */ "limit_clause_opt", - /* 213 */ "query_primary", - /* 214 */ "sort_specification_list", - /* 215 */ "sort_specification", - /* 216 */ "ordering_specification_opt", - /* 217 */ "null_ordering_opt", + /* 93 */ "TOPIC", + /* 94 */ "AS", + /* 95 */ "MNODES", + /* 96 */ "NK_FLOAT", + /* 97 */ "NK_BOOL", + /* 98 */ "NK_VARIABLE", + /* 99 */ "BETWEEN", + /* 100 */ "IS", + /* 101 */ "NULL", + /* 102 */ "NK_LT", + /* 103 */ "NK_GT", + /* 104 */ "NK_LE", + /* 105 */ "NK_GE", + /* 106 */ "NK_NE", + /* 107 */ "NK_EQ", + /* 108 */ "LIKE", + /* 109 */ "MATCH", + /* 110 */ "NMATCH", + /* 111 */ "IN", + /* 112 */ "FROM", + /* 113 */ "JOIN", + /* 114 */ "INNER", + /* 115 */ "SELECT", + /* 116 */ "DISTINCT", + /* 117 */ "WHERE", + /* 118 */ "PARTITION", + /* 119 */ "BY", + /* 120 */ "SESSION", + /* 121 */ "STATE_WINDOW", + /* 122 */ "SLIDING", + /* 123 */ "FILL", + /* 124 */ "VALUE", + /* 125 */ "NONE", + /* 126 */ "PREV", + /* 127 */ "LINEAR", + /* 128 */ "NEXT", + /* 129 */ "GROUP", + /* 130 */ "HAVING", + /* 131 */ "ORDER", + /* 132 */ "SLIMIT", + /* 133 */ "SOFFSET", + /* 134 */ "LIMIT", + /* 135 */ "OFFSET", + /* 136 */ "ASC", + /* 137 */ "DESC", + /* 138 */ "NULLS", + /* 139 */ "FIRST", + /* 140 */ "LAST", + /* 141 */ "cmd", + /* 142 */ "user_name", + /* 143 */ "dnode_endpoint", + /* 144 */ "dnode_host_name", + /* 145 */ "not_exists_opt", + /* 146 */ "db_name", + /* 147 */ "db_options", + /* 148 */ "exists_opt", + /* 149 */ "full_table_name", + /* 150 */ "column_def_list", + /* 151 */ "tags_def_opt", + /* 152 */ "table_options", + /* 153 */ "multi_create_clause", + /* 154 */ "tags_def", + /* 155 */ "multi_drop_clause", + /* 156 */ "create_subtable_clause", + /* 157 */ "specific_tags_opt", + /* 158 */ "literal_list", + /* 159 */ "drop_table_clause", + /* 160 */ "col_name_list", + /* 161 */ "table_name", + /* 162 */ "column_def", + /* 163 */ "column_name", + /* 164 */ "type_name", + /* 165 */ "col_name", + /* 166 */ "index_name", + /* 167 */ "index_options", + /* 168 */ "func_list", + /* 169 */ "duration_literal", + /* 170 */ "sliding_opt", + /* 171 */ "func", + /* 172 */ "function_name", + /* 173 */ "expression_list", + /* 174 */ "topic_name", + /* 175 */ "query_expression", + /* 176 */ "literal", + /* 177 */ "table_alias", + /* 178 */ "column_alias", + /* 179 */ "expression", + /* 180 */ "column_reference", + /* 181 */ "subquery", + /* 182 */ "predicate", + /* 183 */ "compare_op", + /* 184 */ "in_op", + /* 185 */ "in_predicate_value", + /* 186 */ "boolean_value_expression", + /* 187 */ "boolean_primary", + /* 188 */ "common_expression", + /* 189 */ "from_clause", + /* 190 */ "table_reference_list", + /* 191 */ "table_reference", + /* 192 */ "table_primary", + /* 193 */ "joined_table", + /* 194 */ "alias_opt", + /* 195 */ "parenthesized_joined_table", + /* 196 */ "join_type", + /* 197 */ "search_condition", + /* 198 */ "query_specification", + /* 199 */ "set_quantifier_opt", + /* 200 */ "select_list", + /* 201 */ "where_clause_opt", + /* 202 */ "partition_by_clause_opt", + /* 203 */ "twindow_clause_opt", + /* 204 */ "group_by_clause_opt", + /* 205 */ "having_clause_opt", + /* 206 */ "select_sublist", + /* 207 */ "select_item", + /* 208 */ "fill_opt", + /* 209 */ "fill_mode", + /* 210 */ "group_by_list", + /* 211 */ "query_expression_body", + /* 212 */ "order_by_clause_opt", + /* 213 */ "slimit_clause_opt", + /* 214 */ "limit_clause_opt", + /* 215 */ "query_primary", + /* 216 */ "sort_specification_list", + /* 217 */ "sort_specification", + /* 218 */ "ordering_specification_opt", + /* 219 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -852,240 +869,247 @@ static const char *const yyRuleName[] = { /* 11 */ "dnode_host_name ::= NK_ID", /* 12 */ "dnode_host_name ::= NK_IPTOKEN", /* 13 */ "cmd ::= CREATE QNODE ON DNODE NK_INTEGER", - /* 14 */ "cmd ::= SHOW QNODES", - /* 15 */ "cmd ::= CREATE DATABASE not_exists_opt db_name db_options", - /* 16 */ "cmd ::= DROP DATABASE exists_opt db_name", - /* 17 */ "cmd ::= SHOW DATABASES", - /* 18 */ "cmd ::= USE db_name", - /* 19 */ "not_exists_opt ::= IF NOT EXISTS", - /* 20 */ "not_exists_opt ::=", - /* 21 */ "exists_opt ::= IF EXISTS", - /* 22 */ "exists_opt ::=", - /* 23 */ "db_options ::=", - /* 24 */ "db_options ::= db_options BLOCKS NK_INTEGER", - /* 25 */ "db_options ::= db_options CACHE NK_INTEGER", - /* 26 */ "db_options ::= db_options CACHELAST NK_INTEGER", - /* 27 */ "db_options ::= db_options COMP NK_INTEGER", - /* 28 */ "db_options ::= db_options DAYS NK_INTEGER", - /* 29 */ "db_options ::= db_options FSYNC NK_INTEGER", - /* 30 */ "db_options ::= db_options MAXROWS NK_INTEGER", - /* 31 */ "db_options ::= db_options MINROWS NK_INTEGER", - /* 32 */ "db_options ::= db_options KEEP NK_INTEGER", - /* 33 */ "db_options ::= db_options PRECISION NK_STRING", - /* 34 */ "db_options ::= db_options QUORUM NK_INTEGER", - /* 35 */ "db_options ::= db_options REPLICA NK_INTEGER", - /* 36 */ "db_options ::= db_options TTL NK_INTEGER", - /* 37 */ "db_options ::= db_options WAL NK_INTEGER", - /* 38 */ "db_options ::= db_options VGROUPS NK_INTEGER", - /* 39 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", - /* 40 */ "db_options ::= db_options STREAM_MODE NK_INTEGER", - /* 41 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", - /* 42 */ "cmd ::= CREATE TABLE multi_create_clause", - /* 43 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", - /* 44 */ "cmd ::= DROP TABLE multi_drop_clause", - /* 45 */ "cmd ::= DROP STABLE exists_opt full_table_name", - /* 46 */ "cmd ::= SHOW TABLES", - /* 47 */ "cmd ::= SHOW STABLES", - /* 48 */ "multi_create_clause ::= create_subtable_clause", - /* 49 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 50 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP", - /* 51 */ "multi_drop_clause ::= drop_table_clause", - /* 52 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", - /* 53 */ "drop_table_clause ::= exists_opt full_table_name", - /* 54 */ "specific_tags_opt ::=", - /* 55 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", - /* 56 */ "full_table_name ::= table_name", - /* 57 */ "full_table_name ::= db_name NK_DOT table_name", - /* 58 */ "column_def_list ::= column_def", - /* 59 */ "column_def_list ::= column_def_list NK_COMMA column_def", - /* 60 */ "column_def ::= column_name type_name", - /* 61 */ "column_def ::= column_name type_name COMMENT NK_STRING", - /* 62 */ "type_name ::= BOOL", - /* 63 */ "type_name ::= TINYINT", - /* 64 */ "type_name ::= SMALLINT", - /* 65 */ "type_name ::= INT", - /* 66 */ "type_name ::= INTEGER", - /* 67 */ "type_name ::= BIGINT", - /* 68 */ "type_name ::= FLOAT", - /* 69 */ "type_name ::= DOUBLE", - /* 70 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 71 */ "type_name ::= TIMESTAMP", - /* 72 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 73 */ "type_name ::= TINYINT UNSIGNED", - /* 74 */ "type_name ::= SMALLINT UNSIGNED", - /* 75 */ "type_name ::= INT UNSIGNED", - /* 76 */ "type_name ::= BIGINT UNSIGNED", - /* 77 */ "type_name ::= JSON", - /* 78 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 79 */ "type_name ::= MEDIUMBLOB", - /* 80 */ "type_name ::= BLOB", - /* 81 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 82 */ "type_name ::= DECIMAL", - /* 83 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 84 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 85 */ "tags_def_opt ::=", - /* 86 */ "tags_def_opt ::= tags_def", - /* 87 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", - /* 88 */ "table_options ::=", - /* 89 */ "table_options ::= table_options COMMENT NK_STRING", - /* 90 */ "table_options ::= table_options KEEP NK_INTEGER", - /* 91 */ "table_options ::= table_options TTL NK_INTEGER", - /* 92 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 93 */ "col_name_list ::= col_name", - /* 94 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 95 */ "col_name ::= column_name", - /* 96 */ "cmd ::= CREATE SMA INDEX index_name ON table_name index_options", - /* 97 */ "cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP", - /* 98 */ "index_options ::=", - /* 99 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", - /* 100 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", - /* 101 */ "func_list ::= func", - /* 102 */ "func_list ::= func_list NK_COMMA func", - /* 103 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 104 */ "cmd ::= SHOW VGROUPS", - /* 105 */ "cmd ::= SHOW db_name NK_DOT VGROUPS", - /* 106 */ "cmd ::= SHOW MNODES", - /* 107 */ "cmd ::= query_expression", - /* 108 */ "literal ::= NK_INTEGER", - /* 109 */ "literal ::= NK_FLOAT", - /* 110 */ "literal ::= NK_STRING", - /* 111 */ "literal ::= NK_BOOL", - /* 112 */ "literal ::= TIMESTAMP NK_STRING", - /* 113 */ "literal ::= duration_literal", - /* 114 */ "duration_literal ::= NK_VARIABLE", - /* 115 */ "literal_list ::= literal", - /* 116 */ "literal_list ::= literal_list NK_COMMA literal", - /* 117 */ "db_name ::= NK_ID", - /* 118 */ "table_name ::= NK_ID", - /* 119 */ "column_name ::= NK_ID", - /* 120 */ "function_name ::= NK_ID", - /* 121 */ "table_alias ::= NK_ID", - /* 122 */ "column_alias ::= NK_ID", - /* 123 */ "user_name ::= NK_ID", - /* 124 */ "index_name ::= NK_ID", - /* 125 */ "expression ::= literal", - /* 126 */ "expression ::= column_reference", - /* 127 */ "expression ::= function_name NK_LP expression_list NK_RP", - /* 128 */ "expression ::= function_name NK_LP NK_STAR NK_RP", - /* 129 */ "expression ::= subquery", - /* 130 */ "expression ::= NK_LP expression NK_RP", - /* 131 */ "expression ::= NK_PLUS expression", - /* 132 */ "expression ::= NK_MINUS expression", - /* 133 */ "expression ::= expression NK_PLUS expression", - /* 134 */ "expression ::= expression NK_MINUS expression", - /* 135 */ "expression ::= expression NK_STAR expression", - /* 136 */ "expression ::= expression NK_SLASH expression", - /* 137 */ "expression ::= expression NK_REM expression", - /* 138 */ "expression_list ::= expression", - /* 139 */ "expression_list ::= expression_list NK_COMMA expression", - /* 140 */ "column_reference ::= column_name", - /* 141 */ "column_reference ::= table_name NK_DOT column_name", - /* 142 */ "predicate ::= expression compare_op expression", - /* 143 */ "predicate ::= expression BETWEEN expression AND expression", - /* 144 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 145 */ "predicate ::= expression IS NULL", - /* 146 */ "predicate ::= expression IS NOT NULL", - /* 147 */ "predicate ::= expression in_op in_predicate_value", - /* 148 */ "compare_op ::= NK_LT", - /* 149 */ "compare_op ::= NK_GT", - /* 150 */ "compare_op ::= NK_LE", - /* 151 */ "compare_op ::= NK_GE", - /* 152 */ "compare_op ::= NK_NE", - /* 153 */ "compare_op ::= NK_EQ", - /* 154 */ "compare_op ::= LIKE", - /* 155 */ "compare_op ::= NOT LIKE", - /* 156 */ "compare_op ::= MATCH", - /* 157 */ "compare_op ::= NMATCH", - /* 158 */ "in_op ::= IN", - /* 159 */ "in_op ::= NOT IN", - /* 160 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 161 */ "boolean_value_expression ::= boolean_primary", - /* 162 */ "boolean_value_expression ::= NOT boolean_primary", - /* 163 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 164 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 165 */ "boolean_primary ::= predicate", - /* 166 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 167 */ "common_expression ::= expression", - /* 168 */ "common_expression ::= boolean_value_expression", - /* 169 */ "from_clause ::= FROM table_reference_list", - /* 170 */ "table_reference_list ::= table_reference", - /* 171 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 172 */ "table_reference ::= table_primary", - /* 173 */ "table_reference ::= joined_table", - /* 174 */ "table_primary ::= table_name alias_opt", - /* 175 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 176 */ "table_primary ::= subquery alias_opt", - /* 177 */ "table_primary ::= parenthesized_joined_table", - /* 178 */ "alias_opt ::=", - /* 179 */ "alias_opt ::= table_alias", - /* 180 */ "alias_opt ::= AS table_alias", - /* 181 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 182 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 183 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 184 */ "join_type ::=", - /* 185 */ "join_type ::= INNER", - /* 186 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 187 */ "set_quantifier_opt ::=", - /* 188 */ "set_quantifier_opt ::= DISTINCT", - /* 189 */ "set_quantifier_opt ::= ALL", - /* 190 */ "select_list ::= NK_STAR", - /* 191 */ "select_list ::= select_sublist", - /* 192 */ "select_sublist ::= select_item", - /* 193 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 194 */ "select_item ::= common_expression", - /* 195 */ "select_item ::= common_expression column_alias", - /* 196 */ "select_item ::= common_expression AS column_alias", - /* 197 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 198 */ "where_clause_opt ::=", - /* 199 */ "where_clause_opt ::= WHERE search_condition", - /* 200 */ "partition_by_clause_opt ::=", - /* 201 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 202 */ "twindow_clause_opt ::=", - /* 203 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP", - /* 204 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", - /* 205 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 206 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 207 */ "sliding_opt ::=", - /* 208 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 209 */ "fill_opt ::=", - /* 210 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 211 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 212 */ "fill_mode ::= NONE", - /* 213 */ "fill_mode ::= PREV", - /* 214 */ "fill_mode ::= NULL", - /* 215 */ "fill_mode ::= LINEAR", - /* 216 */ "fill_mode ::= NEXT", - /* 217 */ "group_by_clause_opt ::=", - /* 218 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 219 */ "group_by_list ::= expression", - /* 220 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 221 */ "having_clause_opt ::=", - /* 222 */ "having_clause_opt ::= HAVING search_condition", - /* 223 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 224 */ "query_expression_body ::= query_primary", - /* 225 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 226 */ "query_primary ::= query_specification", - /* 227 */ "order_by_clause_opt ::=", - /* 228 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 229 */ "slimit_clause_opt ::=", - /* 230 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 231 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 232 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 233 */ "limit_clause_opt ::=", - /* 234 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 235 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 236 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 237 */ "subquery ::= NK_LP query_expression NK_RP", - /* 238 */ "search_condition ::= common_expression", - /* 239 */ "sort_specification_list ::= sort_specification", - /* 240 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 241 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 242 */ "ordering_specification_opt ::=", - /* 243 */ "ordering_specification_opt ::= ASC", - /* 244 */ "ordering_specification_opt ::= DESC", - /* 245 */ "null_ordering_opt ::=", - /* 246 */ "null_ordering_opt ::= NULLS FIRST", - /* 247 */ "null_ordering_opt ::= NULLS LAST", + /* 14 */ "cmd ::= DROP QNODE ON DNODE NK_INTEGER", + /* 15 */ "cmd ::= SHOW QNODES", + /* 16 */ "cmd ::= CREATE DATABASE not_exists_opt db_name db_options", + /* 17 */ "cmd ::= DROP DATABASE exists_opt db_name", + /* 18 */ "cmd ::= SHOW DATABASES", + /* 19 */ "cmd ::= USE db_name", + /* 20 */ "cmd ::= ALTER DATABASE db_name db_options", + /* 21 */ "not_exists_opt ::= IF NOT EXISTS", + /* 22 */ "not_exists_opt ::=", + /* 23 */ "exists_opt ::= IF EXISTS", + /* 24 */ "exists_opt ::=", + /* 25 */ "db_options ::=", + /* 26 */ "db_options ::= db_options BLOCKS NK_INTEGER", + /* 27 */ "db_options ::= db_options CACHE NK_INTEGER", + /* 28 */ "db_options ::= db_options CACHELAST NK_INTEGER", + /* 29 */ "db_options ::= db_options COMP NK_INTEGER", + /* 30 */ "db_options ::= db_options DAYS NK_INTEGER", + /* 31 */ "db_options ::= db_options FSYNC NK_INTEGER", + /* 32 */ "db_options ::= db_options MAXROWS NK_INTEGER", + /* 33 */ "db_options ::= db_options MINROWS NK_INTEGER", + /* 34 */ "db_options ::= db_options KEEP NK_INTEGER", + /* 35 */ "db_options ::= db_options PRECISION NK_STRING", + /* 36 */ "db_options ::= db_options QUORUM NK_INTEGER", + /* 37 */ "db_options ::= db_options REPLICA NK_INTEGER", + /* 38 */ "db_options ::= db_options TTL NK_INTEGER", + /* 39 */ "db_options ::= db_options WAL NK_INTEGER", + /* 40 */ "db_options ::= db_options VGROUPS NK_INTEGER", + /* 41 */ "db_options ::= db_options SINGLE_STABLE NK_INTEGER", + /* 42 */ "db_options ::= db_options STREAM_MODE NK_INTEGER", + /* 43 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", + /* 44 */ "cmd ::= CREATE TABLE multi_create_clause", + /* 45 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", + /* 46 */ "cmd ::= DROP TABLE multi_drop_clause", + /* 47 */ "cmd ::= DROP STABLE exists_opt full_table_name", + /* 48 */ "cmd ::= SHOW TABLES", + /* 49 */ "cmd ::= SHOW STABLES", + /* 50 */ "multi_create_clause ::= create_subtable_clause", + /* 51 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", + /* 52 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP", + /* 53 */ "multi_drop_clause ::= drop_table_clause", + /* 54 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", + /* 55 */ "drop_table_clause ::= exists_opt full_table_name", + /* 56 */ "specific_tags_opt ::=", + /* 57 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", + /* 58 */ "full_table_name ::= table_name", + /* 59 */ "full_table_name ::= db_name NK_DOT table_name", + /* 60 */ "column_def_list ::= column_def", + /* 61 */ "column_def_list ::= column_def_list NK_COMMA column_def", + /* 62 */ "column_def ::= column_name type_name", + /* 63 */ "column_def ::= column_name type_name COMMENT NK_STRING", + /* 64 */ "type_name ::= BOOL", + /* 65 */ "type_name ::= TINYINT", + /* 66 */ "type_name ::= SMALLINT", + /* 67 */ "type_name ::= INT", + /* 68 */ "type_name ::= INTEGER", + /* 69 */ "type_name ::= BIGINT", + /* 70 */ "type_name ::= FLOAT", + /* 71 */ "type_name ::= DOUBLE", + /* 72 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", + /* 73 */ "type_name ::= TIMESTAMP", + /* 74 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", + /* 75 */ "type_name ::= TINYINT UNSIGNED", + /* 76 */ "type_name ::= SMALLINT UNSIGNED", + /* 77 */ "type_name ::= INT UNSIGNED", + /* 78 */ "type_name ::= BIGINT UNSIGNED", + /* 79 */ "type_name ::= JSON", + /* 80 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", + /* 81 */ "type_name ::= MEDIUMBLOB", + /* 82 */ "type_name ::= BLOB", + /* 83 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", + /* 84 */ "type_name ::= DECIMAL", + /* 85 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", + /* 86 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 87 */ "tags_def_opt ::=", + /* 88 */ "tags_def_opt ::= tags_def", + /* 89 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", + /* 90 */ "table_options ::=", + /* 91 */ "table_options ::= table_options COMMENT NK_STRING", + /* 92 */ "table_options ::= table_options KEEP NK_INTEGER", + /* 93 */ "table_options ::= table_options TTL NK_INTEGER", + /* 94 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 95 */ "col_name_list ::= col_name", + /* 96 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 97 */ "col_name ::= column_name", + /* 98 */ "cmd ::= CREATE SMA INDEX index_name ON table_name index_options", + /* 99 */ "cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP", + /* 100 */ "cmd ::= DROP INDEX index_name ON table_name", + /* 101 */ "index_options ::=", + /* 102 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", + /* 103 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", + /* 104 */ "func_list ::= func", + /* 105 */ "func_list ::= func_list NK_COMMA func", + /* 106 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 107 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", + /* 108 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name", + /* 109 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 110 */ "cmd ::= SHOW VGROUPS", + /* 111 */ "cmd ::= SHOW db_name NK_DOT VGROUPS", + /* 112 */ "cmd ::= SHOW MNODES", + /* 113 */ "cmd ::= query_expression", + /* 114 */ "literal ::= NK_INTEGER", + /* 115 */ "literal ::= NK_FLOAT", + /* 116 */ "literal ::= NK_STRING", + /* 117 */ "literal ::= NK_BOOL", + /* 118 */ "literal ::= TIMESTAMP NK_STRING", + /* 119 */ "literal ::= duration_literal", + /* 120 */ "duration_literal ::= NK_VARIABLE", + /* 121 */ "literal_list ::= literal", + /* 122 */ "literal_list ::= literal_list NK_COMMA literal", + /* 123 */ "db_name ::= NK_ID", + /* 124 */ "table_name ::= NK_ID", + /* 125 */ "column_name ::= NK_ID", + /* 126 */ "function_name ::= NK_ID", + /* 127 */ "table_alias ::= NK_ID", + /* 128 */ "column_alias ::= NK_ID", + /* 129 */ "user_name ::= NK_ID", + /* 130 */ "index_name ::= NK_ID", + /* 131 */ "topic_name ::= NK_ID", + /* 132 */ "expression ::= literal", + /* 133 */ "expression ::= column_reference", + /* 134 */ "expression ::= function_name NK_LP expression_list NK_RP", + /* 135 */ "expression ::= function_name NK_LP NK_STAR NK_RP", + /* 136 */ "expression ::= subquery", + /* 137 */ "expression ::= NK_LP expression NK_RP", + /* 138 */ "expression ::= NK_PLUS expression", + /* 139 */ "expression ::= NK_MINUS expression", + /* 140 */ "expression ::= expression NK_PLUS expression", + /* 141 */ "expression ::= expression NK_MINUS expression", + /* 142 */ "expression ::= expression NK_STAR expression", + /* 143 */ "expression ::= expression NK_SLASH expression", + /* 144 */ "expression ::= expression NK_REM expression", + /* 145 */ "expression_list ::= expression", + /* 146 */ "expression_list ::= expression_list NK_COMMA expression", + /* 147 */ "column_reference ::= column_name", + /* 148 */ "column_reference ::= table_name NK_DOT column_name", + /* 149 */ "predicate ::= expression compare_op expression", + /* 150 */ "predicate ::= expression BETWEEN expression AND expression", + /* 151 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 152 */ "predicate ::= expression IS NULL", + /* 153 */ "predicate ::= expression IS NOT NULL", + /* 154 */ "predicate ::= expression in_op in_predicate_value", + /* 155 */ "compare_op ::= NK_LT", + /* 156 */ "compare_op ::= NK_GT", + /* 157 */ "compare_op ::= NK_LE", + /* 158 */ "compare_op ::= NK_GE", + /* 159 */ "compare_op ::= NK_NE", + /* 160 */ "compare_op ::= NK_EQ", + /* 161 */ "compare_op ::= LIKE", + /* 162 */ "compare_op ::= NOT LIKE", + /* 163 */ "compare_op ::= MATCH", + /* 164 */ "compare_op ::= NMATCH", + /* 165 */ "in_op ::= IN", + /* 166 */ "in_op ::= NOT IN", + /* 167 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 168 */ "boolean_value_expression ::= boolean_primary", + /* 169 */ "boolean_value_expression ::= NOT boolean_primary", + /* 170 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 171 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 172 */ "boolean_primary ::= predicate", + /* 173 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 174 */ "common_expression ::= expression", + /* 175 */ "common_expression ::= boolean_value_expression", + /* 176 */ "from_clause ::= FROM table_reference_list", + /* 177 */ "table_reference_list ::= table_reference", + /* 178 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 179 */ "table_reference ::= table_primary", + /* 180 */ "table_reference ::= joined_table", + /* 181 */ "table_primary ::= table_name alias_opt", + /* 182 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 183 */ "table_primary ::= subquery alias_opt", + /* 184 */ "table_primary ::= parenthesized_joined_table", + /* 185 */ "alias_opt ::=", + /* 186 */ "alias_opt ::= table_alias", + /* 187 */ "alias_opt ::= AS table_alias", + /* 188 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 189 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 190 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 191 */ "join_type ::=", + /* 192 */ "join_type ::= INNER", + /* 193 */ "query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 194 */ "set_quantifier_opt ::=", + /* 195 */ "set_quantifier_opt ::= DISTINCT", + /* 196 */ "set_quantifier_opt ::= ALL", + /* 197 */ "select_list ::= NK_STAR", + /* 198 */ "select_list ::= select_sublist", + /* 199 */ "select_sublist ::= select_item", + /* 200 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 201 */ "select_item ::= common_expression", + /* 202 */ "select_item ::= common_expression column_alias", + /* 203 */ "select_item ::= common_expression AS column_alias", + /* 204 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 205 */ "where_clause_opt ::=", + /* 206 */ "where_clause_opt ::= WHERE search_condition", + /* 207 */ "partition_by_clause_opt ::=", + /* 208 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 209 */ "twindow_clause_opt ::=", + /* 210 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP", + /* 211 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", + /* 212 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 213 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 214 */ "sliding_opt ::=", + /* 215 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 216 */ "fill_opt ::=", + /* 217 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 218 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 219 */ "fill_mode ::= NONE", + /* 220 */ "fill_mode ::= PREV", + /* 221 */ "fill_mode ::= NULL", + /* 222 */ "fill_mode ::= LINEAR", + /* 223 */ "fill_mode ::= NEXT", + /* 224 */ "group_by_clause_opt ::=", + /* 225 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 226 */ "group_by_list ::= expression", + /* 227 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 228 */ "having_clause_opt ::=", + /* 229 */ "having_clause_opt ::= HAVING search_condition", + /* 230 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 231 */ "query_expression_body ::= query_primary", + /* 232 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 233 */ "query_primary ::= query_specification", + /* 234 */ "order_by_clause_opt ::=", + /* 235 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 236 */ "slimit_clause_opt ::=", + /* 237 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 238 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 239 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 240 */ "limit_clause_opt ::=", + /* 241 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 242 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 243 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 244 */ "subquery ::= NK_LP query_expression NK_RP", + /* 245 */ "search_condition ::= common_expression", + /* 246 */ "sort_specification_list ::= sort_specification", + /* 247 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 248 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 249 */ "ordering_specification_opt ::=", + /* 250 */ "ordering_specification_opt ::= ASC", + /* 251 */ "ordering_specification_opt ::= DESC", + /* 252 */ "null_ordering_opt ::=", + /* 253 */ "null_ordering_opt ::= NULLS FIRST", + /* 254 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -1212,120 +1236,121 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 140: /* cmd */ - case 146: /* db_options */ - case 148: /* full_table_name */ - case 151: /* table_options */ - case 155: /* create_subtable_clause */ - case 158: /* drop_table_clause */ - case 161: /* column_def */ - case 164: /* col_name */ - case 166: /* index_options */ - case 168: /* duration_literal */ - case 169: /* sliding_opt */ - case 170: /* func */ - case 173: /* query_expression */ - case 174: /* literal */ - case 177: /* expression */ - case 178: /* column_reference */ - case 179: /* subquery */ - case 180: /* predicate */ - case 183: /* in_predicate_value */ - case 184: /* boolean_value_expression */ - case 185: /* boolean_primary */ - case 186: /* common_expression */ - case 187: /* from_clause */ - case 188: /* table_reference_list */ - case 189: /* table_reference */ - case 190: /* table_primary */ - case 191: /* joined_table */ - case 193: /* parenthesized_joined_table */ - case 195: /* search_condition */ - case 196: /* query_specification */ - case 199: /* where_clause_opt */ - case 201: /* twindow_clause_opt */ - case 203: /* having_clause_opt */ - case 205: /* select_item */ - case 206: /* fill_opt */ - case 209: /* query_expression_body */ - case 211: /* slimit_clause_opt */ - case 212: /* limit_clause_opt */ - case 213: /* query_primary */ - case 215: /* sort_specification */ + case 141: /* cmd */ + case 147: /* db_options */ + case 149: /* full_table_name */ + case 152: /* table_options */ + case 156: /* create_subtable_clause */ + case 159: /* drop_table_clause */ + case 162: /* column_def */ + case 165: /* col_name */ + case 167: /* index_options */ + case 169: /* duration_literal */ + case 170: /* sliding_opt */ + case 171: /* func */ + case 175: /* query_expression */ + case 176: /* literal */ + case 179: /* expression */ + case 180: /* column_reference */ + case 181: /* subquery */ + case 182: /* predicate */ + case 185: /* in_predicate_value */ + case 186: /* boolean_value_expression */ + case 187: /* boolean_primary */ + case 188: /* common_expression */ + case 189: /* from_clause */ + case 190: /* table_reference_list */ + case 191: /* table_reference */ + case 192: /* table_primary */ + case 193: /* joined_table */ + case 195: /* parenthesized_joined_table */ + case 197: /* search_condition */ + case 198: /* query_specification */ + case 201: /* where_clause_opt */ + case 203: /* twindow_clause_opt */ + case 205: /* having_clause_opt */ + case 207: /* select_item */ + case 208: /* fill_opt */ + case 211: /* query_expression_body */ + case 213: /* slimit_clause_opt */ + case 214: /* limit_clause_opt */ + case 215: /* query_primary */ + case 217: /* sort_specification */ { - nodesDestroyNode((yypminor->yy68)); + nodesDestroyNode((yypminor->yy432)); } break; - case 141: /* user_name */ - case 142: /* dnode_endpoint */ - case 143: /* dnode_host_name */ - case 145: /* db_name */ - case 160: /* table_name */ - case 162: /* column_name */ - case 165: /* index_name */ - case 171: /* function_name */ - case 175: /* table_alias */ - case 176: /* column_alias */ - case 192: /* alias_opt */ + case 142: /* user_name */ + case 143: /* dnode_endpoint */ + case 144: /* dnode_host_name */ + case 146: /* db_name */ + case 161: /* table_name */ + case 163: /* column_name */ + case 166: /* index_name */ + case 172: /* function_name */ + case 174: /* topic_name */ + case 177: /* table_alias */ + case 178: /* column_alias */ + case 194: /* alias_opt */ { } break; - case 144: /* not_exists_opt */ - case 147: /* exists_opt */ - case 197: /* set_quantifier_opt */ + case 145: /* not_exists_opt */ + case 148: /* exists_opt */ + case 199: /* set_quantifier_opt */ { } break; - case 149: /* column_def_list */ - case 150: /* tags_def_opt */ - case 152: /* multi_create_clause */ - case 153: /* tags_def */ - case 154: /* multi_drop_clause */ - case 156: /* specific_tags_opt */ - case 157: /* literal_list */ - case 159: /* col_name_list */ - case 167: /* func_list */ - case 172: /* expression_list */ - case 198: /* select_list */ - case 200: /* partition_by_clause_opt */ - case 202: /* group_by_clause_opt */ - case 204: /* select_sublist */ - case 208: /* group_by_list */ - case 210: /* order_by_clause_opt */ - case 214: /* sort_specification_list */ + case 150: /* column_def_list */ + case 151: /* tags_def_opt */ + case 153: /* multi_create_clause */ + case 154: /* tags_def */ + case 155: /* multi_drop_clause */ + case 157: /* specific_tags_opt */ + case 158: /* literal_list */ + case 160: /* col_name_list */ + case 168: /* func_list */ + case 173: /* expression_list */ + case 200: /* select_list */ + case 202: /* partition_by_clause_opt */ + case 204: /* group_by_clause_opt */ + case 206: /* select_sublist */ + case 210: /* group_by_list */ + case 212: /* order_by_clause_opt */ + case 216: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy40)); + nodesDestroyList((yypminor->yy24)); } break; - case 163: /* type_name */ + case 164: /* type_name */ { } break; - case 181: /* compare_op */ - case 182: /* in_op */ + case 183: /* compare_op */ + case 184: /* in_op */ { } break; - case 194: /* join_type */ + case 196: /* join_type */ { } break; - case 207: /* fill_mode */ + case 209: /* fill_mode */ { } break; - case 216: /* ordering_specification_opt */ + case 218: /* ordering_specification_opt */ { } break; - case 217: /* null_ordering_opt */ + case 219: /* null_ordering_opt */ { } @@ -1624,254 +1649,261 @@ static const struct { YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */ signed char nrhs; /* Negative of the number of RHS symbols in the rule */ } yyRuleInfo[] = { - { 140, -5 }, /* (0) cmd ::= CREATE USER user_name PASS NK_STRING */ - { 140, -5 }, /* (1) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 140, -5 }, /* (2) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ - { 140, -3 }, /* (3) cmd ::= DROP USER user_name */ - { 140, -2 }, /* (4) cmd ::= SHOW USERS */ - { 140, -3 }, /* (5) cmd ::= CREATE DNODE dnode_endpoint */ - { 140, -5 }, /* (6) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ - { 140, -3 }, /* (7) cmd ::= DROP DNODE NK_INTEGER */ - { 140, -3 }, /* (8) cmd ::= DROP DNODE dnode_endpoint */ - { 140, -2 }, /* (9) cmd ::= SHOW DNODES */ - { 142, -1 }, /* (10) dnode_endpoint ::= NK_STRING */ - { 143, -1 }, /* (11) dnode_host_name ::= NK_ID */ - { 143, -1 }, /* (12) dnode_host_name ::= NK_IPTOKEN */ - { 140, -5 }, /* (13) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 140, -2 }, /* (14) cmd ::= SHOW QNODES */ - { 140, -5 }, /* (15) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 140, -4 }, /* (16) cmd ::= DROP DATABASE exists_opt db_name */ - { 140, -2 }, /* (17) cmd ::= SHOW DATABASES */ - { 140, -2 }, /* (18) cmd ::= USE db_name */ - { 144, -3 }, /* (19) not_exists_opt ::= IF NOT EXISTS */ - { 144, 0 }, /* (20) not_exists_opt ::= */ - { 147, -2 }, /* (21) exists_opt ::= IF EXISTS */ - { 147, 0 }, /* (22) exists_opt ::= */ - { 146, 0 }, /* (23) db_options ::= */ - { 146, -3 }, /* (24) db_options ::= db_options BLOCKS NK_INTEGER */ - { 146, -3 }, /* (25) db_options ::= db_options CACHE NK_INTEGER */ - { 146, -3 }, /* (26) db_options ::= db_options CACHELAST NK_INTEGER */ - { 146, -3 }, /* (27) db_options ::= db_options COMP NK_INTEGER */ - { 146, -3 }, /* (28) db_options ::= db_options DAYS NK_INTEGER */ - { 146, -3 }, /* (29) db_options ::= db_options FSYNC NK_INTEGER */ - { 146, -3 }, /* (30) db_options ::= db_options MAXROWS NK_INTEGER */ - { 146, -3 }, /* (31) db_options ::= db_options MINROWS NK_INTEGER */ - { 146, -3 }, /* (32) db_options ::= db_options KEEP NK_INTEGER */ - { 146, -3 }, /* (33) db_options ::= db_options PRECISION NK_STRING */ - { 146, -3 }, /* (34) db_options ::= db_options QUORUM NK_INTEGER */ - { 146, -3 }, /* (35) db_options ::= db_options REPLICA NK_INTEGER */ - { 146, -3 }, /* (36) db_options ::= db_options TTL NK_INTEGER */ - { 146, -3 }, /* (37) db_options ::= db_options WAL NK_INTEGER */ - { 146, -3 }, /* (38) db_options ::= db_options VGROUPS NK_INTEGER */ - { 146, -3 }, /* (39) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 146, -3 }, /* (40) db_options ::= db_options STREAM_MODE NK_INTEGER */ - { 140, -9 }, /* (41) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 140, -3 }, /* (42) cmd ::= CREATE TABLE multi_create_clause */ - { 140, -9 }, /* (43) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 140, -3 }, /* (44) cmd ::= DROP TABLE multi_drop_clause */ - { 140, -4 }, /* (45) cmd ::= DROP STABLE exists_opt full_table_name */ - { 140, -2 }, /* (46) cmd ::= SHOW TABLES */ - { 140, -2 }, /* (47) cmd ::= SHOW STABLES */ - { 152, -1 }, /* (48) multi_create_clause ::= create_subtable_clause */ - { 152, -2 }, /* (49) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 155, -9 }, /* (50) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ - { 154, -1 }, /* (51) multi_drop_clause ::= drop_table_clause */ - { 154, -2 }, /* (52) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 158, -2 }, /* (53) drop_table_clause ::= exists_opt full_table_name */ - { 156, 0 }, /* (54) specific_tags_opt ::= */ - { 156, -3 }, /* (55) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - { 148, -1 }, /* (56) full_table_name ::= table_name */ - { 148, -3 }, /* (57) full_table_name ::= db_name NK_DOT table_name */ - { 149, -1 }, /* (58) column_def_list ::= column_def */ - { 149, -3 }, /* (59) column_def_list ::= column_def_list NK_COMMA column_def */ - { 161, -2 }, /* (60) column_def ::= column_name type_name */ - { 161, -4 }, /* (61) column_def ::= column_name type_name COMMENT NK_STRING */ - { 163, -1 }, /* (62) type_name ::= BOOL */ - { 163, -1 }, /* (63) type_name ::= TINYINT */ - { 163, -1 }, /* (64) type_name ::= SMALLINT */ - { 163, -1 }, /* (65) type_name ::= INT */ - { 163, -1 }, /* (66) type_name ::= INTEGER */ - { 163, -1 }, /* (67) type_name ::= BIGINT */ - { 163, -1 }, /* (68) type_name ::= FLOAT */ - { 163, -1 }, /* (69) type_name ::= DOUBLE */ - { 163, -4 }, /* (70) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 163, -1 }, /* (71) type_name ::= TIMESTAMP */ - { 163, -4 }, /* (72) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 163, -2 }, /* (73) type_name ::= TINYINT UNSIGNED */ - { 163, -2 }, /* (74) type_name ::= SMALLINT UNSIGNED */ - { 163, -2 }, /* (75) type_name ::= INT UNSIGNED */ - { 163, -2 }, /* (76) type_name ::= BIGINT UNSIGNED */ - { 163, -1 }, /* (77) type_name ::= JSON */ - { 163, -4 }, /* (78) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 163, -1 }, /* (79) type_name ::= MEDIUMBLOB */ - { 163, -1 }, /* (80) type_name ::= BLOB */ - { 163, -4 }, /* (81) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 163, -1 }, /* (82) type_name ::= DECIMAL */ - { 163, -4 }, /* (83) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 163, -6 }, /* (84) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 150, 0 }, /* (85) tags_def_opt ::= */ - { 150, -1 }, /* (86) tags_def_opt ::= tags_def */ - { 153, -4 }, /* (87) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 151, 0 }, /* (88) table_options ::= */ - { 151, -3 }, /* (89) table_options ::= table_options COMMENT NK_STRING */ - { 151, -3 }, /* (90) table_options ::= table_options KEEP NK_INTEGER */ - { 151, -3 }, /* (91) table_options ::= table_options TTL NK_INTEGER */ - { 151, -5 }, /* (92) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 159, -1 }, /* (93) col_name_list ::= col_name */ - { 159, -3 }, /* (94) col_name_list ::= col_name_list NK_COMMA col_name */ - { 164, -1 }, /* (95) col_name ::= column_name */ - { 140, -7 }, /* (96) cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ - { 140, -9 }, /* (97) cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ - { 166, 0 }, /* (98) index_options ::= */ - { 166, -9 }, /* (99) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ - { 166, -11 }, /* (100) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ - { 167, -1 }, /* (101) func_list ::= func */ - { 167, -3 }, /* (102) func_list ::= func_list NK_COMMA func */ - { 170, -4 }, /* (103) func ::= function_name NK_LP expression_list NK_RP */ - { 140, -2 }, /* (104) cmd ::= SHOW VGROUPS */ - { 140, -4 }, /* (105) cmd ::= SHOW db_name NK_DOT VGROUPS */ - { 140, -2 }, /* (106) cmd ::= SHOW MNODES */ - { 140, -1 }, /* (107) cmd ::= query_expression */ - { 174, -1 }, /* (108) literal ::= NK_INTEGER */ - { 174, -1 }, /* (109) literal ::= NK_FLOAT */ - { 174, -1 }, /* (110) literal ::= NK_STRING */ - { 174, -1 }, /* (111) literal ::= NK_BOOL */ - { 174, -2 }, /* (112) literal ::= TIMESTAMP NK_STRING */ - { 174, -1 }, /* (113) literal ::= duration_literal */ - { 168, -1 }, /* (114) duration_literal ::= NK_VARIABLE */ - { 157, -1 }, /* (115) literal_list ::= literal */ - { 157, -3 }, /* (116) literal_list ::= literal_list NK_COMMA literal */ - { 145, -1 }, /* (117) db_name ::= NK_ID */ - { 160, -1 }, /* (118) table_name ::= NK_ID */ - { 162, -1 }, /* (119) column_name ::= NK_ID */ - { 171, -1 }, /* (120) function_name ::= NK_ID */ - { 175, -1 }, /* (121) table_alias ::= NK_ID */ - { 176, -1 }, /* (122) column_alias ::= NK_ID */ - { 141, -1 }, /* (123) user_name ::= NK_ID */ - { 165, -1 }, /* (124) index_name ::= NK_ID */ - { 177, -1 }, /* (125) expression ::= literal */ - { 177, -1 }, /* (126) expression ::= column_reference */ - { 177, -4 }, /* (127) expression ::= function_name NK_LP expression_list NK_RP */ - { 177, -4 }, /* (128) expression ::= function_name NK_LP NK_STAR NK_RP */ - { 177, -1 }, /* (129) expression ::= subquery */ - { 177, -3 }, /* (130) expression ::= NK_LP expression NK_RP */ - { 177, -2 }, /* (131) expression ::= NK_PLUS expression */ - { 177, -2 }, /* (132) expression ::= NK_MINUS expression */ - { 177, -3 }, /* (133) expression ::= expression NK_PLUS expression */ - { 177, -3 }, /* (134) expression ::= expression NK_MINUS expression */ - { 177, -3 }, /* (135) expression ::= expression NK_STAR expression */ - { 177, -3 }, /* (136) expression ::= expression NK_SLASH expression */ - { 177, -3 }, /* (137) expression ::= expression NK_REM expression */ - { 172, -1 }, /* (138) expression_list ::= expression */ - { 172, -3 }, /* (139) expression_list ::= expression_list NK_COMMA expression */ - { 178, -1 }, /* (140) column_reference ::= column_name */ - { 178, -3 }, /* (141) column_reference ::= table_name NK_DOT column_name */ - { 180, -3 }, /* (142) predicate ::= expression compare_op expression */ - { 180, -5 }, /* (143) predicate ::= expression BETWEEN expression AND expression */ - { 180, -6 }, /* (144) predicate ::= expression NOT BETWEEN expression AND expression */ - { 180, -3 }, /* (145) predicate ::= expression IS NULL */ - { 180, -4 }, /* (146) predicate ::= expression IS NOT NULL */ - { 180, -3 }, /* (147) predicate ::= expression in_op in_predicate_value */ - { 181, -1 }, /* (148) compare_op ::= NK_LT */ - { 181, -1 }, /* (149) compare_op ::= NK_GT */ - { 181, -1 }, /* (150) compare_op ::= NK_LE */ - { 181, -1 }, /* (151) compare_op ::= NK_GE */ - { 181, -1 }, /* (152) compare_op ::= NK_NE */ - { 181, -1 }, /* (153) compare_op ::= NK_EQ */ - { 181, -1 }, /* (154) compare_op ::= LIKE */ - { 181, -2 }, /* (155) compare_op ::= NOT LIKE */ - { 181, -1 }, /* (156) compare_op ::= MATCH */ - { 181, -1 }, /* (157) compare_op ::= NMATCH */ - { 182, -1 }, /* (158) in_op ::= IN */ - { 182, -2 }, /* (159) in_op ::= NOT IN */ - { 183, -3 }, /* (160) in_predicate_value ::= NK_LP expression_list NK_RP */ - { 184, -1 }, /* (161) boolean_value_expression ::= boolean_primary */ - { 184, -2 }, /* (162) boolean_value_expression ::= NOT boolean_primary */ - { 184, -3 }, /* (163) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 184, -3 }, /* (164) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 185, -1 }, /* (165) boolean_primary ::= predicate */ - { 185, -3 }, /* (166) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 186, -1 }, /* (167) common_expression ::= expression */ - { 186, -1 }, /* (168) common_expression ::= boolean_value_expression */ - { 187, -2 }, /* (169) from_clause ::= FROM table_reference_list */ - { 188, -1 }, /* (170) table_reference_list ::= table_reference */ - { 188, -3 }, /* (171) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 189, -1 }, /* (172) table_reference ::= table_primary */ - { 189, -1 }, /* (173) table_reference ::= joined_table */ - { 190, -2 }, /* (174) table_primary ::= table_name alias_opt */ - { 190, -4 }, /* (175) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 190, -2 }, /* (176) table_primary ::= subquery alias_opt */ - { 190, -1 }, /* (177) table_primary ::= parenthesized_joined_table */ - { 192, 0 }, /* (178) alias_opt ::= */ - { 192, -1 }, /* (179) alias_opt ::= table_alias */ - { 192, -2 }, /* (180) alias_opt ::= AS table_alias */ - { 193, -3 }, /* (181) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 193, -3 }, /* (182) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 191, -6 }, /* (183) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 194, 0 }, /* (184) join_type ::= */ - { 194, -1 }, /* (185) join_type ::= INNER */ - { 196, -9 }, /* (186) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - { 197, 0 }, /* (187) set_quantifier_opt ::= */ - { 197, -1 }, /* (188) set_quantifier_opt ::= DISTINCT */ - { 197, -1 }, /* (189) set_quantifier_opt ::= ALL */ - { 198, -1 }, /* (190) select_list ::= NK_STAR */ - { 198, -1 }, /* (191) select_list ::= select_sublist */ - { 204, -1 }, /* (192) select_sublist ::= select_item */ - { 204, -3 }, /* (193) select_sublist ::= select_sublist NK_COMMA select_item */ - { 205, -1 }, /* (194) select_item ::= common_expression */ - { 205, -2 }, /* (195) select_item ::= common_expression column_alias */ - { 205, -3 }, /* (196) select_item ::= common_expression AS column_alias */ - { 205, -3 }, /* (197) select_item ::= table_name NK_DOT NK_STAR */ - { 199, 0 }, /* (198) where_clause_opt ::= */ - { 199, -2 }, /* (199) where_clause_opt ::= WHERE search_condition */ - { 200, 0 }, /* (200) partition_by_clause_opt ::= */ - { 200, -3 }, /* (201) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 201, 0 }, /* (202) twindow_clause_opt ::= */ - { 201, -6 }, /* (203) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ - { 201, -4 }, /* (204) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ - { 201, -6 }, /* (205) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 201, -8 }, /* (206) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 169, 0 }, /* (207) sliding_opt ::= */ - { 169, -4 }, /* (208) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 206, 0 }, /* (209) fill_opt ::= */ - { 206, -4 }, /* (210) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 206, -6 }, /* (211) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 207, -1 }, /* (212) fill_mode ::= NONE */ - { 207, -1 }, /* (213) fill_mode ::= PREV */ - { 207, -1 }, /* (214) fill_mode ::= NULL */ - { 207, -1 }, /* (215) fill_mode ::= LINEAR */ - { 207, -1 }, /* (216) fill_mode ::= NEXT */ - { 202, 0 }, /* (217) group_by_clause_opt ::= */ - { 202, -3 }, /* (218) group_by_clause_opt ::= GROUP BY group_by_list */ - { 208, -1 }, /* (219) group_by_list ::= expression */ - { 208, -3 }, /* (220) group_by_list ::= group_by_list NK_COMMA expression */ - { 203, 0 }, /* (221) having_clause_opt ::= */ - { 203, -2 }, /* (222) having_clause_opt ::= HAVING search_condition */ - { 173, -4 }, /* (223) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 209, -1 }, /* (224) query_expression_body ::= query_primary */ - { 209, -4 }, /* (225) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 213, -1 }, /* (226) query_primary ::= query_specification */ - { 210, 0 }, /* (227) order_by_clause_opt ::= */ - { 210, -3 }, /* (228) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 211, 0 }, /* (229) slimit_clause_opt ::= */ - { 211, -2 }, /* (230) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 211, -4 }, /* (231) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 211, -4 }, /* (232) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 212, 0 }, /* (233) limit_clause_opt ::= */ - { 212, -2 }, /* (234) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 212, -4 }, /* (235) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 212, -4 }, /* (236) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 179, -3 }, /* (237) subquery ::= NK_LP query_expression NK_RP */ - { 195, -1 }, /* (238) search_condition ::= common_expression */ - { 214, -1 }, /* (239) sort_specification_list ::= sort_specification */ - { 214, -3 }, /* (240) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 215, -3 }, /* (241) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 216, 0 }, /* (242) ordering_specification_opt ::= */ - { 216, -1 }, /* (243) ordering_specification_opt ::= ASC */ - { 216, -1 }, /* (244) ordering_specification_opt ::= DESC */ - { 217, 0 }, /* (245) null_ordering_opt ::= */ - { 217, -2 }, /* (246) null_ordering_opt ::= NULLS FIRST */ - { 217, -2 }, /* (247) null_ordering_opt ::= NULLS LAST */ + { 141, -5 }, /* (0) cmd ::= CREATE USER user_name PASS NK_STRING */ + { 141, -5 }, /* (1) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 141, -5 }, /* (2) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ + { 141, -3 }, /* (3) cmd ::= DROP USER user_name */ + { 141, -2 }, /* (4) cmd ::= SHOW USERS */ + { 141, -3 }, /* (5) cmd ::= CREATE DNODE dnode_endpoint */ + { 141, -5 }, /* (6) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ + { 141, -3 }, /* (7) cmd ::= DROP DNODE NK_INTEGER */ + { 141, -3 }, /* (8) cmd ::= DROP DNODE dnode_endpoint */ + { 141, -2 }, /* (9) cmd ::= SHOW DNODES */ + { 143, -1 }, /* (10) dnode_endpoint ::= NK_STRING */ + { 144, -1 }, /* (11) dnode_host_name ::= NK_ID */ + { 144, -1 }, /* (12) dnode_host_name ::= NK_IPTOKEN */ + { 141, -5 }, /* (13) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 141, -5 }, /* (14) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 141, -2 }, /* (15) cmd ::= SHOW QNODES */ + { 141, -5 }, /* (16) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 141, -4 }, /* (17) cmd ::= DROP DATABASE exists_opt db_name */ + { 141, -2 }, /* (18) cmd ::= SHOW DATABASES */ + { 141, -2 }, /* (19) cmd ::= USE db_name */ + { 141, -4 }, /* (20) cmd ::= ALTER DATABASE db_name db_options */ + { 145, -3 }, /* (21) not_exists_opt ::= IF NOT EXISTS */ + { 145, 0 }, /* (22) not_exists_opt ::= */ + { 148, -2 }, /* (23) exists_opt ::= IF EXISTS */ + { 148, 0 }, /* (24) exists_opt ::= */ + { 147, 0 }, /* (25) db_options ::= */ + { 147, -3 }, /* (26) db_options ::= db_options BLOCKS NK_INTEGER */ + { 147, -3 }, /* (27) db_options ::= db_options CACHE NK_INTEGER */ + { 147, -3 }, /* (28) db_options ::= db_options CACHELAST NK_INTEGER */ + { 147, -3 }, /* (29) db_options ::= db_options COMP NK_INTEGER */ + { 147, -3 }, /* (30) db_options ::= db_options DAYS NK_INTEGER */ + { 147, -3 }, /* (31) db_options ::= db_options FSYNC NK_INTEGER */ + { 147, -3 }, /* (32) db_options ::= db_options MAXROWS NK_INTEGER */ + { 147, -3 }, /* (33) db_options ::= db_options MINROWS NK_INTEGER */ + { 147, -3 }, /* (34) db_options ::= db_options KEEP NK_INTEGER */ + { 147, -3 }, /* (35) db_options ::= db_options PRECISION NK_STRING */ + { 147, -3 }, /* (36) db_options ::= db_options QUORUM NK_INTEGER */ + { 147, -3 }, /* (37) db_options ::= db_options REPLICA NK_INTEGER */ + { 147, -3 }, /* (38) db_options ::= db_options TTL NK_INTEGER */ + { 147, -3 }, /* (39) db_options ::= db_options WAL NK_INTEGER */ + { 147, -3 }, /* (40) db_options ::= db_options VGROUPS NK_INTEGER */ + { 147, -3 }, /* (41) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 147, -3 }, /* (42) db_options ::= db_options STREAM_MODE NK_INTEGER */ + { 141, -9 }, /* (43) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 141, -3 }, /* (44) cmd ::= CREATE TABLE multi_create_clause */ + { 141, -9 }, /* (45) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 141, -3 }, /* (46) cmd ::= DROP TABLE multi_drop_clause */ + { 141, -4 }, /* (47) cmd ::= DROP STABLE exists_opt full_table_name */ + { 141, -2 }, /* (48) cmd ::= SHOW TABLES */ + { 141, -2 }, /* (49) cmd ::= SHOW STABLES */ + { 153, -1 }, /* (50) multi_create_clause ::= create_subtable_clause */ + { 153, -2 }, /* (51) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 156, -9 }, /* (52) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ + { 155, -1 }, /* (53) multi_drop_clause ::= drop_table_clause */ + { 155, -2 }, /* (54) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 159, -2 }, /* (55) drop_table_clause ::= exists_opt full_table_name */ + { 157, 0 }, /* (56) specific_tags_opt ::= */ + { 157, -3 }, /* (57) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + { 149, -1 }, /* (58) full_table_name ::= table_name */ + { 149, -3 }, /* (59) full_table_name ::= db_name NK_DOT table_name */ + { 150, -1 }, /* (60) column_def_list ::= column_def */ + { 150, -3 }, /* (61) column_def_list ::= column_def_list NK_COMMA column_def */ + { 162, -2 }, /* (62) column_def ::= column_name type_name */ + { 162, -4 }, /* (63) column_def ::= column_name type_name COMMENT NK_STRING */ + { 164, -1 }, /* (64) type_name ::= BOOL */ + { 164, -1 }, /* (65) type_name ::= TINYINT */ + { 164, -1 }, /* (66) type_name ::= SMALLINT */ + { 164, -1 }, /* (67) type_name ::= INT */ + { 164, -1 }, /* (68) type_name ::= INTEGER */ + { 164, -1 }, /* (69) type_name ::= BIGINT */ + { 164, -1 }, /* (70) type_name ::= FLOAT */ + { 164, -1 }, /* (71) type_name ::= DOUBLE */ + { 164, -4 }, /* (72) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 164, -1 }, /* (73) type_name ::= TIMESTAMP */ + { 164, -4 }, /* (74) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 164, -2 }, /* (75) type_name ::= TINYINT UNSIGNED */ + { 164, -2 }, /* (76) type_name ::= SMALLINT UNSIGNED */ + { 164, -2 }, /* (77) type_name ::= INT UNSIGNED */ + { 164, -2 }, /* (78) type_name ::= BIGINT UNSIGNED */ + { 164, -1 }, /* (79) type_name ::= JSON */ + { 164, -4 }, /* (80) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 164, -1 }, /* (81) type_name ::= MEDIUMBLOB */ + { 164, -1 }, /* (82) type_name ::= BLOB */ + { 164, -4 }, /* (83) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 164, -1 }, /* (84) type_name ::= DECIMAL */ + { 164, -4 }, /* (85) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 164, -6 }, /* (86) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 151, 0 }, /* (87) tags_def_opt ::= */ + { 151, -1 }, /* (88) tags_def_opt ::= tags_def */ + { 154, -4 }, /* (89) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 152, 0 }, /* (90) table_options ::= */ + { 152, -3 }, /* (91) table_options ::= table_options COMMENT NK_STRING */ + { 152, -3 }, /* (92) table_options ::= table_options KEEP NK_INTEGER */ + { 152, -3 }, /* (93) table_options ::= table_options TTL NK_INTEGER */ + { 152, -5 }, /* (94) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 160, -1 }, /* (95) col_name_list ::= col_name */ + { 160, -3 }, /* (96) col_name_list ::= col_name_list NK_COMMA col_name */ + { 165, -1 }, /* (97) col_name ::= column_name */ + { 141, -7 }, /* (98) cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ + { 141, -9 }, /* (99) cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ + { 141, -5 }, /* (100) cmd ::= DROP INDEX index_name ON table_name */ + { 167, 0 }, /* (101) index_options ::= */ + { 167, -9 }, /* (102) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ + { 167, -11 }, /* (103) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ + { 168, -1 }, /* (104) func_list ::= func */ + { 168, -3 }, /* (105) func_list ::= func_list NK_COMMA func */ + { 171, -4 }, /* (106) func ::= function_name NK_LP expression_list NK_RP */ + { 141, -6 }, /* (107) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ + { 141, -6 }, /* (108) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ + { 141, -4 }, /* (109) cmd ::= DROP TOPIC exists_opt topic_name */ + { 141, -2 }, /* (110) cmd ::= SHOW VGROUPS */ + { 141, -4 }, /* (111) cmd ::= SHOW db_name NK_DOT VGROUPS */ + { 141, -2 }, /* (112) cmd ::= SHOW MNODES */ + { 141, -1 }, /* (113) cmd ::= query_expression */ + { 176, -1 }, /* (114) literal ::= NK_INTEGER */ + { 176, -1 }, /* (115) literal ::= NK_FLOAT */ + { 176, -1 }, /* (116) literal ::= NK_STRING */ + { 176, -1 }, /* (117) literal ::= NK_BOOL */ + { 176, -2 }, /* (118) literal ::= TIMESTAMP NK_STRING */ + { 176, -1 }, /* (119) literal ::= duration_literal */ + { 169, -1 }, /* (120) duration_literal ::= NK_VARIABLE */ + { 158, -1 }, /* (121) literal_list ::= literal */ + { 158, -3 }, /* (122) literal_list ::= literal_list NK_COMMA literal */ + { 146, -1 }, /* (123) db_name ::= NK_ID */ + { 161, -1 }, /* (124) table_name ::= NK_ID */ + { 163, -1 }, /* (125) column_name ::= NK_ID */ + { 172, -1 }, /* (126) function_name ::= NK_ID */ + { 177, -1 }, /* (127) table_alias ::= NK_ID */ + { 178, -1 }, /* (128) column_alias ::= NK_ID */ + { 142, -1 }, /* (129) user_name ::= NK_ID */ + { 166, -1 }, /* (130) index_name ::= NK_ID */ + { 174, -1 }, /* (131) topic_name ::= NK_ID */ + { 179, -1 }, /* (132) expression ::= literal */ + { 179, -1 }, /* (133) expression ::= column_reference */ + { 179, -4 }, /* (134) expression ::= function_name NK_LP expression_list NK_RP */ + { 179, -4 }, /* (135) expression ::= function_name NK_LP NK_STAR NK_RP */ + { 179, -1 }, /* (136) expression ::= subquery */ + { 179, -3 }, /* (137) expression ::= NK_LP expression NK_RP */ + { 179, -2 }, /* (138) expression ::= NK_PLUS expression */ + { 179, -2 }, /* (139) expression ::= NK_MINUS expression */ + { 179, -3 }, /* (140) expression ::= expression NK_PLUS expression */ + { 179, -3 }, /* (141) expression ::= expression NK_MINUS expression */ + { 179, -3 }, /* (142) expression ::= expression NK_STAR expression */ + { 179, -3 }, /* (143) expression ::= expression NK_SLASH expression */ + { 179, -3 }, /* (144) expression ::= expression NK_REM expression */ + { 173, -1 }, /* (145) expression_list ::= expression */ + { 173, -3 }, /* (146) expression_list ::= expression_list NK_COMMA expression */ + { 180, -1 }, /* (147) column_reference ::= column_name */ + { 180, -3 }, /* (148) column_reference ::= table_name NK_DOT column_name */ + { 182, -3 }, /* (149) predicate ::= expression compare_op expression */ + { 182, -5 }, /* (150) predicate ::= expression BETWEEN expression AND expression */ + { 182, -6 }, /* (151) predicate ::= expression NOT BETWEEN expression AND expression */ + { 182, -3 }, /* (152) predicate ::= expression IS NULL */ + { 182, -4 }, /* (153) predicate ::= expression IS NOT NULL */ + { 182, -3 }, /* (154) predicate ::= expression in_op in_predicate_value */ + { 183, -1 }, /* (155) compare_op ::= NK_LT */ + { 183, -1 }, /* (156) compare_op ::= NK_GT */ + { 183, -1 }, /* (157) compare_op ::= NK_LE */ + { 183, -1 }, /* (158) compare_op ::= NK_GE */ + { 183, -1 }, /* (159) compare_op ::= NK_NE */ + { 183, -1 }, /* (160) compare_op ::= NK_EQ */ + { 183, -1 }, /* (161) compare_op ::= LIKE */ + { 183, -2 }, /* (162) compare_op ::= NOT LIKE */ + { 183, -1 }, /* (163) compare_op ::= MATCH */ + { 183, -1 }, /* (164) compare_op ::= NMATCH */ + { 184, -1 }, /* (165) in_op ::= IN */ + { 184, -2 }, /* (166) in_op ::= NOT IN */ + { 185, -3 }, /* (167) in_predicate_value ::= NK_LP expression_list NK_RP */ + { 186, -1 }, /* (168) boolean_value_expression ::= boolean_primary */ + { 186, -2 }, /* (169) boolean_value_expression ::= NOT boolean_primary */ + { 186, -3 }, /* (170) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 186, -3 }, /* (171) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 187, -1 }, /* (172) boolean_primary ::= predicate */ + { 187, -3 }, /* (173) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 188, -1 }, /* (174) common_expression ::= expression */ + { 188, -1 }, /* (175) common_expression ::= boolean_value_expression */ + { 189, -2 }, /* (176) from_clause ::= FROM table_reference_list */ + { 190, -1 }, /* (177) table_reference_list ::= table_reference */ + { 190, -3 }, /* (178) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 191, -1 }, /* (179) table_reference ::= table_primary */ + { 191, -1 }, /* (180) table_reference ::= joined_table */ + { 192, -2 }, /* (181) table_primary ::= table_name alias_opt */ + { 192, -4 }, /* (182) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 192, -2 }, /* (183) table_primary ::= subquery alias_opt */ + { 192, -1 }, /* (184) table_primary ::= parenthesized_joined_table */ + { 194, 0 }, /* (185) alias_opt ::= */ + { 194, -1 }, /* (186) alias_opt ::= table_alias */ + { 194, -2 }, /* (187) alias_opt ::= AS table_alias */ + { 195, -3 }, /* (188) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 195, -3 }, /* (189) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 193, -6 }, /* (190) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 196, 0 }, /* (191) join_type ::= */ + { 196, -1 }, /* (192) join_type ::= INNER */ + { 198, -9 }, /* (193) query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + { 199, 0 }, /* (194) set_quantifier_opt ::= */ + { 199, -1 }, /* (195) set_quantifier_opt ::= DISTINCT */ + { 199, -1 }, /* (196) set_quantifier_opt ::= ALL */ + { 200, -1 }, /* (197) select_list ::= NK_STAR */ + { 200, -1 }, /* (198) select_list ::= select_sublist */ + { 206, -1 }, /* (199) select_sublist ::= select_item */ + { 206, -3 }, /* (200) select_sublist ::= select_sublist NK_COMMA select_item */ + { 207, -1 }, /* (201) select_item ::= common_expression */ + { 207, -2 }, /* (202) select_item ::= common_expression column_alias */ + { 207, -3 }, /* (203) select_item ::= common_expression AS column_alias */ + { 207, -3 }, /* (204) select_item ::= table_name NK_DOT NK_STAR */ + { 201, 0 }, /* (205) where_clause_opt ::= */ + { 201, -2 }, /* (206) where_clause_opt ::= WHERE search_condition */ + { 202, 0 }, /* (207) partition_by_clause_opt ::= */ + { 202, -3 }, /* (208) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 203, 0 }, /* (209) twindow_clause_opt ::= */ + { 203, -6 }, /* (210) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ + { 203, -4 }, /* (211) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ + { 203, -6 }, /* (212) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 203, -8 }, /* (213) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 170, 0 }, /* (214) sliding_opt ::= */ + { 170, -4 }, /* (215) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 208, 0 }, /* (216) fill_opt ::= */ + { 208, -4 }, /* (217) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 208, -6 }, /* (218) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 209, -1 }, /* (219) fill_mode ::= NONE */ + { 209, -1 }, /* (220) fill_mode ::= PREV */ + { 209, -1 }, /* (221) fill_mode ::= NULL */ + { 209, -1 }, /* (222) fill_mode ::= LINEAR */ + { 209, -1 }, /* (223) fill_mode ::= NEXT */ + { 204, 0 }, /* (224) group_by_clause_opt ::= */ + { 204, -3 }, /* (225) group_by_clause_opt ::= GROUP BY group_by_list */ + { 210, -1 }, /* (226) group_by_list ::= expression */ + { 210, -3 }, /* (227) group_by_list ::= group_by_list NK_COMMA expression */ + { 205, 0 }, /* (228) having_clause_opt ::= */ + { 205, -2 }, /* (229) having_clause_opt ::= HAVING search_condition */ + { 175, -4 }, /* (230) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 211, -1 }, /* (231) query_expression_body ::= query_primary */ + { 211, -4 }, /* (232) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 215, -1 }, /* (233) query_primary ::= query_specification */ + { 212, 0 }, /* (234) order_by_clause_opt ::= */ + { 212, -3 }, /* (235) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 213, 0 }, /* (236) slimit_clause_opt ::= */ + { 213, -2 }, /* (237) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 213, -4 }, /* (238) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 213, -4 }, /* (239) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 214, 0 }, /* (240) limit_clause_opt ::= */ + { 214, -2 }, /* (241) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 214, -4 }, /* (242) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 214, -4 }, /* (243) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 181, -3 }, /* (244) subquery ::= NK_LP query_expression NK_RP */ + { 197, -1 }, /* (245) search_condition ::= common_expression */ + { 216, -1 }, /* (246) sort_specification_list ::= sort_specification */ + { 216, -3 }, /* (247) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 217, -3 }, /* (248) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 218, 0 }, /* (249) ordering_specification_opt ::= */ + { 218, -1 }, /* (250) ordering_specification_opt ::= ASC */ + { 218, -1 }, /* (251) ordering_specification_opt ::= DESC */ + { 219, 0 }, /* (252) null_ordering_opt ::= */ + { 219, -2 }, /* (253) null_ordering_opt ::= NULLS FIRST */ + { 219, -2 }, /* (254) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -1959,31 +1991,31 @@ static YYACTIONTYPE yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0); } break; case 1: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy5, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy129, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } break; case 2: /* cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy5, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy129, TSDB_ALTER_USER_PRIVILEGES, &yymsp[0].minor.yy0); } break; case 3: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy5); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy129); } break; case 4: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL); } break; case 5: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy5, NULL);} +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy129, NULL); } break; case 6: /* cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0); } break; case 7: /* cmd ::= DROP DNODE NK_INTEGER */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0);} +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; case 8: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy5);} +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy129); } break; case 9: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL); } @@ -1991,742 +2023,761 @@ static YYACTIONTYPE yy_reduce( case 10: /* dnode_endpoint ::= NK_STRING */ case 11: /* dnode_host_name ::= NK_ID */ yytestcase(yyruleno==11); case 12: /* dnode_host_name ::= NK_IPTOKEN */ yytestcase(yyruleno==12); - case 117: /* db_name ::= NK_ID */ yytestcase(yyruleno==117); - case 118: /* table_name ::= NK_ID */ yytestcase(yyruleno==118); - case 119: /* column_name ::= NK_ID */ yytestcase(yyruleno==119); - case 120: /* function_name ::= NK_ID */ yytestcase(yyruleno==120); - case 121: /* table_alias ::= NK_ID */ yytestcase(yyruleno==121); - case 122: /* column_alias ::= NK_ID */ yytestcase(yyruleno==122); - case 123: /* user_name ::= NK_ID */ yytestcase(yyruleno==123); - case 124: /* index_name ::= NK_ID */ yytestcase(yyruleno==124); -{ yylhsminor.yy5 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy5 = yylhsminor.yy5; + case 123: /* db_name ::= NK_ID */ yytestcase(yyruleno==123); + case 124: /* table_name ::= NK_ID */ yytestcase(yyruleno==124); + case 125: /* column_name ::= NK_ID */ yytestcase(yyruleno==125); + case 126: /* function_name ::= NK_ID */ yytestcase(yyruleno==126); + case 127: /* table_alias ::= NK_ID */ yytestcase(yyruleno==127); + case 128: /* column_alias ::= NK_ID */ yytestcase(yyruleno==128); + case 129: /* user_name ::= NK_ID */ yytestcase(yyruleno==129); + case 130: /* index_name ::= NK_ID */ yytestcase(yyruleno==130); + case 131: /* topic_name ::= NK_ID */ yytestcase(yyruleno==131); +{ yylhsminor.yy129 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy129 = yylhsminor.yy129; break; case 13: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ { pCxt->pRootNode = createCreateQnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; - case 14: /* cmd ::= SHOW QNODES */ + case 14: /* cmd ::= DROP QNODE ON DNODE NK_INTEGER */ +{ pCxt->pRootNode = createDropQnodeStmt(pCxt, &yymsp[0].minor.yy0); } + break; + case 15: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT, NULL); } break; - case 15: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy25, &yymsp[-1].minor.yy5, yymsp[0].minor.yy68);} + case 16: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy97, &yymsp[-1].minor.yy129, yymsp[0].minor.yy432); } break; - case 16: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy25, &yymsp[0].minor.yy5); } + case 17: /* cmd ::= DROP DATABASE exists_opt db_name */ +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy97, &yymsp[0].minor.yy129); } break; - case 17: /* cmd ::= SHOW DATABASES */ + case 18: /* cmd ::= SHOW DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL); } break; - case 18: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy5);} + case 19: /* cmd ::= USE db_name */ +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy129); } break; - case 19: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy25 = true; } + case 20: /* cmd ::= ALTER DATABASE db_name db_options */ +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy129, yymsp[0].minor.yy432); } break; - case 20: /* not_exists_opt ::= */ - case 22: /* exists_opt ::= */ yytestcase(yyruleno==22); - case 187: /* set_quantifier_opt ::= */ yytestcase(yyruleno==187); -{ yymsp[1].minor.yy25 = false; } + case 21: /* not_exists_opt ::= IF NOT EXISTS */ +{ yymsp[-2].minor.yy97 = true; } break; - case 21: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy25 = true; } + case 22: /* not_exists_opt ::= */ + case 24: /* exists_opt ::= */ yytestcase(yyruleno==24); + case 194: /* set_quantifier_opt ::= */ yytestcase(yyruleno==194); +{ yymsp[1].minor.yy97 = false; } break; - case 23: /* db_options ::= */ -{ yymsp[1].minor.yy68 = createDefaultDatabaseOptions(pCxt); } + case 23: /* exists_opt ::= IF EXISTS */ +{ yymsp[-1].minor.yy97 = true; } break; - case 24: /* db_options ::= db_options BLOCKS NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 25: /* db_options ::= */ +{ yymsp[1].minor.yy432 = createDefaultDatabaseOptions(pCxt); } break; - case 25: /* db_options ::= db_options CACHE NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 26: /* db_options ::= db_options BLOCKS NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 26: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 27: /* db_options ::= db_options CACHE NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 27: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 28: /* db_options ::= db_options CACHELAST NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 28: /* db_options ::= db_options DAYS NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 29: /* db_options ::= db_options COMP NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 29: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 30: /* db_options ::= db_options DAYS NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 30: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 31: /* db_options ::= db_options FSYNC NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 31: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 32: /* db_options ::= db_options MAXROWS NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 32: /* db_options ::= db_options KEEP NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 33: /* db_options ::= db_options MINROWS NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 33: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 34: /* db_options ::= db_options KEEP NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_KEEP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 34: /* db_options ::= db_options QUORUM NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 35: /* db_options ::= db_options PRECISION NK_STRING */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 35: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 36: /* db_options ::= db_options QUORUM NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 36: /* db_options ::= db_options TTL NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 37: /* db_options ::= db_options REPLICA NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 37: /* db_options ::= db_options WAL NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 38: /* db_options ::= db_options TTL NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 38: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 39: /* db_options ::= db_options WAL NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 39: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_SINGLESTABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 40: /* db_options ::= db_options VGROUPS NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 40: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ -{ yylhsminor.yy68 = setDatabaseOption(pCxt, yymsp[-2].minor.yy68, DB_OPTION_STREAMMODE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 41: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_SINGLESTABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 41: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - case 43: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==43); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy25, yymsp[-5].minor.yy68, yymsp[-3].minor.yy40, yymsp[-1].minor.yy40, yymsp[0].minor.yy68);} + case 42: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ +{ yylhsminor.yy432 = setDatabaseOption(pCxt, yymsp[-2].minor.yy432, DB_OPTION_STREAMMODE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 42: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy40);} + case 43: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + case 45: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==45); +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy97, yymsp[-5].minor.yy432, yymsp[-3].minor.yy24, yymsp[-1].minor.yy24, yymsp[0].minor.yy432);} break; - case 44: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy40); } + case 44: /* cmd ::= CREATE TABLE multi_create_clause */ +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy24);} break; - case 45: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy25, yymsp[0].minor.yy68); } + case 46: /* cmd ::= DROP TABLE multi_drop_clause */ +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy24); } break; - case 46: /* cmd ::= SHOW TABLES */ + case 47: /* cmd ::= DROP STABLE exists_opt full_table_name */ +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy97, yymsp[0].minor.yy432); } + break; + case 48: /* cmd ::= SHOW TABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, NULL); } break; - case 47: /* cmd ::= SHOW STABLES */ + case 49: /* cmd ::= SHOW STABLES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, NULL); } break; - case 48: /* multi_create_clause ::= create_subtable_clause */ - case 51: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==51); - case 58: /* column_def_list ::= column_def */ yytestcase(yyruleno==58); - case 93: /* col_name_list ::= col_name */ yytestcase(yyruleno==93); - case 101: /* func_list ::= func */ yytestcase(yyruleno==101); - case 192: /* select_sublist ::= select_item */ yytestcase(yyruleno==192); - case 239: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==239); -{ yylhsminor.yy40 = createNodeList(pCxt, yymsp[0].minor.yy68); } - yymsp[0].minor.yy40 = yylhsminor.yy40; + case 50: /* multi_create_clause ::= create_subtable_clause */ + case 53: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==53); + case 60: /* column_def_list ::= column_def */ yytestcase(yyruleno==60); + case 95: /* col_name_list ::= col_name */ yytestcase(yyruleno==95); + case 104: /* func_list ::= func */ yytestcase(yyruleno==104); + case 199: /* select_sublist ::= select_item */ yytestcase(yyruleno==199); + case 246: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==246); +{ yylhsminor.yy24 = createNodeList(pCxt, yymsp[0].minor.yy432); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 49: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 52: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==52); -{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-1].minor.yy40, yymsp[0].minor.yy68); } - yymsp[-1].minor.yy40 = yylhsminor.yy40; + case 51: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ + case 54: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==54); +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-1].minor.yy24, yymsp[0].minor.yy432); } + yymsp[-1].minor.yy24 = yylhsminor.yy24; break; - case 50: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ -{ yylhsminor.yy68 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy25, yymsp[-7].minor.yy68, yymsp[-5].minor.yy68, yymsp[-4].minor.yy40, yymsp[-1].minor.yy40); } - yymsp[-8].minor.yy68 = yylhsminor.yy68; + case 52: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ +{ yylhsminor.yy432 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy97, yymsp[-7].minor.yy432, yymsp[-5].minor.yy432, yymsp[-4].minor.yy24, yymsp[-1].minor.yy24); } + yymsp[-8].minor.yy432 = yylhsminor.yy432; break; - case 53: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy68 = createDropTableClause(pCxt, yymsp[-1].minor.yy25, yymsp[0].minor.yy68); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + case 55: /* drop_table_clause ::= exists_opt full_table_name */ +{ yylhsminor.yy432 = createDropTableClause(pCxt, yymsp[-1].minor.yy97, yymsp[0].minor.yy432); } + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 54: /* specific_tags_opt ::= */ - case 85: /* tags_def_opt ::= */ yytestcase(yyruleno==85); - case 200: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==200); - case 217: /* group_by_clause_opt ::= */ yytestcase(yyruleno==217); - case 227: /* order_by_clause_opt ::= */ yytestcase(yyruleno==227); -{ yymsp[1].minor.yy40 = NULL; } + case 56: /* specific_tags_opt ::= */ + case 87: /* tags_def_opt ::= */ yytestcase(yyruleno==87); + case 207: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==207); + case 224: /* group_by_clause_opt ::= */ yytestcase(yyruleno==224); + case 234: /* order_by_clause_opt ::= */ yytestcase(yyruleno==234); +{ yymsp[1].minor.yy24 = NULL; } break; - case 55: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy40 = yymsp[-1].minor.yy40; } + case 57: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ +{ yymsp[-2].minor.yy24 = yymsp[-1].minor.yy24; } break; - case 56: /* full_table_name ::= table_name */ -{ yylhsminor.yy68 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy5, NULL); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 58: /* full_table_name ::= table_name */ +{ yylhsminor.yy432 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy129, NULL); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 57: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy68 = createRealTableNode(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy5, NULL); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 59: /* full_table_name ::= db_name NK_DOT table_name */ +{ yylhsminor.yy432 = createRealTableNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129, NULL); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 59: /* column_def_list ::= column_def_list NK_COMMA column_def */ - case 94: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==94); - case 102: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==102); - case 193: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==193); - case 240: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==240); -{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-2].minor.yy40, yymsp[0].minor.yy68); } - yymsp[-2].minor.yy40 = yylhsminor.yy40; + case 61: /* column_def_list ::= column_def_list NK_COMMA column_def */ + case 96: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==96); + case 105: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==105); + case 200: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==200); + case 247: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==247); +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, yymsp[0].minor.yy432); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 60: /* column_def ::= column_name type_name */ -{ yylhsminor.yy68 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy5, yymsp[0].minor.yy372, NULL); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + case 62: /* column_def ::= column_name type_name */ +{ yylhsminor.yy432 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy129, yymsp[0].minor.yy224, NULL); } + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 61: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy68 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy5, yymsp[-2].minor.yy372, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + case 63: /* column_def ::= column_name type_name COMMENT NK_STRING */ +{ yylhsminor.yy432 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-2].minor.yy224, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy432 = yylhsminor.yy432; break; - case 62: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_BOOL); } + case 64: /* type_name ::= BOOL */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_BOOL); } break; - case 63: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_TINYINT); } + case 65: /* type_name ::= TINYINT */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; - case 64: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_SMALLINT); } + case 66: /* type_name ::= SMALLINT */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; - case 65: /* type_name ::= INT */ - case 66: /* type_name ::= INTEGER */ yytestcase(yyruleno==66); -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_INT); } + case 67: /* type_name ::= INT */ + case 68: /* type_name ::= INTEGER */ yytestcase(yyruleno==68); +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_INT); } break; - case 67: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_BIGINT); } + case 69: /* type_name ::= BIGINT */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; - case 68: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_FLOAT); } + case 70: /* type_name ::= FLOAT */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; - case 69: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_DOUBLE); } + case 71: /* type_name ::= DOUBLE */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; - case 70: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy372 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } + case 72: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy224 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; - case 71: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } + case 73: /* type_name ::= TIMESTAMP */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; - case 72: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy372 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } + case 74: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy224 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; - case 73: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy372 = createDataType(TSDB_DATA_TYPE_UTINYINT); } + case 75: /* type_name ::= TINYINT UNSIGNED */ +{ yymsp[-1].minor.yy224 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; - case 74: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy372 = createDataType(TSDB_DATA_TYPE_USMALLINT); } + case 76: /* type_name ::= SMALLINT UNSIGNED */ +{ yymsp[-1].minor.yy224 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; - case 75: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy372 = createDataType(TSDB_DATA_TYPE_UINT); } + case 77: /* type_name ::= INT UNSIGNED */ +{ yymsp[-1].minor.yy224 = createDataType(TSDB_DATA_TYPE_UINT); } break; - case 76: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy372 = createDataType(TSDB_DATA_TYPE_UBIGINT); } + case 78: /* type_name ::= BIGINT UNSIGNED */ +{ yymsp[-1].minor.yy224 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; - case 77: /* type_name ::= JSON */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_JSON); } + case 79: /* type_name ::= JSON */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_JSON); } break; - case 78: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy372 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } + case 80: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy224 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; - case 79: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } + case 81: /* type_name ::= MEDIUMBLOB */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; - case 80: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_BLOB); } + case 82: /* type_name ::= BLOB */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_BLOB); } break; - case 81: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy372 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } + case 83: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy224 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; - case 82: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy372 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 84: /* type_name ::= DECIMAL */ +{ yymsp[0].minor.yy224 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 83: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy372 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 85: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy224 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 84: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy372 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 86: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy224 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 86: /* tags_def_opt ::= tags_def */ - case 191: /* select_list ::= select_sublist */ yytestcase(yyruleno==191); -{ yylhsminor.yy40 = yymsp[0].minor.yy40; } - yymsp[0].minor.yy40 = yylhsminor.yy40; + case 88: /* tags_def_opt ::= tags_def */ + case 198: /* select_list ::= select_sublist */ yytestcase(yyruleno==198); +{ yylhsminor.yy24 = yymsp[0].minor.yy24; } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 87: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy40 = yymsp[-1].minor.yy40; } + case 89: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ +{ yymsp[-3].minor.yy24 = yymsp[-1].minor.yy24; } break; - case 88: /* table_options ::= */ -{ yymsp[1].minor.yy68 = createDefaultTableOptions(pCxt);} + case 90: /* table_options ::= */ +{ yymsp[1].minor.yy432 = createDefaultTableOptions(pCxt);} break; - case 89: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy68 = setTableOption(pCxt, yymsp[-2].minor.yy68, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 91: /* table_options ::= table_options COMMENT NK_STRING */ +{ yylhsminor.yy432 = setTableOption(pCxt, yymsp[-2].minor.yy432, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 90: /* table_options ::= table_options KEEP NK_INTEGER */ -{ yylhsminor.yy68 = setTableOption(pCxt, yymsp[-2].minor.yy68, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 92: /* table_options ::= table_options KEEP NK_INTEGER */ +{ yylhsminor.yy432 = setTableOption(pCxt, yymsp[-2].minor.yy432, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 91: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy68 = setTableOption(pCxt, yymsp[-2].minor.yy68, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 93: /* table_options ::= table_options TTL NK_INTEGER */ +{ yylhsminor.yy432 = setTableOption(pCxt, yymsp[-2].minor.yy432, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 92: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy68 = setTableSmaOption(pCxt, yymsp[-4].minor.yy68, yymsp[-1].minor.yy40); } - yymsp[-4].minor.yy68 = yylhsminor.yy68; + case 94: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ +{ yylhsminor.yy432 = setTableSmaOption(pCxt, yymsp[-4].minor.yy432, yymsp[-1].minor.yy24); } + yymsp[-4].minor.yy432 = yylhsminor.yy432; break; - case 95: /* col_name ::= column_name */ -{ yylhsminor.yy68 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy5); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 97: /* col_name ::= column_name */ +{ yylhsminor.yy432 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy129); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 96: /* cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &yymsp[-3].minor.yy5, &yymsp[-1].minor.yy5, NULL, yymsp[0].minor.yy68); } + case 98: /* cmd ::= CREATE SMA INDEX index_name ON table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, &yymsp[-3].minor.yy129, &yymsp[-1].minor.yy129, NULL, yymsp[0].minor.yy432); } break; - case 97: /* cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &yymsp[-5].minor.yy5, &yymsp[-3].minor.yy5, yymsp[-1].minor.yy40, NULL); } + case 99: /* cmd ::= CREATE FULLTEXT INDEX index_name ON table_name NK_LP col_name_list NK_RP */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, &yymsp[-5].minor.yy129, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy24, NULL); } break; - case 98: /* index_options ::= */ - case 198: /* where_clause_opt ::= */ yytestcase(yyruleno==198); - case 202: /* twindow_clause_opt ::= */ yytestcase(yyruleno==202); - case 207: /* sliding_opt ::= */ yytestcase(yyruleno==207); - case 209: /* fill_opt ::= */ yytestcase(yyruleno==209); - case 221: /* having_clause_opt ::= */ yytestcase(yyruleno==221); - case 229: /* slimit_clause_opt ::= */ yytestcase(yyruleno==229); - case 233: /* limit_clause_opt ::= */ yytestcase(yyruleno==233); -{ yymsp[1].minor.yy68 = NULL; } + case 100: /* cmd ::= DROP INDEX index_name ON table_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129); } break; - case 99: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ -{ yymsp[-8].minor.yy68 = createIndexOption(pCxt, yymsp[-6].minor.yy40, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), NULL, yymsp[0].minor.yy68); } + case 101: /* index_options ::= */ + case 205: /* where_clause_opt ::= */ yytestcase(yyruleno==205); + case 209: /* twindow_clause_opt ::= */ yytestcase(yyruleno==209); + case 214: /* sliding_opt ::= */ yytestcase(yyruleno==214); + case 216: /* fill_opt ::= */ yytestcase(yyruleno==216); + case 228: /* having_clause_opt ::= */ yytestcase(yyruleno==228); + case 236: /* slimit_clause_opt ::= */ yytestcase(yyruleno==236); + case 240: /* limit_clause_opt ::= */ yytestcase(yyruleno==240); +{ yymsp[1].minor.yy432 = NULL; } break; - case 100: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ -{ yymsp[-10].minor.yy68 = createIndexOption(pCxt, yymsp[-8].minor.yy40, releaseRawExprNode(pCxt, yymsp[-4].minor.yy68), releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), yymsp[0].minor.yy68); } + case 102: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ +{ yymsp[-8].minor.yy432 = createIndexOption(pCxt, yymsp[-6].minor.yy24, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), NULL, yymsp[0].minor.yy432); } break; - case 103: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy68 = createFunctionNode(pCxt, &yymsp[-3].minor.yy5, yymsp[-1].minor.yy40); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + case 103: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ +{ yymsp[-10].minor.yy432 = createIndexOption(pCxt, yymsp[-8].minor.yy24, releaseRawExprNode(pCxt, yymsp[-4].minor.yy432), releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), yymsp[0].minor.yy432); } break; - case 104: /* cmd ::= SHOW VGROUPS */ + case 106: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy432 = createFunctionNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy24); } + yymsp[-3].minor.yy432 = yylhsminor.yy432; + break; + case 107: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy97, &yymsp[-2].minor.yy129, yymsp[0].minor.yy432, NULL); } + break; + case 108: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy97, &yymsp[-2].minor.yy129, NULL, &yymsp[0].minor.yy129); } + break; + case 109: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy97, &yymsp[0].minor.yy129); } + break; + case 110: /* cmd ::= SHOW VGROUPS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, NULL); } break; - case 105: /* cmd ::= SHOW db_name NK_DOT VGROUPS */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &yymsp[-2].minor.yy5); } + case 111: /* cmd ::= SHOW db_name NK_DOT VGROUPS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, &yymsp[-2].minor.yy129); } break; - case 106: /* cmd ::= SHOW MNODES */ + case 112: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL); } break; - case 107: /* cmd ::= query_expression */ -{ pCxt->pRootNode = yymsp[0].minor.yy68; } + case 113: /* cmd ::= query_expression */ +{ pCxt->pRootNode = yymsp[0].minor.yy432; } break; - case 108: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 114: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 109: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 115: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 110: /* literal ::= NK_STRING */ -{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 116: /* literal ::= NK_STRING */ +{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 111: /* literal ::= NK_BOOL */ -{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 117: /* literal ::= NK_BOOL */ +{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 112: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + case 118: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 113: /* literal ::= duration_literal */ - case 125: /* expression ::= literal */ yytestcase(yyruleno==125); - case 126: /* expression ::= column_reference */ yytestcase(yyruleno==126); - case 129: /* expression ::= subquery */ yytestcase(yyruleno==129); - case 161: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==161); - case 165: /* boolean_primary ::= predicate */ yytestcase(yyruleno==165); - case 167: /* common_expression ::= expression */ yytestcase(yyruleno==167); - case 168: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==168); - case 170: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==170); - case 172: /* table_reference ::= table_primary */ yytestcase(yyruleno==172); - case 173: /* table_reference ::= joined_table */ yytestcase(yyruleno==173); - case 177: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==177); - case 224: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==224); - case 226: /* query_primary ::= query_specification */ yytestcase(yyruleno==226); -{ yylhsminor.yy68 = yymsp[0].minor.yy68; } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 119: /* literal ::= duration_literal */ + case 132: /* expression ::= literal */ yytestcase(yyruleno==132); + case 133: /* expression ::= column_reference */ yytestcase(yyruleno==133); + case 136: /* expression ::= subquery */ yytestcase(yyruleno==136); + case 168: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==168); + case 172: /* boolean_primary ::= predicate */ yytestcase(yyruleno==172); + case 174: /* common_expression ::= expression */ yytestcase(yyruleno==174); + case 175: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==175); + case 177: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==177); + case 179: /* table_reference ::= table_primary */ yytestcase(yyruleno==179); + case 180: /* table_reference ::= joined_table */ yytestcase(yyruleno==180); + case 184: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==184); + case 231: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==231); + case 233: /* query_primary ::= query_specification */ yytestcase(yyruleno==233); +{ yylhsminor.yy432 = yymsp[0].minor.yy432; } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 114: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 120: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 115: /* literal_list ::= literal */ - case 138: /* expression_list ::= expression */ yytestcase(yyruleno==138); -{ yylhsminor.yy40 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy68)); } - yymsp[0].minor.yy40 = yylhsminor.yy40; + case 121: /* literal_list ::= literal */ + case 145: /* expression_list ::= expression */ yytestcase(yyruleno==145); +{ yylhsminor.yy24 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy432)); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 116: /* literal_list ::= literal_list NK_COMMA literal */ - case 139: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==139); -{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-2].minor.yy40, releaseRawExprNode(pCxt, yymsp[0].minor.yy68)); } - yymsp[-2].minor.yy40 = yylhsminor.yy40; + case 122: /* literal_list ::= literal_list NK_COMMA literal */ + case 146: /* expression_list ::= expression_list NK_COMMA expression */ yytestcase(yyruleno==146); +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, releaseRawExprNode(pCxt, yymsp[0].minor.yy432)); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 127: /* expression ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy5, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy5, yymsp[-1].minor.yy40)); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + case 134: /* expression ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy129, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy24)); } + yymsp[-3].minor.yy432 = yylhsminor.yy432; break; - case 128: /* expression ::= function_name NK_LP NK_STAR NK_RP */ -{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy5, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy5, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + case 135: /* expression ::= function_name NK_LP NK_STAR NK_RP */ +{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy129, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy129, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } + yymsp[-3].minor.yy432 = yylhsminor.yy432; break; - case 130: /* expression ::= NK_LP expression NK_RP */ - case 166: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==166); -{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy68)); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 137: /* expression ::= NK_LP expression NK_RP */ + case 173: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==173); +{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy432)); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 131: /* expression ::= NK_PLUS expression */ + case 138: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy68)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy432)); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 132: /* expression ::= NK_MINUS expression */ + case 139: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy68), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy432), NULL)); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 133: /* expression ::= expression NK_PLUS expression */ + case 140: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 134: /* expression ::= expression NK_MINUS expression */ + case 141: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 135: /* expression ::= expression NK_STAR expression */ + case 142: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 136: /* expression ::= expression NK_SLASH expression */ + case 143: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 137: /* expression ::= expression NK_REM expression */ + case 144: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 140: /* column_reference ::= column_name */ -{ yylhsminor.yy68 = createRawExprNode(pCxt, &yymsp[0].minor.yy5, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy5)); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 147: /* column_reference ::= column_name */ +{ yylhsminor.yy432 = createRawExprNode(pCxt, &yymsp[0].minor.yy129, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy129)); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 141: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy5, createColumnNode(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy5)); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 148: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129, createColumnNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129)); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 142: /* predicate ::= expression compare_op expression */ - case 147: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==147); + case 149: /* predicate ::= expression compare_op expression */ + case 154: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==154); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy416, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy260, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 143: /* predicate ::= expression BETWEEN expression AND expression */ + case 150: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy68), releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy432), releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-4].minor.yy68 = yylhsminor.yy68; + yymsp[-4].minor.yy432 = yylhsminor.yy432; break; - case 144: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 151: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[-5].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[-5].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-5].minor.yy68 = yylhsminor.yy68; + yymsp[-5].minor.yy432 = yylhsminor.yy432; break; - case 145: /* predicate ::= expression IS NULL */ + case 152: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), NULL)); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 146: /* predicate ::= expression IS NOT NULL */ + case 153: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy68), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy432), NULL)); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + yymsp[-3].minor.yy432 = yylhsminor.yy432; break; - case 148: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy416 = OP_TYPE_LOWER_THAN; } + case 155: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy260 = OP_TYPE_LOWER_THAN; } break; - case 149: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy416 = OP_TYPE_GREATER_THAN; } + case 156: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy260 = OP_TYPE_GREATER_THAN; } break; - case 150: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy416 = OP_TYPE_LOWER_EQUAL; } + case 157: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy260 = OP_TYPE_LOWER_EQUAL; } break; - case 151: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy416 = OP_TYPE_GREATER_EQUAL; } + case 158: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy260 = OP_TYPE_GREATER_EQUAL; } break; - case 152: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy416 = OP_TYPE_NOT_EQUAL; } + case 159: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy260 = OP_TYPE_NOT_EQUAL; } break; - case 153: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy416 = OP_TYPE_EQUAL; } + case 160: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy260 = OP_TYPE_EQUAL; } break; - case 154: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy416 = OP_TYPE_LIKE; } + case 161: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy260 = OP_TYPE_LIKE; } break; - case 155: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy416 = OP_TYPE_NOT_LIKE; } + case 162: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy260 = OP_TYPE_NOT_LIKE; } break; - case 156: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy416 = OP_TYPE_MATCH; } + case 163: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy260 = OP_TYPE_MATCH; } break; - case 157: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy416 = OP_TYPE_NMATCH; } + case 164: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy260 = OP_TYPE_NMATCH; } break; - case 158: /* in_op ::= IN */ -{ yymsp[0].minor.yy416 = OP_TYPE_IN; } + case 165: /* in_op ::= IN */ +{ yymsp[0].minor.yy260 = OP_TYPE_IN; } break; - case 159: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy416 = OP_TYPE_NOT_IN; } + case 166: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy260 = OP_TYPE_NOT_IN; } break; - case 160: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy40)); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 167: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy24)); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 162: /* boolean_value_expression ::= NOT boolean_primary */ + case 169: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy68), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy432), NULL)); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 163: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 170: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 164: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 171: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy68); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy432); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 169: /* from_clause ::= FROM table_reference_list */ - case 199: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==199); - case 222: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==222); -{ yymsp[-1].minor.yy68 = yymsp[0].minor.yy68; } + case 176: /* from_clause ::= FROM table_reference_list */ + case 206: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==206); + case 229: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==229); +{ yymsp[-1].minor.yy432 = yymsp[0].minor.yy432; } break; - case 171: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy68 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy68, yymsp[0].minor.yy68, NULL); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 178: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy432 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy432, yymsp[0].minor.yy432, NULL); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 174: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy68 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy5, &yymsp[0].minor.yy5); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + case 181: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy432 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy129, &yymsp[0].minor.yy129); } + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 175: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy68 = createRealTableNode(pCxt, &yymsp[-3].minor.yy5, &yymsp[-1].minor.yy5, &yymsp[0].minor.yy5); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + case 182: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy432 = createRealTableNode(pCxt, &yymsp[-3].minor.yy129, &yymsp[-1].minor.yy129, &yymsp[0].minor.yy129); } + yymsp[-3].minor.yy432 = yylhsminor.yy432; break; - case 176: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy68 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy68), &yymsp[0].minor.yy5); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + case 183: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy432 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy432), &yymsp[0].minor.yy129); } + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 178: /* alias_opt ::= */ -{ yymsp[1].minor.yy5 = nil_token; } + case 185: /* alias_opt ::= */ +{ yymsp[1].minor.yy129 = nil_token; } break; - case 179: /* alias_opt ::= table_alias */ -{ yylhsminor.yy5 = yymsp[0].minor.yy5; } - yymsp[0].minor.yy5 = yylhsminor.yy5; + case 186: /* alias_opt ::= table_alias */ +{ yylhsminor.yy129 = yymsp[0].minor.yy129; } + yymsp[0].minor.yy129 = yylhsminor.yy129; break; - case 180: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy5 = yymsp[0].minor.yy5; } + case 187: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy129 = yymsp[0].minor.yy129; } break; - case 181: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 182: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==182); -{ yymsp[-2].minor.yy68 = yymsp[-1].minor.yy68; } + case 188: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 189: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==189); +{ yymsp[-2].minor.yy432 = yymsp[-1].minor.yy432; } break; - case 183: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy68 = createJoinTableNode(pCxt, yymsp[-4].minor.yy92, yymsp[-5].minor.yy68, yymsp[-2].minor.yy68, yymsp[0].minor.yy68); } - yymsp[-5].minor.yy68 = yylhsminor.yy68; + case 190: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy432 = createJoinTableNode(pCxt, yymsp[-4].minor.yy332, yymsp[-5].minor.yy432, yymsp[-2].minor.yy432, yymsp[0].minor.yy432); } + yymsp[-5].minor.yy432 = yylhsminor.yy432; break; - case 184: /* join_type ::= */ -{ yymsp[1].minor.yy92 = JOIN_TYPE_INNER; } + case 191: /* join_type ::= */ +{ yymsp[1].minor.yy332 = JOIN_TYPE_INNER; } break; - case 185: /* join_type ::= INNER */ -{ yymsp[0].minor.yy92 = JOIN_TYPE_INNER; } + case 192: /* join_type ::= INNER */ +{ yymsp[0].minor.yy332 = JOIN_TYPE_INNER; } break; - case 186: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 193: /* query_specification ::= SELECT set_quantifier_opt select_list from_clause where_clause_opt partition_by_clause_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ { - yymsp[-8].minor.yy68 = createSelectStmt(pCxt, yymsp[-7].minor.yy25, yymsp[-6].minor.yy40, yymsp[-5].minor.yy68); - yymsp[-8].minor.yy68 = addWhereClause(pCxt, yymsp[-8].minor.yy68, yymsp[-4].minor.yy68); - yymsp[-8].minor.yy68 = addPartitionByClause(pCxt, yymsp[-8].minor.yy68, yymsp[-3].minor.yy40); - yymsp[-8].minor.yy68 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy68, yymsp[-2].minor.yy68); - yymsp[-8].minor.yy68 = addGroupByClause(pCxt, yymsp[-8].minor.yy68, yymsp[-1].minor.yy40); - yymsp[-8].minor.yy68 = addHavingClause(pCxt, yymsp[-8].minor.yy68, yymsp[0].minor.yy68); + yymsp[-8].minor.yy432 = createSelectStmt(pCxt, yymsp[-7].minor.yy97, yymsp[-6].minor.yy24, yymsp[-5].minor.yy432); + yymsp[-8].minor.yy432 = addWhereClause(pCxt, yymsp[-8].minor.yy432, yymsp[-4].minor.yy432); + yymsp[-8].minor.yy432 = addPartitionByClause(pCxt, yymsp[-8].minor.yy432, yymsp[-3].minor.yy24); + yymsp[-8].minor.yy432 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy432, yymsp[-2].minor.yy432); + yymsp[-8].minor.yy432 = addGroupByClause(pCxt, yymsp[-8].minor.yy432, yymsp[-1].minor.yy24); + yymsp[-8].minor.yy432 = addHavingClause(pCxt, yymsp[-8].minor.yy432, yymsp[0].minor.yy432); } break; - case 188: /* set_quantifier_opt ::= DISTINCT */ -{ yymsp[0].minor.yy25 = true; } + case 195: /* set_quantifier_opt ::= DISTINCT */ +{ yymsp[0].minor.yy97 = true; } break; - case 189: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy25 = false; } + case 196: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy97 = false; } break; - case 190: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy40 = NULL; } + case 197: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy24 = NULL; } break; - case 194: /* select_item ::= common_expression */ + case 201: /* select_item ::= common_expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy68); - yylhsminor.yy68 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy68), &t); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy432); + yylhsminor.yy432 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy432), &t); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 195: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy68 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy68), &yymsp[0].minor.yy5); } - yymsp[-1].minor.yy68 = yylhsminor.yy68; + case 202: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy432 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy432), &yymsp[0].minor.yy129); } + yymsp[-1].minor.yy432 = yylhsminor.yy432; break; - case 196: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy68 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), &yymsp[0].minor.yy5); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 203: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy432 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), &yymsp[0].minor.yy129); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 197: /* select_item ::= table_name NK_DOT NK_STAR */ -{ yylhsminor.yy68 = createColumnNode(pCxt, &yymsp[-2].minor.yy5, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 204: /* select_item ::= table_name NK_DOT NK_STAR */ +{ yylhsminor.yy432 = createColumnNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 201: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 218: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==218); - case 228: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==228); -{ yymsp[-2].minor.yy40 = yymsp[0].minor.yy40; } + case 208: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 225: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==225); + case 235: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==235); +{ yymsp[-2].minor.yy24 = yymsp[0].minor.yy24; } break; - case 203: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy68 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy68), &yymsp[-1].minor.yy0); } + case 210: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy432 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy432), &yymsp[-1].minor.yy0); } break; - case 204: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ -{ yymsp[-3].minor.yy68 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy68)); } + case 211: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ +{ yymsp[-3].minor.yy432 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy432)); } break; - case 205: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy68 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy68), NULL, yymsp[-1].minor.yy68, yymsp[0].minor.yy68); } + case 212: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy432 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy432), NULL, yymsp[-1].minor.yy432, yymsp[0].minor.yy432); } break; - case 206: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy68 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy68), releaseRawExprNode(pCxt, yymsp[-3].minor.yy68), yymsp[-1].minor.yy68, yymsp[0].minor.yy68); } + case 213: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy432 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy432), releaseRawExprNode(pCxt, yymsp[-3].minor.yy432), yymsp[-1].minor.yy432, yymsp[0].minor.yy432); } break; - case 208: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ -{ yymsp[-3].minor.yy68 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy68); } + case 215: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ +{ yymsp[-3].minor.yy432 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy432); } break; - case 210: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy68 = createFillNode(pCxt, yymsp[-1].minor.yy94, NULL); } + case 217: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy432 = createFillNode(pCxt, yymsp[-1].minor.yy294, NULL); } break; - case 211: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy68 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy40)); } + case 218: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy432 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy24)); } break; - case 212: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy94 = FILL_MODE_NONE; } + case 219: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy294 = FILL_MODE_NONE; } break; - case 213: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy94 = FILL_MODE_PREV; } + case 220: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy294 = FILL_MODE_PREV; } break; - case 214: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy94 = FILL_MODE_NULL; } + case 221: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy294 = FILL_MODE_NULL; } break; - case 215: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy94 = FILL_MODE_LINEAR; } + case 222: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy294 = FILL_MODE_LINEAR; } break; - case 216: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy94 = FILL_MODE_NEXT; } + case 223: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy294 = FILL_MODE_NEXT; } break; - case 219: /* group_by_list ::= expression */ -{ yylhsminor.yy40 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[0].minor.yy40 = yylhsminor.yy40; + case 226: /* group_by_list ::= expression */ +{ yylhsminor.yy24 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 220: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy40 = addNodeToList(pCxt, yymsp[-2].minor.yy40, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy68))); } - yymsp[-2].minor.yy40 = yylhsminor.yy40; + case 227: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy432))); } + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 223: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 230: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy68 = addOrderByClause(pCxt, yymsp[-3].minor.yy68, yymsp[-2].minor.yy40); - yylhsminor.yy68 = addSlimitClause(pCxt, yylhsminor.yy68, yymsp[-1].minor.yy68); - yylhsminor.yy68 = addLimitClause(pCxt, yylhsminor.yy68, yymsp[0].minor.yy68); + yylhsminor.yy432 = addOrderByClause(pCxt, yymsp[-3].minor.yy432, yymsp[-2].minor.yy24); + yylhsminor.yy432 = addSlimitClause(pCxt, yylhsminor.yy432, yymsp[-1].minor.yy432); + yylhsminor.yy432 = addLimitClause(pCxt, yylhsminor.yy432, yymsp[0].minor.yy432); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + yymsp[-3].minor.yy432 = yylhsminor.yy432; break; - case 225: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy68 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy68, yymsp[0].minor.yy68); } - yymsp[-3].minor.yy68 = yylhsminor.yy68; + case 232: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy432 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy432, yymsp[0].minor.yy432); } + yymsp[-3].minor.yy432 = yylhsminor.yy432; break; - case 230: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 234: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==234); -{ yymsp[-1].minor.yy68 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 237: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 241: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==241); +{ yymsp[-1].minor.yy432 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 231: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 235: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==235); -{ yymsp[-3].minor.yy68 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 238: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 242: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==242); +{ yymsp[-3].minor.yy432 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 232: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 236: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==236); -{ yymsp[-3].minor.yy68 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 239: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 243: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==243); +{ yymsp[-3].minor.yy432 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 237: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy68 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy68); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 244: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy432 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy432); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 238: /* search_condition ::= common_expression */ -{ yylhsminor.yy68 = releaseRawExprNode(pCxt, yymsp[0].minor.yy68); } - yymsp[0].minor.yy68 = yylhsminor.yy68; + case 245: /* search_condition ::= common_expression */ +{ yylhsminor.yy432 = releaseRawExprNode(pCxt, yymsp[0].minor.yy432); } + yymsp[0].minor.yy432 = yylhsminor.yy432; break; - case 241: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy68 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy68), yymsp[-1].minor.yy54, yymsp[0].minor.yy53); } - yymsp[-2].minor.yy68 = yylhsminor.yy68; + case 248: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy432 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy432), yymsp[-1].minor.yy378, yymsp[0].minor.yy257); } + yymsp[-2].minor.yy432 = yylhsminor.yy432; break; - case 242: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy54 = ORDER_ASC; } + case 249: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy378 = ORDER_ASC; } break; - case 243: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy54 = ORDER_ASC; } + case 250: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy378 = ORDER_ASC; } break; - case 244: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy54 = ORDER_DESC; } + case 251: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy378 = ORDER_DESC; } break; - case 245: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy53 = NULL_ORDER_DEFAULT; } + case 252: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy257 = NULL_ORDER_DEFAULT; } break; - case 246: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy53 = NULL_ORDER_FIRST; } + case 253: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy257 = NULL_ORDER_FIRST; } break; - case 247: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy53 = NULL_ORDER_LAST; } + case 254: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy257 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/parser/test/parserAstTest.cpp b/source/libs/parser/test/parserAstTest.cpp index 259c4712ba..f4c1bde478 100644 --- a/source/libs/parser/test/parserAstTest.cpp +++ b/source/libs/parser/test/parserAstTest.cpp @@ -340,6 +340,23 @@ TEST_F(ParserTest, createDatabase) { ASSERT_TRUE(run()); } +TEST_F(ParserTest, alterDatabase) { + setDatabase("root", "test"); + + bind("alter database wxy_db BLOCKS 200"); + ASSERT_TRUE(run()); + + bind("alter database wxy_db " + "BLOCKS 200 " + "CACHELAST 1 " + "FSYNC 200 " + "KEEP 200 " + "QUORUM 2 " + "WAL 1 " + ); + ASSERT_TRUE(run()); +} + TEST_F(ParserTest, showDatabase) { setDatabase("root", "test"); @@ -406,9 +423,49 @@ TEST_F(ParserTest, createSmaIndex) { ASSERT_TRUE(run()); } +TEST_F(ParserTest, dropIndex) { + setDatabase("root", "test"); + + bind("drop index index1 on t1"); + ASSERT_TRUE(run()); +} + TEST_F(ParserTest, createQnode) { setDatabase("root", "test"); bind("create qnode on dnode 1"); ASSERT_TRUE(run()); } + +TEST_F(ParserTest, dropQnode) { + setDatabase("root", "test"); + + bind("drop qnode on dnode 1"); + ASSERT_TRUE(run()); +} + +TEST_F(ParserTest, createTopic) { + setDatabase("root", "test"); + + bind("create topic tp1 as select * from t1"); + ASSERT_TRUE(run()); + + bind("create topic if not exists tp1 as select * from t1"); + ASSERT_TRUE(run()); + + bind("create topic tp1 as test"); + ASSERT_TRUE(run()); + + bind("create topic if not exists tp1 as test"); + ASSERT_TRUE(run()); +} + +TEST_F(ParserTest, dropTopic) { + setDatabase("root", "test"); + + bind("drop topic tp1"); + ASSERT_TRUE(run()); + + bind("drop topic if exists tp1"); + ASSERT_TRUE(run()); +} From 4046173c48d05f3a6f849ef5443dacb6a7cbc7b9 Mon Sep 17 00:00:00 2001 From: plum-lihui Date: Wed, 16 Mar 2022 14:17:03 +0800 Subject: [PATCH 17/37] [add interval case] --- tests/script/tsim/query/interval.sim | 207 +++++++++++++++++++++++++++ 1 file changed, 207 insertions(+) create mode 100644 tests/script/tsim/query/interval.sim diff --git a/tests/script/tsim/query/interval.sim b/tests/script/tsim/query/interval.sim new file mode 100644 index 0000000000..35e7c938d8 --- /dev/null +++ b/tests/script/tsim/query/interval.sim @@ -0,0 +1,207 @@ +system sh/stop_dnodes.sh + +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 -c wal -v 1 +system sh/exec.sh -n dnode1 -s start +sleep 2000 +sql connect + +$dbPrefix = m_in_db +$tbPrefix = m_in_tb +$mtPrefix = m_in_mt +$tbNum = 10 +$rowNum = 20 +$totalNum = 200 + +print =============== step1 +$i = 0 +$db = $dbPrefix . $i +$mt = $mtPrefix . $i + +sql drop database $db -x step1 +step1: +sql create database $db +sql use $db +sql create table $mt (ts timestamp, tbcol int) TAGS(tgcol int) + +print ====== start create child tables and insert data +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using $mt tags( $i ) + + $x = 0 + while $x < $rowNum + $cc = $x * 60000 + $ms = 1601481600000 + $cc + + sql insert into $tb values ($ms , $x ) + $x = $x + 1 + endw + + $i = $i + 1 +endw + +print =============== step2 +$i = 1 +$tb = $tbPrefix . $i + +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb interval(1m) +print ===> $rows +if $rows < $rowNum then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +print =============== step3 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms interval(1m) +print ===> $rows +if $rows > 10 then + return -1 +endi +if $rows < 3 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +print =============== step4 +$cc = 40 * 60000 +$ms = 1601481600000 + $cc + +$cc = 1 * 60000 +$ms2 = 1601481600000 - $cc + +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) +print ===> $rows +if $rows < 18 then + return -1 +endi +if $rows > 22 then + return -1 +endi +if $data01 != 1 then + return -1 +endi +if $data05 != 1 then + return -1 +endi + +print =============== step5 +$cc = 40 * 60000 +$ms = 1601481600000 + $cc + +$cc = 1 * 60000 +$ms2 = 1601481600000 - $cc + +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $tb where ts <= $ms and ts > $ms2 interval(1m) fill(value,0) +print ===> $rows +if $rows < 30 then + return -1 +endi +if $rows > 50 then + return -1 +endi +if $data21 != 1 then + return -1 +endi +if $data25 != 1 then + return -1 +endi + +print =============== step6 +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt interval(1m) +print ===> $rows +if $rows < 18 then + return -1 +endi +if $rows > 22 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== step7 +$cc = 4 * 60000 +$ms = 1601481600000 + $cc +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms interval(1m) +print ===> $rows +if $rows < 3 then + return -1 +endi +if $rows > 7 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== step8 +$cc = 40 * 60000 +$ms1 = 1601481600000 + $cc + +$cc = 1 * 60000 +$ms2 = 1601481600000 - $cc + +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) +print ===> $rows +if $rows < 18 then + return -1 +endi +if $rows > 22 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== step9 +$cc = 40 * 60000 +$ms1 = 1601481600000 + $cc + +$cc = 1 * 60000 +$ms2 = 1601481600000 - $cc + +sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(tbcol) from $mt where ts <= $ms1 and ts > $ms2 interval(1m) fill(value, 0) +if $rows < 30 then + return -1 +endi +if $rows > 50 then + return -1 +endi +if $data11 > 15 then + return -1 +endi +if $data11 < 5 then + return -1 +endi + +print =============== clear +sql drop database $db +sql show databases +if $rows != 0 then + return -1 +endi + +system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file From a9692987d9b411aaa74c1ac6deae54f84dcc2d73 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 16 Mar 2022 14:34:09 +0800 Subject: [PATCH 18/37] handle except and update UT --- source/libs/transport/src/transSrv.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/libs/transport/src/transSrv.c b/source/libs/transport/src/transSrv.c index 040c12b880..ec42ab6402 100644 --- a/source/libs/transport/src/transSrv.c +++ b/source/libs/transport/src/transSrv.c @@ -214,7 +214,9 @@ static void uvHandleReq(SSrvConn* pConn) { // pHead = rpcDecompresSTransMsg(pHead); } else { pHead->msgLen = htonl(pHead->msgLen); - // impl later + if (pHead->secured == 1) { + pHead->msgLen -= sizeof(STransUserMsg); + } // } From 5967a4dff8c36f0754352758c900587e0c6e4c36 Mon Sep 17 00:00:00 2001 From: Xiaoyu Wang Date: Wed, 16 Mar 2022 02:53:25 -0400 Subject: [PATCH 19/37] TD-13597 create/drop topic, alter database, drop index, drop qnode statement implement --- source/dnode/mnode/impl/src/mndTopic.c | 17 +++++++++++++++-- source/dnode/mnode/impl/test/topic/topic.cpp | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/source/dnode/mnode/impl/src/mndTopic.c b/source/dnode/mnode/impl/src/mndTopic.c index 32fa3df910..e913cae1ac 100644 --- a/source/dnode/mnode/impl/src/mndTopic.c +++ b/source/dnode/mnode/impl/src/mndTopic.c @@ -237,6 +237,10 @@ static int32_t mndCheckCreateTopicReq(SCMCreateTopicReq *pCreate) { } static int32_t mndGetPlanString(SCMCreateTopicReq *pCreate, char **pStr) { + if (NULL == pCreate->ast) { + return TSDB_CODE_SUCCESS; + } + SNode* pAst = NULL; int32_t code = nodesStringToNode(pCreate->ast, &pAst); @@ -266,17 +270,23 @@ static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateTopicReq topicObj.dbUid = pDb->uid; topicObj.version = 1; topicObj.sql = pCreate->sql; - topicObj.logicalPlan = NULL; + topicObj.physicalPlan = ""; + topicObj.logicalPlan = ""; topicObj.sqlLen = strlen(pCreate->sql); - if (TSDB_CODE_SUCCESS != mndGetPlanString(pCreate, &topicObj.physicalPlan)) { + char* pPlanStr = NULL; + if (TSDB_CODE_SUCCESS != mndGetPlanString(pCreate, &pPlanStr)) { mError("topic:%s, failed to get plan since %s", pCreate->name, terrstr()); return -1; } + if (NULL != pPlanStr) { + topicObj.physicalPlan = pPlanStr; + } STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_TYPE_CREATE_TOPIC, &pReq->rpcMsg); if (pTrans == NULL) { mError("topic:%s, failed to create since %s", pCreate->name, terrstr()); + tfree(pPlanStr); return -1; } mDebug("trans:%d, used to create topic:%s", pTrans->id, pCreate->name); @@ -284,6 +294,7 @@ static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateTopicReq SSdbRaw *pRedoRaw = mndTopicActionEncode(&topicObj); if (pRedoRaw == NULL || mndTransAppendRedolog(pTrans, pRedoRaw) != 0) { mError("trans:%d, failed to append redo log since %s", pTrans->id, terrstr()); + tfree(pPlanStr); mndTransDrop(pTrans); return -1; } @@ -291,10 +302,12 @@ static int32_t mndCreateTopic(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateTopicReq if (mndTransPrepare(pMnode, pTrans) != 0) { mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); + tfree(pPlanStr); mndTransDrop(pTrans); return -1; } + tfree(pPlanStr); mndTransDrop(pTrans); return 0; } diff --git a/source/dnode/mnode/impl/test/topic/topic.cpp b/source/dnode/mnode/impl/test/topic/topic.cpp index 79f353a4d6..73eefd875d 100644 --- a/source/dnode/mnode/impl/test/topic/topic.cpp +++ b/source/dnode/mnode/impl/test/topic/topic.cpp @@ -65,7 +65,7 @@ void* MndTestTopic::BuildCreateTopicReq(const char* topicName, const char* sql, strcpy(createReq.name, topicName); createReq.igExists = 0; createReq.sql = (char*)sql; - createReq.ast = (char*)"ast"; + createReq.ast = NULL; int32_t contLen = tSerializeSCMCreateTopicReq(NULL, 0, &createReq); void* pReq = rpcMallocCont(contLen); From f7cd75544c3247a54de75bd8e5a6bf7b5bfa0bf2 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 16 Mar 2022 15:09:56 +0800 Subject: [PATCH 20/37] sync raft store --- source/libs/sync/inc/syncIO.h | 6 +- source/libs/sync/inc/syncRaftStore.h | 15 +-- source/libs/sync/src/syncElection.c | 3 +- source/libs/sync/src/syncIO.c | 6 +- source/libs/sync/src/syncIndexMgr.c | 2 +- source/libs/sync/src/syncMain.c | 9 ++ source/libs/sync/src/syncRaftStore.c | 36 ++++-- source/libs/sync/src/syncVoteMgr.c | 4 +- source/libs/sync/test/CMakeLists.txt | 19 +++ source/libs/sync/test/syncElectTest.cpp | 121 ++++++++++++++++++++ source/libs/sync/test/syncRaftStoreTest.cpp | 56 ++++++--- 11 files changed, 239 insertions(+), 38 deletions(-) create mode 100644 source/libs/sync/test/syncElectTest.cpp diff --git a/source/libs/sync/inc/syncIO.h b/source/libs/sync/inc/syncIO.h index 09e93fda1c..5a4b7555bf 100644 --- a/source/libs/sync/inc/syncIO.h +++ b/source/libs/sync/inc/syncIO.h @@ -34,11 +34,11 @@ extern "C" { typedef struct SSyncIO { STaosQueue *pMsgQ; - STaosQset *pQset; + STaosQset * pQset; pthread_t consumerTid; - void *serverRpc; - void *clientRpc; + void * serverRpc; + void * clientRpc; SEpSet myAddr; tmr_h qTimer; diff --git a/source/libs/sync/inc/syncRaftStore.h b/source/libs/sync/inc/syncRaftStore.h index 62bb94c834..355a08ac84 100644 --- a/source/libs/sync/inc/syncRaftStore.h +++ b/source/libs/sync/inc/syncRaftStore.h @@ -43,13 +43,14 @@ int32_t raftStorePersist(SRaftStore *pRaftStore); int32_t raftStoreSerialize(SRaftStore *pRaftStore, char *buf, size_t len); int32_t raftStoreDeserialize(SRaftStore *pRaftStore, char *buf, size_t len); -bool raftStoreHasVoted(SRaftStore *pRaftStore); -void raftStoreVote(SRaftStore *pRaftStore, SRaftId *pRaftId); -void raftStoreClearVote(SRaftStore *pRaftStore); -void raftStoreNextTerm(SRaftStore *pRaftStore); -void raftStoreSetTerm(SRaftStore *pRaftStore, SyncTerm term); -cJSON *raftStore2Json(SRaftStore *pRaftStore); -char *raftStore2Str(SRaftStore *pRaftStore); +bool raftStoreHasVoted(SRaftStore *pRaftStore); +void raftStoreVote(SRaftStore *pRaftStore, SRaftId *pRaftId); +void raftStoreClearVote(SRaftStore *pRaftStore); +void raftStoreNextTerm(SRaftStore *pRaftStore); +void raftStoreSetTerm(SRaftStore *pRaftStore, SyncTerm term); +int32_t raftStoreFromJson(SRaftStore *pRaftStore, cJSON *pJson); +cJSON * raftStore2Json(SRaftStore *pRaftStore); +char * raftStore2Str(SRaftStore *pRaftStore); // for debug ------------------- void raftStorePrint(SRaftStore *pObj); diff --git a/source/libs/sync/src/syncElection.c b/source/libs/sync/src/syncElection.c index 77c3d07698..12e20ef762 100644 --- a/source/libs/sync/src/syncElection.c +++ b/source/libs/sync/src/syncElection.c @@ -50,6 +50,7 @@ int32_t syncNodeRequestVotePeers(SSyncNode* pSyncNode) { } int32_t syncNodeElect(SSyncNode* pSyncNode) { + int32_t ret = 0; if (pSyncNode->state == TAOS_SYNC_STATE_FOLLOWER) { syncNodeFollower2Candidate(pSyncNode); } @@ -62,7 +63,7 @@ int32_t syncNodeElect(SSyncNode* pSyncNode) { votesRespondReset(pSyncNode->pVotesRespond, pSyncNode->pRaftStore->currentTerm); syncNodeVoteForSelf(pSyncNode); - int32_t ret = syncNodeRequestVotePeers(pSyncNode); + ret = syncNodeRequestVotePeers(pSyncNode); assert(ret == 0); syncNodeResetElectTimer(pSyncNode); diff --git a/source/libs/sync/src/syncIO.c b/source/libs/sync/src/syncIO.c index 8176ac417a..e6a43f2bb5 100644 --- a/source/libs/sync/src/syncIO.c +++ b/source/libs/sync/src/syncIO.c @@ -29,7 +29,7 @@ static int32_t syncIODestroy(SSyncIO *io); static int32_t syncIOStartInternal(SSyncIO *io); static int32_t syncIOStopInternal(SSyncIO *io); -static void *syncIOConsumerFunc(void *param); +static void * syncIOConsumerFunc(void *param); static void syncIOProcessRequest(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet); static void syncIOProcessReply(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet); static int32_t syncIOAuth(void *parent, char *meterId, char *spi, char *encrypt, char *secret, char *ckey); @@ -234,9 +234,9 @@ static int32_t syncIOStopInternal(SSyncIO *io) { } static void *syncIOConsumerFunc(void *param) { - SSyncIO *io = param; + SSyncIO * io = param; STaosQall *qall; - SRpcMsg *pRpcMsg, rpcMsg; + SRpcMsg * pRpcMsg, rpcMsg; qall = taosAllocateQall(); while (1) { diff --git a/source/libs/sync/src/syncIndexMgr.c b/source/libs/sync/src/syncIndexMgr.c index 58a61ba77e..aa97104180 100644 --- a/source/libs/sync/src/syncIndexMgr.c +++ b/source/libs/sync/src/syncIndexMgr.c @@ -96,7 +96,7 @@ cJSON *syncIndexMgr2Json(SSyncIndexMgr *pSyncIndexMgr) { char *syncIndexMgr2Str(SSyncIndexMgr *pSyncIndexMgr) { cJSON *pJson = syncIndexMgr2Json(pSyncIndexMgr); - char *serialized = cJSON_Print(pJson); + char * serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 48a57dc0fb..58710d7d1f 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -103,6 +103,12 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pSyncInfo) { assert(pSyncNode != NULL); memset(pSyncNode, 0, sizeof(SSyncNode)); + if (taosMkDir(pSyncInfo->path) != 0) { + terrno = TAOS_SYSTEM_ERROR(errno); + sError("failed to create dir:%s since %s", pSyncInfo->path, terrstr()); + return NULL; + } + // init by SSyncInfo pSyncNode->vgId = pSyncInfo->vgId; pSyncNode->syncCfg = pSyncInfo->syncCfg; @@ -200,6 +206,9 @@ SSyncNode* syncNodeOpen(const SSyncInfo* pSyncInfo) { pSyncNode->FpOnAppendEntriesReply = syncNodeOnAppendEntriesReplyCb; pSyncNode->FpOnTimeout = syncNodeOnTimeoutCb; + // start raft + syncNodeBecomeFollower(pSyncNode); + return pSyncNode; } diff --git a/source/libs/sync/src/syncRaftStore.c b/source/libs/sync/src/syncRaftStore.c index 9a5401e3f1..bb0eab0fdc 100644 --- a/source/libs/sync/src/syncRaftStore.c +++ b/source/libs/sync/src/syncRaftStore.c @@ -97,16 +97,32 @@ int32_t raftStorePersist(SRaftStore *pRaftStore) { return 0; } -static bool raftStoreFileExist(char *path) { return taosStatFile(path, NULL, NULL) >= 0; } +static bool raftStoreFileExist(char *path) { + bool b = taosStatFile(path, NULL, NULL) >= 0; + return b; +} int32_t raftStoreSerialize(SRaftStore *pRaftStore, char *buf, size_t len) { assert(pRaftStore != NULL); cJSON *pRoot = cJSON_CreateObject(); - cJSON_AddNumberToObject(pRoot, "current_term", pRaftStore->currentTerm); - cJSON_AddNumberToObject(pRoot, "vote_for_addr", pRaftStore->voteFor.addr); + + char u64Buf[128]; + snprintf(u64Buf, sizeof(u64Buf), "%lu", pRaftStore->currentTerm); + cJSON_AddStringToObject(pRoot, "current_term", u64Buf); + + snprintf(u64Buf, sizeof(u64Buf), "%lu", pRaftStore->voteFor.addr); + cJSON_AddStringToObject(pRoot, "vote_for_addr", u64Buf); + cJSON_AddNumberToObject(pRoot, "vote_for_vgid", pRaftStore->voteFor.vgId); + uint64_t u64 = pRaftStore->voteFor.addr; + char host[128]; + uint16_t port; + syncUtilU642Addr(u64, host, sizeof(host), &port); + cJSON_AddStringToObject(pRoot, "addr_host", host); + cJSON_AddNumberToObject(pRoot, "addr_port", port); + char *serialized = cJSON_Print(pRoot); int len2 = strlen(serialized); assert(len2 < len); @@ -125,10 +141,12 @@ int32_t raftStoreDeserialize(SRaftStore *pRaftStore, char *buf, size_t len) { cJSON *pRoot = cJSON_Parse(buf); cJSON *pCurrentTerm = cJSON_GetObjectItem(pRoot, "current_term"); - pRaftStore->currentTerm = pCurrentTerm->valueint; + assert(cJSON_IsString(pCurrentTerm)); + sscanf(pCurrentTerm->valuestring, "%lu", &(pRaftStore->currentTerm)); cJSON *pVoteForAddr = cJSON_GetObjectItem(pRoot, "vote_for_addr"); - pRaftStore->voteFor.addr = pVoteForAddr->valueint; + assert(cJSON_IsString(pVoteForAddr)); + sscanf(pVoteForAddr->valuestring, "%lu", &(pRaftStore->voteFor.addr)); cJSON *pVoteForVgid = cJSON_GetObjectItem(pRoot, "vote_for_vgid"); pRaftStore->voteFor.vgId = pVoteForVgid->valueint; @@ -139,11 +157,10 @@ int32_t raftStoreDeserialize(SRaftStore *pRaftStore, char *buf, size_t len) { bool raftStoreHasVoted(SRaftStore *pRaftStore) { bool b = syncUtilEmptyId(&(pRaftStore->voteFor)); - return b; + return (!b); } void raftStoreVote(SRaftStore *pRaftStore, SRaftId *pRaftId) { - assert(!raftStoreHasVoted(pRaftStore)); assert(!syncUtilEmptyId(pRaftId)); pRaftStore->voteFor = *pRaftId; raftStorePersist(pRaftStore); @@ -164,6 +181,8 @@ void raftStoreSetTerm(SRaftStore *pRaftStore, SyncTerm term) { raftStorePersist(pRaftStore); } +int32_t raftStoreFromJson(SRaftStore *pRaftStore, cJSON *pJson) { return 0; } + cJSON *raftStore2Json(SRaftStore *pRaftStore) { char u64buf[128]; cJSON *pRoot = cJSON_CreateObject(); @@ -185,6 +204,9 @@ cJSON *raftStore2Json(SRaftStore *pRaftStore) { } cJSON_AddNumberToObject(pVoteFor, "vgId", pRaftStore->voteFor.vgId); cJSON_AddItemToObject(pRoot, "voteFor", pVoteFor); + + int hasVoted = raftStoreHasVoted(pRaftStore); + cJSON_AddNumberToObject(pRoot, "hasVoted", hasVoted); } cJSON *pJson = cJSON_CreateObject(); diff --git a/source/libs/sync/src/syncVoteMgr.c b/source/libs/sync/src/syncVoteMgr.c index 5830a0a54f..00851a7b4f 100644 --- a/source/libs/sync/src/syncVoteMgr.c +++ b/source/libs/sync/src/syncVoteMgr.c @@ -116,7 +116,7 @@ cJSON *voteGranted2Json(SVotesGranted *pVotesGranted) { char *voteGranted2Str(SVotesGranted *pVotesGranted) { cJSON *pJson = voteGranted2Json(pVotesGranted); - char *serialized = cJSON_Print(pJson); + char * serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } @@ -238,7 +238,7 @@ cJSON *votesRespond2Json(SVotesRespond *pVotesRespond) { char *votesRespond2Str(SVotesRespond *pVotesRespond) { cJSON *pJson = votesRespond2Json(pVotesRespond); - char *serialized = cJSON_Print(pJson); + char * serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } diff --git a/source/libs/sync/test/CMakeLists.txt b/source/libs/sync/test/CMakeLists.txt index b542f55ec3..2583deb32f 100644 --- a/source/libs/sync/test/CMakeLists.txt +++ b/source/libs/sync/test/CMakeLists.txt @@ -27,6 +27,7 @@ add_executable(syncPingReplyTest "") add_executable(syncRpcMsgTest "") add_executable(syncPingTimerTest2 "") add_executable(syncPingSelfTest "") +add_executable(syncElectTest "") target_sources(syncTest @@ -145,6 +146,10 @@ target_sources(syncPingSelfTest PRIVATE "syncPingSelfTest.cpp" ) +target_sources(syncElectTest + PRIVATE + "syncElectTest.cpp" +) target_include_directories(syncTest @@ -292,6 +297,16 @@ target_include_directories(syncPingSelfTest "${CMAKE_SOURCE_DIR}/include/libs/sync" "${CMAKE_CURRENT_SOURCE_DIR}/../inc" ) +target_include_directories(syncElectTest + PUBLIC + "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) +target_include_directories(syncElectTest + PUBLIC + "${CMAKE_SOURCE_DIR}/include/libs/sync" + "${CMAKE_CURRENT_SOURCE_DIR}/../inc" +) target_link_libraries(syncTest @@ -410,6 +425,10 @@ target_link_libraries(syncPingSelfTest sync gtest_main ) +target_link_libraries(syncElectTest + sync + gtest_main +) enable_testing() diff --git a/source/libs/sync/test/syncElectTest.cpp b/source/libs/sync/test/syncElectTest.cpp new file mode 100644 index 0000000000..e52fe61ef5 --- /dev/null +++ b/source/libs/sync/test/syncElectTest.cpp @@ -0,0 +1,121 @@ +#include +#include +#include "syncEnv.h" +#include "syncIO.h" +#include "syncInt.h" +#include "syncRaftLog.h" +#include "syncRaftStore.h" +#include "syncUtil.h" + +void logTest() { + sTrace("--- sync log test: trace"); + sDebug("--- sync log test: debug"); + sInfo("--- sync log test: info"); + sWarn("--- sync log test: warn"); + sError("--- sync log test: error"); + sFatal("--- sync log test: fatal"); +} + +uint16_t ports[] = {7010, 7110, 7210, 7310, 7410}; +int32_t replicaNum = 1; +int32_t myIndex = 0; + +SRaftId ids[TSDB_MAX_REPLICA]; +SSyncInfo syncInfo; +SSyncFSM* pFsm; +SWal* pWal; +SSyncNode* gSyncNode; + +SSyncNode* syncNodeInit() { + syncInfo.vgId = 1234; + syncInfo.rpcClient = gSyncIO->clientRpc; + syncInfo.FpSendMsg = syncIOSendMsg; + syncInfo.queue = gSyncIO->pMsgQ; + syncInfo.FpEqMsg = syncIOEqMsg; + syncInfo.pFsm = pFsm; + snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", "./elect_test"); + + int code = walInit(); + assert(code == 0); + SWalCfg walCfg; + memset(&walCfg, 0, sizeof(SWalCfg)); + walCfg.vgId = syncInfo.vgId; + walCfg.fsyncPeriod = 1000; + walCfg.retentionPeriod = 1000; + walCfg.rollPeriod = 1000; + walCfg.retentionSize = 1000; + walCfg.segSize = 1000; + walCfg.level = TAOS_WAL_FSYNC; + pWal = walOpen("./elect_test_wal", &walCfg); + assert(pWal != NULL); + + syncInfo.pWal = pWal; + + SSyncCfg* pCfg = &syncInfo.syncCfg; + pCfg->myIndex = myIndex; + pCfg->replicaNum = replicaNum; + + for (int i = 0; i < replicaNum; ++i) { + pCfg->nodeInfo[i].nodePort = ports[i]; + snprintf(pCfg->nodeInfo[i].nodeFqdn, sizeof(pCfg->nodeInfo[i].nodeFqdn), "%s", "127.0.0.1"); + // taosGetFqdn(pCfg->nodeInfo[0].nodeFqdn); + } + + SSyncNode* pSyncNode = syncNodeOpen(&syncInfo); + assert(pSyncNode != NULL); + + gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing; + gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply; + gSyncIO->FpOnSyncRequestVote = pSyncNode->FpOnRequestVote; + gSyncIO->FpOnSyncRequestVoteReply = pSyncNode->FpOnRequestVoteReply; + gSyncIO->FpOnSyncAppendEntries = pSyncNode->FpOnAppendEntries; + gSyncIO->FpOnSyncAppendEntriesReply = pSyncNode->FpOnAppendEntriesReply; + gSyncIO->FpOnSyncPing = pSyncNode->FpOnPing; + gSyncIO->FpOnSyncPingReply = pSyncNode->FpOnPingReply; + gSyncIO->FpOnSyncTimeout = pSyncNode->FpOnTimeout; + gSyncIO->pSyncNode = pSyncNode; + + return pSyncNode; +} + +SSyncNode* syncInitTest() { return syncNodeInit(); } + +void initRaftId(SSyncNode* pSyncNode) { + for (int i = 0; i < replicaNum; ++i) { + ids[i] = pSyncNode->replicasId[i]; + char* s = syncUtilRaftId2Str(&ids[i]); + printf("raftId[%d] : %s\n", i, s); + free(s); + } +} + +int main(int argc, char** argv) { + // taosInitLog((char *)"syncTest.log", 100000, 10); + tsAsyncLog = 0; + sDebugFlag = 143 + 64; + + myIndex = 0; + if (argc >= 2) { + myIndex = atoi(argv[1]); + } + + int32_t ret = syncIOStart((char*)"127.0.0.1", ports[myIndex]); + assert(ret == 0); + + ret = syncEnvStart(); + assert(ret == 0); + + gSyncNode = syncInitTest(); + assert(gSyncNode != NULL); + syncNodePrint2((char*)"", gSyncNode); + + initRaftId(gSyncNode); + + //--------------------------- + while (1) { + sTrace("while 1 sleep, state: %d, %s", gSyncNode->state, syncUtilState2String(gSyncNode->state)); + taosMsleep(1000); + } + + return 0; +} diff --git a/source/libs/sync/test/syncRaftStoreTest.cpp b/source/libs/sync/test/syncRaftStoreTest.cpp index 0c1c9b881e..688802625a 100644 --- a/source/libs/sync/test/syncRaftStoreTest.cpp +++ b/source/libs/sync/test/syncRaftStoreTest.cpp @@ -3,6 +3,7 @@ #include #include "syncIO.h" #include "syncInt.h" +#include "syncUtil.h" void logTest() { sTrace("--- sync log test: trace"); @@ -13,6 +14,21 @@ void logTest() { sFatal("--- sync log test: fatal"); } +uint16_t ports[] = {7010, 7110, 7210, 7310, 7410}; +int32_t replicaNum = 5; +int32_t myIndex = 0; +SRaftId ids[TSDB_MAX_REPLICA]; + +void initRaftId() { + for (int i = 0; i < replicaNum; ++i) { + ids[i].addr = syncUtilAddr2U64("127.0.0.1", ports[i]); + ids[i].vgId = 1234; + char* s = syncUtilRaftId2Str(&ids[i]); + printf("raftId[%d] : %s\n", i, s); + free(s); + } +} + int main() { // taosInitLog((char *)"syncTest.log", 100000, 10); tsAsyncLog = 0; @@ -20,23 +36,35 @@ int main() { logTest(); - SRaftStore *pRaftStore = raftStoreOpen("./raft_store.json"); + initRaftId(); + + SRaftStore* pRaftStore = raftStoreOpen("./test_raft_store.json"); assert(pRaftStore != NULL); - raftStorePrint(pRaftStore); + raftStorePrint2((char*)"==raftStoreOpen==", pRaftStore); -#if 0 - pRaftStore->currentTerm = 100; - pRaftStore->voteFor.addr = 200; - pRaftStore->voteFor.vgId = 300; - raftStorePersist(pRaftStore); - raftStorePrint(pRaftStore); -#endif + raftStoreSetTerm(pRaftStore, 100); + raftStorePrint2((char*)"==raftStoreSetTerm==", pRaftStore); - ++(pRaftStore->currentTerm); - ++(pRaftStore->voteFor.addr); - ++(pRaftStore->voteFor.vgId); - raftStorePersist(pRaftStore); - raftStorePrint(pRaftStore); + raftStoreVote(pRaftStore, &ids[0]); + raftStorePrint2((char*)"==raftStoreVote==", pRaftStore); + + raftStoreClearVote(pRaftStore); + raftStorePrint2((char*)"==raftStoreClearVote==", pRaftStore); + + raftStoreVote(pRaftStore, &ids[1]); + raftStorePrint2((char*)"==raftStoreVote==", pRaftStore); + + raftStoreNextTerm(pRaftStore); + raftStorePrint2((char*)"==raftStoreNextTerm==", pRaftStore); + + raftStoreNextTerm(pRaftStore); + raftStorePrint2((char*)"==raftStoreNextTerm==", pRaftStore); + + raftStoreNextTerm(pRaftStore); + raftStorePrint2((char*)"==raftStoreNextTerm==", pRaftStore); + + raftStoreNextTerm(pRaftStore); + raftStorePrint2((char*)"==raftStoreNextTerm==", pRaftStore); return 0; } From 90478b87421a09e1c20e4228ebe1ace8c00fb5dc Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 16 Mar 2022 15:24:11 +0800 Subject: [PATCH 21/37] sync refactor --- source/libs/sync/inc/syncEnv.h | 6 +++--- source/libs/sync/src/syncElection.c | 8 ++++++++ source/libs/sync/src/syncRequestVoteReply.c | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/source/libs/sync/inc/syncEnv.h b/source/libs/sync/inc/syncEnv.h index 40ff79287b..66c7c8620d 100644 --- a/source/libs/sync/inc/syncEnv.h +++ b/source/libs/sync/inc/syncEnv.h @@ -31,10 +31,10 @@ extern "C" { #define TIMER_MAX_MS 0x7FFFFFFF #define ENV_TICK_TIMER_MS 1000 #define PING_TIMER_MS 1000 -#define ELECT_TIMER_MS_MIN 150 -#define ELECT_TIMER_MS_MAX 300 +#define ELECT_TIMER_MS_MIN 1500 +#define ELECT_TIMER_MS_MAX 3000 #define ELECT_TIMER_MS_RANGE (ELECT_TIMER_MS_MAX - ELECT_TIMER_MS_MIN) -#define HEARTBEAT_TIMER_MS 30 +#define HEARTBEAT_TIMER_MS 300 #define EMPTY_RAFT_ID ((SRaftId){.addr = 0, .vgId = 0}) diff --git a/source/libs/sync/src/syncElection.c b/source/libs/sync/src/syncElection.c index 12e20ef762..6ae70689ef 100644 --- a/source/libs/sync/src/syncElection.c +++ b/source/libs/sync/src/syncElection.c @@ -63,6 +63,14 @@ int32_t syncNodeElect(SSyncNode* pSyncNode) { votesRespondReset(pSyncNode->pVotesRespond, pSyncNode->pRaftStore->currentTerm); syncNodeVoteForSelf(pSyncNode); + if (voteGrantedMajority(pSyncNode->pVotesGranted)) { + // only myself, to leader + assert(!pSyncNode->pVotesGranted->toLeader); + syncNodeCandidate2Leader(pSyncNode); + pSyncNode->pVotesGranted->toLeader = true; + return ret; + } + ret = syncNodeRequestVotePeers(pSyncNode); assert(ret == 0); syncNodeResetElectTimer(pSyncNode); diff --git a/source/libs/sync/src/syncRequestVoteReply.c b/source/libs/sync/src/syncRequestVoteReply.c index 7cdeace166..802d95076c 100644 --- a/source/libs/sync/src/syncRequestVoteReply.c +++ b/source/libs/sync/src/syncRequestVoteReply.c @@ -57,7 +57,7 @@ int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg) if (pMsg->voteGranted) { voteGrantedVote(ths->pVotesGranted, pMsg); if (voteGrantedMajority(ths->pVotesGranted)) { - if (ths->pVotesGranted->toLeader) { + if (!ths->pVotesGranted->toLeader) { syncNodeCandidate2Leader(ths); ths->pVotesGranted->toLeader = true; } From acfe73ed18987b145af656ee01c2b5b4da84b1c5 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 16 Mar 2022 15:47:49 +0800 Subject: [PATCH 22/37] sync refactor --- source/libs/sync/src/syncRequestVote.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/libs/sync/src/syncRequestVote.c b/source/libs/sync/src/syncRequestVote.c index be4f40aaad..062b0244bd 100644 --- a/source/libs/sync/src/syncRequestVote.c +++ b/source/libs/sync/src/syncRequestVote.c @@ -56,6 +56,8 @@ int32_t syncNodeOnRequestVoteCb(SSyncNode* ths, SyncRequestVote* pMsg) { bool grant = (pMsg->term == ths->pRaftStore->currentTerm) && logOK && ((!raftStoreHasVoted(ths->pRaftStore)) || (syncUtilSameId(&(ths->pRaftStore->voteFor), &(pMsg->srcId)))); if (grant) { + // maybe has already voted for pMsg->srcId + // vote again, no harm raftStoreVote(ths->pRaftStore, &(pMsg->srcId)); } From b08cdf2f824d5149257df715313b676bd3d39679 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 16 Mar 2022 16:20:01 +0800 Subject: [PATCH 23/37] sync refactor --- source/libs/sync/src/syncMain.c | 22 +++++++++++++++++++-- source/libs/sync/src/syncRaftStore.c | 2 +- source/libs/sync/src/syncRequestVoteReply.c | 13 ++++++++++++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 58710d7d1f..c146c2fa7a 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -510,15 +510,17 @@ void syncNodeUpdateTerm(SSyncNode* pSyncNode, SyncTerm term) { } void syncNodeBecomeFollower(SSyncNode* pSyncNode) { + // maybe clear leader cache if (pSyncNode->state == TAOS_SYNC_STATE_LEADER) { pSyncNode->leaderCache = EMPTY_RAFT_ID; } + // state change pSyncNode->state = TAOS_SYNC_STATE_FOLLOWER; syncNodeStopHeartbeatTimer(pSyncNode); - int32_t electMS = syncUtilElectRandomMS(); - syncNodeRestartElectTimer(pSyncNode, electMS); + // reset elect timer + syncNodeResetElectTimer(pSyncNode); } // TLA+ Spec @@ -540,19 +542,31 @@ void syncNodeBecomeFollower(SSyncNode* pSyncNode) { // /\ UNCHANGED <> // void syncNodeBecomeLeader(SSyncNode* pSyncNode) { + // state change pSyncNode->state = TAOS_SYNC_STATE_LEADER; + + // set leader cache pSyncNode->leaderCache = pSyncNode->myRaftId; for (int i = 0; i < pSyncNode->pNextIndex->replicaNum; ++i) { + // maybe overwrite myself, no harm + // just do it! pSyncNode->pNextIndex->index[i] = pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore) + 1; } for (int i = 0; i < pSyncNode->pMatchIndex->replicaNum; ++i) { + // maybe overwrite myself, no harm + // just do it! pSyncNode->pMatchIndex->index[i] = SYNC_INDEX_INVALID; } + // stop elect timer syncNodeStopElectTimer(pSyncNode); + + // start heartbeat timer syncNodeStartHeartbeatTimer(pSyncNode); + + // start replicate right now! syncNodeReplicate(pSyncNode); } @@ -578,6 +592,9 @@ void syncNodeCandidate2Follower(SSyncNode* pSyncNode) { } // raft vote -------------- + +// just called by syncNodeVoteForSelf +// need assert void syncNodeVoteForTerm(SSyncNode* pSyncNode, SyncTerm term, SRaftId* pRaftId) { assert(term == pSyncNode->pRaftStore->currentTerm); assert(!raftStoreHasVoted(pSyncNode->pRaftStore)); @@ -585,6 +602,7 @@ void syncNodeVoteForTerm(SSyncNode* pSyncNode, SyncTerm term, SRaftId* pRaftId) raftStoreVote(pSyncNode->pRaftStore, pRaftId); } +// simulate get vote from outside void syncNodeVoteForSelf(SSyncNode* pSyncNode) { syncNodeVoteForTerm(pSyncNode, pSyncNode->pRaftStore->currentTerm, &(pSyncNode->myRaftId)); diff --git a/source/libs/sync/src/syncRaftStore.c b/source/libs/sync/src/syncRaftStore.c index bb0eab0fdc..3f6db129ce 100644 --- a/source/libs/sync/src/syncRaftStore.c +++ b/source/libs/sync/src/syncRaftStore.c @@ -216,7 +216,7 @@ cJSON *raftStore2Json(SRaftStore *pRaftStore) { char *raftStore2Str(SRaftStore *pRaftStore) { cJSON *pJson = raftStore2Json(pRaftStore); - char *serialized = cJSON_Print(pJson); + char * serialized = cJSON_Print(pJson); cJSON_Delete(pJson); return serialized; } diff --git a/source/libs/sync/src/syncRequestVoteReply.c b/source/libs/sync/src/syncRequestVoteReply.c index 802d95076c..10ea53864f 100644 --- a/source/libs/sync/src/syncRequestVoteReply.c +++ b/source/libs/sync/src/syncRequestVoteReply.c @@ -45,6 +45,7 @@ int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg) return ret; } + assert(!(pMsg->term > ths->pRaftStore->currentTerm)); // no need this code, because if I receive reply.term, then I must have sent for that term. // if (pMsg->term > ths->pRaftStore->currentTerm) { // syncNodeUpdateTerm(ths, pMsg->term); @@ -52,17 +53,29 @@ int32_t syncNodeOnRequestVoteReplyCb(SSyncNode* ths, SyncRequestVoteReply* pMsg) assert(pMsg->term == ths->pRaftStore->currentTerm); + // This tallies votes even when the current state is not Candidate, + // but they won't be looked at, so it doesn't matter. if (ths->state == TAOS_SYNC_STATE_CANDIDATE) { votesRespondAdd(ths->pVotesRespond, pMsg); if (pMsg->voteGranted) { + // add vote voteGrantedVote(ths->pVotesGranted, pMsg); + + // maybe to leader if (voteGrantedMajority(ths->pVotesGranted)) { if (!ths->pVotesGranted->toLeader) { syncNodeCandidate2Leader(ths); + + // prevent to leader again! ths->pVotesGranted->toLeader = true; } } + } else { + ; + // do nothing + // UNCHANGED <> } } + return ret; } From 5387e4ff7d59fcc9a1030085d48e155831d2baab Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 16 Mar 2022 16:54:55 +0800 Subject: [PATCH 24/37] sync refactor --- source/libs/sync/src/syncReplication.c | 40 ++++++++++++++++++++------ 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/source/libs/sync/src/syncReplication.c b/source/libs/sync/src/syncReplication.c index b935943a1d..ca04db81b6 100644 --- a/source/libs/sync/src/syncReplication.c +++ b/source/libs/sync/src/syncReplication.c @@ -18,6 +18,7 @@ #include "syncMessage.h" #include "syncRaftEntry.h" #include "syncRaftLog.h" +#include "syncRaftStore.h" #include "syncUtil.h" // TLA+ Spec @@ -50,33 +51,54 @@ int32_t syncNodeAppendEntriesPeers(SSyncNode* pSyncNode) { int32_t ret = 0; for (int i = 0; i < pSyncNode->peersNum; ++i) { - SRaftId* pDestId = &(pSyncNode->peersId[i]); - SyncIndex nextIndex = syncIndexMgrGetIndex(pSyncNode->pNextIndex, pDestId); + SRaftId* pDestId = &(pSyncNode->peersId[i]); + // set prevLogIndex + SyncIndex nextIndex = syncIndexMgrGetIndex(pSyncNode->pNextIndex, pDestId); SyncIndex preLogIndex = nextIndex - 1; + // set preLogTerm SyncTerm preLogTerm = 0; if (preLogIndex >= SYNC_INDEX_BEGIN) { SSyncRaftEntry* pPreEntry = pSyncNode->pLogStore->getEntry(pSyncNode->pLogStore, preLogIndex); + assert(pPreEntry != NULL); + preLogTerm = pPreEntry->term; + syncEntryDestory(pPreEntry); } - SyncIndex lastIndex = syncUtilMinIndex(pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore), nextIndex); - assert(nextIndex == lastIndex); + // batch optimized + // SyncIndex lastIndex = syncUtilMinIndex(pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore), nextIndex); - SSyncRaftEntry* pEntry = logStoreGetEntry(pSyncNode->pLogStore, nextIndex); - assert(pEntry != NULL); + SyncAppendEntries* pMsg = NULL; + SSyncRaftEntry* pEntry = logStoreGetEntry(pSyncNode->pLogStore, nextIndex); + if (pEntry != NULL) { + SyncAppendEntries* pMsg = syncAppendEntriesBuild(pEntry->bytes); + + // add pEntry into msg + uint32_t len; + char* serialized = syncEntrySerialize(pEntry, &len); + assert(len == pEntry->bytes); + memcpy(pMsg->data, serialized, len); + + free(serialized); + syncEntryDestory(pEntry); + + } else { + // maybe overflow, send empty record + SyncAppendEntries* pMsg = syncAppendEntriesBuild(0); + } - SyncAppendEntries* pMsg = syncAppendEntriesBuild(pEntry->bytes); pMsg->srcId = pSyncNode->myRaftId; pMsg->destId = *pDestId; + pMsg->term = pSyncNode->pRaftStore->currentTerm; pMsg->prevLogIndex = preLogIndex; pMsg->prevLogTerm = preLogTerm; pMsg->commitIndex = pSyncNode->commitIndex; - pMsg->dataLen = pEntry->bytes; - // add pEntry into msg + // send AppendEntries syncNodeAppendEntries(pSyncNode, pDestId, pMsg); + syncAppendEntriesDestroy(pMsg); } return ret; From f22226a44ec541e0c9492ab8bdeb6eb6b21620f8 Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 16 Mar 2022 17:16:10 +0800 Subject: [PATCH 25/37] sync refactor --- source/libs/sync/src/syncAppendEntriesReply.c | 6 ++- source/libs/sync/src/syncCommit.c | 41 +++++++++++++++++++ source/libs/sync/src/syncMain.c | 2 - 3 files changed, 45 insertions(+), 4 deletions(-) create mode 100644 source/libs/sync/src/syncCommit.c diff --git a/source/libs/sync/src/syncAppendEntriesReply.c b/source/libs/sync/src/syncAppendEntriesReply.c index 61eb4884e2..4fa4f89628 100644 --- a/source/libs/sync/src/syncAppendEntriesReply.c +++ b/source/libs/sync/src/syncAppendEntriesReply.c @@ -51,10 +51,10 @@ int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* p assert(pMsg->term == ths->pRaftStore->currentTerm); if (pMsg->success) { - // nextIndex = reply.matchIndex + 1 + // nextIndex' = [nextIndex EXCEPT ![i][j] = m.mmatchIndex + 1] syncIndexMgrSetIndex(ths->pNextIndex, &(pMsg->srcId), pMsg->matchIndex + 1); - // matchIndex = reply.matchIndex + // matchIndex' = [matchIndex EXCEPT ![i][j] = m.mmatchIndex] syncIndexMgrSetIndex(ths->pMatchIndex, &(pMsg->srcId), pMsg->matchIndex); // maybe commit @@ -62,6 +62,8 @@ int32_t syncNodeOnAppendEntriesReplyCb(SSyncNode* ths, SyncAppendEntriesReply* p } else { SyncIndex nextIndex = syncIndexMgrGetIndex(ths->pNextIndex, &(pMsg->srcId)); + + // notice! int64, uint64 if (nextIndex > SYNC_INDEX_BEGIN) { --nextIndex; } else { diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c new file mode 100644 index 0000000000..ec4272fdd0 --- /dev/null +++ b/source/libs/sync/src/syncCommit.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2019 TAOS Data, Inc. + * + * This program is free software: you can use, redistribute, and/or modify + * it under the terms of the GNU Affero General Public License, version 3 + * or later ("AGPL"), as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "syncInt.h" + +// \* Leader i advances its commitIndex. +// \* This is done as a separate step from handling AppendEntries responses, +// \* in part to minimize atomic regions, and in part so that leaders of +// \* single-server clusters are able to mark entries committed. +// AdvanceCommitIndex(i) == +// /\ state[i] = Leader +// /\ LET \* The set of servers that agree up through index. +// Agree(index) == {i} \cup {k \in Server : +// matchIndex[i][k] >= index} +// \* The maximum indexes for which a quorum agrees +// agreeIndexes == {index \in 1..Len(log[i]) : +// Agree(index) \in Quorum} +// \* New value for commitIndex'[i] +// newCommitIndex == +// IF /\ agreeIndexes /= {} +// /\ log[i][Max(agreeIndexes)].term = currentTerm[i] +// THEN +// Max(agreeIndexes) +// ELSE +// commitIndex[i] +// IN commitIndex' = [commitIndex EXCEPT ![i] = newCommitIndex] +// /\ UNCHANGED <> +// +void syncNodeMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {} \ No newline at end of file diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index c146c2fa7a..7d2087eded 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -617,8 +617,6 @@ void syncNodeVoteForSelf(SSyncNode* pSyncNode) { syncRequestVoteReplyDestroy(pMsg); } -void syncNodeMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {} - // for debug -------------- void syncNodePrint(SSyncNode* pObj) { char* serialized = syncNode2Str(pObj); From d1c4e9ae9227c442432f86f2fa8287e39cca944e Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 16 Mar 2022 18:15:26 +0800 Subject: [PATCH 26/37] handle except --- source/libs/transport/src/transCli.c | 107 ++++++++++++++++----------- 1 file changed, 64 insertions(+), 43 deletions(-) diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index b7bc428901..0932241abf 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -30,6 +30,7 @@ typedef struct SCliConn { void* hostThrd; SConnBuffer readBuf; void* data; + SArray* cliMsgs; queue conn; uint64_t expireTime; int hThrdIdx; @@ -106,6 +107,7 @@ static void cliAsyncCb(uv_async_t* handle); static SCliConn* cliCreateConn(SCliThrdObj* thrd); static void cliDestroyConn(SCliConn* pConn, bool clear /*clear tcp handle or not*/); static void cliDestroy(uv_handle_t* handle); +static void cliSend(SCliConn* pConn); // process data read from server, add decompress etc later static void cliHandleResp(SCliConn* conn); @@ -158,6 +160,14 @@ static void destroyThrdObj(SCliThrdObj* pThrd); static void* cliWorkThread(void* arg); +bool cliMayContinueSendMsg(SCliConn* conn) { + if (taosArrayGetSize(conn->cliMsgs) > 0) { + cliSend(conn); + return true; + } else { + return false; + } +} void cliHandleResp(SCliConn* conn) { SCliThrdObj* pThrd = conn->hostThrd; STrans* pTransInst = pThrd->pTransInst; @@ -173,18 +183,18 @@ void cliHandleResp(SCliConn* conn) { transMsg.msgType = pHead->msgType; transMsg.ahandle = NULL; - SCliMsg* pMsg = conn->data; + SCliMsg* pMsg = NULL; + if (taosArrayGetSize(conn->cliMsgs) > 0) { + pMsg = taosArrayGetP(conn->cliMsgs, 0); + taosArrayRemove(conn->cliMsgs, 0); + } + STransConnCtx* pCtx = pMsg ? pMsg->ctx : NULL; if (pMsg == NULL && !CONN_NO_PERSIST_BY_APP(conn)) { transMsg.ahandle = pTransInst->mfp ? (*pTransInst->mfp)(pTransInst->parent, transMsg.msgType) : NULL; } else { transMsg.ahandle = pCtx ? pCtx->ahandle : NULL; } - // if (rpcMsg.ahandle == NULL) { - // tDebug("%s cli conn %p handle except", CONN_GET_INST_LABEL(conn), conn); - // return; - //} - // buf's mem alread translated to transMsg.pCont transClearBuffer(&conn->readBuf); @@ -214,12 +224,15 @@ void cliHandleResp(SCliConn* conn) { memcpy((char*)pCtx->pRsp, (char*)&transMsg, sizeof(transMsg)); tsem_post(pCtx->pSem); } + destroyCmsg(pMsg); + + if (cliMayContinueSendMsg(conn) == true) { + return; + } if (CONN_NO_PERSIST_BY_APP(conn)) { addConnToPool(pThrd->pool, conn); } - destroyCmsg(conn->data); - conn->data = NULL; uv_read_start((uv_stream_t*)conn->stream, cliAllocRecvBufferCb, cliRecvCb); // start thread's timer of conn pool if not active @@ -229,7 +242,7 @@ void cliHandleResp(SCliConn* conn) { } void cliHandleExcept(SCliConn* pConn) { - if (pConn->data == NULL) { + if (taosArrayGetSize(pConn->cliMsgs) == 0) { if (pConn->broken == true || CONN_NO_PERSIST_BY_APP(pConn)) { transUnrefCliHandle(pConn); return; @@ -238,32 +251,38 @@ void cliHandleExcept(SCliConn* pConn) { SCliThrdObj* pThrd = pConn->hostThrd; STrans* pTransInst = pThrd->pTransInst; - SCliMsg* pMsg = pConn->data; - STransConnCtx* pCtx = pMsg ? pMsg->ctx : NULL; + do { + SCliMsg* pMsg = NULL; + if (taosArrayGetSize(pConn->cliMsgs) > 0) { + pMsg = taosArrayGetP(pConn->cliMsgs, 0); + taosArrayRemove(pConn->cliMsgs, 0); + } - STransMsg transMsg = {0}; - transMsg.code = TSDB_CODE_RPC_NETWORK_UNAVAIL; - transMsg.msgType = pMsg ? pMsg->msg.msgType + 1 : 0; - transMsg.ahandle = NULL; + STransConnCtx* pCtx = pMsg ? pMsg->ctx : NULL; - if (pMsg == NULL && !CONN_NO_PERSIST_BY_APP(pConn)) { - transMsg.ahandle = pTransInst->mfp ? (*pTransInst->mfp)(pTransInst->parent, transMsg.msgType) : NULL; - } else { - transMsg.ahandle = pCtx ? pCtx->ahandle : NULL; - } + STransMsg transMsg = {0}; + transMsg.code = TSDB_CODE_RPC_NETWORK_UNAVAIL; + transMsg.msgType = pMsg ? pMsg->msg.msgType + 1 : 0; + transMsg.ahandle = NULL; - if (pCtx == NULL || pCtx->pSem == NULL) { - tTrace("%s cli conn %p handle resp", pTransInst->label, pConn); - (pTransInst->cfp)(pTransInst->parent, &transMsg, NULL); - } else { - tTrace("%s cli conn(sync) %p handle resp", pTransInst->label, pConn); - memcpy((char*)(pCtx->pRsp), (char*)(&transMsg), sizeof(transMsg)); - tsem_post(pCtx->pSem); - } - destroyCmsg(pConn->data); - pConn->data = NULL; + if (pMsg == NULL && !CONN_NO_PERSIST_BY_APP(pConn)) { + transMsg.ahandle = pTransInst->mfp ? (*pTransInst->mfp)(pTransInst->parent, transMsg.msgType) : NULL; + } else { + transMsg.ahandle = pCtx ? pCtx->ahandle : NULL; + } + + if (pCtx == NULL || pCtx->pSem == NULL) { + tTrace("%s cli conn %p handle resp", pTransInst->label, pConn); + (pTransInst->cfp)(pTransInst->parent, &transMsg, NULL); + } else { + tTrace("%s cli conn(sync) %p handle resp", pTransInst->label, pConn); + memcpy((char*)(pCtx->pRsp), (char*)(&transMsg), sizeof(transMsg)); + tsem_post(pCtx->pSem); + } + destroyCmsg(pMsg); + tTrace("%s cli conn %p start to destroy", CONN_GET_INST_LABEL(pConn), pConn); + } while (taosArrayGetSize(pConn->cliMsgs) > 0); - tTrace("%s cli conn %p start to destroy", CONN_GET_INST_LABEL(pConn), pConn); transUnrefCliHandle(pConn); } @@ -398,6 +417,7 @@ static SCliConn* cliCreateConn(SCliThrdObj* pThrd) { conn->writeReq.data = conn; conn->connReq.data = conn; + conn->cliMsgs = taosArrayInit(2, sizeof(void*)); QUEUE_INIT(&conn->conn); conn->hostThrd = pThrd; @@ -417,6 +437,7 @@ static void cliDestroy(uv_handle_t* handle) { SCliConn* conn = handle->data; free(conn->ip); free(conn->stream); + taosArrayDestroy(conn->cliMsgs); tTrace("%s cli conn %p destroy successfully", CONN_GET_INST_LABEL(conn), conn); free(conn); } @@ -426,11 +447,6 @@ static void cliSendCb(uv_write_t* req, int status) { if (status == 0) { tTrace("%s cli conn %p data already was written out", CONN_GET_INST_LABEL(pConn), pConn); - SCliMsg* pMsg = pConn->data; - if (pMsg == NULL) { - return; - } - destroyUserdata(&pMsg->msg); } else { tError("%s cli conn %p failed to write: %s", CONN_GET_INST_LABEL(pConn), pConn, uv_err_name(status)); cliHandleExcept(pConn); @@ -442,7 +458,8 @@ static void cliSendCb(uv_write_t* req, int status) { void cliSend(SCliConn* pConn) { CONN_HANDLE_BROKEN(pConn); - SCliMsg* pCliMsg = pConn->data; + assert(taosArrayGetSize(pConn->cliMsgs) > 0); + SCliMsg* pCliMsg = taosArrayGetP(pConn->cliMsgs, 0); STransConnCtx* pCtx = pCliMsg->ctx; SCliThrdObj* pThrd = pConn->hostThrd; @@ -480,6 +497,7 @@ void cliSend(SCliConn* pConn) { TMSG_INFO(pHead->msgType), inet_ntoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), inet_ntoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port)); + pConn->writeReq.data = pConn; uv_write(&pConn->writeReq, (uv_stream_t*)pConn->stream, &wb, 1, cliSendCb); return; @@ -502,8 +520,8 @@ void cliConnCb(uv_connect_t* req, int status) { uv_tcp_getsockname((uv_tcp_t*)pConn->stream, (struct sockaddr*)&pConn->locaddr, &addrlen); tTrace("%s cli conn %p connect to server successfully", CONN_GET_INST_LABEL(pConn), pConn); - assert(pConn->stream == req->handle); + cliSend(pConn); } @@ -521,8 +539,11 @@ static void cliHandleRelease(SCliMsg* pMsg, SCliThrdObj* pThrd) { SCliConn* conn = pMsg->msg.handle; tDebug("%s cli conn %p release to inst", CONN_GET_INST_LABEL(conn), conn); - destroyCmsg(pMsg); - conn->data = NULL; + while (taosArrayGetSize(conn->cliMsgs) > 0) { + SCliMsg* pMsg = taosArrayGetP(conn->cliMsgs, 0); + destroyCmsg(pMsg); + taosArrayRemove(conn->cliMsgs, 0); + } transDestroyBuffer(&conn->readBuf); if (conn->persist && T_REF_VAL_GET(conn) >= 2) { @@ -561,14 +582,14 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) { SCliConn* conn = cliGetConn(pMsg, pThrd); if (conn != NULL) { - conn->data = pMsg; + taosArrayPush(conn->cliMsgs, &pMsg); conn->hThrdIdx = pCtx->hThrdIdx; - transDestroyBuffer(&conn->readBuf); cliSend(conn); } else { conn = cliCreateConn(pThrd); - conn->data = pMsg; + taosArrayPush(conn->cliMsgs, &pMsg); + conn->hThrdIdx = pCtx->hThrdIdx; conn->ip = strdup(pMsg->ctx->ip); conn->port = pMsg->ctx->port; From e10f471b9525e452746c98820f8034c2766741e1 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Wed, 16 Mar 2022 18:19:26 +0800 Subject: [PATCH 27/37] refactor --- include/common/tmsg.h | 25 +--- include/util/taoserror.h | 1 + source/dnode/vnode/src/inc/tsdbDef.h | 9 +- source/dnode/vnode/src/tsdb/tsdbBDBImpl.c | 4 +- source/dnode/vnode/src/tsdb/tsdbSma.c | 170 ++++++++++++++-------- source/dnode/vnode/test/tsdbSmaTest.cpp | 121 +++++++-------- source/util/src/terror.c | 1 + 7 files changed, 184 insertions(+), 147 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index f0718900c0..40bf9a7f62 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -1896,33 +1896,18 @@ static FORCE_INLINE void* tDecodeSSchemaWrapper(void* buf, SSchemaWrapper* pSW) } return buf; } -typedef enum { - TD_TIME_UNIT_UNKNOWN = -1, - TD_TIME_UNIT_YEAR = 0, - TD_TIME_UNIT_SEASON = 1, - TD_TIME_UNIT_MONTH = 2, - TD_TIME_UNIT_WEEK = 3, - TD_TIME_UNIT_DAY = 4, - TD_TIME_UNIT_HOUR = 5, - TD_TIME_UNIT_MINUTE = 6, - TD_TIME_UNIT_SEC = 7, - TD_TIME_UNIT_MILLISEC = 8, - TD_TIME_UNIT_MICROSEC = 9, - TD_TIME_UNIT_NANOSEC = 10 -} ETDTimeUnit; - typedef struct { int8_t version; // for compatibility(default 0) - int8_t intervalUnit; - int8_t slidingUnit; + int8_t intervalUnit; // MACRO: TIME_UNIT_XXX + int8_t slidingUnit; // MACRO: TIME_UNIT_XXX char indexName[TSDB_INDEX_NAME_LEN]; - char timezone[TD_TIMEZONE_LEN]; // sma data is invalid if timezone change. + char timezone[TD_TIMEZONE_LEN]; // sma data expired if timezone changes. int32_t exprLen; int32_t tagsFilterLen; int64_t indexUid; tb_uid_t tableUid; // super/child/common table uid int64_t interval; - int64_t offset; + int64_t offset; // use unit by precision of DB int64_t sliding; char* expr; // sma expression char* tagsFilter; @@ -1967,7 +1952,7 @@ typedef struct { typedef struct { int64_t indexUid; - TSKEY skey; // startTS of one interval/sliding + TSKEY skey; // startKey of one interval/sliding window int64_t interval; int32_t dataLen; // not including head int8_t intervalUnit; diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 1c61d738b5..fe06a1c4a2 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -354,6 +354,7 @@ int32_t* taosGetErrno(); #define TSDB_CODE_TDB_IVLD_TAG_VAL TAOS_DEF_ERROR_CODE(0, 0x0615) #define TSDB_CODE_TDB_NO_CACHE_LAST_ROW TAOS_DEF_ERROR_CODE(0, 0x0616) #define TSDB_CODE_TDB_NO_SMA_INDEX_IN_META TAOS_DEF_ERROR_CODE(0, 0x0617) +#define TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR TAOS_DEF_ERROR_CODE(0, 0x0618) // query #define TSDB_CODE_QRY_INVALID_QHANDLE TAOS_DEF_ERROR_CODE(0, 0x0700) diff --git a/source/dnode/vnode/src/inc/tsdbDef.h b/source/dnode/vnode/src/inc/tsdbDef.h index 6f91b4d3ab..5e4c852621 100644 --- a/source/dnode/vnode/src/inc/tsdbDef.h +++ b/source/dnode/vnode/src/inc/tsdbDef.h @@ -60,10 +60,11 @@ struct STsdb { SSmaEnv * pRSmaEnv; }; -#define REPO_ID(r) ((r)->vgId) -#define REPO_CFG(r) (&(r)->config) -#define REPO_FS(r) (r)->fs -#define IS_REPO_LOCKED(r) (r)->repoLocked +#define REPO_ID(r) ((r)->vgId) +#define REPO_CFG(r) (&(r)->config) +#define REPO_FS(r) (r)->fs +#define IS_REPO_LOCKED(r) (r)->repoLocked +#define REPO_SMA_ENV(r, t) ((TSDB_SMA_TYPE_ROLLUP == (t)) ? (r)->pRSmaEnv : (r)->pTSmaEnv) int tsdbLockRepo(STsdb *pTsdb); int tsdbUnlockRepo(STsdb *pTsdb); diff --git a/source/dnode/vnode/src/tsdb/tsdbBDBImpl.c b/source/dnode/vnode/src/tsdb/tsdbBDBImpl.c index cf3351c5d8..ee279abf47 100644 --- a/source/dnode/vnode/src/tsdb/tsdbBDBImpl.c +++ b/source/dnode/vnode/src/tsdb/tsdbBDBImpl.c @@ -68,8 +68,8 @@ int32_t tsdbOpenBDBEnv(DB_ENV **ppEnv, const char *path) { ret = pEnv->open(pEnv, path, DB_CREATE | DB_INIT_CDB | DB_INIT_MPOOL, 0); if (ret != 0) { - // BDB_PERR("Failed to open tsdb env", ret); - tsdbWarn("Failed to open tsdb env for path %s since %d", path ? path : "NULL", ret); + terrno = TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR; + tsdbWarn("Failed to open tsdb env for path %s since ret %d != 0", path ? path : "NULL", ret); return -1; } diff --git a/source/dnode/vnode/src/tsdb/tsdbSma.c b/source/dnode/vnode/src/tsdb/tsdbSma.c index 7335e4f585..880eb403f4 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSma.c +++ b/source/dnode/vnode/src/tsdb/tsdbSma.c @@ -17,7 +17,7 @@ #undef SMA_PRINT_DEBUG_LOG #define SMA_STORAGE_TSDB_DAYS 30 -#define SMA_STORAGE_TSDB_TIMES 30 +#define SMA_STORAGE_TSDB_TIMES 10 #define SMA_STORAGE_SPLIT_HOURS 24 #define SMA_KEY_LEN 18 // tableUid_colId_TSKEY 8+2+8 @@ -93,6 +93,11 @@ static int32_t tsdbGetTSmaDays(STsdb *pTsdb, int64_t interval, int32_t storageLe static int32_t tsdbSetTSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData, int32_t storageLevel, int32_t fid); static int32_t tsdbInitTSmaFile(STSmaReadH *pSmaH, TSKEY skey); static bool tsdbSetAndOpenTSmaFile(STSmaReadH *pReadH, TSKEY *queryKey); +static void tsdbGetSmaDir(int32_t repoid, int8_t smaType, char dirName[]); + +static void tsdbGetSmaDir(int32_t repoid, int8_t smaType, char dirName[]) { + snprintf(dirName, TSDB_FILENAME_LEN, "vnode/vnode%d/tsdb/data", repoid); +} static SSmaEnv *tsdbNewSmaEnv(const STsdb *pTsdb, const char *path) { SSmaEnv *pEnv = NULL; @@ -136,7 +141,7 @@ static int32_t tsdbInitSmaEnv(STsdb *pTsdb, const char *path, SSmaEnv **pEnv) { return TSDB_CODE_FAILED; } - if (pEnv && *pEnv) { + if (*pEnv) { return TSDB_CODE_SUCCESS; } @@ -144,7 +149,7 @@ static int32_t tsdbInitSmaEnv(STsdb *pTsdb, const char *path, SSmaEnv **pEnv) { return TSDB_CODE_FAILED; } - if (*pEnv == NULL) { + if (*pEnv == NULL) { // 2nd phase check if ((*pEnv = tsdbNewSmaEnv(pTsdb, path)) == NULL) { tsdbUnlockRepo(pTsdb); return TSDB_CODE_FAILED; @@ -152,7 +157,7 @@ static int32_t tsdbInitSmaEnv(STsdb *pTsdb, const char *path, SSmaEnv **pEnv) { } if (tsdbUnlockRepo(pTsdb) != 0) { - tsdbFreeSmaEnv(*pEnv); + *pEnv = tsdbFreeSmaEnv(*pEnv); return TSDB_CODE_FAILED; } @@ -244,6 +249,39 @@ int32_t tsdbDestroySmaState(SSmaStat *pSmaStat) { } } +static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) { + switch (smaType) { + case TSDB_SMA_TYPE_TIME_RANGE: + if (pTsdb->pTSmaEnv) { + return TSDB_CODE_SUCCESS; + } + break; + case TSDB_SMA_TYPE_ROLLUP: + if (pTsdb->pRSmaEnv) { + return TSDB_CODE_SUCCESS; + } + break; + default: + terrno = TSDB_CODE_INVALID_PARA; + return TSDB_CODE_FAILED; + } + + // SDiskID did = {0}; + SSmaEnv *pEnv = NULL; + char smaPath[TSDB_FILENAME_LEN] = "/proj/.sma/"; + if (tsdbInitSmaEnv(pTsdb, smaPath, &pEnv) != TSDB_CODE_SUCCESS) { + return TSDB_CODE_FAILED; + } + + if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { + pTsdb->pTSmaEnv = pEnv; + } else { + pTsdb->pRSmaEnv = pEnv; + } + + return TSDB_CODE_SUCCESS; +}; + /** * @brief Update expired window according to msg from stream computing module. * @@ -253,26 +291,17 @@ int32_t tsdbDestroySmaState(SSmaStat *pSmaStat) { * @return int32_t */ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, int8_t smaType, char *msg) { - STsdbCfg *pCfg = REPO_CFG(pTsdb); - SSmaEnv * pEnv = NULL; - if (!msg || !pTsdb->pMeta) { terrno = TSDB_CODE_INVALID_PTR; return TSDB_CODE_FAILED; } - char smaPath[TSDB_FILENAME_LEN] = "/proj/.sma/"; - if (tsdbInitSmaEnv(pTsdb, smaPath, &pEnv) != TSDB_CODE_SUCCESS) { + if (tsdbCheckAndInitSmaEnv(pTsdb, smaType) != TSDB_CODE_SUCCESS) { + terrno = TSDB_CODE_TDB_INIT_FAILED; return TSDB_CODE_FAILED; } - if (smaType == TSDB_SMA_TYPE_TIME_RANGE) { - pTsdb->pTSmaEnv = pEnv; - } else if (smaType == TSDB_SMA_TYPE_ROLLUP) { - pTsdb->pRSmaEnv = pEnv; - } else { - ASSERT(0); - } + SSmaEnv *pEnv = REPO_SMA_ENV(pTsdb, smaType); // TODO: decode the msg => start int64_t indexUid = SMA_TEST_INDEX_UID; @@ -308,7 +337,6 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, int8_t smaType, char *msg) { } pItem->pSma = pSma; - // TODO: change indexName to indexUid if (taosHashPut(pItemsHash, &indexUid, sizeof(indexUid), &pItem, sizeof(pItem)) != 0) { // If error occurs during put smaStatItem, free the resources of pItem taosHashCleanup(pItem->expiredWindows); @@ -378,32 +406,32 @@ static int32_t tsdbResetExpiredWindow(SSmaStat *pStat, int64_t indexUid, TSKEY s static int32_t tsdbGetSmaStorageLevel(int64_t interval, int8_t intervalUnit) { // TODO: configurable for SMA_STORAGE_SPLIT_HOURS? switch (intervalUnit) { - case TD_TIME_UNIT_HOUR: + case TIME_UNIT_HOUR: if (interval < SMA_STORAGE_SPLIT_HOURS) { return SMA_STORAGE_LEVEL_DFILESET; } break; - case TD_TIME_UNIT_MINUTE: + case TIME_UNIT_MINUTE: if (interval < 60 * SMA_STORAGE_SPLIT_HOURS) { return SMA_STORAGE_LEVEL_DFILESET; } break; - case TD_TIME_UNIT_SEC: + case TIME_UNIT_SECOND: if (interval < 3600 * SMA_STORAGE_SPLIT_HOURS) { return SMA_STORAGE_LEVEL_DFILESET; } break; - case TD_TIME_UNIT_MILLISEC: + case TIME_UNIT_MILLISECOND: if (interval < 3600 * 1e3 * SMA_STORAGE_SPLIT_HOURS) { return SMA_STORAGE_LEVEL_DFILESET; } break; - case TD_TIME_UNIT_MICROSEC: + case TIME_UNIT_MICROSECOND: if (interval < 3600 * 1e6 * SMA_STORAGE_SPLIT_HOURS) { return SMA_STORAGE_LEVEL_DFILESET; } break; - case TD_TIME_UNIT_NANOSEC: + case TIME_UNIT_NANOSECOND: if (interval < 3600 * 1e9 * SMA_STORAGE_SPLIT_HOURS) { return SMA_STORAGE_LEVEL_DFILESET; } @@ -429,8 +457,8 @@ static int32_t tsdbInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, uint32_t k // TODO: insert sma data blocks into B+Tree tsdbDebug("vgId:%d insert sma data blocks into %s: smaKey %" PRIx64 "-%" PRIu16 "-%" PRIx64 ", dataLen %d", - REPO_ID(pSmaH->pTsdb), pDBFile->path, *(tb_uid_t *)smaKey, *(uint16_t *)POINTER_SHIFT(smaKey, 8), - *(int64_t *)POINTER_SHIFT(smaKey, 10), dataLen); + REPO_ID(pSmaH->pTsdb), pDBFile->path, *(tb_uid_t *)smaKey, *(uint16_t *)POINTER_SHIFT(smaKey, 8), + *(int64_t *)POINTER_SHIFT(smaKey, 10), dataLen); if (tsdbSaveSmaToDB(pDBFile, smaKey, keyLen, pData, dataLen) != 0) { return TSDB_CODE_FAILED; @@ -447,66 +475,73 @@ static int32_t tsdbInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, uint32_t k return TSDB_CODE_SUCCESS; } +/** + * @brief Approximate value for week/month/year. + * + * @param interval + * @param intervalUnit + * @param precision + * @return int64_t + */ static int64_t tsdbGetIntervalByPrecision(int64_t interval, uint8_t intervalUnit, int8_t precision) { - if (intervalUnit < TD_TIME_UNIT_MILLISEC) { - switch (intervalUnit) { - case TD_TIME_UNIT_YEAR: - case TD_TIME_UNIT_SEASON: - case TD_TIME_UNIT_MONTH: - case TD_TIME_UNIT_WEEK: - // illegal time unit - tsdbError("invalid interval unit: %d\n", intervalUnit); - TASSERT(0); - break; - case TD_TIME_UNIT_DAY: // the interval for tSma calculation must <= day - interval *= 86400 * 1e3; - break; - case TD_TIME_UNIT_HOUR: - interval *= 3600 * 1e3; - break; - case TD_TIME_UNIT_MINUTE: - interval *= 60 * 1e3; - break; - case TD_TIME_UNIT_SEC: - interval *= 1e3; - break; - default: - break; - } + switch (intervalUnit) { + case TIME_UNIT_YEAR: // approximate value + interval *= 365 * 86400 * 1e3; + break; + case TIME_UNIT_MONTH: // approximate value + interval *= 30 * 86400 * 1e3; + break; + case TIME_UNIT_WEEK: // approximate value + interval *= 7 * 86400 * 1e3; + break; + case TIME_UNIT_DAY: // the interval for tSma calculation must <= day + interval *= 86400 * 1e3; + break; + case TIME_UNIT_HOUR: + interval *= 3600 * 1e3; + break; + case TIME_UNIT_MINUTE: + interval *= 60 * 1e3; + break; + case TIME_UNIT_SECOND: + interval *= 1e3; + break; + default: + break; } switch (precision) { case TSDB_TIME_PRECISION_MILLI: - if (TD_TIME_UNIT_MICROSEC == intervalUnit) { // us + if (TIME_UNIT_MICROSECOND == intervalUnit) { // us return interval / 1e3; - } else if (TD_TIME_UNIT_NANOSEC == intervalUnit) { // nano second + } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // nano second return interval / 1e6; } else { return interval; } break; case TSDB_TIME_PRECISION_MICRO: - if (TD_TIME_UNIT_MICROSEC == intervalUnit) { // us + if (TIME_UNIT_MICROSECOND == intervalUnit) { // us return interval; - } else if (TD_TIME_UNIT_NANOSEC == intervalUnit) { // nano second + } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // nano second return interval / 1e3; } else { return interval * 1e3; } break; case TSDB_TIME_PRECISION_NANO: - if (TD_TIME_UNIT_MICROSEC == intervalUnit) { + if (TIME_UNIT_MICROSECOND == intervalUnit) { return interval * 1e3; - } else if (TD_TIME_UNIT_NANOSEC == intervalUnit) { // nano second + } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // nano second return interval; } else { return interval * 1e6; } break; default: // ms - if (TD_TIME_UNIT_MICROSEC == intervalUnit) { // us + if (TIME_UNIT_MICROSECOND == intervalUnit) { // us return interval / 1e3; - } else if (TD_TIME_UNIT_NANOSEC == intervalUnit) { // nano second + } else if (TIME_UNIT_NANOSECOND == intervalUnit) { // nano second return interval / 1e6; } else { return interval; @@ -800,10 +835,19 @@ static bool tsdbSetAndOpenTSmaFile(STSmaReadH *pReadH, TSKEY *queryKey) { static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval, int8_t intervalUnit, tb_uid_t tableUid, col_id_t colId, TSKEY querySkey, int32_t nMaxResult) { + if (!pTsdb->pTSmaEnv) { + terrno = TSDB_CODE_INVALID_PTR; + tsdbWarn("vgId:%d getTSmaDataImpl failed since pTSmaEnv is NULL", REPO_ID(pTsdb)); + return TSDB_CODE_FAILED; + } + SSmaStatItem *pItem = (SSmaStatItem *)taosHashGet(SMA_ENV_STAT_ITEMS(pTsdb->pTSmaEnv), &indexUid, sizeof(indexUid)); if (pItem == NULL) { - // mark all window as expired and notify query module to query raw TS data. - return TSDB_CODE_SUCCESS; + // Normally pItem should not be NULL, mark all windows as expired and notify query module to fetch raw TS data if + // it's NULL. + terrno = TSDB_CODE_TDB_INVALID_ACTION; + tsdbWarn("vgId:%d getTSmaDataImpl failed since no index %" PRIi64 " in local cache", REPO_ID(pTsdb), indexUid); + return TSDB_CODE_FAILED; } #if 0 @@ -815,6 +859,7 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_ } } #endif + #if 0 if (taosHashGet(pItem->expiredWindows, &querySkey, sizeof(TSKEY)) != NULL) { // TODO: mark this window as expired. @@ -835,8 +880,8 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_ tsdbEncodeTSmaKey(tableUid, colId, querySkey, (void **)&pSmaKey); tsdbDebug("vgId:%d get sma data from %s: smaKey %" PRIx64 "-%" PRIu16 "-%" PRIx64 ", keyLen %d", REPO_ID(pTsdb), - tReadH.dFile.path, *(tb_uid_t *)smaKey, *(uint16_t *)POINTER_SHIFT(smaKey, 8), - *(int64_t *)POINTER_SHIFT(smaKey, 10), SMA_KEY_LEN); + tReadH.dFile.path, *(tb_uid_t *)smaKey, *(uint16_t *)POINTER_SHIFT(smaKey, 8), + *(int64_t *)POINTER_SHIFT(smaKey, 10), SMA_KEY_LEN); void * result = NULL; uint32_t valueSize = 0; @@ -947,7 +992,6 @@ int32_t tsdbUpdateSmaWindow(STsdb *pTsdb, int8_t smaType, char *msg) { * @brief Insert Time-range-wise Rollup Sma(RSma) data * * @param pTsdb - * @param param * @param msg * @return int32_t */ diff --git a/source/dnode/vnode/test/tsdbSmaTest.cpp b/source/dnode/vnode/test/tsdbSmaTest.cpp index 18dca33bda..96fd35e700 100644 --- a/source/dnode/vnode/test/tsdbSmaTest.cpp +++ b/source/dnode/vnode/test/tsdbSmaTest.cpp @@ -37,9 +37,9 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) { // encode STSma tSma = {0}; tSma.version = 0; - tSma.intervalUnit = TD_TIME_UNIT_DAY; + tSma.intervalUnit = TIME_UNIT_DAY; tSma.interval = 1; - tSma.slidingUnit = TD_TIME_UNIT_HOUR; + tSma.slidingUnit = TIME_UNIT_HOUR; tSma.sliding = 0; tstrncpy(tSma.indexName, "sma_index_test", TSDB_INDEX_NAME_LEN); tstrncpy(tSma.timezone, "Asia/Shanghai", TD_TIMEZONE_LEN); @@ -50,37 +50,37 @@ TEST(testCase, tSma_Meta_Encode_Decode_Test) { uint32_t bufLen = tEncodeTSmaWrapper(NULL, &tSmaWrapper); void *buf = calloc(bufLen, 1); - assert(buf != NULL); + ASSERT_NE(buf, nullptr); STSmaWrapper *pSW = (STSmaWrapper *)buf; uint32_t len = tEncodeTSmaWrapper(&buf, &tSmaWrapper); - EXPECT_EQ(len, bufLen); + ASSERT_EQ(len, bufLen); // decode STSmaWrapper dstTSmaWrapper = {0}; void * result = tDecodeTSmaWrapper(pSW, &dstTSmaWrapper); - assert(result != NULL); + ASSERT_NE(result, nullptr); - EXPECT_EQ(tSmaWrapper.number, dstTSmaWrapper.number); + ASSERT_EQ(tSmaWrapper.number, dstTSmaWrapper.number); for (int i = 0; i < tSmaWrapper.number; ++i) { STSma *pSma = tSmaWrapper.tSma + i; STSma *qSma = dstTSmaWrapper.tSma + i; - EXPECT_EQ(pSma->version, qSma->version); - EXPECT_EQ(pSma->intervalUnit, qSma->intervalUnit); - EXPECT_EQ(pSma->slidingUnit, qSma->slidingUnit); - EXPECT_STRCASEEQ(pSma->indexName, qSma->indexName); - EXPECT_STRCASEEQ(pSma->timezone, qSma->timezone); - EXPECT_EQ(pSma->indexUid, qSma->indexUid); - EXPECT_EQ(pSma->tableUid, qSma->tableUid); - EXPECT_EQ(pSma->interval, qSma->interval); - EXPECT_EQ(pSma->sliding, qSma->sliding); - EXPECT_EQ(pSma->exprLen, qSma->exprLen); - EXPECT_STRCASEEQ(pSma->expr, qSma->expr); - EXPECT_EQ(pSma->tagsFilterLen, qSma->tagsFilterLen); - EXPECT_STRCASEEQ(pSma->tagsFilter, qSma->tagsFilter); + ASSERT_EQ(pSma->version, qSma->version); + ASSERT_EQ(pSma->intervalUnit, qSma->intervalUnit); + ASSERT_EQ(pSma->slidingUnit, qSma->slidingUnit); + ASSERT_STRCASEEQ(pSma->indexName, qSma->indexName); + ASSERT_STRCASEEQ(pSma->timezone, qSma->timezone); + ASSERT_EQ(pSma->indexUid, qSma->indexUid); + ASSERT_EQ(pSma->tableUid, qSma->tableUid); + ASSERT_EQ(pSma->interval, qSma->interval); + ASSERT_EQ(pSma->sliding, qSma->sliding); + ASSERT_EQ(pSma->exprLen, qSma->exprLen); + ASSERT_STRCASEEQ(pSma->expr, qSma->expr); + ASSERT_EQ(pSma->tagsFilterLen, qSma->tagsFilterLen); + ASSERT_STRCASEEQ(pSma->tagsFilter, qSma->tagsFilter); } // resource release @@ -103,9 +103,9 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { // encode STSma tSma = {0}; tSma.version = 0; - tSma.intervalUnit = TD_TIME_UNIT_DAY; + tSma.intervalUnit = TIME_UNIT_DAY; tSma.interval = 1; - tSma.slidingUnit = TD_TIME_UNIT_HOUR; + tSma.slidingUnit = TIME_UNIT_HOUR; tSma.sliding = 0; tSma.indexUid = indexUid1; tstrncpy(tSma.indexName, smaIndexName1, TSDB_INDEX_NAME_LEN); @@ -114,10 +114,12 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { tSma.exprLen = strlen(expr); tSma.expr = (char *)calloc(tSma.exprLen + 1, 1); + ASSERT_NE(tSma.expr, nullptr); tstrncpy(tSma.expr, expr, tSma.exprLen + 1); tSma.tagsFilterLen = strlen(tagsFilter); tSma.tagsFilter = (char *)calloc(tSma.tagsFilterLen + 1, 1); + ASSERT_NE(tSma.tagsFilter, nullptr); tstrncpy(tSma.tagsFilter, tagsFilter, tSma.tagsFilterLen + 1); SMeta * pMeta = NULL; @@ -129,18 +131,18 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { pMeta = metaOpen(smaTestDir, pMetaCfg, NULL); assert(pMeta != NULL); // save index 1 - EXPECT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); + ASSERT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); pSmaCfg->indexUid = indexUid2; tstrncpy(pSmaCfg->indexName, smaIndexName2, TSDB_INDEX_NAME_LEN); pSmaCfg->version = 1; - pSmaCfg->intervalUnit = TD_TIME_UNIT_HOUR; + pSmaCfg->intervalUnit = TIME_UNIT_HOUR; pSmaCfg->interval = 1; - pSmaCfg->slidingUnit = TD_TIME_UNIT_MINUTE; + pSmaCfg->slidingUnit = TIME_UNIT_MINUTE; pSmaCfg->sliding = 5; // save index 2 - EXPECT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); + ASSERT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); // get value by indexName STSma *qSmaCfg = NULL; @@ -150,8 +152,8 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { printf("timezone1 = %s\n", qSmaCfg->timezone); printf("expr1 = %s\n", qSmaCfg->expr != NULL ? qSmaCfg->expr : ""); printf("tagsFilter1 = %s\n", qSmaCfg->tagsFilter != NULL ? qSmaCfg->tagsFilter : ""); - EXPECT_STRCASEEQ(qSmaCfg->indexName, smaIndexName1); - EXPECT_EQ(qSmaCfg->tableUid, tSma.tableUid); + ASSERT_STRCASEEQ(qSmaCfg->indexName, smaIndexName1); + ASSERT_EQ(qSmaCfg->tableUid, tSma.tableUid); tdDestroyTSma(qSmaCfg); tfree(qSmaCfg); @@ -161,8 +163,8 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { printf("timezone2 = %s\n", qSmaCfg->timezone); printf("expr2 = %s\n", qSmaCfg->expr != NULL ? qSmaCfg->expr : ""); printf("tagsFilter2 = %s\n", qSmaCfg->tagsFilter != NULL ? qSmaCfg->tagsFilter : ""); - EXPECT_STRCASEEQ(qSmaCfg->indexName, smaIndexName2); - EXPECT_EQ(qSmaCfg->interval, tSma.interval); + ASSERT_STRCASEEQ(qSmaCfg->indexName, smaIndexName2); + ASSERT_EQ(qSmaCfg->interval, tSma.interval); tdDestroyTSma(qSmaCfg); tfree(qSmaCfg); @@ -178,25 +180,25 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { printf("indexName = %s\n", indexName); ++indexCnt; } - EXPECT_EQ(indexCnt, nCntTSma); + ASSERT_EQ(indexCnt, nCntTSma); metaCloseSmaCurosr(pSmaCur); // get wrapper by table uid STSmaWrapper *pSW = metaGetSmaInfoByTable(pMeta, tbUid); assert(pSW != NULL); - EXPECT_EQ(pSW->number, nCntTSma); - EXPECT_STRCASEEQ(pSW->tSma->indexName, smaIndexName1); - EXPECT_STRCASEEQ(pSW->tSma->timezone, timezone); - EXPECT_STRCASEEQ(pSW->tSma->expr, expr); - EXPECT_STRCASEEQ(pSW->tSma->tagsFilter, tagsFilter); - EXPECT_EQ(pSW->tSma->indexUid, indexUid1); - EXPECT_EQ(pSW->tSma->tableUid, tbUid); - EXPECT_STRCASEEQ((pSW->tSma + 1)->indexName, smaIndexName2); - EXPECT_STRCASEEQ((pSW->tSma + 1)->timezone, timezone); - EXPECT_STRCASEEQ((pSW->tSma + 1)->expr, expr); - EXPECT_STRCASEEQ((pSW->tSma + 1)->tagsFilter, tagsFilter); - EXPECT_EQ((pSW->tSma + 1)->indexUid, indexUid2); - EXPECT_EQ((pSW->tSma + 1)->tableUid, tbUid); + ASSERT_EQ(pSW->number, nCntTSma); + ASSERT_STRCASEEQ(pSW->tSma->indexName, smaIndexName1); + ASSERT_STRCASEEQ(pSW->tSma->timezone, timezone); + ASSERT_STRCASEEQ(pSW->tSma->expr, expr); + ASSERT_STRCASEEQ(pSW->tSma->tagsFilter, tagsFilter); + ASSERT_EQ(pSW->tSma->indexUid, indexUid1); + ASSERT_EQ(pSW->tSma->tableUid, tbUid); + ASSERT_STRCASEEQ((pSW->tSma + 1)->indexName, smaIndexName2); + ASSERT_STRCASEEQ((pSW->tSma + 1)->timezone, timezone); + ASSERT_STRCASEEQ((pSW->tSma + 1)->expr, expr); + ASSERT_STRCASEEQ((pSW->tSma + 1)->tagsFilter, tagsFilter); + ASSERT_EQ((pSW->tSma + 1)->indexUid, indexUid2); + ASSERT_EQ((pSW->tSma + 1)->tableUid, tbUid); tdDestroyTSmaWrapper(pSW); tfree(pSW); @@ -208,7 +210,7 @@ TEST(testCase, tSma_metaDB_Put_Get_Del_Test) { printf("metaGetSmaTbUids: uid[%" PRIu32 "] = %" PRIi64 "\n", i, *(tb_uid_t *)taosArrayGet(pUids, i)); // printf("metaGetSmaTbUids: index[%" PRIu32 "] = %s", i, (char *)taosArrayGet(pUids, i)); } - EXPECT_EQ(taosArrayGetSize(pUids), 1); + ASSERT_EQ(taosArrayGetSize(pUids), 1); taosArrayDestroy(pUids); // resource release @@ -231,7 +233,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { const tb_uid_t tbUid = 1234567890; const int64_t indexUid1 = 2000000001; const int64_t interval1 = 1; - const int8_t intervalUnit1 = TD_TIME_UNIT_DAY; + const int8_t intervalUnit1 = TIME_UNIT_DAY; const uint32_t nCntTSma = 2; TSKEY skey1 = 1646987196; const int64_t testSmaData1 = 100; @@ -239,9 +241,9 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { // encode STSma tSma = {0}; tSma.version = 0; - tSma.intervalUnit = TD_TIME_UNIT_DAY; + tSma.intervalUnit = TIME_UNIT_DAY; tSma.interval = 1; - tSma.slidingUnit = TD_TIME_UNIT_HOUR; + tSma.slidingUnit = TIME_UNIT_HOUR; tSma.sliding = 0; tSma.indexUid = indexUid1; tstrncpy(tSma.indexName, smaIndexName1, TSDB_INDEX_NAME_LEN); @@ -250,10 +252,12 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { tSma.exprLen = strlen(expr); tSma.expr = (char *)calloc(tSma.exprLen + 1, 1); + ASSERT_NE(tSma.expr, nullptr); tstrncpy(tSma.expr, expr, tSma.exprLen + 1); tSma.tagsFilterLen = strlen(tagsFilter); tSma.tagsFilter = (char *)calloc(tSma.tagsFilterLen + 1, 1); + ASSERT_NE(tSma.tagsFilter, nullptr); tstrncpy(tSma.tagsFilter, tagsFilter, tSma.tagsFilterLen + 1); SMeta * pMeta = NULL; @@ -265,7 +269,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { pMeta = metaOpen(smaTestDir, pMetaCfg, NULL); assert(pMeta != NULL); // save index 1 - EXPECT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); + ASSERT_EQ(metaSaveSmaToDB(pMeta, pSmaCfg), 0); // step 2: insert data STSmaDataWrapper *pSmaData = NULL; @@ -298,18 +302,19 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { } char *msg = (char *)calloc(100, 1); - EXPECT_EQ(tsdbUpdateSmaWindow(&tsdb, TSDB_SMA_TYPE_TIME_RANGE, msg), 0); + assert(msg != NULL); + ASSERT_EQ(tsdbUpdateSmaWindow(&tsdb, TSDB_SMA_TYPE_TIME_RANGE, msg), 0); // init int32_t allocCnt = 0; - int32_t allocStep = 40960; - int32_t buffer = 4096; + int32_t allocStep = 16384; + int32_t buffer = 1024; void * buf = NULL; - EXPECT_EQ(tsdbMakeRoom(&buf, allocStep), 0); + ASSERT_EQ(tsdbMakeRoom(&buf, allocStep), 0); int32_t bufSize = taosTSizeof(buf); int32_t numOfTables = 10; col_id_t numOfCols = 4096; - EXPECT_GT(numOfCols, 0); + ASSERT_GT(numOfCols, 0); pSmaData = (STSmaDataWrapper *)buf; printf(">> allocate [%d] time to %d and addr is %p\n", ++allocCnt, bufSize, pSmaData); @@ -326,7 +331,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { int32_t tableDataLen = sizeof(STSmaTbData); for (col_id_t c = 0; c < numOfCols; ++c) { if (bufSize - len - tableDataLen < buffer) { - EXPECT_EQ(tsdbMakeRoom(&buf, bufSize + allocStep), 0); + ASSERT_EQ(tsdbMakeRoom(&buf, bufSize + allocStep), 0); pSmaData = (STSmaDataWrapper *)buf; pTbData = (STSmaTbData *)POINTER_SHIFT(pSmaData, len); bufSize = taosTSizeof(buf); @@ -353,22 +358,22 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { } pSmaData->dataLen = (len - sizeof(STSmaDataWrapper)); - EXPECT_GE(bufSize, pSmaData->dataLen); + ASSERT_GE(bufSize, pSmaData->dataLen); // execute - EXPECT_EQ(tsdbInsertTSmaData(&tsdb, (char *)pSmaData), TSDB_CODE_SUCCESS); + ASSERT_EQ(tsdbInsertTSmaData(&tsdb, (char *)pSmaData), TSDB_CODE_SUCCESS); // step 3: query uint32_t checkDataCnt = 0; for (int32_t t = 0; t < numOfTables; ++t) { for (col_id_t c = 0; c < numOfCols; ++c) { - EXPECT_EQ(tsdbGetTSmaData(&tsdb, NULL, indexUid1, interval1, intervalUnit1, tbUid + t, + ASSERT_EQ(tsdbGetTSmaData(&tsdb, NULL, indexUid1, interval1, intervalUnit1, tbUid + t, c + PRIMARYKEY_TIMESTAMP_COL_ID, skey1, 1), TSDB_CODE_SUCCESS); ++checkDataCnt; } } - + printf("%s:%d The sma data check count for insert and query is %" PRIu32 "\n", __FILE__, __LINE__, checkDataCnt); // release data diff --git a/source/util/src/terror.c b/source/util/src/terror.c index f97df62ccc..469b944bf9 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -350,6 +350,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TDB_MESSED_MSG, "TSDB messed message") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_IVLD_TAG_VAL, "TSDB invalid tag value") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_CACHE_LAST_ROW, "TSDB no cache last row data") TAOS_DEFINE_ERROR(TSDB_CODE_TDB_NO_SMA_INDEX_IN_META, "No sma index in meta") +TAOS_DEFINE_ERROR(TSDB_CODE_TDB_TDB_ENV_OPEN_ERROR, "TDB env open error") // query TAOS_DEFINE_ERROR(TSDB_CODE_QRY_INVALID_QHANDLE, "Invalid handle") From 18f254a0178cd1487b3e31dee4994da4f30d3d9b Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Wed, 16 Mar 2022 18:29:31 +0800 Subject: [PATCH 28/37] task deploy and task exec --- include/common/tcommon.h | 21 +++-- include/common/tmsg.h | 100 ++++++++++++++------- include/common/tmsgdef.h | 1 + include/dnode/snode/snode.h | 3 +- source/common/src/tmsg.c | 72 ++++++++++----- source/dnode/mgmt/impl/src/dndSnode.c | 27 ++++-- source/dnode/mnode/impl/inc/mndDef.h | 10 +-- source/dnode/mnode/impl/inc/mndScheduler.h | 2 + source/dnode/mnode/impl/src/mndScheduler.c | 75 ++++++++++------ source/dnode/mnode/impl/src/mndStream.c | 7 ++ source/dnode/snode/CMakeLists.txt | 3 +- source/dnode/snode/inc/sndInt.h | 31 ++----- source/dnode/snode/src/snode.c | 75 +++++++++++++--- 13 files changed, 285 insertions(+), 142 deletions(-) diff --git a/include/common/tcommon.h b/include/common/tcommon.h index 23dd349861..cb8b077b47 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -58,7 +58,10 @@ typedef struct SDataBlockInfo { int32_t rows; int32_t rowSize; int32_t numOfCols; - union {int64_t uid; int64_t blockId;}; + union { + int64_t uid; + int64_t blockId; + }; } SDataBlockInfo; typedef struct SConstantItem { @@ -70,10 +73,10 @@ typedef struct SConstantItem { // info.numOfCols = taosArrayGetSize(pDataBlock) + taosArrayGetSize(pConstantList); typedef struct SSDataBlock { - SColumnDataAgg *pBlockAgg; - SArray *pDataBlock; // SArray - SArray *pConstantList; // SArray, it is a constant/tags value of the corresponding result value. - SDataBlockInfo info; + SColumnDataAgg* pBlockAgg; + SArray* pDataBlock; // SArray + SArray* pConstantList; // SArray, it is a constant/tags value of the corresponding result value. + SDataBlockInfo info; } SSDataBlock; typedef struct SVarColAttr { @@ -244,7 +247,7 @@ typedef struct SGroupbyExpr { typedef struct SFunctParam { int32_t type; - SColumn *pCol; + SColumn* pCol; SVariant param; } SFunctParam; @@ -262,12 +265,12 @@ typedef struct SResSchame { typedef struct SExprBasicInfo { SResSchema resSchema; int16_t numOfParams; // argument value of each function - SFunctParam *pParam; + SFunctParam* pParam; } SExprBasicInfo; typedef struct SExprInfo { - struct SExprBasicInfo base; - struct tExprNode *pExpr; + struct SExprBasicInfo base; + struct tExprNode* pExpr; } SExprInfo; typedef struct SStateWindow { diff --git a/include/common/tmsg.h b/include/common/tmsg.h index a3e35e1874..30f61374ea 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -24,6 +24,7 @@ #include "thash.h" #include "tlist.h" #include "trow.h" +#include "tuuid.h" #ifdef __cplusplus extern "C" { @@ -171,7 +172,7 @@ typedef struct { char db[TSDB_DB_FNAME_LEN]; int64_t dbId; int32_t vgVersion; - int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT + int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT } SBuildUseDBInput; typedef struct SField { @@ -427,10 +428,10 @@ typedef struct { int16_t slotId; }; - int16_t type; - int32_t bytes; - uint8_t precision; - uint8_t scale; + int16_t type; + int32_t bytes; + uint8_t precision; + uint8_t scale; } SColumnInfo; typedef struct { @@ -526,7 +527,7 @@ typedef struct { char db[TSDB_DB_FNAME_LEN]; int64_t dbId; int32_t vgVersion; - int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT + int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT } SUseDbReq; int32_t tSerializeSUseDbReq(void* buf, int32_t bufLen, SUseDbReq* pReq); @@ -553,15 +554,13 @@ int32_t tSerializeSQnodeListReq(void* buf, int32_t bufLen, SQnodeListReq* pReq); int32_t tDeserializeSQnodeListReq(void* buf, int32_t bufLen, SQnodeListReq* pReq); typedef struct { - SArray *epSetList; // SArray + SArray* epSetList; // SArray } SQnodeListRsp; int32_t tSerializeSQnodeListRsp(void* buf, int32_t bufLen, SQnodeListRsp* pRsp); int32_t tDeserializeSQnodeListRsp(void* buf, int32_t bufLen, SQnodeListRsp* pRsp); void tFreeSQnodeListRsp(SQnodeListRsp* pRsp); - - typedef struct { SArray* pArray; // Array of SUseDbRsp } SUseDbBatchRsp; @@ -777,7 +776,6 @@ typedef struct SVgroupInfo { int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT } SVgroupInfo; - typedef struct { int32_t numOfVgroups; SVgroupInfo vgroups[]; @@ -1062,8 +1060,8 @@ typedef struct { } STaskStatus; typedef struct { - int64_t refId; - SArray *taskStatus; //SArray + int64_t refId; + SArray* taskStatus; // SArray } SSchedulerStatusRsp; typedef struct { @@ -1072,35 +1070,31 @@ typedef struct { int8_t action; } STaskAction; - typedef struct SQueryNodeEpId { int32_t nodeId; // vgId or qnodeId SEp ep; } SQueryNodeEpId; - typedef struct { SMsgHead header; uint64_t sId; SQueryNodeEpId epId; - SArray *taskAction; //SArray + SArray* taskAction; // SArray } SSchedulerHbReq; -int32_t tSerializeSSchedulerHbReq(void *buf, int32_t bufLen, SSchedulerHbReq *pReq); -int32_t tDeserializeSSchedulerHbReq(void *buf, int32_t bufLen, SSchedulerHbReq *pReq); -void tFreeSSchedulerHbReq(SSchedulerHbReq *pReq); - +int32_t tSerializeSSchedulerHbReq(void* buf, int32_t bufLen, SSchedulerHbReq* pReq); +int32_t tDeserializeSSchedulerHbReq(void* buf, int32_t bufLen, SSchedulerHbReq* pReq); +void tFreeSSchedulerHbReq(SSchedulerHbReq* pReq); typedef struct { uint64_t seqId; SQueryNodeEpId epId; - SArray *taskStatus; //SArray + SArray* taskStatus; // SArray } SSchedulerHbRsp; -int32_t tSerializeSSchedulerHbRsp(void *buf, int32_t bufLen, SSchedulerHbRsp *pRsp); -int32_t tDeserializeSSchedulerHbRsp(void *buf, int32_t bufLen, SSchedulerHbRsp *pRsp); -void tFreeSSchedulerHbRsp(SSchedulerHbRsp *pRsp); - +int32_t tSerializeSSchedulerHbRsp(void* buf, int32_t bufLen, SSchedulerHbRsp* pRsp); +int32_t tDeserializeSSchedulerHbRsp(void* buf, int32_t bufLen, SSchedulerHbRsp* pRsp); +void tFreeSSchedulerHbRsp(SSchedulerHbRsp* pRsp); typedef struct { SMsgHead header; @@ -1370,7 +1364,7 @@ typedef struct SVCreateTbReq { } SVCreateTbReq, SVUpdateTbReq; typedef struct { - int tmp; // TODO: to avoid compile error + int tmp; // TODO: to avoid compile error } SVCreateTbRsp, SVUpdateTbRsp; int32_t tSerializeSVCreateTbReq(void** buf, SVCreateTbReq* pReq); @@ -1382,7 +1376,7 @@ typedef struct { } SVCreateTbBatchReq; typedef struct { - int tmp; // TODO: to avoid compile error + int tmp; // TODO: to avoid compile error } SVCreateTbBatchRsp; int32_t tSerializeSVCreateTbBatchReq(void** buf, SVCreateTbBatchReq* pReq); @@ -1396,7 +1390,7 @@ typedef struct { } SVDropTbReq; typedef struct { - int tmp; // TODO: to avoid compile error + int tmp; // TODO: to avoid compile error } SVDropTbRsp; int32_t tSerializeSVDropTbReq(void** buf, SVDropTbReq* pReq); @@ -1933,7 +1927,7 @@ typedef struct { } SVCreateTSmaReq; typedef struct { - int8_t type; // 0 status report, 1 update data + int8_t type; // 0 status report, 1 update data char indexName[TSDB_INDEX_NAME_LEN]; // STimeWindow windows; } STSmaMsg; @@ -1944,7 +1938,7 @@ typedef struct { } SVDropTSmaReq; typedef struct { - int tmp; // TODO: to avoid compile error + int tmp; // TODO: to avoid compile error } SVCreateTSmaRsp, SVDropTSmaRsp; int32_t tSerializeSVCreateTSmaReq(void** buf, SVCreateTSmaReq* pReq); @@ -2029,7 +2023,7 @@ static FORCE_INLINE int32_t tEncodeTSma(void** buf, const STSma* pSma) { tlen += taosEncodeFixedI64(buf, pSma->tableUid); tlen += taosEncodeFixedI64(buf, pSma->interval); tlen += taosEncodeFixedI64(buf, pSma->sliding); - + if (pSma->exprLen > 0) { tlen += taosEncodeString(buf, pSma->expr); } @@ -2064,7 +2058,6 @@ static FORCE_INLINE void* tDecodeTSma(void* buf, STSma* pSma) { buf = taosDecodeFixedI64(buf, &pSma->interval); buf = taosDecodeFixedI64(buf, &pSma->sliding); - if (pSma->exprLen > 0) { pSma->expr = (char*)calloc(pSma->exprLen, 1); if (pSma->expr != NULL) { @@ -2265,6 +2258,51 @@ static FORCE_INLINE void* tDecodeSMqCMGetSubEpRsp(void* buf, SMqCMGetSubEpRsp* p return buf; } +enum { + STREAM_TASK_STATUS__RUNNING = 1, + STREAM_TASK_STATUS__STOP, +}; + +typedef struct { + int64_t streamId; + int32_t taskId; + int32_t level; + int8_t status; + char* qmsg; + void* executor; + // void* stateStore; + // storage handle +} SStreamTask; + +static FORCE_INLINE SStreamTask* streamTaskNew(int64_t streamId, int32_t level) { + SStreamTask* pTask = (SStreamTask*)calloc(1, sizeof(SStreamTask)); + if (pTask == NULL) { + return NULL; + } + pTask->taskId = tGenIdPI32(); + pTask->status = STREAM_TASK_STATUS__RUNNING; + pTask->qmsg = NULL; + return pTask; +} + +int32_t tEncodeSStreamTask(SCoder* pEncoder, const SStreamTask* pTask); +int32_t tDecodeSStreamTask(SCoder* pDecoder, SStreamTask* pTask); +void tFreeSStreamTask(SStreamTask* pTask); + +typedef struct { + SMsgHead head; + SStreamTask* task; +} SStreamTaskDeployReq; + +typedef struct { + int32_t reserved; +} SStreamTaskDeployRsp; + +typedef struct { + SMsgHead head; + // TODO: other info needed by task +} SStreamTaskExecReq; + #pragma pack(pop) #ifdef __cplusplus diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index 03f8daad42..b30a325d7c 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -199,6 +199,7 @@ enum { // Requests handled by SNODE TD_NEW_MSG_SEG(TDMT_SND_MSG) + TD_DEF_MSG_TYPE(TDMT_SND_TASK_DEPLOY, "snode-task-deploy", SStreamTaskDeployReq, SStreamTaskDeployRsp) #if defined(TD_MSG_NUMBER_) TDMT_MAX diff --git a/include/dnode/snode/snode.h b/include/dnode/snode/snode.h index 21a93532e0..b25f8a8666 100644 --- a/include/dnode/snode/snode.h +++ b/include/dnode/snode/snode.h @@ -16,6 +16,7 @@ #ifndef _TD_SNODE_H_ #define _TD_SNODE_H_ +#include "tcommon.h" #include "tmsg.h" #include "trpc.h" @@ -78,7 +79,7 @@ int32_t sndGetLoad(SSnode *pSnode, SSnodeLoad *pLoad); * @param pRsp The response message * @return int32_t 0 for success, -1 for failure */ -int32_t sndProcessMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp); +// int32_t sndProcessMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp); int32_t sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg); diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index f26f19f3b2..121f5271b3 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -1467,8 +1467,7 @@ int32_t tDeserializeSUseDbReq(void *buf, int32_t bufLen, SUseDbReq *pReq) { return 0; } - -int32_t tSerializeSQnodeListReq(void* buf, int32_t bufLen, SQnodeListReq* pReq) { +int32_t tSerializeSQnodeListReq(void *buf, int32_t bufLen, SQnodeListReq *pReq) { SCoder encoder = {0}; tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); @@ -1499,7 +1498,7 @@ int32_t tSerializeSQnodeListRsp(void *buf, int32_t bufLen, SQnodeListRsp *pRsp) if (tStartEncode(&encoder) < 0) return -1; int32_t num = taosArrayGetSize(pRsp->epSetList); - if (tEncodeI32(&encoder, num) < 0) return -1; + if (tEncodeI32(&encoder, num) < 0) return -1; for (int32_t i = 0; i < num; ++i) { SEpSet *epSet = taosArrayGet(pRsp->epSetList, i); if (tEncodeSEpSet(&encoder, epSet) < 0) return -1; @@ -2491,27 +2490,27 @@ int32_t tSerializeSSchedulerHbReq(void *buf, int32_t bufLen, SSchedulerHbReq *pR tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); if (tStartEncode(&encoder) < 0) return -1; - if (tEncodeU64(&encoder, pReq->sId) < 0) return -1; - if (tEncodeI32(&encoder, pReq->epId.nodeId) < 0) return -1; + if (tEncodeU64(&encoder, pReq->sId) < 0) return -1; + if (tEncodeI32(&encoder, pReq->epId.nodeId) < 0) return -1; if (tEncodeU16(&encoder, pReq->epId.ep.port) < 0) return -1; - if (tEncodeCStr(&encoder, pReq->epId.ep.fqdn) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->epId.ep.fqdn) < 0) return -1; if (pReq->taskAction) { int32_t num = taosArrayGetSize(pReq->taskAction); - if (tEncodeI32(&encoder, num) < 0) return -1; + if (tEncodeI32(&encoder, num) < 0) return -1; for (int32_t i = 0; i < num; ++i) { STaskAction *action = taosArrayGet(pReq->taskAction, i); - if (tEncodeU64(&encoder, action->queryId) < 0) return -1; - if (tEncodeU64(&encoder, action->taskId) < 0) return -1; - if (tEncodeI8(&encoder, action->action) < 0) return -1; + if (tEncodeU64(&encoder, action->queryId) < 0) return -1; + if (tEncodeU64(&encoder, action->taskId) < 0) return -1; + if (tEncodeI8(&encoder, action->action) < 0) return -1; } } else { - if (tEncodeI32(&encoder, 0) < 0) return -1; + if (tEncodeI32(&encoder, 0) < 0) return -1; } tEndEncode(&encoder); int32_t tlen = encoder.pos; tCoderClear(&encoder); - + if (buf != NULL) { SMsgHead *pHead = (SMsgHead *)((char *)buf - headLen); pHead->vgId = htonl(pReq->header.vgId); @@ -2559,29 +2558,27 @@ int32_t tDeserializeSSchedulerHbReq(void *buf, int32_t bufLen, SSchedulerHbReq * void tFreeSSchedulerHbReq(SSchedulerHbReq *pReq) { taosArrayDestroy(pReq->taskAction); } - - int32_t tSerializeSSchedulerHbRsp(void *buf, int32_t bufLen, SSchedulerHbRsp *pRsp) { SCoder encoder = {0}; tCoderInit(&encoder, TD_LITTLE_ENDIAN, buf, bufLen, TD_ENCODER); if (tStartEncode(&encoder) < 0) return -1; - if (tEncodeU64(&encoder, pRsp->seqId) < 0) return -1; - if (tEncodeI32(&encoder, pRsp->epId.nodeId) < 0) return -1; + if (tEncodeU64(&encoder, pRsp->seqId) < 0) return -1; + if (tEncodeI32(&encoder, pRsp->epId.nodeId) < 0) return -1; if (tEncodeU16(&encoder, pRsp->epId.ep.port) < 0) return -1; - if (tEncodeCStr(&encoder, pRsp->epId.ep.fqdn) < 0) return -1; + if (tEncodeCStr(&encoder, pRsp->epId.ep.fqdn) < 0) return -1; if (pRsp->taskStatus) { int32_t num = taosArrayGetSize(pRsp->taskStatus); - if (tEncodeI32(&encoder, num) < 0) return -1; + if (tEncodeI32(&encoder, num) < 0) return -1; for (int32_t i = 0; i < num; ++i) { STaskStatus *status = taosArrayGet(pRsp->taskStatus, i); - if (tEncodeU64(&encoder, status->queryId) < 0) return -1; - if (tEncodeU64(&encoder, status->taskId) < 0) return -1; - if (tEncodeI64(&encoder, status->refId) < 0) return -1; - if (tEncodeI8(&encoder, status->status) < 0) return -1; + if (tEncodeU64(&encoder, status->queryId) < 0) return -1; + if (tEncodeU64(&encoder, status->taskId) < 0) return -1; + if (tEncodeI64(&encoder, status->refId) < 0) return -1; + if (tEncodeI8(&encoder, status->status) < 0) return -1; } } else { - if (tEncodeI32(&encoder, 0) < 0) return -1; + if (tEncodeI32(&encoder, 0) < 0) return -1; } tEndEncode(&encoder); @@ -2694,3 +2691,32 @@ void tFreeSCMCreateStreamReq(SCMCreateStreamReq *pReq) { tfree(pReq->physicalPlan); tfree(pReq->logicalPlan); } + +int32_t tEncodeSStreamTask(SCoder *pEncoder, const SStreamTask *pTask) { + if (tStartEncode(pEncoder) < 0) return -1; + if (tEncodeI64(pEncoder, pTask->streamId) < 0) return -1; + if (tEncodeI32(pEncoder, pTask->taskId) < 0) return -1; + if (tEncodeI32(pEncoder, pTask->level) < 0) return -1; + if (tEncodeI8(pEncoder, pTask->status) < 0) return -1; + if (tEncodeCStr(pEncoder, pTask->qmsg) < 0) return -1; + tEndEncode(pEncoder); + return pEncoder->pos; +} + +int32_t tDecodeSStreamTask(SCoder *pDecoder, SStreamTask *pTask) { + if (tStartDecode(pDecoder) < 0) return -1; + if (tDecodeI64(pDecoder, &pTask->streamId) < 0) return -1; + if (tDecodeI32(pDecoder, &pTask->taskId) < 0) return -1; + if (tDecodeI32(pDecoder, &pTask->level) < 0) return -1; + if (tDecodeI8(pDecoder, &pTask->status) < 0) return -1; + if (tDecodeCStr(pDecoder, (const char **)&pTask->qmsg) < 0) return -1; + tEndDecode(pDecoder); + return 0; +} + +void tFreeSStreamTask(SStreamTask *pTask) { + // TODO + /*free(pTask->qmsg);*/ + /*free(pTask->executor);*/ + /*free(pTask);*/ +} diff --git a/source/dnode/mgmt/impl/src/dndSnode.c b/source/dnode/mgmt/impl/src/dndSnode.c index 5ea8a841d2..8667952f2c 100644 --- a/source/dnode/mgmt/impl/src/dndSnode.c +++ b/source/dnode/mgmt/impl/src/dndSnode.c @@ -323,8 +323,8 @@ int32_t dndProcessDropSnodeReq(SDnode *pDnode, SRpcMsg *pReq) { } static void dndProcessSnodeUniqueQueue(SDnode *pDnode, STaosQall *qall, int32_t numOfMsgs) { - SSnodeMgmt *pMgmt = &pDnode->smgmt; - int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED; + /*SSnodeMgmt *pMgmt = &pDnode->smgmt;*/ + int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED; SSnode *pSnode = dndAcquireSnode(pDnode); if (pSnode != NULL) { @@ -334,22 +334,35 @@ static void dndProcessSnodeUniqueQueue(SDnode *pDnode, STaosQall *qall, int32_t sndProcessUMsg(pSnode, pMsg); + rpcFreeCont(pMsg->pCont); + taosFreeQitem(pMsg); + } + dndReleaseSnode(pDnode, pSnode); + } else { + for (int32_t i = 0; i < numOfMsgs; i++) { + SRpcMsg *pMsg = NULL; + taosGetQitem(qall, (void **)&pMsg); + SRpcMsg rpcRsp = {.handle = pMsg->handle, .ahandle = pMsg->ahandle, .code = code}; + rpcSendResponse(&rpcRsp); + rpcFreeCont(pMsg->pCont); taosFreeQitem(pMsg); } } - dndReleaseSnode(pDnode, pSnode); } static void dndProcessSnodeSharedQueue(SDnode *pDnode, SRpcMsg *pMsg) { - SSnodeMgmt *pMgmt = &pDnode->smgmt; - int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED; + /*SSnodeMgmt *pMgmt = &pDnode->smgmt;*/ + int32_t code = TSDB_CODE_DND_SNODE_NOT_DEPLOYED; SSnode *pSnode = dndAcquireSnode(pDnode); if (pSnode != NULL) { - code = sndProcessSMsg(pSnode, pMsg); + sndProcessSMsg(pSnode, pMsg); + dndReleaseSnode(pDnode, pSnode); + } else { + SRpcMsg rpcRsp = {.handle = pMsg->handle, .ahandle = pMsg->ahandle, .code = code}; + rpcSendResponse(&rpcRsp); } - dndReleaseSnode(pDnode, pSnode); #if 0 if (pMsg->msgType & 1u) { diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index a7116b72ff..8ea9cc141f 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -85,6 +85,8 @@ typedef enum { TRN_TYPE_REBALANCE = 1017, TRN_TYPE_COMMIT_OFFSET = 1018, TRN_TYPE_CREATE_STREAM = 1019, + TRN_TYPE_DROP_STREAM = 1020, + TRN_TYPE_ALTER_STREAM = 1021, TRN_TYPE_BASIC_SCOPE_END, TRN_TYPE_GLOBAL_SCOPE = 2000, TRN_TYPE_CREATE_DNODE = 2001, @@ -679,12 +681,6 @@ static FORCE_INLINE void* tDecodeSMqConsumerObj(void* buf, SMqConsumerObj* pCons return buf; } -typedef struct { - int32_t taskId; - int32_t level; - SSubplan* plan; -} SStreamTaskMeta; - typedef struct { char name[TSDB_TOPIC_FNAME_LEN]; char db[TSDB_DB_FNAME_LEN]; @@ -700,7 +696,7 @@ typedef struct { char* sql; char* logicalPlan; char* physicalPlan; - SArray* tasks; // SArray> + SArray* tasks; // SArray> } SStreamObj; int32_t tEncodeSStreamObj(SCoder* pEncoder, const SStreamObj* pObj); diff --git a/source/dnode/mnode/impl/inc/mndScheduler.h b/source/dnode/mnode/impl/inc/mndScheduler.h index 3bf6e0c33a..42951beca2 100644 --- a/source/dnode/mnode/impl/inc/mndScheduler.h +++ b/source/dnode/mnode/impl/inc/mndScheduler.h @@ -27,6 +27,8 @@ void mndCleanupScheduler(SMnode* pMnode); int32_t mndSchedInitSubEp(SMnode* pMnode, const SMqTopicObj* pTopic, SMqSubscribeObj* pSub); +int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream); + #ifdef __cplusplus } #endif diff --git a/source/dnode/mnode/impl/src/mndScheduler.c b/source/dnode/mnode/impl/src/mndScheduler.c index 855e244daa..16b1ba8a5c 100644 --- a/source/dnode/mnode/impl/src/mndScheduler.c +++ b/source/dnode/mnode/impl/src/mndScheduler.c @@ -31,7 +31,7 @@ #include "tname.h" #include "tuuid.h" -int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) { +int32_t mndScheduleStream(SMnode* pMnode, STrans* pTrans, SStreamObj* pStream) { SSdb* pSdb = pMnode->pSdb; SVgObj* pVgroup = NULL; SQueryPlan* pPlan = qStringToQueryPlan(pStream->physicalPlan); @@ -41,17 +41,18 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) { } ASSERT(pStream->vgNum == 0); - int32_t levelNum = LIST_LENGTH(pPlan->pSubplans); - pStream->tasks = taosArrayInit(levelNum, sizeof(SArray)); + int32_t totLevel = LIST_LENGTH(pPlan->pSubplans); + pStream->tasks = taosArrayInit(totLevel, sizeof(SArray)); - for (int32_t i = 0; i < levelNum; i++) { - SArray* taskOneLevel = taosArrayInit(0, sizeof(SStreamTaskMeta)); - SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, i); + int32_t msgLen; + for (int32_t level = 0; level < totLevel; level++) { + SArray* taskOneLevel = taosArrayInit(0, sizeof(SStreamTask)); + SNodeListNode* inner = nodesListGetNode(pPlan->pSubplans, level); int32_t opNum = LIST_LENGTH(inner->pNodeList); ASSERT(opNum == 1); - SSubplan* plan = nodesListGetNode(inner->pNodeList, 0); - if (i == 0) { + SSubplan* plan = nodesListGetNode(inner->pNodeList, level); + if (level == 0) { ASSERT(plan->type == SUBPLAN_TYPE_SCAN); void* pIter = NULL; while (1) { @@ -63,15 +64,19 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) { } pStream->vgNum++; + // send to vnode + + SStreamTask* pTask = streamTaskNew(pStream->uid, level); + plan->execNode.nodeId = pVgroup->vgId; plan->execNode.epSet = mndGetVgroupEpset(pMnode, pVgroup); - SStreamTaskMeta task = { - .taskId = tGenIdPI32(), - .level = i, - .plan = plan, - }; - // send to vnode - taosArrayPush(taskOneLevel, &task); + if (qSubPlanToString(plan, &pTask->qmsg, &msgLen) < 0) { + sdbRelease(pSdb, pVgroup); + qDestroyQueryPlan(pPlan); + terrno = TSDB_CODE_QRY_INVALID_INPUT; + return -1; + } + taosArrayPush(taskOneLevel, pTask); } } else if (plan->subplanType == SUBPLAN_TYPE_SCAN) { // duplicatable @@ -82,22 +87,36 @@ int32_t mndScheduleStream(SMnode* pMnode, SStreamObj* pStream) { // if has snode, set to shared thread num in snode parallel = SND_SHARED_THREAD_NUM; - for (int32_t j = 0; j < parallel; j++) { - SStreamTaskMeta task = { - .taskId = tGenIdPI32(), - .level = i, - .plan = plan, - }; - taosArrayPush(taskOneLevel, &task); + for (int32_t i = 0; i < parallel; i++) { + SStreamTask* pTask = streamTaskNew(pStream->uid, level); + + // TODO:get snode id and ep + plan->execNode.nodeId = pVgroup->vgId; + plan->execNode.epSet = mndGetVgroupEpset(pMnode, pVgroup); + + if (qSubPlanToString(plan, &pTask->qmsg, &msgLen) < 0) { + qDestroyQueryPlan(pPlan); + terrno = TSDB_CODE_QRY_INVALID_INPUT; + return -1; + } + + taosArrayPush(taskOneLevel, pTask); } } else { // not duplicatable - SStreamTaskMeta task = { - .taskId = tGenIdPI32(), - .level = i, - .plan = plan, - }; - taosArrayPush(taskOneLevel, &task); + SStreamTask* pTask = streamTaskNew(pStream->uid, level); + + // TODO:get snode id and ep + plan->execNode.nodeId = pVgroup->vgId; + plan->execNode.epSet = mndGetVgroupEpset(pMnode, pVgroup); + + if (qSubPlanToString(plan, &pTask->qmsg, &msgLen) < 0) { + sdbRelease(pSdb, pVgroup); + qDestroyQueryPlan(pPlan); + terrno = TSDB_CODE_QRY_INVALID_INPUT; + return -1; + } + taosArrayPush(taskOneLevel, pTask); } taosArrayPush(pStream->tasks, taskOneLevel); } diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index 54ad9cd7e2..67011dfe8a 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -18,6 +18,7 @@ #include "mndDb.h" #include "mndDnode.h" #include "mndMnode.h" +#include "mndScheduler.h" #include "mndShow.h" #include "mndStb.h" #include "mndTrans.h" @@ -237,6 +238,12 @@ static int32_t mndCreateStream(SMnode *pMnode, SMnodeMsg *pReq, SCMCreateStreamR } sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY); + if (mndScheduleStream(pMnode, pTrans, &streamObj) < 0) { + mError("stream:%ld, schedule stream since %s", streamObj.uid, terrstr()); + mndTransDrop(pTrans); + return -1; + } + if (mndTransPrepare(pMnode, pTrans) != 0) { mError("trans:%d, failed to prepare since %s", pTrans->id, terrstr()); mndTransDrop(pTrans); diff --git a/source/dnode/snode/CMakeLists.txt b/source/dnode/snode/CMakeLists.txt index dafd5d6594..d1b1abdf1d 100644 --- a/source/dnode/snode/CMakeLists.txt +++ b/source/dnode/snode/CMakeLists.txt @@ -7,8 +7,9 @@ target_include_directories( ) target_link_libraries( snode + PRIVATE executor PRIVATE transport PRIVATE os PRIVATE common PRIVATE util -) \ No newline at end of file +) diff --git a/source/dnode/snode/inc/sndInt.h b/source/dnode/snode/inc/sndInt.h index 3fe816845d..e5f6c3c266 100644 --- a/source/dnode/snode/inc/sndInt.h +++ b/source/dnode/snode/inc/sndInt.h @@ -38,13 +38,8 @@ enum { STREAM_STATUS__DELETING, }; -enum { - STREAM_TASK_STATUS__RUNNING = 1, - STREAM_TASK_STATUS__STOP, -}; - typedef struct { - SHashObj* pHash; // taskId -> streamTask + SHashObj* pHash; // taskId -> SStreamTask } SStreamMeta; typedef struct SSnode { @@ -52,26 +47,16 @@ typedef struct SSnode { SSnodeOpt cfg; } SSnode; -typedef struct { - int64_t streamId; - int32_t taskId; - int32_t IdxInLevel; - int32_t level; -} SStreamTaskInfo; +SStreamMeta* sndMetaNew(); +void sndMetaDelete(SStreamMeta* pMeta); -typedef struct { - SStreamTaskInfo meta; - int8_t status; - void* executor; - void* stateStore; - // storage handle -} SStreamTask; +int32_t sndMetaDeployTask(SStreamMeta* pMeta, SStreamTask* pTask); +int32_t sndMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId); -int32_t sndCreateTask(); -int32_t sndDropTaskOfStream(int64_t streamId); +int32_t sndDropTaskOfStream(SStreamMeta* pMeta, int64_t streamId); -int32_t sndStopTaskOfStream(int64_t streamId); -int32_t sndResumeTaskOfStream(int64_t streamId); +int32_t sndStopTaskOfStream(SStreamMeta* pMeta, int64_t streamId); +int32_t sndResumeTaskOfStream(SStreamMeta* pMeta, int64_t streamId); #ifdef __cplusplus } diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c index 74e41d45c5..80e33bd971 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -13,40 +13,91 @@ * along with this program. If not, see . */ +#include "executor.h" #include "sndInt.h" #include "tuuid.h" SSnode *sndOpen(const char *path, const SSnodeOpt *pOption) { SSnode *pSnode = calloc(1, sizeof(SSnode)); + if (pSnode == NULL) { + return NULL; + } memcpy(&pSnode->cfg, pOption, sizeof(SSnodeOpt)); + pSnode->pMeta = sndMetaNew(); + if (pSnode->pMeta == NULL) { + free(pSnode); + return NULL; + } return pSnode; } -void sndClose(SSnode *pSnode) { free(pSnode); } +void sndClose(SSnode *pSnode) { + sndMetaDelete(pSnode->pMeta); + free(pSnode); +} int32_t sndGetLoad(SSnode *pSnode, SSnodeLoad *pLoad) { return 0; } -int32_t sndProcessMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp) { - *pRsp = NULL; - return 0; -} +/*int32_t sndProcessMsg(SSnode *pSnode, SRpcMsg *pMsg, SRpcMsg **pRsp) {*/ +/**pRsp = NULL;*/ +/*return 0;*/ +/*}*/ void sndDestroy(const char *path) {} -static int32_t sndDeployTask(SSnode *pSnode, SRpcMsg *pMsg) { - SStreamTask *task = malloc(sizeof(SStreamTask)); - if (task == NULL) { +SStreamMeta *sndMetaNew() { + SStreamMeta *pMeta = calloc(1, sizeof(SStreamMeta)); + if (pMeta == NULL) { + return NULL; + } + pMeta->pHash = taosHashInit(64, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), true, HASH_NO_LOCK); + if (pMeta->pHash == NULL) { + free(pMeta); + return NULL; + } + return pMeta; +} + +void sndMetaDelete(SStreamMeta *pMeta) { + taosHashCleanup(pMeta->pHash); + free(pMeta); +} + +int32_t sndMetaDeployTask(SStreamMeta *pMeta, SStreamTask *pTask) { + pTask->executor = qCreateStreamExecTaskInfo(pTask->qmsg, NULL); + return taosHashPut(pMeta->pHash, &pTask->taskId, sizeof(int32_t), pTask, sizeof(void *)); +} + +int32_t sndMetaRemoveTask(SStreamMeta *pMeta, int32_t taskId) { + SStreamTask *pTask = taosHashGet(pMeta->pHash, &taskId, sizeof(int32_t)); + if (pTask == NULL) { return -1; } - task->meta.taskId = tGenIdPI32(); - taosHashPut(pSnode->pMeta->pHash, &task->meta.taskId, sizeof(int32_t), &task, sizeof(void *)); - return 0; + free(pTask->qmsg); + // TODO:free executor + free(pTask); + return taosHashRemove(pMeta->pHash, &taskId, sizeof(int32_t)); } int32_t sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg) { - // stream deployment + // stream deploy // stream stop/resume // operator exec + if (pMsg->msgType == TDMT_SND_TASK_DEPLOY) { + void *msg = POINTER_SHIFT(pMsg->pCont, sizeof(SMsgHead)); + SStreamTask *pTask = malloc(sizeof(SStreamTask)); + if (pTask == NULL) { + return -1; + } + SCoder decoder; + tCoderInit(&decoder, TD_LITTLE_ENDIAN, msg, pMsg->contLen - sizeof(SMsgHead), TD_DECODER); + tDecodeSStreamTask(&decoder, pTask); + tCoderClear(&decoder); + + sndMetaDeployTask(pSnode->pMeta, pTask); + } else { + // + } return 0; } From 231ac079bee6f2304da05d2d5a66dc87dc4211be Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Wed, 16 Mar 2022 19:01:45 +0800 Subject: [PATCH 29/37] refactor --- source/dnode/vnode/src/tsdb/tsdbFile.c | 4 ++-- source/dnode/vnode/src/tsdb/tsdbSma.c | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/source/dnode/vnode/src/tsdb/tsdbFile.c b/source/dnode/vnode/src/tsdb/tsdbFile.c index b756cc9862..00e97c7b61 100644 --- a/source/dnode/vnode/src/tsdb/tsdbFile.c +++ b/source/dnode/vnode/src/tsdb/tsdbFile.c @@ -23,8 +23,8 @@ static const char *TSDB_FNAME_SUFFIX[] = { "smal", // TSDB_FILE_SMAL "", // TSDB_FILE_MAX "meta", // TSDB_FILE_META - "sma", // TSDB_FILE_TSMA(directory name) - "sma", // TSDB_FILE_RSMA(directory name) + "tsma", // TSDB_FILE_TSMA + "rsma", // TSDB_FILE_RSMA }; static void tsdbGetFilename(int vid, int fid, uint32_t ver, TSDB_FILE_T ftype, char *fname); diff --git a/source/dnode/vnode/src/tsdb/tsdbSma.c b/source/dnode/vnode/src/tsdb/tsdbSma.c index 880eb403f4..cd8b60385f 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSma.c +++ b/source/dnode/vnode/src/tsdb/tsdbSma.c @@ -15,6 +15,12 @@ #include "tsdbDef.h" +static const char *TSDB_SMA_DNAME[] = { + "", // TSDB_SMA_TYPE_BLOCK + "tsma", // TSDB_SMA_TYPE_TIME_RANGE + "rsma", // TSDB_SMA_TYPE_ROLLUP +}; + #undef SMA_PRINT_DEBUG_LOG #define SMA_STORAGE_TSDB_DAYS 30 #define SMA_STORAGE_TSDB_TIMES 10 @@ -93,10 +99,10 @@ static int32_t tsdbGetTSmaDays(STsdb *pTsdb, int64_t interval, int32_t storageLe static int32_t tsdbSetTSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData, int32_t storageLevel, int32_t fid); static int32_t tsdbInitTSmaFile(STSmaReadH *pSmaH, TSKEY skey); static bool tsdbSetAndOpenTSmaFile(STSmaReadH *pReadH, TSKEY *queryKey); -static void tsdbGetSmaDir(int32_t repoid, int8_t smaType, char dirName[]); +static void tsdbGetSmaDir(int32_t vgId, ETsdbSmaType smaType, char dirName[]); -static void tsdbGetSmaDir(int32_t repoid, int8_t smaType, char dirName[]) { - snprintf(dirName, TSDB_FILENAME_LEN, "vnode/vnode%d/tsdb/data", repoid); +static void tsdbGetSmaDir(int32_t vgId, ETsdbSmaType smaType, char dirName[]) { + snprintf(dirName, TSDB_FILENAME_LEN, "vnode/vnode%d/tsdb/%s", vgId, TSDB_SMA_DNAME[smaType]); } static SSmaEnv *tsdbNewSmaEnv(const STsdb *pTsdb, const char *path) { From 3d4280c705a114819646229f3bda1a4db2f7dd6c Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 16 Mar 2022 19:23:45 +0800 Subject: [PATCH 30/37] handle except --- source/libs/transport/src/transCli.c | 7 ++++++- source/libs/transport/test/transUT.cc | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 0932241abf..2c5c4810af 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -582,8 +582,13 @@ void cliHandleReq(SCliMsg* pMsg, SCliThrdObj* pThrd) { SCliConn* conn = cliGetConn(pMsg, pThrd); if (conn != NULL) { - taosArrayPush(conn->cliMsgs, &pMsg); conn->hThrdIdx = pCtx->hThrdIdx; + + if (taosArrayGetSize(conn->cliMsgs) > 0) { + taosArrayPush(conn->cliMsgs, &pMsg); + return; + } + taosArrayPush(conn->cliMsgs, &pMsg); transDestroyBuffer(&conn->readBuf); cliSend(conn); } else { diff --git a/source/libs/transport/test/transUT.cc b/source/libs/transport/test/transUT.cc index b3fbade050..bdbfb4a0ae 100644 --- a/source/libs/transport/test/transUT.cc +++ b/source/libs/transport/test/transUT.cc @@ -50,6 +50,7 @@ static void *ConstructArgForSpecificMsgType(void *parent, tmsg_t msgType) { } // server except static bool handleExcept(void *parent, tmsg_t msgType) { + // return msgType == TDMT_VND_QUERY || msgType == TDMT_VND_FETCH_RSP || msgType == TDMT_VND_RES_READY_RSP; } typedef void (*CB)(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet); From 575ab144393190af14a10914d71ceaaf4fbbeebd Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Wed, 16 Mar 2022 19:28:33 +0800 Subject: [PATCH 31/37] trow bug fix --- include/common/trow.h | 30 +++++++++++++++--------------- source/libs/parser/src/parInsert.c | 6 +++--- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/include/common/trow.h b/include/common/trow.h index 4dd3daba4d..47edf6f1ad 100644 --- a/include/common/trow.h +++ b/include/common/trow.h @@ -98,13 +98,13 @@ typedef void *SRow; typedef struct { TDRowValT valType; - void *val; + void * val; } SCellVal; typedef struct { // TODO - int tmp; // TODO: to avoid compile error -} STpRow; // tuple + int tmp; // TODO: to avoid compile error +} STpRow; // tuple #pragma pack(push, 1) typedef struct { @@ -158,8 +158,8 @@ typedef struct { int16_t nBitmaps; int16_t nBoundBitmaps; int32_t offset; - void *pBitmap; - void *pOffset; + void * pBitmap; + void * pOffset; int32_t extendedRowSize; } SRowBuilder; @@ -273,7 +273,7 @@ static FORCE_INLINE int32_t tdSetBitmapValType(void *pBitmap, int16_t colIdx, TD } int16_t nBytes = colIdx / TD_VTYPE_PARTS; int16_t nOffset = colIdx & TD_VTYPE_OPTR; - char *pDestByte = (char *)POINTER_SHIFT(pBitmap, nBytes); + char * pDestByte = (char *)POINTER_SHIFT(pBitmap, nBytes); switch (nOffset) { case 0: *pDestByte = ((*pDestByte) & 0x3F) | (valType << 6); @@ -311,7 +311,7 @@ static FORCE_INLINE int32_t tdGetBitmapValType(void *pBitmap, int16_t colIdx, TD } int16_t nBytes = colIdx / TD_VTYPE_PARTS; int16_t nOffset = colIdx & TD_VTYPE_OPTR; - char *pDestByte = (char *)POINTER_SHIFT(pBitmap, nBytes); + char * pDestByte = (char *)POINTER_SHIFT(pBitmap, nBytes); switch (nOffset) { case 0: *pValType = (((*pDestByte) & 0xC0) >> 6); @@ -617,7 +617,7 @@ static FORCE_INLINE int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowVa if (tdValIsNorm(valType, val, colType)) { // ts key stored in STSRow.ts SKvRowIdx *pColIdx = (SKvRowIdx *)POINTER_SHIFT(TD_ROW_COL_IDX(row), offset); - char *ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row)); + char * ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row)); pColIdx->colId = colId; pColIdx->offset = TD_ROW_LEN(row); // the offset include the TD_ROW_HEAD_LEN @@ -635,7 +635,7 @@ static FORCE_INLINE int32_t tdAppendColValToKvRow(SRowBuilder *pBuilder, TDRowVa // NULL/None value else { SKvRowIdx *pColIdx = (SKvRowIdx *)POINTER_SHIFT(TD_ROW_COL_IDX(row), offset); - char *ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row)); + char * ptr = (char *)POINTER_SHIFT(row, TD_ROW_LEN(row)); pColIdx->colId = colId; pColIdx->offset = TD_ROW_LEN(row); // the offset include the TD_ROW_HEAD_LEN const void *nullVal = getNullValue(colType); @@ -697,9 +697,9 @@ static FORCE_INLINE int32_t tdAppendColValToRow(SRowBuilder *pBuilder, int16_t c } // TODO: We can avoid the type judegement by FP, but would prevent the inline scheme. if (TD_IS_TP_ROW(pRow)) { - tdAppendColValToTpRow(pBuilder, valType, val, true, colType, colIdx, offset); + tdAppendColValToTpRow(pBuilder, valType, val, isCopyVarData, colType, colIdx, offset); } else { - tdAppendColValToKvRow(pBuilder, valType, val, true, colType, colIdx, offset, colId); + tdAppendColValToKvRow(pBuilder, valType, val, isCopyVarData, colType, colIdx, offset, colId); } return TSDB_CODE_SUCCESS; } @@ -771,8 +771,8 @@ static FORCE_INLINE int32_t tdGetKvRowValOfCol(SCellVal *output, STSRow *pRow, v typedef struct { STSchema *pSchema; - STSRow *pRow; - void *pBitmap; + STSRow * pRow; + void * pBitmap; uint32_t offset; col_id_t maxColId; col_id_t colIdx; // [PRIMARYKEY_TIMESTAMP_COL_ID, nSchemaCols], PRIMARYKEY_TIMESTAMP_COL_ID equals 1 @@ -877,7 +877,7 @@ static FORCE_INLINE bool tdGetTpRowDataOfCol(STSRowIter *pIter, col_type_t colTy // internal static FORCE_INLINE bool tdGetKvRowValOfColEx(STSRowIter *pIter, col_id_t colId, col_type_t colType, col_id_t *nIdx, SCellVal *pVal) { - STSRow *pRow = pIter->pRow; + STSRow * pRow = pIter->pRow; SKvRowIdx *pKvIdx = NULL; bool colFound = false; col_id_t kvNCols = tdRowGetNCols(pRow); @@ -1068,7 +1068,7 @@ typedef struct { typedef struct { STSchema *pSchema; - STSRow *pRow; + STSRow * pRow; } STSRowReader; typedef struct { diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index 28f680cfbb..6db3abb9d6 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -617,7 +617,7 @@ static FORCE_INLINE int32_t MemRowAppend(const void* value, int32_t len, void* p if (TSDB_DATA_TYPE_BINARY == pa->schema->type) { const char* rowEnd = tdRowEnd(rb->pBuf); STR_WITH_SIZE_TO_VARSTR(rowEnd, value, len); - tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, rowEnd, false, pa->toffset, pa->colIdx); + tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, rowEnd, true, pa->toffset, pa->colIdx); } else if (TSDB_DATA_TYPE_NCHAR == pa->schema->type) { // if the converted output len is over than pColumnModel->bytes, return error: 'Argument list too long' int32_t output = 0; @@ -626,9 +626,9 @@ static FORCE_INLINE int32_t MemRowAppend(const void* value, int32_t len, void* p return TSDB_CODE_TSC_SQL_SYNTAX_ERROR; } varDataSetLen(rowEnd, output); - tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, rowEnd, false, pa->toffset, pa->colIdx); + tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, rowEnd, true, pa->toffset, pa->colIdx); } else { - tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, value, true, pa->toffset, pa->colIdx); + tdAppendColValToRow(rb, pa->schema->colId, pa->schema->type, TD_VTYPE_NORM, value, false, pa->toffset, pa->colIdx); } return TSDB_CODE_SUCCESS; } From 7f4c88b756c5c42b34f29379a1efde747549edce Mon Sep 17 00:00:00 2001 From: Liu Jicong Date: Wed, 16 Mar 2022 19:40:48 +0800 Subject: [PATCH 32/37] task deploy and task exec --- include/common/tmsg.h | 4 ++++ include/common/tmsgdef.h | 1 + include/util/tencode.h | 25 ++++++++++++++++++++++++- source/common/src/tmsg.c | 8 ++++---- source/dnode/mnode/impl/src/mndDef.c | 6 +++--- source/dnode/snode/inc/sndInt.h | 5 +++-- source/dnode/snode/src/snode.c | 23 ++++++++++++++++++++++- 7 files changed, 61 insertions(+), 11 deletions(-) diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 7e9b2186da..b449cad2a1 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -2306,6 +2306,10 @@ typedef struct { // TODO: other info needed by task } SStreamTaskExecReq; +typedef struct { + int32_t reserved; +} SStreamTaskExecRsp; + #pragma pack(pop) #ifdef __cplusplus diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index b30a325d7c..6a07887721 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -200,6 +200,7 @@ enum { // Requests handled by SNODE TD_NEW_MSG_SEG(TDMT_SND_MSG) TD_DEF_MSG_TYPE(TDMT_SND_TASK_DEPLOY, "snode-task-deploy", SStreamTaskDeployReq, SStreamTaskDeployRsp) + TD_DEF_MSG_TYPE(TDMT_SND_TASK_EXEC, "snode-task-exec", SStreamTaskExecReq, SStreamTaskExecRsp) #if defined(TD_MSG_NUMBER_) TDMT_MAX diff --git a/include/util/tencode.h b/include/util/tencode.h index c058eebb50..cbbd55c8a3 100644 --- a/include/util/tencode.h +++ b/include/util/tencode.h @@ -402,10 +402,33 @@ static int32_t tDecodeCStrTo(SCoder* pDecoder, char* val) { return 0; } +static FORCE_INLINE int32_t tDecodeBinaryAlloc(SCoder* pDecoder, void** val, uint64_t* len) { + if (tDecodeU64v(pDecoder, len) < 0) return -1; + + if (TD_CODER_CHECK_CAPACITY_FAILED(pDecoder, *len)) return -1; + *val = malloc(*len); + if (*val == NULL) return -1; + memcpy(*val, TD_CODER_CURRENT(pDecoder), *len); + + TD_CODER_MOVE_POS(pDecoder, *len); + return 0; +} + +static FORCE_INLINE int32_t tDecodeCStrAndLenAlloc(SCoder* pDecoder, char** val, uint64_t* len) { + if (tDecodeBinaryAlloc(pDecoder, (void**)val, len) < 0) return -1; + (*len) -= 1; + return 0; +} + +static FORCE_INLINE int32_t tDecodeCStrAlloc(SCoder* pDecoder, char** val) { + uint64_t len; + return tDecodeCStrAndLenAlloc(pDecoder, val, &len); +} + static FORCE_INLINE bool tDecodeIsEnd(SCoder* pCoder) { return (pCoder->size == pCoder->pos); } #ifdef __cplusplus } #endif -#endif /*_TD_UTIL_ENCODE_H_*/ \ No newline at end of file +#endif /*_TD_UTIL_ENCODE_H_*/ diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 469090c05b..794e5a8542 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -2674,9 +2674,9 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea if (tStartDecode(&decoder) < 0) return -1; if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1; if (tDecodeI8(&decoder, &pReq->igExists) < 0) return -1; - if (tDecodeCStr(&decoder, (const char **)&pReq->sql) < 0) return -1; - if (tDecodeCStr(&decoder, (const char **)&pReq->physicalPlan) < 0) return -1; - if (tDecodeCStr(&decoder, (const char **)&pReq->logicalPlan) < 0) return -1; + if (tDecodeCStrAlloc(&decoder, &pReq->sql) < 0) return -1; + if (tDecodeCStrAlloc(&decoder, &pReq->physicalPlan) < 0) return -1; + if (tDecodeCStrAlloc(&decoder, &pReq->logicalPlan) < 0) return -1; tEndDecode(&decoder); tCoderClear(&decoder); @@ -2706,7 +2706,7 @@ int32_t tDecodeSStreamTask(SCoder *pDecoder, SStreamTask *pTask) { if (tDecodeI32(pDecoder, &pTask->taskId) < 0) return -1; if (tDecodeI32(pDecoder, &pTask->level) < 0) return -1; if (tDecodeI8(pDecoder, &pTask->status) < 0) return -1; - if (tDecodeCStr(pDecoder, (const char **)&pTask->qmsg) < 0) return -1; + if (tDecodeCStrAlloc(pDecoder, &pTask->qmsg) < 0) return -1; tEndDecode(pDecoder); return 0; } diff --git a/source/dnode/mnode/impl/src/mndDef.c b/source/dnode/mnode/impl/src/mndDef.c index 6e8d9aa79f..cc5bf843ce 100644 --- a/source/dnode/mnode/impl/src/mndDef.c +++ b/source/dnode/mnode/impl/src/mndDef.c @@ -39,8 +39,8 @@ int32_t tDecodeSStreamObj(SCoder *pDecoder, SStreamObj *pObj) { if (tDecodeI64(pDecoder, &pObj->dbUid) < 0) return -1; if (tDecodeI32(pDecoder, &pObj->version) < 0) return -1; if (tDecodeI8(pDecoder, &pObj->status) < 0) return -1; - if (tDecodeCStr(pDecoder, (const char **)&pObj->sql) < 0) return -1; - if (tDecodeCStr(pDecoder, (const char **)&pObj->logicalPlan) < 0) return -1; - if (tDecodeCStr(pDecoder, (const char **)&pObj->physicalPlan) < 0) return -1; + if (tDecodeCStrAlloc(pDecoder, &pObj->sql) < 0) return -1; + if (tDecodeCStrAlloc(pDecoder, &pObj->logicalPlan) < 0) return -1; + if (tDecodeCStrAlloc(pDecoder, &pObj->physicalPlan) < 0) return -1; return 0; } diff --git a/source/dnode/snode/inc/sndInt.h b/source/dnode/snode/inc/sndInt.h index e5f6c3c266..d1122fc4ec 100644 --- a/source/dnode/snode/inc/sndInt.h +++ b/source/dnode/snode/inc/sndInt.h @@ -50,8 +50,9 @@ typedef struct SSnode { SStreamMeta* sndMetaNew(); void sndMetaDelete(SStreamMeta* pMeta); -int32_t sndMetaDeployTask(SStreamMeta* pMeta, SStreamTask* pTask); -int32_t sndMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId); +int32_t sndMetaDeployTask(SStreamMeta* pMeta, SStreamTask* pTask); +SStreamTask* sndMetaGetTask(SStreamMeta* pMeta, int32_t taskId); +int32_t sndMetaRemoveTask(SStreamMeta* pMeta, int32_t taskId); int32_t sndDropTaskOfStream(SStreamMeta* pMeta, int64_t streamId); diff --git a/source/dnode/snode/src/snode.c b/source/dnode/snode/src/snode.c index 80e33bd971..2ecaeb00e9 100644 --- a/source/dnode/snode/src/snode.c +++ b/source/dnode/snode/src/snode.c @@ -68,6 +68,10 @@ int32_t sndMetaDeployTask(SStreamMeta *pMeta, SStreamTask *pTask) { return taosHashPut(pMeta->pHash, &pTask->taskId, sizeof(int32_t), pTask, sizeof(void *)); } +SStreamTask *sndMetaGetTask(SStreamMeta *pMeta, int32_t taskId) { + return taosHashGet(pMeta->pHash, &taskId, sizeof(int32_t)); +} + int32_t sndMetaRemoveTask(SStreamMeta *pMeta, int32_t taskId) { SStreamTask *pTask = taosHashGet(pMeta->pHash, &taskId, sizeof(int32_t)); if (pTask == NULL) { @@ -79,6 +83,16 @@ int32_t sndMetaRemoveTask(SStreamMeta *pMeta, int32_t taskId) { return taosHashRemove(pMeta->pHash, &taskId, sizeof(int32_t)); } +static int32_t sndProcessTaskExecReq(SSnode *pSnode, SRpcMsg *pMsg) { + SMsgHead *pHead = pMsg->pCont; + int32_t taskId = pHead->streamTaskId; + SStreamTask *pTask = sndMetaGetTask(pSnode->pMeta, taskId); + if (pTask == NULL) { + return -1; + } + return 0; +} + int32_t sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg) { // stream deploy // stream stop/resume @@ -95,13 +109,20 @@ int32_t sndProcessUMsg(SSnode *pSnode, SRpcMsg *pMsg) { tCoderClear(&decoder); sndMetaDeployTask(pSnode->pMeta, pTask); + } else if (pMsg->msgType == TDMT_SND_TASK_EXEC) { + sndProcessTaskExecReq(pSnode, pMsg); } else { - // + ASSERT(0); } return 0; } int32_t sndProcessSMsg(SSnode *pSnode, SRpcMsg *pMsg) { // operator exec + if (pMsg->msgType == TDMT_SND_TASK_EXEC) { + sndProcessTaskExecReq(pSnode, pMsg); + } else { + ASSERT(0); + } return 0; } From fda9803c176f47826aba16466267bbb5d5a7638a Mon Sep 17 00:00:00 2001 From: Minghao Li Date: Wed, 16 Mar 2022 20:03:22 +0800 Subject: [PATCH 33/37] sync refactor --- source/libs/sync/src/syncAppendEntries.c | 20 ++++++++++++-------- source/libs/sync/src/syncCommit.c | 6 +++++- source/libs/sync/src/syncIO.c | 13 ++++++++++--- source/libs/sync/src/syncMain.c | 6 +++--- source/libs/sync/src/syncRaftLog.c | 17 ++++++++++------- source/libs/sync/test/syncElectTest.cpp | 9 ++++++--- source/libs/sync/test/syncLogStoreTest.cpp | 6 +++--- 7 files changed, 49 insertions(+), 28 deletions(-) diff --git a/source/libs/sync/src/syncAppendEntries.c b/source/libs/sync/src/syncAppendEntries.c index 87d6669f59..888d7e16d1 100644 --- a/source/libs/sync/src/syncAppendEntries.c +++ b/source/libs/sync/src/syncAppendEntries.c @@ -102,7 +102,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { SyncTerm localPreLogTerm = 0; if (pMsg->prevLogTerm >= SYNC_INDEX_BEGIN && pMsg->prevLogTerm <= ths->pLogStore->getLastIndex(ths->pLogStore)) { - SSyncRaftEntry* pEntry = logStoreGetEntry(ths->pLogStore, pMsg->prevLogTerm); + SSyncRaftEntry* pEntry = logStoreGetEntry(ths->pLogStore, pMsg->prevLogIndex); assert(pEntry != NULL); localPreLogTerm = pEntry->term; syncEntryDestory(pEntry); @@ -111,9 +111,9 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { bool logOK = (pMsg->prevLogIndex == SYNC_INDEX_INVALID) || ((pMsg->prevLogIndex >= SYNC_INDEX_BEGIN) && - (pMsg->prevLogIndex <= ths->pLogStore->getLastIndex(ths->pLogStore)) && (pMsg->prevLogIndex == localPreLogTerm)); + (pMsg->prevLogIndex <= ths->pLogStore->getLastIndex(ths->pLogStore)) && (pMsg->prevLogTerm == localPreLogTerm)); - // reject + // reject request if ((pMsg->term < ths->pRaftStore->currentTerm) || ((pMsg->term == ths->pRaftStore->currentTerm) && (ths->state == TAOS_SYNC_STATE_FOLLOWER) && !logOK)) { SyncAppendEntriesReply* pReply = syncAppendEntriesReplyBuild(); @@ -134,6 +134,9 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { // return to follower state if (pMsg->term == ths->pRaftStore->currentTerm && ths->state == TAOS_SYNC_STATE_CANDIDATE) { syncNodeBecomeFollower(ths); + + // need ret? + return ret; } // accept request @@ -144,17 +147,17 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { matchSuccess = true; } if (pMsg->prevLogIndex >= SYNC_INDEX_BEGIN && pMsg->prevLogIndex <= ths->pLogStore->getLastIndex(ths->pLogStore)) { - SSyncRaftEntry* pEntry = logStoreGetEntry(ths->pLogStore, pMsg->prevLogTerm); - assert(pEntry != NULL); - if (pMsg->prevLogTerm == pEntry->term) { + SSyncRaftEntry* pPreEntry = logStoreGetEntry(ths->pLogStore, pMsg->prevLogIndex); + assert(pPreEntry != NULL); + if (pMsg->prevLogTerm == pPreEntry->term) { matchSuccess = true; } - syncEntryDestory(pEntry); + syncEntryDestory(pPreEntry); } if (matchSuccess) { // delete conflict entries - if (ths->pLogStore->getLastIndex(ths->pLogStore) > pMsg->prevLogIndex) { + if (pMsg->prevLogIndex < ths->pLogStore->getLastIndex(ths->pLogStore)) { SyncIndex fromIndex = pMsg->prevLogIndex + 1; ths->pLogStore->truncate(ths->pLogStore, fromIndex); } @@ -178,6 +181,7 @@ int32_t syncNodeOnAppendEntriesCb(SSyncNode* ths, SyncAppendEntries* pMsg) { syncNodeSendMsgById(&pReply->destId, ths, &rpcMsg); syncAppendEntriesReplyDestroy(pReply); + } else { SyncAppendEntriesReply* pReply = syncAppendEntriesReplyBuild(); pReply->srcId = ths->myRaftId; diff --git a/source/libs/sync/src/syncCommit.c b/source/libs/sync/src/syncCommit.c index ec4272fdd0..850468f393 100644 --- a/source/libs/sync/src/syncCommit.c +++ b/source/libs/sync/src/syncCommit.c @@ -13,6 +13,7 @@ * along with this program. If not, see . */ +#include "syncIndexMgr.h" #include "syncInt.h" // \* Leader i advances its commitIndex. @@ -38,4 +39,7 @@ // IN commitIndex' = [commitIndex EXCEPT ![i] = newCommitIndex] // /\ UNCHANGED <> // -void syncNodeMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) {} \ No newline at end of file +void syncNodeMaybeAdvanceCommitIndex(SSyncNode* pSyncNode) { + syncIndexMgrLog2("==syncNodeMaybeAdvanceCommitIndex== pNextIndex", pSyncNode->pNextIndex); + syncIndexMgrLog2("==syncNodeMaybeAdvanceCommitIndex== pMatchIndex", pSyncNode->pMatchIndex); +} \ No newline at end of file diff --git a/source/libs/sync/src/syncIO.c b/source/libs/sync/src/syncIO.c index e6a43f2bb5..c8448c32eb 100644 --- a/source/libs/sync/src/syncIO.c +++ b/source/libs/sync/src/syncIO.c @@ -29,7 +29,7 @@ static int32_t syncIODestroy(SSyncIO *io); static int32_t syncIOStartInternal(SSyncIO *io); static int32_t syncIOStopInternal(SSyncIO *io); -static void * syncIOConsumerFunc(void *param); +static void *syncIOConsumerFunc(void *param); static void syncIOProcessRequest(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet); static void syncIOProcessReply(void *pParent, SRpcMsg *pMsg, SEpSet *pEpSet); static int32_t syncIOAuth(void *parent, char *meterId, char *spi, char *encrypt, char *secret, char *ckey); @@ -234,9 +234,9 @@ static int32_t syncIOStopInternal(SSyncIO *io) { } static void *syncIOConsumerFunc(void *param) { - SSyncIO * io = param; + SSyncIO *io = param; STaosQall *qall; - SRpcMsg * pRpcMsg, rpcMsg; + SRpcMsg *pRpcMsg, rpcMsg; qall = taosAllocateQall(); while (1) { @@ -269,6 +269,7 @@ static void *syncIOConsumerFunc(void *param) { } else if (pRpcMsg->msgType == SYNC_PING_REPLY) { if (io->FpOnSyncPingReply != NULL) { SyncPingReply *pSyncMsg = syncPingReplyFromRpcMsg2(pRpcMsg); + assert(pSyncMsg != NULL); io->FpOnSyncPingReply(io->pSyncNode, pSyncMsg); syncPingReplyDestroy(pSyncMsg); } @@ -276,6 +277,7 @@ static void *syncIOConsumerFunc(void *param) { } else if (pRpcMsg->msgType == SYNC_CLIENT_REQUEST) { if (io->FpOnSyncClientRequest != NULL) { SyncClientRequest *pSyncMsg = syncClientRequestFromRpcMsg2(pRpcMsg); + assert(pSyncMsg != NULL); io->FpOnSyncClientRequest(io->pSyncNode, pSyncMsg); syncClientRequestDestroy(pSyncMsg); } @@ -283,6 +285,7 @@ static void *syncIOConsumerFunc(void *param) { } else if (pRpcMsg->msgType == SYNC_REQUEST_VOTE) { if (io->FpOnSyncRequestVote != NULL) { SyncRequestVote *pSyncMsg = syncRequestVoteFromRpcMsg2(pRpcMsg); + assert(pSyncMsg != NULL); io->FpOnSyncRequestVote(io->pSyncNode, pSyncMsg); syncRequestVoteDestroy(pSyncMsg); } @@ -290,6 +293,7 @@ static void *syncIOConsumerFunc(void *param) { } else if (pRpcMsg->msgType == SYNC_REQUEST_VOTE_REPLY) { if (io->FpOnSyncRequestVoteReply != NULL) { SyncRequestVoteReply *pSyncMsg = syncRequestVoteReplyFromRpcMsg2(pRpcMsg); + assert(pSyncMsg != NULL); io->FpOnSyncRequestVoteReply(io->pSyncNode, pSyncMsg); syncRequestVoteReplyDestroy(pSyncMsg); } @@ -297,6 +301,7 @@ static void *syncIOConsumerFunc(void *param) { } else if (pRpcMsg->msgType == SYNC_APPEND_ENTRIES) { if (io->FpOnSyncAppendEntries != NULL) { SyncAppendEntries *pSyncMsg = syncAppendEntriesFromRpcMsg2(pRpcMsg); + assert(pSyncMsg != NULL); io->FpOnSyncAppendEntries(io->pSyncNode, pSyncMsg); syncAppendEntriesDestroy(pSyncMsg); } @@ -304,6 +309,7 @@ static void *syncIOConsumerFunc(void *param) { } else if (pRpcMsg->msgType == SYNC_APPEND_ENTRIES_REPLY) { if (io->FpOnSyncAppendEntriesReply != NULL) { SyncAppendEntriesReply *pSyncMsg = syncAppendEntriesReplyFromRpcMsg2(pRpcMsg); + assert(pSyncMsg != NULL); io->FpOnSyncAppendEntriesReply(io->pSyncNode, pSyncMsg); syncAppendEntriesReplyDestroy(pSyncMsg); } @@ -311,6 +317,7 @@ static void *syncIOConsumerFunc(void *param) { } else if (pRpcMsg->msgType == SYNC_TIMEOUT) { if (io->FpOnSyncTimeout != NULL) { SyncTimeout *pSyncMsg = syncTimeoutFromRpcMsg2(pRpcMsg); + assert(pSyncMsg != NULL); io->FpOnSyncTimeout(io->pSyncNode, pSyncMsg); syncTimeoutDestroy(pSyncMsg); } diff --git a/source/libs/sync/src/syncMain.c b/source/libs/sync/src/syncMain.c index 7d2087eded..ff446dfc27 100644 --- a/source/libs/sync/src/syncMain.c +++ b/source/libs/sync/src/syncMain.c @@ -563,11 +563,11 @@ void syncNodeBecomeLeader(SSyncNode* pSyncNode) { // stop elect timer syncNodeStopElectTimer(pSyncNode); - // start heartbeat timer - syncNodeStartHeartbeatTimer(pSyncNode); - // start replicate right now! syncNodeReplicate(pSyncNode); + + // start heartbeat timer + syncNodeStartHeartbeatTimer(pSyncNode); } void syncNodeCandidate2Leader(SSyncNode* pSyncNode) { diff --git a/source/libs/sync/src/syncRaftLog.c b/source/libs/sync/src/syncRaftLog.c index f3fd7f84a2..01ec761a9c 100644 --- a/source/libs/sync/src/syncRaftLog.c +++ b/source/libs/sync/src/syncRaftLog.c @@ -63,15 +63,18 @@ int32_t logStoreAppendEntry(SSyncLogStore* pLogStore, SSyncRaftEntry* pEntry) { SSyncRaftEntry* logStoreGetEntry(SSyncLogStore* pLogStore, SyncIndex index) { SSyncLogStoreData* pData = pLogStore->data; SWal* pWal = pData->pWal; - SSyncRaftEntry* pEntry; + SSyncRaftEntry* pEntry = NULL; - SWalReadHandle* pWalHandle = walOpenReadHandle(pWal); - walReadWithHandle(pWalHandle, index); - pEntry = syncEntryDeserialize(pWalHandle->pHead->head.body, pWalHandle->pHead->head.len); - assert(pEntry != NULL); + if (index >= SYNC_INDEX_BEGIN && index <= logStoreLastIndex(pLogStore)) { + SWalReadHandle* pWalHandle = walOpenReadHandle(pWal); + walReadWithHandle(pWalHandle, index); + pEntry = syncEntryDeserialize(pWalHandle->pHead->head.body, pWalHandle->pHead->head.len); + assert(pEntry != NULL); + + // need to hold, do not new every time!! + walCloseReadHandle(pWalHandle); + } - // need to hold, do not new every time!! - walCloseReadHandle(pWalHandle); return pEntry; } diff --git a/source/libs/sync/test/syncElectTest.cpp b/source/libs/sync/test/syncElectTest.cpp index e52fe61ef5..b8a1460f35 100644 --- a/source/libs/sync/test/syncElectTest.cpp +++ b/source/libs/sync/test/syncElectTest.cpp @@ -17,7 +17,7 @@ void logTest() { } uint16_t ports[] = {7010, 7110, 7210, 7310, 7410}; -int32_t replicaNum = 1; +int32_t replicaNum = 3; int32_t myIndex = 0; SRaftId ids[TSDB_MAX_REPLICA]; @@ -33,7 +33,7 @@ SSyncNode* syncNodeInit() { syncInfo.queue = gSyncIO->pMsgQ; syncInfo.FpEqMsg = syncIOEqMsg; syncInfo.pFsm = pFsm; - snprintf(syncInfo.path, sizeof(syncInfo.path), "%s", "./elect_test"); + snprintf(syncInfo.path, sizeof(syncInfo.path), "./elect_test_%d", myIndex); int code = walInit(); assert(code == 0); @@ -46,7 +46,10 @@ SSyncNode* syncNodeInit() { walCfg.retentionSize = 1000; walCfg.segSize = 1000; walCfg.level = TAOS_WAL_FSYNC; - pWal = walOpen("./elect_test_wal", &walCfg); + + char tmpdir[128]; + snprintf(tmpdir, sizeof(tmpdir), "./elect_test_wal_%d", myIndex); + pWal = walOpen(tmpdir, &walCfg); assert(pWal != NULL); syncInfo.pWal = pWal; diff --git a/source/libs/sync/test/syncLogStoreTest.cpp b/source/libs/sync/test/syncLogStoreTest.cpp index 1b05f76fa2..c1cb66f382 100644 --- a/source/libs/sync/test/syncLogStoreTest.cpp +++ b/source/libs/sync/test/syncLogStoreTest.cpp @@ -81,7 +81,7 @@ SSyncNode* syncNodeInit() { SSyncNode* syncInitTest() { return syncNodeInit(); } void logStoreTest() { - logStorePrint2((char*)"logStoreTest2", pSyncNode->pLogStore); + logStorePrint2((char*)"logStoreTest", pSyncNode->pLogStore); assert(pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore) == SYNC_INDEX_INVALID); @@ -105,10 +105,10 @@ void logStoreTest() { assert(pSyncNode->pLogStore->getLastIndex(pSyncNode->pLogStore) == SYNC_INDEX_BEGIN); } } - logStorePrint(pSyncNode->pLogStore); + logStorePrint2((char*)"after appendEntry", pSyncNode->pLogStore); pSyncNode->pLogStore->truncate(pSyncNode->pLogStore, 3); - logStorePrint(pSyncNode->pLogStore); + logStorePrint2((char*)"after truncate 3", pSyncNode->pLogStore); } void initRaftId(SSyncNode* pSyncNode) { From 1d8ffd9581131ab60ee4a4b942e2ca3c8306389e Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 16 Mar 2022 21:48:19 +0800 Subject: [PATCH 34/37] handle except --- include/libs/transport/trpc.h | 1 + source/libs/transport/src/transCli.c | 30 +++++++++++++++++++++++--- source/libs/transport/src/transSrv.c | 17 ++++++++++----- source/libs/transport/test/transUT.cc | 31 ++++++++++++++++++++++++++- 4 files changed, 70 insertions(+), 9 deletions(-) diff --git a/include/libs/transport/trpc.h b/include/libs/transport/trpc.h index 5795cdd919..3e42036567 100644 --- a/include/libs/transport/trpc.h +++ b/include/libs/transport/trpc.h @@ -43,6 +43,7 @@ typedef struct SRpcMsg { int32_t code; void * handle; // rpc handle returned to app void * ahandle; // app handle set by client + int noResp; // has response or not(default 0 indicate resp); } SRpcMsg; typedef struct SRpcInit { diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index 2c5c4810af..cf1fad0835 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -158,9 +158,11 @@ static void destroyThrdObj(SCliThrdObj* pThrd); } while (0) #define CONN_NO_PERSIST_BY_APP(conn) ((conn)->persist == false) +#define REQUEST_NO_RESP(msg) ((msg)->noResp == 1) + static void* cliWorkThread(void* arg); -bool cliMayContinueSendMsg(SCliConn* conn) { +bool cliMaySendCachedMsg(SCliConn* conn) { if (taosArrayGetSize(conn->cliMsgs) > 0) { cliSend(conn); return true; @@ -226,7 +228,7 @@ void cliHandleResp(SCliConn* conn) { } destroyCmsg(pMsg); - if (cliMayContinueSendMsg(conn) == true) { + if (cliMaySendCachedMsg(conn) == true) { return; } @@ -441,7 +443,24 @@ static void cliDestroy(uv_handle_t* handle) { tTrace("%s cli conn %p destroy successfully", CONN_GET_INST_LABEL(conn), conn); free(conn); } - +static bool cliHandleNoResp(SCliConn* conn) { + bool res = false; + SArray* msgs = conn->cliMsgs; + if (taosArrayGetSize(msgs) > 0) { + SCliMsg* pMsg = taosArrayGetP(msgs, 0); + if (REQUEST_NO_RESP(&pMsg->msg)) { + taosArrayRemove(msgs, 0); + destroyCmsg(pMsg); + res = true; + } + if (res == true) { + if (cliMaySendCachedMsg(conn) == false) { + addConnToPool(conn->hostThrd, conn); + } + } + } + return res; +} static void cliSendCb(uv_write_t* req, int status) { SCliConn* pConn = req->data; @@ -452,6 +471,10 @@ static void cliSendCb(uv_write_t* req, int status) { cliHandleExcept(pConn); return; } + if (cliHandleNoResp(pConn) == true) { + tTrace("%s cli conn %p no resp required", CONN_GET_INST_LABEL(pConn), pConn); + return; + } uv_read_start((uv_stream_t*)pConn->stream, cliAllocRecvBufferCb, cliRecvCb); } @@ -489,6 +512,7 @@ void cliSend(SCliConn* pConn) { msgLen += sizeof(STransUserMsg); } + pHead->resflag = REQUEST_NO_RESP(pMsg) ? 1 : 0; pHead->msgType = pMsg->msgType; pHead->msgLen = (int32_t)htonl((uint32_t)msgLen); diff --git a/source/libs/transport/src/transSrv.c b/source/libs/transport/src/transSrv.c index ec42ab6402..2efdb109aa 100644 --- a/source/libs/transport/src/transSrv.c +++ b/source/libs/transport/src/transSrv.c @@ -226,15 +226,22 @@ static void uvHandleReq(SSrvConn* pConn) { transMsg.msgType = pHead->msgType; transMsg.code = pHead->code; transMsg.ahandle = NULL; - transMsg.handle = pConn; + transMsg.handle = NULL; transClearBuffer(&pConn->readBuf); pConn->inType = pHead->msgType; - transRefSrvHandle(pConn); - tDebug("server conn %p %s received from %s:%d, local info: %s:%d, msg size: %d", pConn, TMSG_INFO(transMsg.msgType), - inet_ntoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), inet_ntoa(pConn->locaddr.sin_addr), - ntohs(pConn->locaddr.sin_port), transMsg.contLen); + if (pHead->resflag == 0) { + transRefSrvHandle(pConn); + transMsg.handle = pConn; + tDebug("server conn %p %s received from %s:%d, local info: %s:%d, msg size: %d", pConn, TMSG_INFO(transMsg.msgType), + inet_ntoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), inet_ntoa(pConn->locaddr.sin_addr), + ntohs(pConn->locaddr.sin_port), transMsg.contLen); + } else { + tDebug("server conn %p %s received from %s:%d, local info: %s:%d, msg size: %d, no resp ", pConn, + TMSG_INFO(transMsg.msgType), inet_ntoa(pConn->addr.sin_addr), ntohs(pConn->addr.sin_port), + inet_ntoa(pConn->locaddr.sin_addr), ntohs(pConn->locaddr.sin_port), transMsg.contLen); + } STrans* pTransInst = (STrans*)p->shandle; (*pTransInst->cfp)(pTransInst->parent, &transMsg, NULL); diff --git a/source/libs/transport/test/transUT.cc b/source/libs/transport/test/transUT.cc index bdbfb4a0ae..ec89d695a2 100644 --- a/source/libs/transport/test/transUT.cc +++ b/source/libs/transport/test/transUT.cc @@ -361,7 +361,7 @@ TEST_F(TransEnv, cliPersistHandle) { tr->SetCliPersistFp(cliPersistHandle); SRpcMsg resp = {0}; for (int i = 0; i < 10; i++) { - SRpcMsg req = {.handle = resp.handle}; + SRpcMsg req = {.handle = resp.handle, .noResp = 0}; req.msgType = 1; req.pCont = rpcMallocCont(10); req.contLen = 10; @@ -448,6 +448,25 @@ TEST_F(TransEnv, srvPersistHandleExcept) { // conn broken // } +TEST_F(TransEnv, cliPersistHandleExcept) { + tr->SetSrvContinueSend(processContinueSend); + tr->SetCliPersistFp(cliPersistHandle); + SRpcMsg resp = {0}; + for (int i = 0; i < 5; i++) { + SRpcMsg req = {.handle = resp.handle}; + req.msgType = 1; + req.pCont = rpcMallocCont(10); + req.contLen = 10; + tr->cliSendAndRecv(&req, &resp); + if (i > 2) { + tr->StopSrv(); + break; + } + } + taosMsleep(2000); + // conn broken + // +} TEST_F(TransEnv, multiCliPersistHandleExcept) { // conn broken @@ -458,5 +477,15 @@ TEST_F(TransEnv, queryExcept) { // query and conn is broken } TEST_F(TransEnv, noResp) { + SRpcMsg resp = {0}; + for (int i = 0; i < 5; i++) { + SRpcMsg req = {.noResp = 1}; + req.msgType = 1; + req.pCont = rpcMallocCont(10); + req.contLen = 10; + tr->cliSendAndRecv(&req, &resp); + } + taosMsleep(2000); + // no resp } From 6d6a177eeb703f851268455f7730c35c7a3dda2f Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 16 Mar 2022 22:08:47 +0800 Subject: [PATCH 35/37] handle except --- source/libs/transport/src/transCli.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/libs/transport/src/transCli.c b/source/libs/transport/src/transCli.c index cf1fad0835..31097a591f 100644 --- a/source/libs/transport/src/transCli.c +++ b/source/libs/transport/src/transCli.c @@ -455,7 +455,8 @@ static bool cliHandleNoResp(SCliConn* conn) { } if (res == true) { if (cliMaySendCachedMsg(conn) == false) { - addConnToPool(conn->hostThrd, conn); + SCliThrdObj* thrd = conn->hostThrd; + addConnToPool(thrd->pool, conn); } } } From 3843b689bbdf6b93a72e88cc5df2ca69b06f0461 Mon Sep 17 00:00:00 2001 From: yihaoDeng Date: Wed, 16 Mar 2022 22:19:43 +0800 Subject: [PATCH 36/37] handle except --- include/libs/transport/trpc.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/libs/transport/trpc.h b/include/libs/transport/trpc.h index 3e42036567..6bc28e3ea0 100644 --- a/include/libs/transport/trpc.h +++ b/include/libs/transport/trpc.h @@ -38,12 +38,14 @@ typedef struct SRpcConnInfo { typedef struct SRpcMsg { tmsg_t msgType; + tmsg_t expectMsgType; void * pCont; int contLen; int32_t code; void * handle; // rpc handle returned to app void * ahandle; // app handle set by client int noResp; // has response or not(default 0 indicate resp); + } SRpcMsg; typedef struct SRpcInit { From 91df290152424fd4fb1216d0886139bb66c33291 Mon Sep 17 00:00:00 2001 From: Cary Xu Date: Thu, 17 Mar 2022 11:46:34 +0800 Subject: [PATCH 37/37] add REF for SSmaStat in case of delete SSmaStatItem when drop sma index --- source/dnode/vnode/inc/tsdb.h | 6 +- source/dnode/vnode/src/meta/metaBDBImpl.c | 2 +- source/dnode/vnode/src/tsdb/tsdbSma.c | 146 ++++++++++++++-------- source/dnode/vnode/test/tsdbSmaTest.cpp | 2 +- 4 files changed, 95 insertions(+), 61 deletions(-) diff --git a/source/dnode/vnode/inc/tsdb.h b/source/dnode/vnode/inc/tsdb.h index 87edfb8dde..7b93f7580d 100644 --- a/source/dnode/vnode/inc/tsdb.h +++ b/source/dnode/vnode/inc/tsdb.h @@ -107,10 +107,8 @@ int32_t tsdbUpdateSmaWindow(STsdb *pTsdb, int8_t smaType, char *msg); int32_t tsdbInsertRSmaData(STsdb *pTsdb, char *msg); // TODO: This is the basic params, and should wrap the params to a queryHandle. -int32_t tsdbGetTSmaData(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval, - int8_t intervalUnit, tb_uid_t tableUid, col_id_t colId, TSKEY querySkey, - int32_t nMaxResult); - +int32_t tsdbGetTSmaData(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval, int8_t intervalUnit, + tb_uid_t tableUid, col_id_t colId, TSKEY querySKey, int32_t nMaxResult); // STsdbCfg int tsdbOptionsInit(STsdbCfg *); diff --git a/source/dnode/vnode/src/meta/metaBDBImpl.c b/source/dnode/vnode/src/meta/metaBDBImpl.c index a729288e34..df2d9604d2 100644 --- a/source/dnode/vnode/src/meta/metaBDBImpl.c +++ b/source/dnode/vnode/src/meta/metaBDBImpl.c @@ -636,7 +636,7 @@ STSma *metaGetSmaInfoByIndex(SMeta *pMeta, int64_t indexUid) { } // Decode - pCfg = (STSma *)malloc(sizeof(STSma)); + pCfg = (STSma *)calloc(1, sizeof(STSma)); if (pCfg == NULL) { return NULL; } diff --git a/source/dnode/vnode/src/tsdb/tsdbSma.c b/source/dnode/vnode/src/tsdb/tsdbSma.c index cd8b60385f..7a5c9c5c1e 100644 --- a/source/dnode/vnode/src/tsdb/tsdbSma.c +++ b/source/dnode/vnode/src/tsdb/tsdbSma.c @@ -20,7 +20,7 @@ static const char *TSDB_SMA_DNAME[] = { "tsma", // TSDB_SMA_TYPE_TIME_RANGE "rsma", // TSDB_SMA_TYPE_ROLLUP }; - +#define SMA_CHECK_HASH #undef SMA_PRINT_DEBUG_LOG #define SMA_STORAGE_TSDB_DAYS 30 #define SMA_STORAGE_TSDB_TIMES 10 @@ -72,35 +72,43 @@ typedef struct { struct SSmaStat { SHashObj *smaStatItems; // key: indexName, value: SSmaStatItem + T_REF_DECLARE() }; // declaration of static functions -static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg); -static int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, char *msg); -// TODO: This is the basic params, and should wrap the params to a queryHandle. -static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval, - int8_t intervalUnit, tb_uid_t tableUid, col_id_t colId, TSKEY querySkey, - int32_t nMaxResult); -static int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, int8_t smaType, char *msg); - +// expired window +static int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, ETsdbSmaType smaType, char *msg); static int32_t tsdbInitSmaStat(SSmaStat **pSmaStat); static int32_t tsdbDestroySmaState(SSmaStat *pSmaStat); static SSmaEnv *tsdbNewSmaEnv(const STsdb *pTsdb, const char *path); static int32_t tsdbInitSmaEnv(STsdb *pTsdb, const char *path, SSmaEnv **pEnv); -static int32_t tsdbInitTSmaWriteH(STSmaWriteH *pSmaH, STsdb *pTsdb, STSmaDataWrapper *pData); -static void tsdbDestroyTSmaWriteH(STSmaWriteH *pSmaH); -static int32_t tsdbInitTSmaReadH(STSmaReadH *pSmaH, STsdb *pTsdb, int64_t interval, int8_t intervalUnit); -static int32_t tsdbGetSmaStorageLevel(int64_t interval, int8_t intervalUnit); -static int32_t tsdbInsertTSmaDataSection(STSmaWriteH *pSmaH, STSmaDataWrapper *pData); -static int32_t tsdbInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, uint32_t keyLen, void *pData, uint32_t dataLen); +static int32_t tsdbResetExpiredWindow(STsdb *pTsdb, SSmaStat *pStat, int64_t indexUid, TSKEY skey); +static int32_t tsdbRefSmaStat(STsdb *pTsdb, SSmaStat *pStat); +static int32_t tsdbUnRefSmaStat(STsdb *pTsdb, SSmaStat *pStat); +// read data +// TODO: This is the basic params, and should wrap the params to a queryHandle. +static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval, + int8_t intervalUnit, tb_uid_t tableUid, col_id_t colId, TSKEY querySKey, + int32_t nMaxResult); + +// insert data +static int32_t tsdbInitTSmaWriteH(STSmaWriteH *pSmaH, STsdb *pTsdb, STSmaDataWrapper *pData); +static void tsdbDestroyTSmaWriteH(STSmaWriteH *pSmaH); +static int32_t tsdbInitTSmaReadH(STSmaReadH *pSmaH, STsdb *pTsdb, int64_t interval, int8_t intervalUnit); +static int32_t tsdbGetSmaStorageLevel(int64_t interval, int8_t intervalUnit); +static int32_t tsdbInsertTSmaDataSection(STSmaWriteH *pSmaH, STSmaDataWrapper *pData); +static int32_t tsdbInsertTSmaBlocks(STSmaWriteH *pSmaH, void *smaKey, uint32_t keyLen, void *pData, uint32_t dataLen); static int64_t tsdbGetIntervalByPrecision(int64_t interval, uint8_t intervalUnit, int8_t precision); static int32_t tsdbGetTSmaDays(STsdb *pTsdb, int64_t interval, int32_t storageLevel); static int32_t tsdbSetTSmaDataFile(STSmaWriteH *pSmaH, STSmaDataWrapper *pData, int32_t storageLevel, int32_t fid); static int32_t tsdbInitTSmaFile(STSmaReadH *pSmaH, TSKEY skey); static bool tsdbSetAndOpenTSmaFile(STSmaReadH *pReadH, TSKEY *queryKey); static void tsdbGetSmaDir(int32_t vgId, ETsdbSmaType smaType, char dirName[]); +static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg); +static int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, char *msg); +// implementation static void tsdbGetSmaDir(int32_t vgId, ETsdbSmaType smaType, char dirName[]) { snprintf(dirName, TSDB_FILENAME_LEN, "vnode/vnode%d/tsdb/%s", vgId, TSDB_SMA_DNAME[smaType]); } @@ -192,6 +200,21 @@ void *tsdbFreeSmaEnv(SSmaEnv *pSmaEnv) { return NULL; } +static int32_t tsdbRefSmaStat(STsdb *pTsdb, SSmaStat *pStat) { + if (pStat == NULL) return 0; + int ref = T_REF_INC(pStat); + tsdbDebug("vgId:%d ref sma stat %p ref %d", REPO_ID(pTsdb), pStat, ref); + return 0; +} + +static int32_t tsdbUnRefSmaStat(STsdb *pTsdb, SSmaStat *pStat) { + if (pStat == NULL) return 0; + + int ref = T_REF_DEC(pStat); + tsdbDebug("vgId:%d unref sma stat %p ref %d", REPO_ID(pTsdb), pStat, ref); + return 0; +} + static int32_t tsdbInitSmaStat(SSmaStat **pSmaStat) { ASSERT(pSmaStat != NULL); @@ -296,7 +319,7 @@ static int32_t tsdbCheckAndInitSmaEnv(STsdb *pTsdb, int8_t smaType) { * @param msg * @return int32_t */ -int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, int8_t smaType, char *msg) { +int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, ETsdbSmaType smaType, char *msg) { if (!msg || !pTsdb->pMeta) { terrno = TSDB_CODE_INVALID_PTR; return TSDB_CODE_FAILED; @@ -307,27 +330,28 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, int8_t smaType, char *msg) { return TSDB_CODE_FAILED; } - SSmaEnv *pEnv = REPO_SMA_ENV(pTsdb, smaType); - - // TODO: decode the msg => start - int64_t indexUid = SMA_TEST_INDEX_UID; - // const char * indexName = SMA_TEST_INDEX_NAME; + // TODO: decode the msg from Stream Computing module => start + int64_t indexUid = SMA_TEST_INDEX_UID; const int32_t SMA_TEST_EXPIRED_WINDOW_SIZE = 10; TSKEY expiredWindows[SMA_TEST_EXPIRED_WINDOW_SIZE]; - int64_t now = taosGetTimestampMs(); + TSKEY skey1 = 1646987196 * 1e3; for (int32_t i = 0; i < SMA_TEST_EXPIRED_WINDOW_SIZE; ++i) { - expiredWindows[i] = now + i; + expiredWindows[i] = skey1 + i; } - // TODO: decode the msg <= end + + SSmaEnv * pEnv = REPO_SMA_ENV(pTsdb, smaType); + SSmaStat *pStat = SMA_ENV_STAT(pEnv); SHashObj *pItemsHash = SMA_ENV_STAT_ITEMS(pEnv); + tsdbRefSmaStat(pTsdb, pStat); SSmaStatItem *pItem = (SSmaStatItem *)taosHashGet(pItemsHash, &indexUid, sizeof(indexUid)); if (pItem == NULL) { pItem = tsdbNewSmaStatItem(TSDB_SMA_STAT_EXPIRED); // TODO use the real state if (pItem == NULL) { // Response to stream computing: OOM - // For query, if the indexName not found, the TSDB should tell query module to query raw TS data. + // For query, if the indexUid not found, the TSDB should tell query module to query raw TS data. + tsdbUnRefSmaStat(pTsdb, pStat); return TSDB_CODE_FAILED; } @@ -337,6 +361,7 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, int8_t smaType, char *msg) { terrno = TSDB_CODE_TDB_NO_SMA_INDEX_IN_META; taosHashCleanup(pItem->expiredWindows); free(pItem); + tsdbUnRefSmaStat(pTsdb, pStat); tsdbWarn("vgId:%d update expired window failed for smaIndex %" PRIi64 " since %s", REPO_ID(pTsdb), indexUid, tstrerror(terrno)); return TSDB_CODE_FAILED; @@ -347,18 +372,14 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, int8_t smaType, char *msg) { // If error occurs during put smaStatItem, free the resources of pItem taosHashCleanup(pItem->expiredWindows); free(pItem); + tsdbUnRefSmaStat(pTsdb, pStat); return TSDB_CODE_FAILED; } } -#if 0 - SSmaStatItem *pItem1 = (SSmaStatItem *)taosHashGet(pItemsHash, &indexUid, sizeof(indexUid)); - int size1 = taosHashGetSize(pItem1->expiredWindows); - tsdbWarn("vgId:%d smaIndex %" PRIi64 " size is %d before hashPut", REPO_ID(pTsdb), indexUid, size1); -#endif int8_t state = TSDB_SMA_STAT_EXPIRED; for (int32_t i = 0; i < SMA_TEST_EXPIRED_WINDOW_SIZE; ++i) { - if (taosHashPut(pItem->expiredWindows, &expiredWindows[i], sizeof(TSKEY), &state, sizeof(state)) != 0) { + if (taosHashPut(pItem->expiredWindows, (void *)(expiredWindows + i), sizeof(TSKEY), &state, sizeof(state)) != 0) { // If error occurs during taosHashPut expired windows, remove the smaIndex from pTsdb->pSmaStat, thus TSDB would // tell query module to query raw TS data. // N.B. @@ -368,37 +389,43 @@ int32_t tsdbUpdateExpiredWindow(STsdb *pTsdb, int8_t smaType, char *msg) { taosHashCleanup(pItem->expiredWindows); tfree(pItem->pSma); taosHashRemove(pItemsHash, &indexUid, sizeof(indexUid)); + tsdbUnRefSmaStat(pTsdb, pStat); return TSDB_CODE_FAILED; } + tsdbDebug("vgId:%d smaIndex %" PRIi64 " tsKey %" PRIi64 " is put to hash", REPO_ID(pTsdb), indexUid, + expiredWindows[i]); } -#if 0 - SSmaStatItem *pItem2 = (SSmaStatItem *)taosHashGet(pItemsHash, &indexUid, sizeof(indexUid)); - int size2 = taosHashGetSize(pItem1->expiredWindows); - tsdbWarn("vgId:%d smaIndex %" PRIi64 " size is %d after hashPut", REPO_ID(pTsdb), indexUid, size2); -#endif - + tsdbUnRefSmaStat(pTsdb, pStat); return TSDB_CODE_SUCCESS; } -static int32_t tsdbResetExpiredWindow(SSmaStat *pStat, int64_t indexUid, TSKEY skey) { +static int32_t tsdbResetExpiredWindow(STsdb *pTsdb, SSmaStat *pStat, int64_t indexUid, TSKEY skey) { SSmaStatItem *pItem = NULL; - // TODO: If HASH_ENTRY_LOCK used, whether rwlock needed to handle cases of removing hashNode? + tsdbRefSmaStat(pTsdb, pStat); + if (pStat && pStat->smaStatItems) { - pItem = (SSmaStatItem *)taosHashGet(pStat->smaStatItems, &indexUid, sizeof(indexUid)); + pItem = *(SSmaStatItem **)taosHashGet(pStat->smaStatItems, &indexUid, sizeof(indexUid)); } -#if 0 if (pItem != NULL) { - // TODO: reset time window for the sma data blocks + // pItem resides in hash buffer all the time unless drop sma index + // TODO: multithread protect if (taosHashRemove(pItem->expiredWindows, &skey, sizeof(TSKEY)) != 0) { // error handling + tsdbUnRefSmaStat(pTsdb, pStat); + tsdbWarn("vgId:%d remove skey %" PRIi64 " from expired window for sma index %" PRIi64 " failed", REPO_ID(pTsdb), + skey, indexUid); + return TSDB_CODE_FAILED; } - } else { // error handling + tsdbUnRefSmaStat(pTsdb, pStat); + tsdbWarn("vgId:%d expired window %" PRIi64 " not exists for sma index %" PRIi64, REPO_ID(pTsdb), skey, indexUid); + return TSDB_CODE_FAILED; } -#endif + + tsdbUnRefSmaStat(pTsdb, pStat); return TSDB_CODE_SUCCESS; } @@ -705,7 +732,7 @@ static int32_t tsdbInsertTSmaDataImpl(STsdb *pTsdb, char *msg) { // TODO:tsdbEndTSmaCommit(); // Step 3: reset the SSmaStat - tsdbResetExpiredWindow(SMA_ENV_STAT(pTsdb->pTSmaEnv), pData->indexUid, pData->skey); + tsdbResetExpiredWindow(pTsdb, SMA_ENV_STAT(pTsdb->pTSmaEnv), pData->indexUid, pData->skey); tsdbDestroyTSmaWriteH(&tSmaH); return TSDB_CODE_SUCCESS; @@ -751,7 +778,7 @@ static int32_t tsdbInsertRSmaDataImpl(STsdb *pTsdb, char *msg) { // TODO:tsdbEndTSmaCommit(); // reset the SSmaStat - tsdbResetExpiredWindow(SMA_ENV_STAT(pTsdb->pRSmaEnv), pData->indexUid, pData->skey); + tsdbResetExpiredWindow(pTsdb, SMA_ENV_STAT(pTsdb->pRSmaEnv), pData->indexUid, pData->skey); return TSDB_CODE_SUCCESS; } @@ -839,7 +866,7 @@ static bool tsdbSetAndOpenTSmaFile(STSmaReadH *pReadH, TSKEY *queryKey) { * @return int32_t */ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval, - int8_t intervalUnit, tb_uid_t tableUid, col_id_t colId, TSKEY querySkey, + int8_t intervalUnit, tb_uid_t tableUid, col_id_t colId, TSKEY querySKey, int32_t nMaxResult) { if (!pTsdb->pTSmaEnv) { terrno = TSDB_CODE_INVALID_PTR; @@ -847,12 +874,14 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_ return TSDB_CODE_FAILED; } - SSmaStatItem *pItem = (SSmaStatItem *)taosHashGet(SMA_ENV_STAT_ITEMS(pTsdb->pTSmaEnv), &indexUid, sizeof(indexUid)); + tsdbRefSmaStat(pTsdb, SMA_ENV_STAT(pTsdb->pTSmaEnv)); + SSmaStatItem *pItem = *(SSmaStatItem **)taosHashGet(SMA_ENV_STAT_ITEMS(pTsdb->pTSmaEnv), &indexUid, sizeof(indexUid)); if (pItem == NULL) { // Normally pItem should not be NULL, mark all windows as expired and notify query module to fetch raw TS data if // it's NULL. + tsdbUnRefSmaStat(pTsdb, SMA_ENV_STAT(pTsdb->pTSmaEnv)); terrno = TSDB_CODE_TDB_INVALID_ACTION; - tsdbWarn("vgId:%d getTSmaDataImpl failed since no index %" PRIi64 " in local cache", REPO_ID(pTsdb), indexUid); + tsdbDebug("vgId:%d getTSmaDataImpl failed since no index %" PRIi64, REPO_ID(pTsdb), indexUid); return TSDB_CODE_FAILED; } @@ -866,16 +895,23 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_ } #endif -#if 0 - if (taosHashGet(pItem->expiredWindows, &querySkey, sizeof(TSKEY)) != NULL) { +#if 1 + if (taosHashGet(pItem->expiredWindows, &querySKey, sizeof(TSKEY)) != NULL) { // TODO: mark this window as expired. + tsdbDebug("vgId:%d skey %" PRIi64 " of window exists in expired window for index %" PRIi64, REPO_ID(pTsdb), + querySKey, indexUid); + } else { + tsdbDebug("vgId:%d skey %" PRIi64 " of window not in expired window for index %" PRIi64, REPO_ID(pTsdb), querySKey, + indexUid); } + tsdbUnRefSmaStat(pTsdb, SMA_ENV_STAT(pTsdb->pTSmaEnv)); + #endif STSmaReadH tReadH = {0}; tsdbInitTSmaReadH(&tReadH, pTsdb, interval, intervalUnit); tsdbCloseDBF(&tReadH.dFile); - tsdbInitTSmaFile(&tReadH, querySkey); + tsdbInitTSmaFile(&tReadH, querySKey); if (tsdbOpenDBF(SMA_ENV_ENV(pTsdb->pTSmaEnv), &tReadH.dFile) != 0) { tsdbWarn("vgId:%d open DBF %s failed since %s", REPO_ID(pTsdb), tReadH.dFile.path, tstrerror(terrno)); return TSDB_CODE_FAILED; @@ -883,7 +919,7 @@ static int32_t tsdbGetTSmaDataImpl(STsdb *pTsdb, STSmaDataWrapper *pData, int64_ char smaKey[SMA_KEY_LEN] = {0}; void *pSmaKey = &smaKey; - tsdbEncodeTSmaKey(tableUid, colId, querySkey, (void **)&pSmaKey); + tsdbEncodeTSmaKey(tableUid, colId, querySKey, (void **)&pSmaKey); tsdbDebug("vgId:%d get sma data from %s: smaKey %" PRIx64 "-%" PRIu16 "-%" PRIx64 ", keyLen %d", REPO_ID(pTsdb), tReadH.dFile.path, *(tb_uid_t *)smaKey, *(uint16_t *)POINTER_SHIFT(smaKey, 8), @@ -1010,9 +1046,9 @@ int32_t tsdbInsertRSmaData(STsdb *pTsdb, char *msg) { } int32_t tsdbGetTSmaData(STsdb *pTsdb, STSmaDataWrapper *pData, int64_t indexUid, int64_t interval, int8_t intervalUnit, - tb_uid_t tableUid, col_id_t colId, TSKEY querySkey, int32_t nMaxResult) { + tb_uid_t tableUid, col_id_t colId, TSKEY querySKey, int32_t nMaxResult) { int32_t code = TSDB_CODE_SUCCESS; - if ((code = tsdbGetTSmaDataImpl(pTsdb, pData, indexUid, interval, intervalUnit, tableUid, colId, querySkey, + if ((code = tsdbGetTSmaDataImpl(pTsdb, pData, indexUid, interval, intervalUnit, tableUid, colId, querySKey, nMaxResult)) < 0) { tsdbWarn("vgId:%d get tSma data failed since %s", REPO_ID(pTsdb), tstrerror(terrno)); } diff --git a/source/dnode/vnode/test/tsdbSmaTest.cpp b/source/dnode/vnode/test/tsdbSmaTest.cpp index 96fd35e700..ae4e9b0a75 100644 --- a/source/dnode/vnode/test/tsdbSmaTest.cpp +++ b/source/dnode/vnode/test/tsdbSmaTest.cpp @@ -301,7 +301,7 @@ TEST(testCase, tSma_Data_Insert_Query_Test) { break; } - char *msg = (char *)calloc(100, 1); + char *msg = (char *)calloc(1, 100); assert(msg != NULL); ASSERT_EQ(tsdbUpdateSmaWindow(&tsdb, TSDB_SMA_TYPE_TIME_RANGE, msg), 0);