diff --git a/include/common/tcommon.h b/include/common/tcommon.h index b57de3660b..8332e9d09a 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -209,8 +209,8 @@ typedef struct SGroupbyExpr { } SGroupbyExpr; enum { - FUNC_PARAM_TYPE_VALUE = 0, - FUNC_PARAM_TYPE_COLUMN, + FUNC_PARAM_TYPE_VALUE = 0x1, + FUNC_PARAM_TYPE_COLUMN= 0x2, }; typedef struct SFunctParam { diff --git a/include/common/tmsg.h b/include/common/tmsg.h index cd16bbf862..31b316861b 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -524,6 +524,7 @@ typedef struct { int8_t walLevel; int8_t quorum; int8_t cacheLastRow; + int8_t replications; } SAlterDbReq; int32_t tSerializeSAlterDbReq(void* buf, int32_t bufLen, SAlterDbReq* pReq); diff --git a/include/common/ttime.h b/include/common/ttime.h index 57af24e635..306f54bedb 100644 --- a/include/common/ttime.h +++ b/include/common/ttime.h @@ -60,8 +60,10 @@ int32_t parseNatualDuration(const char* token, int32_t tokenLen, int64_t* durati int32_t taosParseTime(const char* timestr, int64_t* time, int32_t len, int32_t timePrec, int8_t dayligth); void deltaToUtcInitOnce(); +char getPrecisionUnit(int32_t precision); int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision); +int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char toUnit); void taosFormatUtcTime(char *buf, int32_t bufLen, int64_t time, int32_t precision); diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 47a97071aa..8d996be21e 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -82,21 +82,21 @@ #define TK_SINGLE_STABLE 64 #define TK_STREAM_MODE 65 #define TK_RETENTIONS 66 -#define TK_TABLE 67 -#define TK_NK_LP 68 -#define TK_NK_RP 69 -#define TK_STABLE 70 -#define TK_ADD 71 -#define TK_COLUMN 72 -#define TK_MODIFY 73 -#define TK_RENAME 74 -#define TK_TAG 75 -#define TK_SET 76 -#define TK_NK_EQ 77 -#define TK_USING 78 -#define TK_TAGS 79 -#define TK_NK_DOT 80 -#define TK_NK_COMMA 81 +#define TK_NK_COMMA 67 +#define TK_TABLE 68 +#define TK_NK_LP 69 +#define TK_NK_RP 70 +#define TK_STABLE 71 +#define TK_ADD 72 +#define TK_COLUMN 73 +#define TK_MODIFY 74 +#define TK_RENAME 75 +#define TK_TAG 76 +#define TK_SET 77 +#define TK_NK_EQ 78 +#define TK_USING 79 +#define TK_TAGS 80 +#define TK_NK_DOT 81 #define TK_COMMENT 82 #define TK_BOOL 83 #define TK_TINYINT 84 @@ -131,69 +131,91 @@ #define TK_FUNCTIONS 113 #define TK_INDEXES 114 #define TK_FROM 115 -#define TK_LIKE 116 -#define TK_INDEX 117 -#define TK_FULLTEXT 118 -#define TK_FUNCTION 119 -#define TK_INTERVAL 120 -#define TK_TOPIC 121 -#define TK_AS 122 -#define TK_DESC 123 -#define TK_DESCRIBE 124 -#define TK_RESET 125 -#define TK_QUERY 126 -#define TK_EXPLAIN 127 -#define TK_ANALYZE 128 -#define TK_VERBOSE 129 -#define TK_NK_BOOL 130 -#define TK_RATIO 131 -#define TK_NULL 132 -#define TK_NK_VARIABLE 133 -#define TK_NK_UNDERLINE 134 -#define TK_ROWTS 135 -#define TK_TBNAME 136 -#define TK_QSTARTTS 137 -#define TK_QENDTS 138 -#define TK_WSTARTTS 139 -#define TK_WENDTS 140 -#define TK_WDURATION 141 -#define TK_BETWEEN 142 -#define TK_IS 143 -#define TK_NK_LT 144 -#define TK_NK_GT 145 -#define TK_NK_LE 146 -#define TK_NK_GE 147 -#define TK_NK_NE 148 -#define TK_MATCH 149 -#define TK_NMATCH 150 -#define TK_IN 151 -#define TK_JOIN 152 -#define TK_INNER 153 -#define TK_SELECT 154 -#define TK_DISTINCT 155 -#define TK_WHERE 156 -#define TK_PARTITION 157 -#define TK_BY 158 -#define TK_SESSION 159 -#define TK_STATE_WINDOW 160 -#define TK_SLIDING 161 -#define TK_FILL 162 -#define TK_VALUE 163 -#define TK_NONE 164 -#define TK_PREV 165 -#define TK_LINEAR 166 -#define TK_NEXT 167 -#define TK_GROUP 168 -#define TK_HAVING 169 -#define TK_ORDER 170 -#define TK_SLIMIT 171 -#define TK_SOFFSET 172 -#define TK_LIMIT 173 -#define TK_OFFSET 174 -#define TK_ASC 175 -#define TK_NULLS 176 -#define TK_FIRST 177 -#define TK_LAST 178 +#define TK_ACCOUNTS 116 +#define TK_APPS 117 +#define TK_CONNECTIONS 118 +#define TK_LICENCE 119 +#define TK_QUERIES 120 +#define TK_SCORES 121 +#define TK_TOPICS 122 +#define TK_VARIABLES 123 +#define TK_LIKE 124 +#define TK_INDEX 125 +#define TK_FULLTEXT 126 +#define TK_FUNCTION 127 +#define TK_INTERVAL 128 +#define TK_TOPIC 129 +#define TK_AS 130 +#define TK_DESC 131 +#define TK_DESCRIBE 132 +#define TK_RESET 133 +#define TK_QUERY 134 +#define TK_EXPLAIN 135 +#define TK_ANALYZE 136 +#define TK_VERBOSE 137 +#define TK_NK_BOOL 138 +#define TK_RATIO 139 +#define TK_COMPACT 140 +#define TK_VNODES 141 +#define TK_IN 142 +#define TK_OUTPUTTYPE 143 +#define TK_AGGREGATE 144 +#define TK_BUFSIZE 145 +#define TK_STREAM 146 +#define TK_INTO 147 +#define TK_KILL 148 +#define TK_CONNECTION 149 +#define TK_MERGE 150 +#define TK_VGROUP 151 +#define TK_REDISTRIBUTE 152 +#define TK_SPLIT 153 +#define TK_SYNCDB 154 +#define TK_NULL 155 +#define TK_NK_VARIABLE 156 +#define TK_NK_UNDERLINE 157 +#define TK_ROWTS 158 +#define TK_TBNAME 159 +#define TK_QSTARTTS 160 +#define TK_QENDTS 161 +#define TK_WSTARTTS 162 +#define TK_WENDTS 163 +#define TK_WDURATION 164 +#define TK_BETWEEN 165 +#define TK_IS 166 +#define TK_NK_LT 167 +#define TK_NK_GT 168 +#define TK_NK_LE 169 +#define TK_NK_GE 170 +#define TK_NK_NE 171 +#define TK_MATCH 172 +#define TK_NMATCH 173 +#define TK_JOIN 174 +#define TK_INNER 175 +#define TK_SELECT 176 +#define TK_DISTINCT 177 +#define TK_WHERE 178 +#define TK_PARTITION 179 +#define TK_BY 180 +#define TK_SESSION 181 +#define TK_STATE_WINDOW 182 +#define TK_SLIDING 183 +#define TK_FILL 184 +#define TK_VALUE 185 +#define TK_NONE 186 +#define TK_PREV 187 +#define TK_LINEAR 188 +#define TK_NEXT 189 +#define TK_GROUP 190 +#define TK_HAVING 191 +#define TK_ORDER 192 +#define TK_SLIMIT 193 +#define TK_SOFFSET 194 +#define TK_LIMIT 195 +#define TK_OFFSET 196 +#define TK_ASC 197 +#define TK_NULLS 198 +#define TK_FIRST 199 +#define TK_LAST 200 #define TK_NK_SPACE 300 #define TK_NK_COMMENT 301 @@ -207,10 +229,9 @@ #define TK_NK_COLON 500 #define TK_NK_BITNOT 501 #define TK_INSERT 502 -#define TK_INTO 503 #define TK_NOW 504 #define TK_VALUES 507 -#define TK_IMPORT 507 +#define TK_IMPORT 509 #define TK_NK_SEMI 508 #define TK_NK_NIL 65535 diff --git a/include/libs/command/command.h b/include/libs/command/command.h index 699c2f9792..7e58d39692 100644 --- a/include/libs/command/command.h +++ b/include/libs/command/command.h @@ -15,5 +15,10 @@ #include "cmdnodes.h" #include "tmsg.h" +#include "plannodes.h" int32_t qExecCommand(SNode* pStmt, SRetrieveTableRsp** pRsp); + +int32_t qExecStaticExplain(SQueryPlan *pDag, SRetrieveTableRsp **pRsp); + + diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index 1c812d40ca..069aec14b5 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -38,7 +38,9 @@ typedef struct SDatabaseOptions { int32_t fsyncPeriod; int32_t maxRowsPerBlock; int32_t minRowsPerBlock; - int32_t keep; + int32_t keep0; + int32_t keep1; + int32_t keep2; int32_t precision; int32_t quorum; int32_t replica; @@ -76,7 +78,9 @@ typedef struct SAlterDatabaseStmt { typedef struct STableOptions { ENodeType type; - int32_t keep; + int32_t keep0; + int32_t keep1; + int32_t keep2; int32_t ttl; char comments[TSDB_STB_COMMENT_LEN]; SNodeList* pSma; @@ -193,6 +197,12 @@ typedef struct SShowStmt { SNode* pTbNamePattern; // SValueNode } SShowStmt; +typedef struct SShowCreatStmt { + ENodeType type; + char dbName[TSDB_DB_NAME_LEN]; + char tableName[TSDB_TABLE_NAME_LEN]; +} SShowCreatStmt; + typedef enum EIndexType { INDEX_TYPE_SMA = 1, INDEX_TYPE_FULLTEXT diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 5f86c75787..9668082696 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -103,6 +103,15 @@ typedef enum ENodeType { QUERY_NODE_EXPLAIN_STMT, QUERY_NODE_DESCRIBE_STMT, QUERY_NODE_RESET_QUERY_CACHE_STMT, + QUERY_NODE_COMPACT_STMT, + QUERY_NODE_CREATE_FUNCTION_STMT, + QUERY_NODE_DROP_FUNCTION_STMT, + QUERY_NODE_CREATE_STREAM_STMT, + QUERY_NODE_DROP_STREAM_STMT, + QUERY_NODE_MERGE_VGROUP_STMT, + QUERY_NODE_REDISTRIBUTE_VGROUP_STMT, + QUERY_NODE_SPLIT_VGROUP_STMT, + QUERY_NODE_SYNCDB_STMT, QUERY_NODE_SHOW_DATABASES_STMT, QUERY_NODE_SHOW_TABLES_STMT, QUERY_NODE_SHOW_STABLES_STMT, @@ -115,6 +124,18 @@ typedef enum ENodeType { QUERY_NODE_SHOW_FUNCTIONS_STMT, QUERY_NODE_SHOW_INDEXES_STMT, QUERY_NODE_SHOW_STREAMS_STMT, + QUERY_NODE_SHOW_APPS_STMT, + QUERY_NODE_SHOW_CONNECTIONS_STMT, + QUERY_NODE_SHOW_LICENCE_STMT, + QUERY_NODE_SHOW_CREATE_DATABASE_STMT, + QUERY_NODE_SHOW_CREATE_TABLE_STMT, + QUERY_NODE_SHOW_CREATE_STABLE_STMT, + QUERY_NODE_SHOW_QUERIES_STMT, + QUERY_NODE_SHOW_SCORES_STMT, + QUERY_NODE_SHOW_TOPICS_STMT, + QUERY_NODE_SHOW_VARIABLE_STMT, + QUERY_NODE_KILL_CONNECTION_STMT, + QUERY_NODE_KILL_QUERY_STMT, // logic plan node QUERY_NODE_LOGIC_PLAN_SCAN, @@ -215,6 +236,8 @@ 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); +int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len); + #ifdef __cplusplus } #endif diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index f41e049196..37163f60dd 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -253,7 +253,7 @@ typedef struct SIntervalPhysiNode { int64_t sliding; int8_t intervalUnit; int8_t slidingUnit; - uint8_t precision; + uint8_t precision; SFillNode* pFill; } SIntervalPhysiNode; diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 23a63c1a0b..ddcbaa0bee 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -314,6 +314,7 @@ bool nodesIsTimeorderQuery(const SNode* pQuery); bool nodesIsTimelineQuery(const SNode* pQuery); void* nodesGetValueFromNode(SValueNode *pNode); +char* nodesGetStrValueFromNode(SValueNode *pNode); #ifdef __cplusplus } diff --git a/include/libs/qcom/query.h b/include/libs/qcom/query.h index f487e5ae22..bb550e75e8 100644 --- a/include/libs/qcom/query.h +++ b/include/libs/qcom/query.h @@ -53,6 +53,7 @@ typedef struct SIndexMeta { } SIndexMeta; + /* * ASSERT(sizeof(SCTableMeta) == 24) * ASSERT(tableType == TSDB_CHILD_TABLE) @@ -235,6 +236,11 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t } \ } while (0) +#define QRY_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0) +#define QRY_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) +#define QRY_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) + + #ifdef __cplusplus } #endif diff --git a/include/os/osMemory.h b/include/os/osMemory.h index 62ac82782c..34e2422167 100644 --- a/include/os/osMemory.h +++ b/include/os/osMemory.h @@ -32,6 +32,7 @@ extern "C" { void *taosMemoryMalloc(int32_t size); void *taosMemoryCalloc(int32_t num, int32_t size); void *taosMemoryRealloc(void *ptr, int32_t size); +void *taosMemoryStrDup(void *ptr); void taosMemoryFree(const void *ptr); int32_t taosMemorySize(void *ptr); diff --git a/include/os/osProc.h b/include/os/osProc.h index 0b22105e5e..f09b695ef4 100644 --- a/include/os/osProc.h +++ b/include/os/osProc.h @@ -21,9 +21,11 @@ extern "C" { #endif int32_t taosNewProc(char **args); +void taosWaitProc(int32_t pid); +void taosKillProc(int32_t pid); +bool taosProcExist(int32_t pid); void taosSetProcName(int32_t argc, char **argv, const char *name); void taosSetProcPath(int32_t argc, char **argv); -bool taosProcExists(int32_t pid); #ifdef __cplusplus } diff --git a/include/os/osTime.h b/include/os/osTime.h index 9e426455dc..766fec0fbd 100644 --- a/include/os/osTime.h +++ b/include/os/osTime.h @@ -46,6 +46,14 @@ extern "C" { #define MILLISECOND_PER_DAY (MILLISECOND_PER_HOUR * 24) #define MILLISECOND_PER_WEEK (MILLISECOND_PER_DAY * 7) +#define NANOSECOND_PER_USEC (1000L) +#define NANOSECOND_PER_MSEC (1000000L) +#define NANOSECOND_PER_SEC (1000000000L) +#define NANOSECOND_PER_MINUTE (NANOSECOND_PER_SEC * 60) +#define NANOSECOND_PER_HOUR (NANOSECOND_PER_MINUTE * 60) +#define NANOSECOND_PER_DAY (NANOSECOND_PER_HOUR * 24) +#define NANOSECOND_PER_WEEK (NANOSECOND_PER_DAY * 7) + int32_t taosGetTimeOfDay(struct timeval *tv); //@return timestamp in second diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 27145afc3d..4e2cb7944a 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -479,6 +479,9 @@ int32_t* taosGetErrno(); #define TSDB_CODE_PAR_INVALID_ENDPOINT TAOS_DEF_ERROR_CODE(0, 0x2613) #define TSDB_CODE_PAR_EXPRIE_STATEMENT TAOS_DEF_ERROR_CODE(0, 0x2614) #define TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL TAOS_DEF_ERROR_CODE(0, 0x2615) +#define TSDB_CODE_PAR_DB_NOT_SPECIFIED TAOS_DEF_ERROR_CODE(0, 0x2616) +#define TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME TAOS_DEF_ERROR_CODE(0, 0x2617) +#define TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR TAOS_DEF_ERROR_CODE(0, 0x2618) #ifdef __cplusplus } diff --git a/include/util/tdef.h b/include/util/tdef.h index 43981adea2..517cb8baee 100644 --- a/include/util/tdef.h +++ b/include/util/tdef.h @@ -224,6 +224,7 @@ typedef enum ELogicConditionType { #define TSDB_APP_NAME_LEN TSDB_UNI_LEN #define TSDB_STB_COMMENT_LEN 1024 + /** * In some scenarios uint16_t (0~65535) is used to store the row len. * - Firstly, we use 65531(65535 - 4), as the SDataRow/SKVRow contains 4 bits header. @@ -303,13 +304,13 @@ typedef enum ELogicConditionType { #define TSDB_MAX_TOTAL_BLOCKS 10000 #define TSDB_DEFAULT_TOTAL_BLOCKS 6 -#define TSDB_MIN_DAYS_PER_FILE 1 -#define TSDB_MAX_DAYS_PER_FILE 3650 -#define TSDB_DEFAULT_DAYS_PER_FILE 10 +#define TSDB_MIN_DAYS_PER_FILE (1 * 1440) // unit minute +#define TSDB_MAX_DAYS_PER_FILE (3650 * 1440) +#define TSDB_DEFAULT_DAYS_PER_FILE (10 * 1440) -#define TSDB_MIN_KEEP 1 // data in db to be reserved. -#define TSDB_MAX_KEEP 365000 // data in db to be reserved. -#define TSDB_DEFAULT_KEEP 3650 // ten years +#define TSDB_MIN_KEEP (1 * 1440) // data in db to be reserved. unit minute +#define TSDB_MAX_KEEP (365000 * 1440) // data in db to be reserved. +#define TSDB_DEFAULT_KEEP (3650 * 1440) // ten years #define TSDB_MIN_MIN_ROW_FBLOCK 10 #define TSDB_MAX_MIN_ROW_FBLOCK 1000 @@ -327,7 +328,7 @@ typedef enum ELogicConditionType { #define TSDB_MAX_FSYNC_PERIOD 180000 // millisecond #define TSDB_DEFAULT_FSYNC_PERIOD 3000 // three second -#define TSDB_MIN_WAL_LEVEL 0 +#define TSDB_MIN_WAL_LEVEL 1 #define TSDB_MAX_WAL_LEVEL 2 #define TSDB_DEFAULT_WAL_LEVEL 1 @@ -388,6 +389,7 @@ typedef enum ELogicConditionType { #define TSDB_DEFAULT_EXPLAIN_RATIO 0.001 #define TSDB_EXPLAIN_RESULT_ROW_SIZE 1024 +#define TSDB_EXPLAIN_RESULT_COLUMN_NAME "QUERY PLAN" #define TSDB_MAX_JOIN_TABLE_NUM 10 #define TSDB_MAX_UNION_CLAUSE 5 @@ -479,6 +481,9 @@ enum { #define QND_VGID 1 #define VND_VGID 0 +#define MAX_NUM_STR_SIZE 40 + + #ifdef __cplusplus } #endif diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index c85184ffba..06dd2906be 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -1629,6 +1629,7 @@ int32_t tSerializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) { if (tEncodeI8(&encoder, pReq->walLevel) < 0) return -1; if (tEncodeI8(&encoder, pReq->quorum) < 0) return -1; if (tEncodeI8(&encoder, pReq->cacheLastRow) < 0) return -1; + if (tEncodeI8(&encoder, pReq->replications) < 0) return -1; tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -1650,6 +1651,7 @@ int32_t tDeserializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) { if (tDecodeI8(&decoder, &pReq->walLevel) < 0) return -1; if (tDecodeI8(&decoder, &pReq->quorum) < 0) return -1; if (tDecodeI8(&decoder, &pReq->cacheLastRow) < 0) return -1; + if (tDecodeI8(&decoder, &pReq->replications) < 0) return -1; tEndDecode(&decoder); tCoderClear(&decoder); diff --git a/source/common/src/ttime.c b/source/common/src/ttime.c index 510a2809e7..a65352f2b9 100644 --- a/source/common/src/ttime.c +++ b/source/common/src/ttime.c @@ -361,6 +361,18 @@ int32_t parseLocaltimeDst(char* timestr, int64_t* time, int32_t timePrec) { return 0; } +char getPrecisionUnit(int32_t precision) { + static char units[3] = {TIME_UNIT_MILLISECOND, TIME_UNIT_MICROSECOND, TIME_UNIT_NANOSECOND}; + switch (precision) { + case TSDB_TIME_PRECISION_MILLI: + case TSDB_TIME_PRECISION_MICRO: + case TSDB_TIME_PRECISION_NANO: + return units[precision]; + default: + return 0; + } +} + int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrecision) { assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || fromPrecision == TSDB_TIME_PRECISION_MICRO || fromPrecision == TSDB_TIME_PRECISION_NANO); @@ -370,6 +382,33 @@ int64_t convertTimePrecision(int64_t time, int32_t fromPrecision, int32_t toPrec return (int64_t)((double)time * factors[fromPrecision][toPrecision]); } +int64_t convertTimeFromPrecisionToUnit(int64_t time, int32_t fromPrecision, char toUnit) { + assert(fromPrecision == TSDB_TIME_PRECISION_MILLI || fromPrecision == TSDB_TIME_PRECISION_MICRO || + fromPrecision == TSDB_TIME_PRECISION_NANO); + static double factors[3] = {1000000., 1000., 1.}; + switch (toUnit) { + case 's': + return time * factors[fromPrecision] / NANOSECOND_PER_SEC; + case 'm': + return time * factors[fromPrecision] / NANOSECOND_PER_MINUTE; + case 'h': + return time * factors[fromPrecision] / NANOSECOND_PER_HOUR; + case 'd': + return time * factors[fromPrecision] / NANOSECOND_PER_DAY; + case 'w': + return time * factors[fromPrecision] / NANOSECOND_PER_WEEK; + case 'a': + return time * factors[fromPrecision] / NANOSECOND_PER_MSEC; + case 'u': + return time * factors[fromPrecision] / NANOSECOND_PER_USEC; + case 'b': + return time * factors[fromPrecision]; + default: { + return -1; + } + } +} + static int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision) { switch (unit) { case 's': @@ -688,4 +727,4 @@ void taosFormatUtcTime(char* buf, int32_t bufLen, int64_t t, int32_t precision) length += (int32_t)strftime(ts + length, 40 - length, "%z", ptm); tstrncpy(buf, ts, bufLen); -} \ No newline at end of file +} diff --git a/source/dnode/mgmt/dm/src/dmFile.c b/source/dnode/mgmt/dm/src/dmFile.c index 444f18e6e0..d5105bcb1b 100644 --- a/source/dnode/mgmt/dm/src/dmFile.c +++ b/source/dnode/mgmt/dm/src/dmFile.c @@ -200,7 +200,7 @@ int32_t dmWriteFile(SDnodeMgmt *pMgmt) { taosMemoryFree(content); char realfile[PATH_MAX]; - snprintf(realfile, sizeof(realfile), "%s%smnode.json", pMgmt->path, TD_DIRSEP); + snprintf(realfile, sizeof(realfile), "%s%sdnode.json", pMgmt->path, TD_DIRSEP); if (taosRenameFile(file, realfile) != 0) { terrno = TAOS_SYSTEM_ERROR(errno); diff --git a/source/dnode/mgmt/main/src/dndExec.c b/source/dnode/mgmt/main/src/dndExec.c index fdc6125fb0..b37893aa6f 100644 --- a/source/dnode/mgmt/main/src/dndExec.c +++ b/source/dnode/mgmt/main/src/dndExec.c @@ -20,9 +20,9 @@ static bool dndRequireNode(SMgmtWrapper *pWrapper) { bool required = false; int32_t code = (*pWrapper->fp.requiredFp)(pWrapper, &required); if (!required) { - dDebug("node:%s, no need to start", pWrapper->name); + dDebug("node:%s, does not require startup", pWrapper->name); } else { - dDebug("node:%s, need to start", pWrapper->name); + dDebug("node:%s, needs to be started", pWrapper->name); } return required; } @@ -255,17 +255,39 @@ static int32_t dndRunInParentProcess(SDnode *pDnode) { while (1) { if (pDnode->event == DND_EVENT_STOP) { dInfo("dnode is about to stop"); + for (ENodeType n = DNODE + 1; n < NODE_MAX; ++n) { + SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; + if (!pWrapper->required) continue; + if (pDnode->ntype == NODE_MAX) continue; + + if (pWrapper->procId > 0 && taosProcExist(pWrapper->procId)) { + dInfo("node:%s, send kill signal to the child process:%d", pWrapper->name, pWrapper->procId); + taosKillProc(pWrapper->procId); + } + } + + for (ENodeType n = DNODE + 1; n < NODE_MAX; ++n) { + SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; + if (!pWrapper->required) continue; + if (pDnode->ntype == NODE_MAX) continue; + + if (pWrapper->procId > 0 && taosProcExist(pWrapper->procId)) { + dInfo("node:%s, wait for child process:%d to stop", pWrapper->name, pWrapper->procId); + taosWaitProc(pWrapper->procId); + dInfo("node:%s, child process:%d is stopped", pWrapper->name, pWrapper->procId); + } + } break; - } + } else { + for (ENodeType n = DNODE + 1; n < NODE_MAX; ++n) { + SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; + if (!pWrapper->required) continue; + if (pDnode->ntype == NODE_MAX) continue; - for (ENodeType n = DNODE + 1; n < NODE_MAX; ++n) { - SMgmtWrapper *pWrapper = &pDnode->wrappers[n]; - if (!pWrapper->required) continue; - if (pDnode->ntype == NODE_MAX) continue; - - if (pWrapper->procId <= 0 || !taosProcExists(pWrapper->procId)) { - dInfo("node:%s, process:%d is killed and needs to be restarted", pWrapper->name, pWrapper->procId); - dndNewProc(pWrapper, n); + if (pWrapper->procId <= 0 || !taosProcExist(pWrapper->procId)) { + dInfo("node:%s, process:%d is killed and needs to be restarted", pWrapper->name, pWrapper->procId); + dndNewProc(pWrapper, n); + } } } @@ -279,6 +301,12 @@ static int32_t dndRunInChildProcess(SDnode *pDnode) { SMgmtWrapper *pWrapper = &pDnode->wrappers[pDnode->ntype]; dInfo("%s run in child process", pWrapper->name); + pWrapper->required = dndRequireNode(pWrapper); + if (!pWrapper->required) { + dError("%s does not require startup", pWrapper->name); + return -1; + } + SMsgCb msgCb = dndCreateMsgcb(pWrapper); tmsgSetDefaultMsgCb(&msgCb); pWrapper->procType = PROC_CHILD; diff --git a/source/dnode/mgmt/vm/src/vmWorker.c b/source/dnode/mgmt/vm/src/vmWorker.c index 9d62624756..4be6311cf8 100644 --- a/source/dnode/mgmt/vm/src/vmWorker.c +++ b/source/dnode/mgmt/vm/src/vmWorker.c @@ -187,7 +187,7 @@ static int32_t vmPutNodeMsgToQueue(SVnodesMgmt *pMgmt, SNodeMsg *pMsg, EQueueTyp SVnodeObj *pVnode = vmAcquireVnode(pMgmt, pHead->vgId); if (pVnode == NULL) { dError("vgId:%d, failed to write msg:%p to vnode-queue since %s", pHead->vgId, pMsg, terrstr()); - return -1; + return terrno; } int32_t code = 0; diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index bd66bdeae9..462f0eb85a 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -1309,7 +1309,7 @@ static int32_t mndGetDbMeta(SNodeMsg *pReq, SShowObj *pShow, STableMetaRsp *pMet cols++; pShow->bytes[cols] = 2; - pSchema[cols].type = TSDB_DATA_TYPE_SMALLINT; + pSchema[cols].type = TSDB_DATA_TYPE_INT; strcpy(pSchema[cols].name, "days"); pSchema[cols].bytes = pShow->bytes[cols]; cols++; @@ -1444,7 +1444,7 @@ static void dumpDbInfoToPayload(char *data, SDbObj *pDb, SShowObj *pShow, int32_ cols++; pWrite = getDataPosition(data, pShow, cols, rows, rowCapacity); - *(int16_t *)pWrite = pDb->cfg.daysPerFile; + *(int32_t *)pWrite = pDb->cfg.daysPerFile; cols++; pWrite = getDataPosition(data, pShow, cols, rows, rowCapacity); diff --git a/source/dnode/mnode/impl/src/mndInfoSchema.c b/source/dnode/mnode/impl/src/mndInfoSchema.c index ce08dfaaa3..92b854157b 100644 --- a/source/dnode/mnode/impl/src/mndInfoSchema.c +++ b/source/dnode/mnode/impl/src/mndInfoSchema.c @@ -53,7 +53,7 @@ static const SInfosTableSchema userDBSchema[] = { {.name = "ntables", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT}, {.name = "replica", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT}, {.name = "quorum", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT}, - {.name = "days", .bytes = 2, .type = TSDB_DATA_TYPE_SMALLINT}, + {.name = "days", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "keep", .bytes = 24 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}, {.name = "cache", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "blocks", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, @@ -89,7 +89,6 @@ static const SInfosTableSchema userStbsSchema[] = { {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, {.name = "columns", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "tags", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, - {.name = "tables", .bytes = 4, .type = TSDB_DATA_TYPE_INT}, {.name = "last_update", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP}, {.name = "table_comment", .bytes = 1024 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_INT}, }; diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index 02e09252f9..196767462e 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -1652,10 +1652,6 @@ static int32_t mndRetrieveStb(SNodeMsg *pReq, SShowObj *pShow, char *data, int32 *(int32_t *)pWrite = pStb->numOfTags; cols++; - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; - *(int32_t *)pWrite = 0; // number of tables - cols++; - pWrite = data + pShow->offset[cols] * rows + pShow->bytes[cols] * numOfRows; *(int64_t *)pWrite = pStb->updateTime; // number of tables cols++; diff --git a/source/dnode/mnode/impl/test/sma/sma.cpp b/source/dnode/mnode/impl/test/sma/sma.cpp index 85f6a86183..4b0e33a323 100644 --- a/source/dnode/mnode/impl/test/sma/sma.cpp +++ b/source/dnode/mnode/impl/test/sma/sma.cpp @@ -42,10 +42,10 @@ void* MndTestSma::BuildCreateDbReq(const char* dbname, int32_t* pContLen) { createReq.numOfVgroups = 2; createReq.cacheBlockSize = 16; createReq.totalBlocks = 10; - createReq.daysPerFile = 10; - createReq.daysToKeep0 = 3650; - createReq.daysToKeep1 = 3650; - createReq.daysToKeep2 = 3650; + createReq.daysPerFile = 10 * 1440; + createReq.daysToKeep0 = 3650 * 1440; + createReq.daysToKeep1 = 3650 * 1440; + createReq.daysToKeep2 = 3650 * 1440; createReq.minRows = 100; createReq.maxRows = 4096; createReq.commitTime = 3600; diff --git a/source/dnode/mnode/impl/test/topic/topic.cpp b/source/dnode/mnode/impl/test/topic/topic.cpp index 73eefd875d..5d603ab5b2 100644 --- a/source/dnode/mnode/impl/test/topic/topic.cpp +++ b/source/dnode/mnode/impl/test/topic/topic.cpp @@ -35,10 +35,10 @@ void* MndTestTopic::BuildCreateDbReq(const char* dbname, int32_t* pContLen) { createReq.numOfVgroups = 2; createReq.cacheBlockSize = 16; createReq.totalBlocks = 10; - createReq.daysPerFile = 10; - createReq.daysToKeep0 = 3650; - createReq.daysToKeep1 = 3650; - createReq.daysToKeep2 = 3650; + createReq.daysPerFile = 10 * 1440; + createReq.daysToKeep0 = 3650 * 1440; + createReq.daysToKeep1 = 3650 * 1440; + createReq.daysToKeep2 = 3650 * 1440; createReq.minRows = 100; createReq.maxRows = 4096; createReq.commitTime = 3600; diff --git a/source/dnode/mnode/impl/test/user/user.cpp b/source/dnode/mnode/impl/test/user/user.cpp index 61b99beeb7..97a144fdee 100644 --- a/source/dnode/mnode/impl/test/user/user.cpp +++ b/source/dnode/mnode/impl/test/user/user.cpp @@ -324,10 +324,10 @@ TEST_F(MndTestUser, 03_Alter_User) { createReq.numOfVgroups = 2; createReq.cacheBlockSize = 16; createReq.totalBlocks = 10; - createReq.daysPerFile = 10; - createReq.daysToKeep0 = 3650; - createReq.daysToKeep1 = 3650; - createReq.daysToKeep2 = 3650; + createReq.daysPerFile = 10 * 1440; + createReq.daysToKeep0 = 3650 * 1440; + createReq.daysToKeep1 = 3650 * 1440; + createReq.daysToKeep2 = 3650 * 1440; createReq.minRows = 100; createReq.maxRows = 4096; createReq.commitTime = 3600; diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index 9bd5c1c016..09f51dc03e 100644 --- a/source/libs/catalog/inc/catalogInt.h +++ b/source/libs/catalog/inc/catalogInt.h @@ -112,7 +112,14 @@ typedef struct SCtgRuntimeStat { } SCtgRuntimeStat; typedef struct SCtgCacheStat { - + uint64_t clusterNum; + uint64_t dbNum; + uint64_t tblNum; + uint64_t stblNum; + uint64_t vgHitNum; + uint64_t vgMissNum; + uint64_t tblHitNum; + uint64_t tblMissNum; } SCtgCacheStat; typedef struct SCatalogStat { @@ -186,7 +193,7 @@ typedef struct SCatalogMgmt { bool exit; SRWLatch lock; SCtgQueue queue; - TdThread updateThread; + TdThread updateThread; SHashObj *pCluster; //key: clusterId, value: SCatalog* SCatalogStat stat; SCatalogCfg cfg; @@ -204,8 +211,13 @@ typedef struct SCtgAction { #define CTG_QUEUE_ADD() atomic_add_fetch_64(&gCtgMgmt.queue.qRemainNum, 1) #define CTG_QUEUE_SUB() atomic_sub_fetch_64(&gCtgMgmt.queue.qRemainNum, 1) -#define CTG_STAT_ADD(n) atomic_add_fetch_64(&(n), 1) -#define CTG_STAT_SUB(n) atomic_sub_fetch_64(&(n), 1) +#define CTG_STAT_ADD(_item, _n) atomic_add_fetch_64(&(_item), _n) +#define CTG_STAT_SUB(_item, _n) atomic_sub_fetch_64(&(_item), _n) +#define CTG_STAT_GET(_item) atomic_load_64(&(_item)) + +#define CTG_RUNTIME_STAT_ADD(item, n) (CTG_STAT_ADD(gCtgMgmt.stat.runtime.item, n)) +#define CTG_CACHE_STAT_ADD(item, n) (CTG_STAT_ADD(gCtgMgmt.stat.cache.item, n)) +#define CTG_CACHE_STAT_SUB(item, n) (CTG_STAT_SUB(gCtgMgmt.stat.cache.item, n)) #define CTG_IS_META_NULL(type) ((type) == META_TYPE_NULL_TABLE) #define CTG_IS_META_CTABLE(type) ((type) == META_TYPE_CTABLE) @@ -291,6 +303,9 @@ typedef struct SCtgAction { #define CTG_API_ENTER() do { CTG_API_DEBUG("CTG API enter %s", __FUNCTION__); CTG_LOCK(CTG_READ, &gCtgMgmt.lock); if (atomic_load_8((int8_t*)&gCtgMgmt.exit)) { CTG_API_LEAVE(TSDB_CODE_CTG_OUT_OF_SERVICE); } } while (0) +extern void ctgdShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p); +extern void ctgdShowClusterCache(SCatalog* pCtg); +extern int32_t ctgdShowCacheInfo(void); #ifdef __cplusplus } diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index a3019d8d56..e1f5332899 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -24,8 +24,8 @@ int32_t ctgActRemoveDB(SCtgMetaAction *action); int32_t ctgActRemoveStb(SCtgMetaAction *action); int32_t ctgActRemoveTbl(SCtgMetaAction *action); +extern SCtgDebug gCTGDebug; SCatalogMgmt gCtgMgmt = {0}; -SCtgDebug gCTGDebug = {0}; SCtgAction gCtgAction[CTG_ACT_MAX] = {{ CTG_ACT_UPDATE_VG, "update vgInfo", @@ -53,182 +53,6 @@ SCtgAction gCtgAction[CTG_ACT_MAX] = {{ } }; -int32_t ctgDbgEnableDebug(char *option) { - if (0 == strcasecmp(option, "lock")) { - gCTGDebug.lockEnable = true; - qDebug("lock debug enabled"); - return TSDB_CODE_SUCCESS; - } - - if (0 == strcasecmp(option, "cache")) { - gCTGDebug.cacheEnable = true; - qDebug("cache debug enabled"); - return TSDB_CODE_SUCCESS; - } - - if (0 == strcasecmp(option, "api")) { - gCTGDebug.apiEnable = true; - qDebug("api debug enabled"); - return TSDB_CODE_SUCCESS; - } - - if (0 == strcasecmp(option, "meta")) { - gCTGDebug.metaEnable = true; - qDebug("api debug enabled"); - return TSDB_CODE_SUCCESS; - } - - qError("invalid debug option:%s", option); - - return TSDB_CODE_CTG_INTERNAL_ERROR; -} - -int32_t ctgDbgGetStatNum(char *option, void *res) { - if (0 == strcasecmp(option, "runtime.qDoneNum")) { - *(uint64_t *)res = atomic_load_64(&gCtgMgmt.stat.runtime.qDoneNum); - return TSDB_CODE_SUCCESS; - } - - qError("invalid stat option:%s", option); - - return TSDB_CODE_CTG_INTERNAL_ERROR; -} - -int32_t ctgDbgGetTbMetaNum(SCtgDBCache *dbCache) { - return dbCache->tbCache.metaCache ? (int32_t)taosHashGetSize(dbCache->tbCache.metaCache) : 0; -} - -int32_t ctgDbgGetStbNum(SCtgDBCache *dbCache) { - return dbCache->tbCache.stbCache ? (int32_t)taosHashGetSize(dbCache->tbCache.stbCache) : 0; -} - -int32_t ctgDbgGetRentNum(SCtgRentMgmt *rent) { - int32_t num = 0; - for (uint16_t i = 0; i < rent->slotNum; ++i) { - SCtgRentSlot *slot = &rent->slots[i]; - if (NULL == slot->meta) { - continue; - } - - num += taosArrayGetSize(slot->meta); - } - - return num; -} - -int32_t ctgDbgGetClusterCacheNum(SCatalog* pCtg, int32_t type) { - if (NULL == pCtg || NULL == pCtg->dbCache) { - return 0; - } - - switch (type) { - case CTG_DBG_DB_NUM: - return (int32_t)taosHashGetSize(pCtg->dbCache); - case CTG_DBG_DB_RENT_NUM: - return ctgDbgGetRentNum(&pCtg->dbRent); - case CTG_DBG_STB_RENT_NUM: - return ctgDbgGetRentNum(&pCtg->stbRent); - default: - break; - } - - SCtgDBCache *dbCache = NULL; - int32_t num = 0; - void *pIter = taosHashIterate(pCtg->dbCache, NULL); - while (pIter) { - dbCache = (SCtgDBCache *)pIter; - switch (type) { - case CTG_DBG_META_NUM: - num += ctgDbgGetTbMetaNum(dbCache); - break; - case CTG_DBG_STB_NUM: - num += ctgDbgGetStbNum(dbCache); - break; - default: - ctgError("invalid type:%d", type); - break; - } - pIter = taosHashIterate(pCtg->dbCache, pIter); - } - - return num; -} - -void ctgDbgShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p) { - if (!gCTGDebug.metaEnable) { - return; - } - - STableComInfo *c = &p->tableInfo; - - if (TSDB_CHILD_TABLE == p->tableType) { - ctgDebug("table [%s] meta: type:%d, vgId:%d, uid:%" PRIx64 ",suid:%" PRIx64, tbName, p->tableType, p->vgId, p->uid, p->suid); - return; - } else { - ctgDebug("table [%s] meta: type:%d, vgId:%d, uid:%" PRIx64 ",suid:%" PRIx64 ",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d", - tbName, p->tableType, p->vgId, p->uid, p->suid, p->sversion, p->tversion, c->numOfTags, c->precision, c->numOfColumns, c->rowSize); - } - - int32_t colNum = c->numOfColumns + c->numOfTags; - for (int32_t i = 0; i < colNum; ++i) { - SSchema *s = &p->schema[i]; - ctgDebug("[%d] name:%s, type:%d, colId:%" PRIi16 ", bytes:%d", i, s->name, s->type, s->colId, s->bytes); - } -} - -void ctgDbgShowDBCache(SCatalog* pCtg, SHashObj *dbHash) { - if (NULL == dbHash || !gCTGDebug.cacheEnable) { - return; - } - - int32_t i = 0; - SCtgDBCache *dbCache = NULL; - void *pIter = taosHashIterate(dbHash, NULL); - while (pIter) { - char *dbFName = NULL; - size_t len = 0; - - dbCache = (SCtgDBCache *)pIter; - - dbFName = taosHashGetKey(pIter, &len); - - int32_t metaNum = dbCache->tbCache.metaCache ? taosHashGetSize(dbCache->tbCache.metaCache) : 0; - int32_t stbNum = dbCache->tbCache.stbCache ? taosHashGetSize(dbCache->tbCache.stbCache) : 0; - int32_t vgVersion = CTG_DEFAULT_INVALID_VERSION; - int32_t hashMethod = -1; - int32_t vgNum = 0; - - if (dbCache->vgInfo) { - vgVersion = dbCache->vgInfo->vgVersion; - hashMethod = dbCache->vgInfo->hashMethod; - if (dbCache->vgInfo->vgHash) { - vgNum = taosHashGetSize(dbCache->vgInfo->vgHash); - } - } - - ctgDebug("[%d] db [%.*s][%"PRIx64"] %s: metaNum:%d, stbNum:%d, vgVersion:%d, hashMethod:%d, vgNum:%d", - i, (int32_t)len, dbFName, dbCache->dbId, dbCache->deleted?"deleted":"", metaNum, stbNum, vgVersion, hashMethod, vgNum); - - pIter = taosHashIterate(dbHash, pIter); - } -} - - - - -void ctgDbgShowClusterCache(SCatalog* pCtg) { - if (!gCTGDebug.cacheEnable || NULL == pCtg) { - return; - } - - ctgDebug("## cluster %"PRIx64" %p cache Info ##", pCtg->clusterId, pCtg); - ctgDebug("db:%d meta:%d stb:%d dbRent:%d stbRent:%d", ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM), ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM), - ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_STB_NUM), ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_DB_RENT_NUM), ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_STB_RENT_NUM)); - - ctgDbgShowDBCache(pCtg, pCtg->dbCache); -} - - void ctgFreeMetaRent(SCtgRentMgmt *mgmt) { if (NULL == mgmt->slots) { return; @@ -249,15 +73,19 @@ void ctgFreeMetaRent(SCtgRentMgmt *mgmt) { void ctgFreeTableMetaCache(SCtgTbMetaCache *cache) { CTG_LOCK(CTG_WRITE, &cache->stbLock); if (cache->stbCache) { + int32_t stblNum = taosHashGetSize(cache->stbCache); taosHashCleanup(cache->stbCache); cache->stbCache = NULL; + CTG_CACHE_STAT_SUB(stblNum, stblNum); } CTG_UNLOCK(CTG_WRITE, &cache->stbLock); CTG_LOCK(CTG_WRITE, &cache->metaLock); if (cache->metaCache) { + int32_t tblNum = taosHashGetSize(cache->metaCache); taosHashCleanup(cache->metaCache); cache->metaCache = NULL; + CTG_CACHE_STAT_SUB(tblNum, tblNum); } CTG_UNLOCK(CTG_WRITE, &cache->metaLock); } @@ -293,6 +121,8 @@ void ctgFreeHandle(SCatalog* pCtg) { ctgFreeMetaRent(&pCtg->stbRent); if (pCtg->dbCache) { + int32_t dbNum = taosHashGetSize(pCtg->dbCache); + void *pIter = taosHashIterate(pCtg->dbCache, NULL); while (pIter) { SCtgDBCache *dbCache = pIter; @@ -305,6 +135,8 @@ void ctgFreeHandle(SCatalog* pCtg) { } taosHashCleanup(pCtg->dbCache); + + CTG_CACHE_STAT_SUB(dbNum, dbNum); } taosMemoryFree(pCtg); @@ -361,7 +193,7 @@ int32_t ctgPushAction(SCatalog* pCtg, SCtgMetaAction *action) { CTG_UNLOCK(CTG_WRITE, &gCtgMgmt.queue.qlock); CTG_QUEUE_ADD(); - CTG_STAT_ADD(gCtgMgmt.stat.runtime.qNum); + CTG_RUNTIME_STAT_ADD(qNum, 1); tsem_post(&gCtgMgmt.queue.reqSem); @@ -620,34 +452,45 @@ int32_t ctgGetDBCache(SCatalog* pCtg, const char *dbFName, SCtgDBCache **pCache) int32_t ctgAcquireVgInfoFromCache(SCatalog* pCtg, const char *dbFName, SCtgDBCache **pCache, bool *inCache) { + SCtgDBCache *dbCache = NULL; + if (NULL == pCtg->dbCache) { - *pCache = NULL; - *inCache = false; - ctgWarn("empty db cache, dbFName:%s", dbFName); - return TSDB_CODE_SUCCESS; + ctgDebug("empty db cache, dbFName:%s", dbFName); + goto _return; } - SCtgDBCache *dbCache = NULL; ctgAcquireDBCache(pCtg, dbFName, &dbCache); if (NULL == dbCache) { - *pCache = NULL; - *inCache = false; - return TSDB_CODE_SUCCESS; + ctgDebug("db %s not in cache", dbFName); + goto _return; } ctgAcquireVgInfo(pCtg, dbCache, inCache); if (!(*inCache)) { - ctgReleaseDBCache(pCtg, dbCache); - - *pCache = NULL; - return TSDB_CODE_SUCCESS; + ctgDebug("vgInfo of db %s not in cache", dbFName); + goto _return; } *pCache = dbCache; *inCache = true; + CTG_CACHE_STAT_ADD(vgHitNum, 1); + ctgDebug("Got db vgInfo from cache, dbFName:%s", dbFName); + return TSDB_CODE_SUCCESS; + +_return: + + if (dbCache) { + ctgReleaseDBCache(pCtg, dbCache); + } + + *pCache = NULL; + *inCache = false; + + CTG_CACHE_STAT_ADD(vgMissNum, 1); + return TSDB_CODE_SUCCESS; } @@ -763,11 +606,10 @@ int32_t ctgIsTableMetaExistInCache(SCatalog* pCtg, char *dbFName, char* tbName, } -int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STableMeta** pTableMeta, int32_t *exist, int32_t flag, uint64_t *dbId) { +int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STableMeta** pTableMeta, bool *inCache, int32_t flag, uint64_t *dbId) { if (NULL == pCtg->dbCache) { - *exist = 0; - ctgWarn("empty tbmeta cache, tbName:%s", pTableName->tname); - return TSDB_CODE_SUCCESS; + ctgDebug("empty tbmeta cache, tbName:%s", pTableName->tname); + goto _return; } char dbFName[TSDB_DB_FNAME_LEN] = {0}; @@ -782,8 +624,8 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable SCtgDBCache *dbCache = NULL; ctgAcquireDBCache(pCtg, dbFName, &dbCache); if (NULL == dbCache) { - *exist = 0; - return TSDB_CODE_SUCCESS; + ctgDebug("db %s not in cache", pTableName->tname); + goto _return; } int32_t sz = 0; @@ -792,13 +634,11 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable CTG_UNLOCK(CTG_READ, &dbCache->tbCache.metaLock); if (NULL == *pTableMeta) { - *exist = 0; ctgReleaseDBCache(pCtg, dbCache); ctgDebug("tbl not in cache, dbFName:%s, tbName:%s", dbFName, pTableName->tname); - return TSDB_CODE_SUCCESS; + goto _return; } - *exist = 1; if (dbId) { *dbId = dbCache->dbId; } @@ -808,6 +648,10 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable if (tbMeta->tableType != TSDB_CHILD_TABLE) { ctgReleaseDBCache(pCtg, dbCache); ctgDebug("Got meta from cache, type:%d, dbFName:%s, tbName:%s", tbMeta->tableType, dbFName, pTableName->tname); + + *inCache = true; + CTG_CACHE_STAT_ADD(tblHitNum, 1); + return TSDB_CODE_SUCCESS; } @@ -819,8 +663,7 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable ctgReleaseDBCache(pCtg, dbCache); ctgError("stb not in stbCache, suid:%"PRIx64, tbMeta->suid); taosMemoryFreeClear(*pTableMeta); - *exist = 0; - return TSDB_CODE_SUCCESS; + goto _return; } if ((*stbMeta)->suid != tbMeta->suid) { @@ -846,8 +689,18 @@ int32_t ctgGetTableMetaFromCache(SCatalog* pCtg, const SName* pTableName, STable ctgReleaseDBCache(pCtg, dbCache); + *inCache = true; + CTG_CACHE_STAT_ADD(tblHitNum, 1); + ctgDebug("Got tbmeta from cache, dbFName:%s, tbName:%s", dbFName, pTableName->tname); + return TSDB_CODE_SUCCESS; + +_return: + + *inCache = false; + CTG_CACHE_STAT_ADD(tblMissNum, 1); + return TSDB_CODE_SUCCESS; } @@ -1377,6 +1230,8 @@ int32_t ctgAddNewDBCache(SCatalog *pCtg, const char *dbFName, uint64_t dbId) { ctgError("taosHashPut db to cache failed, dbFName:%s", dbFName); CTG_ERR_JRET(TSDB_CODE_CTG_MEM_ERROR); } + + CTG_CACHE_STAT_ADD(dbNum, 1); SDbVgVersion vgVersion = {.dbId = newDBCache.dbId, .vgVersion = -1}; strncpy(vgVersion.dbFName, dbFName, sizeof(vgVersion.dbFName)); @@ -1436,6 +1291,8 @@ int32_t ctgRemoveDB(SCatalog* pCtg, SCtgDBCache *dbCache, const char* dbFName) { CTG_ERR_RET(TSDB_CODE_CTG_DB_DROPPED); } + CTG_CACHE_STAT_SUB(dbNum, 1); + ctgInfo("db removed from cache, dbFName:%s, dbId:%"PRIx64, dbFName, dbId); return TSDB_CODE_SUCCESS; @@ -1568,6 +1425,8 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui CTG_LOCK(CTG_WRITE, &tbCache->stbLock); if (taosHashRemove(tbCache->stbCache, &orig->suid, sizeof(orig->suid))) { ctgError("stb not exist in stbCache, dbFName:%s, stb:%s, suid:%"PRIx64, dbFName, tbName, orig->suid); + } else { + CTG_CACHE_STAT_SUB(stblNum, 1); } CTG_UNLOCK(CTG_WRITE, &tbCache->stbLock); @@ -1594,8 +1453,12 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR); } + if (NULL == orig) { + CTG_CACHE_STAT_ADD(tblNum, 1); + } + ctgDebug("tbmeta updated to cache, dbFName:%s, tbName:%s, tbType:%d", dbFName, tbName, meta->tableType); - ctgDbgShowTableMeta(pCtg, tbName, meta); + ctgdShowTableMeta(pCtg, tbName, meta); if (!isStb) { CTG_UNLOCK(CTG_READ, &tbCache->metaLock); @@ -1615,6 +1478,8 @@ int32_t ctgUpdateTblMeta(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, ui ctgError("taosHashPut stable to stable cache failed, suid:%"PRIx64, meta->suid); CTG_ERR_RET(TSDB_CODE_CTG_MEM_ERROR); } + + CTG_CACHE_STAT_ADD(stblNum, 1); CTG_UNLOCK(CTG_WRITE, &tbCache->stbLock); @@ -1874,7 +1739,7 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons CTG_ERR_RET(TSDB_CODE_CTG_INVALID_INPUT); } - int32_t exist = 0; + bool inCache = false; int32_t code = 0; uint64_t dbId = 0; uint64_t suid = 0; @@ -1884,11 +1749,11 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons CTG_FLAG_SET_INF_DB(flag); } - CTG_ERR_RET(ctgGetTableMetaFromCache(pCtg, pTableName, pTableMeta, &exist, flag, &dbId)); + CTG_ERR_RET(ctgGetTableMetaFromCache(pCtg, pTableName, pTableMeta, &inCache, flag, &dbId)); int32_t tbType = 0; - if (exist) { + if (inCache) { if (CTG_FLAG_MATCH_STB(flag, (*pTableMeta)->tableType) && ((!CTG_FLAG_IS_FORCE_UPDATE(flag)) || (CTG_FLAG_IS_INF_DB(flag)))) { goto _return; } @@ -1930,8 +1795,8 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons SName stbName = *pTableName; strcpy(stbName.tname, output->tbName); - CTG_ERR_JRET(ctgGetTableMetaFromCache(pCtg, &stbName, pTableMeta, &exist, flag, NULL)); - if (0 == exist) { + CTG_ERR_JRET(ctgGetTableMetaFromCache(pCtg, &stbName, pTableMeta, &inCache, flag, NULL)); + if (!inCache) { ctgDebug("stb no longer exist, dbFName:%s, tbName:%s", output->dbFName, pTableName->tname); continue; } @@ -1943,7 +1808,7 @@ int32_t ctgGetTableMeta(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, cons _return: - if (CTG_TABLE_NOT_EXIST(code) && exist) { + if (CTG_TABLE_NOT_EXIST(code) && inCache) { char dbFName[TSDB_DB_FNAME_LEN] = {0}; if (CTG_FLAG_IS_INF_DB(flag)) { strcpy(dbFName, pTableName->dbname); @@ -1962,7 +1827,7 @@ _return: if (*pTableMeta) { ctgDebug("tbmeta returned, tbName:%s, tbType:%d", pTableName->tname, (*pTableMeta)->tableType); - ctgDbgShowTableMeta(pCtg, pTableName->tname, *pTableMeta); + ctgdShowTableMeta(pCtg, pTableName->tname, *pTableMeta); } CTG_RET(code); @@ -2075,12 +1940,16 @@ int32_t ctgActRemoveStb(SCtgMetaAction *action) { CTG_LOCK(CTG_WRITE, &dbCache->tbCache.stbLock); if (taosHashRemove(dbCache->tbCache.stbCache, &msg->suid, sizeof(msg->suid))) { ctgDebug("stb not exist in stbCache, may be removed, dbFName:%s, stb:%s, suid:%"PRIx64, msg->dbFName, msg->stbName, msg->suid); + } else { + CTG_CACHE_STAT_SUB(stblNum, 1); } CTG_LOCK(CTG_READ, &dbCache->tbCache.metaLock); if (taosHashRemove(dbCache->tbCache.metaCache, msg->stbName, strlen(msg->stbName))) { ctgError("stb not exist in cache, dbFName:%s, stb:%s, suid:%"PRIx64, msg->dbFName, msg->stbName, msg->suid); - } + } else { + CTG_CACHE_STAT_SUB(tblNum, 1); + } CTG_UNLOCK(CTG_READ, &dbCache->tbCache.metaLock); CTG_UNLOCK(CTG_WRITE, &dbCache->tbCache.stbLock); @@ -2119,6 +1988,8 @@ int32_t ctgActRemoveTbl(SCtgMetaAction *action) { CTG_UNLOCK(CTG_READ, &dbCache->tbCache.metaLock); ctgError("stb not exist in cache, dbFName:%s, tbName:%s", msg->dbFName, msg->tbName); CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR); + } else { + CTG_CACHE_STAT_SUB(tblNum, 1); } CTG_UNLOCK(CTG_READ, &dbCache->tbCache.metaLock); @@ -2140,7 +2011,9 @@ void* ctgUpdateThreadFunc(void* param) { CTG_LOCK(CTG_READ, &gCtgMgmt.lock); while (true) { - tsem_wait(&gCtgMgmt.queue.reqSem); + if (tsem_wait(&gCtgMgmt.queue.reqSem)) { + qError("ctg tsem_wait failed, error:%s", tstrerror(TAOS_SYSTEM_ERROR(errno))); + } if (atomic_load_8((int8_t*)&gCtgMgmt.exit)) { tsem_post(&gCtgMgmt.queue.rspSem); @@ -2161,9 +2034,9 @@ void* ctgUpdateThreadFunc(void* param) { tsem_post(&gCtgMgmt.queue.rspSem); } - CTG_STAT_ADD(gCtgMgmt.stat.runtime.qDoneNum); + CTG_RUNTIME_STAT_ADD(qDoneNum, 1); - ctgDbgShowClusterCache(pCtg); + ctgdShowClusterCache(pCtg); } CTG_UNLOCK(CTG_READ, &gCtgMgmt.lock); @@ -2304,8 +2177,15 @@ int32_t catalogInit(SCatalogCfg *cfg) { CTG_ERR_RET(TSDB_CODE_CTG_INTERNAL_ERROR); } - tsem_init(&gCtgMgmt.queue.reqSem, 0, 0); - tsem_init(&gCtgMgmt.queue.rspSem, 0, 0); + if (tsem_init(&gCtgMgmt.queue.reqSem, 0, 0)) { + qError("tsem_init failed, error:%s", tstrerror(TAOS_SYSTEM_ERROR(errno))); + CTG_ERR_RET(TSDB_CODE_CTG_SYS_ERROR); + } + + if (tsem_init(&gCtgMgmt.queue.rspSem, 0, 0)) { + qError("tsem_init failed, error:%s", tstrerror(TAOS_SYSTEM_ERROR(errno))); + CTG_ERR_RET(TSDB_CODE_CTG_SYS_ERROR); + } gCtgMgmt.queue.head = taosMemoryCalloc(1, sizeof(SCtgQNode)); if (NULL == gCtgMgmt.queue.head) { @@ -2383,6 +2263,8 @@ int32_t catalogGetHandle(uint64_t clusterId, SCatalog** catalogHandle) { } *catalogHandle = clusterCtg; + + CTG_CACHE_STAT_ADD(clusterNum, 1); return TSDB_CODE_SUCCESS; @@ -2403,10 +2285,12 @@ void catalogFreeHandle(SCatalog* pCtg) { return; } + CTG_CACHE_STAT_SUB(clusterNum, 1); + uint64_t clusterId = pCtg->clusterId; ctgFreeHandle(pCtg); - + ctgInfo("handle freed, culsterId:%"PRIx64, clusterId); } @@ -2417,24 +2301,12 @@ int32_t catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* vers CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); } - if (NULL == pCtg->dbCache) { - *version = CTG_DEFAULT_INVALID_VERSION; - ctgInfo("empty db cache, dbFName:%s", dbFName); - CTG_API_LEAVE(TSDB_CODE_SUCCESS); - } - SCtgDBCache *dbCache = NULL; - ctgAcquireDBCache(pCtg, dbFName, &dbCache); - if (NULL == dbCache) { - *version = CTG_DEFAULT_INVALID_VERSION; - CTG_API_LEAVE(TSDB_CODE_SUCCESS); - } - bool inCache = false; - ctgAcquireVgInfo(pCtg, dbCache, &inCache); - if (!inCache) { - ctgReleaseDBCache(pCtg, dbCache); + int32_t code = 0; + CTG_ERR_JRET(ctgAcquireVgInfoFromCache(pCtg, dbFName, &dbCache, &inCache)); + if (!inCache) { *version = CTG_DEFAULT_INVALID_VERSION; CTG_API_LEAVE(TSDB_CODE_SUCCESS); } @@ -2449,6 +2321,10 @@ int32_t catalogGetDBVgVersion(SCatalog* pCtg, const char* dbFName, int32_t* vers ctgDebug("Got db vgVersion from cache, dbFName:%s, vgVersion:%d", dbFName, *version); CTG_API_LEAVE(TSDB_CODE_SUCCESS); + +_return: + + CTG_API_LEAVE(code); } int32_t catalogGetDBVgInfo(SCatalog* pCtg, void *pRpc, const SEpSet* pMgmtEps, const char* dbFName, SArray** vgroupList) { @@ -2549,11 +2425,11 @@ int32_t catalogRemoveTableMeta(SCatalog* pCtg, const SName* pTableName) { } STableMeta *tblMeta = NULL; - int32_t exist = 0; + bool inCache = false; uint64_t dbId = 0; - CTG_ERR_JRET(ctgGetTableMetaFromCache(pCtg, pTableName, &tblMeta, &exist, 0, &dbId)); + CTG_ERR_JRET(ctgGetTableMetaFromCache(pCtg, pTableName, &tblMeta, &inCache, 0, &dbId)); - if (0 == exist) { + if (!inCache) { ctgDebug("table already not in cache, db:%s, tblName:%s", pTableName->dbname, pTableName->tname); goto _return; } @@ -2851,8 +2727,13 @@ void catalogDestroy(void) { atomic_store_8((int8_t*)&gCtgMgmt.exit, true); - tsem_post(&gCtgMgmt.queue.reqSem); - tsem_post(&gCtgMgmt.queue.rspSem); + if (tsem_post(&gCtgMgmt.queue.reqSem)) { + qError("tsem_post failed, error:%s", tstrerror(TAOS_SYSTEM_ERROR(errno))); + } + + if (tsem_post(&gCtgMgmt.queue.rspSem)) { + qError("tsem_post failed, error:%s", tstrerror(TAOS_SYSTEM_ERROR(errno))); + } while (CTG_IS_LOCKED(&gCtgMgmt.lock)) { taosUsleep(1); diff --git a/source/libs/catalog/src/catalogDbg.c b/source/libs/catalog/src/catalogDbg.c new file mode 100644 index 0000000000..1d4ad0082c --- /dev/null +++ b/source/libs/catalog/src/catalogDbg.c @@ -0,0 +1,222 @@ +/* + * 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 "trpc.h" +#include "query.h" +#include "tname.h" +#include "catalogInt.h" + +extern SCatalogMgmt gCtgMgmt; +SCtgDebug gCTGDebug = {0}; + +int32_t ctgdEnableDebug(char *option) { + if (0 == strcasecmp(option, "lock")) { + gCTGDebug.lockEnable = true; + qDebug("lock debug enabled"); + return TSDB_CODE_SUCCESS; + } + + if (0 == strcasecmp(option, "cache")) { + gCTGDebug.cacheEnable = true; + qDebug("cache debug enabled"); + return TSDB_CODE_SUCCESS; + } + + if (0 == strcasecmp(option, "api")) { + gCTGDebug.apiEnable = true; + qDebug("api debug enabled"); + return TSDB_CODE_SUCCESS; + } + + if (0 == strcasecmp(option, "meta")) { + gCTGDebug.metaEnable = true; + qDebug("api debug enabled"); + return TSDB_CODE_SUCCESS; + } + + qError("invalid debug option:%s", option); + + return TSDB_CODE_CTG_INTERNAL_ERROR; +} + +int32_t ctgdGetStatNum(char *option, void *res) { + if (0 == strcasecmp(option, "runtime.qDoneNum")) { + *(uint64_t *)res = atomic_load_64(&gCtgMgmt.stat.runtime.qDoneNum); + return TSDB_CODE_SUCCESS; + } + + qError("invalid stat option:%s", option); + + return TSDB_CODE_CTG_INTERNAL_ERROR; +} + +int32_t ctgdGetTbMetaNum(SCtgDBCache *dbCache) { + return dbCache->tbCache.metaCache ? (int32_t)taosHashGetSize(dbCache->tbCache.metaCache) : 0; +} + +int32_t ctgdGetStbNum(SCtgDBCache *dbCache) { + return dbCache->tbCache.stbCache ? (int32_t)taosHashGetSize(dbCache->tbCache.stbCache) : 0; +} + +int32_t ctgdGetRentNum(SCtgRentMgmt *rent) { + int32_t num = 0; + for (uint16_t i = 0; i < rent->slotNum; ++i) { + SCtgRentSlot *slot = &rent->slots[i]; + if (NULL == slot->meta) { + continue; + } + + num += taosArrayGetSize(slot->meta); + } + + return num; +} + +int32_t ctgdGetClusterCacheNum(SCatalog* pCtg, int32_t type) { + if (NULL == pCtg || NULL == pCtg->dbCache) { + return 0; + } + + switch (type) { + case CTG_DBG_DB_NUM: + return (int32_t)taosHashGetSize(pCtg->dbCache); + case CTG_DBG_DB_RENT_NUM: + return ctgdGetRentNum(&pCtg->dbRent); + case CTG_DBG_STB_RENT_NUM: + return ctgdGetRentNum(&pCtg->stbRent); + default: + break; + } + + SCtgDBCache *dbCache = NULL; + int32_t num = 0; + void *pIter = taosHashIterate(pCtg->dbCache, NULL); + while (pIter) { + dbCache = (SCtgDBCache *)pIter; + switch (type) { + case CTG_DBG_META_NUM: + num += ctgdGetTbMetaNum(dbCache); + break; + case CTG_DBG_STB_NUM: + num += ctgdGetStbNum(dbCache); + break; + default: + ctgError("invalid type:%d", type); + break; + } + pIter = taosHashIterate(pCtg->dbCache, pIter); + } + + return num; +} + +void ctgdShowTableMeta(SCatalog* pCtg, const char *tbName, STableMeta* p) { + if (!gCTGDebug.metaEnable) { + return; + } + + STableComInfo *c = &p->tableInfo; + + if (TSDB_CHILD_TABLE == p->tableType) { + ctgDebug("table [%s] meta: type:%d, vgId:%d, uid:%" PRIx64 ",suid:%" PRIx64, tbName, p->tableType, p->vgId, p->uid, p->suid); + return; + } else { + ctgDebug("table [%s] meta: type:%d, vgId:%d, uid:%" PRIx64 ",suid:%" PRIx64 ",sv:%d, tv:%d, tagNum:%d, precision:%d, colNum:%d, rowSize:%d", + tbName, p->tableType, p->vgId, p->uid, p->suid, p->sversion, p->tversion, c->numOfTags, c->precision, c->numOfColumns, c->rowSize); + } + + int32_t colNum = c->numOfColumns + c->numOfTags; + for (int32_t i = 0; i < colNum; ++i) { + SSchema *s = &p->schema[i]; + ctgDebug("[%d] name:%s, type:%d, colId:%d, bytes:%d", i, s->name, s->type, s->colId, s->bytes); + } +} + +void ctgdShowDBCache(SCatalog* pCtg, SHashObj *dbHash) { + if (NULL == dbHash || !gCTGDebug.cacheEnable) { + return; + } + + int32_t i = 0; + SCtgDBCache *dbCache = NULL; + void *pIter = taosHashIterate(dbHash, NULL); + while (pIter) { + char *dbFName = NULL; + size_t len = 0; + + dbCache = (SCtgDBCache *)pIter; + + dbFName = taosHashGetKey(pIter, &len); + + int32_t metaNum = dbCache->tbCache.metaCache ? taosHashGetSize(dbCache->tbCache.metaCache) : 0; + int32_t stbNum = dbCache->tbCache.stbCache ? taosHashGetSize(dbCache->tbCache.stbCache) : 0; + int32_t vgVersion = CTG_DEFAULT_INVALID_VERSION; + int32_t hashMethod = -1; + int32_t vgNum = 0; + + if (dbCache->vgInfo) { + vgVersion = dbCache->vgInfo->vgVersion; + hashMethod = dbCache->vgInfo->hashMethod; + if (dbCache->vgInfo->vgHash) { + vgNum = taosHashGetSize(dbCache->vgInfo->vgHash); + } + } + + ctgDebug("[%d] db [%.*s][%"PRIx64"] %s: metaNum:%d, stbNum:%d, vgVersion:%d, hashMethod:%d, vgNum:%d", + i, (int32_t)len, dbFName, dbCache->dbId, dbCache->deleted?"deleted":"", metaNum, stbNum, vgVersion, hashMethod, vgNum); + + pIter = taosHashIterate(dbHash, pIter); + } +} + + + + +void ctgdShowClusterCache(SCatalog* pCtg) { + if (!gCTGDebug.cacheEnable || NULL == pCtg) { + return; + } + + ctgDebug("## cluster %"PRIx64" %p cache Info BEGIN ##", pCtg->clusterId, pCtg); + ctgDebug("db:%d meta:%d stb:%d dbRent:%d stbRent:%d", ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM), ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM), + ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_NUM), ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_RENT_NUM), ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_RENT_NUM)); + + ctgdShowDBCache(pCtg, pCtg->dbCache); + + ctgDebug("## cluster %"PRIx64" %p cache Info END ##", pCtg->clusterId, pCtg); +} + +int32_t ctgdShowCacheInfo(void) { + if (!gCTGDebug.cacheEnable) { + return TSDB_CODE_CTG_OUT_OF_SERVICE; + } + + CTG_API_ENTER(); + + SCatalog *pCtg = NULL; + void *pIter = taosHashIterate(gCtgMgmt.pCluster, NULL); + while (pIter) { + pCtg = *(SCatalog **)pIter; + + if (pCtg) { + ctgdShowClusterCache(pCtg); + } + + pIter = taosHashIterate(gCtgMgmt.pCluster, pIter); + } + + CTG_API_LEAVE(TSDB_CODE_SUCCESS); +} + diff --git a/source/libs/catalog/test/catalogTests.cpp b/source/libs/catalog/test/catalogTests.cpp index e62819b078..73d0dc2011 100644 --- a/source/libs/catalog/test/catalogTests.cpp +++ b/source/libs/catalog/test/catalogTests.cpp @@ -38,11 +38,11 @@ namespace { extern "C" int32_t ctgGetTableMetaFromCache(struct SCatalog *pCatalog, const SName *pTableName, STableMeta **pTableMeta, - int32_t *exist, int32_t flag, uint64_t *dbId); -extern "C" int32_t ctgDbgGetClusterCacheNum(struct SCatalog* pCatalog, int32_t type); + bool *inCache, int32_t flag, uint64_t *dbId); +extern "C" int32_t ctgdGetClusterCacheNum(struct SCatalog* pCatalog, int32_t type); extern "C" int32_t ctgActUpdateTbl(SCtgMetaAction *action); -extern "C" int32_t ctgDbgEnableDebug(char *option); -extern "C" int32_t ctgDbgGetStatNum(char *option, void *res); +extern "C" int32_t ctgdEnableDebug(char *option); +extern "C" int32_t ctgdGetStatNum(char *option, void *res); void ctgTestSetRspTableMeta(); void ctgTestSetRspCTableMeta(); @@ -140,9 +140,9 @@ void ctgTestInitLogFile() { qDebugFlag = 159; strcpy(tsLogDir, "/var/log/taos"); - ctgDbgEnableDebug("api"); - ctgDbgEnableDebug("meta"); - ctgDbgEnableDebug("cache"); + ctgdEnableDebug("api"); + ctgdEnableDebug("meta"); + ctgdEnableDebug("cache"); if (taosInitLog(defaultLogFileNamePrefix, maxLogFileNum) < 0) { printf("failed to open log file in directory:%s\n", tsLogDir); @@ -786,15 +786,15 @@ void *ctgTestGetCtableMetaThread(void *param) { int32_t code = 0; int32_t n = 0; STableMeta *tbMeta = NULL; - int32_t exist = 0; + bool inCache = false; SName cn = {.type = TSDB_TABLE_NAME_T, .acctId = 1}; strcpy(cn.dbname, "db1"); strcpy(cn.tname, ctgTestCTablename); while (!ctgTestStop) { - code = ctgGetTableMetaFromCache(pCtg, &cn, &tbMeta, &exist, 0, NULL); - if (code || 0 == exist) { + code = ctgGetTableMetaFromCache(pCtg, &cn, &tbMeta, &inCache, 0, NULL); + if (code || !inCache) { assert(0); } @@ -879,7 +879,7 @@ TEST(tableMeta, normalTable) { ASSERT_EQ(vgInfo.vgId, 8); ASSERT_EQ(vgInfo.epSet.numOfEps, 3); - while (0 == ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM)) { + while (0 == ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM)) { taosMsleep(50); } @@ -899,7 +899,7 @@ TEST(tableMeta, normalTable) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); while (true) { - uint32_t n = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); + uint32_t n = ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); if (0 == n) { taosMsleep(50); } else { @@ -994,7 +994,7 @@ TEST(tableMeta, childTableCase) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); while (true) { - uint32_t n = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); + uint32_t n = ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); if (0 == n) { taosMsleep(50); } else { @@ -1103,7 +1103,7 @@ TEST(tableMeta, superTableCase) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); while (true) { - uint32_t n = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); + uint32_t n = ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); if (0 == n) { taosMsleep(50); } else { @@ -1130,7 +1130,7 @@ TEST(tableMeta, superTableCase) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); while (true) { - uint32_t n = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); + uint32_t n = ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); if (2 != n) { taosMsleep(50); } else { @@ -1228,7 +1228,7 @@ TEST(tableMeta, rmStbMeta) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); while (true) { - uint32_t n = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); + uint32_t n = ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); if (0 == n) { taosMsleep(50); } else { @@ -1241,8 +1241,8 @@ TEST(tableMeta, rmStbMeta) { ASSERT_EQ(code, 0); while (true) { - int32_t n = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); - int32_t m = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_STB_RENT_NUM); + int32_t n = ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); + int32_t m = ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_RENT_NUM); if (n || m) { taosMsleep(50); } else { @@ -1251,11 +1251,11 @@ TEST(tableMeta, rmStbMeta) { } - ASSERT_EQ(ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM), 1); - ASSERT_EQ(ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM), 0); - ASSERT_EQ(ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_STB_NUM), 0); - ASSERT_EQ(ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_DB_RENT_NUM), 1); - ASSERT_EQ(ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_STB_RENT_NUM), 0); + ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM), 1); + ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM), 0); + ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_NUM), 0); + ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_RENT_NUM), 1); + ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_RENT_NUM), 0); catalogDestroy(); memset(&gCtgMgmt, 0, sizeof(gCtgMgmt)); @@ -1298,7 +1298,7 @@ TEST(tableMeta, updateStbMeta) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); while (true) { - uint32_t n = ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); + uint32_t n = ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM); if (0 == n) { taosMsleep(50); } else { @@ -1318,7 +1318,7 @@ TEST(tableMeta, updateStbMeta) { while (true) { uint64_t n = 0; - ctgDbgGetStatNum("runtime.qDoneNum", (void *)&n); + ctgdGetStatNum("runtime.qDoneNum", (void *)&n); if (n != 3) { taosMsleep(50); } else { @@ -1326,11 +1326,11 @@ TEST(tableMeta, updateStbMeta) { } } - ASSERT_EQ(ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM), 1); - ASSERT_EQ(ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM), 1); - ASSERT_EQ(ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_STB_NUM), 1); - ASSERT_EQ(ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_DB_RENT_NUM), 1); - ASSERT_EQ(ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_STB_RENT_NUM), 1); + ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_NUM), 1); + ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM), 1); + ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_NUM), 1); + ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_DB_RENT_NUM), 1); + ASSERT_EQ(ctgdGetClusterCacheNum(pCtg, CTG_DBG_STB_RENT_NUM), 1); code = catalogGetTableMeta(pCtg, mockPointer, (const SEpSet *)mockPointer, &n, &tableMeta); ASSERT_EQ(code, 0); @@ -1388,7 +1388,7 @@ TEST(refreshGetMeta, normal2normal) { while (true) { uint64_t n = 0; - ctgDbgGetStatNum("runtime.qDoneNum", (void *)&n); + ctgdGetStatNum("runtime.qDoneNum", (void *)&n); if (n > 0) { break; } @@ -1409,7 +1409,7 @@ TEST(refreshGetMeta, normal2normal) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); taosMemoryFreeClear(tableMeta); - while (0 == ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { + while (0 == ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { taosMsleep(50); } @@ -1467,7 +1467,7 @@ TEST(refreshGetMeta, normal2notexist) { while (true) { uint64_t n = 0; - ctgDbgGetStatNum("runtime.qDoneNum", (void *)&n); + ctgdGetStatNum("runtime.qDoneNum", (void *)&n); if (n > 0) { break; } @@ -1488,7 +1488,7 @@ TEST(refreshGetMeta, normal2notexist) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); taosMemoryFreeClear(tableMeta); - while (0 == ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { + while (0 == ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { taosMsleep(50); } @@ -1541,7 +1541,7 @@ TEST(refreshGetMeta, normal2child) { while (true) { uint64_t n = 0; - ctgDbgGetStatNum("runtime.qDoneNum", (void *)&n); + ctgdGetStatNum("runtime.qDoneNum", (void *)&n); if (n > 0) { break; } @@ -1562,7 +1562,7 @@ TEST(refreshGetMeta, normal2child) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); taosMemoryFreeClear(tableMeta); - while (0 == ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { + while (0 == ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { taosMsleep(50); } @@ -1625,7 +1625,7 @@ TEST(refreshGetMeta, stable2child) { while (true) { uint64_t n = 0; - ctgDbgGetStatNum("runtime.qDoneNum", (void *)&n); + ctgdGetStatNum("runtime.qDoneNum", (void *)&n); if (n > 0) { break; } @@ -1647,7 +1647,7 @@ TEST(refreshGetMeta, stable2child) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); taosMemoryFreeClear(tableMeta); - while (0 == ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { + while (0 == ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { taosMsleep(50); } @@ -1710,7 +1710,7 @@ TEST(refreshGetMeta, stable2stable) { while (true) { uint64_t n = 0; - ctgDbgGetStatNum("runtime.qDoneNum", (void *)&n); + ctgdGetStatNum("runtime.qDoneNum", (void *)&n); if (n > 0) { break; } @@ -1732,7 +1732,7 @@ TEST(refreshGetMeta, stable2stable) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); taosMemoryFreeClear(tableMeta); - while (0 == ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { + while (0 == ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { taosMsleep(50); } @@ -1798,7 +1798,7 @@ TEST(refreshGetMeta, child2stable) { while (true) { uint64_t n = 0; - ctgDbgGetStatNum("runtime.qDoneNum", (void *)&n); + ctgdGetStatNum("runtime.qDoneNum", (void *)&n); if (n > 0) { break; } @@ -1818,7 +1818,7 @@ TEST(refreshGetMeta, child2stable) { ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); taosMemoryFreeClear(tableMeta); - while (2 != ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { + while (2 != ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM)) { taosMsleep(50); } @@ -2015,7 +2015,7 @@ TEST(dbVgroup, getSetDbVgroupCase) { while (true) { uint64_t n = 0; - ctgDbgGetStatNum("runtime.qDoneNum", (void *)&n); + ctgdGetStatNum("runtime.qDoneNum", (void *)&n); if (n > 0) { break; } @@ -2041,7 +2041,7 @@ TEST(dbVgroup, getSetDbVgroupCase) { while (true) { uint64_t n = 0; - ctgDbgGetStatNum("runtime.qDoneNum", (void *)&n); + ctgdGetStatNum("runtime.qDoneNum", (void *)&n); if (n != 3) { taosMsleep(50); } else { @@ -2266,7 +2266,7 @@ TEST(rentTest, allRent) { ASSERT_EQ(tableMeta->tableInfo.precision, 1); ASSERT_EQ(tableMeta->tableInfo.rowSize, 12); - while (ctgDbgGetClusterCacheNum(pCtg, CTG_DBG_META_NUM) < i) { + while (ctgdGetClusterCacheNum(pCtg, CTG_DBG_META_NUM) < i) { taosMsleep(50); } diff --git a/source/libs/command/inc/commandInt.h b/source/libs/command/inc/commandInt.h new file mode 100644 index 0000000000..771baca2ab --- /dev/null +++ b/source/libs/command/inc/commandInt.h @@ -0,0 +1,99 @@ +/* + * 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 _TD_QUERY_INT_H_ +#define _TD_QUERY_INT_H_ + +#ifdef __cplusplus +extern "C" { +#endif +#include "nodes.h" +#include "plannodes.h" +#include "ttime.h" + +#define EXPLAIN_MAX_GROUP_NUM 100 + +//newline area +#define EXPLAIN_TAG_SCAN_FORMAT "Tag Scan on %s columns=%d width=%d" +#define EXPLAIN_TBL_SCAN_FORMAT "Table Scan on %s columns=%d width=%d" +#define EXPLAIN_SYSTBL_SCAN_FORMAT "System Table Scan on %s columns=%d width=%d" +#define EXPLAIN_PROJECTION_FORMAT "Projection columns=%d width=%d" +#define EXPLAIN_JOIN_FORMAT "%s between %d tables width=%d" +#define EXPLAIN_AGG_FORMAT "Aggragate functions=%d" +#define EXPLAIN_EXCHANGE_FORMAT "Data Exchange %d:1 width=%d" +#define EXPLAIN_SORT_FORMAT "Sort on %d Column(s) width=%d" +#define EXPLAIN_INTERVAL_FORMAT "Interval on Column %s functions=%d interval=%" PRId64 "%c offset=%" PRId64 "%c sliding=%" PRId64 "%c width=%d" +#define EXPLAIN_SESSION_FORMAT "Session gap=%" PRId64 " functions=%d width=%d" +#define EXPLAIN_ORDER_FORMAT "Order: %s" +#define EXPLAIN_FILTER_FORMAT "Filter: " +#define EXPLAIN_FILL_FORMAT "Fill: %s" +#define EXPLAIN_ON_CONDITIONS_FORMAT "Join Cond: " +#define EXPLAIN_TIMERANGE_FORMAT "Time Range: [%" PRId64 ", %" PRId64 "]" + +//append area +#define EXPLAIN_GROUPS_FORMAT " groups=%d" +#define EXPLAIN_WIDTH_FORMAT " width=%d" +#define EXPLAIN_LOOPS_FORMAT " loops=%d" +#define EXPLAIN_REVERSE_FORMAT " reverse=%d" + +typedef struct SExplainGroup { + int32_t nodeNum; + SSubplan *plan; + void *execInfo; //TODO +} SExplainGroup; + +typedef struct SExplainResNode { + SNodeList* pChildren; + SPhysiNode* pNode; + void* pExecInfo; +} SExplainResNode; + +typedef struct SQueryExplainRowInfo { + int32_t level; + int32_t len; + char *buf; +} SQueryExplainRowInfo; + +typedef struct SExplainCtx { + int32_t totalSize; + bool verbose; + char *tbuf; + SArray *rows; + SHashObj *groupHash; +} SExplainCtx; + +#define EXPLAIN_ORDER_STRING(_order) ((TSDB_ORDER_ASC == _order) ? "Ascending" : "Descending") +#define EXPLAIN_JOIN_STRING(_type) ((JOIN_TYPE_INNER == _type) ? "Inner join" : "Join") + +#define INVERAL_TIME_FROM_PRECISION_TO_UNIT(_t, _u, _p) (((_u) == 'n' || (_u) == 'y') ? (_t) : (convertTimeFromPrecisionToUnit(_t, _p, _u))) + +#define EXPLAIN_ROW_NEW(level, ...) \ + do { \ + if (isVerboseLine) { \ + tlen = snprintf(tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, "%*s", (level) * 2 + 3, ""); \ + } else { \ + tlen = snprintf(tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, "%*s%s", (level) * 2, "", "-> "); \ + } \ + tlen += snprintf(tbuf + VARSTR_HEADER_SIZE + tlen, TSDB_EXPLAIN_RESULT_ROW_SIZE - tlen, __VA_ARGS__); \ + } while (0) + +#define EXPLAIN_ROW_APPEND(...) tlen += snprintf(tbuf + VARSTR_HEADER_SIZE + tlen, TSDB_EXPLAIN_RESULT_ROW_SIZE - tlen, __VA_ARGS__) +#define EXPLAIN_ROW_END() do { varDataSetLen(tbuf, tlen); tlen += VARSTR_HEADER_SIZE; isVerboseLine = true; } while (0) + +#ifdef __cplusplus +} +#endif + +#endif /*_TD_QUERY_INT_H_*/ diff --git a/source/libs/command/src/explain.c b/source/libs/command/src/explain.c new file mode 100644 index 0000000000..847a863e76 --- /dev/null +++ b/source/libs/command/src/explain.c @@ -0,0 +1,687 @@ +/* + * 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 "query.h" +#include "plannodes.h" +#include "commandInt.h" + +int32_t qGenerateExplainResNode(SPhysiNode *pNode, void *pExecInfo, SExplainResNode **pRes); +int32_t qAppendTaskExplainResRows(void *pCtx, int32_t groupId, int32_t level); + + +void qFreeExplainResTree(SExplainResNode *res) { + if (NULL == res) { + return; + } + + taosMemoryFreeClear(res->pExecInfo); + + SNode* node = NULL; + FOREACH(node, res->pChildren) { + qFreeExplainResTree((SExplainResNode *)node); + } + nodesClearList(res->pChildren); + + taosMemoryFreeClear(res); +} + +void qFreeExplainCtx(void *ctx) { + if (NULL == ctx) { + return; + } + + SExplainCtx *pCtx = (SExplainCtx *)ctx; + int32_t rowSize = taosArrayGetSize(pCtx->rows); + for (int32_t i = 0; i < rowSize; ++i) { + SQueryExplainRowInfo *row = taosArrayGet(pCtx->rows, i); + taosMemoryFreeClear(row->buf); + } + + taosHashCleanup(pCtx->groupHash); + taosArrayDestroy(pCtx->rows); + taosMemoryFree(pCtx); +} + +int32_t qInitExplainCtx(void **pCtx, SHashObj *groupHash, bool verbose) { + int32_t code = 0; + SExplainCtx *ctx = taosMemoryCalloc(1, sizeof(SExplainCtx)); + if (NULL == ctx) { + qError("calloc SExplainCtx failed"); + QRY_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + SArray *rows = taosArrayInit(10, sizeof(SQueryExplainRowInfo)); + if (NULL == rows) { + qError("taosArrayInit SQueryExplainRowInfo failed"); + QRY_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + char *tbuf = taosMemoryMalloc(TSDB_EXPLAIN_RESULT_ROW_SIZE); + if (NULL == tbuf) { + qError("malloc size %d failed", TSDB_EXPLAIN_RESULT_ROW_SIZE); + QRY_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + ctx->verbose = verbose; + ctx->tbuf = tbuf; + ctx->rows = rows; + ctx->groupHash = groupHash; + + *pCtx = ctx; + + return TSDB_CODE_SUCCESS; + +_return: + + taosArrayDestroy(rows); + taosHashCleanup(groupHash); + taosMemoryFree(ctx); + + QRY_RET(code); +} + + +char *qFillModeString(EFillMode mode) { + switch (mode) { + case FILL_MODE_NONE: + return "none"; + case FILL_MODE_VALUE: + return "value"; + case FILL_MODE_PREV: + return "prev"; + case FILL_MODE_NULL: + return "null"; + case FILL_MODE_LINEAR: + return "linear"; + case FILL_MODE_NEXT: + return "next"; + default: + return "unknown"; + } +} + +char *qGetNameFromColumnNode(SNode *pNode) { + if (NULL == pNode || QUERY_NODE_COLUMN != pNode->type) { + return "NULL"; + } + + return ((SColumnNode *)pNode)->colName; +} + +int32_t qGenerateExplainResChildren(SPhysiNode *pNode, void *pExecInfo, SNodeList **pChildren) { + int32_t tlen = 0; + SNodeList *pPhysiChildren = NULL; + + switch (pNode->type) { + case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: { + STagScanPhysiNode *pTagScanNode = (STagScanPhysiNode *)pNode; + pPhysiChildren = pTagScanNode->node.pChildren; + break; + } + case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN: + case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:{ + STableScanPhysiNode *pTblScanNode = (STableScanPhysiNode *)pNode; + pPhysiChildren = pTblScanNode->scan.node.pChildren; + break; + } + case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN:{ + SSystemTableScanPhysiNode *pSTblScanNode = (SSystemTableScanPhysiNode *)pNode; + pPhysiChildren = pSTblScanNode->scan.node.pChildren; + break; + } + case QUERY_NODE_PHYSICAL_PLAN_PROJECT:{ + SProjectPhysiNode *pPrjNode = (SProjectPhysiNode *)pNode; + pPhysiChildren = pPrjNode->node.pChildren; + break; + } + case QUERY_NODE_PHYSICAL_PLAN_JOIN:{ + SJoinPhysiNode *pJoinNode = (SJoinPhysiNode *)pNode; + pPhysiChildren = pJoinNode->node.pChildren; + break; + } + case QUERY_NODE_PHYSICAL_PLAN_AGG:{ + SAggPhysiNode *pAggNode = (SAggPhysiNode *)pNode; + pPhysiChildren = pAggNode->node.pChildren; + break; + } + case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE:{ + SExchangePhysiNode *pExchNode = (SExchangePhysiNode *)pNode; + pPhysiChildren = pExchNode->node.pChildren; + break; + } + case QUERY_NODE_PHYSICAL_PLAN_SORT:{ + SSortPhysiNode *pSortNode = (SSortPhysiNode *)pNode; + pPhysiChildren = pSortNode->node.pChildren; + break; + } + case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:{ + SIntervalPhysiNode *pIntNode = (SIntervalPhysiNode *)pNode; + pPhysiChildren = pIntNode->window.node.pChildren; + break; + } + case QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW:{ + SSessionWinodwPhysiNode *pSessNode = (SSessionWinodwPhysiNode *)pNode; + pPhysiChildren = pSessNode->window.node.pChildren; + break; + } + default: + qError("not supported physical node type %d", pNode->type); + QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + } + + if (pPhysiChildren) { + *pChildren = nodesMakeList(); + if (NULL == *pChildren) { + qError("nodesMakeList failed"); + QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + } + + SNode* node = NULL; + SExplainResNode *pResNode = NULL; + FOREACH(node, pPhysiChildren) { + QRY_ERR_RET(qGenerateExplainResNode((SPhysiNode *)node, pExecInfo, &pResNode)); + QRY_ERR_RET(nodesListAppend(*pChildren, pResNode)); + } + + return TSDB_CODE_SUCCESS; +} + +int32_t qGenerateExplainResNode(SPhysiNode *pNode, void *pExecInfo, SExplainResNode **pRes) { + if (NULL == pNode) { + *pRes = NULL; + qError("physical node is NULL"); + return TSDB_CODE_QRY_APP_ERROR; + } + + SExplainResNode *res = taosMemoryCalloc(1, sizeof(SExplainResNode)); + if (NULL == res) { + qError("calloc SPhysiNodeExplainRes failed"); + return TSDB_CODE_QRY_OUT_OF_MEMORY; + } + + int32_t code = 0; + res->pNode = pNode; + res->pExecInfo = pExecInfo; + QRY_ERR_JRET(qGenerateExplainResChildren(pNode, pExecInfo, &res->pChildren)); + + *pRes = res; + + return TSDB_CODE_SUCCESS; + +_return: + + qFreeExplainResTree(res); + + QRY_RET(code); +} + +int32_t qExplainBufAppendExecInfo(void *pExecInfo, char *tbuf, int32_t *len) { + int32_t tlen = *len; + + EXPLAIN_ROW_APPEND("(exec info here)"); + + *len = tlen; + + return TSDB_CODE_SUCCESS; +} + +int32_t qExplainResAppendRow(SExplainCtx *ctx, char *tbuf, int32_t len, int32_t level) { + SQueryExplainRowInfo row = {0}; + row.buf = taosMemoryMalloc(len); + if (NULL == row.buf) { + qError("taosMemoryMalloc %d failed", len); + QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + memcpy(row.buf, tbuf, len); + row.level = level; + row.len = len; + ctx->totalSize += len; + + if (NULL == taosArrayPush(ctx->rows, &row)) { + qError("taosArrayPush row to explain res rows failed"); + taosMemoryFree(row.buf); + QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + return TSDB_CODE_SUCCESS; +} + + +int32_t qExplainResNodeToRowsImpl(SExplainResNode *pResNode, SExplainCtx *ctx, int32_t level) { + int32_t tlen = 0; + bool isVerboseLine = false; + char *tbuf = ctx->tbuf; + bool verbose = ctx->verbose; + SPhysiNode* pNode = pResNode->pNode; + if (NULL == pNode) { + qError("pyhsical node in explain res node is NULL"); + return TSDB_CODE_QRY_APP_ERROR; + } + + switch (pNode->type) { + case QUERY_NODE_PHYSICAL_PLAN_TAG_SCAN: { + STagScanPhysiNode *pTagScanNode = (STagScanPhysiNode *)pNode; + EXPLAIN_ROW_NEW(level, EXPLAIN_TAG_SCAN_FORMAT, pTagScanNode->tableName.tname, pTagScanNode->pScanCols->length, pTagScanNode->node.pOutputDataBlockDesc->outputRowSize); + if (pResNode->pExecInfo) { + QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); + } + EXPLAIN_ROW_APPEND(EXPLAIN_LOOPS_FORMAT, pTagScanNode->count); + if (pTagScanNode->reverse) { + EXPLAIN_ROW_APPEND(EXPLAIN_REVERSE_FORMAT, pTagScanNode->reverse); + } + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + if (verbose) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_ORDER_FORMAT, EXPLAIN_ORDER_STRING(pTagScanNode->order)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_TABLE_SEQ_SCAN: + case QUERY_NODE_PHYSICAL_PLAN_TABLE_SCAN:{ + STableScanPhysiNode *pTblScanNode = (STableScanPhysiNode *)pNode; + EXPLAIN_ROW_NEW(level, EXPLAIN_TBL_SCAN_FORMAT, pTblScanNode->scan.tableName.tname, pTblScanNode->scan.pScanCols->length, pTblScanNode->scan.node.pOutputDataBlockDesc->outputRowSize); + if (pResNode->pExecInfo) { + QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); + } + EXPLAIN_ROW_APPEND(EXPLAIN_LOOPS_FORMAT, pTblScanNode->scan.count); + if (pTblScanNode->scan.reverse) { + EXPLAIN_ROW_APPEND(EXPLAIN_REVERSE_FORMAT, pTblScanNode->scan.reverse); + } + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + if (verbose) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_ORDER_FORMAT, EXPLAIN_ORDER_STRING(pTblScanNode->scan.order)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_TIMERANGE_FORMAT, pTblScanNode->scanRange.skey, pTblScanNode->scanRange.ekey); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + + if (pTblScanNode->scan.node.pConditions) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT); + QRY_ERR_RET(nodesNodeToSQL(pTblScanNode->scan.node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_SYSTABLE_SCAN:{ + SSystemTableScanPhysiNode *pSTblScanNode = (SSystemTableScanPhysiNode *)pNode; + EXPLAIN_ROW_NEW(level, EXPLAIN_SYSTBL_SCAN_FORMAT, pSTblScanNode->scan.tableName.tname, pSTblScanNode->scan.pScanCols->length, pSTblScanNode->scan.node.pOutputDataBlockDesc->outputRowSize); + if (pResNode->pExecInfo) { + QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); + } + EXPLAIN_ROW_APPEND(EXPLAIN_LOOPS_FORMAT, pSTblScanNode->scan.count); + if (pSTblScanNode->scan.reverse) { + EXPLAIN_ROW_APPEND(EXPLAIN_REVERSE_FORMAT, pSTblScanNode->scan.reverse); + } + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + if (verbose) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_ORDER_FORMAT, EXPLAIN_ORDER_STRING(pSTblScanNode->scan.order)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + + if (pSTblScanNode->scan.node.pConditions) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT); + QRY_ERR_RET(nodesNodeToSQL(pSTblScanNode->scan.node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_PROJECT:{ + SProjectPhysiNode *pPrjNode = (SProjectPhysiNode *)pNode; + EXPLAIN_ROW_NEW(level, EXPLAIN_PROJECTION_FORMAT, pPrjNode->pProjections->length, pPrjNode->node.pOutputDataBlockDesc->outputRowSize); + if (pResNode->pExecInfo) { + QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); + } + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + if (verbose) { + if (pPrjNode->node.pConditions) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT); + QRY_ERR_RET(nodesNodeToSQL(pPrjNode->node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_JOIN:{ + SJoinPhysiNode *pJoinNode = (SJoinPhysiNode *)pNode; + EXPLAIN_ROW_NEW(level, EXPLAIN_JOIN_FORMAT, EXPLAIN_JOIN_STRING(pJoinNode->joinType), pJoinNode->pTargets->length, pJoinNode->node.pOutputDataBlockDesc->outputRowSize); + if (pResNode->pExecInfo) { + QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); + } + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + if (verbose) { + if (pJoinNode->node.pConditions) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT); + QRY_ERR_RET(nodesNodeToSQL(pJoinNode->node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_ON_CONDITIONS_FORMAT); + QRY_ERR_RET(nodesNodeToSQL(pJoinNode->pOnConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_AGG:{ + SAggPhysiNode *pAggNode = (SAggPhysiNode *)pNode; + EXPLAIN_ROW_NEW(level, EXPLAIN_AGG_FORMAT, pAggNode->pAggFuncs->length); + if (pAggNode->pGroupKeys) { + EXPLAIN_ROW_APPEND(EXPLAIN_GROUPS_FORMAT, pAggNode->pGroupKeys->length); + } + EXPLAIN_ROW_APPEND(EXPLAIN_WIDTH_FORMAT, pAggNode->node.pOutputDataBlockDesc->outputRowSize); + + if (pResNode->pExecInfo) { + QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); + } + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + if (verbose) { + if (pAggNode->node.pConditions) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT); + QRY_ERR_RET(nodesNodeToSQL(pAggNode->node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_EXCHANGE:{ + SExchangePhysiNode *pExchNode = (SExchangePhysiNode *)pNode; + SExplainGroup *group = taosHashGet(ctx->groupHash, &pExchNode->srcGroupId, sizeof(pExchNode->srcGroupId)); + if (NULL == group) { + qError("exchange src group %d not in groupHash", pExchNode->srcGroupId); + QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + } + + EXPLAIN_ROW_NEW(level, EXPLAIN_EXCHANGE_FORMAT, group->nodeNum, pExchNode->node.pOutputDataBlockDesc->outputRowSize); + if (pResNode->pExecInfo) { + QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); + } + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + if (verbose) { + if (pExchNode->node.pConditions) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT); + QRY_ERR_RET(nodesNodeToSQL(pExchNode->node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + } + + QRY_ERR_RET(qAppendTaskExplainResRows(ctx, pExchNode->srcGroupId, level + 1)); + break; + } + case QUERY_NODE_PHYSICAL_PLAN_SORT:{ + SSortPhysiNode *pSortNode = (SSortPhysiNode *)pNode; + EXPLAIN_ROW_NEW(level, EXPLAIN_SORT_FORMAT, pSortNode->pSortKeys->length, pSortNode->node.pOutputDataBlockDesc->outputRowSize); + if (pResNode->pExecInfo) { + QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); + } + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + if (verbose) { + if (pSortNode->node.pConditions) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT); + QRY_ERR_RET(nodesNodeToSQL(pSortNode->node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_INTERVAL:{ + SIntervalPhysiNode *pIntNode = (SIntervalPhysiNode *)pNode; + EXPLAIN_ROW_NEW(level, EXPLAIN_INTERVAL_FORMAT, qGetNameFromColumnNode(pIntNode->pTspk), pIntNode->window.pFuncs->length, + INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->interval, pIntNode->intervalUnit, pIntNode->precision), pIntNode->intervalUnit, + pIntNode->offset, getPrecisionUnit(pIntNode->precision), + INVERAL_TIME_FROM_PRECISION_TO_UNIT(pIntNode->sliding, pIntNode->slidingUnit, pIntNode->precision), pIntNode->slidingUnit, + pIntNode->window.node.pOutputDataBlockDesc->outputRowSize); + if (pResNode->pExecInfo) { + QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); + } + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + if (verbose) { + if (pIntNode->pFill) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILL_FORMAT, qFillModeString(pIntNode->pFill->mode)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + + if (pIntNode->window.node.pConditions) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT); + QRY_ERR_RET(nodesNodeToSQL(pIntNode->window.node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + } + break; + } + case QUERY_NODE_PHYSICAL_PLAN_SESSION_WINDOW:{ + SSessionWinodwPhysiNode *pIntNode = (SSessionWinodwPhysiNode *)pNode; + EXPLAIN_ROW_NEW(level, EXPLAIN_SESSION_FORMAT, pIntNode->gap, pIntNode->window.pFuncs->length, pIntNode->window.node.pOutputDataBlockDesc->outputRowSize); + if (pResNode->pExecInfo) { + QRY_ERR_RET(qExplainBufAppendExecInfo(pResNode->pExecInfo, tbuf, &tlen)); + } + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level)); + + if (verbose) { + if (pIntNode->window.node.pConditions) { + EXPLAIN_ROW_NEW(level + 1, EXPLAIN_FILTER_FORMAT); + QRY_ERR_RET(nodesNodeToSQL(pIntNode->window.node.pConditions, tbuf + VARSTR_HEADER_SIZE, TSDB_EXPLAIN_RESULT_ROW_SIZE, &tlen)); + EXPLAIN_ROW_END(); + QRY_ERR_RET(qExplainResAppendRow(ctx, tbuf, tlen, level + 1)); + } + } + break; + } + default: + qError("not supported physical node type %d", pNode->type); + return TSDB_CODE_QRY_APP_ERROR; + } + + return TSDB_CODE_SUCCESS; +} + + +int32_t qExplainResNodeToRows(SExplainResNode *pResNode, SExplainCtx *ctx, int32_t level) { + if (NULL == pResNode) { + qError("explain res node is NULL"); + QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + } + + int32_t code = 0; + QRY_ERR_RET(qExplainResNodeToRowsImpl(pResNode, ctx, level)); + + SNode* pNode = NULL; + FOREACH(pNode, pResNode->pChildren) { + QRY_ERR_RET(qExplainResNodeToRows((SExplainResNode *)pNode, ctx, level + 1)); + } + + return TSDB_CODE_SUCCESS; +} + +int32_t qAppendTaskExplainResRows(void *pCtx, int32_t groupId, int32_t level) { + SExplainResNode *node = NULL; + int32_t code = 0; + SExplainCtx *ctx = (SExplainCtx *)pCtx; + + SExplainGroup *group = taosHashGet(ctx->groupHash, &groupId, sizeof(groupId)); + if (NULL == group) { + qError("group %d not in groupHash", groupId); + QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + } + + QRY_ERR_RET(qGenerateExplainResNode(group->plan->pNode, group->execInfo, &node)); + + QRY_ERR_JRET(qExplainResNodeToRows(node, ctx, level)); + +_return: + + qFreeExplainResTree(node); + + QRY_RET(code); +} + + +int32_t qGetExplainRspFromCtx(void *ctx, SRetrieveTableRsp **pRsp) { + SExplainCtx *pCtx = (SExplainCtx *)ctx; + int32_t rowNum = taosArrayGetSize(pCtx->rows); + if (rowNum <= 0) { + qError("empty explain res rows"); + QRY_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + } + + int32_t colNum = 1; + int32_t rspSize = sizeof(SRetrieveTableRsp) + sizeof(int32_t) * colNum + sizeof(int32_t) * rowNum + pCtx->totalSize; + SRetrieveTableRsp *rsp = (SRetrieveTableRsp *)taosMemoryCalloc(1, rspSize); + if (NULL == rsp) { + qError("malloc SRetrieveTableRsp failed, size:%d", rspSize); + QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + rsp->completed = 1; + rsp->numOfRows = htonl(rowNum); + + *(int32_t *)rsp->data = htonl(pCtx->totalSize); + + int32_t *offset = (int32_t *)((char *)rsp->data + sizeof(int32_t)); + char *data = (char *)(offset + rowNum); + int32_t tOffset = 0; + + for (int32_t i = 0; i < rowNum; ++i) { + SQueryExplainRowInfo *row = taosArrayGet(pCtx->rows, i); + *offset = tOffset; + tOffset += row->len; + + memcpy(data, row->buf, row->len); + + ++offset; + data += row->len; + } + + *pRsp = rsp; + + return TSDB_CODE_SUCCESS; +} + +int32_t qExecStaticExplain(SQueryPlan *pDag, SRetrieveTableRsp **pRsp) { + int32_t code = 0; + SNodeListNode *plans = NULL; + int32_t taskNum = 0; + SExplainGroup *pGroup = NULL; + void *pCtx = NULL; + int32_t rootGroupId = 0; + + if (pDag->numOfSubplans <= 0) { + qError("invalid subplan num:%d", pDag->numOfSubplans); + QRY_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); + } + + int32_t levelNum = (int32_t)LIST_LENGTH(pDag->pSubplans); + if (levelNum <= 0) { + qError("invalid level num:%d", levelNum); + QRY_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); + } + + SHashObj *groupHash = taosHashInit(EXPLAIN_MAX_GROUP_NUM, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); + if (NULL == groupHash) { + qError("groupHash %d failed", EXPLAIN_MAX_GROUP_NUM); + QRY_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + QRY_ERR_JRET(qInitExplainCtx(&pCtx, groupHash, pDag->explainInfo.verbose)); + + for (int32_t i = 0; i < levelNum; ++i) { + plans = (SNodeListNode *)nodesListGetNode(pDag->pSubplans, i); + if (NULL == plans) { + qError("empty level plan, level:%d", i); + QRY_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); + } + + taskNum = (int32_t)LIST_LENGTH(plans->pNodeList); + if (taskNum <= 0) { + qError("invalid level plan number:%d, level:%d", taskNum, i); + QRY_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); + } + + SSubplan *plan = NULL; + for (int32_t n = 0; n < taskNum; ++n) { + plan = (SSubplan *)nodesListGetNode(plans->pNodeList, n); + pGroup = taosHashGet(groupHash, &plan->id.groupId, sizeof(plan->id.groupId)); + if (pGroup) { + ++pGroup->nodeNum; + continue; + } + + SExplainGroup group = {.nodeNum = 1, .plan = plan, .execInfo = NULL}; + if (0 != taosHashPut(groupHash, &plan->id.groupId, sizeof(plan->id.groupId), &group, sizeof(group))) { + qError("taosHashPut to explainGroupHash failed, taskIdx:%d", n); + QRY_ERR_JRET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + } + + if (0 == i) { + if (taskNum > 1) { + qError("invalid taskNum %d for level 0", taskNum); + QRY_ERR_JRET(TSDB_CODE_QRY_INVALID_INPUT); + } + + rootGroupId = plan->id.groupId; + } + + qDebug("level %d group handled, taskNum:%d", i, taskNum); + } + + QRY_ERR_JRET(qAppendTaskExplainResRows(pCtx, rootGroupId, 0)); + + QRY_ERR_JRET(qGetExplainRspFromCtx(pCtx, pRsp)); + +_return: + + qFreeExplainCtx(pCtx); + + QRY_RET(code); +} + + + diff --git a/source/libs/executor/inc/executil.h b/source/libs/executor/inc/executil.h index 5d5e0cae88..3faf208c0e 100644 --- a/source/libs/executor/inc/executil.h +++ b/source/libs/executor/inc/executil.h @@ -73,27 +73,12 @@ typedef struct SResultRowPosition { } SResultRowPosition; typedef struct SResultRowInfo { - SList *pRows; SResultRowPosition *pPosition; - SResultRow **pResult; // result list int32_t size; // number of result set int32_t capacity; // max capacity int32_t curPos; // current active result row index of pResult list } SResultRowInfo; -typedef struct SResultRowPool { - int32_t elemSize; - int32_t blockSize; - int32_t numOfElemPerBlock; - - struct { - int32_t blockIndex; - int32_t pos; - } position; - - SArray* pData; // SArray -} SResultRowPool; - struct STaskAttr; struct STaskRuntimeEnv; struct SUdfInfo; @@ -109,25 +94,33 @@ void resetResultRowInfo(struct STaskRuntimeEnv* pRuntimeEnv, SResultRowInfo* int32_t numOfClosedResultRows(SResultRowInfo* pResultRowInfo); void closeAllResultRows(SResultRowInfo* pResultRowInfo); -int32_t initResultRow(SResultRow *pResultRow); -void closeResultRow(SResultRowInfo* pResultRowInfo, int32_t slot); -bool isResultRowClosed(SResultRowInfo *pResultRowInfo, int32_t slot); -void clearResultRow(struct STaskRuntimeEnv* pRuntimeEnv, SResultRow* pResultRow); +void initResultRow(SResultRow *pResultRow); +void closeResultRow(SResultRow* pResultRow); +bool isResultRowClosed(SResultRow* pResultRow); struct SResultRowEntryInfo* getResultCell(const SResultRow* pRow, int32_t index, int32_t* offset); -void* destroyQueryFuncExpr(SExprInfo* pExprInfo, int32_t numOfExpr); int32_t getRowNumForMultioutput(struct STaskAttr* pQueryAttr, bool topBottomQuery, bool stable); -static FORCE_INLINE SResultRow *getResultRow(SResultRowInfo *pResultRowInfo, int32_t slot) { - assert(pResultRowInfo != NULL && slot >= 0 && slot < pResultRowInfo->size); - return pResultRowInfo->pResult[slot]; +static FORCE_INLINE SResultRow *getResultRow(SDiskbasedBuf* pBuf, SResultRowInfo *pResultRowInfo, int32_t slot) { + ASSERT(pResultRowInfo != NULL && slot >= 0 && slot < pResultRowInfo->size); + SResultRowPosition* pos = &pResultRowInfo->pPosition[slot]; + + SFilePage* bufPage = (SFilePage*) getBufPage(pBuf, pos->pageId); + SResultRow* pRow = (SResultRow*)((char*)bufPage + pos->offset); + return pRow; +} + +static FORCE_INLINE SResultRow *getResultRowByPos(SDiskbasedBuf* pBuf, SResultRowPosition* pos) { + SFilePage* bufPage = (SFilePage*) getBufPage(pBuf, pos->pageId); + SResultRow* pRow = (SResultRow*)((char*)bufPage + pos->offset); + return pRow; } static FORCE_INLINE char* getPosInResultPage(struct STaskAttr* pQueryAttr, SFilePage* page, int32_t rowOffset, int32_t offset) { assert(rowOffset >= 0 && pQueryAttr != NULL); - + ASSERT(0); // int32_t numOfRows = (int32_t)getRowNumForMultioutput(pQueryAttr, pQueryAttr->topBotQuery, pQueryAttr->stableQuery); // return ((char *)page->data) + rowOffset + offset * numOfRows; } @@ -139,22 +132,11 @@ static FORCE_INLINE char* getPosInResultPage_rv(SFilePage* page, int32_t rowOffs return (char*) page + rowOffset + offset * numOfRows; } -//bool isNullOperator(SColumnFilterElem *pFilter, const char* minval, const char* maxval, int16_t type); -//bool notNullOperator(SColumnFilterElem *pFilter, const char* minval, const char* maxval, int16_t type); - -__filter_func_t getFilterOperator(int32_t lowerOptr, int32_t upperOptr); - -SResultRow* getNewResultRow(SResultRowPool* p); - typedef struct { SArray* pResult; // SArray int32_t colId; } SStddevInterResult; -void interResToBinary(SBufferWriter* bw, SArray* pRes, int32_t tagLen); -SArray* interResFromBinary(const char* data, int32_t len); -void freeInterResult(void* param); - void initGroupResInfo(SGroupResInfo* pGroupResInfo, SResultRowInfo* pResultInfo); void initMultiResInfoFromArrayList(SGroupResInfo* pGroupResInfo, SArray* pArrayList); diff --git a/source/libs/executor/inc/executorimpl.h b/source/libs/executor/inc/executorimpl.h index ce0069fdfa..287cb094a6 100644 --- a/source/libs/executor/inc/executorimpl.h +++ b/source/libs/executor/inc/executorimpl.h @@ -69,7 +69,7 @@ enum { typedef struct SResultRowCell { uint64_t groupId; - SResultRow* pRow; + SResultRowPosition pos; } SResultRowCell; /** @@ -277,8 +277,6 @@ typedef struct STaskRuntimeEnv { char* keyBuf; // window key buffer // The window result objects pool, all the resultRow Objects are allocated and managed by this object. char** prevRow; - SResultRowPool* pool; - SArray* prevResult; // intermediate result, SArray STSBuf* pTsBuf; // timestamp filter list STSCursor cur; @@ -364,6 +362,7 @@ typedef struct SSourceDataInfo { int32_t index; SRetrieveTableRsp *pRsp; uint64_t totalRows; + int32_t code; EX_SOURCE_STATUS status; } SSourceDataInfo; diff --git a/source/libs/executor/src/executil.c b/source/libs/executor/src/executil.c index 93fbfe43ce..40e86c7840 100644 --- a/source/libs/executor/src/executil.c +++ b/source/libs/executor/src/executil.c @@ -53,15 +53,13 @@ int32_t getOutputInterResultBufSize(STaskAttr* pQueryAttr) { int32_t initResultRowInfo(SResultRowInfo *pResultRowInfo, int32_t size) { pResultRowInfo->size = 0; - pResultRowInfo->curPos = -1; + pResultRowInfo->curPos = -1; pResultRowInfo->capacity = size; - - pResultRowInfo->pResult = taosMemoryCalloc(pResultRowInfo->capacity, POINTER_BYTES); pResultRowInfo->pPosition = taosMemoryCalloc(pResultRowInfo->capacity, sizeof(SResultRowPosition)); - if (pResultRowInfo->pResult == NULL || pResultRowInfo->pPosition == NULL) { + + if (pResultRowInfo->pPosition == NULL) { return TSDB_CODE_QRY_OUT_OF_MEMORY; } - return TSDB_CODE_SUCCESS; } @@ -71,17 +69,17 @@ void cleanupResultRowInfo(SResultRowInfo *pResultRowInfo) { } if (pResultRowInfo->capacity == 0) { - assert(pResultRowInfo->pResult == NULL); +// assert(pResultRowInfo->pResult == NULL); return; } for(int32_t i = 0; i < pResultRowInfo->size; ++i) { - if (pResultRowInfo->pResult[i]) { - taosMemoryFreeClear(pResultRowInfo->pResult[i]->key); - } +// if (pResultRowInfo->pResult[i]) { +// taosMemoryFreeClear(pResultRowInfo->pResult[i]->key); +// } } - taosMemoryFreeClear(pResultRowInfo->pResult); + taosMemoryFreeClear(pResultRowInfo->pPosition); } void resetResultRowInfo(STaskRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRowInfo) { @@ -90,8 +88,8 @@ void resetResultRowInfo(STaskRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRow } for (int32_t i = 0; i < pResultRowInfo->size; ++i) { - SResultRow *pWindowRes = pResultRowInfo->pResult[i]; - clearResultRow(pRuntimeEnv, pWindowRes); +// SResultRow *pWindowRes = pResultRowInfo->pResult[i]; +// clearResultRow(pRuntimeEnv, pWindowRes); int32_t groupIndex = 0; int64_t uid = 0; @@ -101,14 +99,13 @@ void resetResultRowInfo(STaskRuntimeEnv *pRuntimeEnv, SResultRowInfo *pResultRow } pResultRowInfo->size = 0; - pResultRowInfo->curPos = -1; } int32_t numOfClosedResultRows(SResultRowInfo *pResultRowInfo) { int32_t i = 0; - while (i < pResultRowInfo->size && pResultRowInfo->pResult[i]->closed) { - ++i; - } +// while (i < pResultRowInfo->size && pResultRowInfo->pResult[i]->closed) { +// ++i; +// } return i; } @@ -117,21 +114,22 @@ void closeAllResultRows(SResultRowInfo *pResultRowInfo) { assert(pResultRowInfo->size >= 0 && pResultRowInfo->capacity >= pResultRowInfo->size); for (int32_t i = 0; i < pResultRowInfo->size; ++i) { - SResultRow* pRow = pResultRowInfo->pResult[i]; - if (pRow->closed) { - continue; - } +// ASSERT(0); +// SResultRow* pRow = pResultRowInfo->pResult[i]; +// if (pRow->closed) { +// continue; +// } - pRow->closed = true; +// pRow->closed = true; } } -bool isResultRowClosed(SResultRowInfo *pResultRowInfo, int32_t slot) { - return (getResultRow(pResultRowInfo, slot)->closed == true); +bool isResultRowClosed(SResultRow* pRow) { + return (pRow->closed == true); } -void closeResultRow(SResultRowInfo *pResultRowInfo, int32_t slot) { - getResultRow(pResultRowInfo, slot)->closed = true; +void closeResultRow(SResultRow* pResultRow) { + pResultRow->closed = true; } void clearResultRow(STaskRuntimeEnv *pRuntimeEnv, SResultRow *pResultRow) { @@ -181,29 +179,6 @@ size_t getResultRowSize(SqlFunctionCtx* pCtx, int32_t numOfOutput) { return rowSize; } -SResultRow* getNewResultRow(SResultRowPool* p) { - if (p == NULL) { - return NULL; - } - - void* ptr = NULL; - if (p->position.pos == 0) { - ptr = taosMemoryCalloc(1, p->blockSize); - taosArrayPush(p->pData, &ptr); - - } else { - size_t last = taosArrayGetSize(p->pData); - - void** pBlock = taosArrayGet(p->pData, last - 1); - ptr = ((char*) (*pBlock)) + p->elemSize * p->position.pos; - } - - p->position.pos = (p->position.pos + 1)%p->numOfElemPerBlock; - initResultRow(ptr); - - return ptr; -} - void cleanupGroupResInfo(SGroupResInfo* pGroupResInfo) { assert(pGroupResInfo != NULL); @@ -261,8 +236,9 @@ int32_t getNumOfTotalRes(SGroupResInfo* pGroupResInfo) { return (int32_t) taosArrayGetSize(pGroupResInfo->pRows); } -static int64_t getNumOfResultWindowRes(STaskRuntimeEnv* pRuntimeEnv, SResultRow *pResultRow, int32_t* rowCellInfoOffset) { +static int64_t getNumOfResultWindowRes(STaskRuntimeEnv* pRuntimeEnv, SResultRowPosition *pos, int32_t* rowCellInfoOffset) { STaskAttr* pQueryAttr = pRuntimeEnv->pQueryAttr; + ASSERT(0); for (int32_t j = 0; j < pQueryAttr->numOfOutput; ++j) { int32_t functionId = 0;//pQueryAttr->pExpr1[j].base.functionId; @@ -305,25 +281,26 @@ static int32_t tableResultComparFn(const void *pLeft, const void *pRight, void * return -1; } + ASSERT(0); STableQueryInfo** pList = supporter->pTableQueryInfo; - SResultRow* pWindowRes1 = pList[left]->resInfo.pResult[leftPos]; +// SResultRow* pWindowRes1 = pList[left]->resInfo.pResult[leftPos]; // SResultRow * pWindowRes1 = getResultRow(&(pList[left]->resInfo), leftPos); - TSKEY leftTimestamp = pWindowRes1->win.skey; +// TSKEY leftTimestamp = pWindowRes1->win.skey; // SResultRowInfo *pWindowResInfo2 = &(pList[right]->resInfo); // SResultRow * pWindowRes2 = getResultRow(pWindowResInfo2, rightPos); - SResultRow* pWindowRes2 = pList[right]->resInfo.pResult[rightPos]; - TSKEY rightTimestamp = pWindowRes2->win.skey; +// SResultRow* pWindowRes2 = pList[right]->resInfo.pResult[rightPos]; +// TSKEY rightTimestamp = pWindowRes2->win.skey; - if (leftTimestamp == rightTimestamp) { +// if (leftTimestamp == rightTimestamp) { return 0; - } +// } - if (supporter->order == TSDB_ORDER_ASC) { - return (leftTimestamp > rightTimestamp)? 1:-1; - } else { - return (leftTimestamp < rightTimestamp)? 1:-1; - } +// if (supporter->order == TSDB_ORDER_ASC) { +// return (leftTimestamp > rightTimestamp)? 1:-1; +// } else { +// return (leftTimestamp < rightTimestamp)? 1:-1; +// } } int32_t tsAscOrder(const void* p1, const void* p2) { @@ -331,11 +308,12 @@ int32_t tsAscOrder(const void* p1, const void* p2) { SResultRowCell* pc2 = (SResultRowCell*) p2; if (pc1->groupId == pc2->groupId) { - if (pc1->pRow->win.skey == pc2->pRow->win.skey) { - return 0; - } else { - return (pc1->pRow->win.skey < pc2->pRow->win.skey)? -1:1; - } + ASSERT(0); +// if (pc1->pRow->win.skey == pc2->pRow->win.skey) { +// return 0; +// } else { +// return (pc1->pRow->win.skey < pc2->pRow->win.skey)? -1:1; +// } } else { return (pc1->groupId < pc2->groupId)? -1:1; } @@ -346,11 +324,12 @@ int32_t tsDescOrder(const void* p1, const void* p2) { SResultRowCell* pc2 = (SResultRowCell*) p2; if (pc1->groupId == pc2->groupId) { - if (pc1->pRow->win.skey == pc2->pRow->win.skey) { - return 0; - } else { - return (pc1->pRow->win.skey < pc2->pRow->win.skey)? 1:-1; - } + ASSERT(0); +// if (pc1->pRow->win.skey == pc2->pRow->win.skey) { +// return 0; +// } else { +// return (pc1->pRow->win.skey < pc2->pRow->win.skey)? 1:-1; +// } } else { return (pc1->groupId < pc2->groupId)? -1:1; } @@ -384,13 +363,13 @@ static int32_t mergeIntoGroupResultImplRv(STaskRuntimeEnv *pRuntimeEnv, SGroupRe break; } - int64_t num = getNumOfResultWindowRes(pRuntimeEnv, pResultRowCell->pRow, rowCellInfoOffset); + int64_t num = getNumOfResultWindowRes(pRuntimeEnv, &pResultRowCell->pos, rowCellInfoOffset); if (num <= 0) { continue; } - taosArrayPush(pGroupResInfo->pRows, &pResultRowCell->pRow); - pResultRowCell->pRow->numOfRows = (uint32_t) num; + taosArrayPush(pGroupResInfo->pRows, &pResultRowCell->pos); +// pResultRowCell->pRow->numOfRows = (uint32_t) num; } return TSDB_CODE_SUCCESS; @@ -449,9 +428,10 @@ static UNUSED_FUNC int32_t mergeIntoGroupResultImpl(STaskRuntimeEnv *pRuntimeEnv int32_t tableIndex = tMergeTreeGetChosenIndex(pTree); SResultRowInfo *pWindowResInfo = &pTableQueryInfoList[tableIndex]->resInfo; - SResultRow *pWindowRes = getResultRow(pWindowResInfo, cs.rowIndex[tableIndex]); + ASSERT(0); + SResultRow *pWindowRes = NULL;//getResultRow(pBuf, pWindowResInfo, cs.rowIndex[tableIndex]); - int64_t num = getNumOfResultWindowRes(pRuntimeEnv, pWindowRes, rowCellInfoOffset); + int64_t num = 0;//getNumOfResultWindowRes(pRuntimeEnv, pWindowRes, rowCellInfoOffset); if (num <= 0) { cs.rowIndex[tableIndex] += 1; diff --git a/source/libs/executor/src/executorimpl.c b/source/libs/executor/src/executorimpl.c index 6265fe6123..54a75d9c7e 100644 --- a/source/libs/executor/src/executorimpl.c +++ b/source/libs/executor/src/executorimpl.c @@ -426,18 +426,10 @@ static void prepareResultListBuffer(SResultRowInfo* pResultRowInfo, jmp_buf env) newCapacity += 4; } - char* t = taosMemoryRealloc(pResultRowInfo->pResult, (size_t)(newCapacity * POINTER_BYTES)); - if (t == NULL) { - longjmp(env, TSDB_CODE_QRY_OUT_OF_MEMORY); - } - pResultRowInfo->pPosition = taosMemoryRealloc(pResultRowInfo->pPosition, newCapacity * sizeof(SResultRowPosition)); - pResultRowInfo->pResult = (SResultRow**)t; int32_t inc = (int32_t)newCapacity - pResultRowInfo->capacity; - memset(&pResultRowInfo->pResult[pResultRowInfo->capacity], 0, POINTER_BYTES * inc); memset(&pResultRowInfo->pPosition[pResultRowInfo->capacity], 0, sizeof(SResultRowPosition)); - pResultRowInfo->capacity = (int32_t)newCapacity; } @@ -458,9 +450,8 @@ static bool chkResultRowFromKey(STaskRuntimeEnv* pRuntimeEnv, SResultRowInfo* pR if (p1 != NULL) { if (pResultRowInfo->size == 0) { existed = false; - assert(pResultRowInfo->curPos == -1); } else if (pResultRowInfo->size == 1) { - existed = (pResultRowInfo->pResult[0] == (*p1)); +// existed = (pResultRowInfo->pResult[0] == (*p1)); } else { // check if current pResultRowInfo contains the existed pResultRow SET_RES_EXT_WINDOW_KEY(pRuntimeEnv->keyBuf, pData, bytes, uid, pResultRowInfo); int64_t* index = @@ -479,6 +470,7 @@ static bool chkResultRowFromKey(STaskRuntimeEnv* pRuntimeEnv, SResultRowInfo* pR return p1 != NULL; } +#if 0 static SResultRow* doSetResultOutBufByKey(STaskRuntimeEnv* pRuntimeEnv, SResultRowInfo* pResultRowInfo, int64_t tid, char* pData, int16_t bytes, bool masterscan, uint64_t tableGroupId) { bool existed = false; @@ -496,16 +488,16 @@ static SResultRow* doSetResultOutBufByKey(STaskRuntimeEnv* pRuntimeEnv, SResultR if (p1 != NULL) { if (pResultRowInfo->size == 0) { existed = false; - assert(pResultRowInfo->curPos == -1); +// assert(pResultRowInfo->curPos == -1); } else if (pResultRowInfo->size == 1) { - existed = (pResultRowInfo->pResult[0] == (*p1)); - pResultRowInfo->curPos = 0; +// existed = (pResultRowInfo->pResult[0] == (*p1)); +// pResultRowInfo->curPos = 0; } else { // check if current pResultRowInfo contains the existed pResultRow SET_RES_EXT_WINDOW_KEY(pRuntimeEnv->keyBuf, pData, bytes, tid, pResultRowInfo); int64_t* index = taosHashGet(pRuntimeEnv->pResultRowListSet, pRuntimeEnv->keyBuf, GET_RES_EXT_WINDOW_KEY_LEN(bytes)); if (index != NULL) { - pResultRowInfo->curPos = (int32_t)*index; +// pResultRowInfo->curPos = (int32_t)*index; existed = true; } else { existed = false; @@ -555,6 +547,7 @@ static SResultRow* doSetResultOutBufByKey(STaskRuntimeEnv* pRuntimeEnv, SResultR return pResultRowInfo->pResult[pResultRowInfo->curPos]; } +#endif SResultRow* getNewResultRow_rv(SDiskbasedBuf* pResultBuf, int64_t tableGroupId, int32_t interBufSize) { SFilePage* pData = NULL; @@ -599,65 +592,75 @@ SResultRow* getNewResultRow_rv(SDiskbasedBuf* pResultBuf, int64_t tableGroupId, static SResultRow* doSetResultOutBufByKey_rv(SDiskbasedBuf* pResultBuf, SResultRowInfo* pResultRowInfo, int64_t tid, char* pData, int16_t bytes, bool masterscan, uint64_t tableGroupId, SExecTaskInfo* pTaskInfo, bool isIntervalQuery, SAggSupporter* pSup) { - bool existed = false; + bool existInCurrentResusltRowInfo = false; SET_RES_WINDOW_KEY(pSup->keyBuf, pData, bytes, tableGroupId); - SResultRow** p1 = (SResultRow**)taosHashGet(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes)); + SResultRowPosition* p1 = (SResultRowPosition*)taosHashGet(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes)); // in case of repeat scan/reverse scan, no new time window added. if (isIntervalQuery) { if (!masterscan) { // the *p1 may be NULL in case of sliding+offset exists. - return (p1 != NULL) ? *p1 : NULL; + if (p1 != NULL) { + return getResultRowByPos(pResultBuf, p1); + } else { + return NULL; + } } if (p1 != NULL) { if (pResultRowInfo->size == 0) { - existed = false; + existInCurrentResusltRowInfo = false; // this time window created by other timestamp that does not belongs to current table. assert(pResultRowInfo->curPos == -1); } else if (pResultRowInfo->size == 1) { - existed = (pResultRowInfo->pResult[0] == (*p1)); - pResultRowInfo->curPos = 0; - } else { // check if current pResultRowInfo contains the existed pResultRow + ASSERT(0); +// existInCurrentResusltRowInfo = (pResultRowInfo->pResult[0] == (*p1)); + } else { // check if current pResultRowInfo contains the existInCurrentResusltRowInfo pResultRow SET_RES_EXT_WINDOW_KEY(pSup->keyBuf, pData, bytes, tid, pResultRowInfo); int64_t* index = taosHashGet(pSup->pResultRowListSet, pSup->keyBuf, GET_RES_EXT_WINDOW_KEY_LEN(bytes)); if (index != NULL) { - pResultRowInfo->curPos = (int32_t)*index; - existed = true; + // TODO check the scan order for current opened time window +// pResultRowInfo->curPos = (int32_t)*index; + existInCurrentResusltRowInfo = true; } else { - existed = false; + existInCurrentResusltRowInfo = false; } } } } else { - // In case of group by column query, the required SResultRow object must be existed in the pResultRowInfo object. + // In case of group by column query, the required SResultRow object must be existInCurrentResusltRowInfo in the pResultRowInfo object. if (p1 != NULL) { - return *p1; + return getResultRowByPos(pResultBuf, p1); } } - if (!existed) { - prepareResultListBuffer(pResultRowInfo, pTaskInfo->env); - - SResultRow* pResult = NULL; - if (p1 == NULL) { - pResult = getNewResultRow_rv(pResultBuf, tableGroupId, pSup->resultRowSize); - int32_t ret = initResultRow(pResult); - if (ret != TSDB_CODE_SUCCESS) { - longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); - } - - // add a new result set for a new group - taosHashPut(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &pResult, POINTER_BYTES); - SResultRowCell cell = {.groupId = tableGroupId, .pRow = pResult}; - taosArrayPush(pSup->pResultRowArrayList, &cell); - } else { - pResult = *p1; + SResultRow* pResult = NULL; + if (!existInCurrentResusltRowInfo) { + // 1. close current opened time window + if (pResultRowInfo->curPos != -1) { // todo extract function + SResultRowPosition* pos = &pResultRowInfo->pPosition[pResultRowInfo->curPos]; + SFilePage* pPage = getBufPage(pResultBuf, pos->pageId); + SResultRow* pRow = (SResultRow*)((char*)pPage + pos->offset); + closeResultRow(pRow); + releaseBufPage(pResultBuf, pPage); } + prepareResultListBuffer(pResultRowInfo, pTaskInfo->env); + if (p1 == NULL) { + pResult = getNewResultRow_rv(pResultBuf, tableGroupId, pSup->resultRowSize); + initResultRow(pResult); + + // add a new result set for a new group + SResultRowPosition pos = {.pageId = pResult->pageId, .offset = pResult->offset}; + taosHashPut(pSup->pResultRowHashTable, pSup->keyBuf, GET_RES_WINDOW_KEY_LEN(bytes), &pos, POINTER_BYTES); + SResultRowCell cell = {.groupId = tableGroupId, .pos = pos}; + taosArrayPush(pSup->pResultRowArrayList, &cell); + } else { + pResult = getResultRowByPos(pResultBuf, p1); + } + + // 2. set the new time window to be the new active time window pResultRowInfo->curPos = pResultRowInfo->size; - pResultRowInfo->pPosition[pResultRowInfo->size] = - (SResultRowPosition){.pageId = pResult->pageId, .offset = pResult->offset}; - pResultRowInfo->pResult[pResultRowInfo->size++] = pResult; + pResultRowInfo->pPosition[pResultRowInfo->size++] = (SResultRowPosition){.pageId = pResult->pageId, .offset = pResult->offset}; int64_t index = pResultRowInfo->curPos; SET_RES_EXT_WINDOW_KEY(pSup->keyBuf, pData, bytes, tid, pResultRowInfo); @@ -669,7 +672,7 @@ static SResultRow* doSetResultOutBufByKey_rv(SDiskbasedBuf* pResultBuf, SResultR longjmp(pTaskInfo->env, TSDB_CODE_QRY_TOO_MANY_TIMEWINDOW); } - return pResultRowInfo->pResult[pResultRowInfo->curPos]; + return pResult; } static void getInitialStartTimeWindow(SInterval* pInterval, int32_t precision, TSKEY ts, STimeWindow* w, TSKEY ekey, @@ -693,7 +696,7 @@ static void getInitialStartTimeWindow(SInterval* pInterval, int32_t precision, T } // get the correct time window according to the handled timestamp -static STimeWindow getActiveTimeWindow(SResultRowInfo* pResultRowInfo, int64_t ts, SInterval* pInterval, +static STimeWindow getActiveTimeWindow(SDiskbasedBuf * pBuf, SResultRowInfo* pResultRowInfo, int64_t ts, SInterval* pInterval, int32_t precision, STimeWindow* win) { STimeWindow w = {0}; @@ -701,7 +704,7 @@ static STimeWindow getActiveTimeWindow(SResultRowInfo* pResultRowInfo, int64_t t getInitialStartTimeWindow(pInterval, precision, ts, &w, win->ekey, true); w.ekey = taosTimeAdd(w.skey, pInterval->interval, pInterval->intervalUnit, precision) - 1; } else { - w = getResultRow(pResultRowInfo, pResultRowInfo->curPos)->win; + w = getResultRow(pBuf, pResultRowInfo, pResultRowInfo->curPos)->win; } if (w.skey > ts || w.ekey < ts) { @@ -730,7 +733,7 @@ static STimeWindow getActiveTimeWindow(SResultRowInfo* pResultRowInfo, int64_t t // get the correct time window according to the handled timestamp static STimeWindow getCurrentActiveTimeWindow(SResultRowInfo* pResultRowInfo, int64_t ts, STaskAttr* pQueryAttr) { STimeWindow w = {0}; - +#if 0 if (pResultRowInfo->curPos == -1) { // the first window, from the previous stored value // getInitialStartTimeWindow(pQueryAttr, ts, &w); @@ -742,7 +745,7 @@ static STimeWindow getCurrentActiveTimeWindow(SResultRowInfo* pResultRowInfo, in w.ekey = w.skey + pQueryAttr->interval.interval - 1; } } else { - w = getResultRow(pResultRowInfo, pResultRowInfo->curPos)->win; + w = pRow->win; } /* @@ -752,6 +755,7 @@ static STimeWindow getCurrentActiveTimeWindow(SResultRowInfo* pResultRowInfo, in if (w.ekey > pQueryAttr->window.ekey && QUERY_IS_ASC_QUERY(pQueryAttr)) { w.ekey = pQueryAttr->window.ekey; } +#endif return w; } @@ -816,8 +820,8 @@ static int32_t setResultOutputBufByKey(STaskRuntimeEnv* pRuntimeEnv, SResultRowI assert(win->skey <= win->ekey); SDiskbasedBuf* pResultBuf = pRuntimeEnv->pResultBuf; - SResultRow* pResultRow = doSetResultOutBufByKey(pRuntimeEnv, pResultRowInfo, tid, (char*)&win->skey, TSDB_KEYSIZE, - masterscan, tableGroupId); + SResultRow* pResultRow = NULL;//doSetResultOutBufByKey(pRuntimeEnv, pResultRowInfo, tid, (char*)&win->skey, TSDB_KEYSIZE, +// masterscan, tableGroupId); if (pResultRow == NULL) { *pResult = NULL; return TSDB_CODE_SUCCESS; @@ -840,8 +844,7 @@ static int32_t setResultOutputBufByKey(STaskRuntimeEnv* pRuntimeEnv, SResultRowI return TSDB_CODE_SUCCESS; } -static void setResultRowOutputBufInitCtx_rv(SDiskbasedBuf* pBuf, SResultRow* pResult, SqlFunctionCtx* pCtx, - int32_t numOfOutput, int32_t* rowCellInfoOffset); +static void setResultRowOutputBufInitCtx_rv(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowCellInfoOffset); static int32_t setResultOutputBufByKey_rv(SResultRowInfo* pResultRowInfo, int64_t id, STimeWindow* win, bool masterscan, SResultRow** pResult, int64_t tableGroupId, SqlFunctionCtx* pCtx, @@ -859,7 +862,7 @@ static int32_t setResultOutputBufByKey_rv(SResultRowInfo* pResultRowInfo, int64_ // set time window for current result pResultRow->win = (*win); *pResult = pResultRow; - setResultRowOutputBufInitCtx_rv(pAggSup->pResultBuf, pResultRow, pCtx, numOfOutput, rowCellInfoOffset); + setResultRowOutputBufInitCtx_rv(pResultRow, pCtx, numOfOutput, rowCellInfoOffset); return TSDB_CODE_SUCCESS; } @@ -909,9 +912,9 @@ static FORCE_INLINE int32_t getForwardStepsInBlock(int32_t numOfRows, __block_se return forwardStep; } -static void doUpdateResultRowIndex(SResultRowInfo* pResultRowInfo, TSKEY lastKey, bool ascQuery, - bool timeWindowInterpo) { +static void doUpdateResultRowIndex(SResultRowInfo* pResultRowInfo, TSKEY lastKey, bool ascQuery, bool timeWindowInterpo) { int64_t skey = TSKEY_INITIAL_VAL; +#if 0 int32_t i = 0; for (i = pResultRowInfo->size - 1; i >= 0; --i) { SResultRow* pResult = pResultRowInfo->pResult[i]; @@ -963,6 +966,7 @@ static void doUpdateResultRowIndex(SResultRowInfo* pResultRowInfo, TSKEY lastKey pResultRowInfo->curPos = i + 1; // current not closed result object } } +#endif } static void updateResultRowInfoActiveIndex(SResultRowInfo* pResultRowInfo, const STimeWindow* pWin, TSKEY lastKey, @@ -1041,7 +1045,9 @@ static void updateTimeWindowInfo(SColumnInfoData* pColData, STimeWindow* pWin) { static void doApplyFunctions(SqlFunctionCtx* pCtx, STimeWindow* pWin, SColumnInfoData* pTimeWindowData, int32_t offset, int32_t forwardStep, TSKEY* tsCol, int32_t numOfTotal, int32_t numOfOutput, int32_t order) { SScalarParam intervalParam = {.numOfRows = 5, .columnData = pTimeWindowData}; //TODO move out of this function - updateTimeWindowInfo(pTimeWindowData, pWin); + if (pTimeWindowData != NULL) { + updateTimeWindowInfo(pTimeWindowData, pWin); + } for (int32_t k = 0; k < numOfOutput; ++k) { pCtx[k].startTs = pWin->skey; @@ -1253,8 +1259,8 @@ static void doSetInputDataBlock(SOperatorInfo* pOperator, SqlFunctionCtx* pCtx, ASSERT(pCtx[i].input.pData[j] != NULL); } } - // setBlockStatisInfo(&pCtx[i], pBlock, pOperator->pExpr[i].base.pColumns); + // setBlockStatisInfo(&pCtx[i], pBlock, pOperator->pExpr[i].base.pColumns); // uint32_t flag = pOperator->pExpr[i].base.pParam[0].pCol->flag; // if (TSDB_COL_IS_NORMAL_COL(flag) /*|| (pCtx[i].functionId == FUNCTION_BLKINFO) || // (TSDB_COL_IS_TAG(flag) && pOperator->pRuntimeEnv->scanFlag == MERGE_STAGE)*/) { @@ -1551,14 +1557,14 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe if (pSDataBlock->pDataBlock != NULL) { SColumnInfoData* pColDataInfo = taosArrayGet(pSDataBlock->pDataBlock, 0); tsCols = (int64_t*)pColDataInfo->pData; -// assert(tsCols[0] == pSDataBlock->info.window.skey && -// tsCols[pSDataBlock->info.rows - 1] == pSDataBlock->info.window.ekey); +// assert(tsCols[0] == pSDataBlock->info.window.skey && tsCols[pSDataBlock->info.rows - 1] == +// pSDataBlock->info.window.ekey); } int32_t startPos = ascScan? 0 : (pSDataBlock->info.rows - 1); TSKEY ts = getStartTsKey(&pSDataBlock->info.window, tsCols, pSDataBlock->info.rows, ascScan); - STimeWindow win = getActiveTimeWindow(pResultRowInfo, ts, &pInfo->interval, pInfo->interval.precision, &pInfo->win); + STimeWindow win = getActiveTimeWindow(pInfo->aggSup.pResultBuf, pResultRowInfo, ts, &pInfo->interval, pInfo->interval.precision, &pInfo->win); bool masterScan = true; SResultRow* pResult = NULL; @@ -1581,6 +1587,8 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe // prev time window not interpolation yet. int32_t curIndex = pResultRowInfo->curPos; + +#if 0 if (prevIndex != -1 && prevIndex < curIndex && pInfo->timeWindowInterpo) { for (int32_t j = prevIndex; j < curIndex; ++j) { // previous time window may be all closed already. SResultRow* pRes = getResultRow(pResultRowInfo, j); @@ -1615,6 +1623,7 @@ static SArray* hashIntervalAgg(SOperatorInfo* pOperatorInfo, SResultRowInfo* pRe longjmp(pTaskInfo->env, TSDB_CODE_QRY_OUT_OF_MEMORY); } } +#endif // window start key interpolation doWindowBorderInterpolation(pOperatorInfo, pSDataBlock, pInfo->binfo.pCtx, pResult, &win, startPos, forwardStep, @@ -1886,9 +1895,7 @@ static void doHashGroupbyAgg(SOperatorInfo* pOperator, SSDataBlock* pBlock) { } /*int32_t ret = */ generatedHashKey(pInfo->keyBuf, &len, pInfo->pGroupColVals); - int32_t ret = - setGroupResultOutputBuf_rv(&(pInfo->binfo), pOperator->numOfOutput, pInfo->keyBuf, TSDB_DATA_TYPE_VARCHAR, len, - 0, pInfo->aggSup.pResultBuf, pTaskInfo, &pInfo->aggSup); + int32_t ret = setGroupResultOutputBuf_rv(&(pInfo->binfo), pOperator->numOfOutput, pInfo->keyBuf, TSDB_DATA_TYPE_VARCHAR, len, 0, pInfo->aggSup.pResultBuf, pTaskInfo, &pInfo->aggSup); if (ret != TSDB_CODE_SUCCESS) { // null data, too many state code longjmp(pTaskInfo->env, TSDB_CODE_QRY_APP_ERROR); } @@ -2010,12 +2017,11 @@ static int32_t setGroupResultOutputBuf_rv(SOptrBasicInfo* binfo, int32_t numOfCo SqlFunctionCtx* pCtx = binfo->pCtx; SResultRow* pResultRow = doSetResultOutBufByKey_rv(pBuf, pResultRowInfo, groupId, (char*)pData, bytes, true, groupId, - pTaskInfo, true, pAggSup); + pTaskInfo, false, pAggSup); assert(pResultRow != NULL); setResultRowKey(pResultRow, pData, type); - - setResultRowOutputBufInitCtx_rv(pBuf, pResultRow, pCtx, numOfCols, binfo->rowCellInfoOffset); + setResultRowOutputBufInitCtx_rv(pResultRow, pCtx, numOfCols, binfo->rowCellInfoOffset); return TSDB_CODE_SUCCESS; } @@ -2170,8 +2176,8 @@ static SqlFunctionCtx* createSqlFunctionCtx_rv(SExprInfo* pExprInfo, int32_t num } } pCtx->resDataInfo.interBufSize = env.calcMemSize; - } else if (pExpr->pExpr->nodeType == QUERY_NODE_COLUMN) { - } else if (pExpr->pExpr->nodeType == QUERY_NODE_OPERATOR) { + } else if (pExpr->pExpr->nodeType == QUERY_NODE_COLUMN || pExpr->pExpr->nodeType == QUERY_NODE_OPERATOR) { + pCtx->resDataInfo.interBufSize = pFunct->resSchema.bytes; // for simple column, the intermediate buffer needs to hold one element. } pCtx->input.numOfInputCols = pFunct->numOfParams; @@ -3430,10 +3436,8 @@ void switchCtxOrder(SqlFunctionCtx* pCtx, int32_t numOfOutput) { } } -// TODO fix this bug. -int32_t initResultRow(SResultRow* pResultRow) { +void initResultRow(SResultRow* pResultRow) { pResultRow->pEntryInfo = (struct SResultRowEntryInfo*)((char*)pResultRow + sizeof(SResultRow)); - return TSDB_CODE_SUCCESS; } /* @@ -3449,7 +3453,9 @@ void setFunctionResultOutput(SOptrBasicInfo* pInfo, SAggSupporter* pSup, int32_t SqlFunctionCtx* pCtx = pInfo->pCtx; SSDataBlock* pDataBlock = pInfo->pRes; int32_t* rowCellInfoOffset = pInfo->rowCellInfoOffset; + SResultRowInfo* pResultRowInfo = &pInfo->resultRowInfo; + initResultRowInfo(pResultRowInfo, 16); int64_t tid = 0; int64_t groupId = 0; @@ -3610,9 +3616,11 @@ void finalizeMultiTupleQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SD SFilePage* bufPage = getBufPage(pBuf, pPos->pageId); SResultRow* pRow = (SResultRow*)((char*)bufPage + pPos->offset); - if (!isResultRowClosed(pResultRowInfo, i)) { - continue; - } + + // TODO ignore the close status anyway. +// if (!isResultRowClosed(pRow)) { +// continue; +// } for (int32_t j = 0; j < numOfOutput; ++j) { pCtx[j].resultInfo = getResultCell(pRow, j, rowCellInfoOffset); @@ -3622,7 +3630,7 @@ void finalizeMultiTupleQueryResult(SqlFunctionCtx* pCtx, int32_t numOfOutput, SD continue; } - if (pCtx[j].fpSet.process) { // TODO set the dummy function. + if (pCtx[j].fpSet.process) { // TODO set the dummy function, to avoid the check for null ptr. pCtx[j].fpSet.finalize(&pCtx[j]); } @@ -3765,8 +3773,7 @@ void setResultRowOutputBufInitCtx(STaskRuntimeEnv* pRuntimeEnv, SResultRow* pRes } } -void setResultRowOutputBufInitCtx_rv(SDiskbasedBuf* pBuf, SResultRow* pResult, SqlFunctionCtx* pCtx, - int32_t numOfOutput, int32_t* rowCellInfoOffset) { +void setResultRowOutputBufInitCtx_rv(SResultRow* pResult, SqlFunctionCtx* pCtx, int32_t numOfOutput, int32_t* rowCellInfoOffset) { for (int32_t i = 0; i < numOfOutput; ++i) { pCtx[i].resultInfo = getResultCell(pResult, i, rowCellInfoOffset); @@ -3779,18 +3786,13 @@ void setResultRowOutputBufInitCtx_rv(SDiskbasedBuf* pBuf, SResultRow* pResult, S continue; } - // if (functionId == FUNCTION_TOP || functionId == FUNCTION_BOTTOM || functionId == FUNCTION_DIFF) { - // if (i > 0) pCtx[i].ptsOutputBuf = pCtx[i - 1].pOutput; - // } - if (!pResInfo->initialized && pCtx[i].functionId != -1) { pCtx[i].fpSet.init(&pCtx[i], pResInfo); } } } -void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, int32_t tableGroupId, - SExecTaskInfo* pTaskInfo) { +void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, int32_t tableGroupId, SExecTaskInfo* pTaskInfo) { // for simple group by query without interval, all the tables belong to one group result. int64_t uid = 0; int64_t tid = 0; @@ -3809,14 +3811,13 @@ void doSetTableGroupOutputBuf(SAggOperatorInfo* pAggInfo, int32_t numOfOutput, i * all group belong to one result set, and each group result has different group id so set the id to be one */ if (pResultRow->pageId == -1) { - int32_t ret = - addNewWindowResultBuf(pResultRow, pAggInfo->pResultBuf, tableGroupId, pAggInfo->binfo.pRes->info.rowSize); + int32_t ret = addNewWindowResultBuf(pResultRow, pAggInfo->pResultBuf, tableGroupId, pAggInfo->binfo.pRes->info.rowSize); if (ret != TSDB_CODE_SUCCESS) { return; } } - setResultRowOutputBufInitCtx_rv(pAggInfo->pResultBuf, pResultRow, pCtx, numOfOutput, rowCellInfoOffset); + setResultRowOutputBufInitCtx_rv(pResultRow, pCtx, numOfOutput, rowCellInfoOffset); } void setExecutionContext(int32_t numOfOutput, int32_t tableGroupId, TSKEY nextKey, SExecTaskInfo* pTaskInfo, @@ -4132,7 +4133,7 @@ static void updateNumOfRowsInResultRows(SqlFunctionCtx* pCtx, int32_t numOfOutpu // if (QUERY_IS_INTERVAL_QUERY(pQueryAttr)) { // return; // } - +#if 0 for (int32_t i = 0; i < pResultRowInfo->size; ++i) { SResultRow* pResult = pResultRowInfo->pResult[i]; @@ -4146,6 +4147,8 @@ static void updateNumOfRowsInResultRows(SqlFunctionCtx* pCtx, int32_t numOfOutpu pResult->numOfRows = (uint16_t)(TMAX(pResult->numOfRows, pCell->numOfRes)); } } +#endif + } static int32_t compressQueryColData(SColumnInfoData* pColRes, int32_t numOfRows, char* data, int8_t compressed) { @@ -5001,12 +5004,16 @@ static SSDataBlock* doStreamBlockScan(SOperatorInfo* pOperator, bool* newgroup) int32_t loadRemoteDataCallback(void* param, const SDataBuf* pMsg, int32_t code) { SSourceDataInfo* pSourceDataInfo = (SSourceDataInfo*)param; - pSourceDataInfo->pRsp = pMsg->pData; + if (code == TSDB_CODE_SUCCESS) { + pSourceDataInfo->pRsp = pMsg->pData; - SRetrieveTableRsp* pRsp = pSourceDataInfo->pRsp; - pRsp->numOfRows = htonl(pRsp->numOfRows); - pRsp->useconds = htobe64(pRsp->useconds); - pRsp->compLen = htonl(pRsp->compLen); + SRetrieveTableRsp* pRsp = pSourceDataInfo->pRsp; + pRsp->numOfRows = htonl(pRsp->numOfRows); + pRsp->compLen = htonl(pRsp->compLen); + pRsp->useconds = htobe64(pRsp->useconds); + } else { + pSourceDataInfo->code = code; + } pSourceDataInfo->status = EX_SOURCE_DATA_READY; tsem_post(&pSourceDataInfo->pEx->ready); @@ -5262,7 +5269,6 @@ static SSDataBlock* concurrentlyLoadRemoteData(SOperatorInfo* pOperator) { totalSources, endTs - startTs); tsem_wait(&pExchangeInfo->ready); - pOperator->status = OP_RES_TO_RETURN; return concurrentlyLoadRemoteDataImpl(pOperator, pExchangeInfo, pTaskInfo); } @@ -5306,18 +5312,22 @@ static SSDataBlock* seqLoadRemoteData(SOperatorInfo* pOperator) { } doSendFetchDataRequest(pExchangeInfo, pTaskInfo, pExchangeInfo->current); - tsem_wait(&pExchangeInfo->ready); - SSourceDataInfo* pDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, pExchangeInfo->current); + SSourceDataInfo* pDataInfo = taosArrayGet(pExchangeInfo->pSourceDataInfo, pExchangeInfo->current); SDownstreamSourceNode* pSource = taosArrayGet(pExchangeInfo->pSources, pExchangeInfo->current); + if (pDataInfo->code != TSDB_CODE_SUCCESS) { + qError("%s vgId:%d, taskID:0x%" PRIx64 " error happens, code:%s", + GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, tstrerror(pDataInfo->code)); + pOperator->pTaskInfo->code = pDataInfo->code; + return NULL; + } + SRetrieveTableRsp* pRsp = pDataInfo->pRsp; SLoadRemoteDataInfo* pLoadInfo = &pExchangeInfo->loadInfo; - if (pRsp->numOfRows == 0) { - qDebug("%s vgId:%d, taskID:0x%" PRIx64 " %d of total completed, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64 - " try next", + qDebug("%s vgId:%d, taskID:0x%" PRIx64 " %d of total completed, rowsOfSource:%" PRIu64 ", totalRows:%" PRIu64 " try next", GET_TASKID(pTaskInfo), pSource->addr.nodeId, pSource->taskId, pExchangeInfo->current + 1, pDataInfo->totalRows, pLoadInfo->totalRows); @@ -7585,10 +7595,10 @@ static void destroyOperatorInfo(SOperatorInfo* pOperator) { int32_t doInitAggInfoSup(SAggSupporter* pAggSup, SqlFunctionCtx* pCtx, int32_t numOfOutput, const char* pKey) { _hash_fn_t hashFn = taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY); - pAggSup->resultRowSize = getResultRowSize(pCtx, numOfOutput); - pAggSup->keyBuf = taosMemoryCalloc(1, sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES); + pAggSup->resultRowSize = getResultRowSize(pCtx, numOfOutput); + pAggSup->keyBuf = taosMemoryCalloc(1, sizeof(int64_t) + sizeof(int64_t) + POINTER_BYTES); pAggSup->pResultRowHashTable = taosHashInit(10, hashFn, true, HASH_NO_LOCK); - pAggSup->pResultRowListSet = taosHashInit(100, hashFn, false, HASH_NO_LOCK); + pAggSup->pResultRowListSet = taosHashInit(100, hashFn, false, HASH_NO_LOCK); pAggSup->pResultRowArrayList = taosArrayInit(10, sizeof(SResultRowCell)); if (pAggSup->keyBuf == NULL || pAggSup->pResultRowArrayList == NULL || pAggSup->pResultRowListSet == NULL || @@ -8761,8 +8771,8 @@ SExprInfo* createExprInfo(SNodeList* pNodeList, SNodeList* pGroupKeys, int32_t* pExp->pExpr->_optrRoot.pRootNode = pTargetNode->pExpr; - pExp->base.pParam[0].type = FUNC_PARAM_TYPE_COLUMN; - pExp->base.pParam[0].pCol = createColumn(pTargetNode->dataBlockId, pTargetNode->slotId, pType); +// pExp->base.pParam[0].type = FUNC_PARAM_TYPE_COLUMN; +// pExp->base.pParam[0].pCol = createColumn(pTargetNode->dataBlockId, pTargetNode->slotId, pType); } else { ASSERT(0); } diff --git a/source/libs/index/inc/indexFstRegex.h b/source/libs/index/inc/indexFstRegex.h index 50b9cae7ff..8fb5455336 100644 --- a/source/libs/index/inc/indexFstRegex.h +++ b/source/libs/index/inc/indexFstRegex.h @@ -63,9 +63,10 @@ typedef struct { FstRegex *regexCreate(const char *str); -void regexSetup(FstRegex *regex, uint32_t size, const char *str); - -// uint32_t regexStart() +uint32_t regexAutomStart(FstRegex *regex); +bool regexAutomIsMatch(FstRegex *regex, uint32_t state); +bool regexAutomCanMatch(FstRegex *regex, uint32_t state, bool null); +bool regexAutomAccept(FstRegex *regex, uint32_t state, uint8_t byte, uint32_t *result); #ifdef __cplusplus } diff --git a/source/libs/index/inc/indexFstSparse.h b/source/libs/index/inc/indexFstSparse.h index 69b33c82d9..665fb2ba5c 100644 --- a/source/libs/index/inc/indexFstSparse.h +++ b/source/libs/index/inc/indexFstSparse.h @@ -23,9 +23,9 @@ extern "C" { #endif typedef struct FstSparseSet { - SArray *dense; - SArray *sparse; - int32_t size; + uint32_t *dense; + uint32_t *sparse; + int32_t size; } FstSparseSet; FstSparseSet *sparSetCreate(int32_t sz); diff --git a/source/libs/index/src/index.c b/source/libs/index/src/index.c index d3ca3a1acf..7d52abcd1b 100644 --- a/source/libs/index/src/index.c +++ b/source/libs/index/src/index.c @@ -27,7 +27,7 @@ #endif #define INDEX_NUM_OF_THREADS 4 -#define INDEX_QUEUE_SIZE 200 +#define INDEX_QUEUE_SIZE 200 void* indexQhandle = NULL; diff --git a/source/libs/index/src/indexCache.c b/source/libs/index/src/indexCache.c index ca26cf38e5..df3c0b6e7b 100644 --- a/source/libs/index/src/indexCache.c +++ b/source/libs/index/src/indexCache.c @@ -21,8 +21,8 @@ #define MAX_INDEX_KEY_LEN 256 // test only, change later -#define MEM_TERM_LIMIT 10 * 10000 -#define MEM_THRESHOLD 1024 * 1024 +#define MEM_TERM_LIMIT 10 * 10000 +#define MEM_THRESHOLD 1024 * 1024 #define MEM_ESTIMATE_RADIO 1.5 static void indexMemRef(MemTable* tbl); diff --git a/source/libs/index/src/indexFstCommon.c b/source/libs/index/src/indexFstCommon.c index e2544c7ac3..902e68ce09 100644 --- a/source/libs/index/src/indexFstCommon.c +++ b/source/libs/index/src/indexFstCommon.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019 TAOS Data, Inc. +YAML:9:25: error: unknown key 'AlignConsecutiveMacros' * 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 diff --git a/source/libs/index/src/indexFstRegex.c b/source/libs/index/src/indexFstRegex.c index ec41a7f58e..33eeae802e 100644 --- a/source/libs/index/src/indexFstRegex.c +++ b/source/libs/index/src/indexFstRegex.c @@ -14,6 +14,7 @@ */ #include "indexFstRegex.h" +#include "indexFstDfa.h" #include "indexFstSparse.h" FstRegex *regexCreate(const char *str) { @@ -26,9 +27,35 @@ FstRegex *regexCreate(const char *str) { memcpy(orig, str, sz); regex->orig = orig; + + // construct insts based on str + SArray *insts = NULL; + + FstDfaBuilder *builder = dfaBuilderCreate(insts); + regex->dfa = dfaBuilderBuild(builder); + return regex; } -void regexSetup(FstRegex *regex, uint32_t size, const char *str) { - // return - // return; +uint32_t regexAutomStart(FstRegex *regex) { + ///// no nothing + return 0; +} +bool regexAutomIsMatch(FstRegex *regex, uint32_t state) { + if (regex->dfa != NULL && dfaIsMatch(regex->dfa, state)) { + return true; + } else { + return false; + } +} + +bool regexAutomCanMatch(FstRegex *regex, uint32_t state, bool null) { + // make frame happy + return null; +} + +bool regexAutomAccept(FstRegex *regex, uint32_t state, uint8_t byte, uint32_t *result) { + if (regex->dfa == NULL) { + return false; + } + return dfaAccept(regex->dfa, state, byte, result); } diff --git a/source/libs/index/src/indexSparse.c b/source/libs/index/src/indexFstSparse.c similarity index 65% rename from source/libs/index/src/indexSparse.c rename to source/libs/index/src/indexFstSparse.c index 9d228e71ff..e8ab3be2fe 100644 --- a/source/libs/index/src/indexSparse.c +++ b/source/libs/index/src/indexFstSparse.c @@ -21,47 +21,44 @@ FstSparseSet *sparSetCreate(int32_t sz) { return NULL; } - ss->dense = taosArrayInit(sz, sizeof(uint32_t)); - ss->sparse = taosArrayInit(sz, sizeof(uint32_t)); - ss->size = sz; + ss->dense = (uint32_t *)taosMemoryCalloc(sz, sizeof(uint32_t)); + ss->sparse = (uint32_t *)taosMemoryCalloc(sz, sizeof(uint32_t)); + ss->size = 0; return ss; } void sparSetDestroy(FstSparseSet *ss) { if (ss == NULL) { return; } - taosArrayDestroy(ss->dense); - taosArrayDestroy(ss->sparse); + taosMemoryFree(ss->dense); + taosMemoryFree(ss->sparse); taosMemoryFree(ss); } -uint32_t sparSetLen(FstSparseSet *ss) { return ss == NULL ? 0 : ss->size; } +uint32_t sparSetLen(FstSparseSet *ss) { + // Get occupied size + return ss == NULL ? 0 : ss->size; +} uint32_t sparSetAdd(FstSparseSet *ss, uint32_t ip) { if (ss == NULL) { return 0; } uint32_t i = ss->size; - taosArraySet(ss->dense, i, &ip); - taosArraySet(ss->sparse, ip, &i); + ss->dense[i] = ip; + ss->sparse[ip] = i; ss->size += 1; return i; } uint32_t sparSetGet(FstSparseSet *ss, uint32_t i) { - if (i >= taosArrayGetSize(ss->dense)) { - return 0; - } - uint32_t *v = taosArrayGet(ss->dense, i); - return *v; + // check later + return ss->dense[i]; } bool sparSetContains(FstSparseSet *ss, uint32_t ip) { - if (ip >= taosArrayGetSize(ss->sparse)) { + uint32_t i = ss->sparse[ip]; + if (i < ss->size && ss->dense[i] == ip) { + return true; + } else { return false; } - uint32_t i = *(uint32_t *)taosArrayGet(ss->sparse, ip); - if (i >= taosArrayGetSize(ss->dense)) { - return false; - } - uint32_t v = *(uint32_t *)taosArrayGet(ss->dense, i); - return v == ip; } void sparSetClear(FstSparseSet *ss) { if (ss == NULL) { diff --git a/source/libs/nodes/inc/nodesUtil.h b/source/libs/nodes/inc/nodesUtil.h index de00b6bca4..976044c16f 100644 --- a/source/libs/nodes/inc/nodesUtil.h +++ b/source/libs/nodes/inc/nodesUtil.h @@ -20,12 +20,16 @@ extern "C" { #endif -#define nodesFatal(param, ...) qFatal("NODES: " param, __VA_ARGS__) -#define nodesError(param, ...) qError("NODES: " param, __VA_ARGS__) -#define nodesWarn(param, ...) qWarn("NODES: " param, __VA_ARGS__) -#define nodesInfo(param, ...) qInfo("NODES: " param, __VA_ARGS__) -#define nodesDebug(param, ...) qDebug("NODES: " param, __VA_ARGS__) -#define nodesTrace(param, ...) qTrace("NODES: " param, __VA_ARGS__) +#define nodesFatal(...) qFatal("NODES: " __VA_ARGS__) +#define nodesError(...) qError("NODES: " __VA_ARGS__) +#define nodesWarn(...) qWarn("NODES: " __VA_ARGS__) +#define nodesInfo(...) qInfo("NODES: " __VA_ARGS__) +#define nodesDebug(...) qDebug("NODES: " __VA_ARGS__) +#define nodesTrace(...) qTrace("NODES: " __VA_ARGS__) + +#define NODES_ERR_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; return _code; } } while (0) +#define NODES_RET(c) do { int32_t _code = c; if (_code != TSDB_CODE_SUCCESS) { terrno = _code; } return _code; } while (0) +#define NODES_ERR_JRET(c) do { code = c; if (code != TSDB_CODE_SUCCESS) { terrno = code; goto _return; } } while (0) #ifdef __cplusplus } diff --git a/source/libs/nodes/src/nodesToSQLFuncs.c b/source/libs/nodes/src/nodesToSQLFuncs.c new file mode 100644 index 0000000000..68f38bb6a7 --- /dev/null +++ b/source/libs/nodes/src/nodesToSQLFuncs.c @@ -0,0 +1,145 @@ +/* + * 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 "cmdnodes.h" +#include "nodesUtil.h" +#include "plannodes.h" +#include "querynodes.h" +#include "taos.h" +#include "taoserror.h" +#include "thash.h" + +char *gOperatorStr[] = {NULL, "+", "-", "*", "/", "%", "&", "|", ">", ">=", "<", "<=", "=", "<>", + "IN", "NOT IN", "LIKE", "NOT LIKE", "MATCH", "NMATCH", "IS NULL", "IS NOT NULL", + "IS TRUE", "IS FALSE", "IS UNKNOWN", "IS NOT TRUE", "IS NOT FALSE", "IS NOT UNKNOWN"}; +char *gLogicConditionStr[] = {"AND", "OR", "NOT"}; + +int32_t nodesNodeToSQL(SNode *pNode, char *buf, int32_t bufSize, int32_t *len) { + switch (pNode->type) { + case QUERY_NODE_COLUMN: { + SColumnNode *colNode = (SColumnNode *)pNode; + if (colNode->dbName[0]) { + *len += snprintf(buf + *len, bufSize - *len, "`%s`.", colNode->dbName); + } + + if (colNode->tableAlias[0]) { + *len += snprintf(buf + *len, bufSize - *len, "`%s`.", colNode->tableAlias); + } else if (colNode->tableName[0]) { + *len += snprintf(buf + *len, bufSize - *len, "`%s`.", colNode->tableName); + } + + *len += snprintf(buf + *len, bufSize - *len, "`%s`", colNode->colName); + + return TSDB_CODE_SUCCESS; + } + case QUERY_NODE_VALUE:{ + SValueNode *colNode = (SValueNode *)pNode; + char *t = nodesGetStrValueFromNode(colNode); + if (NULL == t) { + nodesError("fail to get str value from valueNode"); + NODES_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + } + + *len += snprintf(buf + *len, bufSize - *len, "%s", t); + taosMemoryFree(t); + + return TSDB_CODE_SUCCESS; + } + case QUERY_NODE_OPERATOR: { + SOperatorNode* pOpNode = (SOperatorNode*)pNode; + *len += snprintf(buf + *len, bufSize - *len, "("); + if (pOpNode->pLeft) { + NODES_ERR_RET(nodesNodeToSQL(pOpNode->pLeft, buf, bufSize, len)); + } + + if (pOpNode->opType >= (sizeof(gOperatorStr) / sizeof(gOperatorStr[0]))) { + nodesError("unknown operation type:%d", pOpNode->opType); + NODES_ERR_RET(TSDB_CODE_QRY_APP_ERROR); + } + + *len += snprintf(buf + *len, bufSize - *len, " %s ", gOperatorStr[pOpNode->opType]); + + if (pOpNode->pRight) { + NODES_ERR_RET(nodesNodeToSQL(pOpNode->pRight, buf, bufSize, len)); + } + + *len += snprintf(buf + *len, bufSize - *len, ")"); + + return TSDB_CODE_SUCCESS; + } + case QUERY_NODE_LOGIC_CONDITION:{ + SLogicConditionNode* pLogicNode = (SLogicConditionNode*)pNode; + SNode* node = NULL; + bool first = true; + + *len += snprintf(buf + *len, bufSize - *len, "("); + + FOREACH(node, pLogicNode->pParameterList) { + if (!first) { + *len += snprintf(buf + *len, bufSize - *len, " %s ", gLogicConditionStr[pLogicNode->condType]); + } + NODES_ERR_RET(nodesNodeToSQL(node, buf, bufSize, len)); + first = false; + } + + *len += snprintf(buf + *len, bufSize - *len, ")"); + + return TSDB_CODE_SUCCESS; + } + case QUERY_NODE_FUNCTION:{ + SFunctionNode* pFuncNode = (SFunctionNode*)pNode; + SNode* node = NULL; + bool first = true; + + *len += snprintf(buf + *len, bufSize - *len, "%s(", pFuncNode->functionName); + + FOREACH(node, pFuncNode->pParameterList) { + if (!first) { + *len += snprintf(buf + *len, bufSize - *len, ", "); + } + NODES_ERR_RET(nodesNodeToSQL(node, buf, bufSize, len)); + first = false; + } + + *len += snprintf(buf + *len, bufSize - *len, ")"); + + return TSDB_CODE_SUCCESS; + } + case QUERY_NODE_NODE_LIST:{ + SNodeListNode* pListNode = (SNodeListNode *)pNode; + SNode* node = NULL; + bool first = true; + + *len += snprintf(buf + *len, bufSize - *len, "("); + + FOREACH(node, pListNode->pNodeList) { + if (!first) { + *len += snprintf(buf + *len, bufSize - *len, ", "); + } + NODES_ERR_RET(nodesNodeToSQL(node, buf, bufSize, len)); + first = false; + } + + *len += snprintf(buf + *len, bufSize - *len, ")"); + + return TSDB_CODE_SUCCESS; + } + default: + break; + } + + nodesError("nodesNodeToSQL unknown node = %s", nodesNodeName(pNode->type)); + NODES_RET(TSDB_CODE_QRY_APP_ERROR); +} diff --git a/source/libs/nodes/src/nodesTraverseFuncs.c b/source/libs/nodes/src/nodesTraverseFuncs.c index 7eaa049946..bbd0473edd 100644 --- a/source/libs/nodes/src/nodesTraverseFuncs.c +++ b/source/libs/nodes/src/nodesTraverseFuncs.c @@ -17,7 +17,8 @@ typedef enum ETraversalOrder { TRAVERSAL_PREORDER = 1, - TRAVERSAL_POSTORDER + TRAVERSAL_INORDER, + TRAVERSAL_POSTORDER, } ETraversalOrder; static EDealRes walkList(SNodeList* pNodeList, ETraversalOrder order, FNodeWalker walker, void* pContext); diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 799d07e5d9..732d9acfbe 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -790,6 +790,71 @@ void* nodesGetValueFromNode(SValueNode *pNode) { return NULL; } +char* nodesGetStrValueFromNode(SValueNode *pNode) { + switch (pNode->node.resType.type) { + case TSDB_DATA_TYPE_BOOL: { + void *buf = taosMemoryMalloc(MAX_NUM_STR_SIZE); + if (NULL == buf) { + return NULL; + } + + sprintf(buf, "%s", pNode->datum.b ? "true" : "false"); + return buf; + } + case TSDB_DATA_TYPE_TINYINT: + case TSDB_DATA_TYPE_SMALLINT: + case TSDB_DATA_TYPE_INT: + case TSDB_DATA_TYPE_BIGINT: + case TSDB_DATA_TYPE_TIMESTAMP: { + void *buf = taosMemoryMalloc(MAX_NUM_STR_SIZE); + if (NULL == buf) { + return NULL; + } + + sprintf(buf, "%" PRId64, pNode->datum.i); + return buf; + } + case TSDB_DATA_TYPE_UTINYINT: + case TSDB_DATA_TYPE_USMALLINT: + case TSDB_DATA_TYPE_UINT: + case TSDB_DATA_TYPE_UBIGINT: { + void *buf = taosMemoryMalloc(MAX_NUM_STR_SIZE); + if (NULL == buf) { + return NULL; + } + + sprintf(buf, "%" PRIu64, pNode->datum.u); + return buf; + } + case TSDB_DATA_TYPE_FLOAT: + case TSDB_DATA_TYPE_DOUBLE: { + void *buf = taosMemoryMalloc(MAX_NUM_STR_SIZE); + if (NULL == buf) { + return NULL; + } + + sprintf(buf, "%e", pNode->datum.d); + return buf; + } + case TSDB_DATA_TYPE_NCHAR: + case TSDB_DATA_TYPE_VARCHAR: + case TSDB_DATA_TYPE_VARBINARY: { + int32_t bufSize = varDataLen(pNode->datum.p) + 2 + 1; + void *buf = taosMemoryMalloc(bufSize); + if (NULL == buf) { + return NULL; + } + + snprintf(buf, bufSize, "'%s'", varDataVal(pNode->datum.p)); + return buf; + } + default: + break; + } + + return NULL; +} + bool nodesIsExprNode(const SNode* pNode) { ENodeType type = nodeType(pNode); return (QUERY_NODE_COLUMN == type || QUERY_NODE_VALUE == type || QUERY_NODE_OPERATOR == type || QUERY_NODE_FUNCTION == type); diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index 9ad089f38e..1fce11acdf 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -71,6 +71,7 @@ typedef enum ETableOptionType { typedef struct SAlterOption { int32_t type; SToken val; + SNodeList* pKeep; } SAlterOption; extern SToken nil_token; @@ -121,6 +122,8 @@ SNode* createSetOperator(SAstCreateContext* pCxt, ESetOperatorType type, SNode* SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt); SNode* createDefaultAlterDatabaseOptions(SAstCreateContext* pCxt); SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOptionType type, const SToken* pVal); +SNode* setDatabaseKeepOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pKeep); +SNode* setDatabaseAlterOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOption* pAlterOption); SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, SToken* pDbName, SNode* pOptions); SNode* createDropDatabaseStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SToken* pDbName); SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode* pOptions); @@ -129,6 +132,8 @@ SNode* createDefaultAlterTableOptions(SAstCreateContext* pCxt); SNode* setTableOption(SAstCreateContext* pCxt, SNode* pOptions, ETableOptionType type, const SToken* pVal); SNode* setTableSmaOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pSma); SNode* setTableRollupOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pFuncs); +SNode* setTableKeepOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pKeep); +SNode* setTableAlterOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOption* pAlterOption); 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); @@ -145,6 +150,8 @@ SNode* createAlterTableRenameCol(SAstCreateContext* pCxt, SNode* pRealTable, int SNode* createAlterTableSetTag(SAstCreateContext* pCxt, SNode* pRealTable, const SToken* pTagName, SNode* pVal); SNode* createUseDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName); SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, SNode* pTbNamePattern); +SNode* createShowCreateDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName); +SNode* createShowCreateTableStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pRealTable); SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword); SNode* createAlterUserStmt(SAstCreateContext* pCxt, SToken* pUserName, int8_t alterType, const SToken* pVal); SNode* createDropUserStmt(SAstCreateContext* pCxt, SToken* pUserName); @@ -165,6 +172,16 @@ SNode* setExplainRatio(SAstCreateContext* pCxt, SNode* pOptions, const SToken* p SNode* createExplainStmt(SAstCreateContext* pCxt, bool analyze, SNode* pOptions, SNode* pQuery); SNode* createDescribeStmt(SAstCreateContext* pCxt, SNode* pRealTable); SNode* createResetQueryCacheStmt(SAstCreateContext* pCxt); +SNode* createCompactStmt(SAstCreateContext* pCxt, SNodeList* pVgroups); +SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool aggFunc, const SToken* pFuncName, const SToken* pLibPath, SDataType dataType, int32_t bufSize); +SNode* createDropFunctionStmt(SAstCreateContext* pCxt, const SToken* pFuncName); +SNode* createCreateStreamStmt(SAstCreateContext* pCxt, const SToken* pStreamName, const SToken* pTableName, SNode* pQuery); +SNode* createDropStreamStmt(SAstCreateContext* pCxt, const SToken* pStreamName); +SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId); +SNode* createMergeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId1, const SToken* pVgId2); +SNode* createRedistributeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId, SNodeList* pDnodes); +SNode* createSplitVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId); +SNode* createSyncdbStmt(SAstCreateContext* pCxt, const SToken* pDbName); #ifdef __cplusplus } diff --git a/source/libs/parser/inc/parInsertData.h b/source/libs/parser/inc/parInsertData.h index a38d64c58c..dbf7d379ec 100644 --- a/source/libs/parser/inc/parInsertData.h +++ b/source/libs/parser/inc/parInsertData.h @@ -78,8 +78,6 @@ typedef struct STableDataBlocks { char *pData; bool cloned; STagData tagData; - char tableName[TSDB_TABLE_NAME_LEN]; - char dbFName[TSDB_DB_FNAME_LEN]; SParsedDataColInfo boundColumnInfo; SRowBuilder rowBuilder; diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y index 60c3e29913..29b1d8857a 100644 --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -137,7 +137,7 @@ db_options(A) ::= db_options(B) DAYS NK_INTEGER(C). db_options(A) ::= db_options(B) FSYNC NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_FSYNC, &C); } db_options(A) ::= db_options(B) MAXROWS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_MAXROWS, &C); } db_options(A) ::= db_options(B) MINROWS NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_MINROWS, &C); } -db_options(A) ::= db_options(B) KEEP NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_KEEP, &C); } +db_options(A) ::= db_options(B) KEEP integer_list(C). { A = setDatabaseKeepOption(pCxt, B, C); } db_options(A) ::= db_options(B) PRECISION NK_STRING(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_PRECISION, &C); } db_options(A) ::= db_options(B) QUORUM NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_QUORUM, &C); } db_options(A) ::= db_options(B) REPLICA NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_REPLICA, &C); } @@ -148,17 +148,23 @@ db_options(A) ::= db_options(B) SINGLE_STABLE NK_INTEGER(C). db_options(A) ::= db_options(B) STREAM_MODE NK_INTEGER(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_STREAM_MODE, &C); } db_options(A) ::= db_options(B) RETENTIONS NK_STRING(C). { A = setDatabaseOption(pCxt, B, DB_OPTION_RETENTIONS, &C); } -alter_db_options(A) ::= alter_db_option(B). { A = createDefaultAlterDatabaseOptions(pCxt); A = setDatabaseOption(pCxt, A, B.type, &B.val); } -alter_db_options(A) ::= alter_db_options(B) alter_db_option(C). { A = setDatabaseOption(pCxt, B, C.type, &C.val); } +alter_db_options(A) ::= alter_db_option(B). { A = createDefaultAlterDatabaseOptions(pCxt); A = setDatabaseAlterOption(pCxt, A, &B); } +alter_db_options(A) ::= alter_db_options(B) alter_db_option(C). { A = setDatabaseAlterOption(pCxt, B, &C); } %type alter_db_option { SAlterOption } %destructor alter_db_option { } alter_db_option(A) ::= BLOCKS NK_INTEGER(B). { A.type = DB_OPTION_BLOCKS; A.val = B; } alter_db_option(A) ::= FSYNC NK_INTEGER(B). { A.type = DB_OPTION_FSYNC; A.val = B; } -alter_db_option(A) ::= KEEP NK_INTEGER(B). { A.type = DB_OPTION_KEEP; A.val = B; } +alter_db_option(A) ::= KEEP integer_list(B). { A.type = DB_OPTION_KEEP; A.pKeep = B; } alter_db_option(A) ::= WAL NK_INTEGER(B). { A.type = DB_OPTION_WAL; A.val = B; } alter_db_option(A) ::= QUORUM NK_INTEGER(B). { A.type = DB_OPTION_QUORUM; A.val = B; } alter_db_option(A) ::= CACHELAST NK_INTEGER(B). { A.type = DB_OPTION_CACHELAST; A.val = B; } +alter_db_option(A) ::= REPLICA NK_INTEGER(B). { A.type = DB_OPTION_REPLICA; A.val = B; } + +%type integer_list { SNodeList* } +%destructor integer_list { nodesDestroyList($$); } +integer_list(A) ::= NK_INTEGER(B). { A = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B)); } +integer_list(A) ::= integer_list(B) NK_COMMA NK_INTEGER(C). { A = addNodeToList(pCxt, B, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C)); } /************************************************ create/drop table/stable ********************************************/ cmd ::= CREATE TABLE not_exists_opt(A) full_table_name(B) @@ -259,20 +265,20 @@ tags_def(A) ::= TAGS NK_LP column_def_list(B) NK_RP. 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); } +table_options(A) ::= table_options(B) KEEP integer_list(C). { A = setTableKeepOption(pCxt, B, C); } table_options(A) ::= table_options(B) TTL NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_TTL, &C); } table_options(A) ::= table_options(B) SMA NK_LP col_name_list(C) NK_RP. { A = setTableSmaOption(pCxt, B, C); } table_options(A) ::= table_options(B) ROLLUP NK_LP func_name_list(C) NK_RP. { A = setTableRollupOption(pCxt, B, C); } table_options(A) ::= table_options(B) FILE_FACTOR NK_FLOAT(C). { A = setTableOption(pCxt, B, TABLE_OPTION_FILE_FACTOR, &C); } table_options(A) ::= table_options(B) DELAY NK_INTEGER(C). { A = setTableOption(pCxt, B, TABLE_OPTION_DELAY, &C); } -alter_table_options(A) ::= alter_table_option(B). { A = createDefaultAlterTableOptions(pCxt); A = setTableOption(pCxt, A, B.type, &B.val); } -alter_table_options(A) ::= alter_table_options(B) alter_table_option(C). { A = setTableOption(pCxt, B, C.type, &C.val); } +alter_table_options(A) ::= alter_table_option(B). { A = createDefaultAlterTableOptions(pCxt); A = setTableAlterOption(pCxt, A, &B); } +alter_table_options(A) ::= alter_table_options(B) alter_table_option(C). { A = setTableAlterOption(pCxt, B, &C); } %type alter_table_option { SAlterOption } %destructor alter_table_option { } alter_table_option(A) ::= COMMENT NK_STRING(B). { A.type = TABLE_OPTION_COMMENT; A.val = B; } -alter_table_option(A) ::= KEEP NK_INTEGER(B). { A.type = TABLE_OPTION_KEEP; A.val = B; } +alter_table_option(A) ::= KEEP integer_list(B). { A.type = TABLE_OPTION_KEEP; A.pKeep = B; } alter_table_option(A) ::= TTL NK_INTEGER(B). { A.type = TABLE_OPTION_TTL; A.val = B; } %type col_name_list { SNodeList* } @@ -295,6 +301,17 @@ cmd ::= SHOW QNODES. cmd ::= SHOW FUNCTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT, NULL, NULL); } cmd ::= SHOW INDEXES FROM table_name_cond(A) from_db_opt(B). { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, A, B); } cmd ::= SHOW STREAMS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT, NULL, NULL); } +cmd ::= SHOW ACCOUNTS. { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } +cmd ::= SHOW APPS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT, NULL, NULL); } +cmd ::= SHOW CONNECTIONS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT, NULL, NULL); } +cmd ::= SHOW LICENCE. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT, NULL, NULL); } +cmd ::= SHOW CREATE DATABASE db_name(A). { pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &A); } +cmd ::= SHOW CREATE TABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, A); } +cmd ::= SHOW CREATE STABLE full_table_name(A). { pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, A); } +cmd ::= SHOW QUERIES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT, NULL, NULL); } +cmd ::= SHOW SCORES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT, NULL, NULL); } +cmd ::= SHOW TOPICS. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT, NULL, NULL); } +cmd ::= SHOW VARIABLES. { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLE_STMT, NULL, NULL); } db_name_cond_opt(A) ::= . { A = createDefaultDatabaseCondValue(pCxt); } db_name_cond_opt(A) ::= db_name(B) NK_DOT. { A = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &B); } @@ -358,6 +375,45 @@ explain_options(A) ::= . explain_options(A) ::= explain_options(B) VERBOSE NK_BOOL(C). { A = setExplainVerbose(pCxt, B, &C); } explain_options(A) ::= explain_options(B) RATIO NK_FLOAT(C). { A = setExplainRatio(pCxt, B, &C); } +/************************************************ compact *************************************************************/ +cmd ::= COMPACT VNODES IN NK_LP integer_list(A) NK_RP. { pCxt->pRootNode = createCompactStmt(pCxt, A); } + +/************************************************ create/drop function ************************************************/ +cmd ::= CREATE agg_func_opt(A) FUNCTION function_name(B) + AS NK_STRING(C) OUTPUTTYPE type_name(D) bufsize_opt(E). { pCxt->pRootNode = createCreateFunctionStmt(pCxt, A, &B, &C, D, E); } +cmd ::= DROP FUNCTION function_name(A). { pCxt->pRootNode = createDropFunctionStmt(pCxt, &A); } + +%type agg_func_opt { bool } +%destructor agg_func_opt { } +agg_func_opt(A) ::= . { A = false; } +agg_func_opt(A) ::= AGGREGATE. { A = true; } + +%type bufsize_opt { int32_t } +%destructor bufsize_opt { } +bufsize_opt(A) ::= . { A = 0; } +bufsize_opt(A) ::= BUFSIZE NK_INTEGER(B). { A = strtol(B.z, NULL, 10); } + +/************************************************ create/drop stream **************************************************/ +cmd ::= CREATE STREAM stream_name(A) INTO table_name(B) AS query_expression(C). { pCxt->pRootNode = createCreateStreamStmt(pCxt, &A, &B, C); } +cmd ::= DROP STREAM stream_name(A). { pCxt->pRootNode = createDropStreamStmt(pCxt, &A); } + +/************************************************ kill connection/query ***********************************************/ +cmd ::= KILL CONNECTION NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &A); } +cmd ::= KILL QUERY NK_INTEGER(A). { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_QUERY_STMT, &A); } + +/************************************************ merge/redistribute/ vgroup ******************************************/ +cmd ::= MERGE VGROUP NK_INTEGER(A) NK_INTEGER(B). { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &A, &B); } +cmd ::= REDISTRIBUTE VGROUP NK_INTEGER(A) dnode_list(B). { pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &A, B); } +cmd ::= SPLIT VGROUP NK_INTEGER(A). { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &A); } + +%type dnode_list { SNodeList* } +%destructor dnode_list { nodesDestroyList($$); } +dnode_list(A) ::= DNODE NK_INTEGER(B). { A = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &B)); } +dnode_list(A) ::= dnode_list(B) DNODE NK_INTEGER(C). { A = addNodeToList(pCxt, B, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &C)); } + +/************************************************ syncdb **************************************************************/ +cmd ::= SYNCDB db_name(A) REPLICA. { pCxt->pRootNode = createSyncdbStmt(pCxt, &A); } + /************************************************ select **************************************************************/ cmd ::= query_expression(A). { pCxt->pRootNode = A; } @@ -436,6 +492,10 @@ index_name(A) ::= NK_ID(B). %destructor topic_name { } topic_name(A) ::= NK_ID(B). { A = B; } +%type stream_name { SToken } +%destructor stream_name { } +stream_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 7f3ba6d508..18a0ae8cfa 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -138,18 +138,6 @@ static SDatabaseOptions* setDbMinRows(SAstCreateContext* pCxt, SDatabaseOptions* return pOptions; } -static SDatabaseOptions* setDbKeep(SAstCreateContext* pCxt, SDatabaseOptions* pOptions, const SToken* pVal) { - int64_t val = strtol(pVal->z, NULL, 10); - if (val < TSDB_MIN_KEEP || val > TSDB_MAX_KEEP) { - snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, - "invalid db option keep: %"PRId64" valid range: [%d, %d]", val, TSDB_MIN_KEEP, TSDB_MAX_KEEP); - pCxt->valid = false; - return pOptions; - } - pOptions->keep = val; - return pOptions; -} - static SDatabaseOptions* setDbPrecision(SAstCreateContext* pCxt, SDatabaseOptions* pOptions, const SToken* pVal) { char val[10] = {0}; trimString(pVal->z, pVal->n, val, sizeof(val)); @@ -180,9 +168,9 @@ static SDatabaseOptions* setDbQuorum(SAstCreateContext* pCxt, SDatabaseOptions* static SDatabaseOptions* setDbReplica(SAstCreateContext* pCxt, SDatabaseOptions* pOptions, const SToken* pVal) { int64_t val = strtol(pVal->z, NULL, 10); - if (val < TSDB_MIN_DB_REPLICA_OPTION || val > TSDB_MAX_DB_REPLICA_OPTION) { + if (!(val == TSDB_MIN_DB_REPLICA_OPTION || val == TSDB_MAX_DB_REPLICA_OPTION)) { snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, - "invalid db option replications: %"PRId64" valid range: [%d, %d]", val, TSDB_MIN_DB_REPLICA_OPTION, TSDB_MAX_DB_REPLICA_OPTION); + "invalid db option replications: %"PRId64", only 1, 3 allowed", val); pCxt->valid = false; return pOptions; } @@ -291,7 +279,6 @@ static void initSetDatabaseOptionFp() { setDbOptionFuncs[DB_OPTION_FSYNC] = setDbFsync; setDbOptionFuncs[DB_OPTION_MAXROWS] = setDbMaxRows; setDbOptionFuncs[DB_OPTION_MINROWS] = setDbMinRows; - setDbOptionFuncs[DB_OPTION_KEEP] = setDbKeep; setDbOptionFuncs[DB_OPTION_PRECISION] = setDbPrecision; setDbOptionFuncs[DB_OPTION_QUORUM] = setDbQuorum; setDbOptionFuncs[DB_OPTION_REPLICA] = setDbReplica; @@ -303,18 +290,6 @@ static void initSetDatabaseOptionFp() { setDbOptionFuncs[DB_OPTION_RETENTIONS] = setDbRetentions; } -static STableOptions* setTableKeep(SAstCreateContext* pCxt, STableOptions* pOptions, const SToken* pVal) { - int64_t val = strtol(pVal->z, NULL, 10); - if (val < TSDB_MIN_KEEP || val > TSDB_MAX_KEEP) { - snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, - "invalid table option keep: %"PRId64" valid range: [%d, %d]", val, TSDB_MIN_KEEP, TSDB_MAX_KEEP); - pCxt->valid = false; - return pOptions; - } - pOptions->keep = val; - return pOptions; -} - static STableOptions* setTableTtl(SAstCreateContext* pCxt, STableOptions* pOptions, const SToken* pVal) { int64_t val = strtol(pVal->z, NULL, 10); if (val < TSDB_MIN_DB_TTL_OPTION) { @@ -363,7 +338,6 @@ static STableOptions* setTableDelay(SAstCreateContext* pCxt, STableOptions* pOpt } static void initSetTableOptionFp() { - setTableOptionFuncs[TABLE_OPTION_KEEP] = setTableKeep; setTableOptionFuncs[TABLE_OPTION_TTL] = setTableTtl; setTableOptionFuncs[TABLE_OPTION_COMMENT] = setTableComment; setTableOptionFuncs[TABLE_OPTION_FILE_FACTOR] = setTableFileFactor; @@ -397,7 +371,9 @@ static bool checkUserName(SAstCreateContext* pCxt, SToken* pUserName) { pCxt->valid = false; } } - trimEscape(pUserName); + if (pCxt->valid) { + trimEscape(pUserName); + } return pCxt->valid; } @@ -472,45 +448,50 @@ static bool checkPort(SAstCreateContext* pCxt, const SToken* pPortToken, int32_t static bool checkDbName(SAstCreateContext* pCxt, SToken* pDbName, bool query) { if (NULL == pDbName) { - pCxt->valid = (query ? NULL != pCxt->pQueryCxt->db : true); - if (!pCxt->valid) { - snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "db not specified"); + if (query && NULL == pCxt->pQueryCxt->db) { + generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_DB_NOT_SPECIFIED); + pCxt->valid = false; } } else { - pCxt->valid = pDbName->n < TSDB_DB_NAME_LEN ? true : false; + if (pDbName->n >= TSDB_DB_NAME_LEN) { + generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pDbName->z); + pCxt->valid = false; + } + } + if (pCxt->valid) { + trimEscape(pDbName); } - trimEscape(pDbName); return pCxt->valid; } static bool checkTableName(SAstCreateContext* pCxt, SToken* pTableName) { - if (NULL == pTableName) { - pCxt->valid = true; - } else { - pCxt->valid = pTableName->n < TSDB_TABLE_NAME_LEN ? true : false; + if (NULL != pTableName && pTableName->n >= TSDB_TABLE_NAME_LEN) { + generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pTableName->z); + pCxt->valid = false; + return false; } trimEscape(pTableName); - return pCxt->valid; + return true; } static bool checkColumnName(SAstCreateContext* pCxt, SToken* pColumnName) { - if (NULL == pColumnName) { - pCxt->valid = true; - } else { - pCxt->valid = pColumnName->n < TSDB_COL_NAME_LEN ? true : false; + if (NULL != pColumnName && pColumnName->n >= TSDB_COL_NAME_LEN) { + generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pColumnName->z); + pCxt->valid = false; + return false; } trimEscape(pColumnName); - return pCxt->valid; + return true; } static bool checkIndexName(SAstCreateContext* pCxt, SToken* pIndexName) { - if (NULL == pIndexName) { + if (NULL != pIndexName && pIndexName->n >= TSDB_INDEX_NAME_LEN) { + generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME, pIndexName->z); pCxt->valid = false; - } else { - pCxt->valid = pIndexName->n < TSDB_INDEX_NAME_LEN ? true : false; + return false; } trimEscape(pIndexName); - return pCxt->valid; + return true; } SNode* createRawExprNode(SAstCreateContext* pCxt, const SToken* pToken, SNode* pNode) { @@ -885,7 +866,9 @@ SNode* createDefaultDatabaseOptions(SAstCreateContext* pCxt) { pOptions->fsyncPeriod = TSDB_DEFAULT_FSYNC_PERIOD; pOptions->maxRowsPerBlock = TSDB_DEFAULT_MAX_ROW_FBLOCK; pOptions->minRowsPerBlock = TSDB_DEFAULT_MIN_ROW_FBLOCK; - pOptions->keep = TSDB_DEFAULT_KEEP; + pOptions->keep0 = TSDB_DEFAULT_KEEP; + pOptions->keep1 = TSDB_DEFAULT_KEEP; + pOptions->keep2 = TSDB_DEFAULT_KEEP; pOptions->precision = TSDB_TIME_PRECISION_MILLI; pOptions->quorum = TSDB_DEFAULT_DB_QUORUM_OPTION; pOptions->replica = TSDB_DEFAULT_DB_REPLICA_OPTION; @@ -908,7 +891,9 @@ SNode* createDefaultAlterDatabaseOptions(SAstCreateContext* pCxt) { pOptions->fsyncPeriod = -1; pOptions->maxRowsPerBlock = -1; pOptions->minRowsPerBlock = -1; - pOptions->keep = -1; + pOptions->keep0 = -1; + pOptions->keep1 = -1; + pOptions->keep2= -1; pOptions->precision = -1; pOptions->quorum = -1; pOptions->replica = -1; @@ -924,6 +909,48 @@ SNode* setDatabaseOption(SAstCreateContext* pCxt, SNode* pOptions, EDatabaseOpti return (SNode*)setDbOptionFuncs[type](pCxt, (SDatabaseOptions*)pOptions, pVal); } +static bool checkAndSetKeepOption(SAstCreateContext* pCxt, SNodeList* pKeep, int32_t* pKeep0, int32_t* pKeep1, int32_t* pKeep2) { + int32_t numOfKeep = LIST_LENGTH(pKeep); + if (numOfKeep > 3 || numOfKeep < 1) { + snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "invalid number of keep options"); + return false; + } + + int32_t daysToKeep0 = strtol(((SValueNode*)nodesListGetNode(pKeep, 0))->literal, NULL, 10); + int32_t daysToKeep1 = numOfKeep > 1 ? strtol(((SValueNode*)nodesListGetNode(pKeep, 1))->literal, NULL, 10) : daysToKeep0; + int32_t daysToKeep2 = numOfKeep > 2 ? strtol(((SValueNode*)nodesListGetNode(pKeep, 2))->literal, NULL, 10) : daysToKeep1; + if (daysToKeep0 < TSDB_MIN_KEEP || daysToKeep1 < TSDB_MIN_KEEP || daysToKeep2 < TSDB_MIN_KEEP || + daysToKeep0 > TSDB_MAX_KEEP || daysToKeep1 > TSDB_MAX_KEEP || daysToKeep2 > TSDB_MAX_KEEP) { + snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, + "invalid option keep: %d, %d, %d valid range: [%d, %d]", daysToKeep0, daysToKeep1, daysToKeep2, TSDB_MIN_KEEP, TSDB_MAX_KEEP); + return false; + } + + if (!((daysToKeep0 <= daysToKeep1) && (daysToKeep1 <= daysToKeep2))) { + snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "invalid keep value, should be keep0 <= keep1 <= keep2"); + return false; + } + + *pKeep0 = daysToKeep0; + *pKeep1 = daysToKeep1; + *pKeep2 = daysToKeep2; + return true; +} + +SNode* setDatabaseKeepOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pKeep) { + SDatabaseOptions* pOp = (SDatabaseOptions*)pOptions; + pCxt->valid = checkAndSetKeepOption(pCxt, pKeep, &pOp->keep0, &pOp->keep1, &pOp->keep2); + return pOptions; +} + +SNode* setDatabaseAlterOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOption* pAlterOption) { + if (DB_OPTION_KEEP == pAlterOption->type) { + return setDatabaseKeepOption(pCxt, pOptions, pAlterOption->pKeep); + } else { + return setDatabaseOption(pCxt, pOptions, pAlterOption->type, &pAlterOption->val); + } +} + SNode* createCreateDatabaseStmt(SAstCreateContext* pCxt, bool ignoreExists, SToken* pDbName, SNode* pOptions) { if (!checkDbName(pCxt, pDbName, false)) { return NULL; @@ -961,7 +988,9 @@ SNode* createAlterDatabaseStmt(SAstCreateContext* pCxt, SToken* pDbName, SNode* SNode* createDefaultTableOptions(SAstCreateContext* pCxt) { STableOptions* pOptions = nodesMakeNode(QUERY_NODE_TABLE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); - pOptions->keep = TSDB_DEFAULT_KEEP; + pOptions->keep0 = TSDB_DEFAULT_KEEP; + pOptions->keep1 = TSDB_DEFAULT_KEEP; + pOptions->keep2 = TSDB_DEFAULT_KEEP; pOptions->ttl = TSDB_DEFAULT_DB_TTL_OPTION; pOptions->filesFactor = TSDB_DEFAULT_DB_FILE_FACTOR; pOptions->delay = TSDB_DEFAULT_DB_DELAY; @@ -971,7 +1000,9 @@ SNode* createDefaultTableOptions(SAstCreateContext* pCxt) { SNode* createDefaultAlterTableOptions(SAstCreateContext* pCxt) { STableOptions* pOptions = nodesMakeNode(QUERY_NODE_TABLE_OPTIONS); CHECK_OUT_OF_MEM(pOptions); - pOptions->keep = -1; + pOptions->keep0 = -1; + pOptions->keep1 = -1; + pOptions->keep2 = -1; pOptions->ttl = -1; pOptions->filesFactor = -1; pOptions->delay = -1; @@ -997,6 +1028,20 @@ SNode* setTableRollupOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* return pOptions; } +SNode* setTableKeepOption(SAstCreateContext* pCxt, SNode* pOptions, SNodeList* pKeep) { + STableOptions* pOp = (STableOptions*)pOptions; + pCxt->valid = checkAndSetKeepOption(pCxt, pKeep, &pOp->keep0, &pOp->keep1, &pOp->keep2); + return pOptions; +} + +SNode* setTableAlterOption(SAstCreateContext* pCxt, SNode* pOptions, SAlterOption* pAlterOption) { + if (TABLE_OPTION_KEEP == pAlterOption->type) { + return setTableKeepOption(pCxt, pOptions, pAlterOption->pKeep); + } else { + return setTableOption(pCxt, pOptions, pAlterOption->type, &pAlterOption->val); + } +} + SNode* createColumnDefNode(SAstCreateContext* pCxt, const SToken* pColName, SDataType dataType, const SToken* pComment) { SColumnDefNode* pCol = (SColumnDefNode*)nodesMakeNode(QUERY_NODE_COLUMN_DEF); CHECK_OUT_OF_MEM(pCol); @@ -1176,6 +1221,18 @@ SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pDbName, S return (SNode*)pStmt; } +SNode* createShowCreateDatabaseStmt(SAstCreateContext* pCxt, const SToken* pDbName) { + SNode* pStmt = nodesMakeNode(QUERY_NODE_SHOW_CREATE_DATABASE_STMT); + CHECK_OUT_OF_MEM(pStmt); + return pStmt; +} + +SNode* createShowCreateTableStmt(SAstCreateContext* pCxt, ENodeType type, SNode* pRealTable) { + SNode* pStmt = nodesMakeNode(type); + CHECK_OUT_OF_MEM(pStmt); + return pStmt; +} + SNode* createCreateUserStmt(SAstCreateContext* pCxt, SToken* pUserName, const SToken* pPassword) { char password[TSDB_USET_PASSWORD_LEN] = {0}; if (!checkUserName(pCxt, pUserName) || !checkPassword(pCxt, pPassword, password)) { @@ -1388,3 +1445,63 @@ SNode* createResetQueryCacheStmt(SAstCreateContext* pCxt) { CHECK_OUT_OF_MEM(pStmt); return pStmt; } + +SNode* createCompactStmt(SAstCreateContext* pCxt, SNodeList* pVgroups) { + SNode* pStmt = nodesMakeNode(QUERY_NODE_COMPACT_STMT); + CHECK_OUT_OF_MEM(pStmt); + return pStmt; +} + +SNode* createCreateFunctionStmt(SAstCreateContext* pCxt, bool aggFunc, const SToken* pFuncName, const SToken* pLibPath, SDataType dataType, int32_t bufSize) { + SNode* pStmt = nodesMakeNode(QUERY_NODE_CREATE_FUNCTION_STMT); + CHECK_OUT_OF_MEM(pStmt); + return pStmt; +} + +SNode* createDropFunctionStmt(SAstCreateContext* pCxt, const SToken* pFuncName) { + SNode* pStmt = nodesMakeNode(QUERY_NODE_DROP_FUNCTION_STMT); + CHECK_OUT_OF_MEM(pStmt); + return pStmt; +} + +SNode* createCreateStreamStmt(SAstCreateContext* pCxt, const SToken* pStreamName, const SToken* pTableName, SNode* pQuery) { + SNode* pStmt = nodesMakeNode(QUERY_NODE_CREATE_STREAM_STMT); + CHECK_OUT_OF_MEM(pStmt); + return pStmt; +} + +SNode* createDropStreamStmt(SAstCreateContext* pCxt, const SToken* pStreamName) { + SNode* pStmt = nodesMakeNode(QUERY_NODE_DROP_STREAM_STMT); + CHECK_OUT_OF_MEM(pStmt); + return pStmt; +} + +SNode* createKillStmt(SAstCreateContext* pCxt, ENodeType type, const SToken* pId) { + SNode* pStmt = nodesMakeNode(type); + CHECK_OUT_OF_MEM(pStmt); + return pStmt; +} + +SNode* createMergeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId1, const SToken* pVgId2) { + SNode* pStmt = nodesMakeNode(QUERY_NODE_MERGE_VGROUP_STMT); + CHECK_OUT_OF_MEM(pStmt); + return pStmt; +} + +SNode* createRedistributeVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId, SNodeList* pDnodes) { + SNode* pStmt = nodesMakeNode(QUERY_NODE_REDISTRIBUTE_VGROUP_STMT); + CHECK_OUT_OF_MEM(pStmt); + return pStmt; +} + +SNode* createSplitVgroupStmt(SAstCreateContext* pCxt, const SToken* pVgId) { + SNode* pStmt = nodesMakeNode(QUERY_NODE_SPLIT_VGROUP_STMT); + CHECK_OUT_OF_MEM(pStmt); + return pStmt; +} + +SNode* createSyncdbStmt(SAstCreateContext* pCxt, const SToken* pDbName) { + SNode* pStmt = nodesMakeNode(QUERY_NODE_SYNCDB_STMT); + CHECK_OUT_OF_MEM(pStmt); + return pStmt; +} diff --git a/source/libs/parser/src/parInsert.c b/source/libs/parser/src/parInsert.c index e94dfd9e0a..11b552fb94 100644 --- a/source/libs/parser/src/parInsert.c +++ b/source/libs/parser/src/parInsert.c @@ -52,8 +52,6 @@ typedef struct SInsertParseContext { SParseContext* pComCxt; // input char *pSql; // input SMsgBuf msg; // input - char dbFName[TSDB_DB_FNAME_LEN]; - char tableName[TSDB_TABLE_NAME_LEN]; STableMeta* pTableMeta; // each table SParsedDataColInfo tags; // each table SKVRowBuilder tagsBuilder; // each table @@ -231,9 +229,6 @@ static int32_t getTableMeta(SInsertParseContext* pCxt, SToken* pTname) { SVgroupInfo vg; CHECK_CODE(catalogGetTableHashVgroup(pBasicCtx->pCatalog, pBasicCtx->pTransporter, &pBasicCtx->mgmtEpSet, &name, &vg)); CHECK_CODE(taosHashPut(pCxt->pVgroupsHashObj, (const char*)&vg.vgId, sizeof(vg.vgId), (char*)&vg, sizeof(vg))); - pCxt->pTableMeta->vgId = vg.vgId; // todo remove - strcpy(pCxt->tableName, name.tname); - tNameGetFullDbName(&name, pCxt->dbFName); return TSDB_CODE_SUCCESS; } @@ -977,8 +972,6 @@ static int32_t parseInsertBody(SInsertParseContext* pCxt) { STableDataBlocks *dataBuf = NULL; CHECK_CODE(getDataBlockFromList(pCxt->pTableBlockHashObj, pCxt->pTableMeta->uid, TSDB_DEFAULT_PAYLOAD_SIZE, sizeof(SSubmitBlk), getTableInfo(pCxt->pTableMeta).rowSize, pCxt->pTableMeta, &dataBuf, NULL)); - strcpy(dataBuf->tableName, pCxt->tableName); - strcpy(dataBuf->dbFName, pCxt->dbFName); if (TK_NK_LP == sToken.type) { // pSql -> field1_name, ...) diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 817db3592d..be2bd0d0b6 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -29,10 +29,14 @@ typedef struct SKeyword { // keywords in sql string static SKeyword keywordTable[] = { {"ACCOUNT", TK_ACCOUNT}, + {"ACCOUNTS", TK_ACCOUNTS}, + {"ADD", TK_ADD}, + {"AGGREGATE", TK_AGGREGATE}, {"ALL", TK_ALL}, {"ALTER", TK_ALTER}, {"ANALYZE", TK_ANALYZE}, {"AND", TK_AND}, + {"APPS", TK_APPS}, {"AS", TK_AS}, {"ASC", TK_ASC}, {"BETWEEN", TK_BETWEEN}, @@ -40,15 +44,22 @@ static SKeyword keywordTable[] = { {"BIGINT", TK_BIGINT}, {"BLOCKS", TK_BLOCKS}, {"BOOL", TK_BOOL}, + {"BUFSIZE", TK_BUFSIZE}, {"BY", TK_BY}, {"CACHE", TK_CACHE}, {"CACHELAST", TK_CACHELAST}, + {"COLUMN", TK_COLUMN}, {"COMMENT", TK_COMMENT}, {"COMP", TK_COMP}, + {"COMPACT", TK_COMPACT}, + {"CONNS", TK_CONNS}, + {"CONNECTION", TK_CONNECTION}, + {"CONNECTIONS", TK_CONNECTIONS}, {"CREATE", TK_CREATE}, {"DATABASE", TK_DATABASE}, {"DATABASES", TK_DATABASES}, {"DAYS", TK_DAYS}, + {"DBS", TK_DBS}, {"DELAY", TK_DELAY}, {"DESC", TK_DESC}, {"DESCRIBE", TK_DESCRIBE}, @@ -83,14 +94,18 @@ static SKeyword keywordTable[] = { {"JOIN", TK_JOIN}, {"JSON", TK_JSON}, {"KEEP", TK_KEEP}, + {"KILL", TK_KILL}, + {"LICENCE", TK_LICENCE}, {"LIKE", TK_LIKE}, {"LIMIT", TK_LIMIT}, {"LINEAR", TK_LINEAR}, + {"LOCAL", TK_LOCAL}, {"MATCH", TK_MATCH}, {"MAXROWS", TK_MAXROWS}, {"MINROWS", TK_MINROWS}, {"MINUS", TK_MINUS}, {"MNODES", TK_MNODES}, + {"MODIFY", TK_MODIFY}, {"MODULES", TK_MODULES}, {"NCHAR", TK_NCHAR}, {"NMATCH", TK_NMATCH}, @@ -102,9 +117,11 @@ static SKeyword keywordTable[] = { {"ON", TK_ON}, {"OR", TK_OR}, {"ORDER", TK_ORDER}, + {"OUTPUTTYPE", TK_OUTPUTTYPE}, {"PARTITION", TK_PARTITION}, {"PASS", TK_PASS}, {"PORT", TK_PORT}, + {"PPS", TK_PPS}, {"PRECISION", TK_PRECISION}, {"PRIVILEGE", TK_PRIVILEGE}, {"PREV", TK_PREV}, @@ -112,6 +129,8 @@ static SKeyword keywordTable[] = { {"QNODE", TK_QNODE}, {"QNODES", TK_QNODES}, {"QSTARTTS", TK_QSTARTTS}, + {"QTIME", TK_QTIME}, + {"QUERIES", TK_QUERIES}, {"QUERY", TK_QUERY}, {"QUORUM", TK_QUORUM}, {"RATIO", TK_RATIO}, @@ -120,8 +139,10 @@ static SKeyword keywordTable[] = { {"RETENTIONS", TK_RETENTIONS}, {"ROLLUP", TK_ROLLUP}, {"ROWTS", TK_ROWTS}, + {"SCORES", TK_SCORES}, {"SELECT", TK_SELECT}, {"SESSION", TK_SESSION}, + {"SET", TK_SET}, {"SHOW", TK_SHOW}, {"SINGLE_STABLE", TK_SINGLE_STABLE}, {"SLIDING", TK_SLIDING}, @@ -131,16 +152,23 @@ static SKeyword keywordTable[] = { {"SOFFSET", TK_SOFFSET}, {"STABLE", TK_STABLE}, {"STABLES", TK_STABLES}, + {"STATE", TK_STATE}, {"STATE_WINDOW", TK_STATE_WINDOW}, + {"STORAGE", TK_STORAGE}, + {"STREAM", TK_STREAM}, {"STREAMS", TK_STREAMS}, {"STREAM_MODE", TK_STREAM_MODE}, + {"SYNCDB", TK_SYNCDB}, {"TABLE", TK_TABLE}, {"TABLES", TK_TABLES}, + {"TAG", TK_TAG}, {"TAGS", TK_TAGS}, {"TBNAME", TK_TBNAME}, {"TIMESTAMP", TK_TIMESTAMP}, {"TINYINT", TK_TINYINT}, {"TOPIC", TK_TOPIC}, + {"TOPICS", TK_TOPICS}, + {"TSERIES", TK_TSERIES}, {"TTL", TK_TTL}, {"UNION", TK_UNION}, {"UNSIGNED", TK_UNSIGNED}, @@ -150,8 +178,10 @@ static SKeyword keywordTable[] = { {"USING", TK_USING}, {"VALUES", TK_VALUES}, {"VARCHAR", TK_VARCHAR}, + {"VARIABLES", TK_VARIABLES}, {"VERBOSE", TK_VERBOSE}, {"VGROUPS", TK_VGROUPS}, + {"VNODES", TK_VNODES}, {"WAL", TK_WAL}, {"WDURATION", TK_WDURATION}, {"WENDTS", TK_WENDTS}, @@ -182,22 +212,8 @@ static SKeyword keywordTable[] = { // {"UMINUS", TK_UMINUS}, // {"UPLUS", TK_UPLUS}, // {"BITNOT", TK_BITNOT}, - // {"ACCOUNTS", TK_ACCOUNTS}, - // {"QUERIES", TK_QUERIES}, - // {"CONNECTIONS", TK_CONNECTIONS}, - // {"VARIABLES", TK_VARIABLES}, - // {"SCORES", TK_SCORES}, // {"GRANTS", TK_GRANTS}, // {"DOT", TK_DOT}, - // {"SYNCDB", TK_SYNCDB}, - // {"LOCAL", TK_LOCAL}, - // {"PPS", TK_PPS}, - // {"TSERIES", TK_TSERIES}, - // {"DBS", TK_DBS}, - // {"STORAGE", TK_STORAGE}, - // {"QTIME", TK_QTIME}, - // {"CONNS", TK_CONNS}, - // {"STATE", TK_STATE}, // {"CTIME", TK_CTIME}, // {"LP", TK_LP}, // {"RP", TK_RP}, @@ -205,15 +221,8 @@ static SKeyword keywordTable[] = { // {"EVERY", TK_EVERY}, // {"VARIABLE", TK_VARIABLE}, // {"UPDATE", TK_UPDATE}, - // {"ADD", TK_ADD}, - // {"COLUMN", TK_COLUMN}, - // {"TAG", TK_TAG}, // {"CHANGE", TK_CHANGE}, - // {"SET", TK_SET}, - // {"KILL", TK_KILL}, - // {"CONNECTION", TK_CONNECTION}, // {"COLON", TK_COLON}, - // {"STREAM", TK_STREAM}, // {"ABORT", TK_ABORT}, // {"AFTER", TK_AFTER}, // {"ATTACH", TK_ATTACH}, @@ -244,14 +253,7 @@ static SKeyword keywordTable[] = { // {"TRIGGER", TK_TRIGGER}, // {"VIEW", TK_VIEW}, // {"SEMI", TK_SEMI}, - // {"VNODES", TK_VNODES}, -// {"PARTITIONS", TK_PARTITIONS}, - // {"TOPICS", TK_TOPICS}, - // {"COMPACT", TK_COMPACT}, - // {"MODIFY", TK_MODIFY}, - // {"OUTPUTTYPE", TK_OUTPUTTYPE}, - // {"AGGREGATE", TK_AGGREGATE}, - // {"BUFSIZE", TK_BUFSIZE}, + // {"PARTITIONS", TK_PARTITIONS}, // {"MODE", TK_MODE}, }; diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index a8ef762a73..2947d25e1f 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -240,7 +240,11 @@ static void setColumnInfoByExpr(const STableNode* pTable, SExprNode* pExpr, SCol if (NULL != pTable) { strcpy(pCol->tableAlias, pTable->tableAlias); } else if (QUERY_NODE_COLUMN == nodeType(pExpr)) { - strcpy(pCol->tableAlias, ((SColumnNode*)pExpr)->tableAlias); + SColumnNode* pProjCol = (SColumnNode*)pExpr; + strcpy(pCol->tableAlias, pProjCol->tableAlias); + pCol->tableId = pProjCol->tableId; + pCol->colId = pProjCol->colId; + pCol->colType = pProjCol->colType; } strcpy(pCol->colName, pExpr->aliasName); pCol->node.resType = pExpr->resType; @@ -956,9 +960,9 @@ static int32_t buildCreateDbReq(STranslateContext* pCxt, SCreateDatabaseStmt* pS 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->daysToKeep0 = pStmt->pOptions->keep0; + pReq->daysToKeep1 = pStmt->pOptions->keep1; + pReq->daysToKeep2 = pStmt->pOptions->keep2; pReq->minRows = pStmt->pOptions->minRowsPerBlock; pReq->maxRows = pStmt->pOptions->maxRowsPerBlock; pReq->commitTime = -1; @@ -1041,13 +1045,14 @@ static void buildAlterDbReq(STranslateContext* pCxt, SAlterDatabaseStmt* pStmt, 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->daysToKeep0 = pStmt->pOptions->keep0; + pReq->daysToKeep1 = pStmt->pOptions->keep1; + pReq->daysToKeep2 = pStmt->pOptions->keep2; pReq->fsyncPeriod = pStmt->pOptions->fsyncPeriod; pReq->walLevel = pStmt->pOptions->walLevel; pReq->quorum = pStmt->pOptions->quorum; pReq->cacheLastRow = pStmt->pOptions->cachelast; + pReq->replications = pStmt->pOptions->replica; return; } @@ -1094,10 +1099,6 @@ static int32_t columnDefNodeToField(SNodeList* pList, SArray** pArray) { } static int32_t columnNodeToField(SNodeList* pList, SArray** pArray) { - if (NULL == pList) { - return TSDB_CODE_SUCCESS; - } - *pArray = taosArrayInit(LIST_LENGTH(pList), sizeof(SField)); SNode* pNode; FOREACH(pNode, pList) { @@ -1119,7 +1120,7 @@ static const SColumnDefNode* findColDef(const SNodeList* pCols, const SColumnNod return NULL; } -static int32_t checkCreateTable(STranslateContext* pCxt, SCreateTableStmt* pStmt) { +static int32_t checkCreateSuperTable(STranslateContext* pCxt, SCreateTableStmt* pStmt) { if (NULL != pStmt->pOptions->pSma) { SNode* pNode = NULL; FOREACH(pNode, pStmt->pOptions->pSma) { @@ -1148,7 +1149,7 @@ static int32_t getAggregationMethod(SNodeList* pFuncs) { } static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableStmt* pStmt) { - int32_t code = checkCreateTable(pCxt, pStmt); + int32_t code = checkCreateSuperTable(pCxt, pStmt); if (TSDB_CODE_SUCCESS != code) { return code; } @@ -1160,10 +1161,15 @@ static int32_t translateCreateSuperTable(STranslateContext* pCxt, SCreateTableSt createReq.delay = pStmt->pOptions->delay; columnDefNodeToField(pStmt->pCols, &createReq.pColumns); columnDefNodeToField(pStmt->pTags, &createReq.pTags); - columnNodeToField(pStmt->pOptions->pSma, &createReq.pSmas); createReq.numOfColumns = LIST_LENGTH(pStmt->pCols); createReq.numOfTags = LIST_LENGTH(pStmt->pTags); - createReq.numOfSmas = LIST_LENGTH(pStmt->pOptions->pSma); + if (NULL == pStmt->pOptions->pSma) { + columnDefNodeToField(pStmt->pCols, &createReq.pSmas); + createReq.numOfSmas = createReq.numOfColumns; + } else { + columnNodeToField(pStmt->pOptions->pSma, &createReq.pSmas); + createReq.numOfSmas = LIST_LENGTH(pStmt->pOptions->pSma); + } SName tableName = { .type = TSDB_TABLE_NAME_T, .acctId = pCxt->pParseCxt->acctId }; strcpy(tableName.dbname, pStmt->dbName); @@ -1469,20 +1475,20 @@ static int32_t translateAlterDnode(STranslateContext* pCxt, SAlterDnodeStmt* pSt static int32_t nodeTypeToShowType(ENodeType nt) { switch (nt) { - case QUERY_NODE_SHOW_DATABASES_STMT: - return TSDB_MGMT_TABLE_DB; - case QUERY_NODE_SHOW_STABLES_STMT: - return TSDB_MGMT_TABLE_STB; - case QUERY_NODE_SHOW_USERS_STMT: - return TSDB_MGMT_TABLE_USER; - case QUERY_NODE_SHOW_DNODES_STMT: - return TSDB_MGMT_TABLE_DNODE; - case QUERY_NODE_SHOW_VGROUPS_STMT: - 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; + case QUERY_NODE_SHOW_APPS_STMT: + return 0; // todo + case QUERY_NODE_SHOW_CONNECTIONS_STMT: + return TSDB_MGMT_TABLE_CONNS; + case QUERY_NODE_SHOW_LICENCE_STMT: + return 0; // todo + case QUERY_NODE_SHOW_QUERIES_STMT: + return TSDB_MGMT_TABLE_QUERIES; + case QUERY_NODE_SHOW_SCORES_STMT: + return 0; // todo + case QUERY_NODE_SHOW_TOPICS_STMT: + return 0; // todo + case QUERY_NODE_SHOW_VARIABLE_STMT: + return TSDB_MGMT_TABLE_VARIABLES; default: break; } @@ -1508,30 +1514,6 @@ static int32_t translateShow(STranslateContext* pCxt, SShowStmt* pStmt) { return TSDB_CODE_SUCCESS; } -static int32_t translateShowTables(STranslateContext* pCxt) { - SVShowTablesReq* pShowReq = taosMemoryCalloc(1, sizeof(SVShowTablesReq)); - - SArray* array = NULL; - int32_t code = getDBVgInfo(pCxt, pCxt->pParseCxt->db, &array); - if (TSDB_CODE_SUCCESS != code) { - return code; - } - SVgroupInfo* info = taosArrayGet(array, 0); - pShowReq->head.vgId = htonl(info->vgId); - - pCxt->pCmdMsg = taosMemoryMalloc(sizeof(SCmdMsgInfo)); - if (NULL == pCxt->pCmdMsg) { - return TSDB_CODE_OUT_OF_MEMORY; - } - pCxt->pCmdMsg->epSet = info->epSet; - pCxt->pCmdMsg->msgType = TDMT_VND_SHOW_TABLES; - pCxt->pCmdMsg->msgLen = sizeof(SVShowTablesReq); - pCxt->pCmdMsg->pMsg = pShowReq; - pCxt->pCmdMsg->pExtension = array; - - return TSDB_CODE_SUCCESS; -} - static int32_t getSmaIndexDstVgId(STranslateContext* pCxt, char* pTableName, int32_t* pVgId) { SVgroupInfo vg = {0}; int32_t code = getTableHashVgroup(pCxt, pCxt->pParseCxt->db, pTableName, &vg); @@ -1867,17 +1849,19 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_ALTER_DNODE_STMT: code = translateAlterDnode(pCxt, (SAlterDnodeStmt*)pNode); break; - case QUERY_NODE_SHOW_DATABASES_STMT: - case QUERY_NODE_SHOW_STABLES_STMT: - case QUERY_NODE_SHOW_USERS_STMT: - case QUERY_NODE_SHOW_DNODES_STMT: - case QUERY_NODE_SHOW_VGROUPS_STMT: - case QUERY_NODE_SHOW_MNODES_STMT: - case QUERY_NODE_SHOW_QNODES_STMT: + case QUERY_NODE_SHOW_APPS_STMT: + case QUERY_NODE_SHOW_CONNECTIONS_STMT: + case QUERY_NODE_SHOW_LICENCE_STMT: + case QUERY_NODE_SHOW_QUERIES_STMT: + case QUERY_NODE_SHOW_SCORES_STMT: + case QUERY_NODE_SHOW_TOPICS_STMT: + case QUERY_NODE_SHOW_VARIABLE_STMT: code = translateShow(pCxt, (SShowStmt*)pNode); break; - case QUERY_NODE_SHOW_TABLES_STMT: - code = translateShowTables(pCxt); + case QUERY_NODE_SHOW_CREATE_DATABASE_STMT: + case QUERY_NODE_SHOW_CREATE_TABLE_STMT: + case QUERY_NODE_SHOW_CREATE_STABLE_STMT: + // todo break; case QUERY_NODE_CREATE_INDEX_STMT: code = translateCreateIndex(pCxt, (SCreateIndexStmt*)pNode); @@ -1952,6 +1936,7 @@ static int32_t extractExplainResultSchema(int32_t* numOfCols, SSchema** pSchema) } (*pSchema)[0].type = TSDB_DATA_TYPE_BINARY; (*pSchema)[0].bytes = TSDB_EXPLAIN_RESULT_ROW_SIZE; + strcpy((*pSchema)[0].name, TSDB_EXPLAIN_RESULT_COLUMN_NAME); return TSDB_CODE_SUCCESS; } @@ -2447,9 +2432,19 @@ static int32_t buildKVRowForAllTags(STranslateContext* pCxt, SCreateSubTableClau return TSDB_CODE_SUCCESS; } +static int32_t checkCreateSubTable(STranslateContext* pCxt, SCreateSubTableClause* pStmt) { + if (0 != strcmp(pStmt->dbName, pStmt->useDbName)) { + return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR);; + } + return TSDB_CODE_SUCCESS; +} static int32_t rewriteCreateSubTable(STranslateContext* pCxt, SCreateSubTableClause* pStmt, SHashObj* pVgroupHashmap) { + int32_t code = checkCreateSubTable(pCxt, pStmt); + STableMeta* pSuperTableMeta = NULL; - int32_t code = getTableMeta(pCxt, pStmt->useDbName, pStmt->useTableName, &pSuperTableMeta); + if (TSDB_CODE_SUCCESS == code) { + code = getTableMeta(pCxt, pStmt->useDbName, pStmt->useTableName, &pSuperTableMeta); + } SKVRowBuilder kvRowBuilder = {0}; if (TSDB_CODE_SUCCESS == code) { diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index 80d04c5ee4..aeed7719f3 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -61,6 +61,12 @@ static char* getSyntaxErrFormat(int32_t errCode) { return "This statement is no longer supported"; case TSDB_CODE_PAR_INTERVAL_VALUE_TOO_SMALL: return "This interval value is too small : %s"; + case TSDB_CODE_PAR_DB_NOT_SPECIFIED: + return "db not specified"; + case TSDB_CODE_PAR_INVALID_IDENTIFIER_NAME: + return "Invalid identifier name : %s"; + case TSDB_CODE_PAR_CORRESPONDING_STABLE_ERR: + return "corresponding super table not in this db"; case TSDB_CODE_OUT_OF_MEMORY: return "Out of memory"; default: diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index fc6a582da5..618e80cbfe 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -100,24 +100,24 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 277 +#define YYNOCODE 304 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - EFillMode yy6; - EJoinType yy10; - SNode* yy46; - SToken yy95; - SAlterOption yy145; - bool yy151; - SNodeList* yy194; - int32_t yy202; - ENullOrder yy273; - EOperatorType yy292; - SDataType yy400; - EOrder yy456; + EOperatorType yy60; + SNode* yy104; + SToken yy129; + bool yy185; + int32_t yy196; + SAlterOption yy253; + SNodeList* yy312; + SDataType yy336; + EOrder yy354; + ENullOrder yy489; + EJoinType yy532; + EFillMode yy550; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -132,17 +132,17 @@ typedef union { #define ParseCTX_PARAM #define ParseCTX_FETCH #define ParseCTX_STORE -#define YYNSTATE 445 -#define YYNRULE 357 -#define YYNTOKEN 179 -#define YY_MAX_SHIFT 444 -#define YY_MIN_SHIFTREDUCE 691 -#define YY_MAX_SHIFTREDUCE 1047 -#define YY_ERROR_ACTION 1048 -#define YY_ACCEPT_ACTION 1049 -#define YY_NO_ACTION 1050 -#define YY_MIN_REDUCE 1051 -#define YY_MAX_REDUCE 1407 +#define YYNSTATE 512 +#define YYNRULE 389 +#define YYNTOKEN 201 +#define YY_MAX_SHIFT 511 +#define YY_MIN_SHIFTREDUCE 762 +#define YY_MAX_SHIFTREDUCE 1150 +#define YY_ERROR_ACTION 1151 +#define YY_ACCEPT_ACTION 1152 +#define YY_NO_ACTION 1153 +#define YY_MIN_REDUCE 1154 +#define YY_MAX_REDUCE 1542 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -209,422 +209,452 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (1352) +#define YY_ACTTAB_COUNT (1412) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 1264, 344, 24, 174, 363, 363, 258, 243, 1260, 1267, - /* 10 */ 1230, 1231, 31, 29, 27, 26, 25, 1277, 376, 376, - /* 20 */ 9, 8, 95, 69, 69, 31, 29, 27, 26, 25, - /* 30 */ 293, 299, 344, 1386, 108, 62, 1063, 1293, 376, 1154, - /* 40 */ 1154, 348, 1145, 262, 360, 96, 120, 217, 1094, 251, - /* 50 */ 1384, 93, 1146, 95, 362, 375, 1221, 1223, 1251, 1154, - /* 60 */ 217, 167, 1332, 343, 112, 342, 1097, 46, 1386, 923, - /* 70 */ 65, 1278, 1279, 1282, 1325, 1194, 92, 953, 233, 1321, - /* 80 */ 1398, 120, 93, 1251, 1149, 1384, 109, 1121, 966, 1359, - /* 90 */ 953, 346, 116, 1332, 1333, 272, 1337, 429, 428, 427, - /* 100 */ 426, 425, 424, 423, 422, 421, 420, 419, 418, 417, - /* 110 */ 416, 415, 414, 413, 412, 305, 954, 300, 375, 1293, - /* 120 */ 304, 1132, 908, 303, 1049, 301, 360, 80, 302, 954, - /* 130 */ 79, 78, 77, 76, 75, 74, 73, 72, 71, 317, - /* 140 */ 126, 125, 23, 238, 948, 949, 950, 951, 952, 956, - /* 150 */ 957, 958, 315, 375, 334, 23, 238, 948, 949, 950, - /* 160 */ 951, 952, 956, 957, 958, 1277, 12, 284, 31, 29, - /* 170 */ 27, 26, 25, 255, 800, 399, 398, 397, 804, 396, - /* 180 */ 806, 807, 395, 809, 392, 1293, 815, 389, 817, 818, - /* 190 */ 386, 383, 360, 31, 29, 27, 26, 25, 231, 1201, - /* 200 */ 1386, 12, 362, 1074, 30, 28, 1251, 257, 1277, 256, - /* 210 */ 1222, 348, 240, 120, 888, 1264, 1386, 1384, 64, 1278, - /* 220 */ 1279, 1282, 1325, 1260, 1266, 923, 216, 1321, 1293, 1385, - /* 230 */ 886, 46, 121, 1384, 912, 347, 333, 376, 1386, 11, - /* 240 */ 247, 246, 263, 297, 1251, 362, 1218, 296, 1150, 1251, - /* 250 */ 901, 120, 121, 124, 1277, 1384, 121, 1073, 1154, 284, - /* 260 */ 1, 65, 1278, 1279, 1282, 1325, 894, 376, 298, 233, - /* 270 */ 1321, 115, 283, 264, 1293, 339, 335, 30, 28, 990, - /* 280 */ 248, 360, 910, 170, 441, 240, 6, 888, 1154, 326, - /* 290 */ 1352, 362, 30, 28, 1293, 1251, 887, 1264, 1251, 215, - /* 300 */ 240, 360, 888, 886, 1044, 1260, 1266, 66, 1278, 1279, - /* 310 */ 1282, 1325, 11, 1052, 1072, 1324, 1321, 1339, 886, 1014, - /* 320 */ 377, 913, 889, 319, 892, 893, 206, 11, 936, 337, - /* 330 */ 437, 436, 897, 1, 80, 1336, 169, 79, 78, 77, - /* 340 */ 76, 75, 74, 73, 72, 71, 121, 1130, 1, 1051, - /* 350 */ 330, 1012, 1013, 1015, 1016, 1251, 1043, 441, 902, 1071, - /* 360 */ 905, 893, 376, 320, 1070, 1277, 376, 1151, 989, 887, - /* 370 */ 1271, 373, 441, 89, 88, 87, 86, 85, 84, 83, - /* 380 */ 82, 81, 1269, 1154, 887, 1293, 107, 1154, 1277, 338, - /* 390 */ 1386, 1069, 347, 411, 1157, 889, 985, 892, 893, 206, - /* 400 */ 1251, 936, 362, 120, 351, 1251, 1251, 1384, 1293, 121, - /* 410 */ 889, 1277, 892, 893, 206, 360, 936, 727, 65, 1278, - /* 420 */ 1279, 1282, 1325, 155, 1201, 362, 233, 1321, 115, 1251, - /* 430 */ 230, 1293, 1251, 291, 344, 1199, 1339, 728, 360, 727, - /* 440 */ 1068, 65, 1278, 1279, 1282, 1325, 55, 1353, 362, 233, - /* 450 */ 1321, 1398, 1251, 355, 1335, 95, 955, 729, 1067, 1339, - /* 460 */ 1382, 30, 28, 1147, 65, 1278, 1279, 1282, 1325, 240, - /* 470 */ 1277, 888, 233, 1321, 1398, 1131, 911, 1334, 30, 28, - /* 480 */ 361, 1251, 21, 1343, 93, 411, 240, 886, 888, 909, - /* 490 */ 1293, 959, 30, 28, 117, 1332, 1333, 360, 1337, 1251, - /* 500 */ 240, 1066, 888, 194, 886, 244, 1184, 362, 1065, 376, - /* 510 */ 1062, 1251, 141, 107, 374, 139, 348, 7, 886, 988, - /* 520 */ 1061, 1156, 402, 207, 1278, 1279, 1282, 322, 224, 1201, - /* 530 */ 1154, 1064, 408, 1060, 7, 245, 407, 30, 28, 101, - /* 540 */ 1199, 441, 1251, 1386, 1201, 240, 356, 888, 7, 1251, - /* 550 */ 297, 1251, 61, 887, 296, 1200, 120, 409, 441, 997, - /* 560 */ 1384, 1251, 57, 886, 225, 910, 223, 222, 1277, 295, - /* 570 */ 887, 350, 441, 1143, 1251, 298, 406, 405, 404, 889, - /* 580 */ 403, 892, 893, 206, 887, 936, 1139, 376, 1293, 1344, - /* 590 */ 985, 1277, 188, 1, 359, 360, 889, 1141, 892, 893, - /* 600 */ 206, 143, 936, 121, 142, 362, 9, 8, 1154, 1251, - /* 610 */ 889, 1293, 892, 893, 206, 376, 936, 441, 360, 250, - /* 620 */ 254, 66, 1278, 1279, 1282, 1325, 1137, 107, 362, 887, - /* 630 */ 1322, 1201, 1251, 199, 1059, 1156, 1154, 252, 201, 27, - /* 640 */ 26, 25, 1199, 1277, 66, 1278, 1279, 1282, 1325, 1277, - /* 650 */ 200, 344, 358, 1321, 1277, 889, 896, 892, 893, 206, - /* 660 */ 127, 936, 935, 1293, 937, 938, 939, 940, 941, 1293, - /* 670 */ 360, 1011, 95, 1058, 1293, 1251, 360, 1057, 1056, 945, - /* 680 */ 362, 360, 1055, 42, 1251, 145, 362, 1054, 144, 147, - /* 690 */ 1251, 362, 146, 239, 1122, 1251, 110, 1278, 1279, 1282, - /* 700 */ 1277, 93, 211, 1278, 1279, 1282, 1277, 110, 1278, 1279, - /* 710 */ 1282, 118, 1332, 1333, 1251, 1337, 253, 352, 1251, 1251, - /* 720 */ 1293, 67, 899, 1251, 107, 171, 1293, 360, 1251, 1090, - /* 730 */ 1277, 401, 1156, 360, 349, 1399, 888, 362, 44, 43, - /* 740 */ 261, 1251, 122, 362, 327, 331, 1400, 1251, 1046, 1047, - /* 750 */ 1293, 306, 886, 211, 1278, 1279, 1282, 360, 1085, 210, - /* 760 */ 1278, 1279, 1282, 908, 1195, 160, 960, 362, 1277, 121, - /* 770 */ 265, 1251, 1083, 277, 237, 895, 164, 158, 32, 444, - /* 780 */ 308, 290, 278, 211, 1278, 1279, 1282, 20, 1293, 1355, - /* 790 */ 345, 340, 1294, 191, 311, 360, 91, 31, 29, 27, - /* 800 */ 26, 25, 433, 22, 190, 362, 441, 920, 353, 1251, - /* 810 */ 173, 1277, 241, 31, 29, 27, 26, 25, 887, 32, - /* 820 */ 872, 211, 1278, 1279, 1282, 179, 2, 63, 368, 881, - /* 830 */ 186, 1293, 32, 185, 908, 192, 1220, 177, 360, 793, - /* 840 */ 98, 898, 1277, 123, 889, 99, 892, 893, 362, 266, - /* 850 */ 276, 101, 1251, 271, 270, 269, 268, 267, 788, 273, - /* 860 */ 274, 372, 1293, 821, 209, 1278, 1279, 1282, 825, 360, - /* 870 */ 42, 275, 831, 1277, 279, 381, 916, 280, 325, 362, - /* 880 */ 99, 151, 1277, 1251, 100, 128, 31, 29, 27, 26, - /* 890 */ 25, 830, 281, 1293, 102, 212, 1278, 1279, 1282, 915, - /* 900 */ 360, 282, 1293, 101, 1277, 131, 99, 45, 285, 360, - /* 910 */ 362, 134, 914, 1277, 1251, 294, 292, 229, 1144, 362, - /* 920 */ 138, 1140, 90, 1251, 1293, 140, 204, 1278, 1279, 1282, - /* 930 */ 321, 360, 103, 1293, 1129, 213, 1278, 1279, 1282, 150, - /* 940 */ 360, 362, 104, 1277, 1142, 1251, 324, 1138, 105, 106, - /* 950 */ 362, 1277, 153, 913, 1251, 332, 366, 205, 1278, 1279, - /* 960 */ 1282, 1356, 323, 1293, 1366, 156, 214, 1278, 1279, 1282, - /* 970 */ 360, 1293, 329, 893, 1277, 1365, 5, 305, 360, 300, - /* 980 */ 362, 159, 304, 341, 1251, 303, 232, 301, 362, 336, - /* 990 */ 302, 408, 1251, 328, 1293, 407, 1290, 1278, 1279, 1282, - /* 1000 */ 163, 360, 4, 985, 1289, 1278, 1279, 1282, 912, 113, - /* 1010 */ 1346, 362, 165, 1277, 94, 1251, 409, 1340, 33, 166, - /* 1020 */ 234, 1277, 357, 354, 17, 1307, 1229, 1288, 1278, 1279, - /* 1030 */ 1282, 1401, 172, 1293, 364, 406, 405, 404, 1383, 403, - /* 1040 */ 360, 1293, 365, 242, 1277, 1228, 369, 370, 360, 371, - /* 1050 */ 362, 181, 1277, 183, 1251, 310, 193, 1155, 362, 54, - /* 1060 */ 56, 195, 1251, 189, 1293, 379, 220, 1278, 1279, 1282, - /* 1070 */ 318, 360, 1293, 440, 219, 1278, 1279, 1282, 202, 360, - /* 1080 */ 203, 362, 197, 1277, 149, 1251, 198, 313, 1245, 362, - /* 1090 */ 884, 39, 307, 1251, 883, 148, 1239, 221, 1278, 1279, - /* 1100 */ 1282, 1238, 259, 1293, 260, 218, 1278, 1279, 1282, 1237, - /* 1110 */ 360, 1236, 855, 1213, 1212, 97, 1211, 1210, 41, 136, - /* 1120 */ 362, 40, 114, 1209, 1251, 1208, 1207, 1206, 289, 857, - /* 1130 */ 135, 1205, 1204, 1203, 1202, 1096, 208, 1278, 1279, 1282, - /* 1140 */ 1235, 1226, 130, 1133, 1095, 740, 1093, 288, 286, 1082, - /* 1150 */ 1081, 287, 1078, 47, 1135, 70, 133, 137, 838, 837, - /* 1160 */ 836, 1134, 768, 1091, 226, 1086, 767, 766, 765, 227, - /* 1170 */ 1084, 1077, 1076, 228, 764, 763, 68, 314, 309, 316, - /* 1180 */ 1234, 1233, 36, 312, 1225, 154, 48, 3, 14, 32, - /* 1190 */ 111, 152, 15, 37, 34, 10, 51, 8, 946, 367, - /* 1200 */ 162, 184, 832, 132, 1224, 1050, 1050, 129, 1050, 1050, - /* 1210 */ 1050, 1050, 1050, 1050, 1050, 1050, 1050, 1032, 1050, 1050, - /* 1220 */ 1031, 235, 157, 1036, 1035, 236, 1050, 1010, 161, 1050, - /* 1230 */ 903, 1004, 49, 182, 1050, 1003, 50, 1050, 982, 1269, - /* 1240 */ 1050, 829, 981, 1050, 1050, 1037, 1050, 1050, 19, 1050, - /* 1250 */ 1050, 1050, 1050, 1050, 168, 1050, 35, 119, 921, 16, - /* 1260 */ 176, 13, 18, 380, 249, 1008, 178, 180, 175, 52, - /* 1270 */ 53, 384, 387, 1050, 1050, 57, 1092, 390, 1050, 1050, - /* 1280 */ 1268, 393, 799, 1050, 1050, 187, 38, 1050, 827, 760, - /* 1290 */ 738, 822, 382, 752, 438, 1050, 1050, 819, 816, 385, - /* 1300 */ 378, 810, 833, 828, 388, 391, 759, 758, 757, 808, - /* 1310 */ 410, 756, 1080, 1079, 394, 430, 755, 814, 1075, 754, - /* 1320 */ 753, 751, 439, 442, 750, 749, 435, 58, 748, 59, - /* 1330 */ 60, 747, 746, 890, 432, 443, 745, 744, 743, 431, - /* 1340 */ 400, 196, 434, 813, 1050, 1050, 1050, 1050, 1050, 812, - /* 1350 */ 1050, 811, + /* 0 */ 1398, 24, 191, 442, 442, 504, 503, 253, 1307, 72, + /* 10 */ 72, 270, 1394, 1401, 252, 307, 349, 355, 233, 1305, + /* 20 */ 1010, 1197, 1155, 442, 1398, 1260, 1260, 319, 1398, 305, + /* 30 */ 331, 31, 29, 27, 26, 25, 1394, 1400, 429, 332, + /* 40 */ 1394, 1400, 234, 84, 1348, 1260, 83, 82, 81, 80, + /* 50 */ 79, 78, 77, 76, 75, 273, 31, 29, 27, 26, + /* 60 */ 25, 429, 1338, 1340, 265, 213, 236, 1347, 1290, 441, + /* 70 */ 496, 495, 494, 493, 492, 491, 490, 489, 207, 486, + /* 80 */ 485, 484, 483, 482, 481, 480, 479, 478, 998, 1026, + /* 90 */ 31, 29, 27, 26, 25, 84, 441, 1056, 83, 82, + /* 100 */ 81, 80, 79, 78, 77, 76, 75, 330, 1154, 442, + /* 110 */ 325, 324, 323, 322, 321, 306, 318, 317, 316, 315, + /* 120 */ 311, 310, 309, 308, 442, 236, 27, 26, 25, 340, + /* 130 */ 312, 1260, 93, 92, 91, 90, 89, 88, 87, 86, + /* 140 */ 85, 1428, 362, 1057, 357, 12, 1260, 361, 426, 1012, + /* 150 */ 160, 442, 358, 356, 1001, 359, 1056, 313, 404, 399, + /* 160 */ 410, 1061, 874, 465, 464, 463, 878, 462, 880, 881, + /* 170 */ 461, 883, 458, 1260, 889, 455, 891, 892, 452, 449, + /* 180 */ 400, 126, 98, 1010, 23, 260, 1051, 1052, 1053, 1054, + /* 190 */ 1055, 1059, 1060, 20, 112, 1412, 300, 1013, 299, 219, + /* 200 */ 385, 266, 1057, 31, 29, 27, 26, 25, 442, 111, + /* 210 */ 111, 217, 405, 401, 339, 96, 1428, 1262, 1263, 292, + /* 220 */ 1061, 136, 1251, 426, 412, 121, 1467, 1468, 1177, 1472, + /* 230 */ 1260, 477, 301, 428, 294, 126, 113, 1385, 1166, 1412, + /* 240 */ 1011, 386, 414, 23, 260, 1051, 1052, 1053, 1054, 1055, + /* 250 */ 1059, 1060, 126, 68, 1413, 1414, 1417, 1460, 30, 28, + /* 260 */ 1428, 235, 1456, 1521, 1385, 442, 262, 426, 990, 468, + /* 270 */ 1385, 1257, 1521, 1521, 1249, 1412, 125, 428, 990, 159, + /* 280 */ 1519, 1385, 67, 352, 988, 125, 125, 1260, 1117, 1519, + /* 290 */ 1519, 1374, 49, 11, 988, 6, 1428, 70, 1413, 1414, + /* 300 */ 1417, 1460, 95, 413, 354, 1459, 1456, 45, 44, 304, + /* 310 */ 1255, 130, 1245, 428, 1200, 1, 298, 1385, 396, 1115, + /* 320 */ 1116, 1118, 1119, 410, 242, 442, 290, 284, 286, 282, + /* 330 */ 127, 439, 441, 69, 1413, 1414, 1417, 1460, 508, 126, + /* 340 */ 326, 255, 1456, 120, 1428, 98, 1247, 1260, 508, 49, + /* 350 */ 989, 426, 126, 442, 1014, 187, 30, 28, 1093, 440, + /* 360 */ 989, 392, 1487, 362, 262, 357, 990, 1256, 361, 30, + /* 370 */ 28, 160, 1412, 358, 356, 1260, 359, 262, 96, 990, + /* 380 */ 1243, 12, 988, 403, 991, 135, 134, 1176, 122, 1467, + /* 390 */ 1468, 11, 1472, 1428, 991, 988, 9, 8, 117, 1238, + /* 400 */ 413, 994, 995, 224, 11, 1039, 114, 272, 1224, 1300, + /* 410 */ 428, 994, 995, 1, 1385, 111, 1412, 31, 29, 27, + /* 420 */ 26, 25, 126, 1262, 65, 1412, 1, 1088, 1152, 1385, + /* 430 */ 69, 1413, 1414, 1417, 1460, 99, 508, 1428, 255, 1456, + /* 440 */ 120, 1307, 1252, 1521, 426, 340, 1428, 267, 989, 508, + /* 450 */ 165, 1307, 1305, 426, 428, 1058, 1520, 274, 1385, 1488, + /* 460 */ 1519, 989, 1305, 428, 186, 1069, 1038, 1385, 1040, 1041, + /* 470 */ 1042, 1043, 1044, 1062, 227, 1413, 1414, 1417, 277, 467, + /* 480 */ 30, 28, 991, 69, 1413, 1414, 1417, 1460, 262, 1412, + /* 490 */ 990, 255, 1456, 1533, 131, 991, 21, 1175, 1236, 994, + /* 500 */ 995, 224, 1494, 1039, 1412, 384, 988, 275, 417, 1521, + /* 510 */ 1428, 1174, 994, 995, 224, 111, 1039, 426, 47, 410, + /* 520 */ 1015, 46, 125, 1262, 1307, 1428, 1519, 428, 1173, 798, + /* 530 */ 1092, 1385, 426, 1412, 1474, 1339, 1147, 7, 799, 1385, + /* 540 */ 798, 98, 428, 1167, 477, 347, 1385, 69, 1413, 1414, + /* 550 */ 1417, 1460, 1471, 1385, 1428, 255, 1456, 1533, 800, 188, + /* 560 */ 508, 426, 230, 1413, 1414, 1417, 1517, 1100, 1225, 1172, + /* 570 */ 1385, 428, 989, 1012, 96, 1385, 442, 1171, 1474, 30, + /* 580 */ 28, 427, 205, 1335, 123, 1467, 1468, 262, 1472, 990, + /* 590 */ 133, 69, 1413, 1414, 1417, 1460, 1470, 1170, 1260, 255, + /* 600 */ 1456, 1533, 1146, 1474, 22, 988, 991, 1412, 1169, 376, + /* 610 */ 1478, 1385, 30, 28, 31, 29, 27, 26, 25, 1385, + /* 620 */ 262, 1469, 990, 994, 995, 224, 442, 1039, 1428, 58, + /* 630 */ 172, 1168, 276, 1165, 1164, 426, 7, 1163, 988, 1385, + /* 640 */ 1521, 1162, 1161, 487, 126, 428, 295, 1253, 1260, 1385, + /* 650 */ 1385, 269, 268, 125, 414, 1479, 1088, 1519, 1160, 508, + /* 660 */ 418, 1003, 30, 28, 511, 225, 1413, 1414, 1417, 7, + /* 670 */ 262, 989, 990, 1385, 421, 1385, 1385, 996, 210, 1385, + /* 680 */ 397, 94, 1307, 1385, 1385, 1521, 1159, 500, 988, 209, + /* 690 */ 1158, 1157, 508, 1306, 9, 8, 152, 416, 125, 150, + /* 700 */ 1385, 1301, 1519, 1091, 989, 991, 1412, 154, 156, 158, + /* 710 */ 153, 155, 157, 66, 1193, 1188, 203, 1186, 104, 1, + /* 720 */ 425, 388, 994, 995, 224, 64, 1039, 1428, 1385, 1149, + /* 730 */ 1150, 443, 1385, 1385, 426, 60, 363, 365, 991, 368, + /* 740 */ 181, 1405, 508, 999, 428, 374, 438, 43, 1385, 175, + /* 750 */ 1114, 997, 177, 1403, 989, 994, 995, 224, 372, 1039, + /* 760 */ 410, 346, 1412, 411, 70, 1413, 1414, 1417, 1460, 1490, + /* 770 */ 1429, 391, 424, 1456, 168, 32, 32, 1004, 1063, 1023, + /* 780 */ 190, 1010, 98, 1428, 2, 279, 283, 419, 991, 974, + /* 790 */ 426, 164, 241, 841, 1007, 995, 32, 243, 966, 957, + /* 800 */ 428, 414, 314, 422, 1385, 994, 995, 224, 211, 1039, + /* 810 */ 1412, 194, 132, 101, 196, 96, 434, 1000, 1337, 320, + /* 820 */ 115, 1413, 1414, 1417, 328, 184, 1467, 409, 1048, 408, + /* 830 */ 333, 1428, 1521, 31, 29, 27, 26, 25, 426, 102, + /* 840 */ 1019, 246, 202, 104, 147, 125, 867, 119, 428, 1519, + /* 850 */ 327, 43, 1385, 345, 862, 146, 329, 447, 415, 1534, + /* 860 */ 895, 334, 102, 159, 1412, 899, 335, 352, 70, 1413, + /* 870 */ 1414, 1417, 1460, 1412, 1018, 336, 139, 1457, 247, 50, + /* 880 */ 245, 244, 144, 351, 103, 1428, 337, 905, 354, 1017, + /* 890 */ 104, 1026, 426, 904, 1428, 102, 338, 142, 105, 48, + /* 900 */ 341, 426, 428, 145, 1016, 348, 1385, 1412, 350, 261, + /* 910 */ 377, 428, 353, 1250, 149, 1385, 74, 1246, 393, 151, + /* 920 */ 106, 107, 229, 1413, 1414, 1417, 1248, 1244, 1428, 108, + /* 930 */ 109, 229, 1413, 1414, 1417, 426, 143, 360, 138, 251, + /* 940 */ 140, 379, 378, 1412, 167, 428, 170, 1015, 389, 1385, + /* 950 */ 398, 1412, 383, 1501, 367, 390, 995, 137, 432, 1500, + /* 960 */ 5, 387, 380, 1481, 1428, 228, 1413, 1414, 1417, 375, + /* 970 */ 407, 426, 1428, 173, 395, 4, 254, 1412, 176, 426, + /* 980 */ 1491, 428, 402, 162, 394, 1385, 370, 1088, 97, 428, + /* 990 */ 1014, 364, 1237, 1385, 161, 33, 259, 406, 1428, 1235, + /* 1000 */ 1475, 115, 1413, 1414, 1417, 426, 1412, 118, 180, 229, + /* 1010 */ 1413, 1414, 1417, 256, 183, 428, 1518, 182, 41, 1385, + /* 1020 */ 423, 40, 263, 420, 189, 1536, 17, 1428, 1442, 1346, + /* 1030 */ 1412, 430, 431, 264, 426, 229, 1413, 1414, 1417, 1345, + /* 1040 */ 1535, 435, 436, 200, 428, 198, 437, 57, 1385, 206, + /* 1050 */ 212, 1428, 59, 473, 1412, 474, 206, 488, 426, 1261, + /* 1060 */ 473, 445, 214, 507, 222, 1413, 1414, 1417, 428, 208, + /* 1070 */ 220, 39, 1385, 216, 475, 1428, 1379, 221, 1412, 218, + /* 1080 */ 1378, 475, 426, 278, 1375, 280, 281, 984, 231, 1413, + /* 1090 */ 1414, 1417, 428, 472, 471, 470, 1385, 469, 985, 1428, + /* 1100 */ 472, 471, 470, 128, 469, 285, 426, 1412, 1373, 287, + /* 1110 */ 288, 289, 223, 1413, 1414, 1417, 428, 1372, 1371, 291, + /* 1120 */ 1385, 293, 1362, 129, 296, 297, 969, 968, 1428, 1356, + /* 1130 */ 1355, 303, 302, 1412, 1354, 426, 232, 1413, 1414, 1417, + /* 1140 */ 1353, 1412, 940, 1330, 1329, 428, 1328, 1327, 1326, 1385, + /* 1150 */ 1325, 1324, 1323, 1322, 1428, 1321, 1320, 1319, 1318, 100, + /* 1160 */ 1317, 426, 1428, 1316, 1315, 1425, 1413, 1414, 1417, 426, + /* 1170 */ 1314, 428, 1313, 1312, 1311, 1385, 1412, 1310, 1309, 428, + /* 1180 */ 1308, 942, 1412, 1385, 1199, 1370, 1364, 1352, 1343, 1239, + /* 1190 */ 811, 1424, 1413, 1414, 1417, 1198, 1196, 1428, 1185, 1423, + /* 1200 */ 1413, 1414, 1417, 1428, 426, 141, 342, 343, 344, 1184, + /* 1210 */ 426, 1412, 1181, 1241, 428, 73, 487, 1412, 1385, 912, + /* 1220 */ 428, 148, 910, 1240, 1385, 1194, 248, 1189, 840, 839, + /* 1230 */ 838, 837, 1428, 249, 239, 1413, 1414, 1417, 1428, 426, + /* 1240 */ 238, 1413, 1414, 1417, 835, 426, 834, 1187, 250, 428, + /* 1250 */ 1180, 371, 369, 1385, 366, 428, 1179, 373, 71, 1385, + /* 1260 */ 1369, 42, 163, 1412, 1363, 381, 976, 110, 382, 240, + /* 1270 */ 1413, 1414, 1417, 1351, 1350, 237, 1413, 1414, 1417, 1342, + /* 1280 */ 169, 166, 14, 1403, 1428, 51, 171, 3, 32, 174, + /* 1290 */ 15, 426, 1113, 116, 34, 54, 36, 37, 185, 124, + /* 1300 */ 178, 428, 1107, 52, 1135, 1385, 1106, 179, 53, 19, + /* 1310 */ 1134, 1085, 35, 10, 1084, 16, 1140, 8, 257, 1139, + /* 1320 */ 1138, 226, 1413, 1414, 1417, 258, 1341, 1024, 13, 433, + /* 1330 */ 1049, 18, 192, 193, 60, 1111, 195, 197, 55, 199, + /* 1340 */ 56, 1005, 1402, 446, 38, 271, 450, 896, 893, 453, + /* 1350 */ 456, 204, 448, 451, 459, 890, 444, 454, 201, 884, + /* 1360 */ 882, 457, 460, 873, 901, 907, 903, 61, 809, 476, + /* 1370 */ 62, 63, 831, 830, 829, 828, 827, 826, 825, 823, + /* 1380 */ 888, 466, 824, 842, 821, 820, 819, 818, 887, 886, + /* 1390 */ 817, 885, 816, 815, 814, 1195, 497, 498, 1183, 1182, + /* 1400 */ 501, 502, 499, 1178, 906, 505, 506, 1153, 992, 215, + /* 1410 */ 509, 510, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 223, 188, 240, 241, 219, 219, 228, 222, 231, 232, - /* 10 */ 225, 225, 12, 13, 14, 15, 16, 182, 188, 188, - /* 20 */ 1, 2, 209, 193, 193, 12, 13, 14, 15, 16, - /* 30 */ 200, 200, 188, 255, 181, 187, 183, 202, 188, 209, - /* 40 */ 209, 228, 182, 193, 209, 197, 268, 47, 0, 211, - /* 50 */ 272, 238, 204, 209, 219, 20, 218, 219, 223, 209, - /* 60 */ 47, 248, 249, 250, 201, 252, 0, 190, 255, 69, - /* 70 */ 235, 236, 237, 238, 239, 212, 199, 77, 243, 244, - /* 80 */ 245, 268, 238, 223, 207, 272, 191, 192, 69, 254, - /* 90 */ 77, 247, 248, 249, 250, 63, 252, 49, 50, 51, - /* 100 */ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, - /* 110 */ 62, 63, 64, 65, 66, 49, 116, 51, 20, 202, - /* 120 */ 54, 0, 20, 57, 179, 59, 209, 21, 62, 116, - /* 130 */ 24, 25, 26, 27, 28, 29, 30, 31, 32, 21, - /* 140 */ 108, 109, 142, 143, 144, 145, 146, 147, 148, 149, - /* 150 */ 150, 151, 34, 20, 237, 142, 143, 144, 145, 146, - /* 160 */ 147, 148, 149, 150, 151, 182, 68, 46, 12, 13, - /* 170 */ 14, 15, 16, 228, 83, 84, 85, 86, 87, 88, - /* 180 */ 89, 90, 91, 92, 93, 202, 95, 96, 97, 98, - /* 190 */ 99, 100, 209, 12, 13, 14, 15, 16, 206, 202, - /* 200 */ 255, 68, 219, 182, 12, 13, 223, 129, 182, 131, - /* 210 */ 213, 228, 20, 268, 22, 223, 255, 272, 235, 236, - /* 220 */ 237, 238, 239, 231, 232, 69, 243, 244, 202, 268, - /* 230 */ 38, 190, 154, 272, 20, 209, 120, 188, 255, 47, - /* 240 */ 12, 13, 193, 57, 223, 219, 209, 61, 207, 223, - /* 250 */ 22, 268, 154, 216, 182, 272, 154, 182, 209, 46, - /* 260 */ 68, 235, 236, 237, 238, 239, 38, 188, 82, 243, - /* 270 */ 244, 245, 193, 188, 202, 159, 160, 12, 13, 14, - /* 280 */ 206, 209, 20, 257, 92, 20, 43, 22, 209, 263, - /* 290 */ 264, 219, 12, 13, 202, 223, 104, 223, 223, 214, - /* 300 */ 20, 209, 22, 38, 123, 231, 232, 235, 236, 237, - /* 310 */ 238, 239, 47, 0, 182, 243, 244, 233, 38, 132, - /* 320 */ 92, 20, 130, 188, 132, 133, 134, 47, 136, 237, - /* 330 */ 185, 186, 104, 68, 21, 251, 122, 24, 25, 26, - /* 340 */ 27, 28, 29, 30, 31, 32, 154, 0, 68, 0, - /* 350 */ 163, 164, 165, 166, 167, 223, 175, 92, 130, 182, - /* 360 */ 132, 133, 188, 228, 182, 182, 188, 193, 4, 104, - /* 370 */ 68, 193, 92, 24, 25, 26, 27, 28, 29, 30, - /* 380 */ 31, 32, 80, 209, 104, 202, 202, 209, 182, 20, - /* 390 */ 255, 182, 209, 46, 210, 130, 153, 132, 133, 134, - /* 400 */ 223, 136, 219, 268, 3, 223, 223, 272, 202, 154, - /* 410 */ 130, 182, 132, 133, 134, 209, 136, 22, 235, 236, - /* 420 */ 237, 238, 239, 122, 202, 219, 243, 244, 245, 223, - /* 430 */ 208, 202, 223, 38, 188, 213, 233, 20, 209, 22, - /* 440 */ 182, 235, 236, 237, 238, 239, 187, 264, 219, 243, - /* 450 */ 244, 245, 223, 81, 251, 209, 116, 40, 182, 233, - /* 460 */ 254, 12, 13, 204, 235, 236, 237, 238, 239, 20, - /* 470 */ 182, 22, 243, 244, 245, 0, 20, 251, 12, 13, - /* 480 */ 14, 223, 142, 254, 238, 46, 20, 38, 22, 20, - /* 490 */ 202, 151, 12, 13, 248, 249, 250, 209, 252, 223, - /* 500 */ 20, 182, 22, 195, 38, 194, 198, 219, 182, 188, - /* 510 */ 182, 223, 72, 202, 193, 75, 228, 68, 38, 155, - /* 520 */ 182, 210, 79, 235, 236, 237, 238, 69, 35, 202, - /* 530 */ 209, 183, 57, 182, 68, 208, 61, 12, 13, 81, - /* 540 */ 213, 92, 223, 255, 202, 20, 174, 22, 68, 223, - /* 550 */ 57, 223, 68, 104, 61, 213, 268, 82, 92, 14, - /* 560 */ 272, 223, 78, 38, 71, 20, 73, 74, 182, 76, - /* 570 */ 104, 170, 92, 203, 223, 82, 101, 102, 103, 130, - /* 580 */ 105, 132, 133, 134, 104, 136, 203, 188, 202, 152, - /* 590 */ 153, 182, 193, 68, 47, 209, 130, 203, 132, 133, - /* 600 */ 134, 72, 136, 154, 75, 219, 1, 2, 209, 223, - /* 610 */ 130, 202, 132, 133, 134, 188, 136, 92, 209, 194, - /* 620 */ 193, 235, 236, 237, 238, 239, 203, 202, 219, 104, - /* 630 */ 244, 202, 223, 18, 182, 210, 209, 208, 23, 14, - /* 640 */ 15, 16, 213, 182, 235, 236, 237, 238, 239, 182, - /* 650 */ 35, 188, 243, 244, 182, 130, 38, 132, 133, 134, - /* 660 */ 45, 136, 135, 202, 137, 138, 139, 140, 141, 202, - /* 670 */ 209, 69, 209, 182, 202, 223, 209, 182, 182, 132, - /* 680 */ 219, 209, 182, 81, 223, 72, 219, 182, 75, 72, - /* 690 */ 223, 219, 75, 226, 192, 223, 235, 236, 237, 238, - /* 700 */ 182, 238, 235, 236, 237, 238, 182, 235, 236, 237, - /* 710 */ 238, 248, 249, 250, 223, 252, 194, 81, 223, 223, - /* 720 */ 202, 106, 104, 223, 202, 275, 202, 209, 223, 0, - /* 730 */ 182, 203, 210, 209, 273, 274, 22, 219, 123, 124, - /* 740 */ 125, 223, 127, 219, 226, 266, 274, 223, 177, 178, - /* 750 */ 202, 22, 38, 235, 236, 237, 238, 209, 0, 235, - /* 760 */ 236, 237, 238, 20, 212, 69, 69, 219, 182, 154, - /* 770 */ 27, 223, 0, 30, 226, 38, 260, 81, 81, 19, - /* 780 */ 22, 185, 39, 235, 236, 237, 238, 2, 202, 234, - /* 790 */ 253, 267, 202, 33, 22, 209, 36, 12, 13, 14, - /* 800 */ 15, 16, 42, 2, 44, 219, 92, 69, 172, 223, - /* 810 */ 269, 182, 226, 12, 13, 14, 15, 16, 104, 81, - /* 820 */ 69, 235, 236, 237, 238, 69, 256, 67, 69, 128, - /* 830 */ 70, 202, 81, 69, 20, 229, 188, 81, 209, 69, - /* 840 */ 81, 104, 182, 115, 130, 81, 132, 133, 219, 217, - /* 850 */ 107, 81, 223, 110, 111, 112, 113, 114, 69, 215, - /* 860 */ 116, 101, 202, 69, 235, 236, 237, 238, 69, 209, - /* 870 */ 81, 215, 69, 182, 188, 81, 20, 227, 118, 219, - /* 880 */ 81, 121, 182, 223, 81, 190, 12, 13, 14, 15, - /* 890 */ 16, 69, 209, 202, 69, 235, 236, 237, 238, 20, - /* 900 */ 209, 220, 202, 81, 182, 190, 81, 190, 188, 209, - /* 910 */ 219, 190, 20, 182, 223, 202, 184, 184, 202, 219, - /* 920 */ 202, 202, 188, 223, 202, 202, 235, 236, 237, 238, - /* 930 */ 227, 209, 202, 202, 0, 235, 236, 237, 238, 187, - /* 940 */ 209, 219, 202, 182, 202, 223, 220, 202, 202, 202, - /* 950 */ 219, 182, 187, 20, 223, 162, 161, 235, 236, 237, - /* 960 */ 238, 234, 209, 202, 265, 224, 235, 236, 237, 238, - /* 970 */ 209, 202, 223, 133, 182, 265, 169, 49, 209, 51, - /* 980 */ 219, 224, 54, 168, 223, 57, 223, 59, 219, 223, - /* 990 */ 62, 57, 223, 157, 202, 61, 235, 236, 237, 238, - /* 1000 */ 261, 209, 156, 153, 235, 236, 237, 238, 20, 259, - /* 1010 */ 262, 219, 258, 182, 209, 223, 82, 233, 115, 246, - /* 1020 */ 176, 182, 173, 171, 68, 242, 224, 235, 236, 237, - /* 1030 */ 238, 276, 270, 202, 223, 101, 102, 103, 271, 105, - /* 1040 */ 209, 202, 223, 223, 182, 224, 119, 221, 209, 220, - /* 1050 */ 219, 209, 182, 187, 223, 4, 198, 209, 219, 187, - /* 1060 */ 68, 188, 223, 187, 202, 205, 235, 236, 237, 238, - /* 1070 */ 19, 209, 202, 184, 235, 236, 237, 238, 196, 209, - /* 1080 */ 196, 219, 189, 182, 33, 223, 180, 36, 0, 219, - /* 1090 */ 104, 230, 41, 223, 130, 44, 0, 235, 236, 237, - /* 1100 */ 238, 0, 50, 202, 126, 235, 236, 237, 238, 0, - /* 1110 */ 209, 0, 80, 0, 0, 115, 0, 0, 67, 33, - /* 1120 */ 219, 70, 36, 0, 223, 0, 0, 0, 42, 22, - /* 1130 */ 44, 0, 0, 0, 0, 0, 235, 236, 237, 238, - /* 1140 */ 0, 0, 43, 0, 0, 48, 0, 43, 38, 0, - /* 1150 */ 0, 36, 0, 67, 0, 77, 70, 75, 38, 38, - /* 1160 */ 22, 0, 38, 0, 22, 0, 38, 38, 38, 22, - /* 1170 */ 0, 0, 0, 22, 38, 38, 20, 22, 39, 22, - /* 1180 */ 0, 0, 122, 38, 0, 117, 68, 81, 158, 81, - /* 1190 */ 68, 43, 158, 81, 152, 158, 4, 2, 132, 120, - /* 1200 */ 81, 117, 104, 117, 0, 277, 277, 121, 277, 277, - /* 1210 */ 277, 277, 277, 277, 277, 277, 277, 38, 277, 277, - /* 1220 */ 38, 38, 69, 38, 38, 38, 277, 69, 68, 277, - /* 1230 */ 22, 69, 68, 43, 277, 69, 68, 277, 69, 80, - /* 1240 */ 277, 38, 69, 277, 277, 69, 277, 277, 81, 277, - /* 1250 */ 277, 277, 277, 277, 80, 277, 81, 80, 69, 81, - /* 1260 */ 69, 68, 68, 38, 38, 69, 68, 68, 80, 68, - /* 1270 */ 68, 38, 38, 277, 277, 78, 0, 38, 277, 277, - /* 1280 */ 80, 38, 22, 277, 277, 80, 68, 277, 22, 22, - /* 1290 */ 48, 69, 68, 22, 22, 277, 277, 69, 69, 68, - /* 1300 */ 79, 69, 38, 38, 68, 68, 38, 38, 38, 69, - /* 1310 */ 47, 38, 0, 0, 68, 38, 38, 94, 0, 38, - /* 1320 */ 38, 38, 21, 21, 38, 38, 37, 68, 38, 68, - /* 1330 */ 68, 38, 38, 22, 43, 20, 38, 38, 38, 36, - /* 1340 */ 82, 22, 38, 94, 277, 277, 277, 277, 277, 94, - /* 1350 */ 277, 94, 277, 277, 277, 277, 277, 277, 277, 277, - /* 1360 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 1370 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 1380 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 1390 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 1400 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 1410 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 1420 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 1430 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 1440 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 1450 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 1460 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 1470 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 1480 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 1490 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 1500 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 1510 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 1520 */ 277, 277, 277, 277, 277, 277, 277, 277, 277, 277, - /* 1530 */ 277, + /* 0 */ 246, 267, 268, 210, 210, 207, 208, 229, 225, 216, + /* 10 */ 216, 229, 258, 259, 231, 210, 223, 223, 18, 236, + /* 20 */ 20, 0, 0, 210, 246, 232, 232, 27, 246, 216, + /* 30 */ 30, 12, 13, 14, 15, 16, 258, 259, 242, 39, + /* 40 */ 258, 259, 237, 21, 248, 232, 24, 25, 26, 27, + /* 50 */ 28, 29, 30, 31, 32, 234, 12, 13, 14, 15, + /* 60 */ 16, 242, 241, 242, 245, 218, 47, 248, 221, 20, + /* 70 */ 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, + /* 80 */ 59, 60, 61, 62, 63, 64, 65, 66, 38, 70, + /* 90 */ 12, 13, 14, 15, 16, 21, 20, 78, 24, 25, + /* 100 */ 26, 27, 28, 29, 30, 31, 32, 107, 0, 210, + /* 110 */ 110, 111, 112, 113, 114, 216, 116, 117, 118, 119, + /* 120 */ 120, 121, 122, 123, 210, 47, 14, 15, 16, 46, + /* 130 */ 216, 232, 24, 25, 26, 27, 28, 29, 30, 31, + /* 140 */ 32, 225, 49, 124, 51, 69, 232, 54, 232, 20, + /* 150 */ 57, 210, 59, 60, 104, 62, 78, 216, 20, 128, + /* 160 */ 210, 142, 83, 84, 85, 86, 87, 88, 89, 90, + /* 170 */ 91, 92, 93, 232, 95, 96, 97, 98, 99, 100, + /* 180 */ 264, 176, 232, 20, 165, 166, 167, 168, 169, 170, + /* 190 */ 171, 172, 173, 2, 18, 204, 137, 20, 139, 23, + /* 200 */ 210, 217, 124, 12, 13, 14, 15, 16, 210, 225, + /* 210 */ 225, 35, 181, 182, 216, 265, 225, 233, 233, 134, + /* 220 */ 142, 45, 204, 232, 274, 275, 276, 277, 204, 279, + /* 230 */ 232, 46, 251, 242, 149, 176, 203, 246, 205, 204, + /* 240 */ 20, 251, 251, 165, 166, 167, 168, 169, 170, 171, + /* 250 */ 172, 173, 176, 262, 263, 264, 265, 266, 12, 13, + /* 260 */ 225, 270, 271, 282, 246, 210, 20, 232, 22, 80, + /* 270 */ 246, 216, 282, 282, 226, 204, 295, 242, 22, 57, + /* 280 */ 299, 246, 106, 61, 38, 295, 295, 232, 155, 299, + /* 290 */ 299, 0, 212, 47, 38, 43, 225, 262, 263, 264, + /* 300 */ 265, 266, 222, 232, 82, 270, 271, 131, 132, 133, + /* 310 */ 230, 135, 226, 242, 0, 69, 140, 246, 185, 186, + /* 320 */ 187, 188, 189, 210, 148, 210, 150, 36, 152, 153, + /* 330 */ 154, 216, 20, 262, 263, 264, 265, 266, 92, 176, + /* 340 */ 63, 270, 271, 272, 225, 232, 226, 232, 92, 212, + /* 350 */ 104, 232, 176, 210, 20, 284, 12, 13, 14, 216, + /* 360 */ 104, 290, 291, 49, 20, 51, 22, 230, 54, 12, + /* 370 */ 13, 57, 204, 59, 60, 232, 62, 20, 265, 22, + /* 380 */ 226, 69, 38, 264, 138, 108, 109, 204, 275, 276, + /* 390 */ 277, 47, 279, 225, 138, 38, 1, 2, 224, 0, + /* 400 */ 232, 155, 156, 157, 47, 159, 213, 217, 215, 235, + /* 410 */ 242, 155, 156, 69, 246, 225, 204, 12, 13, 14, + /* 420 */ 15, 16, 176, 233, 209, 204, 69, 175, 201, 246, + /* 430 */ 262, 263, 264, 265, 266, 220, 92, 225, 270, 271, + /* 440 */ 272, 225, 227, 282, 232, 46, 225, 231, 104, 92, + /* 450 */ 226, 225, 236, 232, 242, 124, 295, 231, 246, 291, + /* 460 */ 299, 104, 236, 242, 130, 70, 158, 246, 160, 161, + /* 470 */ 162, 163, 164, 142, 262, 263, 264, 265, 251, 226, + /* 480 */ 12, 13, 138, 262, 263, 264, 265, 266, 20, 204, + /* 490 */ 22, 270, 271, 272, 44, 138, 165, 204, 0, 155, + /* 500 */ 156, 157, 281, 159, 204, 254, 38, 217, 3, 282, + /* 510 */ 225, 204, 155, 156, 157, 225, 159, 232, 68, 210, + /* 520 */ 20, 71, 295, 233, 225, 225, 299, 242, 204, 22, + /* 530 */ 4, 246, 232, 204, 260, 236, 131, 69, 20, 246, + /* 540 */ 22, 232, 242, 205, 46, 38, 246, 262, 263, 264, + /* 550 */ 265, 266, 278, 246, 225, 270, 271, 272, 40, 302, + /* 560 */ 92, 232, 262, 263, 264, 265, 281, 14, 215, 204, + /* 570 */ 246, 242, 104, 20, 265, 246, 210, 204, 260, 12, + /* 580 */ 13, 14, 216, 232, 275, 276, 277, 20, 279, 22, + /* 590 */ 239, 262, 263, 264, 265, 266, 278, 204, 232, 270, + /* 600 */ 271, 272, 197, 260, 2, 38, 138, 204, 204, 251, + /* 610 */ 281, 246, 12, 13, 12, 13, 14, 15, 16, 246, + /* 620 */ 20, 278, 22, 155, 156, 157, 210, 159, 225, 209, + /* 630 */ 130, 204, 216, 204, 204, 232, 69, 204, 38, 246, + /* 640 */ 282, 204, 204, 67, 176, 242, 70, 227, 232, 246, + /* 650 */ 246, 12, 13, 295, 251, 174, 175, 299, 204, 92, + /* 660 */ 67, 22, 12, 13, 19, 262, 263, 264, 265, 69, + /* 670 */ 20, 104, 22, 246, 67, 246, 246, 38, 33, 246, + /* 680 */ 293, 36, 225, 246, 246, 282, 204, 42, 38, 44, + /* 690 */ 204, 204, 92, 236, 1, 2, 73, 192, 295, 76, + /* 700 */ 246, 235, 299, 177, 104, 138, 204, 73, 73, 73, + /* 710 */ 76, 76, 76, 68, 0, 0, 71, 0, 67, 69, + /* 720 */ 47, 70, 155, 156, 157, 69, 159, 225, 246, 199, + /* 730 */ 200, 92, 246, 246, 232, 79, 22, 22, 138, 22, + /* 740 */ 287, 69, 92, 104, 242, 21, 101, 67, 246, 67, + /* 750 */ 70, 38, 70, 81, 104, 155, 156, 157, 34, 159, + /* 760 */ 210, 207, 204, 280, 262, 263, 264, 265, 266, 261, + /* 770 */ 225, 126, 270, 271, 129, 67, 67, 138, 70, 70, + /* 780 */ 296, 20, 232, 225, 283, 210, 36, 194, 138, 144, + /* 790 */ 232, 146, 257, 38, 155, 156, 67, 214, 136, 70, + /* 800 */ 242, 251, 210, 196, 246, 155, 156, 157, 252, 159, + /* 810 */ 204, 67, 115, 67, 70, 265, 70, 104, 210, 240, + /* 820 */ 262, 263, 264, 265, 124, 275, 276, 277, 155, 279, + /* 830 */ 210, 225, 282, 12, 13, 14, 15, 16, 232, 67, + /* 840 */ 20, 35, 70, 67, 33, 295, 70, 36, 242, 299, + /* 850 */ 238, 67, 246, 42, 70, 44, 238, 67, 300, 301, + /* 860 */ 70, 256, 67, 57, 204, 70, 242, 61, 262, 263, + /* 870 */ 264, 265, 266, 204, 20, 250, 212, 271, 72, 68, + /* 880 */ 74, 75, 71, 77, 67, 225, 232, 70, 82, 20, + /* 890 */ 67, 70, 232, 70, 225, 67, 243, 212, 70, 212, + /* 900 */ 210, 232, 242, 212, 20, 206, 246, 204, 225, 249, + /* 910 */ 232, 242, 214, 225, 225, 246, 210, 225, 249, 225, + /* 920 */ 225, 225, 262, 263, 264, 265, 225, 225, 225, 225, + /* 930 */ 225, 262, 263, 264, 265, 232, 125, 214, 127, 206, + /* 940 */ 129, 145, 256, 204, 209, 242, 209, 20, 232, 246, + /* 950 */ 184, 204, 242, 292, 4, 243, 156, 146, 183, 292, + /* 960 */ 191, 250, 255, 289, 225, 262, 263, 264, 265, 19, + /* 970 */ 190, 232, 225, 247, 246, 178, 246, 204, 247, 232, + /* 980 */ 261, 242, 246, 33, 179, 246, 36, 175, 232, 242, + /* 990 */ 20, 41, 0, 246, 44, 115, 249, 294, 225, 0, + /* 1000 */ 260, 262, 263, 264, 265, 232, 204, 286, 288, 262, + /* 1010 */ 263, 264, 265, 198, 273, 242, 298, 285, 68, 246, + /* 1020 */ 195, 71, 249, 193, 297, 303, 69, 225, 269, 247, + /* 1030 */ 204, 246, 246, 246, 232, 262, 263, 264, 265, 247, + /* 1040 */ 301, 127, 244, 209, 242, 232, 243, 209, 246, 57, + /* 1050 */ 221, 225, 69, 61, 204, 214, 57, 214, 232, 232, + /* 1060 */ 61, 228, 210, 206, 262, 263, 264, 265, 242, 209, + /* 1070 */ 219, 253, 246, 211, 82, 225, 0, 219, 204, 202, + /* 1080 */ 0, 82, 232, 60, 0, 38, 151, 38, 262, 263, + /* 1090 */ 264, 265, 242, 101, 102, 103, 246, 105, 38, 225, + /* 1100 */ 101, 102, 103, 38, 105, 151, 232, 204, 0, 38, + /* 1110 */ 38, 151, 262, 263, 264, 265, 242, 0, 0, 38, + /* 1120 */ 246, 38, 0, 69, 142, 141, 104, 138, 225, 0, + /* 1130 */ 0, 134, 50, 204, 0, 232, 262, 263, 264, 265, + /* 1140 */ 0, 204, 81, 0, 0, 242, 0, 0, 0, 246, + /* 1150 */ 0, 0, 0, 0, 225, 0, 0, 0, 0, 115, + /* 1160 */ 0, 232, 225, 0, 0, 262, 263, 264, 265, 232, + /* 1170 */ 0, 242, 0, 0, 0, 246, 204, 0, 0, 242, + /* 1180 */ 0, 22, 204, 246, 0, 0, 0, 0, 0, 0, + /* 1190 */ 48, 262, 263, 264, 265, 0, 0, 225, 0, 262, + /* 1200 */ 263, 264, 265, 225, 232, 43, 38, 36, 43, 0, + /* 1210 */ 232, 204, 0, 0, 242, 78, 67, 204, 246, 38, + /* 1220 */ 242, 76, 22, 0, 246, 0, 22, 0, 38, 38, + /* 1230 */ 38, 38, 225, 22, 262, 263, 264, 265, 225, 232, + /* 1240 */ 262, 263, 264, 265, 38, 232, 38, 0, 22, 242, + /* 1250 */ 0, 22, 38, 246, 39, 242, 0, 22, 20, 246, + /* 1260 */ 0, 130, 147, 204, 0, 22, 38, 143, 130, 262, + /* 1270 */ 263, 264, 265, 0, 0, 262, 263, 264, 265, 0, + /* 1280 */ 43, 127, 180, 81, 225, 69, 125, 67, 67, 70, + /* 1290 */ 180, 232, 70, 69, 174, 4, 130, 67, 81, 81, + /* 1300 */ 69, 242, 70, 69, 38, 246, 70, 67, 69, 67, + /* 1310 */ 38, 70, 67, 180, 70, 67, 70, 2, 38, 38, + /* 1320 */ 38, 262, 263, 264, 265, 38, 0, 70, 69, 128, + /* 1330 */ 155, 69, 81, 70, 79, 70, 69, 69, 69, 43, + /* 1340 */ 69, 22, 81, 38, 69, 38, 38, 70, 70, 38, + /* 1350 */ 38, 81, 69, 69, 38, 70, 80, 69, 125, 70, + /* 1360 */ 70, 69, 69, 22, 22, 38, 38, 69, 48, 47, + /* 1370 */ 69, 69, 22, 38, 38, 38, 38, 38, 38, 22, + /* 1380 */ 94, 82, 38, 38, 38, 38, 38, 38, 94, 94, + /* 1390 */ 38, 94, 38, 38, 38, 0, 38, 36, 0, 0, + /* 1400 */ 38, 37, 43, 0, 104, 22, 21, 304, 22, 22, + /* 1410 */ 21, 20, 304, 304, 304, 304, 304, 304, 304, 304, + /* 1420 */ 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, + /* 1430 */ 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, + /* 1440 */ 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, + /* 1450 */ 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, + /* 1460 */ 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, + /* 1470 */ 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, + /* 1480 */ 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, + /* 1490 */ 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, + /* 1500 */ 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, + /* 1510 */ 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, + /* 1520 */ 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, + /* 1530 */ 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, + /* 1540 */ 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, + /* 1550 */ 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, + /* 1560 */ 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, + /* 1570 */ 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, + /* 1580 */ 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, + /* 1590 */ 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, + /* 1600 */ 304, 304, 304, 304, 304, 304, 304, 304, 304, 304, + /* 1610 */ 304, 304, 304, }; -#define YY_SHIFT_COUNT (444) +#define YY_SHIFT_COUNT (511) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (1319) +#define YY_SHIFT_MAX (1403) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 615, 192, 265, 280, 280, 280, 280, 449, 280, 280, - /* 10 */ 480, 525, 98, 466, 480, 480, 480, 480, 480, 480, - /* 20 */ 480, 480, 480, 480, 480, 480, 480, 480, 480, 480, - /* 30 */ 480, 480, 480, 133, 133, 133, 102, 228, 228, 78, - /* 40 */ 35, 35, 228, 35, 35, 35, 35, 213, 262, 369, - /* 50 */ 369, 255, 456, 262, 35, 35, 262, 35, 262, 456, - /* 60 */ 262, 262, 35, 439, 0, 13, 13, 743, 106, 493, - /* 70 */ 714, 714, 714, 714, 714, 714, 714, 714, 714, 714, - /* 80 */ 714, 714, 714, 714, 714, 714, 714, 714, 714, 714, - /* 90 */ 928, 417, 121, 214, 214, 214, 347, 469, 456, 262, - /* 100 */ 262, 262, 443, 91, 91, 91, 91, 91, 313, 66, - /* 110 */ 181, 187, 186, 116, 395, 301, 437, 243, 437, 545, - /* 120 */ 401, 364, 701, 814, 728, 744, 744, 814, 856, 213, - /* 130 */ 469, 879, 213, 213, 814, 213, 892, 262, 262, 262, - /* 140 */ 262, 262, 262, 262, 262, 262, 262, 262, 814, 892, - /* 150 */ 856, 439, 469, 879, 439, 933, 793, 795, 840, 793, - /* 160 */ 795, 840, 840, 807, 815, 836, 846, 850, 469, 988, - /* 170 */ 903, 844, 849, 852, 956, 262, 795, 840, 840, 795, - /* 180 */ 840, 927, 469, 879, 439, 443, 439, 469, 992, 814, - /* 190 */ 439, 892, 1352, 1352, 1352, 1352, 1352, 48, 349, 760, - /* 200 */ 1086, 1051, 475, 934, 785, 801, 527, 156, 874, 874, - /* 210 */ 874, 874, 874, 874, 874, 32, 19, 340, 625, 625, - /* 220 */ 625, 625, 440, 529, 613, 617, 729, 758, 772, 118, - /* 230 */ 458, 602, 696, 605, 571, 636, 372, 697, 547, 738, - /* 240 */ 302, 751, 756, 759, 764, 770, 618, 737, 789, 794, - /* 250 */ 799, 803, 822, 825, 484, 1088, 986, 964, 1096, 1101, - /* 260 */ 1052, 978, 1109, 1111, 1032, 1113, 1114, 1000, 1116, 1117, - /* 270 */ 1123, 1125, 1126, 1127, 1107, 1131, 1132, 1133, 1134, 1135, - /* 280 */ 1140, 1141, 1099, 1143, 1097, 1144, 1146, 1110, 1115, 1104, - /* 290 */ 1149, 1150, 1152, 1154, 1078, 1082, 1120, 1121, 1138, 1161, - /* 300 */ 1124, 1128, 1129, 1130, 1136, 1137, 1163, 1142, 1165, 1147, - /* 310 */ 1139, 1170, 1151, 1145, 1171, 1155, 1172, 1157, 1156, 1180, - /* 320 */ 1181, 1060, 1184, 1118, 1148, 1068, 1106, 1108, 1030, 1153, - /* 330 */ 1112, 1158, 1122, 1160, 1162, 1164, 1166, 1119, 1159, 1168, - /* 340 */ 1167, 1034, 1169, 1173, 1174, 1042, 1175, 1177, 1176, 1178, - /* 350 */ 1037, 1192, 1179, 1182, 1183, 1185, 1186, 1187, 1195, 1066, - /* 360 */ 1188, 1189, 1193, 1194, 1191, 1196, 1198, 1199, 1079, 1201, - /* 370 */ 1204, 1190, 1084, 1202, 1197, 1200, 1205, 1208, 1218, 1221, - /* 380 */ 1222, 1225, 1226, 1224, 1228, 1233, 1231, 1229, 1234, 1236, - /* 390 */ 1232, 1239, 1237, 1240, 1243, 1246, 1223, 1249, 1255, 1257, - /* 400 */ 1260, 1258, 1259, 1264, 1098, 1261, 1262, 1203, 1265, 1266, - /* 410 */ 1242, 1263, 1267, 1268, 1269, 1270, 1273, 1278, 1281, 1282, - /* 420 */ 1271, 1283, 1286, 1287, 1290, 1293, 1294, 1298, 1299, 1300, - /* 430 */ 1276, 1277, 1303, 1291, 1312, 1304, 1289, 1313, 1318, 1272, - /* 440 */ 1301, 1311, 1319, 1302, 1315, + /* 0 */ 176, 246, 344, 357, 357, 357, 357, 468, 357, 357, + /* 10 */ 600, 650, 76, 567, 600, 600, 600, 600, 600, 600, + /* 20 */ 600, 600, 600, 600, 600, 600, 600, 600, 600, 600, + /* 30 */ 600, 600, 600, 312, 312, 312, 163, 639, 639, 59, + /* 40 */ 49, 49, 5, 639, 49, 49, 49, 49, 49, 49, + /* 50 */ 83, 129, 138, 138, 5, 177, 129, 49, 49, 129, + /* 60 */ 49, 129, 177, 129, 129, 49, 185, 0, 19, 78, + /* 70 */ 78, 74, 806, 256, 93, 256, 256, 256, 256, 256, + /* 80 */ 256, 256, 256, 256, 256, 256, 256, 256, 256, 256, + /* 90 */ 256, 256, 256, 256, 518, 399, 334, 334, 334, 498, + /* 100 */ 220, 177, 129, 129, 129, 189, 79, 79, 79, 79, + /* 110 */ 79, 79, 645, 22, 314, 405, 133, 222, 31, 507, + /* 120 */ 500, 481, 252, 481, 553, 505, 526, 761, 750, 755, + /* 130 */ 662, 761, 761, 697, 700, 700, 761, 820, 177, 854, + /* 140 */ 83, 220, 869, 83, 83, 761, 83, 884, 129, 129, + /* 150 */ 129, 129, 129, 129, 129, 129, 129, 129, 129, 755, + /* 160 */ 755, 761, 884, 220, 820, 796, 177, 854, 185, 220, + /* 170 */ 869, 185, 927, 766, 775, 800, 766, 775, 800, 800, + /* 180 */ 769, 780, 805, 797, 812, 220, 970, 880, 815, 825, + /* 190 */ 830, 957, 129, 775, 800, 800, 775, 800, 914, 220, + /* 200 */ 869, 185, 189, 185, 220, 983, 755, 755, 761, 185, + /* 210 */ 884, 1412, 1412, 1412, 1412, 1412, 21, 811, 108, 950, + /* 220 */ 992, 999, 191, 602, 308, 821, 44, 44, 44, 44, + /* 230 */ 44, 44, 44, 450, 277, 395, 331, 112, 112, 112, + /* 240 */ 112, 291, 85, 576, 623, 634, 635, 636, 714, 715, + /* 250 */ 717, 724, 651, 680, 682, 693, 530, 593, 607, 708, + /* 260 */ 673, 709, 672, 729, 744, 746, 772, 776, 50, 713, + /* 270 */ 784, 790, 795, 817, 823, 828, 656, 1076, 1080, 1023, + /* 280 */ 1084, 1047, 935, 1049, 1060, 1065, 954, 1108, 1071, 1072, + /* 290 */ 960, 1117, 1081, 1118, 1083, 1122, 1054, 982, 984, 1022, + /* 300 */ 989, 1129, 1130, 1082, 997, 1134, 1140, 1061, 1143, 1144, + /* 310 */ 1146, 1147, 1148, 1150, 1151, 1152, 1153, 1155, 1156, 1157, + /* 320 */ 1158, 1044, 1160, 1163, 1164, 1170, 1172, 1173, 1159, 1174, + /* 330 */ 1177, 1178, 1180, 1184, 1185, 1186, 1187, 1188, 1162, 1189, + /* 340 */ 1142, 1195, 1196, 1168, 1171, 1165, 1198, 1209, 1212, 1213, + /* 350 */ 1137, 1145, 1181, 1149, 1200, 1223, 1190, 1191, 1192, 1193, + /* 360 */ 1149, 1206, 1208, 1225, 1204, 1227, 1211, 1215, 1247, 1226, + /* 370 */ 1214, 1250, 1229, 1256, 1235, 1238, 1260, 1131, 1115, 1228, + /* 380 */ 1264, 1124, 1243, 1138, 1154, 1273, 1274, 1166, 1279, 1216, + /* 390 */ 1237, 1161, 1220, 1221, 1102, 1219, 1230, 1222, 1224, 1231, + /* 400 */ 1232, 1234, 1236, 1240, 1202, 1239, 1242, 1110, 1241, 1244, + /* 410 */ 1217, 1120, 1245, 1218, 1246, 1248, 1133, 1291, 1266, 1272, + /* 420 */ 1280, 1281, 1282, 1287, 1315, 1175, 1251, 1257, 1259, 1262, + /* 430 */ 1263, 1265, 1267, 1268, 1201, 1269, 1326, 1296, 1233, 1271, + /* 440 */ 1255, 1261, 1270, 1319, 1275, 1276, 1277, 1305, 1307, 1283, + /* 450 */ 1278, 1308, 1284, 1285, 1311, 1288, 1289, 1312, 1292, 1290, + /* 460 */ 1316, 1293, 1286, 1294, 1295, 1297, 1341, 1299, 1298, 1327, + /* 470 */ 1300, 1301, 1302, 1328, 1149, 1342, 1320, 1322, 1350, 1335, + /* 480 */ 1336, 1337, 1338, 1339, 1340, 1344, 1357, 1345, 1149, 1346, + /* 490 */ 1347, 1348, 1349, 1352, 1354, 1355, 1356, 1395, 1358, 1361, + /* 500 */ 1359, 1398, 1362, 1364, 1399, 1403, 1383, 1385, 1386, 1387, + /* 510 */ 1389, 1391, }; -#define YY_REDUCE_COUNT (196) -#define YY_REDUCE_MIN (-238) -#define YY_REDUCE_MAX (906) +#define YY_REDUCE_COUNT (215) +#define YY_REDUCE_MIN (-266) +#define YY_REDUCE_MAX (1059) static const short yy_reduce_ofst[] = { - /* 0 */ -55, -17, 26, 183, -165, 206, 229, 288, 72, 409, - /* 10 */ 461, 386, -187, 467, 518, 524, 472, 548, 586, 629, - /* 20 */ 660, 691, 700, 722, 731, 761, 769, 792, 831, 839, - /* 30 */ 862, 870, 901, -156, 246, 463, 135, -8, 74, -222, - /* 40 */ -170, -169, -223, -150, 49, 79, 174, -123, 222, -83, - /* 50 */ 92, -39, -215, 311, 178, 321, 327, 399, 425, -162, - /* 60 */ 429, 522, 427, -152, -238, -238, -238, 85, -147, -137, - /* 70 */ -140, 21, 75, 132, 177, 182, 209, 258, 276, 319, - /* 80 */ 326, 328, 338, 351, 452, 491, 495, 496, 500, 505, - /* 90 */ -105, 145, 41, 84, 203, 226, 259, 37, -214, 184, - /* 100 */ -3, 342, 308, 370, 383, 394, 423, 528, 348, 502, - /* 110 */ 450, 479, 552, 516, 596, 555, 537, 537, 537, 590, - /* 120 */ 541, 570, 606, 648, 632, 644, 656, 686, 650, 695, - /* 130 */ 683, 681, 715, 717, 720, 721, 732, 713, 716, 718, - /* 140 */ 719, 723, 730, 740, 742, 745, 746, 747, 734, 733, - /* 150 */ 703, 752, 753, 726, 765, 727, 699, 741, 749, 710, - /* 160 */ 757, 763, 766, 748, 739, 750, 754, 537, 805, 784, - /* 170 */ 773, 755, 767, 762, 783, 590, 802, 811, 819, 821, - /* 180 */ 820, 826, 842, 829, 866, 858, 872, 848, 860, 873, - /* 190 */ 876, 889, 861, 882, 884, 893, 906, + /* 0 */ 227, -9, 71, 168, 221, 285, 329, 403, 35, 502, + /* 10 */ 558, 606, 550, 660, 669, 703, 739, 747, 773, 212, + /* 20 */ 300, 802, 826, 850, 874, 903, 929, 937, 972, 978, + /* 30 */ 1007, 1013, 1059, -50, 113, 309, -10, -222, -218, -19, + /* 40 */ -207, -206, 358, -246, -187, -101, -86, -59, -2, 55, + /* 50 */ 80, -217, -84, 119, 161, -181, -16, 115, 143, 216, + /* 60 */ 366, 190, -179, 226, 290, 416, 215, -195, -266, -266, + /* 70 */ -266, 33, 174, 18, 193, 24, 183, 293, 307, 324, + /* 80 */ 365, 373, 393, 404, 427, 429, 430, 433, 437, 438, + /* 90 */ 454, 482, 486, 487, -202, 137, 274, 318, 343, 420, + /* 100 */ 351, -204, -15, 299, 457, -153, 48, 86, 120, 154, + /* 110 */ 224, 253, 251, 338, 353, 257, 387, 466, 453, 554, + /* 120 */ 508, 483, 483, 483, 545, 484, 501, 575, 535, 583, + /* 130 */ 556, 592, 608, 579, 612, 618, 620, 605, 624, 625, + /* 140 */ 664, 654, 653, 685, 687, 690, 691, 699, 683, 688, + /* 150 */ 689, 692, 694, 695, 696, 701, 702, 704, 705, 698, + /* 160 */ 723, 706, 733, 678, 686, 707, 710, 711, 735, 716, + /* 170 */ 712, 737, 719, 661, 726, 728, 667, 731, 730, 736, + /* 180 */ 674, 720, 721, 732, 483, 756, 740, 741, 722, 718, + /* 190 */ 727, 759, 545, 782, 785, 786, 792, 787, 798, 813, + /* 200 */ 803, 834, 829, 838, 827, 833, 841, 843, 852, 860, + /* 210 */ 857, 818, 851, 858, 862, 877, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 10 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 20 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 30 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 40 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1101, 1048, 1048, - /* 50 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 60 */ 1048, 1048, 1048, 1099, 1048, 1327, 1048, 1214, 1048, 1048, - /* 70 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 80 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 90 */ 1048, 1048, 1101, 1338, 1338, 1338, 1099, 1048, 1048, 1048, - /* 100 */ 1048, 1048, 1183, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 110 */ 1402, 1048, 1136, 1362, 1048, 1354, 1330, 1344, 1331, 1048, - /* 120 */ 1387, 1347, 1240, 1048, 1219, 1216, 1216, 1048, 1048, 1101, - /* 130 */ 1048, 1048, 1101, 1101, 1048, 1101, 1048, 1048, 1048, 1048, - /* 140 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 150 */ 1048, 1099, 1048, 1048, 1099, 1048, 1369, 1367, 1048, 1369, - /* 160 */ 1367, 1048, 1048, 1381, 1377, 1360, 1358, 1344, 1048, 1048, - /* 170 */ 1048, 1405, 1393, 1389, 1048, 1048, 1367, 1048, 1048, 1367, - /* 180 */ 1048, 1227, 1048, 1048, 1099, 1048, 1099, 1048, 1152, 1048, - /* 190 */ 1099, 1048, 1242, 1186, 1186, 1102, 1053, 1048, 1048, 1048, - /* 200 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1292, 1380, - /* 210 */ 1379, 1291, 1304, 1303, 1302, 1048, 1048, 1048, 1286, 1287, - /* 220 */ 1285, 1284, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 230 */ 1048, 1048, 1048, 1328, 1048, 1390, 1394, 1048, 1048, 1048, - /* 240 */ 1270, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 250 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 260 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 270 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 280 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 290 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 300 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 310 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 320 */ 1048, 1048, 1048, 1048, 1048, 1048, 1351, 1361, 1048, 1048, - /* 330 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1270, 1048, - /* 340 */ 1378, 1048, 1337, 1333, 1048, 1048, 1329, 1048, 1048, 1388, - /* 350 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1323, 1048, - /* 360 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 370 */ 1048, 1048, 1048, 1048, 1048, 1269, 1048, 1048, 1048, 1048, - /* 380 */ 1048, 1048, 1048, 1180, 1048, 1048, 1048, 1048, 1048, 1048, - /* 390 */ 1048, 1048, 1048, 1048, 1048, 1048, 1165, 1163, 1162, 1161, - /* 400 */ 1048, 1158, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 410 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 420 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 430 */ 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, 1048, - /* 440 */ 1048, 1048, 1048, 1048, 1048, + /* 0 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 10 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 20 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 30 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 40 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 50 */ 1204, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 60 */ 1151, 1151, 1151, 1151, 1151, 1151, 1202, 1331, 1151, 1462, + /* 70 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 80 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 90 */ 1151, 1151, 1151, 1151, 1151, 1204, 1473, 1473, 1473, 1202, + /* 100 */ 1151, 1151, 1151, 1151, 1151, 1289, 1151, 1151, 1151, 1151, + /* 110 */ 1151, 1151, 1365, 1151, 1151, 1537, 1151, 1242, 1497, 1151, + /* 120 */ 1489, 1465, 1479, 1466, 1151, 1522, 1482, 1151, 1151, 1151, + /* 130 */ 1357, 1151, 1151, 1336, 1333, 1333, 1151, 1151, 1151, 1151, + /* 140 */ 1204, 1151, 1151, 1204, 1204, 1151, 1204, 1151, 1151, 1151, + /* 150 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 160 */ 1151, 1151, 1151, 1151, 1151, 1367, 1151, 1151, 1202, 1151, + /* 170 */ 1151, 1202, 1151, 1504, 1502, 1151, 1504, 1502, 1151, 1151, + /* 180 */ 1516, 1512, 1495, 1493, 1479, 1151, 1151, 1151, 1540, 1528, + /* 190 */ 1524, 1151, 1151, 1502, 1151, 1151, 1502, 1151, 1344, 1151, + /* 200 */ 1151, 1202, 1151, 1202, 1151, 1258, 1151, 1151, 1151, 1202, + /* 210 */ 1151, 1359, 1292, 1292, 1205, 1156, 1151, 1151, 1151, 1151, + /* 220 */ 1151, 1151, 1151, 1151, 1151, 1151, 1427, 1515, 1514, 1426, + /* 230 */ 1439, 1438, 1437, 1151, 1151, 1151, 1151, 1421, 1422, 1420, + /* 240 */ 1419, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 250 */ 1151, 1151, 1151, 1151, 1151, 1463, 1151, 1525, 1529, 1151, + /* 260 */ 1151, 1151, 1404, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 270 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 280 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 290 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 300 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 310 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 320 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 330 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 340 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 350 */ 1151, 1151, 1151, 1303, 1151, 1151, 1151, 1151, 1151, 1151, + /* 360 */ 1228, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 370 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 380 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 390 */ 1151, 1151, 1486, 1496, 1151, 1151, 1151, 1151, 1151, 1151, + /* 400 */ 1151, 1151, 1151, 1151, 1404, 1151, 1513, 1151, 1472, 1468, + /* 410 */ 1151, 1151, 1464, 1151, 1151, 1523, 1151, 1151, 1151, 1151, + /* 420 */ 1151, 1151, 1151, 1151, 1458, 1151, 1151, 1151, 1151, 1151, + /* 430 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 440 */ 1151, 1403, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1286, + /* 450 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 460 */ 1151, 1151, 1271, 1269, 1268, 1267, 1151, 1264, 1151, 1151, + /* 470 */ 1151, 1151, 1151, 1151, 1294, 1151, 1151, 1151, 1151, 1151, + /* 480 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1214, 1151, + /* 490 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 500 */ 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, + /* 510 */ 1151, 1151, }; /********** End of lemon-generated parsing tables *****************************/ @@ -798,21 +828,21 @@ static const char *const yyTokenName[] = { /* 64 */ "SINGLE_STABLE", /* 65 */ "STREAM_MODE", /* 66 */ "RETENTIONS", - /* 67 */ "TABLE", - /* 68 */ "NK_LP", - /* 69 */ "NK_RP", - /* 70 */ "STABLE", - /* 71 */ "ADD", - /* 72 */ "COLUMN", - /* 73 */ "MODIFY", - /* 74 */ "RENAME", - /* 75 */ "TAG", - /* 76 */ "SET", - /* 77 */ "NK_EQ", - /* 78 */ "USING", - /* 79 */ "TAGS", - /* 80 */ "NK_DOT", - /* 81 */ "NK_COMMA", + /* 67 */ "NK_COMMA", + /* 68 */ "TABLE", + /* 69 */ "NK_LP", + /* 70 */ "NK_RP", + /* 71 */ "STABLE", + /* 72 */ "ADD", + /* 73 */ "COLUMN", + /* 74 */ "MODIFY", + /* 75 */ "RENAME", + /* 76 */ "TAG", + /* 77 */ "SET", + /* 78 */ "NK_EQ", + /* 79 */ "USING", + /* 80 */ "TAGS", + /* 81 */ "NK_DOT", /* 82 */ "COMMENT", /* 83 */ "BOOL", /* 84 */ "TINYINT", @@ -847,167 +877,194 @@ static const char *const yyTokenName[] = { /* 113 */ "FUNCTIONS", /* 114 */ "INDEXES", /* 115 */ "FROM", - /* 116 */ "LIKE", - /* 117 */ "INDEX", - /* 118 */ "FULLTEXT", - /* 119 */ "FUNCTION", - /* 120 */ "INTERVAL", - /* 121 */ "TOPIC", - /* 122 */ "AS", - /* 123 */ "DESC", - /* 124 */ "DESCRIBE", - /* 125 */ "RESET", - /* 126 */ "QUERY", - /* 127 */ "EXPLAIN", - /* 128 */ "ANALYZE", - /* 129 */ "VERBOSE", - /* 130 */ "NK_BOOL", - /* 131 */ "RATIO", - /* 132 */ "NULL", - /* 133 */ "NK_VARIABLE", - /* 134 */ "NK_UNDERLINE", - /* 135 */ "ROWTS", - /* 136 */ "TBNAME", - /* 137 */ "QSTARTTS", - /* 138 */ "QENDTS", - /* 139 */ "WSTARTTS", - /* 140 */ "WENDTS", - /* 141 */ "WDURATION", - /* 142 */ "BETWEEN", - /* 143 */ "IS", - /* 144 */ "NK_LT", - /* 145 */ "NK_GT", - /* 146 */ "NK_LE", - /* 147 */ "NK_GE", - /* 148 */ "NK_NE", - /* 149 */ "MATCH", - /* 150 */ "NMATCH", - /* 151 */ "IN", - /* 152 */ "JOIN", - /* 153 */ "INNER", - /* 154 */ "SELECT", - /* 155 */ "DISTINCT", - /* 156 */ "WHERE", - /* 157 */ "PARTITION", - /* 158 */ "BY", - /* 159 */ "SESSION", - /* 160 */ "STATE_WINDOW", - /* 161 */ "SLIDING", - /* 162 */ "FILL", - /* 163 */ "VALUE", - /* 164 */ "NONE", - /* 165 */ "PREV", - /* 166 */ "LINEAR", - /* 167 */ "NEXT", - /* 168 */ "GROUP", - /* 169 */ "HAVING", - /* 170 */ "ORDER", - /* 171 */ "SLIMIT", - /* 172 */ "SOFFSET", - /* 173 */ "LIMIT", - /* 174 */ "OFFSET", - /* 175 */ "ASC", - /* 176 */ "NULLS", - /* 177 */ "FIRST", - /* 178 */ "LAST", - /* 179 */ "cmd", - /* 180 */ "account_options", - /* 181 */ "alter_account_options", - /* 182 */ "literal", - /* 183 */ "alter_account_option", - /* 184 */ "user_name", - /* 185 */ "dnode_endpoint", - /* 186 */ "dnode_host_name", - /* 187 */ "not_exists_opt", - /* 188 */ "db_name", - /* 189 */ "db_options", - /* 190 */ "exists_opt", - /* 191 */ "alter_db_options", - /* 192 */ "alter_db_option", - /* 193 */ "full_table_name", - /* 194 */ "column_def_list", - /* 195 */ "tags_def_opt", - /* 196 */ "table_options", - /* 197 */ "multi_create_clause", - /* 198 */ "tags_def", - /* 199 */ "multi_drop_clause", - /* 200 */ "alter_table_clause", - /* 201 */ "alter_table_options", - /* 202 */ "column_name", - /* 203 */ "type_name", - /* 204 */ "create_subtable_clause", - /* 205 */ "specific_tags_opt", - /* 206 */ "literal_list", - /* 207 */ "drop_table_clause", - /* 208 */ "col_name_list", - /* 209 */ "table_name", - /* 210 */ "column_def", - /* 211 */ "func_name_list", - /* 212 */ "alter_table_option", - /* 213 */ "col_name", - /* 214 */ "db_name_cond_opt", - /* 215 */ "like_pattern_opt", - /* 216 */ "table_name_cond", - /* 217 */ "from_db_opt", - /* 218 */ "func_name", - /* 219 */ "function_name", - /* 220 */ "index_name", - /* 221 */ "index_options", - /* 222 */ "func_list", - /* 223 */ "duration_literal", - /* 224 */ "sliding_opt", - /* 225 */ "func", - /* 226 */ "expression_list", - /* 227 */ "topic_name", - /* 228 */ "query_expression", - /* 229 */ "analyze_opt", - /* 230 */ "explain_options", - /* 231 */ "signed", - /* 232 */ "signed_literal", - /* 233 */ "table_alias", - /* 234 */ "column_alias", - /* 235 */ "expression", - /* 236 */ "pseudo_column", - /* 237 */ "column_reference", - /* 238 */ "subquery", - /* 239 */ "predicate", - /* 240 */ "compare_op", - /* 241 */ "in_op", - /* 242 */ "in_predicate_value", - /* 243 */ "boolean_value_expression", - /* 244 */ "boolean_primary", - /* 245 */ "common_expression", - /* 246 */ "from_clause", - /* 247 */ "table_reference_list", - /* 248 */ "table_reference", - /* 249 */ "table_primary", - /* 250 */ "joined_table", - /* 251 */ "alias_opt", - /* 252 */ "parenthesized_joined_table", - /* 253 */ "join_type", - /* 254 */ "search_condition", - /* 255 */ "query_specification", - /* 256 */ "set_quantifier_opt", - /* 257 */ "select_list", - /* 258 */ "where_clause_opt", - /* 259 */ "partition_by_clause_opt", - /* 260 */ "twindow_clause_opt", - /* 261 */ "group_by_clause_opt", - /* 262 */ "having_clause_opt", - /* 263 */ "select_sublist", - /* 264 */ "select_item", - /* 265 */ "fill_opt", - /* 266 */ "fill_mode", - /* 267 */ "group_by_list", - /* 268 */ "query_expression_body", - /* 269 */ "order_by_clause_opt", - /* 270 */ "slimit_clause_opt", - /* 271 */ "limit_clause_opt", - /* 272 */ "query_primary", - /* 273 */ "sort_specification_list", - /* 274 */ "sort_specification", - /* 275 */ "ordering_specification_opt", - /* 276 */ "null_ordering_opt", + /* 116 */ "ACCOUNTS", + /* 117 */ "APPS", + /* 118 */ "CONNECTIONS", + /* 119 */ "LICENCE", + /* 120 */ "QUERIES", + /* 121 */ "SCORES", + /* 122 */ "TOPICS", + /* 123 */ "VARIABLES", + /* 124 */ "LIKE", + /* 125 */ "INDEX", + /* 126 */ "FULLTEXT", + /* 127 */ "FUNCTION", + /* 128 */ "INTERVAL", + /* 129 */ "TOPIC", + /* 130 */ "AS", + /* 131 */ "DESC", + /* 132 */ "DESCRIBE", + /* 133 */ "RESET", + /* 134 */ "QUERY", + /* 135 */ "EXPLAIN", + /* 136 */ "ANALYZE", + /* 137 */ "VERBOSE", + /* 138 */ "NK_BOOL", + /* 139 */ "RATIO", + /* 140 */ "COMPACT", + /* 141 */ "VNODES", + /* 142 */ "IN", + /* 143 */ "OUTPUTTYPE", + /* 144 */ "AGGREGATE", + /* 145 */ "BUFSIZE", + /* 146 */ "STREAM", + /* 147 */ "INTO", + /* 148 */ "KILL", + /* 149 */ "CONNECTION", + /* 150 */ "MERGE", + /* 151 */ "VGROUP", + /* 152 */ "REDISTRIBUTE", + /* 153 */ "SPLIT", + /* 154 */ "SYNCDB", + /* 155 */ "NULL", + /* 156 */ "NK_VARIABLE", + /* 157 */ "NK_UNDERLINE", + /* 158 */ "ROWTS", + /* 159 */ "TBNAME", + /* 160 */ "QSTARTTS", + /* 161 */ "QENDTS", + /* 162 */ "WSTARTTS", + /* 163 */ "WENDTS", + /* 164 */ "WDURATION", + /* 165 */ "BETWEEN", + /* 166 */ "IS", + /* 167 */ "NK_LT", + /* 168 */ "NK_GT", + /* 169 */ "NK_LE", + /* 170 */ "NK_GE", + /* 171 */ "NK_NE", + /* 172 */ "MATCH", + /* 173 */ "NMATCH", + /* 174 */ "JOIN", + /* 175 */ "INNER", + /* 176 */ "SELECT", + /* 177 */ "DISTINCT", + /* 178 */ "WHERE", + /* 179 */ "PARTITION", + /* 180 */ "BY", + /* 181 */ "SESSION", + /* 182 */ "STATE_WINDOW", + /* 183 */ "SLIDING", + /* 184 */ "FILL", + /* 185 */ "VALUE", + /* 186 */ "NONE", + /* 187 */ "PREV", + /* 188 */ "LINEAR", + /* 189 */ "NEXT", + /* 190 */ "GROUP", + /* 191 */ "HAVING", + /* 192 */ "ORDER", + /* 193 */ "SLIMIT", + /* 194 */ "SOFFSET", + /* 195 */ "LIMIT", + /* 196 */ "OFFSET", + /* 197 */ "ASC", + /* 198 */ "NULLS", + /* 199 */ "FIRST", + /* 200 */ "LAST", + /* 201 */ "cmd", + /* 202 */ "account_options", + /* 203 */ "alter_account_options", + /* 204 */ "literal", + /* 205 */ "alter_account_option", + /* 206 */ "user_name", + /* 207 */ "dnode_endpoint", + /* 208 */ "dnode_host_name", + /* 209 */ "not_exists_opt", + /* 210 */ "db_name", + /* 211 */ "db_options", + /* 212 */ "exists_opt", + /* 213 */ "alter_db_options", + /* 214 */ "integer_list", + /* 215 */ "alter_db_option", + /* 216 */ "full_table_name", + /* 217 */ "column_def_list", + /* 218 */ "tags_def_opt", + /* 219 */ "table_options", + /* 220 */ "multi_create_clause", + /* 221 */ "tags_def", + /* 222 */ "multi_drop_clause", + /* 223 */ "alter_table_clause", + /* 224 */ "alter_table_options", + /* 225 */ "column_name", + /* 226 */ "type_name", + /* 227 */ "create_subtable_clause", + /* 228 */ "specific_tags_opt", + /* 229 */ "literal_list", + /* 230 */ "drop_table_clause", + /* 231 */ "col_name_list", + /* 232 */ "table_name", + /* 233 */ "column_def", + /* 234 */ "func_name_list", + /* 235 */ "alter_table_option", + /* 236 */ "col_name", + /* 237 */ "db_name_cond_opt", + /* 238 */ "like_pattern_opt", + /* 239 */ "table_name_cond", + /* 240 */ "from_db_opt", + /* 241 */ "func_name", + /* 242 */ "function_name", + /* 243 */ "index_name", + /* 244 */ "index_options", + /* 245 */ "func_list", + /* 246 */ "duration_literal", + /* 247 */ "sliding_opt", + /* 248 */ "func", + /* 249 */ "expression_list", + /* 250 */ "topic_name", + /* 251 */ "query_expression", + /* 252 */ "analyze_opt", + /* 253 */ "explain_options", + /* 254 */ "agg_func_opt", + /* 255 */ "bufsize_opt", + /* 256 */ "stream_name", + /* 257 */ "dnode_list", + /* 258 */ "signed", + /* 259 */ "signed_literal", + /* 260 */ "table_alias", + /* 261 */ "column_alias", + /* 262 */ "expression", + /* 263 */ "pseudo_column", + /* 264 */ "column_reference", + /* 265 */ "subquery", + /* 266 */ "predicate", + /* 267 */ "compare_op", + /* 268 */ "in_op", + /* 269 */ "in_predicate_value", + /* 270 */ "boolean_value_expression", + /* 271 */ "boolean_primary", + /* 272 */ "common_expression", + /* 273 */ "from_clause", + /* 274 */ "table_reference_list", + /* 275 */ "table_reference", + /* 276 */ "table_primary", + /* 277 */ "joined_table", + /* 278 */ "alias_opt", + /* 279 */ "parenthesized_joined_table", + /* 280 */ "join_type", + /* 281 */ "search_condition", + /* 282 */ "query_specification", + /* 283 */ "set_quantifier_opt", + /* 284 */ "select_list", + /* 285 */ "where_clause_opt", + /* 286 */ "partition_by_clause_opt", + /* 287 */ "twindow_clause_opt", + /* 288 */ "group_by_clause_opt", + /* 289 */ "having_clause_opt", + /* 290 */ "select_sublist", + /* 291 */ "select_item", + /* 292 */ "fill_opt", + /* 293 */ "fill_mode", + /* 294 */ "group_by_list", + /* 295 */ "query_expression_body", + /* 296 */ "order_by_clause_opt", + /* 297 */ "slimit_clause_opt", + /* 298 */ "limit_clause_opt", + /* 299 */ "query_primary", + /* 300 */ "sort_specification_list", + /* 301 */ "sort_specification", + /* 302 */ "ordering_specification_opt", + /* 303 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -1075,7 +1132,7 @@ static const char *const yyRuleName[] = { /* 57 */ "db_options ::= db_options FSYNC NK_INTEGER", /* 58 */ "db_options ::= db_options MAXROWS NK_INTEGER", /* 59 */ "db_options ::= db_options MINROWS NK_INTEGER", - /* 60 */ "db_options ::= db_options KEEP NK_INTEGER", + /* 60 */ "db_options ::= db_options KEEP integer_list", /* 61 */ "db_options ::= db_options PRECISION NK_STRING", /* 62 */ "db_options ::= db_options QUORUM NK_INTEGER", /* 63 */ "db_options ::= db_options REPLICA NK_INTEGER", @@ -1089,289 +1146,321 @@ static const char *const yyRuleName[] = { /* 71 */ "alter_db_options ::= alter_db_options alter_db_option", /* 72 */ "alter_db_option ::= BLOCKS NK_INTEGER", /* 73 */ "alter_db_option ::= FSYNC NK_INTEGER", - /* 74 */ "alter_db_option ::= KEEP NK_INTEGER", + /* 74 */ "alter_db_option ::= KEEP integer_list", /* 75 */ "alter_db_option ::= WAL NK_INTEGER", /* 76 */ "alter_db_option ::= QUORUM NK_INTEGER", /* 77 */ "alter_db_option ::= CACHELAST NK_INTEGER", - /* 78 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", - /* 79 */ "cmd ::= CREATE TABLE multi_create_clause", - /* 80 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", - /* 81 */ "cmd ::= DROP TABLE multi_drop_clause", - /* 82 */ "cmd ::= DROP STABLE exists_opt full_table_name", - /* 83 */ "cmd ::= ALTER TABLE alter_table_clause", - /* 84 */ "cmd ::= ALTER STABLE alter_table_clause", - /* 85 */ "alter_table_clause ::= full_table_name alter_table_options", - /* 86 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", - /* 87 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", - /* 88 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", - /* 89 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", - /* 90 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", - /* 91 */ "alter_table_clause ::= full_table_name DROP TAG column_name", - /* 92 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", - /* 93 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", - /* 94 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal", - /* 95 */ "multi_create_clause ::= create_subtable_clause", - /* 96 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", - /* 97 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP", - /* 98 */ "multi_drop_clause ::= drop_table_clause", - /* 99 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", - /* 100 */ "drop_table_clause ::= exists_opt full_table_name", - /* 101 */ "specific_tags_opt ::=", - /* 102 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", - /* 103 */ "full_table_name ::= table_name", - /* 104 */ "full_table_name ::= db_name NK_DOT table_name", - /* 105 */ "column_def_list ::= column_def", - /* 106 */ "column_def_list ::= column_def_list NK_COMMA column_def", - /* 107 */ "column_def ::= column_name type_name", - /* 108 */ "column_def ::= column_name type_name COMMENT NK_STRING", - /* 109 */ "type_name ::= BOOL", - /* 110 */ "type_name ::= TINYINT", - /* 111 */ "type_name ::= SMALLINT", - /* 112 */ "type_name ::= INT", - /* 113 */ "type_name ::= INTEGER", - /* 114 */ "type_name ::= BIGINT", - /* 115 */ "type_name ::= FLOAT", - /* 116 */ "type_name ::= DOUBLE", - /* 117 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", - /* 118 */ "type_name ::= TIMESTAMP", - /* 119 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", - /* 120 */ "type_name ::= TINYINT UNSIGNED", - /* 121 */ "type_name ::= SMALLINT UNSIGNED", - /* 122 */ "type_name ::= INT UNSIGNED", - /* 123 */ "type_name ::= BIGINT UNSIGNED", - /* 124 */ "type_name ::= JSON", - /* 125 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", - /* 126 */ "type_name ::= MEDIUMBLOB", - /* 127 */ "type_name ::= BLOB", - /* 128 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", - /* 129 */ "type_name ::= DECIMAL", - /* 130 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", - /* 131 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 132 */ "tags_def_opt ::=", - /* 133 */ "tags_def_opt ::= tags_def", - /* 134 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", - /* 135 */ "table_options ::=", - /* 136 */ "table_options ::= table_options COMMENT NK_STRING", - /* 137 */ "table_options ::= table_options KEEP NK_INTEGER", - /* 138 */ "table_options ::= table_options TTL NK_INTEGER", - /* 139 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", - /* 140 */ "table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP", - /* 141 */ "table_options ::= table_options FILE_FACTOR NK_FLOAT", - /* 142 */ "table_options ::= table_options DELAY NK_INTEGER", - /* 143 */ "alter_table_options ::= alter_table_option", - /* 144 */ "alter_table_options ::= alter_table_options alter_table_option", - /* 145 */ "alter_table_option ::= COMMENT NK_STRING", - /* 146 */ "alter_table_option ::= KEEP NK_INTEGER", - /* 147 */ "alter_table_option ::= TTL NK_INTEGER", - /* 148 */ "col_name_list ::= col_name", - /* 149 */ "col_name_list ::= col_name_list NK_COMMA col_name", - /* 150 */ "col_name ::= column_name", - /* 151 */ "cmd ::= SHOW DNODES", - /* 152 */ "cmd ::= SHOW USERS", - /* 153 */ "cmd ::= SHOW DATABASES", - /* 154 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", - /* 155 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", - /* 156 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", - /* 157 */ "cmd ::= SHOW MNODES", - /* 158 */ "cmd ::= SHOW MODULES", - /* 159 */ "cmd ::= SHOW QNODES", - /* 160 */ "cmd ::= SHOW FUNCTIONS", - /* 161 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", - /* 162 */ "cmd ::= SHOW STREAMS", - /* 163 */ "db_name_cond_opt ::=", - /* 164 */ "db_name_cond_opt ::= db_name NK_DOT", - /* 165 */ "like_pattern_opt ::=", - /* 166 */ "like_pattern_opt ::= LIKE NK_STRING", - /* 167 */ "table_name_cond ::= table_name", - /* 168 */ "from_db_opt ::=", - /* 169 */ "from_db_opt ::= FROM db_name", - /* 170 */ "func_name_list ::= func_name", - /* 171 */ "func_name_list ::= func_name_list NK_COMMA col_name", - /* 172 */ "func_name ::= function_name", - /* 173 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options", - /* 174 */ "cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP", - /* 175 */ "cmd ::= DROP INDEX exists_opt index_name ON table_name", - /* 176 */ "index_options ::=", - /* 177 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", - /* 178 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", - /* 179 */ "func_list ::= func", - /* 180 */ "func_list ::= func_list NK_COMMA func", - /* 181 */ "func ::= function_name NK_LP expression_list NK_RP", - /* 182 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", - /* 183 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name", - /* 184 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 185 */ "cmd ::= DESC full_table_name", - /* 186 */ "cmd ::= DESCRIBE full_table_name", - /* 187 */ "cmd ::= RESET QUERY CACHE", - /* 188 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", - /* 189 */ "analyze_opt ::=", - /* 190 */ "analyze_opt ::= ANALYZE", - /* 191 */ "explain_options ::=", - /* 192 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 193 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 194 */ "cmd ::= query_expression", - /* 195 */ "literal ::= NK_INTEGER", - /* 196 */ "literal ::= NK_FLOAT", - /* 197 */ "literal ::= NK_STRING", - /* 198 */ "literal ::= NK_BOOL", - /* 199 */ "literal ::= TIMESTAMP NK_STRING", - /* 200 */ "literal ::= duration_literal", - /* 201 */ "literal ::= NULL", - /* 202 */ "duration_literal ::= NK_VARIABLE", - /* 203 */ "signed ::= NK_INTEGER", - /* 204 */ "signed ::= NK_PLUS NK_INTEGER", - /* 205 */ "signed ::= NK_MINUS NK_INTEGER", - /* 206 */ "signed ::= NK_FLOAT", - /* 207 */ "signed ::= NK_PLUS NK_FLOAT", - /* 208 */ "signed ::= NK_MINUS NK_FLOAT", - /* 209 */ "signed_literal ::= signed", - /* 210 */ "signed_literal ::= NK_STRING", - /* 211 */ "signed_literal ::= NK_BOOL", - /* 212 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 213 */ "signed_literal ::= duration_literal", - /* 214 */ "signed_literal ::= NULL", - /* 215 */ "literal_list ::= signed_literal", - /* 216 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 217 */ "db_name ::= NK_ID", - /* 218 */ "table_name ::= NK_ID", - /* 219 */ "column_name ::= NK_ID", - /* 220 */ "function_name ::= NK_ID", - /* 221 */ "table_alias ::= NK_ID", - /* 222 */ "column_alias ::= NK_ID", - /* 223 */ "user_name ::= NK_ID", - /* 224 */ "index_name ::= NK_ID", - /* 225 */ "topic_name ::= NK_ID", - /* 226 */ "expression ::= literal", - /* 227 */ "expression ::= pseudo_column", - /* 228 */ "expression ::= column_reference", - /* 229 */ "expression ::= function_name NK_LP expression_list NK_RP", - /* 230 */ "expression ::= function_name NK_LP NK_STAR NK_RP", - /* 231 */ "expression ::= subquery", - /* 232 */ "expression ::= NK_LP expression NK_RP", - /* 233 */ "expression ::= NK_PLUS expression", - /* 234 */ "expression ::= NK_MINUS expression", - /* 235 */ "expression ::= expression NK_PLUS expression", - /* 236 */ "expression ::= expression NK_MINUS expression", - /* 237 */ "expression ::= expression NK_STAR expression", - /* 238 */ "expression ::= expression NK_SLASH expression", - /* 239 */ "expression ::= expression NK_REM expression", - /* 240 */ "expression_list ::= expression", - /* 241 */ "expression_list ::= expression_list NK_COMMA expression", - /* 242 */ "column_reference ::= column_name", - /* 243 */ "column_reference ::= table_name NK_DOT column_name", - /* 244 */ "pseudo_column ::= NK_UNDERLINE ROWTS", - /* 245 */ "pseudo_column ::= TBNAME", - /* 246 */ "pseudo_column ::= NK_UNDERLINE QSTARTTS", - /* 247 */ "pseudo_column ::= NK_UNDERLINE QENDTS", - /* 248 */ "pseudo_column ::= NK_UNDERLINE WSTARTTS", - /* 249 */ "pseudo_column ::= NK_UNDERLINE WENDTS", - /* 250 */ "pseudo_column ::= NK_UNDERLINE WDURATION", - /* 251 */ "predicate ::= expression compare_op expression", - /* 252 */ "predicate ::= expression BETWEEN expression AND expression", - /* 253 */ "predicate ::= expression NOT BETWEEN expression AND expression", - /* 254 */ "predicate ::= expression IS NULL", - /* 255 */ "predicate ::= expression IS NOT NULL", - /* 256 */ "predicate ::= expression in_op in_predicate_value", - /* 257 */ "compare_op ::= NK_LT", - /* 258 */ "compare_op ::= NK_GT", - /* 259 */ "compare_op ::= NK_LE", - /* 260 */ "compare_op ::= NK_GE", - /* 261 */ "compare_op ::= NK_NE", - /* 262 */ "compare_op ::= NK_EQ", - /* 263 */ "compare_op ::= LIKE", - /* 264 */ "compare_op ::= NOT LIKE", - /* 265 */ "compare_op ::= MATCH", - /* 266 */ "compare_op ::= NMATCH", - /* 267 */ "in_op ::= IN", - /* 268 */ "in_op ::= NOT IN", - /* 269 */ "in_predicate_value ::= NK_LP expression_list NK_RP", - /* 270 */ "boolean_value_expression ::= boolean_primary", - /* 271 */ "boolean_value_expression ::= NOT boolean_primary", - /* 272 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 273 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 274 */ "boolean_primary ::= predicate", - /* 275 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 276 */ "common_expression ::= expression", - /* 277 */ "common_expression ::= boolean_value_expression", - /* 278 */ "from_clause ::= FROM table_reference_list", - /* 279 */ "table_reference_list ::= table_reference", - /* 280 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 281 */ "table_reference ::= table_primary", - /* 282 */ "table_reference ::= joined_table", - /* 283 */ "table_primary ::= table_name alias_opt", - /* 284 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 285 */ "table_primary ::= subquery alias_opt", - /* 286 */ "table_primary ::= parenthesized_joined_table", - /* 287 */ "alias_opt ::=", - /* 288 */ "alias_opt ::= table_alias", - /* 289 */ "alias_opt ::= AS table_alias", - /* 290 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 291 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 292 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", - /* 293 */ "join_type ::=", - /* 294 */ "join_type ::= INNER", - /* 295 */ "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", - /* 296 */ "set_quantifier_opt ::=", - /* 297 */ "set_quantifier_opt ::= DISTINCT", - /* 298 */ "set_quantifier_opt ::= ALL", - /* 299 */ "select_list ::= NK_STAR", - /* 300 */ "select_list ::= select_sublist", - /* 301 */ "select_sublist ::= select_item", - /* 302 */ "select_sublist ::= select_sublist NK_COMMA select_item", - /* 303 */ "select_item ::= common_expression", - /* 304 */ "select_item ::= common_expression column_alias", - /* 305 */ "select_item ::= common_expression AS column_alias", - /* 306 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 307 */ "where_clause_opt ::=", - /* 308 */ "where_clause_opt ::= WHERE search_condition", - /* 309 */ "partition_by_clause_opt ::=", - /* 310 */ "partition_by_clause_opt ::= PARTITION BY expression_list", - /* 311 */ "twindow_clause_opt ::=", - /* 312 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", - /* 313 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", - /* 314 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", - /* 315 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", - /* 316 */ "sliding_opt ::=", - /* 317 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", - /* 318 */ "fill_opt ::=", - /* 319 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 320 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", - /* 321 */ "fill_mode ::= NONE", - /* 322 */ "fill_mode ::= PREV", - /* 323 */ "fill_mode ::= NULL", - /* 324 */ "fill_mode ::= LINEAR", - /* 325 */ "fill_mode ::= NEXT", - /* 326 */ "group_by_clause_opt ::=", - /* 327 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 328 */ "group_by_list ::= expression", - /* 329 */ "group_by_list ::= group_by_list NK_COMMA expression", - /* 330 */ "having_clause_opt ::=", - /* 331 */ "having_clause_opt ::= HAVING search_condition", - /* 332 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 333 */ "query_expression_body ::= query_primary", - /* 334 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", - /* 335 */ "query_primary ::= query_specification", - /* 336 */ "order_by_clause_opt ::=", - /* 337 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 338 */ "slimit_clause_opt ::=", - /* 339 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 340 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 341 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 342 */ "limit_clause_opt ::=", - /* 343 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 344 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 345 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 346 */ "subquery ::= NK_LP query_expression NK_RP", - /* 347 */ "search_condition ::= common_expression", - /* 348 */ "sort_specification_list ::= sort_specification", - /* 349 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 350 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", - /* 351 */ "ordering_specification_opt ::=", - /* 352 */ "ordering_specification_opt ::= ASC", - /* 353 */ "ordering_specification_opt ::= DESC", - /* 354 */ "null_ordering_opt ::=", - /* 355 */ "null_ordering_opt ::= NULLS FIRST", - /* 356 */ "null_ordering_opt ::= NULLS LAST", + /* 78 */ "alter_db_option ::= REPLICA NK_INTEGER", + /* 79 */ "integer_list ::= NK_INTEGER", + /* 80 */ "integer_list ::= integer_list NK_COMMA NK_INTEGER", + /* 81 */ "cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options", + /* 82 */ "cmd ::= CREATE TABLE multi_create_clause", + /* 83 */ "cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options", + /* 84 */ "cmd ::= DROP TABLE multi_drop_clause", + /* 85 */ "cmd ::= DROP STABLE exists_opt full_table_name", + /* 86 */ "cmd ::= ALTER TABLE alter_table_clause", + /* 87 */ "cmd ::= ALTER STABLE alter_table_clause", + /* 88 */ "alter_table_clause ::= full_table_name alter_table_options", + /* 89 */ "alter_table_clause ::= full_table_name ADD COLUMN column_name type_name", + /* 90 */ "alter_table_clause ::= full_table_name DROP COLUMN column_name", + /* 91 */ "alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name", + /* 92 */ "alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name", + /* 93 */ "alter_table_clause ::= full_table_name ADD TAG column_name type_name", + /* 94 */ "alter_table_clause ::= full_table_name DROP TAG column_name", + /* 95 */ "alter_table_clause ::= full_table_name MODIFY TAG column_name type_name", + /* 96 */ "alter_table_clause ::= full_table_name RENAME TAG column_name column_name", + /* 97 */ "alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal", + /* 98 */ "multi_create_clause ::= create_subtable_clause", + /* 99 */ "multi_create_clause ::= multi_create_clause create_subtable_clause", + /* 100 */ "create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP", + /* 101 */ "multi_drop_clause ::= drop_table_clause", + /* 102 */ "multi_drop_clause ::= multi_drop_clause drop_table_clause", + /* 103 */ "drop_table_clause ::= exists_opt full_table_name", + /* 104 */ "specific_tags_opt ::=", + /* 105 */ "specific_tags_opt ::= NK_LP col_name_list NK_RP", + /* 106 */ "full_table_name ::= table_name", + /* 107 */ "full_table_name ::= db_name NK_DOT table_name", + /* 108 */ "column_def_list ::= column_def", + /* 109 */ "column_def_list ::= column_def_list NK_COMMA column_def", + /* 110 */ "column_def ::= column_name type_name", + /* 111 */ "column_def ::= column_name type_name COMMENT NK_STRING", + /* 112 */ "type_name ::= BOOL", + /* 113 */ "type_name ::= TINYINT", + /* 114 */ "type_name ::= SMALLINT", + /* 115 */ "type_name ::= INT", + /* 116 */ "type_name ::= INTEGER", + /* 117 */ "type_name ::= BIGINT", + /* 118 */ "type_name ::= FLOAT", + /* 119 */ "type_name ::= DOUBLE", + /* 120 */ "type_name ::= BINARY NK_LP NK_INTEGER NK_RP", + /* 121 */ "type_name ::= TIMESTAMP", + /* 122 */ "type_name ::= NCHAR NK_LP NK_INTEGER NK_RP", + /* 123 */ "type_name ::= TINYINT UNSIGNED", + /* 124 */ "type_name ::= SMALLINT UNSIGNED", + /* 125 */ "type_name ::= INT UNSIGNED", + /* 126 */ "type_name ::= BIGINT UNSIGNED", + /* 127 */ "type_name ::= JSON", + /* 128 */ "type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP", + /* 129 */ "type_name ::= MEDIUMBLOB", + /* 130 */ "type_name ::= BLOB", + /* 131 */ "type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP", + /* 132 */ "type_name ::= DECIMAL", + /* 133 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP", + /* 134 */ "type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 135 */ "tags_def_opt ::=", + /* 136 */ "tags_def_opt ::= tags_def", + /* 137 */ "tags_def ::= TAGS NK_LP column_def_list NK_RP", + /* 138 */ "table_options ::=", + /* 139 */ "table_options ::= table_options COMMENT NK_STRING", + /* 140 */ "table_options ::= table_options KEEP integer_list", + /* 141 */ "table_options ::= table_options TTL NK_INTEGER", + /* 142 */ "table_options ::= table_options SMA NK_LP col_name_list NK_RP", + /* 143 */ "table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP", + /* 144 */ "table_options ::= table_options FILE_FACTOR NK_FLOAT", + /* 145 */ "table_options ::= table_options DELAY NK_INTEGER", + /* 146 */ "alter_table_options ::= alter_table_option", + /* 147 */ "alter_table_options ::= alter_table_options alter_table_option", + /* 148 */ "alter_table_option ::= COMMENT NK_STRING", + /* 149 */ "alter_table_option ::= KEEP integer_list", + /* 150 */ "alter_table_option ::= TTL NK_INTEGER", + /* 151 */ "col_name_list ::= col_name", + /* 152 */ "col_name_list ::= col_name_list NK_COMMA col_name", + /* 153 */ "col_name ::= column_name", + /* 154 */ "cmd ::= SHOW DNODES", + /* 155 */ "cmd ::= SHOW USERS", + /* 156 */ "cmd ::= SHOW DATABASES", + /* 157 */ "cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt", + /* 158 */ "cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt", + /* 159 */ "cmd ::= SHOW db_name_cond_opt VGROUPS", + /* 160 */ "cmd ::= SHOW MNODES", + /* 161 */ "cmd ::= SHOW MODULES", + /* 162 */ "cmd ::= SHOW QNODES", + /* 163 */ "cmd ::= SHOW FUNCTIONS", + /* 164 */ "cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt", + /* 165 */ "cmd ::= SHOW STREAMS", + /* 166 */ "cmd ::= SHOW ACCOUNTS", + /* 167 */ "cmd ::= SHOW APPS", + /* 168 */ "cmd ::= SHOW CONNECTIONS", + /* 169 */ "cmd ::= SHOW LICENCE", + /* 170 */ "cmd ::= SHOW CREATE DATABASE db_name", + /* 171 */ "cmd ::= SHOW CREATE TABLE full_table_name", + /* 172 */ "cmd ::= SHOW CREATE STABLE full_table_name", + /* 173 */ "cmd ::= SHOW QUERIES", + /* 174 */ "cmd ::= SHOW SCORES", + /* 175 */ "cmd ::= SHOW TOPICS", + /* 176 */ "cmd ::= SHOW VARIABLES", + /* 177 */ "db_name_cond_opt ::=", + /* 178 */ "db_name_cond_opt ::= db_name NK_DOT", + /* 179 */ "like_pattern_opt ::=", + /* 180 */ "like_pattern_opt ::= LIKE NK_STRING", + /* 181 */ "table_name_cond ::= table_name", + /* 182 */ "from_db_opt ::=", + /* 183 */ "from_db_opt ::= FROM db_name", + /* 184 */ "func_name_list ::= func_name", + /* 185 */ "func_name_list ::= func_name_list NK_COMMA col_name", + /* 186 */ "func_name ::= function_name", + /* 187 */ "cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options", + /* 188 */ "cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP", + /* 189 */ "cmd ::= DROP INDEX exists_opt index_name ON table_name", + /* 190 */ "index_options ::=", + /* 191 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt", + /* 192 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt", + /* 193 */ "func_list ::= func", + /* 194 */ "func_list ::= func_list NK_COMMA func", + /* 195 */ "func ::= function_name NK_LP expression_list NK_RP", + /* 196 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression", + /* 197 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name", + /* 198 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 199 */ "cmd ::= DESC full_table_name", + /* 200 */ "cmd ::= DESCRIBE full_table_name", + /* 201 */ "cmd ::= RESET QUERY CACHE", + /* 202 */ "cmd ::= EXPLAIN analyze_opt explain_options query_expression", + /* 203 */ "analyze_opt ::=", + /* 204 */ "analyze_opt ::= ANALYZE", + /* 205 */ "explain_options ::=", + /* 206 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 207 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 208 */ "cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP", + /* 209 */ "cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt", + /* 210 */ "cmd ::= DROP FUNCTION function_name", + /* 211 */ "agg_func_opt ::=", + /* 212 */ "agg_func_opt ::= AGGREGATE", + /* 213 */ "bufsize_opt ::=", + /* 214 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 215 */ "cmd ::= CREATE STREAM stream_name INTO table_name AS query_expression", + /* 216 */ "cmd ::= DROP STREAM stream_name", + /* 217 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 218 */ "cmd ::= KILL QUERY NK_INTEGER", + /* 219 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 220 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 221 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 222 */ "dnode_list ::= DNODE NK_INTEGER", + /* 223 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 224 */ "cmd ::= SYNCDB db_name REPLICA", + /* 225 */ "cmd ::= query_expression", + /* 226 */ "literal ::= NK_INTEGER", + /* 227 */ "literal ::= NK_FLOAT", + /* 228 */ "literal ::= NK_STRING", + /* 229 */ "literal ::= NK_BOOL", + /* 230 */ "literal ::= TIMESTAMP NK_STRING", + /* 231 */ "literal ::= duration_literal", + /* 232 */ "literal ::= NULL", + /* 233 */ "duration_literal ::= NK_VARIABLE", + /* 234 */ "signed ::= NK_INTEGER", + /* 235 */ "signed ::= NK_PLUS NK_INTEGER", + /* 236 */ "signed ::= NK_MINUS NK_INTEGER", + /* 237 */ "signed ::= NK_FLOAT", + /* 238 */ "signed ::= NK_PLUS NK_FLOAT", + /* 239 */ "signed ::= NK_MINUS NK_FLOAT", + /* 240 */ "signed_literal ::= signed", + /* 241 */ "signed_literal ::= NK_STRING", + /* 242 */ "signed_literal ::= NK_BOOL", + /* 243 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 244 */ "signed_literal ::= duration_literal", + /* 245 */ "signed_literal ::= NULL", + /* 246 */ "literal_list ::= signed_literal", + /* 247 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 248 */ "db_name ::= NK_ID", + /* 249 */ "table_name ::= NK_ID", + /* 250 */ "column_name ::= NK_ID", + /* 251 */ "function_name ::= NK_ID", + /* 252 */ "table_alias ::= NK_ID", + /* 253 */ "column_alias ::= NK_ID", + /* 254 */ "user_name ::= NK_ID", + /* 255 */ "index_name ::= NK_ID", + /* 256 */ "topic_name ::= NK_ID", + /* 257 */ "stream_name ::= NK_ID", + /* 258 */ "expression ::= literal", + /* 259 */ "expression ::= pseudo_column", + /* 260 */ "expression ::= column_reference", + /* 261 */ "expression ::= function_name NK_LP expression_list NK_RP", + /* 262 */ "expression ::= function_name NK_LP NK_STAR NK_RP", + /* 263 */ "expression ::= subquery", + /* 264 */ "expression ::= NK_LP expression NK_RP", + /* 265 */ "expression ::= NK_PLUS expression", + /* 266 */ "expression ::= NK_MINUS expression", + /* 267 */ "expression ::= expression NK_PLUS expression", + /* 268 */ "expression ::= expression NK_MINUS expression", + /* 269 */ "expression ::= expression NK_STAR expression", + /* 270 */ "expression ::= expression NK_SLASH expression", + /* 271 */ "expression ::= expression NK_REM expression", + /* 272 */ "expression_list ::= expression", + /* 273 */ "expression_list ::= expression_list NK_COMMA expression", + /* 274 */ "column_reference ::= column_name", + /* 275 */ "column_reference ::= table_name NK_DOT column_name", + /* 276 */ "pseudo_column ::= NK_UNDERLINE ROWTS", + /* 277 */ "pseudo_column ::= TBNAME", + /* 278 */ "pseudo_column ::= NK_UNDERLINE QSTARTTS", + /* 279 */ "pseudo_column ::= NK_UNDERLINE QENDTS", + /* 280 */ "pseudo_column ::= NK_UNDERLINE WSTARTTS", + /* 281 */ "pseudo_column ::= NK_UNDERLINE WENDTS", + /* 282 */ "pseudo_column ::= NK_UNDERLINE WDURATION", + /* 283 */ "predicate ::= expression compare_op expression", + /* 284 */ "predicate ::= expression BETWEEN expression AND expression", + /* 285 */ "predicate ::= expression NOT BETWEEN expression AND expression", + /* 286 */ "predicate ::= expression IS NULL", + /* 287 */ "predicate ::= expression IS NOT NULL", + /* 288 */ "predicate ::= expression in_op in_predicate_value", + /* 289 */ "compare_op ::= NK_LT", + /* 290 */ "compare_op ::= NK_GT", + /* 291 */ "compare_op ::= NK_LE", + /* 292 */ "compare_op ::= NK_GE", + /* 293 */ "compare_op ::= NK_NE", + /* 294 */ "compare_op ::= NK_EQ", + /* 295 */ "compare_op ::= LIKE", + /* 296 */ "compare_op ::= NOT LIKE", + /* 297 */ "compare_op ::= MATCH", + /* 298 */ "compare_op ::= NMATCH", + /* 299 */ "in_op ::= IN", + /* 300 */ "in_op ::= NOT IN", + /* 301 */ "in_predicate_value ::= NK_LP expression_list NK_RP", + /* 302 */ "boolean_value_expression ::= boolean_primary", + /* 303 */ "boolean_value_expression ::= NOT boolean_primary", + /* 304 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 305 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 306 */ "boolean_primary ::= predicate", + /* 307 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 308 */ "common_expression ::= expression", + /* 309 */ "common_expression ::= boolean_value_expression", + /* 310 */ "from_clause ::= FROM table_reference_list", + /* 311 */ "table_reference_list ::= table_reference", + /* 312 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 313 */ "table_reference ::= table_primary", + /* 314 */ "table_reference ::= joined_table", + /* 315 */ "table_primary ::= table_name alias_opt", + /* 316 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 317 */ "table_primary ::= subquery alias_opt", + /* 318 */ "table_primary ::= parenthesized_joined_table", + /* 319 */ "alias_opt ::=", + /* 320 */ "alias_opt ::= table_alias", + /* 321 */ "alias_opt ::= AS table_alias", + /* 322 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 323 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 324 */ "joined_table ::= table_reference join_type JOIN table_reference ON search_condition", + /* 325 */ "join_type ::=", + /* 326 */ "join_type ::= INNER", + /* 327 */ "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", + /* 328 */ "set_quantifier_opt ::=", + /* 329 */ "set_quantifier_opt ::= DISTINCT", + /* 330 */ "set_quantifier_opt ::= ALL", + /* 331 */ "select_list ::= NK_STAR", + /* 332 */ "select_list ::= select_sublist", + /* 333 */ "select_sublist ::= select_item", + /* 334 */ "select_sublist ::= select_sublist NK_COMMA select_item", + /* 335 */ "select_item ::= common_expression", + /* 336 */ "select_item ::= common_expression column_alias", + /* 337 */ "select_item ::= common_expression AS column_alias", + /* 338 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 339 */ "where_clause_opt ::=", + /* 340 */ "where_clause_opt ::= WHERE search_condition", + /* 341 */ "partition_by_clause_opt ::=", + /* 342 */ "partition_by_clause_opt ::= PARTITION BY expression_list", + /* 343 */ "twindow_clause_opt ::=", + /* 344 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP", + /* 345 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP", + /* 346 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt", + /* 347 */ "twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt", + /* 348 */ "sliding_opt ::=", + /* 349 */ "sliding_opt ::= SLIDING NK_LP duration_literal NK_RP", + /* 350 */ "fill_opt ::=", + /* 351 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 352 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP", + /* 353 */ "fill_mode ::= NONE", + /* 354 */ "fill_mode ::= PREV", + /* 355 */ "fill_mode ::= NULL", + /* 356 */ "fill_mode ::= LINEAR", + /* 357 */ "fill_mode ::= NEXT", + /* 358 */ "group_by_clause_opt ::=", + /* 359 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 360 */ "group_by_list ::= expression", + /* 361 */ "group_by_list ::= group_by_list NK_COMMA expression", + /* 362 */ "having_clause_opt ::=", + /* 363 */ "having_clause_opt ::= HAVING search_condition", + /* 364 */ "query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 365 */ "query_expression_body ::= query_primary", + /* 366 */ "query_expression_body ::= query_expression_body UNION ALL query_expression_body", + /* 367 */ "query_primary ::= query_specification", + /* 368 */ "order_by_clause_opt ::=", + /* 369 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 370 */ "slimit_clause_opt ::=", + /* 371 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 372 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 373 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 374 */ "limit_clause_opt ::=", + /* 375 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 376 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 377 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 378 */ "subquery ::= NK_LP query_expression NK_RP", + /* 379 */ "search_condition ::= common_expression", + /* 380 */ "sort_specification_list ::= sort_specification", + /* 381 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 382 */ "sort_specification ::= expression ordering_specification_opt null_ordering_opt", + /* 383 */ "ordering_specification_opt ::=", + /* 384 */ "ordering_specification_opt ::= ASC", + /* 385 */ "ordering_specification_opt ::= DESC", + /* 386 */ "null_ordering_opt ::=", + /* 387 */ "null_ordering_opt ::= NULLS FIRST", + /* 388 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -1498,148 +1587,153 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 179: /* cmd */ - case 182: /* literal */ - case 189: /* db_options */ - case 191: /* alter_db_options */ - case 193: /* full_table_name */ - case 196: /* table_options */ - case 200: /* alter_table_clause */ - case 201: /* alter_table_options */ - case 204: /* create_subtable_clause */ - case 207: /* drop_table_clause */ - case 210: /* column_def */ - case 213: /* col_name */ - case 214: /* db_name_cond_opt */ - case 215: /* like_pattern_opt */ - case 216: /* table_name_cond */ - case 217: /* from_db_opt */ - case 218: /* func_name */ - case 221: /* index_options */ - case 223: /* duration_literal */ - case 224: /* sliding_opt */ - case 225: /* func */ - case 228: /* query_expression */ - case 230: /* explain_options */ - case 231: /* signed */ - case 232: /* signed_literal */ - case 235: /* expression */ - case 236: /* pseudo_column */ - case 237: /* column_reference */ - case 238: /* subquery */ - case 239: /* predicate */ - case 242: /* in_predicate_value */ - case 243: /* boolean_value_expression */ - case 244: /* boolean_primary */ - case 245: /* common_expression */ - case 246: /* from_clause */ - case 247: /* table_reference_list */ - case 248: /* table_reference */ - case 249: /* table_primary */ - case 250: /* joined_table */ - case 252: /* parenthesized_joined_table */ - case 254: /* search_condition */ - case 255: /* query_specification */ - case 258: /* where_clause_opt */ - case 260: /* twindow_clause_opt */ - case 262: /* having_clause_opt */ - case 264: /* select_item */ - case 265: /* fill_opt */ - case 268: /* query_expression_body */ - case 270: /* slimit_clause_opt */ - case 271: /* limit_clause_opt */ - case 272: /* query_primary */ - case 274: /* sort_specification */ + case 201: /* cmd */ + case 204: /* literal */ + case 211: /* db_options */ + case 213: /* alter_db_options */ + case 216: /* full_table_name */ + case 219: /* table_options */ + case 223: /* alter_table_clause */ + case 224: /* alter_table_options */ + case 227: /* create_subtable_clause */ + case 230: /* drop_table_clause */ + case 233: /* column_def */ + case 236: /* col_name */ + case 237: /* db_name_cond_opt */ + case 238: /* like_pattern_opt */ + case 239: /* table_name_cond */ + case 240: /* from_db_opt */ + case 241: /* func_name */ + case 244: /* index_options */ + case 246: /* duration_literal */ + case 247: /* sliding_opt */ + case 248: /* func */ + case 251: /* query_expression */ + case 253: /* explain_options */ + case 258: /* signed */ + case 259: /* signed_literal */ + case 262: /* expression */ + case 263: /* pseudo_column */ + case 264: /* column_reference */ + case 265: /* subquery */ + case 266: /* predicate */ + case 269: /* in_predicate_value */ + case 270: /* boolean_value_expression */ + case 271: /* boolean_primary */ + case 272: /* common_expression */ + case 273: /* from_clause */ + case 274: /* table_reference_list */ + case 275: /* table_reference */ + case 276: /* table_primary */ + case 277: /* joined_table */ + case 279: /* parenthesized_joined_table */ + case 281: /* search_condition */ + case 282: /* query_specification */ + case 285: /* where_clause_opt */ + case 287: /* twindow_clause_opt */ + case 289: /* having_clause_opt */ + case 291: /* select_item */ + case 292: /* fill_opt */ + case 295: /* query_expression_body */ + case 297: /* slimit_clause_opt */ + case 298: /* limit_clause_opt */ + case 299: /* query_primary */ + case 301: /* sort_specification */ { - nodesDestroyNode((yypminor->yy46)); + nodesDestroyNode((yypminor->yy104)); } break; - case 180: /* account_options */ - case 181: /* alter_account_options */ - case 183: /* alter_account_option */ + case 202: /* account_options */ + case 203: /* alter_account_options */ + case 205: /* alter_account_option */ + case 255: /* bufsize_opt */ { } break; - case 184: /* user_name */ - case 185: /* dnode_endpoint */ - case 186: /* dnode_host_name */ - case 188: /* db_name */ - case 202: /* column_name */ - case 209: /* table_name */ - case 219: /* function_name */ - case 220: /* index_name */ - case 227: /* topic_name */ - case 233: /* table_alias */ - case 234: /* column_alias */ - case 251: /* alias_opt */ + case 206: /* user_name */ + case 207: /* dnode_endpoint */ + case 208: /* dnode_host_name */ + case 210: /* db_name */ + case 225: /* column_name */ + case 232: /* table_name */ + case 242: /* function_name */ + case 243: /* index_name */ + case 250: /* topic_name */ + case 256: /* stream_name */ + case 260: /* table_alias */ + case 261: /* column_alias */ + case 278: /* alias_opt */ { } break; - case 187: /* not_exists_opt */ - case 190: /* exists_opt */ - case 229: /* analyze_opt */ - case 256: /* set_quantifier_opt */ + case 209: /* not_exists_opt */ + case 212: /* exists_opt */ + case 252: /* analyze_opt */ + case 254: /* agg_func_opt */ + case 283: /* set_quantifier_opt */ { } break; - case 192: /* alter_db_option */ - case 212: /* alter_table_option */ + case 214: /* integer_list */ + case 217: /* column_def_list */ + case 218: /* tags_def_opt */ + case 220: /* multi_create_clause */ + case 221: /* tags_def */ + case 222: /* multi_drop_clause */ + case 228: /* specific_tags_opt */ + case 229: /* literal_list */ + case 231: /* col_name_list */ + case 234: /* func_name_list */ + case 245: /* func_list */ + case 249: /* expression_list */ + case 257: /* dnode_list */ + case 284: /* select_list */ + case 286: /* partition_by_clause_opt */ + case 288: /* group_by_clause_opt */ + case 290: /* select_sublist */ + case 294: /* group_by_list */ + case 296: /* order_by_clause_opt */ + case 300: /* sort_specification_list */ +{ + nodesDestroyList((yypminor->yy312)); +} + break; + case 215: /* alter_db_option */ + case 235: /* alter_table_option */ { } break; - case 194: /* column_def_list */ - case 195: /* tags_def_opt */ - case 197: /* multi_create_clause */ - case 198: /* tags_def */ - case 199: /* multi_drop_clause */ - case 205: /* specific_tags_opt */ - case 206: /* literal_list */ - case 208: /* col_name_list */ - case 211: /* func_name_list */ - case 222: /* func_list */ - case 226: /* expression_list */ - case 257: /* select_list */ - case 259: /* partition_by_clause_opt */ - case 261: /* group_by_clause_opt */ - case 263: /* select_sublist */ - case 267: /* group_by_list */ - case 269: /* order_by_clause_opt */ - case 273: /* sort_specification_list */ -{ - nodesDestroyList((yypminor->yy194)); -} - break; - case 203: /* type_name */ + case 226: /* type_name */ { } break; - case 240: /* compare_op */ - case 241: /* in_op */ + case 267: /* compare_op */ + case 268: /* in_op */ { } break; - case 253: /* join_type */ + case 280: /* join_type */ { } break; - case 266: /* fill_mode */ + case 293: /* fill_mode */ { } break; - case 275: /* ordering_specification_opt */ + case 302: /* ordering_specification_opt */ { } break; - case 276: /* null_ordering_opt */ + case 303: /* null_ordering_opt */ { } @@ -1938,363 +2032,395 @@ 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[] = { - { 179, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - { 179, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - { 180, 0 }, /* (2) account_options ::= */ - { 180, -3 }, /* (3) account_options ::= account_options PPS literal */ - { 180, -3 }, /* (4) account_options ::= account_options TSERIES literal */ - { 180, -3 }, /* (5) account_options ::= account_options STORAGE literal */ - { 180, -3 }, /* (6) account_options ::= account_options STREAMS literal */ - { 180, -3 }, /* (7) account_options ::= account_options QTIME literal */ - { 180, -3 }, /* (8) account_options ::= account_options DBS literal */ - { 180, -3 }, /* (9) account_options ::= account_options USERS literal */ - { 180, -3 }, /* (10) account_options ::= account_options CONNS literal */ - { 180, -3 }, /* (11) account_options ::= account_options STATE literal */ - { 181, -1 }, /* (12) alter_account_options ::= alter_account_option */ - { 181, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - { 183, -2 }, /* (14) alter_account_option ::= PASS literal */ - { 183, -2 }, /* (15) alter_account_option ::= PPS literal */ - { 183, -2 }, /* (16) alter_account_option ::= TSERIES literal */ - { 183, -2 }, /* (17) alter_account_option ::= STORAGE literal */ - { 183, -2 }, /* (18) alter_account_option ::= STREAMS literal */ - { 183, -2 }, /* (19) alter_account_option ::= QTIME literal */ - { 183, -2 }, /* (20) alter_account_option ::= DBS literal */ - { 183, -2 }, /* (21) alter_account_option ::= USERS literal */ - { 183, -2 }, /* (22) alter_account_option ::= CONNS literal */ - { 183, -2 }, /* (23) alter_account_option ::= STATE literal */ - { 179, -5 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING */ - { 179, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ - { 179, -5 }, /* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ - { 179, -3 }, /* (27) cmd ::= DROP USER user_name */ - { 179, -3 }, /* (28) cmd ::= CREATE DNODE dnode_endpoint */ - { 179, -5 }, /* (29) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ - { 179, -3 }, /* (30) cmd ::= DROP DNODE NK_INTEGER */ - { 179, -3 }, /* (31) cmd ::= DROP DNODE dnode_endpoint */ - { 179, -4 }, /* (32) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - { 179, -5 }, /* (33) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - { 179, -4 }, /* (34) cmd ::= ALTER ALL DNODES NK_STRING */ - { 179, -5 }, /* (35) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - { 185, -1 }, /* (36) dnode_endpoint ::= NK_STRING */ - { 186, -1 }, /* (37) dnode_host_name ::= NK_ID */ - { 186, -1 }, /* (38) dnode_host_name ::= NK_IPTOKEN */ - { 179, -3 }, /* (39) cmd ::= ALTER LOCAL NK_STRING */ - { 179, -4 }, /* (40) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - { 179, -5 }, /* (41) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - { 179, -5 }, /* (42) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - { 179, -5 }, /* (43) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - { 179, -4 }, /* (44) cmd ::= DROP DATABASE exists_opt db_name */ - { 179, -2 }, /* (45) cmd ::= USE db_name */ - { 179, -4 }, /* (46) cmd ::= ALTER DATABASE db_name alter_db_options */ - { 187, -3 }, /* (47) not_exists_opt ::= IF NOT EXISTS */ - { 187, 0 }, /* (48) not_exists_opt ::= */ - { 190, -2 }, /* (49) exists_opt ::= IF EXISTS */ - { 190, 0 }, /* (50) exists_opt ::= */ - { 189, 0 }, /* (51) db_options ::= */ - { 189, -3 }, /* (52) db_options ::= db_options BLOCKS NK_INTEGER */ - { 189, -3 }, /* (53) db_options ::= db_options CACHE NK_INTEGER */ - { 189, -3 }, /* (54) db_options ::= db_options CACHELAST NK_INTEGER */ - { 189, -3 }, /* (55) db_options ::= db_options COMP NK_INTEGER */ - { 189, -3 }, /* (56) db_options ::= db_options DAYS NK_INTEGER */ - { 189, -3 }, /* (57) db_options ::= db_options FSYNC NK_INTEGER */ - { 189, -3 }, /* (58) db_options ::= db_options MAXROWS NK_INTEGER */ - { 189, -3 }, /* (59) db_options ::= db_options MINROWS NK_INTEGER */ - { 189, -3 }, /* (60) db_options ::= db_options KEEP NK_INTEGER */ - { 189, -3 }, /* (61) db_options ::= db_options PRECISION NK_STRING */ - { 189, -3 }, /* (62) db_options ::= db_options QUORUM NK_INTEGER */ - { 189, -3 }, /* (63) db_options ::= db_options REPLICA NK_INTEGER */ - { 189, -3 }, /* (64) db_options ::= db_options TTL NK_INTEGER */ - { 189, -3 }, /* (65) db_options ::= db_options WAL NK_INTEGER */ - { 189, -3 }, /* (66) db_options ::= db_options VGROUPS NK_INTEGER */ - { 189, -3 }, /* (67) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - { 189, -3 }, /* (68) db_options ::= db_options STREAM_MODE NK_INTEGER */ - { 189, -3 }, /* (69) db_options ::= db_options RETENTIONS NK_STRING */ - { 191, -1 }, /* (70) alter_db_options ::= alter_db_option */ - { 191, -2 }, /* (71) alter_db_options ::= alter_db_options alter_db_option */ - { 192, -2 }, /* (72) alter_db_option ::= BLOCKS NK_INTEGER */ - { 192, -2 }, /* (73) alter_db_option ::= FSYNC NK_INTEGER */ - { 192, -2 }, /* (74) alter_db_option ::= KEEP NK_INTEGER */ - { 192, -2 }, /* (75) alter_db_option ::= WAL NK_INTEGER */ - { 192, -2 }, /* (76) alter_db_option ::= QUORUM NK_INTEGER */ - { 192, -2 }, /* (77) alter_db_option ::= CACHELAST NK_INTEGER */ - { 179, -9 }, /* (78) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - { 179, -3 }, /* (79) cmd ::= CREATE TABLE multi_create_clause */ - { 179, -9 }, /* (80) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - { 179, -3 }, /* (81) cmd ::= DROP TABLE multi_drop_clause */ - { 179, -4 }, /* (82) cmd ::= DROP STABLE exists_opt full_table_name */ - { 179, -3 }, /* (83) cmd ::= ALTER TABLE alter_table_clause */ - { 179, -3 }, /* (84) cmd ::= ALTER STABLE alter_table_clause */ - { 200, -2 }, /* (85) alter_table_clause ::= full_table_name alter_table_options */ - { 200, -5 }, /* (86) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - { 200, -4 }, /* (87) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - { 200, -5 }, /* (88) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - { 200, -5 }, /* (89) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - { 200, -5 }, /* (90) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - { 200, -4 }, /* (91) alter_table_clause ::= full_table_name DROP TAG column_name */ - { 200, -5 }, /* (92) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - { 200, -5 }, /* (93) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - { 200, -6 }, /* (94) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ - { 197, -1 }, /* (95) multi_create_clause ::= create_subtable_clause */ - { 197, -2 }, /* (96) multi_create_clause ::= multi_create_clause create_subtable_clause */ - { 204, -9 }, /* (97) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ - { 199, -1 }, /* (98) multi_drop_clause ::= drop_table_clause */ - { 199, -2 }, /* (99) multi_drop_clause ::= multi_drop_clause drop_table_clause */ - { 207, -2 }, /* (100) drop_table_clause ::= exists_opt full_table_name */ - { 205, 0 }, /* (101) specific_tags_opt ::= */ - { 205, -3 }, /* (102) specific_tags_opt ::= NK_LP col_name_list NK_RP */ - { 193, -1 }, /* (103) full_table_name ::= table_name */ - { 193, -3 }, /* (104) full_table_name ::= db_name NK_DOT table_name */ - { 194, -1 }, /* (105) column_def_list ::= column_def */ - { 194, -3 }, /* (106) column_def_list ::= column_def_list NK_COMMA column_def */ - { 210, -2 }, /* (107) column_def ::= column_name type_name */ - { 210, -4 }, /* (108) column_def ::= column_name type_name COMMENT NK_STRING */ - { 203, -1 }, /* (109) type_name ::= BOOL */ - { 203, -1 }, /* (110) type_name ::= TINYINT */ - { 203, -1 }, /* (111) type_name ::= SMALLINT */ - { 203, -1 }, /* (112) type_name ::= INT */ - { 203, -1 }, /* (113) type_name ::= INTEGER */ - { 203, -1 }, /* (114) type_name ::= BIGINT */ - { 203, -1 }, /* (115) type_name ::= FLOAT */ - { 203, -1 }, /* (116) type_name ::= DOUBLE */ - { 203, -4 }, /* (117) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - { 203, -1 }, /* (118) type_name ::= TIMESTAMP */ - { 203, -4 }, /* (119) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - { 203, -2 }, /* (120) type_name ::= TINYINT UNSIGNED */ - { 203, -2 }, /* (121) type_name ::= SMALLINT UNSIGNED */ - { 203, -2 }, /* (122) type_name ::= INT UNSIGNED */ - { 203, -2 }, /* (123) type_name ::= BIGINT UNSIGNED */ - { 203, -1 }, /* (124) type_name ::= JSON */ - { 203, -4 }, /* (125) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - { 203, -1 }, /* (126) type_name ::= MEDIUMBLOB */ - { 203, -1 }, /* (127) type_name ::= BLOB */ - { 203, -4 }, /* (128) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - { 203, -1 }, /* (129) type_name ::= DECIMAL */ - { 203, -4 }, /* (130) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - { 203, -6 }, /* (131) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - { 195, 0 }, /* (132) tags_def_opt ::= */ - { 195, -1 }, /* (133) tags_def_opt ::= tags_def */ - { 198, -4 }, /* (134) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - { 196, 0 }, /* (135) table_options ::= */ - { 196, -3 }, /* (136) table_options ::= table_options COMMENT NK_STRING */ - { 196, -3 }, /* (137) table_options ::= table_options KEEP NK_INTEGER */ - { 196, -3 }, /* (138) table_options ::= table_options TTL NK_INTEGER */ - { 196, -5 }, /* (139) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - { 196, -5 }, /* (140) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ - { 196, -3 }, /* (141) table_options ::= table_options FILE_FACTOR NK_FLOAT */ - { 196, -3 }, /* (142) table_options ::= table_options DELAY NK_INTEGER */ - { 201, -1 }, /* (143) alter_table_options ::= alter_table_option */ - { 201, -2 }, /* (144) alter_table_options ::= alter_table_options alter_table_option */ - { 212, -2 }, /* (145) alter_table_option ::= COMMENT NK_STRING */ - { 212, -2 }, /* (146) alter_table_option ::= KEEP NK_INTEGER */ - { 212, -2 }, /* (147) alter_table_option ::= TTL NK_INTEGER */ - { 208, -1 }, /* (148) col_name_list ::= col_name */ - { 208, -3 }, /* (149) col_name_list ::= col_name_list NK_COMMA col_name */ - { 213, -1 }, /* (150) col_name ::= column_name */ - { 179, -2 }, /* (151) cmd ::= SHOW DNODES */ - { 179, -2 }, /* (152) cmd ::= SHOW USERS */ - { 179, -2 }, /* (153) cmd ::= SHOW DATABASES */ - { 179, -4 }, /* (154) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ - { 179, -4 }, /* (155) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - { 179, -3 }, /* (156) cmd ::= SHOW db_name_cond_opt VGROUPS */ - { 179, -2 }, /* (157) cmd ::= SHOW MNODES */ - { 179, -2 }, /* (158) cmd ::= SHOW MODULES */ - { 179, -2 }, /* (159) cmd ::= SHOW QNODES */ - { 179, -2 }, /* (160) cmd ::= SHOW FUNCTIONS */ - { 179, -5 }, /* (161) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - { 179, -2 }, /* (162) cmd ::= SHOW STREAMS */ - { 214, 0 }, /* (163) db_name_cond_opt ::= */ - { 214, -2 }, /* (164) db_name_cond_opt ::= db_name NK_DOT */ - { 215, 0 }, /* (165) like_pattern_opt ::= */ - { 215, -2 }, /* (166) like_pattern_opt ::= LIKE NK_STRING */ - { 216, -1 }, /* (167) table_name_cond ::= table_name */ - { 217, 0 }, /* (168) from_db_opt ::= */ - { 217, -2 }, /* (169) from_db_opt ::= FROM db_name */ - { 211, -1 }, /* (170) func_name_list ::= func_name */ - { 211, -3 }, /* (171) func_name_list ::= func_name_list NK_COMMA col_name */ - { 218, -1 }, /* (172) func_name ::= function_name */ - { 179, -8 }, /* (173) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ - { 179, -10 }, /* (174) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ - { 179, -6 }, /* (175) cmd ::= DROP INDEX exists_opt index_name ON table_name */ - { 221, 0 }, /* (176) index_options ::= */ - { 221, -9 }, /* (177) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ - { 221, -11 }, /* (178) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ - { 222, -1 }, /* (179) func_list ::= func */ - { 222, -3 }, /* (180) func_list ::= func_list NK_COMMA func */ - { 225, -4 }, /* (181) func ::= function_name NK_LP expression_list NK_RP */ - { 179, -6 }, /* (182) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ - { 179, -6 }, /* (183) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ - { 179, -4 }, /* (184) cmd ::= DROP TOPIC exists_opt topic_name */ - { 179, -2 }, /* (185) cmd ::= DESC full_table_name */ - { 179, -2 }, /* (186) cmd ::= DESCRIBE full_table_name */ - { 179, -3 }, /* (187) cmd ::= RESET QUERY CACHE */ - { 179, -4 }, /* (188) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ - { 229, 0 }, /* (189) analyze_opt ::= */ - { 229, -1 }, /* (190) analyze_opt ::= ANALYZE */ - { 230, 0 }, /* (191) explain_options ::= */ - { 230, -3 }, /* (192) explain_options ::= explain_options VERBOSE NK_BOOL */ - { 230, -3 }, /* (193) explain_options ::= explain_options RATIO NK_FLOAT */ - { 179, -1 }, /* (194) cmd ::= query_expression */ - { 182, -1 }, /* (195) literal ::= NK_INTEGER */ - { 182, -1 }, /* (196) literal ::= NK_FLOAT */ - { 182, -1 }, /* (197) literal ::= NK_STRING */ - { 182, -1 }, /* (198) literal ::= NK_BOOL */ - { 182, -2 }, /* (199) literal ::= TIMESTAMP NK_STRING */ - { 182, -1 }, /* (200) literal ::= duration_literal */ - { 182, -1 }, /* (201) literal ::= NULL */ - { 223, -1 }, /* (202) duration_literal ::= NK_VARIABLE */ - { 231, -1 }, /* (203) signed ::= NK_INTEGER */ - { 231, -2 }, /* (204) signed ::= NK_PLUS NK_INTEGER */ - { 231, -2 }, /* (205) signed ::= NK_MINUS NK_INTEGER */ - { 231, -1 }, /* (206) signed ::= NK_FLOAT */ - { 231, -2 }, /* (207) signed ::= NK_PLUS NK_FLOAT */ - { 231, -2 }, /* (208) signed ::= NK_MINUS NK_FLOAT */ - { 232, -1 }, /* (209) signed_literal ::= signed */ - { 232, -1 }, /* (210) signed_literal ::= NK_STRING */ - { 232, -1 }, /* (211) signed_literal ::= NK_BOOL */ - { 232, -2 }, /* (212) signed_literal ::= TIMESTAMP NK_STRING */ - { 232, -1 }, /* (213) signed_literal ::= duration_literal */ - { 232, -1 }, /* (214) signed_literal ::= NULL */ - { 206, -1 }, /* (215) literal_list ::= signed_literal */ - { 206, -3 }, /* (216) literal_list ::= literal_list NK_COMMA signed_literal */ - { 188, -1 }, /* (217) db_name ::= NK_ID */ - { 209, -1 }, /* (218) table_name ::= NK_ID */ - { 202, -1 }, /* (219) column_name ::= NK_ID */ - { 219, -1 }, /* (220) function_name ::= NK_ID */ - { 233, -1 }, /* (221) table_alias ::= NK_ID */ - { 234, -1 }, /* (222) column_alias ::= NK_ID */ - { 184, -1 }, /* (223) user_name ::= NK_ID */ - { 220, -1 }, /* (224) index_name ::= NK_ID */ - { 227, -1 }, /* (225) topic_name ::= NK_ID */ - { 235, -1 }, /* (226) expression ::= literal */ - { 235, -1 }, /* (227) expression ::= pseudo_column */ - { 235, -1 }, /* (228) expression ::= column_reference */ - { 235, -4 }, /* (229) expression ::= function_name NK_LP expression_list NK_RP */ - { 235, -4 }, /* (230) expression ::= function_name NK_LP NK_STAR NK_RP */ - { 235, -1 }, /* (231) expression ::= subquery */ - { 235, -3 }, /* (232) expression ::= NK_LP expression NK_RP */ - { 235, -2 }, /* (233) expression ::= NK_PLUS expression */ - { 235, -2 }, /* (234) expression ::= NK_MINUS expression */ - { 235, -3 }, /* (235) expression ::= expression NK_PLUS expression */ - { 235, -3 }, /* (236) expression ::= expression NK_MINUS expression */ - { 235, -3 }, /* (237) expression ::= expression NK_STAR expression */ - { 235, -3 }, /* (238) expression ::= expression NK_SLASH expression */ - { 235, -3 }, /* (239) expression ::= expression NK_REM expression */ - { 226, -1 }, /* (240) expression_list ::= expression */ - { 226, -3 }, /* (241) expression_list ::= expression_list NK_COMMA expression */ - { 237, -1 }, /* (242) column_reference ::= column_name */ - { 237, -3 }, /* (243) column_reference ::= table_name NK_DOT column_name */ - { 236, -2 }, /* (244) pseudo_column ::= NK_UNDERLINE ROWTS */ - { 236, -1 }, /* (245) pseudo_column ::= TBNAME */ - { 236, -2 }, /* (246) pseudo_column ::= NK_UNDERLINE QSTARTTS */ - { 236, -2 }, /* (247) pseudo_column ::= NK_UNDERLINE QENDTS */ - { 236, -2 }, /* (248) pseudo_column ::= NK_UNDERLINE WSTARTTS */ - { 236, -2 }, /* (249) pseudo_column ::= NK_UNDERLINE WENDTS */ - { 236, -2 }, /* (250) pseudo_column ::= NK_UNDERLINE WDURATION */ - { 239, -3 }, /* (251) predicate ::= expression compare_op expression */ - { 239, -5 }, /* (252) predicate ::= expression BETWEEN expression AND expression */ - { 239, -6 }, /* (253) predicate ::= expression NOT BETWEEN expression AND expression */ - { 239, -3 }, /* (254) predicate ::= expression IS NULL */ - { 239, -4 }, /* (255) predicate ::= expression IS NOT NULL */ - { 239, -3 }, /* (256) predicate ::= expression in_op in_predicate_value */ - { 240, -1 }, /* (257) compare_op ::= NK_LT */ - { 240, -1 }, /* (258) compare_op ::= NK_GT */ - { 240, -1 }, /* (259) compare_op ::= NK_LE */ - { 240, -1 }, /* (260) compare_op ::= NK_GE */ - { 240, -1 }, /* (261) compare_op ::= NK_NE */ - { 240, -1 }, /* (262) compare_op ::= NK_EQ */ - { 240, -1 }, /* (263) compare_op ::= LIKE */ - { 240, -2 }, /* (264) compare_op ::= NOT LIKE */ - { 240, -1 }, /* (265) compare_op ::= MATCH */ - { 240, -1 }, /* (266) compare_op ::= NMATCH */ - { 241, -1 }, /* (267) in_op ::= IN */ - { 241, -2 }, /* (268) in_op ::= NOT IN */ - { 242, -3 }, /* (269) in_predicate_value ::= NK_LP expression_list NK_RP */ - { 243, -1 }, /* (270) boolean_value_expression ::= boolean_primary */ - { 243, -2 }, /* (271) boolean_value_expression ::= NOT boolean_primary */ - { 243, -3 }, /* (272) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - { 243, -3 }, /* (273) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - { 244, -1 }, /* (274) boolean_primary ::= predicate */ - { 244, -3 }, /* (275) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - { 245, -1 }, /* (276) common_expression ::= expression */ - { 245, -1 }, /* (277) common_expression ::= boolean_value_expression */ - { 246, -2 }, /* (278) from_clause ::= FROM table_reference_list */ - { 247, -1 }, /* (279) table_reference_list ::= table_reference */ - { 247, -3 }, /* (280) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - { 248, -1 }, /* (281) table_reference ::= table_primary */ - { 248, -1 }, /* (282) table_reference ::= joined_table */ - { 249, -2 }, /* (283) table_primary ::= table_name alias_opt */ - { 249, -4 }, /* (284) table_primary ::= db_name NK_DOT table_name alias_opt */ - { 249, -2 }, /* (285) table_primary ::= subquery alias_opt */ - { 249, -1 }, /* (286) table_primary ::= parenthesized_joined_table */ - { 251, 0 }, /* (287) alias_opt ::= */ - { 251, -1 }, /* (288) alias_opt ::= table_alias */ - { 251, -2 }, /* (289) alias_opt ::= AS table_alias */ - { 252, -3 }, /* (290) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - { 252, -3 }, /* (291) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - { 250, -6 }, /* (292) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ - { 253, 0 }, /* (293) join_type ::= */ - { 253, -1 }, /* (294) join_type ::= INNER */ - { 255, -9 }, /* (295) 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 */ - { 256, 0 }, /* (296) set_quantifier_opt ::= */ - { 256, -1 }, /* (297) set_quantifier_opt ::= DISTINCT */ - { 256, -1 }, /* (298) set_quantifier_opt ::= ALL */ - { 257, -1 }, /* (299) select_list ::= NK_STAR */ - { 257, -1 }, /* (300) select_list ::= select_sublist */ - { 263, -1 }, /* (301) select_sublist ::= select_item */ - { 263, -3 }, /* (302) select_sublist ::= select_sublist NK_COMMA select_item */ - { 264, -1 }, /* (303) select_item ::= common_expression */ - { 264, -2 }, /* (304) select_item ::= common_expression column_alias */ - { 264, -3 }, /* (305) select_item ::= common_expression AS column_alias */ - { 264, -3 }, /* (306) select_item ::= table_name NK_DOT NK_STAR */ - { 258, 0 }, /* (307) where_clause_opt ::= */ - { 258, -2 }, /* (308) where_clause_opt ::= WHERE search_condition */ - { 259, 0 }, /* (309) partition_by_clause_opt ::= */ - { 259, -3 }, /* (310) partition_by_clause_opt ::= PARTITION BY expression_list */ - { 260, 0 }, /* (311) twindow_clause_opt ::= */ - { 260, -6 }, /* (312) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ - { 260, -4 }, /* (313) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ - { 260, -6 }, /* (314) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ - { 260, -8 }, /* (315) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ - { 224, 0 }, /* (316) sliding_opt ::= */ - { 224, -4 }, /* (317) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ - { 265, 0 }, /* (318) fill_opt ::= */ - { 265, -4 }, /* (319) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - { 265, -6 }, /* (320) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ - { 266, -1 }, /* (321) fill_mode ::= NONE */ - { 266, -1 }, /* (322) fill_mode ::= PREV */ - { 266, -1 }, /* (323) fill_mode ::= NULL */ - { 266, -1 }, /* (324) fill_mode ::= LINEAR */ - { 266, -1 }, /* (325) fill_mode ::= NEXT */ - { 261, 0 }, /* (326) group_by_clause_opt ::= */ - { 261, -3 }, /* (327) group_by_clause_opt ::= GROUP BY group_by_list */ - { 267, -1 }, /* (328) group_by_list ::= expression */ - { 267, -3 }, /* (329) group_by_list ::= group_by_list NK_COMMA expression */ - { 262, 0 }, /* (330) having_clause_opt ::= */ - { 262, -2 }, /* (331) having_clause_opt ::= HAVING search_condition */ - { 228, -4 }, /* (332) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ - { 268, -1 }, /* (333) query_expression_body ::= query_primary */ - { 268, -4 }, /* (334) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ - { 272, -1 }, /* (335) query_primary ::= query_specification */ - { 269, 0 }, /* (336) order_by_clause_opt ::= */ - { 269, -3 }, /* (337) order_by_clause_opt ::= ORDER BY sort_specification_list */ - { 270, 0 }, /* (338) slimit_clause_opt ::= */ - { 270, -2 }, /* (339) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - { 270, -4 }, /* (340) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - { 270, -4 }, /* (341) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 271, 0 }, /* (342) limit_clause_opt ::= */ - { 271, -2 }, /* (343) limit_clause_opt ::= LIMIT NK_INTEGER */ - { 271, -4 }, /* (344) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - { 271, -4 }, /* (345) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - { 238, -3 }, /* (346) subquery ::= NK_LP query_expression NK_RP */ - { 254, -1 }, /* (347) search_condition ::= common_expression */ - { 273, -1 }, /* (348) sort_specification_list ::= sort_specification */ - { 273, -3 }, /* (349) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - { 274, -3 }, /* (350) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ - { 275, 0 }, /* (351) ordering_specification_opt ::= */ - { 275, -1 }, /* (352) ordering_specification_opt ::= ASC */ - { 275, -1 }, /* (353) ordering_specification_opt ::= DESC */ - { 276, 0 }, /* (354) null_ordering_opt ::= */ - { 276, -2 }, /* (355) null_ordering_opt ::= NULLS FIRST */ - { 276, -2 }, /* (356) null_ordering_opt ::= NULLS LAST */ + { 201, -6 }, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + { 201, -4 }, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + { 202, 0 }, /* (2) account_options ::= */ + { 202, -3 }, /* (3) account_options ::= account_options PPS literal */ + { 202, -3 }, /* (4) account_options ::= account_options TSERIES literal */ + { 202, -3 }, /* (5) account_options ::= account_options STORAGE literal */ + { 202, -3 }, /* (6) account_options ::= account_options STREAMS literal */ + { 202, -3 }, /* (7) account_options ::= account_options QTIME literal */ + { 202, -3 }, /* (8) account_options ::= account_options DBS literal */ + { 202, -3 }, /* (9) account_options ::= account_options USERS literal */ + { 202, -3 }, /* (10) account_options ::= account_options CONNS literal */ + { 202, -3 }, /* (11) account_options ::= account_options STATE literal */ + { 203, -1 }, /* (12) alter_account_options ::= alter_account_option */ + { 203, -2 }, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + { 205, -2 }, /* (14) alter_account_option ::= PASS literal */ + { 205, -2 }, /* (15) alter_account_option ::= PPS literal */ + { 205, -2 }, /* (16) alter_account_option ::= TSERIES literal */ + { 205, -2 }, /* (17) alter_account_option ::= STORAGE literal */ + { 205, -2 }, /* (18) alter_account_option ::= STREAMS literal */ + { 205, -2 }, /* (19) alter_account_option ::= QTIME literal */ + { 205, -2 }, /* (20) alter_account_option ::= DBS literal */ + { 205, -2 }, /* (21) alter_account_option ::= USERS literal */ + { 205, -2 }, /* (22) alter_account_option ::= CONNS literal */ + { 205, -2 }, /* (23) alter_account_option ::= STATE literal */ + { 201, -5 }, /* (24) cmd ::= CREATE USER user_name PASS NK_STRING */ + { 201, -5 }, /* (25) cmd ::= ALTER USER user_name PASS NK_STRING */ + { 201, -5 }, /* (26) cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ + { 201, -3 }, /* (27) cmd ::= DROP USER user_name */ + { 201, -3 }, /* (28) cmd ::= CREATE DNODE dnode_endpoint */ + { 201, -5 }, /* (29) cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ + { 201, -3 }, /* (30) cmd ::= DROP DNODE NK_INTEGER */ + { 201, -3 }, /* (31) cmd ::= DROP DNODE dnode_endpoint */ + { 201, -4 }, /* (32) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + { 201, -5 }, /* (33) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + { 201, -4 }, /* (34) cmd ::= ALTER ALL DNODES NK_STRING */ + { 201, -5 }, /* (35) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + { 207, -1 }, /* (36) dnode_endpoint ::= NK_STRING */ + { 208, -1 }, /* (37) dnode_host_name ::= NK_ID */ + { 208, -1 }, /* (38) dnode_host_name ::= NK_IPTOKEN */ + { 201, -3 }, /* (39) cmd ::= ALTER LOCAL NK_STRING */ + { 201, -4 }, /* (40) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + { 201, -5 }, /* (41) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + { 201, -5 }, /* (42) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + { 201, -5 }, /* (43) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + { 201, -4 }, /* (44) cmd ::= DROP DATABASE exists_opt db_name */ + { 201, -2 }, /* (45) cmd ::= USE db_name */ + { 201, -4 }, /* (46) cmd ::= ALTER DATABASE db_name alter_db_options */ + { 209, -3 }, /* (47) not_exists_opt ::= IF NOT EXISTS */ + { 209, 0 }, /* (48) not_exists_opt ::= */ + { 212, -2 }, /* (49) exists_opt ::= IF EXISTS */ + { 212, 0 }, /* (50) exists_opt ::= */ + { 211, 0 }, /* (51) db_options ::= */ + { 211, -3 }, /* (52) db_options ::= db_options BLOCKS NK_INTEGER */ + { 211, -3 }, /* (53) db_options ::= db_options CACHE NK_INTEGER */ + { 211, -3 }, /* (54) db_options ::= db_options CACHELAST NK_INTEGER */ + { 211, -3 }, /* (55) db_options ::= db_options COMP NK_INTEGER */ + { 211, -3 }, /* (56) db_options ::= db_options DAYS NK_INTEGER */ + { 211, -3 }, /* (57) db_options ::= db_options FSYNC NK_INTEGER */ + { 211, -3 }, /* (58) db_options ::= db_options MAXROWS NK_INTEGER */ + { 211, -3 }, /* (59) db_options ::= db_options MINROWS NK_INTEGER */ + { 211, -3 }, /* (60) db_options ::= db_options KEEP integer_list */ + { 211, -3 }, /* (61) db_options ::= db_options PRECISION NK_STRING */ + { 211, -3 }, /* (62) db_options ::= db_options QUORUM NK_INTEGER */ + { 211, -3 }, /* (63) db_options ::= db_options REPLICA NK_INTEGER */ + { 211, -3 }, /* (64) db_options ::= db_options TTL NK_INTEGER */ + { 211, -3 }, /* (65) db_options ::= db_options WAL NK_INTEGER */ + { 211, -3 }, /* (66) db_options ::= db_options VGROUPS NK_INTEGER */ + { 211, -3 }, /* (67) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + { 211, -3 }, /* (68) db_options ::= db_options STREAM_MODE NK_INTEGER */ + { 211, -3 }, /* (69) db_options ::= db_options RETENTIONS NK_STRING */ + { 213, -1 }, /* (70) alter_db_options ::= alter_db_option */ + { 213, -2 }, /* (71) alter_db_options ::= alter_db_options alter_db_option */ + { 215, -2 }, /* (72) alter_db_option ::= BLOCKS NK_INTEGER */ + { 215, -2 }, /* (73) alter_db_option ::= FSYNC NK_INTEGER */ + { 215, -2 }, /* (74) alter_db_option ::= KEEP integer_list */ + { 215, -2 }, /* (75) alter_db_option ::= WAL NK_INTEGER */ + { 215, -2 }, /* (76) alter_db_option ::= QUORUM NK_INTEGER */ + { 215, -2 }, /* (77) alter_db_option ::= CACHELAST NK_INTEGER */ + { 215, -2 }, /* (78) alter_db_option ::= REPLICA NK_INTEGER */ + { 214, -1 }, /* (79) integer_list ::= NK_INTEGER */ + { 214, -3 }, /* (80) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + { 201, -9 }, /* (81) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + { 201, -3 }, /* (82) cmd ::= CREATE TABLE multi_create_clause */ + { 201, -9 }, /* (83) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + { 201, -3 }, /* (84) cmd ::= DROP TABLE multi_drop_clause */ + { 201, -4 }, /* (85) cmd ::= DROP STABLE exists_opt full_table_name */ + { 201, -3 }, /* (86) cmd ::= ALTER TABLE alter_table_clause */ + { 201, -3 }, /* (87) cmd ::= ALTER STABLE alter_table_clause */ + { 223, -2 }, /* (88) alter_table_clause ::= full_table_name alter_table_options */ + { 223, -5 }, /* (89) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + { 223, -4 }, /* (90) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + { 223, -5 }, /* (91) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + { 223, -5 }, /* (92) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + { 223, -5 }, /* (93) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + { 223, -4 }, /* (94) alter_table_clause ::= full_table_name DROP TAG column_name */ + { 223, -5 }, /* (95) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + { 223, -5 }, /* (96) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + { 223, -6 }, /* (97) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ + { 220, -1 }, /* (98) multi_create_clause ::= create_subtable_clause */ + { 220, -2 }, /* (99) multi_create_clause ::= multi_create_clause create_subtable_clause */ + { 227, -9 }, /* (100) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ + { 222, -1 }, /* (101) multi_drop_clause ::= drop_table_clause */ + { 222, -2 }, /* (102) multi_drop_clause ::= multi_drop_clause drop_table_clause */ + { 230, -2 }, /* (103) drop_table_clause ::= exists_opt full_table_name */ + { 228, 0 }, /* (104) specific_tags_opt ::= */ + { 228, -3 }, /* (105) specific_tags_opt ::= NK_LP col_name_list NK_RP */ + { 216, -1 }, /* (106) full_table_name ::= table_name */ + { 216, -3 }, /* (107) full_table_name ::= db_name NK_DOT table_name */ + { 217, -1 }, /* (108) column_def_list ::= column_def */ + { 217, -3 }, /* (109) column_def_list ::= column_def_list NK_COMMA column_def */ + { 233, -2 }, /* (110) column_def ::= column_name type_name */ + { 233, -4 }, /* (111) column_def ::= column_name type_name COMMENT NK_STRING */ + { 226, -1 }, /* (112) type_name ::= BOOL */ + { 226, -1 }, /* (113) type_name ::= TINYINT */ + { 226, -1 }, /* (114) type_name ::= SMALLINT */ + { 226, -1 }, /* (115) type_name ::= INT */ + { 226, -1 }, /* (116) type_name ::= INTEGER */ + { 226, -1 }, /* (117) type_name ::= BIGINT */ + { 226, -1 }, /* (118) type_name ::= FLOAT */ + { 226, -1 }, /* (119) type_name ::= DOUBLE */ + { 226, -4 }, /* (120) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + { 226, -1 }, /* (121) type_name ::= TIMESTAMP */ + { 226, -4 }, /* (122) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + { 226, -2 }, /* (123) type_name ::= TINYINT UNSIGNED */ + { 226, -2 }, /* (124) type_name ::= SMALLINT UNSIGNED */ + { 226, -2 }, /* (125) type_name ::= INT UNSIGNED */ + { 226, -2 }, /* (126) type_name ::= BIGINT UNSIGNED */ + { 226, -1 }, /* (127) type_name ::= JSON */ + { 226, -4 }, /* (128) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + { 226, -1 }, /* (129) type_name ::= MEDIUMBLOB */ + { 226, -1 }, /* (130) type_name ::= BLOB */ + { 226, -4 }, /* (131) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + { 226, -1 }, /* (132) type_name ::= DECIMAL */ + { 226, -4 }, /* (133) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + { 226, -6 }, /* (134) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + { 218, 0 }, /* (135) tags_def_opt ::= */ + { 218, -1 }, /* (136) tags_def_opt ::= tags_def */ + { 221, -4 }, /* (137) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + { 219, 0 }, /* (138) table_options ::= */ + { 219, -3 }, /* (139) table_options ::= table_options COMMENT NK_STRING */ + { 219, -3 }, /* (140) table_options ::= table_options KEEP integer_list */ + { 219, -3 }, /* (141) table_options ::= table_options TTL NK_INTEGER */ + { 219, -5 }, /* (142) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + { 219, -5 }, /* (143) table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ + { 219, -3 }, /* (144) table_options ::= table_options FILE_FACTOR NK_FLOAT */ + { 219, -3 }, /* (145) table_options ::= table_options DELAY NK_INTEGER */ + { 224, -1 }, /* (146) alter_table_options ::= alter_table_option */ + { 224, -2 }, /* (147) alter_table_options ::= alter_table_options alter_table_option */ + { 235, -2 }, /* (148) alter_table_option ::= COMMENT NK_STRING */ + { 235, -2 }, /* (149) alter_table_option ::= KEEP integer_list */ + { 235, -2 }, /* (150) alter_table_option ::= TTL NK_INTEGER */ + { 231, -1 }, /* (151) col_name_list ::= col_name */ + { 231, -3 }, /* (152) col_name_list ::= col_name_list NK_COMMA col_name */ + { 236, -1 }, /* (153) col_name ::= column_name */ + { 201, -2 }, /* (154) cmd ::= SHOW DNODES */ + { 201, -2 }, /* (155) cmd ::= SHOW USERS */ + { 201, -2 }, /* (156) cmd ::= SHOW DATABASES */ + { 201, -4 }, /* (157) cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ + { 201, -4 }, /* (158) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + { 201, -3 }, /* (159) cmd ::= SHOW db_name_cond_opt VGROUPS */ + { 201, -2 }, /* (160) cmd ::= SHOW MNODES */ + { 201, -2 }, /* (161) cmd ::= SHOW MODULES */ + { 201, -2 }, /* (162) cmd ::= SHOW QNODES */ + { 201, -2 }, /* (163) cmd ::= SHOW FUNCTIONS */ + { 201, -5 }, /* (164) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + { 201, -2 }, /* (165) cmd ::= SHOW STREAMS */ + { 201, -2 }, /* (166) cmd ::= SHOW ACCOUNTS */ + { 201, -2 }, /* (167) cmd ::= SHOW APPS */ + { 201, -2 }, /* (168) cmd ::= SHOW CONNECTIONS */ + { 201, -2 }, /* (169) cmd ::= SHOW LICENCE */ + { 201, -4 }, /* (170) cmd ::= SHOW CREATE DATABASE db_name */ + { 201, -4 }, /* (171) cmd ::= SHOW CREATE TABLE full_table_name */ + { 201, -4 }, /* (172) cmd ::= SHOW CREATE STABLE full_table_name */ + { 201, -2 }, /* (173) cmd ::= SHOW QUERIES */ + { 201, -2 }, /* (174) cmd ::= SHOW SCORES */ + { 201, -2 }, /* (175) cmd ::= SHOW TOPICS */ + { 201, -2 }, /* (176) cmd ::= SHOW VARIABLES */ + { 237, 0 }, /* (177) db_name_cond_opt ::= */ + { 237, -2 }, /* (178) db_name_cond_opt ::= db_name NK_DOT */ + { 238, 0 }, /* (179) like_pattern_opt ::= */ + { 238, -2 }, /* (180) like_pattern_opt ::= LIKE NK_STRING */ + { 239, -1 }, /* (181) table_name_cond ::= table_name */ + { 240, 0 }, /* (182) from_db_opt ::= */ + { 240, -2 }, /* (183) from_db_opt ::= FROM db_name */ + { 234, -1 }, /* (184) func_name_list ::= func_name */ + { 234, -3 }, /* (185) func_name_list ::= func_name_list NK_COMMA col_name */ + { 241, -1 }, /* (186) func_name ::= function_name */ + { 201, -8 }, /* (187) cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ + { 201, -10 }, /* (188) cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ + { 201, -6 }, /* (189) cmd ::= DROP INDEX exists_opt index_name ON table_name */ + { 244, 0 }, /* (190) index_options ::= */ + { 244, -9 }, /* (191) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ + { 244, -11 }, /* (192) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt */ + { 245, -1 }, /* (193) func_list ::= func */ + { 245, -3 }, /* (194) func_list ::= func_list NK_COMMA func */ + { 248, -4 }, /* (195) func ::= function_name NK_LP expression_list NK_RP */ + { 201, -6 }, /* (196) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ + { 201, -6 }, /* (197) cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ + { 201, -4 }, /* (198) cmd ::= DROP TOPIC exists_opt topic_name */ + { 201, -2 }, /* (199) cmd ::= DESC full_table_name */ + { 201, -2 }, /* (200) cmd ::= DESCRIBE full_table_name */ + { 201, -3 }, /* (201) cmd ::= RESET QUERY CACHE */ + { 201, -4 }, /* (202) cmd ::= EXPLAIN analyze_opt explain_options query_expression */ + { 252, 0 }, /* (203) analyze_opt ::= */ + { 252, -1 }, /* (204) analyze_opt ::= ANALYZE */ + { 253, 0 }, /* (205) explain_options ::= */ + { 253, -3 }, /* (206) explain_options ::= explain_options VERBOSE NK_BOOL */ + { 253, -3 }, /* (207) explain_options ::= explain_options RATIO NK_FLOAT */ + { 201, -6 }, /* (208) cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ + { 201, -9 }, /* (209) cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ + { 201, -3 }, /* (210) cmd ::= DROP FUNCTION function_name */ + { 254, 0 }, /* (211) agg_func_opt ::= */ + { 254, -1 }, /* (212) agg_func_opt ::= AGGREGATE */ + { 255, 0 }, /* (213) bufsize_opt ::= */ + { 255, -2 }, /* (214) bufsize_opt ::= BUFSIZE NK_INTEGER */ + { 201, -7 }, /* (215) cmd ::= CREATE STREAM stream_name INTO table_name AS query_expression */ + { 201, -3 }, /* (216) cmd ::= DROP STREAM stream_name */ + { 201, -3 }, /* (217) cmd ::= KILL CONNECTION NK_INTEGER */ + { 201, -3 }, /* (218) cmd ::= KILL QUERY NK_INTEGER */ + { 201, -4 }, /* (219) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + { 201, -4 }, /* (220) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + { 201, -3 }, /* (221) cmd ::= SPLIT VGROUP NK_INTEGER */ + { 257, -2 }, /* (222) dnode_list ::= DNODE NK_INTEGER */ + { 257, -3 }, /* (223) dnode_list ::= dnode_list DNODE NK_INTEGER */ + { 201, -3 }, /* (224) cmd ::= SYNCDB db_name REPLICA */ + { 201, -1 }, /* (225) cmd ::= query_expression */ + { 204, -1 }, /* (226) literal ::= NK_INTEGER */ + { 204, -1 }, /* (227) literal ::= NK_FLOAT */ + { 204, -1 }, /* (228) literal ::= NK_STRING */ + { 204, -1 }, /* (229) literal ::= NK_BOOL */ + { 204, -2 }, /* (230) literal ::= TIMESTAMP NK_STRING */ + { 204, -1 }, /* (231) literal ::= duration_literal */ + { 204, -1 }, /* (232) literal ::= NULL */ + { 246, -1 }, /* (233) duration_literal ::= NK_VARIABLE */ + { 258, -1 }, /* (234) signed ::= NK_INTEGER */ + { 258, -2 }, /* (235) signed ::= NK_PLUS NK_INTEGER */ + { 258, -2 }, /* (236) signed ::= NK_MINUS NK_INTEGER */ + { 258, -1 }, /* (237) signed ::= NK_FLOAT */ + { 258, -2 }, /* (238) signed ::= NK_PLUS NK_FLOAT */ + { 258, -2 }, /* (239) signed ::= NK_MINUS NK_FLOAT */ + { 259, -1 }, /* (240) signed_literal ::= signed */ + { 259, -1 }, /* (241) signed_literal ::= NK_STRING */ + { 259, -1 }, /* (242) signed_literal ::= NK_BOOL */ + { 259, -2 }, /* (243) signed_literal ::= TIMESTAMP NK_STRING */ + { 259, -1 }, /* (244) signed_literal ::= duration_literal */ + { 259, -1 }, /* (245) signed_literal ::= NULL */ + { 229, -1 }, /* (246) literal_list ::= signed_literal */ + { 229, -3 }, /* (247) literal_list ::= literal_list NK_COMMA signed_literal */ + { 210, -1 }, /* (248) db_name ::= NK_ID */ + { 232, -1 }, /* (249) table_name ::= NK_ID */ + { 225, -1 }, /* (250) column_name ::= NK_ID */ + { 242, -1 }, /* (251) function_name ::= NK_ID */ + { 260, -1 }, /* (252) table_alias ::= NK_ID */ + { 261, -1 }, /* (253) column_alias ::= NK_ID */ + { 206, -1 }, /* (254) user_name ::= NK_ID */ + { 243, -1 }, /* (255) index_name ::= NK_ID */ + { 250, -1 }, /* (256) topic_name ::= NK_ID */ + { 256, -1 }, /* (257) stream_name ::= NK_ID */ + { 262, -1 }, /* (258) expression ::= literal */ + { 262, -1 }, /* (259) expression ::= pseudo_column */ + { 262, -1 }, /* (260) expression ::= column_reference */ + { 262, -4 }, /* (261) expression ::= function_name NK_LP expression_list NK_RP */ + { 262, -4 }, /* (262) expression ::= function_name NK_LP NK_STAR NK_RP */ + { 262, -1 }, /* (263) expression ::= subquery */ + { 262, -3 }, /* (264) expression ::= NK_LP expression NK_RP */ + { 262, -2 }, /* (265) expression ::= NK_PLUS expression */ + { 262, -2 }, /* (266) expression ::= NK_MINUS expression */ + { 262, -3 }, /* (267) expression ::= expression NK_PLUS expression */ + { 262, -3 }, /* (268) expression ::= expression NK_MINUS expression */ + { 262, -3 }, /* (269) expression ::= expression NK_STAR expression */ + { 262, -3 }, /* (270) expression ::= expression NK_SLASH expression */ + { 262, -3 }, /* (271) expression ::= expression NK_REM expression */ + { 249, -1 }, /* (272) expression_list ::= expression */ + { 249, -3 }, /* (273) expression_list ::= expression_list NK_COMMA expression */ + { 264, -1 }, /* (274) column_reference ::= column_name */ + { 264, -3 }, /* (275) column_reference ::= table_name NK_DOT column_name */ + { 263, -2 }, /* (276) pseudo_column ::= NK_UNDERLINE ROWTS */ + { 263, -1 }, /* (277) pseudo_column ::= TBNAME */ + { 263, -2 }, /* (278) pseudo_column ::= NK_UNDERLINE QSTARTTS */ + { 263, -2 }, /* (279) pseudo_column ::= NK_UNDERLINE QENDTS */ + { 263, -2 }, /* (280) pseudo_column ::= NK_UNDERLINE WSTARTTS */ + { 263, -2 }, /* (281) pseudo_column ::= NK_UNDERLINE WENDTS */ + { 263, -2 }, /* (282) pseudo_column ::= NK_UNDERLINE WDURATION */ + { 266, -3 }, /* (283) predicate ::= expression compare_op expression */ + { 266, -5 }, /* (284) predicate ::= expression BETWEEN expression AND expression */ + { 266, -6 }, /* (285) predicate ::= expression NOT BETWEEN expression AND expression */ + { 266, -3 }, /* (286) predicate ::= expression IS NULL */ + { 266, -4 }, /* (287) predicate ::= expression IS NOT NULL */ + { 266, -3 }, /* (288) predicate ::= expression in_op in_predicate_value */ + { 267, -1 }, /* (289) compare_op ::= NK_LT */ + { 267, -1 }, /* (290) compare_op ::= NK_GT */ + { 267, -1 }, /* (291) compare_op ::= NK_LE */ + { 267, -1 }, /* (292) compare_op ::= NK_GE */ + { 267, -1 }, /* (293) compare_op ::= NK_NE */ + { 267, -1 }, /* (294) compare_op ::= NK_EQ */ + { 267, -1 }, /* (295) compare_op ::= LIKE */ + { 267, -2 }, /* (296) compare_op ::= NOT LIKE */ + { 267, -1 }, /* (297) compare_op ::= MATCH */ + { 267, -1 }, /* (298) compare_op ::= NMATCH */ + { 268, -1 }, /* (299) in_op ::= IN */ + { 268, -2 }, /* (300) in_op ::= NOT IN */ + { 269, -3 }, /* (301) in_predicate_value ::= NK_LP expression_list NK_RP */ + { 270, -1 }, /* (302) boolean_value_expression ::= boolean_primary */ + { 270, -2 }, /* (303) boolean_value_expression ::= NOT boolean_primary */ + { 270, -3 }, /* (304) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + { 270, -3 }, /* (305) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + { 271, -1 }, /* (306) boolean_primary ::= predicate */ + { 271, -3 }, /* (307) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + { 272, -1 }, /* (308) common_expression ::= expression */ + { 272, -1 }, /* (309) common_expression ::= boolean_value_expression */ + { 273, -2 }, /* (310) from_clause ::= FROM table_reference_list */ + { 274, -1 }, /* (311) table_reference_list ::= table_reference */ + { 274, -3 }, /* (312) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + { 275, -1 }, /* (313) table_reference ::= table_primary */ + { 275, -1 }, /* (314) table_reference ::= joined_table */ + { 276, -2 }, /* (315) table_primary ::= table_name alias_opt */ + { 276, -4 }, /* (316) table_primary ::= db_name NK_DOT table_name alias_opt */ + { 276, -2 }, /* (317) table_primary ::= subquery alias_opt */ + { 276, -1 }, /* (318) table_primary ::= parenthesized_joined_table */ + { 278, 0 }, /* (319) alias_opt ::= */ + { 278, -1 }, /* (320) alias_opt ::= table_alias */ + { 278, -2 }, /* (321) alias_opt ::= AS table_alias */ + { 279, -3 }, /* (322) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + { 279, -3 }, /* (323) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + { 277, -6 }, /* (324) joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ + { 280, 0 }, /* (325) join_type ::= */ + { 280, -1 }, /* (326) join_type ::= INNER */ + { 282, -9 }, /* (327) 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 */ + { 283, 0 }, /* (328) set_quantifier_opt ::= */ + { 283, -1 }, /* (329) set_quantifier_opt ::= DISTINCT */ + { 283, -1 }, /* (330) set_quantifier_opt ::= ALL */ + { 284, -1 }, /* (331) select_list ::= NK_STAR */ + { 284, -1 }, /* (332) select_list ::= select_sublist */ + { 290, -1 }, /* (333) select_sublist ::= select_item */ + { 290, -3 }, /* (334) select_sublist ::= select_sublist NK_COMMA select_item */ + { 291, -1 }, /* (335) select_item ::= common_expression */ + { 291, -2 }, /* (336) select_item ::= common_expression column_alias */ + { 291, -3 }, /* (337) select_item ::= common_expression AS column_alias */ + { 291, -3 }, /* (338) select_item ::= table_name NK_DOT NK_STAR */ + { 285, 0 }, /* (339) where_clause_opt ::= */ + { 285, -2 }, /* (340) where_clause_opt ::= WHERE search_condition */ + { 286, 0 }, /* (341) partition_by_clause_opt ::= */ + { 286, -3 }, /* (342) partition_by_clause_opt ::= PARTITION BY expression_list */ + { 287, 0 }, /* (343) twindow_clause_opt ::= */ + { 287, -6 }, /* (344) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ + { 287, -4 }, /* (345) twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ + { 287, -6 }, /* (346) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ + { 287, -8 }, /* (347) twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ + { 247, 0 }, /* (348) sliding_opt ::= */ + { 247, -4 }, /* (349) sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ + { 292, 0 }, /* (350) fill_opt ::= */ + { 292, -4 }, /* (351) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + { 292, -6 }, /* (352) fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ + { 293, -1 }, /* (353) fill_mode ::= NONE */ + { 293, -1 }, /* (354) fill_mode ::= PREV */ + { 293, -1 }, /* (355) fill_mode ::= NULL */ + { 293, -1 }, /* (356) fill_mode ::= LINEAR */ + { 293, -1 }, /* (357) fill_mode ::= NEXT */ + { 288, 0 }, /* (358) group_by_clause_opt ::= */ + { 288, -3 }, /* (359) group_by_clause_opt ::= GROUP BY group_by_list */ + { 294, -1 }, /* (360) group_by_list ::= expression */ + { 294, -3 }, /* (361) group_by_list ::= group_by_list NK_COMMA expression */ + { 289, 0 }, /* (362) having_clause_opt ::= */ + { 289, -2 }, /* (363) having_clause_opt ::= HAVING search_condition */ + { 251, -4 }, /* (364) query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + { 295, -1 }, /* (365) query_expression_body ::= query_primary */ + { 295, -4 }, /* (366) query_expression_body ::= query_expression_body UNION ALL query_expression_body */ + { 299, -1 }, /* (367) query_primary ::= query_specification */ + { 296, 0 }, /* (368) order_by_clause_opt ::= */ + { 296, -3 }, /* (369) order_by_clause_opt ::= ORDER BY sort_specification_list */ + { 297, 0 }, /* (370) slimit_clause_opt ::= */ + { 297, -2 }, /* (371) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + { 297, -4 }, /* (372) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + { 297, -4 }, /* (373) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 298, 0 }, /* (374) limit_clause_opt ::= */ + { 298, -2 }, /* (375) limit_clause_opt ::= LIMIT NK_INTEGER */ + { 298, -4 }, /* (376) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + { 298, -4 }, /* (377) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + { 265, -3 }, /* (378) subquery ::= NK_LP query_expression NK_RP */ + { 281, -1 }, /* (379) search_condition ::= common_expression */ + { 300, -1 }, /* (380) sort_specification_list ::= sort_specification */ + { 300, -3 }, /* (381) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + { 301, -3 }, /* (382) sort_specification ::= expression ordering_specification_opt null_ordering_opt */ + { 302, 0 }, /* (383) ordering_specification_opt ::= */ + { 302, -1 }, /* (384) ordering_specification_opt ::= ASC */ + { 302, -1 }, /* (385) ordering_specification_opt ::= DESC */ + { 303, 0 }, /* (386) null_ordering_opt ::= */ + { 303, -2 }, /* (387) null_ordering_opt ::= NULLS FIRST */ + { 303, -2 }, /* (388) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -2383,11 +2509,11 @@ static YYACTIONTYPE yy_reduce( YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,180,&yymsp[0].minor); + yy_destructor(yypParser,202,&yymsp[0].minor); break; case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ { pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,181,&yymsp[0].minor); + yy_destructor(yypParser,203,&yymsp[0].minor); break; case 2: /* account_options ::= */ { } @@ -2401,20 +2527,20 @@ static YYACTIONTYPE yy_reduce( case 9: /* account_options ::= account_options USERS literal */ yytestcase(yyruleno==9); case 10: /* account_options ::= account_options CONNS literal */ yytestcase(yyruleno==10); case 11: /* account_options ::= account_options STATE literal */ yytestcase(yyruleno==11); -{ yy_destructor(yypParser,180,&yymsp[-2].minor); +{ yy_destructor(yypParser,202,&yymsp[-2].minor); { } - yy_destructor(yypParser,182,&yymsp[0].minor); + yy_destructor(yypParser,204,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,183,&yymsp[0].minor); +{ yy_destructor(yypParser,205,&yymsp[0].minor); { } } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,181,&yymsp[-1].minor); +{ yy_destructor(yypParser,203,&yymsp[-1].minor); { } - yy_destructor(yypParser,183,&yymsp[0].minor); + yy_destructor(yypParser,205,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -2428,31 +2554,31 @@ static YYACTIONTYPE yy_reduce( case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22); case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); { } - yy_destructor(yypParser,182,&yymsp[0].minor); + yy_destructor(yypParser,204,&yymsp[0].minor); break; case 24: /* cmd ::= CREATE USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy95, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0); } break; case 25: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy95, 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 26: /* cmd ::= ALTER USER user_name PRIVILEGE NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy95, 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 27: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy95); } +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy129); } break; case 28: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy95, NULL); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy129, NULL); } break; case 29: /* cmd ::= CREATE DNODE dnode_host_name PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy95, &yymsp[0].minor.yy0); } +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0); } break; case 30: /* cmd ::= DROP DNODE NK_INTEGER */ { pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; case 31: /* cmd ::= DROP DNODE dnode_endpoint */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy95); } +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[0].minor.yy129); } break; case 32: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } @@ -2469,17 +2595,18 @@ static YYACTIONTYPE yy_reduce( case 36: /* dnode_endpoint ::= NK_STRING */ case 37: /* dnode_host_name ::= NK_ID */ yytestcase(yyruleno==37); case 38: /* dnode_host_name ::= NK_IPTOKEN */ yytestcase(yyruleno==38); - case 217: /* db_name ::= NK_ID */ yytestcase(yyruleno==217); - case 218: /* table_name ::= NK_ID */ yytestcase(yyruleno==218); - case 219: /* column_name ::= NK_ID */ yytestcase(yyruleno==219); - case 220: /* function_name ::= NK_ID */ yytestcase(yyruleno==220); - case 221: /* table_alias ::= NK_ID */ yytestcase(yyruleno==221); - case 222: /* column_alias ::= NK_ID */ yytestcase(yyruleno==222); - case 223: /* user_name ::= NK_ID */ yytestcase(yyruleno==223); - case 224: /* index_name ::= NK_ID */ yytestcase(yyruleno==224); - case 225: /* topic_name ::= NK_ID */ yytestcase(yyruleno==225); -{ yylhsminor.yy95 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy95 = yylhsminor.yy95; + case 248: /* db_name ::= NK_ID */ yytestcase(yyruleno==248); + case 249: /* table_name ::= NK_ID */ yytestcase(yyruleno==249); + case 250: /* column_name ::= NK_ID */ yytestcase(yyruleno==250); + case 251: /* function_name ::= NK_ID */ yytestcase(yyruleno==251); + case 252: /* table_alias ::= NK_ID */ yytestcase(yyruleno==252); + case 253: /* column_alias ::= NK_ID */ yytestcase(yyruleno==253); + case 254: /* user_name ::= NK_ID */ yytestcase(yyruleno==254); + case 255: /* index_name ::= NK_ID */ yytestcase(yyruleno==255); + case 256: /* topic_name ::= NK_ID */ yytestcase(yyruleno==256); + case 257: /* stream_name ::= NK_ID */ yytestcase(yyruleno==257); +{ yylhsminor.yy129 = yymsp[0].minor.yy0; } + yymsp[0].minor.yy129 = yylhsminor.yy129; break; case 39: /* cmd ::= ALTER LOCAL NK_STRING */ { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } @@ -2494,974 +2621,1063 @@ static YYACTIONTYPE yy_reduce( { pCxt->pRootNode = createDropQnodeStmt(pCxt, &yymsp[0].minor.yy0); } break; case 43: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy151, &yymsp[-1].minor.yy95, yymsp[0].minor.yy46); } +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy185, &yymsp[-1].minor.yy129, yymsp[0].minor.yy104); } break; case 44: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy151, &yymsp[0].minor.yy95); } +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy185, &yymsp[0].minor.yy129); } break; case 45: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy95); } +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy129); } break; case 46: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy95, yymsp[0].minor.yy46); } +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy129, yymsp[0].minor.yy104); } break; case 47: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy151 = true; } +{ yymsp[-2].minor.yy185 = true; } break; case 48: /* not_exists_opt ::= */ case 50: /* exists_opt ::= */ yytestcase(yyruleno==50); - case 189: /* analyze_opt ::= */ yytestcase(yyruleno==189); - case 296: /* set_quantifier_opt ::= */ yytestcase(yyruleno==296); -{ yymsp[1].minor.yy151 = false; } + case 203: /* analyze_opt ::= */ yytestcase(yyruleno==203); + case 211: /* agg_func_opt ::= */ yytestcase(yyruleno==211); + case 328: /* set_quantifier_opt ::= */ yytestcase(yyruleno==328); +{ yymsp[1].minor.yy185 = false; } break; case 49: /* exists_opt ::= IF EXISTS */ -{ yymsp[-1].minor.yy151 = true; } +{ yymsp[-1].minor.yy185 = true; } break; case 51: /* db_options ::= */ -{ yymsp[1].minor.yy46 = createDefaultDatabaseOptions(pCxt); } +{ yymsp[1].minor.yy104 = createDefaultDatabaseOptions(pCxt); } break; case 52: /* db_options ::= db_options BLOCKS NK_INTEGER */ -{ yylhsminor.yy46 = setDatabaseOption(pCxt, yymsp[-2].minor.yy46, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_BLOCKS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; case 53: /* db_options ::= db_options CACHE NK_INTEGER */ -{ yylhsminor.yy46 = setDatabaseOption(pCxt, yymsp[-2].minor.yy46, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_CACHE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; case 54: /* db_options ::= db_options CACHELAST NK_INTEGER */ -{ yylhsminor.yy46 = setDatabaseOption(pCxt, yymsp[-2].minor.yy46, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_CACHELAST, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; case 55: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy46 = setDatabaseOption(pCxt, yymsp[-2].minor.yy46, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_COMP, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; case 56: /* db_options ::= db_options DAYS NK_INTEGER */ -{ yylhsminor.yy46 = setDatabaseOption(pCxt, yymsp[-2].minor.yy46, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; case 57: /* db_options ::= db_options FSYNC NK_INTEGER */ -{ yylhsminor.yy46 = setDatabaseOption(pCxt, yymsp[-2].minor.yy46, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; case 58: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy46 = setDatabaseOption(pCxt, yymsp[-2].minor.yy46, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; case 59: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy46 = setDatabaseOption(pCxt, yymsp[-2].minor.yy46, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 60: /* db_options ::= db_options KEEP NK_INTEGER */ -{ yylhsminor.yy46 = setDatabaseOption(pCxt, yymsp[-2].minor.yy46, DB_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + case 60: /* db_options ::= db_options KEEP integer_list */ +{ yylhsminor.yy104 = setDatabaseKeepOption(pCxt, yymsp[-2].minor.yy104, yymsp[0].minor.yy312); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; case 61: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy46 = setDatabaseOption(pCxt, yymsp[-2].minor.yy46, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; case 62: /* db_options ::= db_options QUORUM NK_INTEGER */ -{ yylhsminor.yy46 = setDatabaseOption(pCxt, yymsp[-2].minor.yy46, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_QUORUM, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; case 63: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy46 = setDatabaseOption(pCxt, yymsp[-2].minor.yy46, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; case 64: /* db_options ::= db_options TTL NK_INTEGER */ -{ yylhsminor.yy46 = setDatabaseOption(pCxt, yymsp[-2].minor.yy46, DB_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; case 65: /* db_options ::= db_options WAL NK_INTEGER */ -{ yylhsminor.yy46 = setDatabaseOption(pCxt, yymsp[-2].minor.yy46, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_WAL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; case 66: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy46 = setDatabaseOption(pCxt, yymsp[-2].minor.yy46, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; case 67: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy46 = setDatabaseOption(pCxt, yymsp[-2].minor.yy46, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; case 68: /* db_options ::= db_options STREAM_MODE NK_INTEGER */ -{ yylhsminor.yy46 = setDatabaseOption(pCxt, yymsp[-2].minor.yy46, DB_OPTION_STREAM_MODE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_STREAM_MODE, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; case 69: /* db_options ::= db_options RETENTIONS NK_STRING */ -{ yylhsminor.yy46 = setDatabaseOption(pCxt, yymsp[-2].minor.yy46, DB_OPTION_RETENTIONS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; +{ yylhsminor.yy104 = setDatabaseOption(pCxt, yymsp[-2].minor.yy104, DB_OPTION_RETENTIONS, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; case 70: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy46 = createDefaultAlterDatabaseOptions(pCxt); yylhsminor.yy46 = setDatabaseOption(pCxt, yylhsminor.yy46, yymsp[0].minor.yy145.type, &yymsp[0].minor.yy145.val); } - yymsp[0].minor.yy46 = yylhsminor.yy46; +{ yylhsminor.yy104 = createDefaultAlterDatabaseOptions(pCxt); yylhsminor.yy104 = setDatabaseAlterOption(pCxt, yylhsminor.yy104, &yymsp[0].minor.yy253); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; case 71: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy46 = setDatabaseOption(pCxt, yymsp[-1].minor.yy46, yymsp[0].minor.yy145.type, &yymsp[0].minor.yy145.val); } - yymsp[-1].minor.yy46 = yylhsminor.yy46; +{ yylhsminor.yy104 = setDatabaseAlterOption(pCxt, yymsp[-1].minor.yy104, &yymsp[0].minor.yy253); } + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; case 72: /* alter_db_option ::= BLOCKS NK_INTEGER */ -{ yymsp[-1].minor.yy145.type = DB_OPTION_BLOCKS; yymsp[-1].minor.yy145.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy253.type = DB_OPTION_BLOCKS; yymsp[-1].minor.yy253.val = yymsp[0].minor.yy0; } break; case 73: /* alter_db_option ::= FSYNC NK_INTEGER */ -{ yymsp[-1].minor.yy145.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy145.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy253.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy253.val = yymsp[0].minor.yy0; } break; - case 74: /* alter_db_option ::= KEEP NK_INTEGER */ -{ yymsp[-1].minor.yy145.type = DB_OPTION_KEEP; yymsp[-1].minor.yy145.val = yymsp[0].minor.yy0; } + case 74: /* alter_db_option ::= KEEP integer_list */ +{ yymsp[-1].minor.yy253.type = DB_OPTION_KEEP; yymsp[-1].minor.yy253.pKeep = yymsp[0].minor.yy312; } break; case 75: /* alter_db_option ::= WAL NK_INTEGER */ -{ yymsp[-1].minor.yy145.type = DB_OPTION_WAL; yymsp[-1].minor.yy145.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy253.type = DB_OPTION_WAL; yymsp[-1].minor.yy253.val = yymsp[0].minor.yy0; } break; case 76: /* alter_db_option ::= QUORUM NK_INTEGER */ -{ yymsp[-1].minor.yy145.type = DB_OPTION_QUORUM; yymsp[-1].minor.yy145.val = yymsp[0].minor.yy0; } +{ yymsp[-1].minor.yy253.type = DB_OPTION_QUORUM; yymsp[-1].minor.yy253.val = yymsp[0].minor.yy0; } break; case 77: /* alter_db_option ::= CACHELAST NK_INTEGER */ -{ yymsp[-1].minor.yy145.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy145.val = yymsp[0].minor.yy0; } - break; - case 78: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - case 80: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==80); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy151, yymsp[-5].minor.yy46, yymsp[-3].minor.yy194, yymsp[-1].minor.yy194, yymsp[0].minor.yy46); } - break; - case 79: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy194); } - break; - case 81: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy194); } - break; - case 82: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy151, yymsp[0].minor.yy46); } - break; - case 83: /* cmd ::= ALTER TABLE alter_table_clause */ - case 84: /* cmd ::= ALTER STABLE alter_table_clause */ yytestcase(yyruleno==84); - case 194: /* cmd ::= query_expression */ yytestcase(yyruleno==194); -{ pCxt->pRootNode = yymsp[0].minor.yy46; } - break; - case 85: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy46 = createAlterTableOption(pCxt, yymsp[-1].minor.yy46, yymsp[0].minor.yy46); } - yymsp[-1].minor.yy46 = yylhsminor.yy46; - break; - case 86: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy46 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy46, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy95, yymsp[0].minor.yy400); } - yymsp[-4].minor.yy46 = yylhsminor.yy46; - break; - case 87: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy46 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy46, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy95); } - yymsp[-3].minor.yy46 = yylhsminor.yy46; - break; - case 88: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy46 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy46, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy95, yymsp[0].minor.yy400); } - yymsp[-4].minor.yy46 = yylhsminor.yy46; - break; - case 89: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy46 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy46, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy95, &yymsp[0].minor.yy95); } - yymsp[-4].minor.yy46 = yylhsminor.yy46; - break; - case 90: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy46 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy46, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy95, yymsp[0].minor.yy400); } - yymsp[-4].minor.yy46 = yylhsminor.yy46; - break; - case 91: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy46 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy46, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy95); } - yymsp[-3].minor.yy46 = yylhsminor.yy46; - break; - case 92: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy46 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy46, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy95, yymsp[0].minor.yy400); } - yymsp[-4].minor.yy46 = yylhsminor.yy46; - break; - case 93: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy46 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy46, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy95, &yymsp[0].minor.yy95); } - yymsp[-4].minor.yy46 = yylhsminor.yy46; - break; - case 94: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ -{ yylhsminor.yy46 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy46, &yymsp[-2].minor.yy95, yymsp[0].minor.yy46); } - yymsp[-5].minor.yy46 = yylhsminor.yy46; - break; - case 95: /* multi_create_clause ::= create_subtable_clause */ - case 98: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==98); - case 105: /* column_def_list ::= column_def */ yytestcase(yyruleno==105); - case 148: /* col_name_list ::= col_name */ yytestcase(yyruleno==148); - case 170: /* func_name_list ::= func_name */ yytestcase(yyruleno==170); - case 179: /* func_list ::= func */ yytestcase(yyruleno==179); - case 215: /* literal_list ::= signed_literal */ yytestcase(yyruleno==215); - case 301: /* select_sublist ::= select_item */ yytestcase(yyruleno==301); - case 348: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==348); -{ yylhsminor.yy194 = createNodeList(pCxt, yymsp[0].minor.yy46); } - yymsp[0].minor.yy194 = yylhsminor.yy194; +{ yymsp[-1].minor.yy253.type = DB_OPTION_CACHELAST; yymsp[-1].minor.yy253.val = yymsp[0].minor.yy0; } + break; + case 78: /* alter_db_option ::= REPLICA NK_INTEGER */ +{ yymsp[-1].minor.yy253.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy253.val = yymsp[0].minor.yy0; } + break; + case 79: /* integer_list ::= NK_INTEGER */ +{ yylhsminor.yy312 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy312 = yylhsminor.yy312; + break; + case 80: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ + case 223: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==223); +{ yylhsminor.yy312 = addNodeToList(pCxt, yymsp[-2].minor.yy312, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[-2].minor.yy312 = yylhsminor.yy312; + break; + case 81: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + case 83: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==83); +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy185, yymsp[-5].minor.yy104, yymsp[-3].minor.yy312, yymsp[-1].minor.yy312, yymsp[0].minor.yy104); } + break; + case 82: /* cmd ::= CREATE TABLE multi_create_clause */ +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy312); } + break; + case 84: /* cmd ::= DROP TABLE multi_drop_clause */ +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy312); } + break; + case 85: /* cmd ::= DROP STABLE exists_opt full_table_name */ +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy185, yymsp[0].minor.yy104); } + break; + case 86: /* cmd ::= ALTER TABLE alter_table_clause */ + case 87: /* cmd ::= ALTER STABLE alter_table_clause */ yytestcase(yyruleno==87); + case 225: /* cmd ::= query_expression */ yytestcase(yyruleno==225); +{ pCxt->pRootNode = yymsp[0].minor.yy104; } + break; + case 88: /* alter_table_clause ::= full_table_name alter_table_options */ +{ yylhsminor.yy104 = createAlterTableOption(pCxt, yymsp[-1].minor.yy104, yymsp[0].minor.yy104); } + yymsp[-1].minor.yy104 = yylhsminor.yy104; + break; + case 89: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ +{ yylhsminor.yy104 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy104, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy129, yymsp[0].minor.yy336); } + yymsp[-4].minor.yy104 = yylhsminor.yy104; + break; + case 90: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ +{ yylhsminor.yy104 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy104, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy129); } + yymsp[-3].minor.yy104 = yylhsminor.yy104; + break; + case 91: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ +{ yylhsminor.yy104 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy104, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy129, yymsp[0].minor.yy336); } + yymsp[-4].minor.yy104 = yylhsminor.yy104; + break; + case 92: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ +{ yylhsminor.yy104 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy104, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy129, &yymsp[0].minor.yy129); } + yymsp[-4].minor.yy104 = yylhsminor.yy104; + break; + case 93: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ +{ yylhsminor.yy104 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy104, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy129, yymsp[0].minor.yy336); } + yymsp[-4].minor.yy104 = yylhsminor.yy104; + break; + case 94: /* alter_table_clause ::= full_table_name DROP TAG column_name */ +{ yylhsminor.yy104 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy104, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy129); } + yymsp[-3].minor.yy104 = yylhsminor.yy104; + break; + case 95: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ +{ yylhsminor.yy104 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy104, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy129, yymsp[0].minor.yy336); } + yymsp[-4].minor.yy104 = yylhsminor.yy104; + break; + case 96: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ +{ yylhsminor.yy104 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy104, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy129, &yymsp[0].minor.yy129); } + yymsp[-4].minor.yy104 = yylhsminor.yy104; + break; + case 97: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ literal */ +{ yylhsminor.yy104 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy104, &yymsp[-2].minor.yy129, yymsp[0].minor.yy104); } + yymsp[-5].minor.yy104 = yylhsminor.yy104; + break; + case 98: /* multi_create_clause ::= create_subtable_clause */ + case 101: /* multi_drop_clause ::= drop_table_clause */ yytestcase(yyruleno==101); + case 108: /* column_def_list ::= column_def */ yytestcase(yyruleno==108); + case 151: /* col_name_list ::= col_name */ yytestcase(yyruleno==151); + case 184: /* func_name_list ::= func_name */ yytestcase(yyruleno==184); + case 193: /* func_list ::= func */ yytestcase(yyruleno==193); + case 246: /* literal_list ::= signed_literal */ yytestcase(yyruleno==246); + case 333: /* select_sublist ::= select_item */ yytestcase(yyruleno==333); + case 380: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==380); +{ yylhsminor.yy312 = createNodeList(pCxt, yymsp[0].minor.yy104); } + yymsp[0].minor.yy312 = yylhsminor.yy312; break; - case 96: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 99: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==99); -{ yylhsminor.yy194 = addNodeToList(pCxt, yymsp[-1].minor.yy194, yymsp[0].minor.yy46); } - yymsp[-1].minor.yy194 = yylhsminor.yy194; + case 99: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ + case 102: /* multi_drop_clause ::= multi_drop_clause drop_table_clause */ yytestcase(yyruleno==102); +{ yylhsminor.yy312 = addNodeToList(pCxt, yymsp[-1].minor.yy312, yymsp[0].minor.yy104); } + yymsp[-1].minor.yy312 = yylhsminor.yy312; break; - case 97: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ -{ yylhsminor.yy46 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy151, yymsp[-7].minor.yy46, yymsp[-5].minor.yy46, yymsp[-4].minor.yy194, yymsp[-1].minor.yy194); } - yymsp[-8].minor.yy46 = yylhsminor.yy46; + case 100: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_tags_opt TAGS NK_LP literal_list NK_RP */ +{ yylhsminor.yy104 = createCreateSubTableClause(pCxt, yymsp[-8].minor.yy185, yymsp[-7].minor.yy104, yymsp[-5].minor.yy104, yymsp[-4].minor.yy312, yymsp[-1].minor.yy312); } + yymsp[-8].minor.yy104 = yylhsminor.yy104; break; - case 100: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy46 = createDropTableClause(pCxt, yymsp[-1].minor.yy151, yymsp[0].minor.yy46); } - yymsp[-1].minor.yy46 = yylhsminor.yy46; + case 103: /* drop_table_clause ::= exists_opt full_table_name */ +{ yylhsminor.yy104 = createDropTableClause(pCxt, yymsp[-1].minor.yy185, yymsp[0].minor.yy104); } + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 101: /* specific_tags_opt ::= */ - case 132: /* tags_def_opt ::= */ yytestcase(yyruleno==132); - case 309: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==309); - case 326: /* group_by_clause_opt ::= */ yytestcase(yyruleno==326); - case 336: /* order_by_clause_opt ::= */ yytestcase(yyruleno==336); -{ yymsp[1].minor.yy194 = NULL; } + case 104: /* specific_tags_opt ::= */ + case 135: /* tags_def_opt ::= */ yytestcase(yyruleno==135); + case 341: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==341); + case 358: /* group_by_clause_opt ::= */ yytestcase(yyruleno==358); + case 368: /* order_by_clause_opt ::= */ yytestcase(yyruleno==368); +{ yymsp[1].minor.yy312 = NULL; } break; - case 102: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ -{ yymsp[-2].minor.yy194 = yymsp[-1].minor.yy194; } + case 105: /* specific_tags_opt ::= NK_LP col_name_list NK_RP */ +{ yymsp[-2].minor.yy312 = yymsp[-1].minor.yy312; } break; - case 103: /* full_table_name ::= table_name */ -{ yylhsminor.yy46 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy95, NULL); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 106: /* full_table_name ::= table_name */ +{ yylhsminor.yy104 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy129, NULL); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 104: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy46 = createRealTableNode(pCxt, &yymsp[-2].minor.yy95, &yymsp[0].minor.yy95, NULL); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + case 107: /* full_table_name ::= db_name NK_DOT table_name */ +{ yylhsminor.yy104 = createRealTableNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129, NULL); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 106: /* column_def_list ::= column_def_list NK_COMMA column_def */ - case 149: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==149); - case 171: /* func_name_list ::= func_name_list NK_COMMA col_name */ yytestcase(yyruleno==171); - case 180: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==180); - case 216: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==216); - case 302: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==302); - case 349: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==349); -{ yylhsminor.yy194 = addNodeToList(pCxt, yymsp[-2].minor.yy194, yymsp[0].minor.yy46); } - yymsp[-2].minor.yy194 = yylhsminor.yy194; + case 109: /* column_def_list ::= column_def_list NK_COMMA column_def */ + case 152: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==152); + case 185: /* func_name_list ::= func_name_list NK_COMMA col_name */ yytestcase(yyruleno==185); + case 194: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==194); + case 247: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==247); + case 334: /* select_sublist ::= select_sublist NK_COMMA select_item */ yytestcase(yyruleno==334); + case 381: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==381); +{ yylhsminor.yy312 = addNodeToList(pCxt, yymsp[-2].minor.yy312, yymsp[0].minor.yy104); } + yymsp[-2].minor.yy312 = yylhsminor.yy312; break; - case 107: /* column_def ::= column_name type_name */ -{ yylhsminor.yy46 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy95, yymsp[0].minor.yy400, NULL); } - yymsp[-1].minor.yy46 = yylhsminor.yy46; + case 110: /* column_def ::= column_name type_name */ +{ yylhsminor.yy104 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy129, yymsp[0].minor.yy336, NULL); } + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 108: /* column_def ::= column_name type_name COMMENT NK_STRING */ -{ yylhsminor.yy46 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy95, yymsp[-2].minor.yy400, &yymsp[0].minor.yy0); } - yymsp[-3].minor.yy46 = yylhsminor.yy46; + case 111: /* column_def ::= column_name type_name COMMENT NK_STRING */ +{ yylhsminor.yy104 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-2].minor.yy336, &yymsp[0].minor.yy0); } + yymsp[-3].minor.yy104 = yylhsminor.yy104; break; - case 109: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_BOOL); } + case 112: /* type_name ::= BOOL */ +{ yymsp[0].minor.yy336 = createDataType(TSDB_DATA_TYPE_BOOL); } break; - case 110: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_TINYINT); } + case 113: /* type_name ::= TINYINT */ +{ yymsp[0].minor.yy336 = createDataType(TSDB_DATA_TYPE_TINYINT); } break; - case 111: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_SMALLINT); } + case 114: /* type_name ::= SMALLINT */ +{ yymsp[0].minor.yy336 = createDataType(TSDB_DATA_TYPE_SMALLINT); } break; - case 112: /* type_name ::= INT */ - case 113: /* type_name ::= INTEGER */ yytestcase(yyruleno==113); -{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_INT); } + case 115: /* type_name ::= INT */ + case 116: /* type_name ::= INTEGER */ yytestcase(yyruleno==116); +{ yymsp[0].minor.yy336 = createDataType(TSDB_DATA_TYPE_INT); } break; - case 114: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_BIGINT); } + case 117: /* type_name ::= BIGINT */ +{ yymsp[0].minor.yy336 = createDataType(TSDB_DATA_TYPE_BIGINT); } break; - case 115: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_FLOAT); } + case 118: /* type_name ::= FLOAT */ +{ yymsp[0].minor.yy336 = createDataType(TSDB_DATA_TYPE_FLOAT); } break; - case 116: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_DOUBLE); } + case 119: /* type_name ::= DOUBLE */ +{ yymsp[0].minor.yy336 = createDataType(TSDB_DATA_TYPE_DOUBLE); } break; - case 117: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy400 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } + case 120: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy336 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } break; - case 118: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } + case 121: /* type_name ::= TIMESTAMP */ +{ yymsp[0].minor.yy336 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } break; - case 119: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy400 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } + case 122: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy336 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } break; - case 120: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy400 = createDataType(TSDB_DATA_TYPE_UTINYINT); } + case 123: /* type_name ::= TINYINT UNSIGNED */ +{ yymsp[-1].minor.yy336 = createDataType(TSDB_DATA_TYPE_UTINYINT); } break; - case 121: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy400 = createDataType(TSDB_DATA_TYPE_USMALLINT); } + case 124: /* type_name ::= SMALLINT UNSIGNED */ +{ yymsp[-1].minor.yy336 = createDataType(TSDB_DATA_TYPE_USMALLINT); } break; - case 122: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy400 = createDataType(TSDB_DATA_TYPE_UINT); } + case 125: /* type_name ::= INT UNSIGNED */ +{ yymsp[-1].minor.yy336 = createDataType(TSDB_DATA_TYPE_UINT); } break; - case 123: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy400 = createDataType(TSDB_DATA_TYPE_UBIGINT); } + case 126: /* type_name ::= BIGINT UNSIGNED */ +{ yymsp[-1].minor.yy336 = createDataType(TSDB_DATA_TYPE_UBIGINT); } break; - case 124: /* type_name ::= JSON */ -{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_JSON); } + case 127: /* type_name ::= JSON */ +{ yymsp[0].minor.yy336 = createDataType(TSDB_DATA_TYPE_JSON); } break; - case 125: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy400 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } + case 128: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy336 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } break; - case 126: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } + case 129: /* type_name ::= MEDIUMBLOB */ +{ yymsp[0].minor.yy336 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } break; - case 127: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_BLOB); } + case 130: /* type_name ::= BLOB */ +{ yymsp[0].minor.yy336 = createDataType(TSDB_DATA_TYPE_BLOB); } break; - case 128: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy400 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } + case 131: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy336 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } break; - case 129: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy400 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 132: /* type_name ::= DECIMAL */ +{ yymsp[0].minor.yy336 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 130: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy400 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 133: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ +{ yymsp[-3].minor.yy336 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 131: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy400 = createDataType(TSDB_DATA_TYPE_DECIMAL); } + case 134: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +{ yymsp[-5].minor.yy336 = createDataType(TSDB_DATA_TYPE_DECIMAL); } break; - case 133: /* tags_def_opt ::= tags_def */ - case 300: /* select_list ::= select_sublist */ yytestcase(yyruleno==300); -{ yylhsminor.yy194 = yymsp[0].minor.yy194; } - yymsp[0].minor.yy194 = yylhsminor.yy194; + case 136: /* tags_def_opt ::= tags_def */ + case 332: /* select_list ::= select_sublist */ yytestcase(yyruleno==332); +{ yylhsminor.yy312 = yymsp[0].minor.yy312; } + yymsp[0].minor.yy312 = yylhsminor.yy312; break; - case 134: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ -{ yymsp[-3].minor.yy194 = yymsp[-1].minor.yy194; } + case 137: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ +{ yymsp[-3].minor.yy312 = yymsp[-1].minor.yy312; } break; - case 135: /* table_options ::= */ -{ yymsp[1].minor.yy46 = createDefaultTableOptions(pCxt); } + case 138: /* table_options ::= */ +{ yymsp[1].minor.yy104 = createDefaultTableOptions(pCxt); } break; - case 136: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy46 = setTableOption(pCxt, yymsp[-2].minor.yy46, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + case 139: /* table_options ::= table_options COMMENT NK_STRING */ +{ yylhsminor.yy104 = setTableOption(pCxt, yymsp[-2].minor.yy104, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 137: /* table_options ::= table_options KEEP NK_INTEGER */ -{ yylhsminor.yy46 = setTableOption(pCxt, yymsp[-2].minor.yy46, TABLE_OPTION_KEEP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + case 140: /* table_options ::= table_options KEEP integer_list */ +{ yylhsminor.yy104 = setTableKeepOption(pCxt, yymsp[-2].minor.yy104, yymsp[0].minor.yy312); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 138: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy46 = setTableOption(pCxt, yymsp[-2].minor.yy46, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + case 141: /* table_options ::= table_options TTL NK_INTEGER */ +{ yylhsminor.yy104 = setTableOption(pCxt, yymsp[-2].minor.yy104, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 139: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy46 = setTableSmaOption(pCxt, yymsp[-4].minor.yy46, yymsp[-1].minor.yy194); } - yymsp[-4].minor.yy46 = yylhsminor.yy46; + case 142: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ +{ yylhsminor.yy104 = setTableSmaOption(pCxt, yymsp[-4].minor.yy104, yymsp[-1].minor.yy312); } + yymsp[-4].minor.yy104 = yylhsminor.yy104; break; - case 140: /* table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ -{ yylhsminor.yy46 = setTableRollupOption(pCxt, yymsp[-4].minor.yy46, yymsp[-1].minor.yy194); } - yymsp[-4].minor.yy46 = yylhsminor.yy46; + case 143: /* table_options ::= table_options ROLLUP NK_LP func_name_list NK_RP */ +{ yylhsminor.yy104 = setTableRollupOption(pCxt, yymsp[-4].minor.yy104, yymsp[-1].minor.yy312); } + yymsp[-4].minor.yy104 = yylhsminor.yy104; break; - case 141: /* table_options ::= table_options FILE_FACTOR NK_FLOAT */ -{ yylhsminor.yy46 = setTableOption(pCxt, yymsp[-2].minor.yy46, TABLE_OPTION_FILE_FACTOR, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + case 144: /* table_options ::= table_options FILE_FACTOR NK_FLOAT */ +{ yylhsminor.yy104 = setTableOption(pCxt, yymsp[-2].minor.yy104, TABLE_OPTION_FILE_FACTOR, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 142: /* table_options ::= table_options DELAY NK_INTEGER */ -{ yylhsminor.yy46 = setTableOption(pCxt, yymsp[-2].minor.yy46, TABLE_OPTION_DELAY, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + case 145: /* table_options ::= table_options DELAY NK_INTEGER */ +{ yylhsminor.yy104 = setTableOption(pCxt, yymsp[-2].minor.yy104, TABLE_OPTION_DELAY, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 143: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy46 = createDefaultAlterTableOptions(pCxt); yylhsminor.yy46 = setTableOption(pCxt, yylhsminor.yy46, yymsp[0].minor.yy145.type, &yymsp[0].minor.yy145.val); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 146: /* alter_table_options ::= alter_table_option */ +{ yylhsminor.yy104 = createDefaultAlterTableOptions(pCxt); yylhsminor.yy104 = setTableAlterOption(pCxt, yylhsminor.yy104, &yymsp[0].minor.yy253); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 144: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy46 = setTableOption(pCxt, yymsp[-1].minor.yy46, yymsp[0].minor.yy145.type, &yymsp[0].minor.yy145.val); } - yymsp[-1].minor.yy46 = yylhsminor.yy46; + case 147: /* alter_table_options ::= alter_table_options alter_table_option */ +{ yylhsminor.yy104 = setTableAlterOption(pCxt, yymsp[-1].minor.yy104, &yymsp[0].minor.yy253); } + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 145: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy145.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy145.val = yymsp[0].minor.yy0; } + case 148: /* alter_table_option ::= COMMENT NK_STRING */ +{ yymsp[-1].minor.yy253.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy253.val = yymsp[0].minor.yy0; } break; - case 146: /* alter_table_option ::= KEEP NK_INTEGER */ -{ yymsp[-1].minor.yy145.type = TABLE_OPTION_KEEP; yymsp[-1].minor.yy145.val = yymsp[0].minor.yy0; } + case 149: /* alter_table_option ::= KEEP integer_list */ +{ yymsp[-1].minor.yy253.type = TABLE_OPTION_KEEP; yymsp[-1].minor.yy253.pKeep = yymsp[0].minor.yy312; } break; - case 147: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy145.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy145.val = yymsp[0].minor.yy0; } + case 150: /* alter_table_option ::= TTL NK_INTEGER */ +{ yymsp[-1].minor.yy253.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy253.val = yymsp[0].minor.yy0; } break; - case 150: /* col_name ::= column_name */ -{ yylhsminor.yy46 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy95); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 153: /* col_name ::= column_name */ +{ yylhsminor.yy104 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy129); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 151: /* cmd ::= SHOW DNODES */ + case 154: /* cmd ::= SHOW DNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT, NULL, NULL); } break; - case 152: /* cmd ::= SHOW USERS */ + case 155: /* cmd ::= SHOW USERS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT, NULL, NULL); } break; - case 153: /* cmd ::= SHOW DATABASES */ + case 156: /* cmd ::= SHOW DATABASES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT, NULL, NULL); } break; - case 154: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy46, yymsp[0].minor.yy46); } + case 157: /* cmd ::= SHOW db_name_cond_opt TABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TABLES_STMT, yymsp[-2].minor.yy104, yymsp[0].minor.yy104); } break; - case 155: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy46, yymsp[0].minor.yy46); } + case 158: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy104, yymsp[0].minor.yy104); } break; - case 156: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy46, NULL); } + case 159: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy104, NULL); } break; - case 157: /* cmd ::= SHOW MNODES */ + case 160: /* cmd ::= SHOW MNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT, NULL, NULL); } break; - case 158: /* cmd ::= SHOW MODULES */ + case 161: /* cmd ::= SHOW MODULES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MODULES_STMT, NULL, NULL); } break; - case 159: /* cmd ::= SHOW QNODES */ + case 162: /* cmd ::= SHOW QNODES */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT, NULL, NULL); } break; - case 160: /* cmd ::= SHOW FUNCTIONS */ + case 163: /* cmd ::= SHOW FUNCTIONS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT, NULL, NULL); } break; - case 161: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[-1].minor.yy46, yymsp[0].minor.yy46); } + case 164: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[-1].minor.yy104, yymsp[0].minor.yy104); } break; - case 162: /* cmd ::= SHOW STREAMS */ + case 165: /* cmd ::= SHOW STREAMS */ { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT, NULL, NULL); } break; - case 163: /* db_name_cond_opt ::= */ - case 168: /* from_db_opt ::= */ yytestcase(yyruleno==168); -{ yymsp[1].minor.yy46 = createDefaultDatabaseCondValue(pCxt); } + case 166: /* cmd ::= SHOW ACCOUNTS */ +{ pCxt->valid = false; generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } break; - case 164: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy46 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy95); } - yymsp[-1].minor.yy46 = yylhsminor.yy46; + case 167: /* cmd ::= SHOW APPS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT, NULL, NULL); } break; - case 165: /* like_pattern_opt ::= */ - case 176: /* index_options ::= */ yytestcase(yyruleno==176); - case 307: /* where_clause_opt ::= */ yytestcase(yyruleno==307); - case 311: /* twindow_clause_opt ::= */ yytestcase(yyruleno==311); - case 316: /* sliding_opt ::= */ yytestcase(yyruleno==316); - case 318: /* fill_opt ::= */ yytestcase(yyruleno==318); - case 330: /* having_clause_opt ::= */ yytestcase(yyruleno==330); - case 338: /* slimit_clause_opt ::= */ yytestcase(yyruleno==338); - case 342: /* limit_clause_opt ::= */ yytestcase(yyruleno==342); -{ yymsp[1].minor.yy46 = NULL; } + case 168: /* cmd ::= SHOW CONNECTIONS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT, NULL, NULL); } break; - case 166: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy46 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + case 169: /* cmd ::= SHOW LICENCE */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCE_STMT, NULL, NULL); } break; - case 167: /* table_name_cond ::= table_name */ -{ yylhsminor.yy46 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy95); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 170: /* cmd ::= SHOW CREATE DATABASE db_name */ +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy129); } break; - case 169: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy46 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy95); } + case 171: /* cmd ::= SHOW CREATE TABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy104); } break; - case 172: /* func_name ::= function_name */ -{ yylhsminor.yy46 = createFunctionNode(pCxt, &yymsp[0].minor.yy95, NULL); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 172: /* cmd ::= SHOW CREATE STABLE full_table_name */ +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy104); } break; - case 173: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy151, &yymsp[-3].minor.yy95, &yymsp[-1].minor.yy95, NULL, yymsp[0].minor.yy46); } + case 173: /* cmd ::= SHOW QUERIES */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT, NULL, NULL); } break; - case 174: /* cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, yymsp[-6].minor.yy151, &yymsp[-5].minor.yy95, &yymsp[-3].minor.yy95, yymsp[-1].minor.yy194, NULL); } + case 174: /* cmd ::= SHOW SCORES */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT, NULL, NULL); } break; - case 175: /* cmd ::= DROP INDEX exists_opt index_name ON table_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-3].minor.yy151, &yymsp[-2].minor.yy95, &yymsp[0].minor.yy95); } + case 175: /* cmd ::= SHOW TOPICS */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT, NULL, NULL); } break; - case 177: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ -{ yymsp[-8].minor.yy46 = createIndexOption(pCxt, yymsp[-6].minor.yy194, releaseRawExprNode(pCxt, yymsp[-2].minor.yy46), NULL, yymsp[0].minor.yy46); } + case 176: /* cmd ::= SHOW VARIABLES */ +{ pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLE_STMT, NULL, NULL); } break; - case 178: /* 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.yy46 = createIndexOption(pCxt, yymsp[-8].minor.yy194, releaseRawExprNode(pCxt, yymsp[-4].minor.yy46), releaseRawExprNode(pCxt, yymsp[-2].minor.yy46), yymsp[0].minor.yy46); } + case 177: /* db_name_cond_opt ::= */ + case 182: /* from_db_opt ::= */ yytestcase(yyruleno==182); +{ yymsp[1].minor.yy104 = createDefaultDatabaseCondValue(pCxt); } break; - case 181: /* func ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy46 = createFunctionNode(pCxt, &yymsp[-3].minor.yy95, yymsp[-1].minor.yy194); } - yymsp[-3].minor.yy46 = yylhsminor.yy46; + case 178: /* db_name_cond_opt ::= db_name NK_DOT */ +{ yylhsminor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy129); } + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 182: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy151, &yymsp[-2].minor.yy95, yymsp[0].minor.yy46, NULL); } + case 179: /* like_pattern_opt ::= */ + case 190: /* index_options ::= */ yytestcase(yyruleno==190); + case 339: /* where_clause_opt ::= */ yytestcase(yyruleno==339); + case 343: /* twindow_clause_opt ::= */ yytestcase(yyruleno==343); + case 348: /* sliding_opt ::= */ yytestcase(yyruleno==348); + case 350: /* fill_opt ::= */ yytestcase(yyruleno==350); + case 362: /* having_clause_opt ::= */ yytestcase(yyruleno==362); + case 370: /* slimit_clause_opt ::= */ yytestcase(yyruleno==370); + case 374: /* limit_clause_opt ::= */ yytestcase(yyruleno==374); +{ yymsp[1].minor.yy104 = NULL; } break; - case 183: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ -{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy151, &yymsp[-2].minor.yy95, NULL, &yymsp[0].minor.yy95); } + case 180: /* like_pattern_opt ::= LIKE NK_STRING */ +{ yymsp[-1].minor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } break; - case 184: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy151, &yymsp[0].minor.yy95); } + case 181: /* table_name_cond ::= table_name */ +{ yylhsminor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy129); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 185: /* cmd ::= DESC full_table_name */ - case 186: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==186); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy46); } + case 183: /* from_db_opt ::= FROM db_name */ +{ yymsp[-1].minor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy129); } break; - case 187: /* cmd ::= RESET QUERY CACHE */ + case 186: /* func_name ::= function_name */ +{ yylhsminor.yy104 = createFunctionNode(pCxt, &yymsp[0].minor.yy129, NULL); } + yymsp[0].minor.yy104 = yylhsminor.yy104; + break; + case 187: /* cmd ::= CREATE SMA INDEX not_exists_opt index_name ON table_name index_options */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy185, &yymsp[-3].minor.yy129, &yymsp[-1].minor.yy129, NULL, yymsp[0].minor.yy104); } + break; + case 188: /* cmd ::= CREATE FULLTEXT INDEX not_exists_opt index_name ON table_name NK_LP col_name_list NK_RP */ +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_FULLTEXT, yymsp[-6].minor.yy185, &yymsp[-5].minor.yy129, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy312, NULL); } + break; + case 189: /* cmd ::= DROP INDEX exists_opt index_name ON table_name */ +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-3].minor.yy185, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129); } + break; + case 191: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt */ +{ yymsp[-8].minor.yy104 = createIndexOption(pCxt, yymsp[-6].minor.yy312, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), NULL, yymsp[0].minor.yy104); } + break; + case 192: /* 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.yy104 = createIndexOption(pCxt, yymsp[-8].minor.yy312, releaseRawExprNode(pCxt, yymsp[-4].minor.yy104), releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), yymsp[0].minor.yy104); } + break; + case 195: /* func ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy104 = createFunctionNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy312); } + yymsp[-3].minor.yy104 = yylhsminor.yy104; + break; + case 196: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_expression */ +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy185, &yymsp[-2].minor.yy129, yymsp[0].minor.yy104, NULL); } + break; + case 197: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS db_name */ +{ pCxt->pRootNode = createCreateTopicStmt(pCxt, yymsp[-3].minor.yy185, &yymsp[-2].minor.yy129, NULL, &yymsp[0].minor.yy129); } + break; + case 198: /* cmd ::= DROP TOPIC exists_opt topic_name */ +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy185, &yymsp[0].minor.yy129); } + break; + case 199: /* cmd ::= DESC full_table_name */ + case 200: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==200); +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy104); } + break; + case 201: /* cmd ::= RESET QUERY CACHE */ { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } break; - case 188: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy151, yymsp[-1].minor.yy46, yymsp[0].minor.yy46); } + case 202: /* cmd ::= EXPLAIN analyze_opt explain_options query_expression */ +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy185, yymsp[-1].minor.yy104, yymsp[0].minor.yy104); } break; - case 190: /* analyze_opt ::= ANALYZE */ - case 297: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==297); -{ yymsp[0].minor.yy151 = true; } + case 204: /* analyze_opt ::= ANALYZE */ + case 212: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==212); + case 329: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==329); +{ yymsp[0].minor.yy185 = true; } break; - case 191: /* explain_options ::= */ -{ yymsp[1].minor.yy46 = createDefaultExplainOptions(pCxt); } + case 205: /* explain_options ::= */ +{ yymsp[1].minor.yy104 = createDefaultExplainOptions(pCxt); } break; - case 192: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy46 = setExplainVerbose(pCxt, yymsp[-2].minor.yy46, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + case 206: /* explain_options ::= explain_options VERBOSE NK_BOOL */ +{ yylhsminor.yy104 = setExplainVerbose(pCxt, yymsp[-2].minor.yy104, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 193: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy46 = setExplainRatio(pCxt, yymsp[-2].minor.yy46, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + case 207: /* explain_options ::= explain_options RATIO NK_FLOAT */ +{ yylhsminor.yy104 = setExplainRatio(pCxt, yymsp[-2].minor.yy104, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 195: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy46 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 208: /* cmd ::= COMPACT VNODES IN NK_LP integer_list NK_RP */ +{ pCxt->pRootNode = createCompactStmt(pCxt, yymsp[-1].minor.yy312); } break; - case 196: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy46 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 209: /* cmd ::= CREATE agg_func_opt FUNCTION function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt */ +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy185, &yymsp[-5].minor.yy129, &yymsp[-3].minor.yy0, yymsp[-1].minor.yy336, yymsp[0].minor.yy196); } break; - case 197: /* literal ::= NK_STRING */ -{ yylhsminor.yy46 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 210: /* cmd ::= DROP FUNCTION function_name */ +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, &yymsp[0].minor.yy129); } break; - case 198: /* literal ::= NK_BOOL */ -{ yylhsminor.yy46 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 213: /* bufsize_opt ::= */ +{ yymsp[1].minor.yy196 = 0; } break; - case 199: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy46 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy46 = yylhsminor.yy46; + case 214: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ +{ yymsp[-1].minor.yy196 = strtol(yymsp[0].minor.yy0.z, NULL, 10); } break; - case 200: /* literal ::= duration_literal */ - case 209: /* signed_literal ::= signed */ yytestcase(yyruleno==209); - case 226: /* expression ::= literal */ yytestcase(yyruleno==226); - case 227: /* expression ::= pseudo_column */ yytestcase(yyruleno==227); - case 228: /* expression ::= column_reference */ yytestcase(yyruleno==228); - case 231: /* expression ::= subquery */ yytestcase(yyruleno==231); - case 270: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==270); - case 274: /* boolean_primary ::= predicate */ yytestcase(yyruleno==274); - case 276: /* common_expression ::= expression */ yytestcase(yyruleno==276); - case 277: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==277); - case 279: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==279); - case 281: /* table_reference ::= table_primary */ yytestcase(yyruleno==281); - case 282: /* table_reference ::= joined_table */ yytestcase(yyruleno==282); - case 286: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==286); - case 333: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==333); - case 335: /* query_primary ::= query_specification */ yytestcase(yyruleno==335); -{ yylhsminor.yy46 = yymsp[0].minor.yy46; } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 215: /* cmd ::= CREATE STREAM stream_name INTO table_name AS query_expression */ +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, &yymsp[-4].minor.yy129, &yymsp[-2].minor.yy129, yymsp[0].minor.yy104); } break; - case 201: /* literal ::= NULL */ -{ yylhsminor.yy46 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL)); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 216: /* cmd ::= DROP STREAM stream_name */ +{ pCxt->pRootNode = createDropStreamStmt(pCxt, &yymsp[0].minor.yy129); } break; - case 202: /* duration_literal ::= NK_VARIABLE */ -{ yylhsminor.yy46 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 217: /* cmd ::= KILL CONNECTION NK_INTEGER */ +{ pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } break; - case 203: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy46 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 218: /* cmd ::= KILL QUERY NK_INTEGER */ +{ pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_QUERY_STMT, &yymsp[0].minor.yy0); } break; - case 204: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy46 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + case 219: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ +{ pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } break; - case 205: /* signed ::= NK_MINUS NK_INTEGER */ + case 220: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy312); } + break; + case 221: /* cmd ::= SPLIT VGROUP NK_INTEGER */ +{ pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } + break; + case 222: /* dnode_list ::= DNODE NK_INTEGER */ +{ yymsp[-1].minor.yy312 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + break; + case 224: /* cmd ::= SYNCDB db_name REPLICA */ +{ pCxt->pRootNode = createSyncdbStmt(pCxt, &yymsp[-1].minor.yy129); } + break; + case 226: /* literal ::= NK_INTEGER */ +{ yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy104 = yylhsminor.yy104; + break; + case 227: /* literal ::= NK_FLOAT */ +{ yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy104 = yylhsminor.yy104; + break; + case 228: /* literal ::= NK_STRING */ +{ yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy104 = yylhsminor.yy104; + break; + case 229: /* literal ::= NK_BOOL */ +{ yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy104 = yylhsminor.yy104; + break; + case 230: /* literal ::= TIMESTAMP NK_STRING */ +{ yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } + yymsp[-1].minor.yy104 = yylhsminor.yy104; + break; + case 231: /* literal ::= duration_literal */ + case 240: /* signed_literal ::= signed */ yytestcase(yyruleno==240); + case 258: /* expression ::= literal */ yytestcase(yyruleno==258); + case 259: /* expression ::= pseudo_column */ yytestcase(yyruleno==259); + case 260: /* expression ::= column_reference */ yytestcase(yyruleno==260); + case 263: /* expression ::= subquery */ yytestcase(yyruleno==263); + case 302: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==302); + case 306: /* boolean_primary ::= predicate */ yytestcase(yyruleno==306); + case 308: /* common_expression ::= expression */ yytestcase(yyruleno==308); + case 309: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==309); + case 311: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==311); + case 313: /* table_reference ::= table_primary */ yytestcase(yyruleno==313); + case 314: /* table_reference ::= joined_table */ yytestcase(yyruleno==314); + case 318: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==318); + case 365: /* query_expression_body ::= query_primary */ yytestcase(yyruleno==365); + case 367: /* query_primary ::= query_specification */ yytestcase(yyruleno==367); +{ yylhsminor.yy104 = yymsp[0].minor.yy104; } + yymsp[0].minor.yy104 = yylhsminor.yy104; + break; + case 232: /* literal ::= NULL */ +{ yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL)); } + yymsp[0].minor.yy104 = yylhsminor.yy104; + break; + case 233: /* duration_literal ::= NK_VARIABLE */ +{ yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } + yymsp[0].minor.yy104 = yylhsminor.yy104; + break; + case 234: /* signed ::= NK_INTEGER */ +{ yylhsminor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy104 = yylhsminor.yy104; + break; + case 235: /* signed ::= NK_PLUS NK_INTEGER */ +{ yymsp[-1].minor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } + break; + case 236: /* signed ::= NK_MINUS NK_INTEGER */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy46 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy46 = yylhsminor.yy46; + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 206: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy46 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 237: /* signed ::= NK_FLOAT */ +{ yylhsminor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 207: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy46 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 238: /* signed ::= NK_PLUS NK_FLOAT */ +{ yymsp[-1].minor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } break; - case 208: /* signed ::= NK_MINUS NK_FLOAT */ + case 239: /* signed ::= NK_MINUS NK_FLOAT */ { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy46 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy46 = yylhsminor.yy46; + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 210: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy46 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 241: /* signed_literal ::= NK_STRING */ +{ yylhsminor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 211: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy46 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 242: /* signed_literal ::= NK_BOOL */ +{ yylhsminor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 212: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy46 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 243: /* signed_literal ::= TIMESTAMP NK_STRING */ +{ yymsp[-1].minor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } break; - case 213: /* signed_literal ::= duration_literal */ - case 347: /* search_condition ::= common_expression */ yytestcase(yyruleno==347); -{ yylhsminor.yy46 = releaseRawExprNode(pCxt, yymsp[0].minor.yy46); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 244: /* signed_literal ::= duration_literal */ + case 379: /* search_condition ::= common_expression */ yytestcase(yyruleno==379); +{ yylhsminor.yy104 = releaseRawExprNode(pCxt, yymsp[0].minor.yy104); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 214: /* signed_literal ::= NULL */ -{ yymsp[0].minor.yy46 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL); } + case 245: /* signed_literal ::= NULL */ +{ yymsp[0].minor.yy104 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, NULL); } break; - case 229: /* expression ::= function_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy46 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy95, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy95, yymsp[-1].minor.yy194)); } - yymsp[-3].minor.yy46 = yylhsminor.yy46; + case 261: /* expression ::= function_name NK_LP expression_list NK_RP */ +{ yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy129, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy129, yymsp[-1].minor.yy312)); } + yymsp[-3].minor.yy104 = yylhsminor.yy104; break; - case 230: /* expression ::= function_name NK_LP NK_STAR NK_RP */ -{ yylhsminor.yy46 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy95, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy95, createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy0)))); } - yymsp[-3].minor.yy46 = yylhsminor.yy46; + case 262: /* expression ::= function_name NK_LP NK_STAR NK_RP */ +{ yylhsminor.yy104 = 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.yy104 = yylhsminor.yy104; break; - case 232: /* expression ::= NK_LP expression NK_RP */ - case 275: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==275); -{ yylhsminor.yy46 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy46)); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + case 264: /* expression ::= NK_LP expression NK_RP */ + case 307: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==307); +{ yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy104)); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 233: /* expression ::= NK_PLUS expression */ + case 265: /* expression ::= NK_PLUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy46); - yylhsminor.yy46 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy46)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy104)); } - yymsp[-1].minor.yy46 = yylhsminor.yy46; + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 234: /* expression ::= NK_MINUS expression */ + case 266: /* expression ::= NK_MINUS expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy46); - yylhsminor.yy46 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy46), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[0].minor.yy104), NULL)); } - yymsp[-1].minor.yy46 = yylhsminor.yy46; + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 235: /* expression ::= expression NK_PLUS expression */ + case 267: /* expression ::= expression NK_PLUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy46); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy46); - yylhsminor.yy46 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy46), releaseRawExprNode(pCxt, yymsp[0].minor.yy46))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 236: /* expression ::= expression NK_MINUS expression */ + case 268: /* expression ::= expression NK_MINUS expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy46); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy46); - yylhsminor.yy46 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy46), releaseRawExprNode(pCxt, yymsp[0].minor.yy46))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 237: /* expression ::= expression NK_STAR expression */ + case 269: /* expression ::= expression NK_STAR expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy46); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy46); - yylhsminor.yy46 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy46), releaseRawExprNode(pCxt, yymsp[0].minor.yy46))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 238: /* expression ::= expression NK_SLASH expression */ + case 270: /* expression ::= expression NK_SLASH expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy46); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy46); - yylhsminor.yy46 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy46), releaseRawExprNode(pCxt, yymsp[0].minor.yy46))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 239: /* expression ::= expression NK_REM expression */ + case 271: /* expression ::= expression NK_REM expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy46); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy46); - yylhsminor.yy46 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy46), releaseRawExprNode(pCxt, yymsp[0].minor.yy46))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MOD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 240: /* expression_list ::= expression */ -{ yylhsminor.yy194 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy46)); } - yymsp[0].minor.yy194 = yylhsminor.yy194; + case 272: /* expression_list ::= expression */ +{ yylhsminor.yy312 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy104)); } + yymsp[0].minor.yy312 = yylhsminor.yy312; break; - case 241: /* expression_list ::= expression_list NK_COMMA expression */ -{ yylhsminor.yy194 = addNodeToList(pCxt, yymsp[-2].minor.yy194, releaseRawExprNode(pCxt, yymsp[0].minor.yy46)); } - yymsp[-2].minor.yy194 = yylhsminor.yy194; + case 273: /* expression_list ::= expression_list NK_COMMA expression */ +{ yylhsminor.yy312 = addNodeToList(pCxt, yymsp[-2].minor.yy312, releaseRawExprNode(pCxt, yymsp[0].minor.yy104)); } + yymsp[-2].minor.yy312 = yylhsminor.yy312; break; - case 242: /* column_reference ::= column_name */ -{ yylhsminor.yy46 = createRawExprNode(pCxt, &yymsp[0].minor.yy95, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy95)); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 274: /* column_reference ::= column_name */ +{ yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy129, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy129)); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 243: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy46 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy95, &yymsp[0].minor.yy95, createColumnNode(pCxt, &yymsp[-2].minor.yy95, &yymsp[0].minor.yy95)); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + case 275: /* column_reference ::= table_name NK_DOT column_name */ +{ yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129, createColumnNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy129)); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 244: /* pseudo_column ::= NK_UNDERLINE ROWTS */ - case 246: /* pseudo_column ::= NK_UNDERLINE QSTARTTS */ yytestcase(yyruleno==246); - case 247: /* pseudo_column ::= NK_UNDERLINE QENDTS */ yytestcase(yyruleno==247); - case 248: /* pseudo_column ::= NK_UNDERLINE WSTARTTS */ yytestcase(yyruleno==248); - case 249: /* pseudo_column ::= NK_UNDERLINE WENDTS */ yytestcase(yyruleno==249); - case 250: /* pseudo_column ::= NK_UNDERLINE WDURATION */ yytestcase(yyruleno==250); + case 276: /* pseudo_column ::= NK_UNDERLINE ROWTS */ + case 278: /* pseudo_column ::= NK_UNDERLINE QSTARTTS */ yytestcase(yyruleno==278); + case 279: /* pseudo_column ::= NK_UNDERLINE QENDTS */ yytestcase(yyruleno==279); + case 280: /* pseudo_column ::= NK_UNDERLINE WSTARTTS */ yytestcase(yyruleno==280); + case 281: /* pseudo_column ::= NK_UNDERLINE WENDTS */ yytestcase(yyruleno==281); + case 282: /* pseudo_column ::= NK_UNDERLINE WDURATION */ yytestcase(yyruleno==282); { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy46 = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL)); + yylhsminor.yy104 = createRawExprNode(pCxt, &t, createFunctionNode(pCxt, &t, NULL)); } - yymsp[-1].minor.yy46 = yylhsminor.yy46; + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 245: /* pseudo_column ::= TBNAME */ -{ yylhsminor.yy46 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + case 277: /* pseudo_column ::= TBNAME */ +{ yylhsminor.yy104 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 251: /* predicate ::= expression compare_op expression */ - case 256: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==256); + case 283: /* predicate ::= expression compare_op expression */ + case 288: /* predicate ::= expression in_op in_predicate_value */ yytestcase(yyruleno==288); { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy46); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy46); - yylhsminor.yy46 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy292, releaseRawExprNode(pCxt, yymsp[-2].minor.yy46), releaseRawExprNode(pCxt, yymsp[0].minor.yy46))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy60, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 252: /* predicate ::= expression BETWEEN expression AND expression */ + case 284: /* predicate ::= expression BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy46); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy46); - yylhsminor.yy46 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy46), releaseRawExprNode(pCxt, yymsp[-2].minor.yy46), releaseRawExprNode(pCxt, yymsp[0].minor.yy46))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy104); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy104), releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } - yymsp[-4].minor.yy46 = yylhsminor.yy46; + yymsp[-4].minor.yy104 = yylhsminor.yy104; break; - case 253: /* predicate ::= expression NOT BETWEEN expression AND expression */ + case 285: /* predicate ::= expression NOT BETWEEN expression AND expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy46); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy46); - yylhsminor.yy46 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy46), releaseRawExprNode(pCxt, yymsp[-5].minor.yy46), releaseRawExprNode(pCxt, yymsp[0].minor.yy46))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy104); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[-5].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } - yymsp[-5].minor.yy46 = yylhsminor.yy46; + yymsp[-5].minor.yy104 = yylhsminor.yy104; break; - case 254: /* predicate ::= expression IS NULL */ + case 286: /* predicate ::= expression IS NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy46); - yylhsminor.yy46 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy46), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), NULL)); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 255: /* predicate ::= expression IS NOT NULL */ + case 287: /* predicate ::= expression IS NOT NULL */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy46); - yylhsminor.yy46 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy46), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy104), NULL)); } - yymsp[-3].minor.yy46 = yylhsminor.yy46; + yymsp[-3].minor.yy104 = yylhsminor.yy104; break; - case 257: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy292 = OP_TYPE_LOWER_THAN; } + case 289: /* compare_op ::= NK_LT */ +{ yymsp[0].minor.yy60 = OP_TYPE_LOWER_THAN; } break; - case 258: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy292 = OP_TYPE_GREATER_THAN; } + case 290: /* compare_op ::= NK_GT */ +{ yymsp[0].minor.yy60 = OP_TYPE_GREATER_THAN; } break; - case 259: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy292 = OP_TYPE_LOWER_EQUAL; } + case 291: /* compare_op ::= NK_LE */ +{ yymsp[0].minor.yy60 = OP_TYPE_LOWER_EQUAL; } break; - case 260: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy292 = OP_TYPE_GREATER_EQUAL; } + case 292: /* compare_op ::= NK_GE */ +{ yymsp[0].minor.yy60 = OP_TYPE_GREATER_EQUAL; } break; - case 261: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy292 = OP_TYPE_NOT_EQUAL; } + case 293: /* compare_op ::= NK_NE */ +{ yymsp[0].minor.yy60 = OP_TYPE_NOT_EQUAL; } break; - case 262: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy292 = OP_TYPE_EQUAL; } + case 294: /* compare_op ::= NK_EQ */ +{ yymsp[0].minor.yy60 = OP_TYPE_EQUAL; } break; - case 263: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy292 = OP_TYPE_LIKE; } + case 295: /* compare_op ::= LIKE */ +{ yymsp[0].minor.yy60 = OP_TYPE_LIKE; } break; - case 264: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy292 = OP_TYPE_NOT_LIKE; } + case 296: /* compare_op ::= NOT LIKE */ +{ yymsp[-1].minor.yy60 = OP_TYPE_NOT_LIKE; } break; - case 265: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy292 = OP_TYPE_MATCH; } + case 297: /* compare_op ::= MATCH */ +{ yymsp[0].minor.yy60 = OP_TYPE_MATCH; } break; - case 266: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy292 = OP_TYPE_NMATCH; } + case 298: /* compare_op ::= NMATCH */ +{ yymsp[0].minor.yy60 = OP_TYPE_NMATCH; } break; - case 267: /* in_op ::= IN */ -{ yymsp[0].minor.yy292 = OP_TYPE_IN; } + case 299: /* in_op ::= IN */ +{ yymsp[0].minor.yy60 = OP_TYPE_IN; } break; - case 268: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy292 = OP_TYPE_NOT_IN; } + case 300: /* in_op ::= NOT IN */ +{ yymsp[-1].minor.yy60 = OP_TYPE_NOT_IN; } break; - case 269: /* in_predicate_value ::= NK_LP expression_list NK_RP */ -{ yylhsminor.yy46 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy194)); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + case 301: /* in_predicate_value ::= NK_LP expression_list NK_RP */ +{ yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy312)); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 271: /* boolean_value_expression ::= NOT boolean_primary */ + case 303: /* boolean_value_expression ::= NOT boolean_primary */ { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy46); - yylhsminor.yy46 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy46), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy104), NULL)); } - yymsp[-1].minor.yy46 = yylhsminor.yy46; + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 272: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 304: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy46); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy46); - yylhsminor.yy46 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy46), releaseRawExprNode(pCxt, yymsp[0].minor.yy46))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 273: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 305: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy46); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy46); - yylhsminor.yy46 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy46), releaseRawExprNode(pCxt, yymsp[0].minor.yy46))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy104); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 278: /* from_clause ::= FROM table_reference_list */ - case 308: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==308); - case 331: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==331); -{ yymsp[-1].minor.yy46 = yymsp[0].minor.yy46; } + case 310: /* from_clause ::= FROM table_reference_list */ + case 340: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==340); + case 363: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==363); +{ yymsp[-1].minor.yy104 = yymsp[0].minor.yy104; } break; - case 280: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy46 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy46, yymsp[0].minor.yy46, NULL); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + case 312: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +{ yylhsminor.yy104 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, yymsp[-2].minor.yy104, yymsp[0].minor.yy104, NULL); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 283: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy46 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy95, &yymsp[0].minor.yy95); } - yymsp[-1].minor.yy46 = yylhsminor.yy46; + case 315: /* table_primary ::= table_name alias_opt */ +{ yylhsminor.yy104 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy129, &yymsp[0].minor.yy129); } + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 284: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy46 = createRealTableNode(pCxt, &yymsp[-3].minor.yy95, &yymsp[-1].minor.yy95, &yymsp[0].minor.yy95); } - yymsp[-3].minor.yy46 = yylhsminor.yy46; + case 316: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +{ yylhsminor.yy104 = createRealTableNode(pCxt, &yymsp[-3].minor.yy129, &yymsp[-1].minor.yy129, &yymsp[0].minor.yy129); } + yymsp[-3].minor.yy104 = yylhsminor.yy104; break; - case 285: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy46 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy46), &yymsp[0].minor.yy95); } - yymsp[-1].minor.yy46 = yylhsminor.yy46; + case 317: /* table_primary ::= subquery alias_opt */ +{ yylhsminor.yy104 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy104), &yymsp[0].minor.yy129); } + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 287: /* alias_opt ::= */ -{ yymsp[1].minor.yy95 = nil_token; } + case 319: /* alias_opt ::= */ +{ yymsp[1].minor.yy129 = nil_token; } break; - case 288: /* alias_opt ::= table_alias */ -{ yylhsminor.yy95 = yymsp[0].minor.yy95; } - yymsp[0].minor.yy95 = yylhsminor.yy95; + case 320: /* alias_opt ::= table_alias */ +{ yylhsminor.yy129 = yymsp[0].minor.yy129; } + yymsp[0].minor.yy129 = yylhsminor.yy129; break; - case 289: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy95 = yymsp[0].minor.yy95; } + case 321: /* alias_opt ::= AS table_alias */ +{ yymsp[-1].minor.yy129 = yymsp[0].minor.yy129; } break; - case 290: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 291: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==291); -{ yymsp[-2].minor.yy46 = yymsp[-1].minor.yy46; } + case 322: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 323: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==323); +{ yymsp[-2].minor.yy104 = yymsp[-1].minor.yy104; } break; - case 292: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ -{ yylhsminor.yy46 = createJoinTableNode(pCxt, yymsp[-4].minor.yy10, yymsp[-5].minor.yy46, yymsp[-2].minor.yy46, yymsp[0].minor.yy46); } - yymsp[-5].minor.yy46 = yylhsminor.yy46; + case 324: /* joined_table ::= table_reference join_type JOIN table_reference ON search_condition */ +{ yylhsminor.yy104 = createJoinTableNode(pCxt, yymsp[-4].minor.yy532, yymsp[-5].minor.yy104, yymsp[-2].minor.yy104, yymsp[0].minor.yy104); } + yymsp[-5].minor.yy104 = yylhsminor.yy104; break; - case 293: /* join_type ::= */ -{ yymsp[1].minor.yy10 = JOIN_TYPE_INNER; } + case 325: /* join_type ::= */ +{ yymsp[1].minor.yy532 = JOIN_TYPE_INNER; } break; - case 294: /* join_type ::= INNER */ -{ yymsp[0].minor.yy10 = JOIN_TYPE_INNER; } + case 326: /* join_type ::= INNER */ +{ yymsp[0].minor.yy532 = JOIN_TYPE_INNER; } break; - case 295: /* 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 327: /* 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.yy46 = createSelectStmt(pCxt, yymsp[-7].minor.yy151, yymsp[-6].minor.yy194, yymsp[-5].minor.yy46); - yymsp[-8].minor.yy46 = addWhereClause(pCxt, yymsp[-8].minor.yy46, yymsp[-4].minor.yy46); - yymsp[-8].minor.yy46 = addPartitionByClause(pCxt, yymsp[-8].minor.yy46, yymsp[-3].minor.yy194); - yymsp[-8].minor.yy46 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy46, yymsp[-2].minor.yy46); - yymsp[-8].minor.yy46 = addGroupByClause(pCxt, yymsp[-8].minor.yy46, yymsp[-1].minor.yy194); - yymsp[-8].minor.yy46 = addHavingClause(pCxt, yymsp[-8].minor.yy46, yymsp[0].minor.yy46); + yymsp[-8].minor.yy104 = createSelectStmt(pCxt, yymsp[-7].minor.yy185, yymsp[-6].minor.yy312, yymsp[-5].minor.yy104); + yymsp[-8].minor.yy104 = addWhereClause(pCxt, yymsp[-8].minor.yy104, yymsp[-4].minor.yy104); + yymsp[-8].minor.yy104 = addPartitionByClause(pCxt, yymsp[-8].minor.yy104, yymsp[-3].minor.yy312); + yymsp[-8].minor.yy104 = addWindowClauseClause(pCxt, yymsp[-8].minor.yy104, yymsp[-2].minor.yy104); + yymsp[-8].minor.yy104 = addGroupByClause(pCxt, yymsp[-8].minor.yy104, yymsp[-1].minor.yy312); + yymsp[-8].minor.yy104 = addHavingClause(pCxt, yymsp[-8].minor.yy104, yymsp[0].minor.yy104); } break; - case 298: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy151 = false; } + case 330: /* set_quantifier_opt ::= ALL */ +{ yymsp[0].minor.yy185 = false; } break; - case 299: /* select_list ::= NK_STAR */ -{ yymsp[0].minor.yy194 = NULL; } + case 331: /* select_list ::= NK_STAR */ +{ yymsp[0].minor.yy312 = NULL; } break; - case 303: /* select_item ::= common_expression */ + case 335: /* select_item ::= common_expression */ { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy46); - yylhsminor.yy46 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy46), &t); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy104); + yylhsminor.yy104 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy104), &t); } - yymsp[0].minor.yy46 = yylhsminor.yy46; + yymsp[0].minor.yy104 = yylhsminor.yy104; break; - case 304: /* select_item ::= common_expression column_alias */ -{ yylhsminor.yy46 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy46), &yymsp[0].minor.yy95); } - yymsp[-1].minor.yy46 = yylhsminor.yy46; + case 336: /* select_item ::= common_expression column_alias */ +{ yylhsminor.yy104 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy104), &yymsp[0].minor.yy129); } + yymsp[-1].minor.yy104 = yylhsminor.yy104; break; - case 305: /* select_item ::= common_expression AS column_alias */ -{ yylhsminor.yy46 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy46), &yymsp[0].minor.yy95); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + case 337: /* select_item ::= common_expression AS column_alias */ +{ yylhsminor.yy104 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), &yymsp[0].minor.yy129); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 306: /* select_item ::= table_name NK_DOT NK_STAR */ -{ yylhsminor.yy46 = createColumnNode(pCxt, &yymsp[-2].minor.yy95, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + case 338: /* select_item ::= table_name NK_DOT NK_STAR */ +{ yylhsminor.yy104 = createColumnNode(pCxt, &yymsp[-2].minor.yy129, &yymsp[0].minor.yy0); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 310: /* partition_by_clause_opt ::= PARTITION BY expression_list */ - case 327: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==327); - case 337: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==337); -{ yymsp[-2].minor.yy194 = yymsp[0].minor.yy194; } + case 342: /* partition_by_clause_opt ::= PARTITION BY expression_list */ + case 359: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==359); + case 369: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==369); +{ yymsp[-2].minor.yy312 = yymsp[0].minor.yy312; } break; - case 312: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ -{ yymsp[-5].minor.yy46 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy46), releaseRawExprNode(pCxt, yymsp[-1].minor.yy46)); } + case 344: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA duration_literal NK_RP */ +{ yymsp[-5].minor.yy104 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy104), releaseRawExprNode(pCxt, yymsp[-1].minor.yy104)); } break; - case 313: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ -{ yymsp[-3].minor.yy46 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy46)); } + case 345: /* twindow_clause_opt ::= STATE_WINDOW NK_LP column_reference NK_RP */ +{ yymsp[-3].minor.yy104 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy104)); } break; - case 314: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy46 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy46), NULL, yymsp[-1].minor.yy46, yymsp[0].minor.yy46); } + case 346: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-5].minor.yy104 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy104), NULL, yymsp[-1].minor.yy104, yymsp[0].minor.yy104); } break; - case 315: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy46 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy46), releaseRawExprNode(pCxt, yymsp[-3].minor.yy46), yymsp[-1].minor.yy46, yymsp[0].minor.yy46); } + case 347: /* twindow_clause_opt ::= INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt fill_opt */ +{ yymsp[-7].minor.yy104 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy104), releaseRawExprNode(pCxt, yymsp[-3].minor.yy104), yymsp[-1].minor.yy104, yymsp[0].minor.yy104); } break; - case 317: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ -{ yymsp[-3].minor.yy46 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy46); } + case 349: /* sliding_opt ::= SLIDING NK_LP duration_literal NK_RP */ +{ yymsp[-3].minor.yy104 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy104); } break; - case 319: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy46 = createFillNode(pCxt, yymsp[-1].minor.yy6, NULL); } + case 351: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +{ yymsp[-3].minor.yy104 = createFillNode(pCxt, yymsp[-1].minor.yy550, NULL); } break; - case 320: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ -{ yymsp[-5].minor.yy46 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy194)); } + case 352: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA literal_list NK_RP */ +{ yymsp[-5].minor.yy104 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy312)); } break; - case 321: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy6 = FILL_MODE_NONE; } + case 353: /* fill_mode ::= NONE */ +{ yymsp[0].minor.yy550 = FILL_MODE_NONE; } break; - case 322: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy6 = FILL_MODE_PREV; } + case 354: /* fill_mode ::= PREV */ +{ yymsp[0].minor.yy550 = FILL_MODE_PREV; } break; - case 323: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy6 = FILL_MODE_NULL; } + case 355: /* fill_mode ::= NULL */ +{ yymsp[0].minor.yy550 = FILL_MODE_NULL; } break; - case 324: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy6 = FILL_MODE_LINEAR; } + case 356: /* fill_mode ::= LINEAR */ +{ yymsp[0].minor.yy550 = FILL_MODE_LINEAR; } break; - case 325: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy6 = FILL_MODE_NEXT; } + case 357: /* fill_mode ::= NEXT */ +{ yymsp[0].minor.yy550 = FILL_MODE_NEXT; } break; - case 328: /* group_by_list ::= expression */ -{ yylhsminor.yy194 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy46))); } - yymsp[0].minor.yy194 = yylhsminor.yy194; + case 360: /* group_by_list ::= expression */ +{ yylhsminor.yy312 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } + yymsp[0].minor.yy312 = yylhsminor.yy312; break; - case 329: /* group_by_list ::= group_by_list NK_COMMA expression */ -{ yylhsminor.yy194 = addNodeToList(pCxt, yymsp[-2].minor.yy194, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy46))); } - yymsp[-2].minor.yy194 = yylhsminor.yy194; + case 361: /* group_by_list ::= group_by_list NK_COMMA expression */ +{ yylhsminor.yy312 = addNodeToList(pCxt, yymsp[-2].minor.yy312, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy104))); } + yymsp[-2].minor.yy312 = yylhsminor.yy312; break; - case 332: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 364: /* query_expression ::= query_expression_body order_by_clause_opt slimit_clause_opt limit_clause_opt */ { - yylhsminor.yy46 = addOrderByClause(pCxt, yymsp[-3].minor.yy46, yymsp[-2].minor.yy194); - yylhsminor.yy46 = addSlimitClause(pCxt, yylhsminor.yy46, yymsp[-1].minor.yy46); - yylhsminor.yy46 = addLimitClause(pCxt, yylhsminor.yy46, yymsp[0].minor.yy46); + yylhsminor.yy104 = addOrderByClause(pCxt, yymsp[-3].minor.yy104, yymsp[-2].minor.yy312); + yylhsminor.yy104 = addSlimitClause(pCxt, yylhsminor.yy104, yymsp[-1].minor.yy104); + yylhsminor.yy104 = addLimitClause(pCxt, yylhsminor.yy104, yymsp[0].minor.yy104); } - yymsp[-3].minor.yy46 = yylhsminor.yy46; + yymsp[-3].minor.yy104 = yylhsminor.yy104; break; - case 334: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ -{ yylhsminor.yy46 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy46, yymsp[0].minor.yy46); } - yymsp[-3].minor.yy46 = yylhsminor.yy46; + case 366: /* query_expression_body ::= query_expression_body UNION ALL query_expression_body */ +{ yylhsminor.yy104 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy104, yymsp[0].minor.yy104); } + yymsp[-3].minor.yy104 = yylhsminor.yy104; break; - case 339: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ - case 343: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==343); -{ yymsp[-1].minor.yy46 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 371: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ + case 375: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==375); +{ yymsp[-1].minor.yy104 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } break; - case 340: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 344: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==344); -{ yymsp[-3].minor.yy46 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 372: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 376: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==376); +{ yymsp[-3].minor.yy104 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } break; - case 341: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 345: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==345); -{ yymsp[-3].minor.yy46 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 373: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 377: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==377); +{ yymsp[-3].minor.yy104 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } break; - case 346: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy46 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy46); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + case 378: /* subquery ::= NK_LP query_expression NK_RP */ +{ yylhsminor.yy104 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy104); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 350: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy46 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy46), yymsp[-1].minor.yy456, yymsp[0].minor.yy273); } - yymsp[-2].minor.yy46 = yylhsminor.yy46; + case 382: /* sort_specification ::= expression ordering_specification_opt null_ordering_opt */ +{ yylhsminor.yy104 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy104), yymsp[-1].minor.yy354, yymsp[0].minor.yy489); } + yymsp[-2].minor.yy104 = yylhsminor.yy104; break; - case 351: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy456 = ORDER_ASC; } + case 383: /* ordering_specification_opt ::= */ +{ yymsp[1].minor.yy354 = ORDER_ASC; } break; - case 352: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy456 = ORDER_ASC; } + case 384: /* ordering_specification_opt ::= ASC */ +{ yymsp[0].minor.yy354 = ORDER_ASC; } break; - case 353: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy456 = ORDER_DESC; } + case 385: /* ordering_specification_opt ::= DESC */ +{ yymsp[0].minor.yy354 = ORDER_DESC; } break; - case 354: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy273 = NULL_ORDER_DEFAULT; } + case 386: /* null_ordering_opt ::= */ +{ yymsp[1].minor.yy489 = NULL_ORDER_DEFAULT; } break; - case 355: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy273 = NULL_ORDER_FIRST; } + case 387: /* null_ordering_opt ::= NULLS FIRST */ +{ yymsp[-1].minor.yy489 = NULL_ORDER_FIRST; } break; - case 356: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy273 = NULL_ORDER_LAST; } + case 388: /* null_ordering_opt ::= NULLS LAST */ +{ yymsp[-1].minor.yy489 = NULL_ORDER_LAST; } break; default: break; diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index 7f6d8826e6..f57f476d51 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -288,7 +288,7 @@ static int32_t createJoinLogicNode(SLogicPlanContext* pCxt, SSelectStmt* pSelect // set the output if (TSDB_CODE_SUCCESS == code) { pJoin->node.pTargets = nodesCloneList(pLeft->pTargets); - if (NULL == pJoin->pOnConditions) { + if (NULL == pJoin->node.pTargets) { code = TSDB_CODE_OUT_OF_MEMORY; } if (TSDB_CODE_SUCCESS == code) { diff --git a/source/libs/qcom/CMakeLists.txt b/source/libs/qcom/CMakeLists.txt index a9bf0f5594..d50047e592 100644 --- a/source/libs/qcom/CMakeLists.txt +++ b/source/libs/qcom/CMakeLists.txt @@ -8,7 +8,7 @@ target_include_directories( target_link_libraries( qcom - PRIVATE os util transport + PRIVATE os util transport nodes ) if(${BUILD_TEST}) diff --git a/source/libs/qcom/inc/queryInt.h b/source/libs/qcom/inc/queryInt.h index 75c1e134cd..f120bf26ce 100644 --- a/source/libs/qcom/inc/queryInt.h +++ b/source/libs/qcom/inc/queryInt.h @@ -21,7 +21,6 @@ extern "C" { #endif - #ifdef __cplusplus } #endif diff --git a/source/libs/scalar/inc/filterInt.h b/source/libs/scalar/inc/filterInt.h index 834a722bd8..3e04e7b30a 100644 --- a/source/libs/scalar/inc/filterInt.h +++ b/source/libs/scalar/inc/filterInt.h @@ -36,8 +36,6 @@ extern "C" { #define FILTER_DUMMY_EMPTY_OPTR 127 -#define MAX_NUM_STR_SIZE 40 - #define FILTER_RM_UNIT_MIN_ROWS 100 enum { diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index d8e97e7e12..429bc6e66f 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -23,7 +23,7 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu colDataSetNull_f(pOutputData->nullbitmap, i); continue; } - out[i] = (in[i] > 0)? in[i] : -in[i]; + out[i] = (in[i] >= 0)? in[i] : -in[i]; } break; } @@ -36,7 +36,7 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu colDataSetNull_f(pOutputData->nullbitmap, i); continue; } - out[i] = (in[i] > 0)? in[i] : -in[i]; + out[i] = (in[i] >= 0)? in[i] : -in[i]; } break; } @@ -49,7 +49,7 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu colDataSetNull_f(pOutputData->nullbitmap, i); continue; } - out[i] = (in[i] > 0)? in[i] : -in[i]; + out[i] = (in[i] >= 0)? in[i] : -in[i]; } break; } @@ -62,7 +62,7 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu colDataSetNull_f(pOutputData->nullbitmap, i); continue; } - out[i] = (in[i] > 0)? in[i] : -in[i]; + out[i] = (in[i] >= 0)? in[i] : -in[i]; } break; } @@ -75,7 +75,7 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu colDataSetNull_f(pOutputData->nullbitmap, i); continue; } - out[i] = (in[i] > 0)? in[i] : -in[i]; + out[i] = (in[i] >= 0)? in[i] : -in[i]; } break; } @@ -88,7 +88,7 @@ int32_t absFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutpu colDataSetNull_f(pOutputData->nullbitmap, i); continue; } - out[i] = (in[i] > 0)? in[i] : -in[i]; + out[i] = (in[i] >= 0)? in[i] : -in[i]; } break; } @@ -407,4 +407,4 @@ int32_t winEndTsFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *p ASSERT(inputNum == 1); colDataAppendInt64(pOutput->columnData, pOutput->numOfRows, (int64_t*) colDataGetData(pInput->columnData, 4)); return TSDB_CODE_SUCCESS; -} \ No newline at end of file +} diff --git a/source/libs/scalar/src/sclvector.c b/source/libs/scalar/src/sclvector.c index f22f9a5c3c..33be65832c 100644 --- a/source/libs/scalar/src/sclvector.c +++ b/source/libs/scalar/src/sclvector.c @@ -720,7 +720,7 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam double lx = getVectorDoubleValueFnLeft(pLeftCol->pData, i); double rx = getVectorDoubleValueFnRight(pRightCol->pData, i); - if (compareDoubleVal(&zero, &rx)) { + if (isnan(lx) || isinf(lx) || isnan(rx) || isinf(rx)) { colDataAppend(pOutputCol, i, NULL, true); continue; } @@ -729,7 +729,7 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam } } else if (pLeft->numOfRows == 1) { double lx = getVectorDoubleValueFnLeft(pLeftCol->pData, 0); - if (colDataIsNull_f(pLeftCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value + if (colDataIsNull_f(pLeftCol->nullbitmap, 0) || isnan(lx) || isinf(lx)) { // Set pLeft->numOfRows NULL value // TODO set numOfRows NULL value } else { for (; i >= 0 && i < pRight->numOfRows; i += step, output += 1) { @@ -739,7 +739,7 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam } double rx = getVectorDoubleValueFnRight(pRightCol->pData, i); - if (compareDoubleVal(&zero, &rx)) { + if (isnan(rx) || isinf(rx) || FLT_EQUAL(rx, 0)) { colDataAppend(pOutputCol, i, NULL, true); continue; } @@ -749,17 +749,17 @@ void vectorMathRemainder(SScalarParam* pLeft, SScalarParam* pRight, SScalarParam } } else if (pRight->numOfRows == 1) { double rx = getVectorDoubleValueFnRight(pRightCol->pData, 0); - if (colDataIsNull_f(pRightCol->nullbitmap, 0)) { // Set pLeft->numOfRows NULL value + if (colDataIsNull_f(pRightCol->nullbitmap, 0) || FLT_EQUAL(rx, 0)) { // Set pLeft->numOfRows NULL value // TODO set numOfRows NULL value } else { for (; i >= 0 && i < pLeft->numOfRows; i += step, output += 1) { - if (colDataIsNull_f(pRightCol->nullbitmap, i)) { + if (colDataIsNull_f(pLeftCol->nullbitmap, i)) { colDataAppend(pOutputCol, i, NULL, true); continue; } - double lx = getVectorDoubleValueFnLeft(pRightCol->pData, i); - if (compareDoubleVal(&zero, &lx)) { + double lx = getVectorDoubleValueFnLeft(pLeftCol->pData, i); + if (isnan(lx) || isinf(lx)) { colDataAppend(pOutputCol, i, NULL, true); continue; } diff --git a/source/libs/scheduler/CMakeLists.txt b/source/libs/scheduler/CMakeLists.txt index a4a299317c..1a62c7d89d 100644 --- a/source/libs/scheduler/CMakeLists.txt +++ b/source/libs/scheduler/CMakeLists.txt @@ -9,7 +9,7 @@ target_include_directories( target_link_libraries( scheduler - PUBLIC os util nodes planner qcom common catalog transport + PUBLIC os util nodes planner qcom common catalog transport command ) if(${BUILD_TEST}) diff --git a/source/libs/scheduler/inc/schedulerInt.h b/source/libs/scheduler/inc/schedulerInt.h index 518da6e2b8..22bd039219 100644 --- a/source/libs/scheduler/inc/schedulerInt.h +++ b/source/libs/scheduler/inc/schedulerInt.h @@ -142,10 +142,10 @@ typedef struct SSchTask { } SSchTask; typedef struct SSchJobAttr { - bool needFetch; - bool syncSchedule; - bool queryJob; - bool needFlowCtrl; + EExplainMode explainMode; + bool syncSchedule; + bool queryJob; + bool needFlowCtrl; } SSchJobAttr; typedef struct SSchJob { diff --git a/source/libs/scheduler/src/scheduler.c b/source/libs/scheduler/src/scheduler.c index 61462f1dc3..9c5019aedc 100644 --- a/source/libs/scheduler/src/scheduler.c +++ b/source/libs/scheduler/src/scheduler.c @@ -19,6 +19,7 @@ #include "tmsg.h" #include "tref.h" #include "trpc.h" +#include "command.h" SSchedulerMgmt schMgmt = {0}; @@ -2103,6 +2104,7 @@ static int32_t schExecJobImpl(void *transport, SArray *pNodeList, SQueryPlan *pD SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); } + pJob->attr.explainMode = pDag->explainInfo.mode; pJob->attr.syncSchedule = syncSchedule; pJob->transport = transport; pJob->sql = sql; @@ -2136,19 +2138,24 @@ static int32_t schExecJobImpl(void *transport, SArray *pNodeList, SQueryPlan *pD tsem_init(&pJob->rspSem, 0, 0); - pJob->refId = taosAddRef(schMgmt.jobRef, pJob); - if (pJob->refId < 0) { - SCH_JOB_ELOG("taosHashPut job failed, error:%s", tstrerror(terrno)); + int64_t refId = taosAddRef(schMgmt.jobRef, pJob); + if (refId < 0) { + SCH_JOB_ELOG("taosAddRef job failed, error:%s", tstrerror(terrno)); SCH_ERR_JRET(terrno); } + if (NULL == schAcquireJob(refId)) { + SCH_JOB_ELOG("schAcquireJob job failed, refId:%" PRIx64, refId); + SCH_RET(TSDB_CODE_SCH_STATUS_ERROR); + } + + pJob->refId = refId; + SCH_JOB_DLOG("job refId:%" PRIx64, pJob->refId); pJob->status = JOB_TASK_STATUS_NOT_START; SCH_ERR_JRET(schLaunchJob(pJob)); - schAcquireJob(pJob->refId); - *job = pJob->refId; if (syncSchedule) { @@ -2168,6 +2175,54 @@ _return: SCH_RET(code); } +int32_t schExecStaticExplain(void *transport, SArray *pNodeList, SQueryPlan *pDag, int64_t *job, const char *sql, + bool syncSchedule) { + qDebug("QID:0x%" PRIx64 " job started", pDag->queryId); + + int32_t code = 0; + SSchJob *pJob = taosMemoryCalloc(1, sizeof(SSchJob)); + if (NULL == pJob) { + qError("QID:%" PRIx64 " calloc %d failed", pDag->queryId, (int32_t)sizeof(SSchJob)); + SCH_ERR_RET(TSDB_CODE_QRY_OUT_OF_MEMORY); + } + + pJob->sql = sql; + pJob->attr.queryJob = true; + pJob->attr.explainMode = pDag->explainInfo.mode; + pJob->queryId = pDag->queryId; + pJob->subPlans = pDag->pSubplans; + + SCH_ERR_JRET(qExecStaticExplain(pDag, (SRetrieveTableRsp **)&pJob->resData)); + + int64_t refId = taosAddRef(schMgmt.jobRef, pJob); + if (refId < 0) { + SCH_JOB_ELOG("taosAddRef job failed, error:%s", tstrerror(terrno)); + SCH_ERR_JRET(terrno); + } + + if (NULL == schAcquireJob(refId)) { + SCH_JOB_ELOG("schAcquireJob job failed, refId:%" PRIx64, refId); + SCH_RET(TSDB_CODE_SCH_STATUS_ERROR); + } + + pJob->refId = refId; + + SCH_JOB_DLOG("job refId:%" PRIx64, pJob->refId); + + pJob->status = JOB_TASK_STATUS_PARTIAL_SUCCEED; + *job = pJob->refId; + SCH_JOB_DLOG("job exec done, job status:%s", SCH_GET_JOB_STATUS_STR(pJob)); + + schReleaseJob(pJob->refId); + + return TSDB_CODE_SUCCESS; + +_return: + + schFreeJobImpl(pJob); + SCH_RET(code); +} + int32_t schedulerInit(SSchedulerCfg *cfg) { if (schMgmt.jobRef) { qError("scheduler already initialized"); @@ -2216,7 +2271,11 @@ int32_t schedulerExecJob(void *transport, SArray *nodeList, SQueryPlan *pDag, in SCH_ERR_RET(TSDB_CODE_QRY_INVALID_INPUT); } - SCH_ERR_RET(schExecJobImpl(transport, nodeList, pDag, pJob, sql, true)); + if (EXPLAIN_MODE_STATIC == pDag->explainInfo.mode) { + SCH_ERR_RET(schExecStaticExplain(transport, nodeList, pDag, pJob, sql, true)); + } else { + SCH_ERR_RET(schExecJobImpl(transport, nodeList, pDag, pJob, sql, true)); + } SSchJob *job = schAcquireJob(*pJob); @@ -2399,11 +2458,15 @@ int32_t schedulerFetchRows(int64_t job, void **pData) { SCH_JOB_DLOG("job already succeed, status:%s", jobTaskStatusStr(status)); goto _return; } else if (status == JOB_TASK_STATUS_PARTIAL_SUCCEED) { - SCH_ERR_JRET(schFetchFromRemote(pJob)); + if (!(pJob->attr.explainMode == EXPLAIN_MODE_STATIC)) { + SCH_ERR_JRET(schFetchFromRemote(pJob)); + tsem_wait(&pJob->rspSem); + } + } else { + SCH_JOB_ELOG("job status error for fetch, status:%s", jobTaskStatusStr(status)); + SCH_ERR_JRET(TSDB_CODE_SCH_STATUS_ERROR); } - tsem_wait(&pJob->rspSem); - status = SCH_GET_JOB_STATUS(pJob); if (JOB_TASK_STATUS_FAILED == status || JOB_TASK_STATUS_DROPPING == status) { diff --git a/source/libs/tdb/src/db/tdbBtree.c b/source/libs/tdb/src/db/tdbBtree.c index fc27e88cf1..f4e1621742 100644 --- a/source/libs/tdb/src/db/tdbBtree.c +++ b/source/libs/tdb/src/db/tdbBtree.c @@ -29,15 +29,15 @@ struct SBTree { int minLocal; int maxLeaf; int minLeaf; - u8 *pTmp; + void *pBuf; }; #define TDB_BTREE_PAGE_COMMON_HDR u8 flags; -#define TDB_BTREE_PAGE_GET_FLAGS(PAGE) (PAGE)->pData[0] +#define TDB_BTREE_PAGE_GET_FLAGS(PAGE) (PAGE)->pData[0] #define TDB_BTREE_PAGE_SET_FLAGS(PAGE, flags) ((PAGE)->pData[0] = (flags)) -#define TDB_BTREE_PAGE_IS_ROOT(PAGE) (TDB_BTREE_PAGE_GET_FLAGS(PAGE) & TDB_BTREE_ROOT) -#define TDB_BTREE_PAGE_IS_LEAF(PAGE) (TDB_BTREE_PAGE_GET_FLAGS(PAGE) & TDB_BTREE_LEAF) +#define TDB_BTREE_PAGE_IS_ROOT(PAGE) (TDB_BTREE_PAGE_GET_FLAGS(PAGE) & TDB_BTREE_ROOT) +#define TDB_BTREE_PAGE_IS_LEAF(PAGE) (TDB_BTREE_PAGE_GET_FLAGS(PAGE) & TDB_BTREE_LEAF) #define TDB_BTREE_ASSERT_FLAG(flags) \ ASSERT(TDB_FLAG_IS(flags, TDB_BTREE_ROOT) || TDB_FLAG_IS(flags, TDB_BTREE_LEAF) || \ TDB_FLAG_IS(flags, TDB_BTREE_ROOT | TDB_BTREE_LEAF) || TDB_FLAG_IS(flags, 0)) @@ -101,7 +101,7 @@ int tdbBtreeOpen(int keyLen, int valLen, SPager *pPager, FKeyComparator kcmpr, S // pBt->kcmpr pBt->kcmpr = kcmpr ? kcmpr : tdbDefaultKeyCmprFn; // pBt->pageSize - pBt->pageSize = tdbPagerGetPageSize(pPager); + pBt->pageSize = pPager->pageSize; // pBt->maxLocal pBt->maxLocal = tdbPageCapacity(pBt->pageSize, sizeof(SIntHdr)) / 4; // pBt->minLocal: Should not be allowed smaller than 15, which is [nPayload][nKey][nData] @@ -127,132 +127,144 @@ int tdbBtreeClose(SBTree *pBt) { return 0; } -int tdbBtCursorInsert(SBTC *pBtc, const void *pKey, int kLen, const void *pVal, int vLen) { - int ret; - int idx; - SPager *pPager; - SCell *pCell; - int szCell; - int cret; - SBTree *pBt; +int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, int vLen) { + SBTC btc; + SCell *pCell; + void *pBuf; + int szCell; + int szBuf; + int ret; + int idx; + int c; - ret = tdbBtcMoveTo(pBtc, pKey, kLen, &cret); + tdbBtcOpen(&btc, pBt); + + // move to the position to insert + ret = tdbBtcMoveTo(&btc, pKey, kLen, &c); if (ret < 0) { - // TODO: handle error + tdbBtcClose(&btc); + ASSERT(0); return -1; } - if (pBtc->idx == -1) { - ASSERT(TDB_PAGE_TOTAL_CELLS(pBtc->pPage) == 0); + if (btc.idx == -1) { idx = 0; } else { - if (cret > 0) { - idx = pBtc->idx + 1; - } else if (cret < 0) { - idx = pBtc->idx; + if (c > 0) { + idx = btc.idx + 1; + } else if (c < 0) { + idx = btc.idx; } else { - /* TODO */ + // TDB does NOT allow same key + tdbBtcClose(&btc); ASSERT(0); - } - } - - // TODO: refact code here - pBt = pBtc->pBt; - if (!pBt->pTmp) { - pBt->pTmp = (u8 *)tdbOsMalloc(pBt->pageSize); - if (pBt->pTmp == NULL) { return -1; } } - pCell = pBt->pTmp; + // make sure enough space to hold the cell + szBuf = kLen + vLen + 14; + pBuf = TDB_REALLOC(pBt->pBuf, pBt->pageSize > szBuf ? szBuf : pBt->pageSize); + if (pBuf == NULL) { + tdbBtcClose(&btc); + ASSERT(0); + return -1; + } + pBt->pBuf = pBuf; + pCell = (SCell *)pBt->pBuf; - // Encode the cell - ret = tdbBtreeEncodeCell(pBtc->pPage, pKey, kLen, pVal, vLen, pCell, &szCell); + // encode cell + ret = tdbBtreeEncodeCell(btc.pPage, pKey, kLen, pVal, vLen, pCell, &szCell); if (ret < 0) { + tdbBtcClose(&btc); + ASSERT(0); return -1; } - // Insert the cell to the index - ret = tdbPageInsertCell(pBtc->pPage, idx, pCell, szCell, 0); + // mark the page dirty + ret = tdbPagerWrite(pBt->pPager, btc.pPage); if (ret < 0) { + tdbBtcClose(&btc); + ASSERT(0); return -1; } - // If page is overflow, balance the tree - if (pBtc->pPage->nOverflow > 0) { - ret = tdbBtreeBalance(pBtc); + // insert the cell + ret = tdbPageInsertCell(btc.pPage, idx, pCell, szCell, 0); + if (ret < 0) { + tdbBtcClose(&btc); + ASSERT(0); + return -1; + } + + // check if need balance + if (btc.pPage->nOverflow > 0) { + ret = tdbBtreeBalance(&btc); if (ret < 0) { + tdbBtcClose(&btc); + ASSERT(0); return -1; } } + tdbBtcClose(&btc); + return 0; } int tdbBtreeGet(SBTree *pBt, const void *pKey, int kLen, void **ppVal, int *vLen) { - SBTC btc; - SCell *pCell; - int cret; - void *pVal; - SCellDecoder cd; - - tdbBtcOpen(&btc, pBt); - - tdbBtcMoveTo(&btc, pKey, kLen, &cret); - - if (cret) { - return cret; - } - - pCell = tdbPageGetCell(btc.pPage, btc.idx); - tdbBtreeDecodeCell(btc.pPage, pCell, &cd); - - *vLen = cd.vLen; - pVal = TDB_REALLOC(*ppVal, *vLen); - if (pVal == NULL) { - return -1; - } - - *ppVal = pVal; - memcpy(*ppVal, cd.pVal, cd.vLen); - return 0; + return tdbBtreePGet(pBt, pKey, kLen, NULL, NULL, ppVal, vLen); } int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkLen, void **ppVal, int *vLen) { SBTC btc; SCell *pCell; int cret; - void *pTKey; - void *pTVal; + int ret; + void *pTKey = NULL; + void *pTVal = NULL; SCellDecoder cd; tdbBtcOpen(&btc, pBt); - tdbBtcMoveTo(&btc, pKey, kLen, &cret); + ret = tdbBtcMoveTo(&btc, pKey, kLen, &cret); + if (ret < 0) { + tdbBtcClose(&btc); + ASSERT(0); + } + if (cret) { - return cret; + tdbBtcClose(&btc); + return -1; } pCell = tdbPageGetCell(btc.pPage, btc.idx); tdbBtreeDecodeCell(btc.pPage, pCell, &cd); - pTKey = TDB_REALLOC(*ppKey, cd.kLen); - pTVal = TDB_REALLOC(*ppVal, cd.vLen); - - if (pTKey == NULL || pTVal == NULL) { - TDB_FREE(pTKey); - TDB_FREE(pTVal); + if (ppKey) { + pTKey = TDB_REALLOC(*ppKey, cd.kLen); + if (pTKey == NULL) { + tdbBtcClose(&btc); + ASSERT(0); + return -1; + } + *ppKey = pTKey; + *pkLen = cd.kLen; + memcpy(*ppKey, cd.pKey, cd.kLen); } - *ppKey = pTKey; + pTVal = TDB_REALLOC(*ppVal, cd.vLen); + if (pTVal == NULL) { + tdbBtcClose(&btc); + ASSERT(0); + return -1; + } *ppVal = pTVal; - *pkLen = cd.kLen; *vLen = cd.vLen; - - memcpy(*ppKey, cd.pKey, cd.kLen); memcpy(*ppVal, cd.pVal, cd.vLen); + tdbBtcClose(&btc); + return 0; } @@ -300,7 +312,8 @@ static int tdbBtreeOpenImpl(SBTree *pBt) { return -1; } - // TODO: Unref the page + // TODO: here still has problem + tdbPagerReturnPage(pBt->pPager, pPage); ASSERT(pgno != 0); pBt->root = pgno; @@ -371,17 +384,7 @@ static int tdbBtreeZeroPage(SPage *pPage, void *arg) { return 0; } -#ifndef TDB_BTREE_BALANCE -typedef struct { - SBTree *pBt; - SPage *pParent; - int idx; - i8 nOld; - SPage *pOldPages[3]; - i8 nNewPages; - SPage *pNewPages[5]; -} SBtreeBalanceHelper; - +// TDB_BTREE_BALANCE ===================== static int tdbBtreeBalanceDeeper(SBTree *pBt, SPage *pRoot, SPage **ppChild) { SPager *pPager; SPage *pChild; @@ -408,6 +411,13 @@ static int tdbBtreeBalanceDeeper(SBTree *pBt, SPage *pRoot, SPage **ppChild) { ((SIntHdr *)pChild->pData)->pgno = ((SIntHdr *)(pRoot->pData))->pgno; } + ret = tdbPagerWrite(pPager, pChild); + if (ret < 0) { + // TODO + ASSERT(0); + return 0; + } + // Copy the root page content to the child page tdbPageCopy(pRoot, pChild); @@ -472,6 +482,13 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) { ASSERT(0); return -1; } + + ret = tdbPagerWrite(pBt->pPager, pOlds[i]); + if (ret < 0) { + // TODO + ASSERT(0); + return -1; + } } // copy the parent key out if child pages are not leaf page childNotLeaf = !TDB_BTREE_PAGE_IS_LEAF(pOlds[0]); @@ -492,6 +509,14 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) { } rPgno = ((SIntHdr *)pOlds[nOlds - 1]->pData)->pgno; } + + ret = tdbPagerWrite(pBt->pPager, pParent); + if (ret < 0) { + // TODO + ASSERT(0); + return -1; + } + // drop the cells on parent page for (int i = 0; i < nOlds; i++) { nCells = TDB_PAGE_TOTAL_CELLS(pParent); @@ -619,6 +644,13 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) { if (ret < 0) { ASSERT(0); } + + ret = tdbPagerWrite(pBt->pPager, pNews[iNew]); + if (ret < 0) { + // TODO + ASSERT(0); + return -1; + } } } @@ -732,14 +764,24 @@ static int tdbBtreeBalanceNonRoot(SBTree *pBt, SPage *pParent, int idx) { } } + // TODO: here is not corrent for drop case + for (int i = 0; i < nNews; i++) { + if (i < nOlds) { + tdbPagerReturnPage(pBt->pPager, pOlds[i]); + } else { + tdbPagerReturnPage(pBt->pPager, pNews[i]); + } + } + return 0; } static int tdbBtreeBalance(SBTC *pBtc) { int iPage; + int ret; + int nFree; SPage *pParent; SPage *pPage; - int ret; u8 flags; u8 leaf; u8 root; @@ -750,10 +792,11 @@ static int tdbBtreeBalance(SBTC *pBtc) { pPage = pBtc->pPage; leaf = TDB_BTREE_PAGE_IS_LEAF(pPage); root = TDB_BTREE_PAGE_IS_ROOT(pPage); + nFree = TDB_PAGE_FREE_SIZE(pPage); // when the page is not overflow and not too empty, the balance work // is finished. Just break out the balance loop. - if (pPage->nOverflow == 0 /* TODO: && pPage->nFree <= */) { + if (pPage->nOverflow == 0 && nFree < TDB_PAGE_USABLE_SIZE(pPage) * 2 / 3) { break; } @@ -781,6 +824,8 @@ static int tdbBtreeBalance(SBTC *pBtc) { return -1; } + tdbPagerReturnPage(pBtc->pBt->pPager, pBtc->pPage); + pBtc->iPage--; pBtc->pPage = pBtc->pgStack[pBtc->iPage]; } @@ -788,7 +833,7 @@ static int tdbBtreeBalance(SBTC *pBtc) { return 0; } -#endif +// TDB_BTREE_BALANCE // TDB_BTREE_CELL ===================== static int tdbBtreeEncodePayload(SPage *pPage, SCell *pCell, int nHeader, const void *pKey, int kLen, const void *pVal, @@ -1028,12 +1073,11 @@ int tdbBtcMoveToFirst(SBTC *pBtc) { // move upward for (;;) { - if (pBtc->iPage == 0) { + if (pBtc->iPage == iPage) { pBtc->idx = 0; break; } - if (pBtc->iPage < iPage) break; tdbBtcMoveUpward(pBtc); } } @@ -1056,6 +1100,7 @@ int tdbBtcMoveToFirst(SBTC *pBtc) { int tdbBtcMoveToLast(SBTC *pBtc) { int ret; + int nCells; SBTree *pBt; SPager *pPager; SPgno pgno; @@ -1071,27 +1116,56 @@ int tdbBtcMoveToLast(SBTC *pBtc) { return -1; } + nCells = TDB_PAGE_TOTAL_CELLS(pBtc->pPage); pBtc->iPage = 0; + if (nCells > 0) { + pBtc->idx = TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage) ? nCells - 1 : nCells; + } else { + // no data at all, point to an invalid position + ASSERT(TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)); + pBtc->idx = -1; + return 0; + } } else { - // move from a position - ASSERT(0); + int iPage = 0; + + // downward search + for (; iPage < pBtc->iPage; iPage++) { + ASSERT(!TDB_BTREE_PAGE_IS_LEAF(pBtc->pgStack[iPage])); + nCells = TDB_PAGE_TOTAL_CELLS(pBtc->pgStack[iPage]); + if (pBtc->idxStack[iPage] != nCells) break; + } + + // move upward + for (;;) { + if (pBtc->iPage == iPage) { + if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) { + pBtc->idx = TDB_PAGE_TOTAL_CELLS(pBtc->pPage) - 1; + } else { + pBtc->idx = TDB_PAGE_TOTAL_CELLS(pBtc->pPage); + } + break; + } + + tdbBtcMoveUpward(pBtc); + } } // move downward for (;;) { - if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) { - // TODO: handle empty case - ASSERT(TDB_PAGE_TOTAL_CELLS(pBtc->pPage) > 0); - pBtc->idx = TDB_PAGE_TOTAL_CELLS(pBtc->pPage) - 1; - break; - } else { - pBtc->idx = TDB_PAGE_TOTAL_CELLS(pBtc->pPage); + if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) break; - ret = tdbBtcMoveDownward(pBtc); - if (ret < 0) { - ASSERT(0); - return -1; - } + ret = tdbBtcMoveDownward(pBtc); + if (ret < 0) { + ASSERT(0); + return -1; + } + + nCells = TDB_PAGE_TOTAL_CELLS(pBtc->pPage); + if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) { + pBtc->idx = nCells - 1; + } else { + pBtc->idx = nCells; } } @@ -1104,6 +1178,7 @@ int tdbBtreeNext(SBTC *pBtc, void **ppKey, int *kLen, void **ppVal, int *vLen) { void *pKey, *pVal; int ret; + // current cursor points to an invalid position if (pBtc->idx < 0) { return -1; } @@ -1134,12 +1209,17 @@ int tdbBtreeNext(SBTC *pBtc, void **ppKey, int *kLen, void **ppVal, int *vLen) { memcpy(pVal, cd.pVal, cd.vLen); ret = tdbBtcMoveToNext(pBtc); + if (ret < 0) { + ASSERT(0); + return -1; + } return 0; } static int tdbBtcMoveToNext(SBTC *pBtc) { int nCells; + int ret; SCell *pCell; ASSERT(TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)); @@ -1151,39 +1231,35 @@ static int tdbBtcMoveToNext(SBTC *pBtc) { return 0; } - if (pBtc->iPage == 0) { - pBtc->idx = -1; - return 0; - } - - // Move upward + // move upward for (;;) { - tdbBtcMoveUpward(pBtc); - pBtc->idx++; - - nCells = TDB_PAGE_TOTAL_CELLS(pBtc->pPage); - if (pBtc->idx <= nCells) { - break; - } - if (pBtc->iPage == 0) { pBtc->idx = -1; return 0; } - } - // Move downward - for (;;) { - nCells = TDB_PAGE_TOTAL_CELLS(pBtc->pPage); + tdbBtcMoveUpward(pBtc); + pBtc->idx++; - tdbBtcMoveDownward(pBtc); - pBtc->idx = 0; - - if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) { + ASSERT(!TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)); + if (pBtc->idx <= TDB_PAGE_TOTAL_CELLS(pBtc->pPage)) { break; } } + // move downward + for (;;) { + if (TDB_BTREE_PAGE_IS_LEAF(pBtc->pPage)) break; + + ret = tdbBtcMoveDownward(pBtc); + if (ret < 0) { + ASSERT(0); + return -1; + } + + pBtc->idx = 0; + } + return 0; } @@ -1230,91 +1306,145 @@ static int tdbBtcMoveUpward(SBTC *pBtc) { } static int tdbBtcMoveTo(SBTC *pBtc, const void *pKey, int kLen, int *pCRst) { - int ret; - SBTree *pBt; - SPager *pPager; + int ret; + int nCells; + int c; + SBTree *pBt; + SCell *pCell; + SPager *pPager; + SCellDecoder cd = {0}; pBt = pBtc->pBt; pPager = pBt->pPager; if (pBtc->iPage < 0) { - ASSERT(pBtc->iPage == -1); - ASSERT(pBtc->idx == -1); - - // Move from the root + // move from a clear cursor ret = tdbPagerFetchPage(pPager, pBt->root, &(pBtc->pPage), tdbBtreeInitPage, pBt); if (ret < 0) { + // TODO ASSERT(0); - return -1; - } - - pBtc->iPage = 0; - - if (TDB_PAGE_TOTAL_CELLS(pBtc->pPage) == 0) { - // Current page is empty - // ASSERT(TDB_FLAG_IS(TDB_PAGE_FLAGS(pBtc->pPage), TDB_BTREE_ROOT | TDB_BTREE_LEAF)); return 0; } - for (;;) { - int lidx, ridx, midx, c, nCells; - SCell *pCell; - SPage *pPage; - SCellDecoder cd = {0}; + pBtc->iPage = 0; + pBtc->idx = -1; + // for empty tree, just return with an invalid position + if (TDB_PAGE_TOTAL_CELLS(pBtc->pPage) == 0) return 0; + } else { + SPage *pPage; + int idx; + int iPage = 0; - pPage = pBtc->pPage; + // downward search + for (; iPage < pBtc->iPage; iPage++) { + pPage = pBtc->pgStack[iPage]; + idx = pBtc->idxStack[iPage]; nCells = TDB_PAGE_TOTAL_CELLS(pPage); - lidx = 0; - ridx = nCells - 1; - ASSERT(nCells > 0); + ASSERT(!TDB_BTREE_PAGE_IS_LEAF(pPage)); - for (;;) { - if (lidx > ridx) break; - - midx = (lidx + ridx) >> 1; - - pCell = tdbPageGetCell(pPage, midx); - ret = tdbBtreeDecodeCell(pPage, pCell, &cd); - if (ret < 0) { - // TODO: handle error - ASSERT(0); - return -1; - } - - // Compare the key values + // check if key <= current position + if (idx < nCells) { + pCell = tdbPageGetCell(pPage, idx); + tdbBtreeDecodeCell(pPage, pCell, &cd); c = pBt->kcmpr(pKey, kLen, cd.pKey, cd.kLen); - if (c < 0) { - /* input-key < cell-key */ - ridx = midx - 1; - } else if (c > 0) { - /* input-key > cell-key */ - lidx = midx + 1; - } else { - /* input-key == cell-key */ - break; - } + if (c > 0) break; } - // Move downward or break - u8 leaf = TDB_BTREE_PAGE_IS_LEAF(pPage); - if (leaf) { - pBtc->idx = midx; - *pCRst = c; - break; - } else { - if (c <= 0) { - pBtc->idx = midx; - } else { - pBtc->idx = midx + 1; - } - tdbBtcMoveDownward(pBtc); + // check if key > current - 1 position + if (idx > 0) { + pCell = tdbPageGetCell(pPage, idx - 1); + tdbBtreeDecodeCell(pPage, pCell, &cd); + c = pBt->kcmpr(pKey, kLen, cd.pKey, cd.kLen); + if (c <= 0) break; } } - } else { - // TODO: Move the cursor from a some position instead of a clear state - ASSERT(0); + // move upward + for (;;) { + if (pBtc->iPage == iPage) break; + tdbBtcMoveUpward(pBtc); + } + } + + // search downward to the leaf + for (;;) { + int lidx, ridx, midx; + SPage *pPage; + + pPage = pBtc->pPage; + nCells = TDB_PAGE_TOTAL_CELLS(pPage); + lidx = 0; + ridx = nCells - 1; + + ASSERT(nCells > 0); + ASSERT(pBtc->idx == -1); + + // compare first cell + midx = lidx; + pCell = tdbPageGetCell(pPage, midx); + tdbBtreeDecodeCell(pPage, pCell, &cd); + c = pBt->kcmpr(pKey, kLen, cd.pKey, cd.kLen); + if (c <= 0) { + ridx = lidx - 1; + } else { + lidx = lidx + 1; + } + + // compare last cell + if (lidx <= ridx) { + midx = ridx; + pCell = tdbPageGetCell(pPage, midx); + tdbBtreeDecodeCell(pPage, pCell, &cd); + c = pBt->kcmpr(pKey, kLen, cd.pKey, cd.kLen); + if (c >= 0) { + lidx = ridx + 1; + } else { + ridx = ridx - 1; + } + } + + // binary search + for (;;) { + if (lidx > ridx) break; + + midx = (lidx + ridx) >> 1; + + pCell = tdbPageGetCell(pPage, midx); + ret = tdbBtreeDecodeCell(pPage, pCell, &cd); + if (ret < 0) { + // TODO: handle error + ASSERT(0); + return -1; + } + + // Compare the key values + c = pBt->kcmpr(pKey, kLen, cd.pKey, cd.kLen); + if (c < 0) { + // pKey < cd.pKey + ridx = midx - 1; + } else if (c > 0) { + // pKey > cd.pKey + lidx = midx + 1; + } else { + // pKey == cd.pKey + break; + } + } + + // keep search downward or break + if (TDB_BTREE_PAGE_IS_LEAF(pPage)) { + pBtc->idx = midx; + *pCRst = c; + break; + } else { + if (c <= 0) { + pBtc->idx = midx; + } else { + pBtc->idx = midx + 1; + } + tdbBtcMoveDownward(pBtc); + } } return 0; diff --git a/source/libs/tdb/src/db/tdbDb.c b/source/libs/tdb/src/db/tdbDb.c index e41e41f72a..fe7b8c6d48 100644 --- a/source/libs/tdb/src/db/tdbDb.c +++ b/source/libs/tdb/src/db/tdbDb.c @@ -49,6 +49,8 @@ int tdbDbOpen(const char *fname, int keyLen, int valLen, FKeyComparator keyCmprF if (ret < 0) { return -1; } + + tdbEnvAddPager(pEnv, pPager); } ASSERT(pPager != NULL); @@ -74,22 +76,7 @@ int tdbDbDrop(TDB *pDb) { } int tdbDbInsert(TDB *pDb, const void *pKey, int keyLen, const void *pVal, int valLen) { - SBTC btc; - SBTC *pCur; - int ret; - - pCur = &btc; - ret = tdbBtcOpen(pCur, pDb->pBt); - if (ret < 0) { - return -1; - } - - ret = tdbBtCursorInsert(pCur, pKey, keyLen, pVal, valLen); - if (ret < 0) { - return -1; - } - - return 0; + return tdbBtreeInsert(pDb->pBt, pKey, keyLen, pVal, valLen); } int tdbDbGet(TDB *pDb, const void *pKey, int kLen, void **ppVal, int *vLen) { diff --git a/source/libs/tdb/src/db/tdbEnv.c b/source/libs/tdb/src/db/tdbEnv.c index 4439147e09..06d37df653 100644 --- a/source/libs/tdb/src/db/tdbEnv.c +++ b/source/libs/tdb/src/db/tdbEnv.c @@ -19,6 +19,7 @@ int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, TENV **ppEnv) { TENV *pEnv; int dsize; int zsize; + int tsize; u8 *pPtr; int ret; @@ -53,6 +54,14 @@ int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, TENV **ppEnv) { return -1; } + pEnv->nPgrHash = 8; + tsize = sizeof(SPager *) * pEnv->nPgrHash; + pEnv->pgrHash = TDB_REALLOC(pEnv->pgrHash, tsize); + if (pEnv->pgrHash == NULL) { + return -1; + } + memset(pEnv->pgrHash, 0, tsize); + mkdir(rootDir, 0755); *ppEnv = pEnv; @@ -64,7 +73,99 @@ int tdbEnvClose(TENV *pEnv) { return 0; } +int tdbBegin(TENV *pEnv) { + SPager *pPager; + int ret; + + for (pPager = pEnv->pgrList; pPager; pPager = pPager->pNext) { + ret = tdbPagerBegin(pPager); + if (ret < 0) { + ASSERT(0); + return -1; + } + } + + return 0; +} + +int tdbCommit(TENV *pEnv) { + SPager *pPager; + int ret; + + for (pPager = pEnv->pgrList; pPager; pPager = pPager->pNext) { + ret = tdbPagerCommit(pPager); + if (ret < 0) { + ASSERT(0); + return -1; + } + } + + return 0; +} + +int tdbRollback(TENV *pEnv) { + ASSERT(0); + return 0; +} + SPager *tdbEnvGetPager(TENV *pEnv, const char *fname) { - // TODO - return NULL; + u32 hash; + SPager **ppPager; + + hash = tdbCstringHash(fname); + ppPager = &pEnv->pgrHash[hash % pEnv->nPgrHash]; + for (; *ppPager && (strcmp(fname, (*ppPager)->dbFileName) != 0); ppPager = &((*ppPager)->pHashNext)) { + } + + return *ppPager; +} + +void tdbEnvAddPager(TENV *pEnv, SPager *pPager) { + u32 hash; + SPager **ppPager; + + // rehash if neccessary + if (pEnv->nPager + 1 > pEnv->nPgrHash) { + // TODO + } + + // add to list + pPager->pNext = pEnv->pgrList; + pEnv->pgrList = pPager; + + // add to hash + hash = tdbCstringHash(pPager->dbFileName); + ppPager = &pEnv->pgrHash[hash % pEnv->nPgrHash]; + pPager->pHashNext = *ppPager; + *ppPager = pPager; + + // increase the counter + pEnv->nPager++; +} + +void tdbEnvRemovePager(TENV *pEnv, SPager *pPager) { + u32 hash; + SPager **ppPager; + + // remove from the list + for (ppPager = &pEnv->pgrList; *ppPager && (*ppPager != pPager); ppPager = &((*ppPager)->pNext)) { + } + ASSERT(*ppPager == pPager); + *ppPager = pPager->pNext; + + // remove from hash + hash = tdbCstringHash(pPager->dbFileName); + ppPager = &pEnv->pgrHash[hash % pEnv->nPgrHash]; + for (; *ppPager && *ppPager != pPager; ppPager = &((*ppPager)->pHashNext)) { + } + ASSERT(*ppPager == pPager); + *ppPager = pPager->pNext; + + // decrease the counter + pEnv->nPager--; + + // rehash if necessary + if (pEnv->nPgrHash > 8 && pEnv->nPager < pEnv->nPgrHash / 2) { + // TODO + } } \ No newline at end of file diff --git a/source/libs/tdb/src/db/tdbPCache.c b/source/libs/tdb/src/db/tdbPCache.c index 07c267a15c..d886cfd889 100644 --- a/source/libs/tdb/src/db/tdbPCache.c +++ b/source/libs/tdb/src/db/tdbPCache.c @@ -34,18 +34,6 @@ struct SPCache { }) #define PAGE_IS_PINNED(pPage) ((pPage)->pLruNext == NULL) -// For page ref -#define TDB_INIT_PAGE_REF(pPage) ((pPage)->nRef = 0) -#if 0 -#define TDB_REF_PAGE(pPage) (++(pPage)->nRef) -#define TDB_UNREF_PAGE(pPage) (--(pPage)->nRef) -#define TDB_GET_PAGE_REF(pPage) ((pPage)->nRef) -#else -#define TDB_REF_PAGE(pPage) atomic_add_fetch_32(&((pPage)->nRef), 1) -#define TDB_UNREF_PAGE(pPage) atomic_sub_fetch_32(&((pPage)->nRef), 1) -#define TDB_GET_PAGE_REF(pPage) atomic_load_32(&((pPage)->nRef)) -#endif - static int tdbPCacheOpenImpl(SPCache *pCache); static void tdbPCacheInitLock(SPCache *pCache); static void tdbPCacheClearLock(SPCache *pCache); @@ -107,12 +95,7 @@ void tdbPCacheRelease(SPCache *pCache, SPage *pPage) { ASSERT(nRef >= 0); if (nRef == 0) { - if (1 /*TODO: page still clean*/) { - tdbPCacheUnpinPage(pCache, pPage); - } else { - // TODO - ASSERT(0); - } + tdbPCacheUnpinPage(pCache, pPage); } } @@ -192,6 +175,8 @@ static void tdbPCacheUnpinPage(SPCache *pCache, SPage *pPage) { tdbPCacheLock(pCache); + ASSERT(!pPage->isDirty); + nRef = TDB_GET_PAGE_REF(pPage); ASSERT(nRef >= 0); if (nRef == 0) { diff --git a/source/libs/tdb/src/db/tdbPager.c b/source/libs/tdb/src/db/tdbPager.c index 748633da34..2bc40a6aad 100644 --- a/source/libs/tdb/src/db/tdbPager.c +++ b/source/libs/tdb/src/db/tdbPager.c @@ -15,20 +15,6 @@ #include "tdbInt.h" -struct SPager { - char *dbFileName; - char *jFileName; - int pageSize; - uint8_t fid[TDB_FILE_ID_LEN]; - tdb_fd_t fd; - tdb_fd_t jfd; - SPCache *pCache; - SPgno dbFileSize; - SPgno dbOrigSize; - SPage *pDirty; - u8 inTran; -}; - typedef struct __attribute__((__packed__)) { u8 hdrString[16]; u16 pageSize; @@ -41,9 +27,8 @@ TDB_STATIC_ASSERT(sizeof(SFileHdr) == 128, "Size of file header is not correct") #define TDB_PAGE_INITIALIZED(pPage) ((pPage)->pPager != NULL) -static int tdbPagerReadPage(SPager *pPager, SPage *pPage); static int tdbPagerAllocPage(SPager *pPager, SPgno *ppgno); -static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage *, void *), void *arg); +static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage *, void *), void *arg, u8 loadPage); static int tdbPagerWritePageToJournal(SPager *pPager, SPage *pPage); static int tdbPagerWritePageToDB(SPager *pPager, SPage *pPage); @@ -131,26 +116,36 @@ int tdbPagerOpenDB(SPager *pPager, SPgno *ppgno, bool toCreate) { } int tdbPagerWrite(SPager *pPager, SPage *pPage) { - int ret; + int ret; + SPage **ppPage; + ASSERT(pPager->inTran); +#if 0 if (pPager->inTran == 0) { ret = tdbPagerBegin(pPager); if (ret < 0) { return -1; } } +#endif if (pPage->isDirty) return 0; + // ref page one more time so the page will not be release + TDB_REF_PAGE(pPage); + // Set page as dirty pPage->isDirty = 1; - // Add page to dirty list - // TODO: sort the list according to the page number - pPage->pDirtyNext = pPager->pDirty; - pPager->pDirty = pPage; + // Add page to dirty list(TODO: NOT use O(n^2) algorithm) + for (ppPage = &pPager->pDirty; (*ppPage) && TDB_PAGE_PGNO(*ppPage) < TDB_PAGE_PGNO(pPage); + ppPage = &((*ppPage)->pDirtyNext)) { + } + ASSERT(*ppPage == NULL || TDB_PAGE_PGNO(*ppPage) > TDB_PAGE_PGNO(pPage)); + pPage->pDirtyNext = *ppPage; + *ppPage = pPage; - // Write page to journal + // Write page to journal if neccessary if (TDB_PAGE_PGNO(pPage) <= pPager->dbOrigSize) { ret = tdbPagerWritePageToJournal(pPager, pPage); if (ret < 0) { @@ -184,54 +179,46 @@ int tdbPagerCommit(SPager *pPager) { SPage *pPage; int ret; - // Begin commit - { - // TODO: Sync the journal file (Here or when write ?) + // sync the journal file + ret = tdbOsFSync(pPager->jfd); + if (ret < 0) { + // TODO + ASSERT(0); + return 0; } - for (;;) { - pPage = pPager->pDirty; - - if (pPage == NULL) break; - + // loop to write the dirty pages to file + for (pPage = pPager->pDirty; pPage; pPage = pPage->pDirtyNext) { + // TODO: update the page footer ret = tdbPagerWritePageToDB(pPager, pPage); if (ret < 0) { ASSERT(0); return -1; } + } + // release the page + for (pPage = pPager->pDirty; pPage; pPage = pPager->pDirty) { pPager->pDirty = pPage->pDirtyNext; pPage->pDirtyNext = NULL; - // TODO: release the page + pPage->isDirty = 0; + + tdbPCacheRelease(pPager->pCache, pPage); } + // sync the db file tdbOsFSync(pPager->fd); + // remote the journal file tdbOsClose(pPager->jfd); tdbOsRemove(pPager->jFileName); - // pPager->jfd = -1; + pPager->dbOrigSize = pPager->dbFileSize; + pPager->inTran = 0; return 0; } -static int tdbPagerReadPage(SPager *pPager, SPage *pPage) { - i64 offset; - int ret; - - ASSERT(memcmp(pPager->fid, pPage->pgid.fileid, TDB_FILE_ID_LEN) == 0); - - offset = (pPage->pgid.pgno - 1) * (i64)(pPager->pageSize); - ret = tdbOsPRead(pPager->fd, pPage->pData, pPager->pageSize, offset); - if (ret < 0) { - // TODO: handle error - return -1; - } - return 0; -} - -int tdbPagerGetPageSize(SPager *pPager) { return pPager->pageSize; } - int tdbPagerFetchPage(SPager *pPager, SPgno pgno, SPage **ppPage, int (*initPage)(SPage *, void *), void *arg) { SPage *pPage; SPgid pgid; @@ -247,7 +234,7 @@ int tdbPagerFetchPage(SPager *pPager, SPgno pgno, SPage **ppPage, int (*initPage // Initialize the page if need if (!TDB_PAGE_INITIALIZED(pPage)) { - ret = tdbPagerInitPage(pPager, pPage, initPage, arg); + ret = tdbPagerInitPage(pPager, pPage, initPage, arg, 1); if (ret < 0) { return -1; } @@ -284,7 +271,7 @@ int tdbPagerNewPage(SPager *pPager, SPgno *ppgno, SPage **ppPage, int (*initPage ASSERT(!TDB_PAGE_INITIALIZED(pPage)); // Initialize the page if need - ret = tdbPagerInitPage(pPager, pPage, initPage, arg); + ret = tdbPagerInitPage(pPager, pPage, initPage, arg, 0); if (ret < 0) { return -1; } @@ -332,10 +319,11 @@ static int tdbPagerAllocPage(SPager *pPager, SPgno *ppgno) { return 0; } -static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage *, void *), void *arg) { +static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage *, void *), void *arg, u8 loadPage) { int ret; int lcode; int nLoops; + i64 nRead; lcode = TDB_TRY_LOCK_PAGE(pPage); if (lcode == P_LOCK_SUCC) { @@ -344,6 +332,19 @@ static int tdbPagerInitPage(SPager *pPager, SPage *pPage, int (*initPage)(SPage return 0; } + if (loadPage) { + nRead = tdbOsPRead(pPager->fd, pPage->pData, pPage->pageSize, ((i64)pPage->pageSize) * TDB_PAGE_PGNO(pPage)); + if (nRead < 0) { + // TODO + ASSERT(0); + return -1; + } else if (nRead < pPage->pageSize) { + // TODO + ASSERT(0); + return -1; + } + } + ret = (*initPage)(pPage, arg); if (ret < 0) { TDB_UNLOCK_PAGE(pPage); diff --git a/source/libs/tdb/src/db/tdbTxn.c b/source/libs/tdb/src/db/tdbTxn.c index fd4d5de60e..03bcbb44a7 100644 --- a/source/libs/tdb/src/db/tdbTxn.c +++ b/source/libs/tdb/src/db/tdbTxn.c @@ -15,17 +15,29 @@ #include "tdbInt.h" -int tdbTxnBegin(TENV *pEnv) { - // TODO - return 0; -} +// int tdbTxnBegin(TENV *pEnv) { +// // TODO +// return 0; +// } -int tdbTxnCommit(TENV *pEnv) { - // TODO - return 0; -} +// int tdbTxnCommit(TENV *pEnv) { +// SPager *pPager = NULL; +// int ret; -int tdbTxnRollback(TENV *pEnv) { - // TODO - return 0; -} \ No newline at end of file +// for (;;) { +// break; +// ret = tdbPagerCommit(pPager); +// if (ret < 0) { +// ASSERT(0); +// return -1; +// } +// } + +// // TODO +// return 0; +// } + +// int tdbTxnRollback(TENV *pEnv) { +// // TODO +// return 0; +// } \ No newline at end of file diff --git a/source/libs/tdb/src/inc/tdbBtree.h b/source/libs/tdb/src/inc/tdbBtree.h index 2797b5ea5e..2eba5f4f1a 100644 --- a/source/libs/tdb/src/inc/tdbBtree.h +++ b/source/libs/tdb/src/inc/tdbBtree.h @@ -40,7 +40,7 @@ struct SBTC { // SBTree int tdbBtreeOpen(int keyLen, int valLen, SPager *pFile, FKeyComparator kcmpr, SBTree **ppBt); int tdbBtreeClose(SBTree *pBt); -int tdbBtCursorInsert(SBTC *pCur, const void *pKey, int kLen, const void *pVal, int vLen); +int tdbBtreeInsert(SBTree *pBt, const void *pKey, int kLen, const void *pVal, int vLen); int tdbBtreeGet(SBTree *pBt, const void *pKey, int kLen, void **ppVal, int *vLen); int tdbBtreePGet(SBTree *pBt, const void *pKey, int kLen, void **ppKey, int *pkLen, void **ppVal, int *vLen); diff --git a/source/libs/tdb/src/inc/tdbEnv.h b/source/libs/tdb/src/inc/tdbEnv.h index a651c3a12e..e10c5d54e0 100644 --- a/source/libs/tdb/src/inc/tdbEnv.h +++ b/source/libs/tdb/src/inc/tdbEnv.h @@ -25,11 +25,20 @@ typedef struct STEnv { char *jfname; int jfd; SPCache *pCache; + SPager *pgrList; + int nPager; + int nPgrHash; + SPager **pgrHash; } TENV; int tdbEnvOpen(const char *rootDir, int pageSize, int cacheSize, TENV **ppEnv); int tdbEnvClose(TENV *pEnv); +int tdbBegin(TENV *pEnv); +int tdbCommit(TENV *pEnv); +int tdbRollback(TENV *pEnv); +void tdbEnvAddPager(TENV *pEnv, SPager *pPager); +void tdbEnvRemovePager(TENV *pEnv, SPager *pPager); SPager *tdbEnvGetPager(TENV *pEnv, const char *fname); #ifdef __cplusplus diff --git a/source/libs/tdb/src/inc/tdbInt.h b/source/libs/tdb/src/inc/tdbInt.h index 361a460cef..57e01f904c 100644 --- a/source/libs/tdb/src/inc/tdbInt.h +++ b/source/libs/tdb/src/inc/tdbInt.h @@ -16,8 +16,6 @@ #ifndef _TD_TDB_INTERNAL_H_ #define _TD_TDB_INTERNAL_H_ -#include "os.h" - #include "tdb.h" #ifdef __cplusplus @@ -91,23 +89,6 @@ static FORCE_INLINE int tdbCmprPgId(const void *p1, const void *p2) { // dbname #define TDB_MAX_DBNAME_LEN 24 -// tdb_log -#define tdbError(var) - -#define TERR_A(val, op, flag) \ - do { \ - if (((val) = (op)) != 0) { \ - goto flag; \ - } \ - } while (0) - -#define TERR_B(val, op, flag) \ - do { \ - if (((val) = (op)) == NULL) { \ - goto flag; \ - } \ - } while (0) - #define TDB_VARIANT_LEN ((int)-1) typedef int (*FKeyComparator)(const void *pKey1, int kLen1, const void *pKey2, int kLen2); diff --git a/source/libs/tdb/src/inc/tdbOs.h b/source/libs/tdb/src/inc/tdbOs.h index 196bbdafc7..ae389708f4 100644 --- a/source/libs/tdb/src/inc/tdbOs.h +++ b/source/libs/tdb/src/inc/tdbOs.h @@ -24,6 +24,8 @@ extern "C" { #define TDB_FOR_TDENGINE #ifdef TDB_FOR_TDENGINE +#include "os.h" +#include "thash.h" // For memory ----------------- #define tdbOsMalloc taosMemoryMalloc @@ -95,7 +97,11 @@ typedef int tdb_fd_t; #define tdbOsOpen(PATH, OPTION, MODE) open((PATH), (OPTION), (MODE)) -#define tdbOsClose close +#define tdbOsClose(FD) \ + do { \ + close(FD); \ + (FD) = -1; \ + } while (0) i64 tdbOsRead(tdb_fd_t fd, void *pData, i64 nBytes); i64 tdbOsPRead(tdb_fd_t fd, void *pData, i64 nBytes, i64 offset); diff --git a/source/libs/tdb/src/inc/tdbPCache.h b/source/libs/tdb/src/inc/tdbPCache.h index c7fa155615..f71d34ab53 100644 --- a/source/libs/tdb/src/inc/tdbPCache.h +++ b/source/libs/tdb/src/inc/tdbPCache.h @@ -33,6 +33,18 @@ extern "C" { SPager *pPager; \ SPgid pgid; +// For page ref +#define TDB_INIT_PAGE_REF(pPage) ((pPage)->nRef = 0) +#if 0 +#define TDB_REF_PAGE(pPage) (++(pPage)->nRef) +#define TDB_UNREF_PAGE(pPage) (--(pPage)->nRef) +#define TDB_GET_PAGE_REF(pPage) ((pPage)->nRef) +#else +#define TDB_REF_PAGE(pPage) atomic_add_fetch_32(&((pPage)->nRef), 1) +#define TDB_UNREF_PAGE(pPage) atomic_sub_fetch_32(&((pPage)->nRef), 1) +#define TDB_GET_PAGE_REF(pPage) atomic_load_32(&((pPage)->nRef)) +#endif + int tdbPCacheOpen(int pageSize, int cacheSize, SPCache **ppCache); int tdbPCacheClose(SPCache *pCache); SPage *tdbPCacheFetch(SPCache *pCache, const SPgid *pPgid, bool alcNewPage); diff --git a/source/libs/tdb/src/inc/tdbPage.h b/source/libs/tdb/src/inc/tdbPage.h index 563fb53e98..77a1ee5f6e 100644 --- a/source/libs/tdb/src/inc/tdbPage.h +++ b/source/libs/tdb/src/inc/tdbPage.h @@ -100,6 +100,7 @@ struct SPage { // APIs #define TDB_PAGE_TOTAL_CELLS(pPage) ((pPage)->nOverflow + (pPage)->pPageMethods->getCellNum(pPage)) #define TDB_PAGE_USABLE_SIZE(pPage) ((u8 *)(pPage)->pPageFtr - (pPage)->pCellIdx) +#define TDB_PAGE_FREE_SIZE(pPage) (*(pPage)->pPageMethods->getFreeBytes)(pPage) #define TDB_PAGE_PGNO(pPage) ((pPage)->pgid.pgno) #define TDB_BYTES_CELL_TAKEN(pPage, pCell) ((*(pPage)->xCellSize)(pPage, pCell) + (pPage)->pPageMethods->szOffset) #define TDB_PAGE_OFFSET_SIZE(pPage) ((pPage)->pPageMethods->szOffset) diff --git a/source/libs/tdb/src/inc/tdbPager.h b/source/libs/tdb/src/inc/tdbPager.h index f4cc822f27..81b6074431 100644 --- a/source/libs/tdb/src/inc/tdbPager.h +++ b/source/libs/tdb/src/inc/tdbPager.h @@ -20,13 +20,28 @@ extern "C" { #endif +struct SPager { + char *dbFileName; + char *jFileName; + int pageSize; + uint8_t fid[TDB_FILE_ID_LEN]; + tdb_fd_t fd; + tdb_fd_t jfd; + SPCache *pCache; + SPgno dbFileSize; + SPgno dbOrigSize; + SPage *pDirty; + u8 inTran; + SPager *pNext; // used by TENV + SPager *pHashNext; // used by TENV +}; + int tdbPagerOpen(SPCache *pCache, const char *fileName, SPager **ppPager); int tdbPagerClose(SPager *pPager); int tdbPagerOpenDB(SPager *pPager, SPgno *ppgno, bool toCreate); int tdbPagerWrite(SPager *pPager, SPage *pPage); int tdbPagerBegin(SPager *pPager); int tdbPagerCommit(SPager *pPager); -int tdbPagerGetPageSize(SPager *pPager); int tdbPagerFetchPage(SPager *pPager, SPgno pgno, SPage **ppPage, int (*initPage)(SPage *, void *), void *arg); int tdbPagerNewPage(SPager *pPager, SPgno *ppgno, SPage **ppPage, int (*initPage)(SPage *, void *), void *arg); void tdbPagerReturnPage(SPager *pPager, SPage *pPage); diff --git a/source/libs/tdb/src/inc/tdbTxn.h b/source/libs/tdb/src/inc/tdbTxn.h index cc11369785..0be2dad3c2 100644 --- a/source/libs/tdb/src/inc/tdbTxn.h +++ b/source/libs/tdb/src/inc/tdbTxn.h @@ -28,10 +28,6 @@ struct STxn { void *xArg; }; -int tdbTxnBegin(TENV *pEnv); -int tdbTxnCommit(TENV *pEnv); -int tdbTxnRollback(TENV *pEnv); - #ifdef __cplusplus } #endif diff --git a/source/libs/tdb/src/inc/tdbUtil.h b/source/libs/tdb/src/inc/tdbUtil.h index c06d9d18c9..6abddb5b22 100644 --- a/source/libs/tdb/src/inc/tdbUtil.h +++ b/source/libs/tdb/src/inc/tdbUtil.h @@ -101,6 +101,8 @@ static inline int tdbGetVarInt(const u8 *p, int *v) { return n; } +static inline u32 tdbCstringHash(const char *s) { return MurmurHash3_32(s, strlen(s)); } + #ifdef __cplusplus } #endif diff --git a/source/libs/tdb/test/tdbTest.cpp b/source/libs/tdb/test/tdbTest.cpp index f41e2bcbee..9e1277a53d 100644 --- a/source/libs/tdb/test/tdbTest.cpp +++ b/source/libs/tdb/test/tdbTest.cpp @@ -118,10 +118,10 @@ TEST(tdb_test, simple_test) { TENV *pEnv; TDB *pDb; FKeyComparator compFunc; - int nData = 1000000; + int nData = 50000000; // Open Env - ret = tdbEnvOpen("tdb", 4096, 256000, &pEnv); + ret = tdbEnvOpen("tdb", 4096, 64, &pEnv); GTEST_ASSERT_EQ(ret, 0); // Create a database @@ -134,36 +134,23 @@ TEST(tdb_test, simple_test) { char val[64]; { // Insert some data - int i = 1; - SPoolMem *pPool; - int memPoolCapacity = 16 * 1024; + for (int i = 1; i <= nData;) { + tdbBegin(pEnv); - pPool = openPool(); - - tdbTxnBegin(pEnv); - - for (;;) { - if (i > nData) break; - - sprintf(key, "key%d", i); - sprintf(val, "value%d", i); - ret = tdbDbInsert(pDb, key, strlen(key), val, strlen(val)); - GTEST_ASSERT_EQ(ret, 0); - - if (pPool->size >= memPoolCapacity) { - tdbTxnCommit(pEnv); - - clearPool(pPool); - - tdbTxnBegin(pEnv); + for (int k = 0; k < 2000; k++) { + sprintf(key, "key%d", i); + sprintf(val, "value%d", i); + ret = tdbDbInsert(pDb, key, strlen(key), val, strlen(val)); + GTEST_ASSERT_EQ(ret, 0); + i++; } - i++; + tdbCommit(pEnv); } - - closePool(pPool); } + tdbCommit(pEnv); + { // Query the data void *pVal = NULL; int vLen; @@ -173,6 +160,7 @@ TEST(tdb_test, simple_test) { sprintf(val, "value%d", i); ret = tdbDbGet(pDb, key, strlen(key), &pVal, &vLen); + ASSERT(ret == 0); GTEST_ASSERT_EQ(ret, 0); GTEST_ASSERT_EQ(vLen, strlen(val)); diff --git a/source/os/src/osFile.c b/source/os/src/osFile.c index ed93708c07..1b73f96896 100644 --- a/source/os/src/osFile.c +++ b/source/os/src/osFile.c @@ -294,7 +294,7 @@ int64_t taosCloseFile(TdFilePtr *ppFile) { #if FILE_WITH_LOCK taosThreadRwlockWrlock(&((*ppFile)->rwlock)); #endif - if (ppFile == NULL || *ppFile == NULL || (*ppFile)->fd == -1) { + if (ppFile == NULL || *ppFile == NULL) { return 0; } if ((*ppFile)->fp != NULL) { diff --git a/source/os/src/osMemory.c b/source/os/src/osMemory.c index f4d4c74d1d..3545aabdca 100644 --- a/source/os/src/osMemory.c +++ b/source/os/src/osMemory.c @@ -23,15 +23,22 @@ #define TD_MEMORY_STACK_TRACE_DEPTH 10 +typedef struct TdMemoryInfo *TdMemoryInfoPtr; + typedef struct TdMemoryInfo { int32_t symbol; int32_t memorySize; void *stackTrace[TD_MEMORY_STACK_TRACE_DEPTH]; // gdb: disassemble /m 0xXXX -} *TdMemoryInfoPtr , TdMemoryInfo; + // TdMemoryInfoPtr pNext; + // TdMemoryInfoPtr pPrev; +} TdMemoryInfo; + +// static TdMemoryInfoPtr GlobalMemoryPtr = NULL; #if defined(_TD_WINDOWS_64) || defined(_TD_WINDOWS_32) - + #define tstrdup(str) _strdup(str) #else + #define tstrdup(str) strdup(str) #include @@ -129,6 +136,26 @@ void *taosMemoryRealloc(void *ptr, int32_t size) { #endif } +void *taosMemoryStrDup(void *ptr) { +#ifdef USE_TD_MEMORY + if (ptr == NULL) return NULL; + + TdMemoryInfoPtr pTdMemoryInfo = (TdMemoryInfoPtr)((char*)ptr - sizeof(TdMemoryInfo)); + assert(pTdMemoryInfo->symbol == TD_MEMORY_SYMBOL); + + void *tmp = tstrdup((const char *)pTdMemoryInfo); + if (tmp == NULL) return NULL; + + memcpy(tmp, pTdMemoryInfo, sizeof(TdMemoryInfo)); + taosBackTrace(((TdMemoryInfoPtr)tmp)->stackTrace,TD_MEMORY_STACK_TRACE_DEPTH); + + return (char*)tmp + sizeof(TdMemoryInfo); +#else + return tstrdup((const char *)ptr); +#endif +} + + void taosMemoryFree(const void *ptr) { if (ptr == NULL) return; diff --git a/source/os/src/osProc.c b/source/os/src/osProc.c index 2d2174a4c8..6b52fa30be 100644 --- a/source/os/src/osProc.c +++ b/source/os/src/osProc.c @@ -32,6 +32,18 @@ int32_t taosNewProc(char **args) { } } +void taosWaitProc(int32_t pid) { + int32_t status = 0; + waitpid(pid, &status, 0); +} + +void taosKillProc(int32_t pid) { kill(pid, SIGINT); } + +bool taosProcExist(int32_t pid) { + int32_t p = getpgid(pid); + return p >= 0; +} + // the length of the new name must be less than the original name to take effect void taosSetProcName(int32_t argc, char **argv, const char *name) { prctl(PR_SET_NAME, name); @@ -48,8 +60,3 @@ void taosSetProcName(int32_t argc, char **argv, const char *name) { } void taosSetProcPath(int32_t argc, char **argv) { tsProcPath = argv[0]; } - -bool taosProcExists(int32_t pid) { - int32_t p = getpgid(pid); - return p >= 0; -} diff --git a/source/util/src/tcompare.c b/source/util/src/tcompare.c index c98f6eb9be..7f9a3ff593 100644 --- a/source/util/src/tcompare.c +++ b/source/util/src/tcompare.c @@ -173,6 +173,7 @@ int32_t compareDoubleVal(const void *pLeft, const void *pRight) { if (isnan(p2)) { return 1; } + if (FLT_EQUAL(p1, p2)) { return 0; } diff --git a/source/util/src/tconfig.c b/source/util/src/tconfig.c index 9101d3c7c8..ce9ef5b1c0 100644 --- a/source/util/src/tconfig.c +++ b/source/util/src/tconfig.c @@ -590,7 +590,7 @@ void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump) { } int32_t cfgLoadFromEnvVar(SConfig *pConfig) { - uInfo("load from global env variables not implemented yet"); + uInfo("load from env variables not implemented yet"); return 0; } diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 811c9941f7..9cf2e9318b 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -23,8 +23,8 @@ ./test.sh -f tsim/insert/null.sim # ---- parser -#./test.sh -f tsim/parser/groupby-basic.sim -#./test.sh -f tsim/parser/fourArithmetic-basic.sim +./test.sh -f tsim/parser/groupby-basic.sim +./test.sh -f tsim/parser/fourArithmetic-basic.sim # ---- query ./test.sh -f tsim/query/interval.sim diff --git a/tests/script/runAllSimCases.sh b/tests/script/runAllSimCases.sh new file mode 100755 index 0000000000..e1eea1cc38 --- /dev/null +++ b/tests/script/runAllSimCases.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +################################################## +# +# Do simulation test +# +################################################## + +set -e +#set -x + +while read line +do + firstChar=`echo ${line:0:1}` + if [[ -n "$line" ]] && [[ $firstChar != "#" ]]; then + echo "======== $line ========" + $line + fi +done < ./jenkins/basic.txt + + diff --git a/tests/script/tsim/db/alter_option.sim b/tests/script/tsim/db/alter_option.sim index 0fc7175cb1..f79bf88ad2 100644 --- a/tests/script/tsim/db/alter_option.sim +++ b/tests/script/tsim/db/alter_option.sim @@ -66,7 +66,7 @@ print ============= create database # | REPLICA value [1 | 3] # | WAL value [1 | 2] -sql create database db BLOCKS 7 CACHE 3 CACHELAST 3 COMP 0 DAYS 240 FSYNC 1000 MAXROWS 8000 MINROWS 10 KEEP 1000 PRECISION 'ns' QUORUM 1 REPLICA 3 TTL 7 WAL 2 VGROUPS 6 SINGLE_STABLE 1 STREAM_MODE 1 +sql create database db BLOCKS 7 CACHE 3 CACHELAST 3 COMP 0 DAYS 345600 FSYNC 1000 MAXROWS 8000 MINROWS 10 KEEP 1440000 PRECISION 'ns' QUORUM 1 REPLICA 3 TTL 7 WAL 2 VGROUPS 6 SINGLE_STABLE 1 STREAM_MODE 1 sql show databases print rows: $rows print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 @@ -92,10 +92,10 @@ endi if $data5_db != 1 then # quorum return -1 endi -if $data6_db != 240 then # days +if $data6_db != 345600 then # days return -1 endi -if $data7_db != 1000,1000,1000 then # keep +if $data7_db != 1440000,1440000,1440000 then # keep return -1 endi if $data8_db != 3 then # cache @@ -138,7 +138,7 @@ sql_error alter database db ntables 0 sql_error alter database db ntables 1 sql_error alter database db ntables 10 -#print ============== modify replica +#print ============== modify replica # TD-14409 sql_error alter database db replica 2 sql_error alter database db replica 5 sql_error alter database db replica -1 @@ -186,7 +186,7 @@ print ============== modify keep sql alter database db keep 2000 sql show databases print keep $data7_db -if $data7_db != 1000,1000,2000 then +if $data7_db != 2000,2000,2000 then return -1 endi @@ -270,7 +270,7 @@ if $data12_db != 2 then return -1 endi -#sql_error alter database db wal 0 # TD-14436 +sql_error alter database db wal 0 # TD-14436 sql_error alter database db wal 3 sql_error alter database db wal 100 sql_error alter database db wal -1 diff --git a/tests/script/tsim/db/basic6.sim b/tests/script/tsim/db/basic6.sim index 7e57fe8f1b..a768a0da38 100644 --- a/tests/script/tsim/db/basic6.sim +++ b/tests/script/tsim/db/basic6.sim @@ -15,7 +15,7 @@ $tb = $tbPrefix . $i print =============== step1 # quorum presicion -sql create database $db vgroups 8 replica 1 days 20 keep 3650 cache 32 blocks 12 minrows 80 maxrows 10000 wal 2 fsync 1000 comp 0 cachelast 2 precision 'us' +sql create database $db vgroups 8 replica 1 days 2880 keep 3650 cache 32 blocks 12 minrows 80 maxrows 10000 wal 2 fsync 1000 comp 0 cachelast 2 precision 'us' sql show databases print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1 print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 @@ -35,7 +35,7 @@ endi if $data04 != 1 then return -1 endi -if $data06 != 20 then +if $data06 != 2880 then return -1 endi if $data07 != 3650,3650,3650 then @@ -67,7 +67,7 @@ print =============== step4 sql_error drop database $db print =============== step5 -sql create database $db replica 1 days 15 keep 1500 +sql create database $db replica 1 days 21600 keep 2160000 sql show databases print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 if $data00 != $db then @@ -79,7 +79,7 @@ endi if $data04 != 1 then return -1 endi -if $data06 != 15 then +if $data06 != 21600 then return -1 endi diff --git a/tests/script/tsim/parser/fourArithmetic-basic.sim b/tests/script/tsim/parser/fourArithmetic-basic.sim index 2ade01522e..bb35df5a90 100644 --- a/tests/script/tsim/parser/fourArithmetic-basic.sim +++ b/tests/script/tsim/parser/fourArithmetic-basic.sim @@ -78,6 +78,10 @@ while $i < $tbNum $tstart = 1640966400000 endw + +$loop_test = 0 +loop_test_pos: + sql select ts, c2-c1, c3/c1, c4+c1, c1*9, c1%3 from ct0 print ===> rows: $rows print ===> $data00 $data01 $data02 $data03 $data04 $data05 @@ -107,4 +111,31 @@ endi if $data93 != 8.000000000 then return -1 endi + +if $loop_test == 0 then + print =============== stop and restart taosd + system sh/exec.sh -n dnode1 -s stop -x SIGINT + system sh/exec.sh -n dnode1 -s start + + $loop_cnt = 0 + check_dnode_ready_0: + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi + sql show dnodes + print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 + if $data00 != 1 then + return -1 + endi + if $data04 != ready then + goto check_dnode_ready_0 + endi + + $loop_test = 1 + goto loop_test_pos +endi + #system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/parser/groupby-basic.sim b/tests/script/tsim/parser/groupby-basic.sim index c0cbfa8aeb..e26f849b13 100644 --- a/tests/script/tsim/parser/groupby-basic.sim +++ b/tests/script/tsim/parser/groupby-basic.sim @@ -45,7 +45,7 @@ $tstart = 1640966400000 # 2022-01-01 00:00:00.000 print ==== create db, stable, ctables, insert data sql drop database if exists $db -x step1 step1: -sql create database if not exists $db keep 3650 +sql create database if not exists $db sql use $db sql create table $mt (ts timestamp, c1 int, c2 float, c3 bigint, c4 smallint, c5 tinyint, c6 double, c7 bool, c8 binary(10), c9 nchar(9)) TAGS(t1 int, t2 binary(12)) @@ -131,6 +131,7 @@ if $data91 != 9 then return -1 endi +print ==== select first(ts),c1 from group_tb0 group by c1; sql select first(ts),c1 from group_tb0 group by c1; print rows: $rows print $data00 $data01 $data02 $data03 @@ -142,19 +143,38 @@ if $row != 10 then return -1 endi -if $data00 != @2022-01-01 00:00:00.000@ then +if $data00 != @22-01-01 00:00:00.000@ then return -1 endi if $data01 != 0 then return -1 endi -if $data90 != @2022-01-01 00:00:00.009@ then +if $data90 != @22-01-01 00:00:00.009@ then return -1 endi if $data91 != 9 then return -1 endi +print ==== select first(ts),c1 from interval(5m) group_tb0 group by c1; +sql select first(ts),c1 from group_tb0 group by c1; +print rows: $rows +print $data00 $data01 $data02 $data03 +print $data10 $data11 $data12 $data13 +print $data20 $data21 $data22 $data23 +print $data80 $data81 $data82 $data83 +print $data90 $data91 $data92 $data93 + +return + + + + + + + + + sql select sum(c1), c1, avg(c1), min(c1), max(c2) from group_tb0 where c1 < 20 group by c1; if $row != 20 then diff --git a/tests/script/tsim/query/interval-offset.sim b/tests/script/tsim/query/interval-offset.sim index ffb13979cd..616ece99e0 100644 --- a/tests/script/tsim/query/interval-offset.sim +++ b/tests/script/tsim/query/interval-offset.sim @@ -73,39 +73,45 @@ sql insert into ct4 values ( '2022-12-01 01:01:30.000', 8 ) sql insert into ct4 values ( '2022-12-31 01:01:36.000', 9 ) print ================ start query ====================== -sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct1 interval(10s, 2s) -print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct1 interval(10s, 2s) +sql select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(*) from ct1 interval(10s, 2s) +print ===> select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(*) from ct1 interval(10s, 2s) print ===> rows: $rows -print ===> rows0: $data00 $data01 $data02 $data03 $data04 -print ===> rows1: $data10 $data11 $data12 $data13 $data14 -print ===> rows2: $data20 $data21 $data22 $data23 $data24 -print ===> rows3: $data30 $data31 $data32 $data33 $data34 -print ===> rows4: $data40 $data41 $data42 $data43 $data44 +print ===> rows0: $data00 $data01 $data02 $data05 +print ===> rows1: $data10 $data11 $data12 $data15 +print ===> rows2: $data20 $data21 $data22 $data25 +print ===> rows3: $data30 $data31 $data32 $data35 +print ===> rows4: $data40 $data41 $data42 $data45 if $rows != 5 then return -1 endi -if $data00 != 1 then +if $data00 != @22-01-01 01:00:52.000@ then return -1 endi -if $data40 != 1 then +if $data02 != 10000 then + return -1 +endi +if $data45 != 1 then return -1 endi -sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct1 interval(10s, 2s) sliding(10s) -print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct1 interval(10s, 2s) sliding(10s) +sql select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(*) from ct1 interval(10s, 2s) sliding(10s) +print ===> select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(*) from ct1 interval(10s, 2s) sliding(10s) print ===> rows: $rows -print ===> rows0: $data00 $data01 $data02 $data03 $data04 -print ===> rows1: $data10 $data11 $data12 $data13 $data14 -print ===> rows2: $data20 $data21 $data22 $data23 $data24 -print ===> rows3: $data30 $data31 $data32 $data33 $data34 -print ===> rows4: $data40 $data41 $data42 $data43 $data44 +print ===> rows0: $data00 $data01 $data02 $data05 +print ===> rows1: $data10 $data11 $data12 $data15 +print ===> rows2: $data20 $data21 $data22 $data25 +print ===> rows3: $data30 $data31 $data32 $data35 +print ===> rows4: $data40 $data41 $data42 $data45 if $rows != 5 then return -1 endi -if $data00 != 1 then +if $data00 != @22-01-01 01:00:52.000@ then return -1 endi -if $data40 != 1 then +if $data02 != 10000 then + return -1 +endi +if $data45 != 1 then return -1 endi @@ -176,107 +182,81 @@ if $data70 != 1 then return -1 endi -sql select _wstartts, _wendts, _wduration, _qstartts, _qendts, count(tbcol) from ct2 interval(1d, 2h) sliding(12h) -print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct2 interval(1d, 2h) sliding(12h) -print ===> rows: $rows -print ===> rows0: $data00 $data01 $data02 $data03 $data04 $data05 -print ===> rows1: $data10 $data11 $data12 $data13 $data14 $data15 -print ===> rows2: $data20 $data21 $data22 $data23 $data24 $data25 -print ===> rows3: $data30 $data31 $data32 $data33 $data34 $data35 -print ===> rows4: $data40 $data41 $data42 $data43 $data44 $data45 -print ===> rows5: $data50 $data51 $data52 $data53 $data54 $data55 -print ===> rows6: $data60 $data61 $data62 $data63 $data64 $data65 -print ===> rows7: $data70 $data71 $data72 $data73 $data74 $data75 -if $rows != 8 then - return -1 -endi -if $data05 != 1 then - return -1 -endi -if $data15 != 2 then - return -1 -endi -if $data75 != 1 then - return -1 -endi -if $data02 != 86400000 then - return -1 -endi - -sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w) +sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w) print ===> rows: $rows print ===> rows0: $data00 $data01 $data02 $data03 $data04 print ===> rows1: $data10 $data11 $data12 $data13 $data14 print ===> rows2: $data20 $data21 $data22 $data23 $data24 print ===> rows3: $data30 $data31 $data32 $data33 $data34 -print ===> rows4: $data40 $data41 $data42 $data43 $data44 -# if $rows != 5 then -# return -1 -# endi -# f $data00 != 1 then -# return -1 -# endi -# if $data40 != 1 then -# return -1 -# endi +if $rows != 4 then + return -1 +endi +if $data00 != @21-12-08 00:00:00.000@ then + return -1 +endi +if $data31 != 1 then + return -1 +endi +if $data34 != $data31 then + return -1 +endi +if $data02 != 2678400000 then + return -1 +endi -sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w) sliding(2w) +sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(2w) print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w) sliding(2w) print ===> rows: $rows print ===> rows0: $data00 $data01 $data02 $data03 $data04 print ===> rows1: $data10 $data11 $data12 $data13 $data14 print ===> rows2: $data20 $data21 $data22 $data23 $data24 print ===> rows3: $data30 $data31 $data32 $data33 $data34 -print ===> rows4: $data40 $data41 $data42 $data43 $data44 -#if $rows != 5 then -# return -1 -#endi -#if $data00 != 1 then -# return -1 -#endi -#if $data40 != 1 then -# return -1 -#endi +if $rows != 4 then + return -1 +endi +if $data00 != @21-11-30 08:00:00.000@ then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data31 != $data34 then + return -1 +endi -sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w) sliding(4w) -print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct3 interval(1n, 1w) sliding(4w) +sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(4w) +print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct3 interval(1n, 1w) sliding(4w) print ===> rows: $rows print ===> rows0: $data00 $data01 $data02 $data03 $data04 print ===> rows1: $data10 $data11 $data12 $data13 $data14 print ===> rows2: $data20 $data21 $data22 $data23 $data24 print ===> rows3: $data30 $data31 $data32 $data33 $data34 -print ===> rows4: $data40 $data41 $data42 $data43 $data44 -print ===> rows5: $data50 $data51 $data52 $data53 $data54 -print ===> rows6: $data60 $data61 $data62 $data63 $data64 -print ===> rows7: $data70 $data71 $data72 $data73 $data74 -#if $rows != 8 then -# return -1 -#endi -#if $data00 != 2 then -# return -1 -#endi -#if $data70 != 1 then -# return -1 -#endi +if $rows != 4 then + return -1 +endi +if $data01 != NULL then + return -1 +endi +if $data04 != 1 then + return -1 +endi -sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) -print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) +sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) +print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) print ===> rows: $rows print ===> rows0: $data00 $data01 $data02 $data03 $data04 print ===> rows1: $data10 $data11 $data12 $data13 $data14 print ===> rows2: $data20 $data21 $data22 $data23 $data24 -print ===> rows3: $data30 $data31 $data32 $data33 $data34 -print ===> rows4: $data40 $data41 $data42 $data43 $data44 -#if $rows != 5 then -# return -1 -#endi -#if $data00 != 1 then -# return -1 -#endi -#if $data40 != 1 then -# return -1 -#endi +if $rows != 3 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data04 != 2 then + return -1 +endi sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(6n) print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(6n) @@ -284,38 +264,31 @@ print ===> rows: $rows print ===> rows0: $data00 $data01 $data02 $data03 $data04 print ===> rows1: $data10 $data11 $data12 $data13 $data14 print ===> rows2: $data20 $data21 $data22 $data23 $data24 -print ===> rows3: $data30 $data31 $data32 $data33 $data34 -print ===> rows4: $data40 $data41 $data42 $data43 $data44 -#if $rows != 5 then -# return -1 -#endi -#if $data00 != 1 then -# return -1 -#endi -#if $data40 != 1 then -# return -1 -#endi +if $rows != 3 then + return -1 +endi +if $data00 != 2 then + return -1 +endi +if $data04 != 2 then + return -1 +endi -sql select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(12n) -print ===> select count(tbcol), sum(tbcol), max(tbcol), min(tbcol), count(*) from ct4 interval(1y, 6n) sliding(12n) +sql select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) sliding(12n) +print ===> select _wstartts, count(tbcol), _wduration, _wstartts, count(*) from ct4 interval(1y, 6n) sliding(12n) print ===> rows: $rows print ===> rows0: $data00 $data01 $data02 $data03 $data04 print ===> rows1: $data10 $data11 $data12 $data13 $data14 print ===> rows2: $data20 $data21 $data22 $data23 $data24 -print ===> rows3: $data30 $data31 $data32 $data33 $data34 -print ===> rows4: $data40 $data41 $data42 $data43 $data44 -print ===> rows5: $data50 $data51 $data52 $data53 $data54 -print ===> rows6: $data60 $data61 $data62 $data63 $data64 -print ===> rows7: $data70 $data71 $data72 $data73 $data74 -#if $rows != 8 then -# return -1 -#endi -#if $data00 != 2 then -# return -1 -#endi -#if $data70 != 1 then -# return -1 -#endi +if $rows != 3 then + return -1 +endi +if $data01 != 2 then + return -1 +endi +if $data04 != 2 then + return -1 +endi #================================================= print =============== stop and restart taosd diff --git a/tests/script/tsim/query/scalarFunction.sim b/tests/script/tsim/query/scalarFunction.sim index 6a2a602703..9e6d378bd0 100644 --- a/tests/script/tsim/query/scalarFunction.sim +++ b/tests/script/tsim/query/scalarFunction.sim @@ -202,7 +202,7 @@ if $rows != $rowNum then endi print ====> sin -#sql select c1, sin(c1), sin(c1) * 3.14159265 / 180 from ct1 # TD-14426 +sql select c1, sin(c1), sin(c1) * 3.14159265 / 180 from ct1 sql select c1, sin(c1), c2, sin(c2), c3, sin(c3) from ct1 print ====> select c1, sin(c1), c2, sin(c2), c3, sin(c3) from ct1 print ====> rows: $rows diff --git a/tests/script/tsim/tmq/multiTopic.sim b/tests/script/tsim/tmq/multiTopic.sim new file mode 100644 index 0000000000..cd977e5909 --- /dev/null +++ b/tests/script/tsim/tmq/multiTopic.sim @@ -0,0 +1,224 @@ +#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406 +# scene1: vgroups=1, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb +# scene2: vgroups=1, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb +# scene3: vgroups=4, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb +# scene4: vgroups=4, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb +# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN +# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5; +# +# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval). +# +######## ######## ######## ######## ######## ######## ######## ######## ######## ######## +######## This test case include scene2 and scene4 +######## ######## ######## ######## ######## ######## ######## ######## ######## ######## + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 +system sh/exec.sh -n dnode1 -s start + +$loop_cnt = 0 +check_dnode_ready: + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 +if $data00 != 1 then + return -1 +endi +if $data04 != ready then + goto check_dnode_ready +endi + +sql connect + +$loop_cnt = 0 +$vgroups = 1 +$dbNamme = d0 +loop_vgroups: +print =============== create database $dbNamme vgroups $vgroups +sql create database $dbNamme vgroups $vgroups +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 + +if $loop_cnt == 0 then + if $rows != 2 then + return -1 + endi + if $data02 != 1 then # vgroups + print vgroups: $data02 + return -1 + endi +else + if $rows != 3 then + return -1 + endi + if $data00 == d1 then + if $data02 != 4 then # vgroups + print vgroups: $data02 + return -1 + endi + else + if $data12 != 4 then # vgroups + print vgroups: $data12 + return -1 + endi + endi +endi + +sql use $dbNamme + +print =============== create super table +sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 binary(10)) tags (t1 int) + +sql show stables +if $rows != 1 then + return -1 +endi + +print =============== create child table +$tbPrefix = ct +$tbNum = 100 + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using stb tags( $i ) + $i = $i + 1 +endw + +print =============== create normal table +sql create table ntb (ts timestamp, c1 int, c2 float, c3 binary(10)) + +print =============== create multi topics. notes: now only support: +print =============== 1. columns from stb/ctb/ntb; 2. * from ctb/ntb; 3. function from stb/ctb/ntb +print =============== will support: * from stb + +sql create topic topic_stb_column as select ts, c1, c3 from stb +#sql create topic topic_stb_all as select * from stb +sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb + +sql create topic topic_ctb_column as select ts, c1, c3 from ct0 +sql create topic topic_ctb_all as select * from ct0 +sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ct0 + +sql create topic topic_ntb_column as select ts, c1, c3 from ntb +sql create topic topic_ntb_all as select * from ntb +sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb + +sql show tables +if $rows != 101 then + return -1 +endi + +print =============== insert data +$rowNum = 100 +$tstart = 1640966400000 # 2022-01-01 00:00:00.000 + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + + $x = 0 + while $x < $rowNum + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + + $binary = ' . binary + $binary = $binary . $c + $binary = $binary . ' + + sql insert into $tb values ($tstart , $c , $x , $binary ) + sql insert into ntb values ($tstart , $c , $x , $binary ) + $tstart = $tstart + 1 + $x = $x + 1 + endw + + $i = $i + 1 + $tstart = 1640966400000 +endw + +#root@trd02 /home $ tmq_sim --help +# -c Configuration directory, default is +# -d The name of the database for cosumer, no default +# -t The topic string for cosumer, no default +# -k The key-value string for cosumer, no default +# -g showMsgFlag, default is 0 +# + +$totalMsgCnt = $rowNum * $tbNum +print inserted totalMsgCnt: $totalMsgCnt + +# supported key: +# group.id: +# enable.auto.commit: +# auto.offset.reset: +# td.connect.ip: +# td.connect.user:root +# td.connect.pass:taosdata +# td.connect.port:6030 +# td.connect.db:db + +$numOfTopics = 2 +$totalMsgCntOfmultiTopics = $totalMsgCnt * $numOfTopics +$expect_result = @{consume success: @ +$expect_result = $expect_result . $totalMsgCntOfmultiTopics +$expect_result = $expect_result . @, @ +$expect_result = $expect_result . 0} +print expect_result----> $expect_result +#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column, topic_stb_function, topic_stb_all" -k "group.id:tg2" +#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column, topic_stb_function, topic_stb_all" -k "group.id:tg2" +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column, topic_stb_function" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column, topic_stb_function" -k "group.id:tg2" +print cmd result----> $system_content +#if $system_content != @{consume success: 20000, 0}@ then +if $system_content != $expect_result then + return -1 +endi + +$numOfTopics = 3 +$totalMsgCntOfmultiTopics = $rowNum * $numOfTopics +$expect_result = @{consume success: @ +$expect_result = $expect_result . $totalMsgCntOfmultiTopics +$expect_result = $expect_result . @, @ +$expect_result = $expect_result . 0} +print expect_result----> $expect_result +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column, topic_ctb_function, topic_ctb_all" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column, topic_ctb_function, topic_ctb_all" -k "group.id:tg2" +print cmd result----> $system_content +#if $system_content != @{consume success: 300, 0}@ then +if $system_content != $expect_result then + return -1 +endi + +$numOfTopics = 3 +$totalMsgCntOfmultiTopics = $totalMsgCnt * $numOfTopics +$expect_result = @{consume success: @ +$expect_result = $expect_result . $totalMsgCntOfmultiTopics +$expect_result = $expect_result . @, @ +$expect_result = $expect_result . 0} +print expect_result----> $expect_result +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column, topic_ntb_all, topic_ntb_function" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column, topic_ntb_all, topic_ntb_function" -k "group.id:tg2" +print cmd result----> $system_content +#if $system_content != @{consume success: 30000, 0}@ then +if $system_content != $expect_result then + return -1 +endi + +if $loop_cnt == 0 then + $loop_cnt = 1 + $vgroups = 4 + $dbNamme = d1 + goto loop_vgroups +endi + + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/script/tsim/tmq/oneTopic.sim b/tests/script/tsim/tmq/oneTopic.sim new file mode 100644 index 0000000000..8e8d00977c --- /dev/null +++ b/tests/script/tsim/tmq/oneTopic.sim @@ -0,0 +1,264 @@ +#### test scenario, please refer to https://jira.taosdata.com:18090/pages/viewpage.action?pageId=135120406 +# scene1: vgroups=1, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb +# scene2: vgroups=1, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb +# scene3: vgroups=4, one topic for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb +# scene4: vgroups=4, multi topics for one consumer, include: columns from stb/ctb/ntb, * from stb/ctb/ntb, Scalar function from stb/ctb/ntb +# notes1: Scalar function: ABS/ACOS/ASIN/ATAN/CEIL/COS/FLOOR/LOG/POW/ROUND/SIN/SQRT/TAN +# The above use cases are combined with where filter conditions, such as: where ts > "2017-08-12 18:25:58.128Z" and sin(a) > 0.5; +# +# notes2: not support aggregate functions(such as sum/count/min/max) and time-windows(interval). +# +######## ######## ######## ######## ######## ######## ######## ######## ######## ######## +######## This test case include scene1 and scene3 +######## ######## ######## ######## ######## ######## ######## ######## ######## ######## + +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/cfg.sh -n dnode1 +system sh/exec.sh -n dnode1 -s start + +$loop_cnt = 0 +check_dnode_ready: + $loop_cnt = $loop_cnt + 1 + sleep 200 + if $loop_cnt == 10 then + print ====> dnode not ready! + return -1 + endi +sql show dnodes +print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05 +if $data00 != 1 then + return -1 +endi +if $data04 != ready then + goto check_dnode_ready +endi + +sql connect + +$loop_cnt = 0 +$vgroups = 1 +$dbNamme = d0 +loop_vgroups: +print =============== create database $dbNamme vgroups $vgroups +sql create database $dbNamme vgroups $vgroups +sql show databases +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09 +print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19 +print $data20 $data21 $data22 $data23 $data24 $data25 $data26 $data27 $data28 $data29 + +if $loop_cnt == 0 then + if $rows != 2 then + return -1 + endi + if $data02 != 1 then # vgroups + print vgroups: $data02 + return -1 + endi +else + if $rows != 3 then + return -1 + endi + if $data00 == d1 then + if $data02 != 4 then # vgroups + print vgroups: $data02 + return -1 + endi + else + if $data12 != 4 then # vgroups + print vgroups: $data12 + return -1 + endi + endi +endi + +sql use $dbNamme + +print =============== create super table +sql create table if not exists stb (ts timestamp, c1 int, c2 float, c3 binary(10)) tags (t1 int) + +sql show stables +if $rows != 1 then + return -1 +endi + +print =============== create child table +$tbPrefix = ct +$tbNum = 100 + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + sql create table $tb using stb tags( $i ) + $i = $i + 1 +endw + +print =============== create normal table +sql create table ntb (ts timestamp, c1 int, c2 float, c3 binary(10)) + +print =============== create multi topics. notes: now only support: +print =============== 1. columns from stb/ctb/ntb; 2. * from ctb/ntb; 3. function from stb/ctb/ntb +print =============== will support: * from stb + +sql create topic topic_stb_column as select ts, c1, c3 from stb +#sql create topic topic_stb_all as select * from stb +sql create topic topic_stb_function as select ts, abs(c1), sin(c2) from stb + +sql create topic topic_ctb_column as select ts, c1, c3 from ct0 +sql create topic topic_ctb_all as select * from ct0 +sql create topic topic_ctb_function as select ts, abs(c1), sin(c2) from ct0 + +sql create topic topic_ntb_column as select ts, c1, c3 from ntb +sql create topic topic_ntb_all as select * from ntb +sql create topic topic_ntb_function as select ts, abs(c1), sin(c2) from ntb + +sql show tables +if $rows != 101 then + return -1 +endi + +print =============== insert data +$rowNum = 100 +$tstart = 1640966400000 # 2022-01-01 00:00:00.000 + +$i = 0 +while $i < $tbNum + $tb = $tbPrefix . $i + + $x = 0 + while $x < $rowNum + $c = $x / 10 + $c = $c * 10 + $c = $x - $c + + $binary = ' . binary + $binary = $binary . $c + $binary = $binary . ' + + sql insert into $tb values ($tstart , $c , $x , $binary ) + sql insert into ntb values ($tstart , $c , $x , $binary ) + $tstart = $tstart + 1 + $x = $x + 1 + endw + + $i = $i + 1 + $tstart = 1640966400000 +endw + +#root@trd02 /home $ tmq_sim --help +# -c Configuration directory, default is +# -d The name of the database for cosumer, no default +# -t The topic string for cosumer, no default +# -k The key-value string for cosumer, no default +# -g showMsgFlag, default is 0 +# + +$totalMsgCnt = $rowNum * $tbNum +print inserted totalMsgCnt: $totalMsgCnt + +# supported key: +# group.id: +# enable.auto.commit: +# auto.offset.reset: +# td.connect.ip: +# td.connect.user:root +# td.connect.pass:taosdata +# td.connect.port:6030 +# td.connect.db:db + +$expect_result = @{consume success: @ +$expect_result = $expect_result . $totalMsgCnt +$expect_result = $expect_result . @, @ +$expect_result = $expect_result . 0} +print expect_result----> $expect_result +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_column" -k "group.id:tg2" +print cmd result----> $system_content +#if $system_content != @{consume success: 10000, 0}@ then +if $system_content != $expect_result then + return -1 +endi + +#print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_all" -k "group.id:tg2" +#system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_all" -k "group.id:tg2" +#print cmd result----> $system_content +##if $system_content != @{consume success: 10000, 0}@ then +#if $system_content != $expect_result then +# return -1 +#endi + +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_function" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_stb_function" -k "group.id:tg2" +print cmd result----> $system_content +#if $system_content != @{consume success: 10000, 0}@ then +if $system_content != $expect_result then + return -1 +endi + +$expect_result = @{consume success: @ +$expect_result = $expect_result . $rowNum +$expect_result = $expect_result . @, @ +$expect_result = $expect_result . 0} +print expect_result----> $expect_result +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_column" -k "group.id:tg2" +print cmd result----> $system_content +#if $system_content != @{consume success: 100, 0}@ then +if $system_content != $expect_result then + return -1 +endi + +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_all" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_all" -k "group.id:tg2" +print cmd result----> $system_content +#if $system_content != @{consume success: 100, 0}@ then +if $system_content != $expect_result then + return -1 +endi + +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_function" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ctb_function" -k "group.id:tg2" +print cmd result----> $system_content +#if $system_content != @{consume success: 100, 0}@ then +if $system_content != $expect_result then + return -1 +endi + +$expect_result = @{consume success: @ +$expect_result = $expect_result . $totalMsgCnt +$expect_result = $expect_result . @, @ +$expect_result = $expect_result . 0} +print expect_result----> $expect_result +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_column" -k "group.id:tg2" +print cmd result----> $system_content +#if $system_content != @{consume success: 10000, 0}@ then +if $system_content != $expect_result then + return -1 +endi + +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_all" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_all" -k "group.id:tg2" +print cmd result----> $system_content +#if $system_content != @{consume success: 10000, 0}@ then +if $system_content != $expect_result then + return -1 +endi + +print cmd===> system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_function" -k "group.id:tg2" +system_content ../../debug/tests/test/c/tmq_sim -c ../../sim/tsim/cfg -d $dbNamme -t "topic_ntb_function" -k "group.id:tg2" +print cmd result----> $system_content +#if $system_content != @{consume success: 10000, 0}@ then +if $system_content != $expect_result then + return -1 +endi + +if $loop_cnt == 0 then + $loop_cnt = 1 + $vgroups = 4 + $dbNamme = d1 + goto loop_vgroups +endi + + +#system sh/exec.sh -n dnode1 -s stop -x SIGINT