diff --git a/Jenkinsfile2 b/Jenkinsfile2 index e9372ab686..05ba85b091 100644 --- a/Jenkinsfile2 +++ b/Jenkinsfile2 @@ -454,7 +454,7 @@ pipeline { cd ${WKC}/tests/parallel_test export DEFAULT_RETRY_TIME=2 date - ''' + timeout_cmd + ''' time ./run.sh -e -m /home/m.json -t cases.task -b ${BRANCH_NAME}_${BUILD_ID} -l ${WKDIR}/log -o 600 ''' + extra_param + ''' + ''' + timeout_cmd + ''' time ./run.sh -e -m /home/m.json -t cases.task -b ${BRANCH_NAME}_${BUILD_ID} -l ${WKDIR}/log -o 900 ''' + extra_param + ''' ''' } } diff --git a/include/common/systable.h b/include/common/systable.h index 77fd18da39..34d46953f6 100644 --- a/include/common/systable.h +++ b/include/common/systable.h @@ -56,6 +56,7 @@ extern "C" { #define TSDB_INS_TABLE_GRANTS_FULL "ins_grants_full" #define TSDB_INS_TABLE_GRANTS_LOGS "ins_grants_logs" #define TSDB_INS_TABLE_MACHINES "ins_machines" +#define TSDB_INS_TABLE_TSMAS "ins_tsmas" #define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema" #define TSDB_PERFS_TABLE_SMAS "perf_smas" diff --git a/include/common/tcommon.h b/include/common/tcommon.h index bdf5f99083..34f28a8150 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -414,6 +414,18 @@ typedef struct STUidTagInfo { int32_t taosGenCrashJsonMsg(int signum, char **pMsg, int64_t clusterId, int64_t startTime); +#define TSMA_RES_STB_POSTFIX "_tsma_res_stb_" +#define MD5_OUTPUT_LEN 32 +#define TSMA_RES_STB_EXTRA_COLUMN_NUM 4 // 3 columns: _wstart, _wend, _wduration, 1 tag: tbname + +static inline bool isTsmaResSTb(const char* stbName) { + const char* pos = strstr(stbName, TSMA_RES_STB_POSTFIX); + if (pos && strlen(stbName) == (pos - stbName) + strlen(TSMA_RES_STB_POSTFIX)) { + return true; + } + return false; +} + #ifdef __cplusplus } #endif diff --git a/include/common/tglobal.h b/include/common/tglobal.h index 96488f3bd5..c2cb27c8b6 100644 --- a/include/common/tglobal.h +++ b/include/common/tglobal.h @@ -201,6 +201,8 @@ extern char tsSmlTsDefaultName[]; extern int32_t tmqMaxTopicNum; extern int32_t tmqRowSize; +extern int32_t tsMaxTsmaNum; +extern int32_t tsMaxTsmaCalcDelay; // wal extern int64_t tsWalFsyncDataSizeLimit; diff --git a/include/common/tmsg.h b/include/common/tmsg.h index 1e3deed987..c220d13703 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -110,6 +110,7 @@ enum { HEARTBEAT_KEY_TMQ, HEARTBEAT_KEY_DYN_VIEW, HEARTBEAT_KEY_VIEWINFO, + HEARTBEAT_KEY_TSMA, }; typedef enum _mgmt_table { @@ -145,6 +146,7 @@ typedef enum _mgmt_table { TSDB_MGMT_TABLE_STREAM_TASKS, TSDB_MGMT_TABLE_PRIVILEGES, TSDB_MGMT_TABLE_VIEWS, + TSDB_MGMT_TABLE_TSMAS, TSDB_MGMT_TABLE_COMPACT, TSDB_MGMT_TABLE_COMPACT_DETAIL, TSDB_MGMT_TABLE_GRANTS_FULL, @@ -247,6 +249,7 @@ typedef enum ENodeType { QUERY_NODE_VIEW, QUERY_NODE_WINDOW_OFFSET, QUERY_NODE_COUNT_WINDOW, + QUERY_NODE_TSMA_OPTIONS, // Statement nodes are used in parser and planner module. QUERY_NODE_SET_OPERATOR = 100, @@ -368,6 +371,10 @@ typedef enum ENodeType { QUERY_NODE_SHOW_GRANTS_FULL_STMT, QUERY_NODE_SHOW_GRANTS_LOGS_STMT, QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT, + QUERY_NODE_SHOW_TSMAS_STMT, + QUERY_NODE_CREATE_TSMA_STMT, + QUERY_NODE_SHOW_CREATE_TSMA_STMT, + QUERY_NODE_DROP_TSMA_STMT, // logic plan node QUERY_NODE_LOGIC_PLAN_SCAN = 1000, @@ -440,9 +447,9 @@ typedef enum ENodeType { } ENodeType; typedef struct { - int32_t vgId; - char* dbFName; - char* tbName; + int32_t vgId; + const char* dbFName; + const char* tbName; } SBuildTableInput; typedef struct { @@ -1397,8 +1404,14 @@ int32_t tDeserializeSDnodeListRsp(void* buf, int32_t bufLen, SDnodeListRsp* pRsp void tFreeSDnodeListRsp(SDnodeListRsp* pRsp); typedef struct { - SUseDbRsp* useDbRsp; - SDbCfgRsp* cfgRsp; + SArray* pTsmas; // SArray +} STableTSMAInfoRsp; + +typedef struct { + SUseDbRsp* useDbRsp; + SDbCfgRsp* cfgRsp; + STableTSMAInfoRsp* pTsmaRsp; + int32_t dbTsmaVersion; } SDbHbRsp; typedef struct { @@ -2597,6 +2610,7 @@ typedef struct { SArray* pVgroupVerList; // 3.3.0.0 SArray* pCols; // array of SField + int64_t smaId; } SCMCreateStreamReq; typedef struct { @@ -3561,6 +3575,10 @@ typedef struct { char* ast; int64_t deleteMark; int64_t lastTs; + int64_t normSourceTbUid; // the Uid of source tb if its a normal table, otherwise 0 + SArray* pVgroupVerList; + int8_t recursiveTsma; + char baseTsmaName[TSDB_TABLE_FNAME_LEN]; // base tsma name for recursively created tsma } SMCreateSmaReq; int32_t tSerializeSMCreateSmaReq(void* buf, int32_t bufLen, SMCreateSmaReq* pReq); @@ -4184,6 +4202,104 @@ typedef struct { int32_t tSerializeSViewMetaRsp(void* buf, int32_t bufLen, const SViewMetaRsp* pRsp); int32_t tDeserializeSViewMetaRsp(void* buf, int32_t bufLen, SViewMetaRsp* pRsp); void tFreeSViewMetaRsp(SViewMetaRsp* pRsp); +typedef struct { + char name[TSDB_TABLE_FNAME_LEN]; // table name or tsma name + bool fetchingWithTsmaName; // if we are fetching with tsma name +}STableTSMAInfoReq; + +int32_t tSerializeTableTSMAInfoReq(void* buf, int32_t bufLen, const STableTSMAInfoReq* pReq); +int32_t tDeserializeTableTSMAInfoReq(void* buf, int32_t bufLen, STableTSMAInfoReq* pReq); + +typedef struct { + int32_t funcId; + col_id_t colId; +} STableTSMAFuncInfo; + +typedef struct { + char name[TSDB_TABLE_NAME_LEN]; + uint64_t tsmaId; + char targetTb[TSDB_TABLE_NAME_LEN]; + char targetDbFName[TSDB_DB_FNAME_LEN]; + char tb[TSDB_TABLE_NAME_LEN]; + char dbFName[TSDB_DB_FNAME_LEN]; + uint64_t suid; + uint64_t destTbUid; + uint64_t dbId; + int32_t version; + int64_t interval; + int8_t unit; + SArray* pFuncs; // SArray + SArray* pTags; // SArray + SArray* pUsedCols; // SArray + char* ast; + + int64_t streamUid; + int64_t reqTs; + int64_t rspTs; + int64_t delayDuration; // ms + bool fillHistoryFinished; +} STableTSMAInfo; + +int32_t tSerializeTableTSMAInfoRsp(void* buf, int32_t bufLen, const STableTSMAInfoRsp* pRsp); +int32_t tDeserializeTableTSMAInfoRsp(void* buf, int32_t bufLen, STableTSMAInfoRsp* pRsp); +int32_t tCloneTbTSMAInfo(STableTSMAInfo* pInfo, STableTSMAInfo** pRes); +void tFreeTableTSMAInfo(void* p); +void tFreeAndClearTableTSMAInfo(void* p); +void tFreeTableTSMAInfoRsp(STableTSMAInfoRsp* pRsp); + +#define STSMAHbRsp STableTSMAInfoRsp +#define tSerializeTSMAHbRsp tSerializeTableTSMAInfoRsp +#define tDeserializeTSMAHbRsp tDeserializeTableTSMAInfoRsp +#define tFreeTSMAHbRsp tFreeTableTSMAInfoRsp + +typedef struct SStreamProgressReq { + int64_t streamId; + int32_t vgId; + int32_t fetchIdx; + int32_t subFetchIdx; +} SStreamProgressReq; + +int32_t tSerializeStreamProgressReq(void* buf, int32_t bufLen, const SStreamProgressReq* pReq); +int32_t tDeserializeStreamProgressReq(void* buf, int32_t bufLen, SStreamProgressReq* pReq); + +typedef struct SStreamProgressRsp { + int64_t streamId; + int32_t vgId; + bool fillHisFinished; + int64_t progressDelay; + int32_t fetchIdx; + int32_t subFetchIdx; +} SStreamProgressRsp; + +int32_t tSerializeStreamProgressRsp(void* buf, int32_t bufLen, const SStreamProgressRsp* pRsp); +int32_t tDeserializeSStreamProgressRsp(void* buf, int32_t bufLen, SStreamProgressRsp* pRsp); + +typedef struct SDropCtbWithTsmaSingleVgReq { + SVgroupInfo vgInfo; + SArray* pTbs; // SVDropTbReq +} SMDropTbReqsOnSingleVg; + +int32_t tEncodeSMDropTbReqOnSingleVg(SEncoder* pEncoder, const SMDropTbReqsOnSingleVg* pReq); +int32_t tDecodeSMDropTbReqOnSingleVg(SDecoder* pDecoder, SMDropTbReqsOnSingleVg* pReq); +void tFreeSMDropTbReqOnSingleVg(void* p); + +typedef struct SDropTbsReq { + SArray* pVgReqs; // SMDropTbReqsOnSingleVg +} SMDropTbsReq; + +int32_t tSerializeSMDropTbsReq(void* buf, int32_t bufLen, const SMDropTbsReq* pReq); +int32_t tDeserializeSMDropTbsReq(void* buf, int32_t bufLen, SMDropTbsReq* pReq); +void tFreeSMDropTbsReq(void*); + +typedef struct SVFetchTtlExpiredTbsRsp { + SArray* pExpiredTbs; // SVDropTbReq + int32_t vgId; +} SVFetchTtlExpiredTbsRsp; + +int32_t tEncodeVFetchTtlExpiredTbsRsp(SEncoder* pCoder, const SVFetchTtlExpiredTbsRsp* pRsp); +int32_t tDecodeVFetchTtlExpiredTbsRsp(SDecoder* pCoder, SVFetchTtlExpiredTbsRsp* pRsp); + +void tFreeFetchTtlExpiredTbsRsp(void* p); #pragma pack(pop) diff --git a/include/common/tmsgdef.h b/include/common/tmsgdef.h index b9f31b8f1f..d897437d1d 100644 --- a/include/common/tmsgdef.h +++ b/include/common/tmsgdef.h @@ -223,6 +223,12 @@ TD_DEF_MSG_TYPE(TDMT_MND_S3MIGRATE_DB, "s3migrate-db", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_S3MIGRATE_DB_TIMER, "s3migrate-db-tmr", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_MND_MAX_MSG, "mnd-max", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_CREATE_TSMA, "create-tsma", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_DROP_TSMA, "drop-tsma", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_STB_DROP, "drop-stb", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_GET_TABLE_TSMA, "get-table-tsma", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_GET_TSMA, "get-tsma", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_MND_DROP_TB_WITH_TSMA, "drop-tb-with-tsma", NULL, NULL) TD_CLOSE_MSG_SEG(TDMT_END_MND_MSG) TD_NEW_MSG_SEG(TDMT_VND_MSG) // 2<<8 @@ -267,6 +273,7 @@ TD_DEF_MSG_TYPE(TDMT_VND_ALTER_HASHRANGE, "alter-hashrange", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_COMPACT, "vnode-compact", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_DROP_TTL_TABLE, "vnode-drop-ttl-stb", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_VND_FETCH_TTL_EXPIRED_TBS, "vnode-fetch-ttl-expired-tbs", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_TRIM, "vnode-trim", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_COMMIT, "vnode-commit", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_CREATE_INDEX, "vnode-create-index", NULL, NULL) @@ -310,6 +317,8 @@ TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_RESUME, "stream-task-resume", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_STREAM_TASK_STOP, "stream-task-stop", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_STREAM_MAX_MSG, "stream-max", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_STREAM_CREATE, "stream-create", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_STREAM_DROP, "stream-drop", NULL, NULL) TD_CLOSE_MSG_SEG(TDMT_END_STREAM_MSG) TD_NEW_MSG_SEG(TDMT_MON_MSG) //5 << 8 @@ -357,6 +366,7 @@ TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TASK_RESET, "vnode-stream-reset", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_STREAM_TASK_CHECK, "vnode-stream-task-check", NULL, NULL) TD_DEF_MSG_TYPE(TDMT_VND_STREAM_MAX_MSG, "vnd-stream-max", NULL, NULL) + TD_DEF_MSG_TYPE(TDMT_VND_GET_STREAM_PROGRESS, "vnd-stream-progress", NULL, NULL) TD_CLOSE_MSG_SEG(TDMT_END_VND_STREAM_MSG) TD_NEW_MSG_SEG(TDMT_VND_TMQ_MSG) //8 << 8 diff --git a/include/common/ttime.h b/include/common/ttime.h index bd123c860e..d890b729d4 100644 --- a/include/common/ttime.h +++ b/include/common/ttime.h @@ -88,6 +88,7 @@ char getPrecisionUnit(int32_t precision); int64_t convertTimePrecision(int64_t ts, int32_t fromPrecision, int32_t toPrecision); int64_t convertTimeFromPrecisionToUnit(int64_t ts, int32_t fromPrecision, char toUnit); int32_t convertStringToTimestamp(int16_t type, char* inputData, int64_t timePrec, int64_t* timeVal); +int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision); void taosFormatUtcTime(char* buf, int32_t bufLen, int64_t ts, int32_t precision); diff --git a/include/common/ttokendef.h b/include/common/ttokendef.h index 4b2ac1c95b..5254a99d85 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -16,105 +16,105 @@ #ifndef _TD_COMMON_TOKEN_H_ #define _TD_COMMON_TOKEN_H_ -#define TK_OR 1 -#define TK_AND 2 -#define TK_UNION 3 -#define TK_ALL 4 -#define TK_MINUS 5 -#define TK_EXCEPT 6 -#define TK_INTERSECT 7 -#define TK_NK_BITAND 8 -#define TK_NK_BITOR 9 -#define TK_NK_LSHIFT 10 -#define TK_NK_RSHIFT 11 -#define TK_NK_PLUS 12 -#define TK_NK_MINUS 13 -#define TK_NK_STAR 14 -#define TK_NK_SLASH 15 -#define TK_NK_REM 16 -#define TK_NK_CONCAT 17 -#define TK_CREATE 18 -#define TK_ACCOUNT 19 -#define TK_NK_ID 20 -#define TK_PASS 21 -#define TK_NK_STRING 22 -#define TK_ALTER 23 -#define TK_PPS 24 -#define TK_TSERIES 25 -#define TK_STORAGE 26 -#define TK_STREAMS 27 -#define TK_QTIME 28 -#define TK_DBS 29 -#define TK_USERS 30 -#define TK_CONNS 31 -#define TK_STATE 32 -#define TK_NK_COMMA 33 -#define TK_HOST 34 -#define TK_USER 35 -#define TK_ENABLE 36 -#define TK_NK_INTEGER 37 -#define TK_SYSINFO 38 -#define TK_ADD 39 -#define TK_DROP 40 -#define TK_GRANT 41 -#define TK_ON 42 -#define TK_TO 43 -#define TK_REVOKE 44 -#define TK_FROM 45 -#define TK_SUBSCRIBE 46 -#define TK_READ 47 -#define TK_WRITE 48 -#define TK_NK_DOT 49 -#define TK_WITH 50 -#define TK_DNODE 51 -#define TK_PORT 52 -#define TK_DNODES 53 -#define TK_RESTORE 54 -#define TK_NK_IPTOKEN 55 -#define TK_FORCE 56 -#define TK_UNSAFE 57 -#define TK_CLUSTER 58 -#define TK_LOCAL 59 -#define TK_QNODE 60 -#define TK_BNODE 61 -#define TK_SNODE 62 -#define TK_MNODE 63 -#define TK_VNODE 64 -#define TK_DATABASE 65 -#define TK_USE 66 -#define TK_FLUSH 67 -#define TK_TRIM 68 -#define TK_S3MIGRATE 69 -#define TK_COMPACT 70 -#define TK_IF 71 -#define TK_NOT 72 -#define TK_EXISTS 73 -#define TK_BUFFER 74 -#define TK_CACHEMODEL 75 -#define TK_CACHESIZE 76 -#define TK_COMP 77 -#define TK_DURATION 78 -#define TK_NK_VARIABLE 79 -#define TK_MAXROWS 80 -#define TK_MINROWS 81 -#define TK_KEEP 82 -#define TK_PAGES 83 -#define TK_PAGESIZE 84 -#define TK_TSDB_PAGESIZE 85 -#define TK_PRECISION 86 -#define TK_REPLICA 87 -#define TK_VGROUPS 88 -#define TK_SINGLE_STABLE 89 -#define TK_RETENTIONS 90 -#define TK_SCHEMALESS 91 -#define TK_WAL_LEVEL 92 -#define TK_WAL_FSYNC_PERIOD 93 -#define TK_WAL_RETENTION_PERIOD 94 -#define TK_WAL_RETENTION_SIZE 95 -#define TK_WAL_ROLL_PERIOD 96 -#define TK_WAL_SEGMENT_SIZE 97 -#define TK_STT_TRIGGER 98 -#define TK_TABLE_PREFIX 99 +#define TK_OR 1 +#define TK_AND 2 +#define TK_UNION 3 +#define TK_ALL 4 +#define TK_MINUS 5 +#define TK_EXCEPT 6 +#define TK_INTERSECT 7 +#define TK_NK_BITAND 8 +#define TK_NK_BITOR 9 +#define TK_NK_LSHIFT 10 +#define TK_NK_RSHIFT 11 +#define TK_NK_PLUS 12 +#define TK_NK_MINUS 13 +#define TK_NK_STAR 14 +#define TK_NK_SLASH 15 +#define TK_NK_REM 16 +#define TK_NK_CONCAT 17 +#define TK_CREATE 18 +#define TK_ACCOUNT 19 +#define TK_NK_ID 20 +#define TK_PASS 21 +#define TK_NK_STRING 22 +#define TK_ALTER 23 +#define TK_PPS 24 +#define TK_TSERIES 25 +#define TK_STORAGE 26 +#define TK_STREAMS 27 +#define TK_QTIME 28 +#define TK_DBS 29 +#define TK_USERS 30 +#define TK_CONNS 31 +#define TK_STATE 32 +#define TK_NK_COMMA 33 +#define TK_HOST 34 +#define TK_USER 35 +#define TK_ENABLE 36 +#define TK_NK_INTEGER 37 +#define TK_SYSINFO 38 +#define TK_ADD 39 +#define TK_DROP 40 +#define TK_GRANT 41 +#define TK_ON 42 +#define TK_TO 43 +#define TK_REVOKE 44 +#define TK_FROM 45 +#define TK_SUBSCRIBE 46 +#define TK_READ 47 +#define TK_WRITE 48 +#define TK_NK_DOT 49 +#define TK_WITH 50 +#define TK_DNODE 51 +#define TK_PORT 52 +#define TK_DNODES 53 +#define TK_RESTORE 54 +#define TK_NK_IPTOKEN 55 +#define TK_FORCE 56 +#define TK_UNSAFE 57 +#define TK_CLUSTER 58 +#define TK_LOCAL 59 +#define TK_QNODE 60 +#define TK_BNODE 61 +#define TK_SNODE 62 +#define TK_MNODE 63 +#define TK_VNODE 64 +#define TK_DATABASE 65 +#define TK_USE 66 +#define TK_FLUSH 67 +#define TK_TRIM 68 +#define TK_S3MIGRATE 69 +#define TK_COMPACT 70 +#define TK_IF 71 +#define TK_NOT 72 +#define TK_EXISTS 73 +#define TK_BUFFER 74 +#define TK_CACHEMODEL 75 +#define TK_CACHESIZE 76 +#define TK_COMP 77 +#define TK_DURATION 78 +#define TK_NK_VARIABLE 79 +#define TK_MAXROWS 80 +#define TK_MINROWS 81 +#define TK_KEEP 82 +#define TK_PAGES 83 +#define TK_PAGESIZE 84 +#define TK_TSDB_PAGESIZE 85 +#define TK_PRECISION 86 +#define TK_REPLICA 87 +#define TK_VGROUPS 88 +#define TK_SINGLE_STABLE 89 +#define TK_RETENTIONS 90 +#define TK_SCHEMALESS 91 +#define TK_WAL_LEVEL 92 +#define TK_WAL_FSYNC_PERIOD 93 +#define TK_WAL_RETENTION_PERIOD 94 +#define TK_WAL_RETENTION_SIZE 95 +#define TK_WAL_ROLL_PERIOD 96 +#define TK_WAL_SEGMENT_SIZE 97 +#define TK_STT_TRIGGER 98 +#define TK_TABLE_PREFIX 99 #define TK_TABLE_SUFFIX 100 #define TK_S3_CHUNKSIZE 101 #define TK_S3_KEEPLOCAL 102 @@ -206,184 +206,185 @@ #define TK_QTAGS 188 #define TK_AS 189 #define TK_SYSTEM 190 -#define TK_INDEX 191 -#define TK_FUNCTION 192 -#define TK_INTERVAL 193 -#define TK_COUNT 194 -#define TK_LAST_ROW 195 -#define TK_META 196 -#define TK_ONLY 197 -#define TK_TOPIC 198 -#define TK_CONSUMER 199 -#define TK_GROUP 200 -#define TK_DESC 201 -#define TK_DESCRIBE 202 -#define TK_RESET 203 -#define TK_QUERY 204 -#define TK_CACHE 205 -#define TK_EXPLAIN 206 -#define TK_ANALYZE 207 -#define TK_VERBOSE 208 -#define TK_NK_BOOL 209 -#define TK_RATIO 210 -#define TK_NK_FLOAT 211 -#define TK_OUTPUTTYPE 212 -#define TK_AGGREGATE 213 -#define TK_BUFSIZE 214 -#define TK_LANGUAGE 215 -#define TK_REPLACE 216 -#define TK_STREAM 217 -#define TK_INTO 218 -#define TK_PAUSE 219 -#define TK_RESUME 220 -#define TK_TRIGGER 221 -#define TK_AT_ONCE 222 -#define TK_WINDOW_CLOSE 223 -#define TK_IGNORE 224 -#define TK_EXPIRED 225 -#define TK_FILL_HISTORY 226 -#define TK_UPDATE 227 -#define TK_SUBTABLE 228 -#define TK_UNTREATED 229 -#define TK_KILL 230 -#define TK_CONNECTION 231 -#define TK_TRANSACTION 232 -#define TK_BALANCE 233 -#define TK_VGROUP 234 -#define TK_LEADER 235 -#define TK_MERGE 236 -#define TK_REDISTRIBUTE 237 -#define TK_SPLIT 238 -#define TK_DELETE 239 -#define TK_INSERT 240 -#define TK_NK_BIN 241 -#define TK_NK_HEX 242 -#define TK_NULL 243 -#define TK_NK_QUESTION 244 -#define TK_NK_ALIAS 245 -#define TK_NK_ARROW 246 -#define TK_ROWTS 247 -#define TK_QSTART 248 -#define TK_QEND 249 -#define TK_QDURATION 250 -#define TK_WSTART 251 -#define TK_WEND 252 -#define TK_WDURATION 253 -#define TK_IROWTS 254 -#define TK_ISFILLED 255 -#define TK_CAST 256 -#define TK_NOW 257 -#define TK_TODAY 258 -#define TK_TIMEZONE 259 -#define TK_CLIENT_VERSION 260 -#define TK_SERVER_VERSION 261 -#define TK_SERVER_STATUS 262 -#define TK_CURRENT_USER 263 -#define TK_CASE 264 -#define TK_WHEN 265 -#define TK_THEN 266 -#define TK_ELSE 267 -#define TK_BETWEEN 268 -#define TK_IS 269 -#define TK_NK_LT 270 -#define TK_NK_GT 271 -#define TK_NK_LE 272 -#define TK_NK_GE 273 -#define TK_NK_NE 274 -#define TK_MATCH 275 -#define TK_NMATCH 276 -#define TK_CONTAINS 277 -#define TK_IN 278 -#define TK_JOIN 279 -#define TK_INNER 280 -#define TK_LEFT 281 -#define TK_RIGHT 282 -#define TK_OUTER 283 -#define TK_SEMI 284 -#define TK_ANTI 285 -#define TK_ASOF 286 -#define TK_WINDOW 287 -#define TK_WINDOW_OFFSET 288 -#define TK_JLIMIT 289 -#define TK_SELECT 290 -#define TK_NK_HINT 291 -#define TK_DISTINCT 292 -#define TK_WHERE 293 -#define TK_PARTITION 294 -#define TK_BY 295 -#define TK_SESSION 296 -#define TK_STATE_WINDOW 297 -#define TK_EVENT_WINDOW 298 -#define TK_COUNT_WINDOW 299 -#define TK_SLIDING 300 -#define TK_FILL 301 -#define TK_VALUE 302 -#define TK_VALUE_F 303 -#define TK_NONE 304 -#define TK_PREV 305 -#define TK_NULL_F 306 -#define TK_LINEAR 307 -#define TK_NEXT 308 -#define TK_HAVING 309 -#define TK_RANGE 310 -#define TK_EVERY 311 -#define TK_ORDER 312 -#define TK_SLIMIT 313 -#define TK_SOFFSET 314 -#define TK_LIMIT 315 -#define TK_OFFSET 316 -#define TK_ASC 317 -#define TK_NULLS 318 -#define TK_ABORT 319 -#define TK_AFTER 320 -#define TK_ATTACH 321 -#define TK_BEFORE 322 -#define TK_BEGIN 323 -#define TK_BITAND 324 -#define TK_BITNOT 325 -#define TK_BITOR 326 -#define TK_BLOCKS 327 -#define TK_CHANGE 328 -#define TK_COMMA 329 -#define TK_CONCAT 330 -#define TK_CONFLICT 331 -#define TK_COPY 332 -#define TK_DEFERRED 333 -#define TK_DELIMITERS 334 -#define TK_DETACH 335 -#define TK_DIVIDE 336 -#define TK_DOT 337 -#define TK_EACH 338 -#define TK_FAIL 339 -#define TK_FILE 340 -#define TK_FOR 341 -#define TK_GLOB 342 -#define TK_ID 343 -#define TK_IMMEDIATE 344 -#define TK_IMPORT 345 -#define TK_INITIALLY 346 -#define TK_INSTEAD 347 -#define TK_ISNULL 348 -#define TK_MODULES 349 -#define TK_NK_BITNOT 350 -#define TK_NK_SEMI 351 -#define TK_NOTNULL 352 -#define TK_OF 353 -#define TK_PLUS 354 -#define TK_PRIVILEGE 355 -#define TK_RAISE 356 -#define TK_RESTRICT 357 -#define TK_ROW 358 -#define TK_STAR 359 -#define TK_STATEMENT 360 -#define TK_STRICT 361 -#define TK_STRING 362 -#define TK_TIMES 363 -#define TK_VALUES 364 -#define TK_VARIABLE 365 -#define TK_WAL 366 - - +#define TK_TSMA 191 +#define TK_INTERVAL 192 +#define TK_RECURSIVE 193 +#define TK_TSMAS 194 +#define TK_FUNCTION 195 +#define TK_INDEX 196 +#define TK_COUNT 197 +#define TK_LAST_ROW 198 +#define TK_META 199 +#define TK_ONLY 200 +#define TK_TOPIC 201 +#define TK_CONSUMER 202 +#define TK_GROUP 203 +#define TK_DESC 204 +#define TK_DESCRIBE 205 +#define TK_RESET 206 +#define TK_QUERY 207 +#define TK_CACHE 208 +#define TK_EXPLAIN 209 +#define TK_ANALYZE 210 +#define TK_VERBOSE 211 +#define TK_NK_BOOL 212 +#define TK_RATIO 213 +#define TK_NK_FLOAT 214 +#define TK_OUTPUTTYPE 215 +#define TK_AGGREGATE 216 +#define TK_BUFSIZE 217 +#define TK_LANGUAGE 218 +#define TK_REPLACE 219 +#define TK_STREAM 220 +#define TK_INTO 221 +#define TK_PAUSE 222 +#define TK_RESUME 223 +#define TK_TRIGGER 224 +#define TK_AT_ONCE 225 +#define TK_WINDOW_CLOSE 226 +#define TK_IGNORE 227 +#define TK_EXPIRED 228 +#define TK_FILL_HISTORY 229 +#define TK_UPDATE 230 +#define TK_SUBTABLE 231 +#define TK_UNTREATED 232 +#define TK_KILL 233 +#define TK_CONNECTION 234 +#define TK_TRANSACTION 235 +#define TK_BALANCE 236 +#define TK_VGROUP 237 +#define TK_LEADER 238 +#define TK_MERGE 239 +#define TK_REDISTRIBUTE 240 +#define TK_SPLIT 241 +#define TK_DELETE 242 +#define TK_INSERT 243 +#define TK_NK_BIN 244 +#define TK_NK_HEX 245 +#define TK_NULL 246 +#define TK_NK_QUESTION 247 +#define TK_NK_ALIAS 248 +#define TK_NK_ARROW 249 +#define TK_ROWTS 250 +#define TK_QSTART 251 +#define TK_QEND 252 +#define TK_QDURATION 253 +#define TK_WSTART 254 +#define TK_WEND 255 +#define TK_WDURATION 256 +#define TK_IROWTS 257 +#define TK_ISFILLED 258 +#define TK_CAST 259 +#define TK_NOW 260 +#define TK_TODAY 261 +#define TK_TIMEZONE 262 +#define TK_CLIENT_VERSION 263 +#define TK_SERVER_VERSION 264 +#define TK_SERVER_STATUS 265 +#define TK_CURRENT_USER 266 +#define TK_CASE 267 +#define TK_WHEN 268 +#define TK_THEN 269 +#define TK_ELSE 270 +#define TK_BETWEEN 271 +#define TK_IS 272 +#define TK_NK_LT 273 +#define TK_NK_GT 274 +#define TK_NK_LE 275 +#define TK_NK_GE 276 +#define TK_NK_NE 277 +#define TK_MATCH 278 +#define TK_NMATCH 279 +#define TK_CONTAINS 280 +#define TK_IN 281 +#define TK_JOIN 282 +#define TK_INNER 283 +#define TK_LEFT 284 +#define TK_RIGHT 285 +#define TK_OUTER 286 +#define TK_SEMI 287 +#define TK_ANTI 288 +#define TK_ASOF 289 +#define TK_WINDOW 290 +#define TK_WINDOW_OFFSET 291 +#define TK_JLIMIT 292 +#define TK_SELECT 293 +#define TK_NK_HINT 294 +#define TK_DISTINCT 295 +#define TK_WHERE 296 +#define TK_PARTITION 297 +#define TK_BY 298 +#define TK_SESSION 299 +#define TK_STATE_WINDOW 300 +#define TK_EVENT_WINDOW 301 +#define TK_COUNT_WINDOW 302 +#define TK_SLIDING 303 +#define TK_FILL 304 +#define TK_VALUE 305 +#define TK_VALUE_F 306 +#define TK_NONE 307 +#define TK_PREV 308 +#define TK_NULL_F 309 +#define TK_LINEAR 310 +#define TK_NEXT 311 +#define TK_HAVING 312 +#define TK_RANGE 313 +#define TK_EVERY 314 +#define TK_ORDER 315 +#define TK_SLIMIT 316 +#define TK_SOFFSET 317 +#define TK_LIMIT 318 +#define TK_OFFSET 319 +#define TK_ASC 320 +#define TK_NULLS 321 +#define TK_ABORT 322 +#define TK_AFTER 323 +#define TK_ATTACH 324 +#define TK_BEFORE 325 +#define TK_BEGIN 326 +#define TK_BITAND 327 +#define TK_BITNOT 328 +#define TK_BITOR 329 +#define TK_BLOCKS 330 +#define TK_CHANGE 331 +#define TK_COMMA 332 +#define TK_CONCAT 333 +#define TK_CONFLICT 334 +#define TK_COPY 335 +#define TK_DEFERRED 336 +#define TK_DELIMITERS 337 +#define TK_DETACH 338 +#define TK_DIVIDE 339 +#define TK_DOT 340 +#define TK_EACH 341 +#define TK_FAIL 342 +#define TK_FILE 343 +#define TK_FOR 344 +#define TK_GLOB 345 +#define TK_ID 346 +#define TK_IMMEDIATE 347 +#define TK_IMPORT 348 +#define TK_INITIALLY 349 +#define TK_INSTEAD 350 +#define TK_ISNULL 351 +#define TK_MODULES 352 +#define TK_NK_BITNOT 353 +#define TK_NK_SEMI 354 +#define TK_NOTNULL 355 +#define TK_OF 356 +#define TK_PLUS 357 +#define TK_PRIVILEGE 358 +#define TK_RAISE 359 +#define TK_RESTRICT 360 +#define TK_ROW 361 +#define TK_STAR 362 +#define TK_STATEMENT 363 +#define TK_STRICT 364 +#define TK_STRING 365 +#define TK_TIMES 366 +#define TK_VALUES 367 +#define TK_VARIABLE 368 +#define TK_WAL 369 #define TK_NK_SPACE 600 #define TK_NK_COMMENT 601 @@ -398,6 +399,7 @@ #define TK_PARA_TABLES_SORT 610 #define TK_SMALLDATA_TS_SORT 611 #define TK_HASH_JOIN 612 +#define TK_SKIP_TSMA 613 #define TK_NK_NIL 65535 diff --git a/include/libs/catalog/catalog.h b/include/libs/catalog/catalog.h index 1957bcbb24..90cc4ac157 100644 --- a/include/libs/catalog/catalog.h +++ b/include/libs/catalog/catalog.h @@ -94,6 +94,8 @@ typedef struct SCatalogReq { SArray* pTableCfg; // element is SNAME SArray* pTableTag; // element is SNAME SArray* pView; // element is STablesReq + SArray* pTableTSMAs; // element is STablesReq + SArray* pTSMAs; // element is STablesReq bool qNodeRequired; // valid qnode bool dNodeRequired; // valid dnode bool svrVerRequired; @@ -122,6 +124,8 @@ typedef struct SMetaData { SArray* pTableTag; // pRes = SArray* SArray* pDnodeList; // pRes = SArray* SArray* pView; // pRes = SViewMeta* + SArray* pTableTsmas; // pRes = SArray + SArray* pTsmas; // pRes = SArray SMetaRes* pSvrVer; // pRes = char* } SMetaData; @@ -130,9 +134,11 @@ typedef struct SCatalogCfg { uint32_t maxViewCacheNum; uint32_t maxDBCacheNum; uint32_t maxUserCacheNum; + uint32_t maxTSMACacheNum; uint32_t dbRentSec; uint32_t stbRentSec; uint32_t viewRentSec; + uint32_t tsmaRentSec; } SCatalogCfg; typedef struct SSTableVersion { @@ -152,6 +158,7 @@ typedef struct SDbCacheInfo { int32_t cfgVersion; int32_t numOfTable; // unit is TSDB_TABLE_NUM_UNIT int64_t stateTs; + int32_t tsmaVersion; } SDbCacheInfo; typedef struct SDynViewVersion { @@ -167,6 +174,14 @@ typedef struct SViewVersion { int32_t version; } SViewVersion; +typedef struct STSMAVersion { + char dbFName[TSDB_DB_FNAME_LEN]; + char tbName[TSDB_TABLE_NAME_LEN]; + char name[TSDB_TABLE_NAME_LEN]; + uint64_t dbId; + uint64_t tsmaId; + int32_t version; +} STSMAVersion; typedef struct STbSVersion { char* tbFName; @@ -342,6 +357,8 @@ int32_t catalogGetExpiredDBs(SCatalog* pCatalog, SDbCacheInfo** dbs, uint32_t* n int32_t catalogGetExpiredUsers(SCatalog* pCtg, SUserAuthVersion** users, uint32_t* num); +int32_t catalogGetExpiredTsmas(SCatalog* pCtg, STSMAVersion** tsmas, uint32_t* num); + int32_t catalogGetDBCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const char* dbFName, SDbCfgInfo* pDbCfg); int32_t catalogGetIndexMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const char* indexName, SIndexInfo* pInfo); @@ -388,6 +405,16 @@ int32_t ctgdEnableDebug(char* option, bool enable); int32_t ctgdHandleDbgCommand(char* command); +int32_t catalogAsyncUpdateTSMA(SCatalog* pCtg, STableTSMAInfo** pTsma, int32_t tsmaVersion); + +int32_t catalogUpdateTSMA(SCatalog* pCtg, STableTSMAInfo** ppTsma); + +int32_t catalogRemoveTSMA(SCatalog* pCtg, const STableTSMAInfo* pTsma); + +int32_t catalogGetTableTsmas(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SArray** pRes); + +int32_t catalogGetTsma(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTsmaName, STableTSMAInfo** pTsma); + /** * Destroy catalog and relase all resources */ diff --git a/include/libs/function/functionMgt.h b/include/libs/function/functionMgt.h index 43ece3cf89..e77635727b 100644 --- a/include/libs/function/functionMgt.h +++ b/include/libs/function/functionMgt.h @@ -88,6 +88,7 @@ typedef enum EFunctionType { FUNCTION_TYPE_LTRIM, FUNCTION_TYPE_RTRIM, FUNCTION_TYPE_SUBSTR, + FUNCTION_TYPE_MD5, // conversion function FUNCTION_TYPE_CAST = 2000, @@ -164,6 +165,18 @@ typedef enum EFunctionType { FUNCTION_TYPE_STDDEV_MERGE, FUNCTION_TYPE_IRATE_PARTIAL, FUNCTION_TYPE_IRATE_MERGE, + FUNCTION_TYPE_AVG_STATE, + FUNCTION_TYPE_AVG_STATE_MERGE, + FUNCTION_TYPE_FIRST_STATE, + FUNCTION_TYPE_FIRST_STATE_MERGE, + FUNCTION_TYPE_LAST_STATE, + FUNCTION_TYPE_LAST_STATE_MERGE, + FUNCTION_TYPE_SPREAD_STATE, + FUNCTION_TYPE_SPREAD_STATE_MERGE, + FUNCTION_TYPE_STDDEV_STATE, + FUNCTION_TYPE_STDDEV_STATE_MERGE, + FUNCTION_TYPE_HYPERLOGLOG_STATE, + FUNCTION_TYPE_HYPERLOGLOG_STATE_MERGE, // geometry functions FUNCTION_TYPE_GEOM_FROM_TEXT = 4250, @@ -271,6 +284,13 @@ bool fmIsInvertible(int32_t funcId); char* fmGetFuncName(int32_t funcId); +bool fmIsTSMASupportedFunc(func_id_t funcId); +int32_t fmCreateStateFuncs(SNodeList* pFuncs); +int32_t fmCreateStateMergeFuncs(SNodeList* pFuncs); +int32_t fmGetFuncId(const char* name); +bool fmIsMyStateFunc(int32_t funcId, int32_t stateFuncId); +bool fmIsCountLikeFunc(int32_t funcId); + #ifdef __cplusplus } #endif diff --git a/include/libs/nodes/cmdnodes.h b/include/libs/nodes/cmdnodes.h index d0a4608cb6..d737f84f7b 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -213,11 +213,13 @@ typedef struct SDropTableClause { char dbName[TSDB_DB_NAME_LEN]; char tableName[TSDB_TABLE_NAME_LEN]; bool ignoreNotExists; + SArray* pTsmas; } SDropTableClause; typedef struct SDropTableStmt { ENodeType type; SNodeList* pTables; + bool withTsma; } SDropTableStmt; typedef struct SDropSuperTableStmt { @@ -590,6 +592,34 @@ typedef struct SSplitVgroupStmt { int32_t vgId; } SSplitVgroupStmt; +typedef struct STSMAOptions { + ENodeType type; + SNodeList* pFuncs; + SNodeList* pCols; + SNode* pInterval; + uint8_t tsPrecision; + bool recursiveTsma; // true if create recursive tsma +} STSMAOptions; + +typedef struct SCreateTSMAStmt { + ENodeType type; + bool ignoreExists; + char tsmaName[TSDB_TABLE_NAME_LEN]; + char dbName[TSDB_DB_NAME_LEN]; + char tableName[TSDB_TABLE_NAME_LEN]; // base tb name or base tsma name + char originalTbName[TSDB_TABLE_NAME_LEN]; + STSMAOptions* pOptions; + SNode* pPrevQuery; + SMCreateSmaReq* pReq; +} SCreateTSMAStmt; + +typedef struct SDropTSMAStmt { + ENodeType type; + bool ignoreNotExists; + char dbName[TSDB_DB_NAME_LEN]; + char tsmaName[TSDB_TABLE_NAME_LEN]; +} SDropTSMAStmt; + #ifdef __cplusplus } #endif diff --git a/include/libs/nodes/nodes.h b/include/libs/nodes/nodes.h index 891084419b..31091928c9 100644 --- a/include/libs/nodes/nodes.h +++ b/include/libs/nodes/nodes.h @@ -123,6 +123,7 @@ int32_t nodesListAppendList(SNodeList* pTarget, SNodeList* pSrc); int32_t nodesListStrictAppendList(SNodeList* pTarget, SNodeList* pSrc); int32_t nodesListMakeStrictAppendList(SNodeList** pTarget, SNodeList* pSrc); int32_t nodesListPushFront(SNodeList* pList, SNode* pNode); +int32_t nodesListMakePushFront(SNodeList** pList, SNode* pNode); SListCell* nodesListErase(SNodeList* pList, SListCell* pCell); void nodesListInsertList(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc); void nodesListInsertListAfterPos(SNodeList* pTarget, SListCell* pPos, SNodeList* pSrc); @@ -169,6 +170,7 @@ int32_t nodesMsgToNode(const char* pStr, int32_t len, SNode** pNode); int32_t nodesNodeToSQL(SNode* pNode, char* buf, int32_t bufSize, int32_t* len); char* nodesGetNameFromColumnNode(SNode* pNode); int32_t nodesGetOutputNumFromSlotList(SNodeList* pSlots); +void nodesSortList(SNodeList** pList, int32_t (*)(SNode* pNode1, SNode* pNode2)); #ifdef __cplusplus } diff --git a/include/libs/nodes/plannodes.h b/include/libs/nodes/plannodes.h index 4c98749fce..2fbed98604 100644 --- a/include/libs/nodes/plannodes.h +++ b/include/libs/nodes/plannodes.h @@ -109,6 +109,9 @@ typedef struct SScanLogicNode { int8_t igExpired; int8_t igCheckUpdate; SArray* pSmaIndexes; + SArray* pTsmas; + SArray* pTsmaTargetTbVgInfo; + SArray* pTsmaTargetTbInfo; SNodeList* pGroupTags; bool groupSort; SNodeList* pTags; // for create stream @@ -124,6 +127,7 @@ typedef struct SScanLogicNode { SArray* pFuncTypes; // for last, last_row bool paraTablesSort; // for table merge scan bool smallDataTsSort; // disable row id sort for table merge scan + bool needSplit; } SScanLogicNode; typedef struct SJoinLogicNode { @@ -169,6 +173,7 @@ typedef struct SAggLogicNode { bool isGroupTb; bool isPartTb; // true if partition keys has tbname bool hasGroup; + SNodeList *pTsmaSubplans; } SAggLogicNode; typedef struct SProjectLogicNode { @@ -252,7 +257,9 @@ typedef struct SMergeLogicNode { SNodeList* pMergeKeys; SNodeList* pInputs; int32_t numOfChannels; + int32_t numOfSubplans; int32_t srcGroupId; + int32_t srcEndGroupId; bool colsMerge; bool needSort; bool groupSort; @@ -305,6 +312,7 @@ typedef struct SWindowLogicNode { bool isPartTb; int64_t windowCount; int64_t windowSliding; + SNodeList* pTsmaSubplans; } SWindowLogicNode; typedef struct SFillLogicNode { @@ -577,6 +585,7 @@ typedef struct SAggPhysiNode { SNodeList* pAggFuncs; bool mergeDataBlock; bool groupKeyOptimized; + bool hasCountLikeFunc; } SAggPhysiNode; typedef struct SDownstreamSourceNode { @@ -606,7 +615,9 @@ typedef struct SMergePhysiNode { SNodeList* pMergeKeys; SNodeList* pTargets; int32_t numOfChannels; + int32_t numOfSubplans; int32_t srcGroupId; + int32_t srcEndGroupId; bool groupSort; bool ignoreGroupId; bool inputWithGroupId; diff --git a/include/libs/nodes/querynodes.h b/include/libs/nodes/querynodes.h index 3ef8d34969..44332d8b51 100644 --- a/include/libs/nodes/querynodes.h +++ b/include/libs/nodes/querynodes.h @@ -142,6 +142,7 @@ typedef enum EHintOption { HINT_PARA_TABLES_SORT, HINT_SMALLDATA_TS_SORT, HINT_HASH_JOIN, + HINT_SKIP_TSMA, } EHintOption; typedef struct SHintNode { @@ -177,6 +178,8 @@ typedef struct SFunctionNode { int32_t udfBufSize; bool hasPk; int32_t pkBytes; + bool hasOriginalFunc; + int32_t originalFuncId; } SFunctionNode; typedef struct STableNode { @@ -190,6 +193,11 @@ typedef struct STableNode { struct STableMeta; +typedef struct STsmaTargetCTbInfo { + char tableName[TSDB_TABLE_NAME_LEN]; // child table or normal table name + uint64_t uid; +} STsmaTargetTbInfo; + typedef struct SRealTableNode { STableNode table; // QUERY_NODE_REAL_TABLE struct STableMeta* pMeta; @@ -198,6 +206,9 @@ typedef struct SRealTableNode { double ratio; SArray* pSmaIndexes; int8_t cacheLastMode; + SArray* pTsmas; + SArray* tsmaTargetTbVgInfo; // SArray, used for child table or normal table only + SArray* tsmaTargetTbInfo; // SArray, used for child table or normal table only } SRealTableNode; typedef struct STempTableNode { diff --git a/include/libs/qcom/query.h b/include/libs/qcom/query.h index e439511837..789462f444 100644 --- a/include/libs/qcom/query.h +++ b/include/libs/qcom/query.h @@ -331,7 +331,8 @@ extern int32_t (*queryProcessMsgRsp[TDMT_MAX])(void* output, char* msg, int32_t #define NEED_CLIENT_RM_TBLMETA_REQ(_type) \ ((_type) == TDMT_VND_CREATE_TABLE || (_type) == TDMT_MND_CREATE_STB || (_type) == TDMT_VND_DROP_TABLE || \ - (_type) == TDMT_MND_DROP_STB || (_type) == TDMT_MND_CREATE_VIEW || (_type) == TDMT_MND_DROP_VIEW) + (_type) == TDMT_MND_DROP_STB || (_type) == TDMT_MND_CREATE_VIEW || (_type) == TDMT_MND_DROP_VIEW || \ + (_type) == TDMT_MND_CREATE_TSMA || (_type) == TDMT_MND_DROP_TSMA || (_type) == TDMT_MND_DROP_TB_WITH_TSMA) #define NEED_SCHEDULER_REDIRECT_ERROR(_code) \ (SYNC_UNKNOWN_LEADER_REDIRECT_ERROR(_code) || SYNC_SELF_LEADER_REDIRECT_ERROR(_code) || \ diff --git a/include/libs/scalar/scalar.h b/include/libs/scalar/scalar.h index ac7f3e5c20..bee8d2e943 100644 --- a/include/libs/scalar/scalar.h +++ b/include/libs/scalar/scalar.h @@ -72,6 +72,7 @@ int32_t upperFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOut int32_t ltrimFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); int32_t rtrimFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); +int32_t md5Function(SScalarParam* pInput, int32_t inputNum, SScalarParam* pOutput); /* Conversion functions */ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput); diff --git a/include/util/taoserror.h b/include/util/taoserror.h index d5a6933a36..fe723588c2 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -423,6 +423,8 @@ int32_t* taosGetErrno(); #define TSDB_CODE_MND_SMA_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0480) #define TSDB_CODE_MND_SMA_NOT_EXIST TAOS_DEF_ERROR_CODE(0, 0x0481) #define TSDB_CODE_MND_INVALID_SMA_OPTION TAOS_DEF_ERROR_CODE(0, 0x0482) +#define TSDB_CODE_MND_INVALID_DROP_TSMA TAOS_DEF_ERROR_CODE(0, 0x0485) +#define TSDB_CODE_MND_MAX_TSMA_NUM_EXCEEDED TAOS_DEF_ERROR_CODE(0, 0x0486) // mnode-tag-indxe @@ -823,6 +825,12 @@ int32_t* taosGetErrno(); #define TSDB_CODE_TSMA_INVALID_STAT TAOS_DEF_ERROR_CODE(0, 0x3103) #define TSDB_CODE_TSMA_INVALID_PTR TAOS_DEF_ERROR_CODE(0, 0x3104) #define TSDB_CODE_TSMA_INVALID_PARA TAOS_DEF_ERROR_CODE(0, 0x3105) +#define TSDB_CODE_TSMA_INVALID_TB TAOS_DEF_ERROR_CODE(0, 0x3106) +#define TSDB_CODE_TSMA_INVALID_INTERVAL TAOS_DEF_ERROR_CODE(0, 0x3107) +#define TSDB_CODE_TSMA_INVALID_FUNC_PARAM TAOS_DEF_ERROR_CODE(0, 0x3108) +#define TSDB_CODE_TSMA_UNSUPPORTED_FUNC TAOS_DEF_ERROR_CODE(0, 0x3109) +#define TSDB_CODE_TSMA_MUST_BE_DROPPED TAOS_DEF_ERROR_CODE(0, 0x3110) +#define TSDB_CODE_TSMA_NAME_TOO_LONG TAOS_DEF_ERROR_CODE(0, 0x3111) //rsma #define TSDB_CODE_RSMA_INVALID_ENV TAOS_DEF_ERROR_CODE(0, 0x3150) diff --git a/source/client/src/clientHb.c b/source/client/src/clientHb.c index b1f0ea55d8..78e8b04a13 100644 --- a/source/client/src/clientHb.c +++ b/source/client/src/clientHb.c @@ -234,6 +234,15 @@ static int32_t hbProcessDBInfoRsp(void *value, int32_t valueLen, struct SCatalog catalogUpdateDbCfg(pCatalog, rsp->cfgRsp->db, rsp->cfgRsp->dbId, rsp->cfgRsp); rsp->cfgRsp = NULL; } + if (rsp->pTsmaRsp) { + if (rsp->pTsmaRsp->pTsmas) { + for (int32_t i = 0; i < rsp->pTsmaRsp->pTsmas->size; ++i) { + STableTSMAInfo* pTsma = taosArrayGetP(rsp->pTsmaRsp->pTsmas, i); + catalogAsyncUpdateTSMA(pCatalog, &pTsma, rsp->dbTsmaVersion); + } + taosArrayClear(rsp->pTsmaRsp->pTsmas); + } + } } _return: @@ -327,6 +336,33 @@ static int32_t hbProcessViewInfoRsp(void *value, int32_t valueLen, struct SCatal return TSDB_CODE_SUCCESS; } +static int32_t hbprocessTSMARsp(void* value, int32_t valueLen, struct SCatalog* pCatalog) { + int32_t code = 0; + + STSMAHbRsp hbRsp = {0}; + if (tDeserializeTSMAHbRsp(value, valueLen, &hbRsp)) { + terrno = TSDB_CODE_INVALID_MSG; + return -1; + } + + int32_t numOfTsma = taosArrayGetSize(hbRsp.pTsmas); + for (int32_t i = 0; i < numOfTsma; ++i) { + STableTSMAInfo* pTsmaInfo = taosArrayGetP(hbRsp.pTsmas, i); + + if (!pTsmaInfo->pFuncs) { + tscDebug("hb to remove tsma: %s.%s", pTsmaInfo->dbFName, pTsmaInfo->name); + catalogRemoveTSMA(pCatalog, pTsmaInfo); + tFreeAndClearTableTSMAInfo(pTsmaInfo); + } else { + tscDebug("hb to update tsma: %s.%s", pTsmaInfo->dbFName, pTsmaInfo->name); + catalogUpdateTSMA(pCatalog, &pTsmaInfo); + tFreeAndClearTableTSMAInfo(pTsmaInfo); + } + } + + taosArrayDestroy(hbRsp.pTsmas); + return TSDB_CODE_SUCCESS; +} static void hbProcessQueryRspKvs(int32_t kvNum, SArray* pKvs, struct SCatalog *pCatalog, SAppHbMgr *pAppHbMgr) { for (int32_t i = 0; i < kvNum; ++i) { @@ -379,6 +415,13 @@ static void hbProcessQueryRspKvs(int32_t kvNum, SArray* pKvs, struct SCatalog *p break; } #endif + case HEARTBEAT_KEY_TSMA: { + if (kv->valueLen <= 0 || !kv->value) { + tscError("Invalid tsma info, len: %d, value: %p", kv->valueLen, kv->value); + } + hbprocessTSMARsp(kv->value, kv->valueLen, pCatalog); + break; + } default: tscError("invalid hb key type:%d", kv->key); break; @@ -763,6 +806,7 @@ int32_t hbGetExpiredDBInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, SCl db->cfgVersion = htonl(db->cfgVersion); db->numOfTable = htonl(db->numOfTable); db->stateTs = htobe64(db->stateTs); + db->tsmaVersion = htonl(db->tsmaVersion); } SKv kv = { @@ -871,6 +915,39 @@ int32_t hbGetExpiredViewInfo(SClientHbKey *connKey, struct SCatalog *pCatalog, S return TSDB_CODE_SUCCESS; } +int32_t hbGetExpiredTSMAInfo(SClientHbKey* connKey, struct SCatalog* pCatalog, SClientHbReq* pReq) { + int32_t code = 0; + uint32_t tsmaNum = 0; + STSMAVersion *tsmas = NULL; + + code = catalogGetExpiredTsmas(pCatalog, &tsmas, &tsmaNum); + if (code) { + taosMemoryFree(tsmas); + return code; + } + + if (tsmaNum <= 0) { + taosMemoryFree(tsmas); + return TSDB_CODE_SUCCESS; + } + + for (int32_t i = 0; i < tsmaNum; ++i) { + STSMAVersion* tsma = &tsmas[i]; + tsma->dbId = htobe64(tsma->dbId); + tsma->tsmaId = htobe64(tsma->tsmaId); + tsma->version = htonl(tsma->version); + } + + tscDebug("hb got %d expred tsmas, valueLen: %lu", tsmaNum, sizeof(STSMAVersion) * tsmaNum); + + if (!pReq->info) { + pReq->info = taosHashInit(64, hbKeyHashFunc, 1, HASH_ENTRY_LOCK); + } + + SKv kv = {.key = HEARTBEAT_KEY_TSMA, .valueLen = sizeof(STSMAVersion) * tsmaNum, .value = tsmas}; + taosHashPut(pReq->info, &kv.key, sizeof(kv.key), &kv, sizeof(kv)); + return TSDB_CODE_SUCCESS; +} int32_t hbGetAppInfo(int64_t clusterId, SClientHbReq *req) { SAppHbReq *pApp = taosHashGet(clientHbMgr.appSummary, &clusterId, sizeof(clusterId)); @@ -935,6 +1012,7 @@ int32_t hbQueryHbReqHandle(SClientHbKey *connKey, void *param, SClientHbReq *req return code; } #endif + code = hbGetExpiredTSMAInfo(connKey, pCatalog, req); } else { req->app.appId = 0; } diff --git a/source/client/src/clientImpl.c b/source/client/src/clientImpl.c index e87e676f08..1c4b49df53 100644 --- a/source/client/src/clientImpl.c +++ b/source/client/src/clientImpl.c @@ -1041,6 +1041,7 @@ void schedulerExecCb(SExecResult* pResult, void* param, int32_t code) { if (code != TSDB_CODE_SUCCESS && NEED_CLIENT_HANDLE_ERROR(code) && pRequest->sqlstr != NULL) { tscDebug("0x%" PRIx64 " client retry to handle the error, code:%s, tryCount:%d, reqId:0x%" PRIx64, pRequest->self, tstrerror(code), pRequest->retry, pRequest->requestId); + removeMeta(pTscObj, pRequest->targetTableList, IS_VIEW_REQUEST(pRequest->type)); restartAsyncQuery(pRequest, code); return; } diff --git a/source/client/src/clientMain.c b/source/client/src/clientMain.c index 9464baea52..19798fa38b 100644 --- a/source/client/src/clientMain.c +++ b/source/client/src/clientMain.c @@ -936,6 +936,8 @@ int32_t cloneCatalogReq(SCatalogReq **ppTarget, SCatalogReq *pSrc) { pTarget->pTableCfg = taosArrayDup(pSrc->pTableCfg, NULL); pTarget->pTableTag = taosArrayDup(pSrc->pTableTag, NULL); pTarget->pView = taosArrayDup(pSrc->pView, NULL); + pTarget->pTableTSMAs = taosArrayDup(pSrc->pTableTSMAs, NULL); + pTarget->pTSMAs = taosArrayDup(pSrc->pTSMAs, NULL); pTarget->qNodeRequired = pSrc->qNodeRequired; pTarget->dNodeRequired = pSrc->dNodeRequired; pTarget->svrVerRequired = pSrc->svrVerRequired; diff --git a/source/common/src/systable.c b/source/common/src/systable.c index 678962a00a..ba692840a1 100644 --- a/source/common/src/systable.c +++ b/source/common/src/systable.c @@ -372,6 +372,18 @@ static const SSysDbTableSchema userCompactsDetailSchema[] = { {.name = "finished", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false}, {.name = "start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false}, }; +static const SSysDbTableSchema tsmaSchema[] = { + {.name = "tsma_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "table_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "target_db", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "target_stb", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "stream_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "create_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false}, + {.name = "interval", .bytes = 64 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "create_sql", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, + {.name = "func_list", .bytes = TSDB_SHOW_SQL_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false}, +}; static const SSysDbTableSchema userGrantsFullSchema[] = { {.name = "grant_name", .bytes = 32 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true}, @@ -427,6 +439,7 @@ static const SSysTableMeta infosMeta[] = { {TSDB_INS_TABLE_GRANTS_LOGS, userGrantsLogsSchema, tListLen(userGrantsLogsSchema), true}, {TSDB_INS_TABLE_MACHINES, userMachinesSchema, tListLen(userMachinesSchema), true}, {TSDB_INS_TABLE_ARBGROUPS, arbGroupsSchema, tListLen(arbGroupsSchema), true}, + {TSDB_INS_TABLE_TSMAS, tsmaSchema, tListLen(tsmaSchema), false}, }; static const SSysDbTableSchema connectionsSchema[] = { diff --git a/source/common/src/tglobal.c b/source/common/src/tglobal.c index 6ae93637d4..1f06891d3d 100644 --- a/source/common/src/tglobal.c +++ b/source/common/src/tglobal.c @@ -298,6 +298,9 @@ int32_t tsS3UploadDelaySec = 60; bool tsExperimental = true; +int32_t tsMaxTsmaNum = 8; +int32_t tsMaxTsmaCalcDelay = 600; + #ifndef _STORAGE int32_t taosSetTfsCfg(SConfig *pCfg) { SConfigItem *pItem = cfgGetItem(pCfg, "dataDir"); @@ -553,6 +556,11 @@ static int32_t taosAddClientCfg(SConfig *pCfg) { if (cfgAddInt32(pCfg, "monitorInterval", tsMonitorInterval, 1, 200000, CFG_SCOPE_BOTH, CFG_DYN_NONE) != 0) return -1; if (cfgAddBool(pCfg, "multiResultFunctionStarReturnTags", tsMultiResultFunctionStarReturnTags, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT) != 0) return -1; + if (cfgAddInt32(pCfg, "countAlwaysReturnValue", tsCountAlwaysReturnValue, 0, 1, CFG_SCOPE_BOTH, CFG_DYN_CLIENT) != 0) + return -1; + if (cfgAddInt32(pCfg, "maxTsmaCalcDelay", tsMaxTsmaCalcDelay, 600, 86400, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT) != + 0) + return -1; return 0; } @@ -607,8 +615,6 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { if (cfgAddInt32(pCfg, "minIntervalTime", tsMinIntervalTime, 1, 1000000, CFG_SCOPE_CLIENT, CFG_DYN_CLIENT) != 0) return -1; - if (cfgAddInt32(pCfg, "countAlwaysReturnValue", tsCountAlwaysReturnValue, 0, 1, CFG_SCOPE_BOTH, CFG_DYN_CLIENT) != 0) - return -1; if (cfgAddInt32(pCfg, "queryBufferSize", tsQueryBufferSize, -1, 500000000000, CFG_SCOPE_SERVER, CFG_DYN_NONE) != 0) return -1; if (cfgAddInt32(pCfg, "queryRspPolicy", tsQueryRspPolicy, 0, 1, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1; @@ -732,6 +738,7 @@ static int32_t taosAddServerCfg(SConfig *pCfg) { if (cfgAddInt32(pCfg, "tmqRowSize", tmqRowSize, 1, 1000000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1; + if (cfgAddInt32(pCfg, "maxTsmaNum", tsMaxTsmaNum, 0, 12, CFG_SCOPE_SERVER, CFG_DYN_SERVER) != 0) return -1; if (cfgAddInt32(pCfg, "transPullupInterval", tsTransPullupInterval, 1, 10000, CFG_SCOPE_SERVER, CFG_DYN_ENT_SERVER) != 0) return -1; @@ -1109,6 +1116,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) { if (taosSetSlowLogScope(cfgGetItem(pCfg, "slowLogScope")->str)) { return -1; } + tsCountAlwaysReturnValue = cfgGetItem(pCfg, "countAlwaysReturnValue")->i32; tsMaxRetryWaitTime = cfgGetItem(pCfg, "maxRetryWaitTime")->i32; @@ -1122,6 +1130,7 @@ static int32_t taosSetClientCfg(SConfig *pCfg) { tsExperimental = cfgGetItem(pCfg, "experimental")->bval; tsMultiResultFunctionStarReturnTags = cfgGetItem(pCfg, "multiResultFunctionStarReturnTags")->bval; + tsMaxTsmaCalcDelay = cfgGetItem(pCfg, "maxTsmaCalcDelay")->i32; return 0; } @@ -1153,7 +1162,6 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tsStatusInterval = cfgGetItem(pCfg, "statusInterval")->i32; tsMinSlidingTime = cfgGetItem(pCfg, "minSlidingTime")->i32; tsMinIntervalTime = cfgGetItem(pCfg, "minIntervalTime")->i32; - tsCountAlwaysReturnValue = cfgGetItem(pCfg, "countAlwaysReturnValue")->i32; tsQueryBufferSize = cfgGetItem(pCfg, "queryBufferSize")->i32; tsNumOfRpcThreads = cfgGetItem(pCfg, "numOfRpcThreads")->i32; @@ -1203,6 +1211,7 @@ static int32_t taosSetServerCfg(SConfig *pCfg) { tmqMaxTopicNum = cfgGetItem(pCfg, "tmqMaxTopicNum")->i32; tmqRowSize = cfgGetItem(pCfg, "tmqRowSize")->i32; + tsMaxTsmaNum = cfgGetItem(pCfg, "maxTsmaNum")->i32; tsTransPullupInterval = cfgGetItem(pCfg, "transPullupInterval")->i32; tsCompactPullupInterval = cfgGetItem(pCfg, "compactPullupInterval")->i32; @@ -1548,7 +1557,8 @@ static int32_t taosCfgDynamicOptionsForServer(SConfig *pCfg, char *name) { {"s3PageCacheSize", &tsS3PageCacheSize}, {"s3UploadDelaySec", &tsS3UploadDelaySec}, {"supportVnodes", &tsNumOfSupportVnodes}, - {"experimental", &tsExperimental}}; + {"experimental", &tsExperimental}, + {"maxTsmaNum", &tsMaxTsmaNum}}; if (taosCfgSetOption(debugOptions, tListLen(debugOptions), pItem, true) != 0) { taosCfgSetOption(options, tListLen(options), pItem, false); @@ -1766,7 +1776,8 @@ static int32_t taosCfgDynamicOptionsForClient(SConfig *pCfg, char *name) { {"slowLogThreshold", &tsSlowLogThreshold}, {"useAdapter", &tsUseAdapter}, {"experimental", &tsExperimental}, - {"multiResultFunctionStarReturnTags", &tsMultiResultFunctionStarReturnTags} }; + {"multiResultFunctionStarReturnTags", &tsMultiResultFunctionStarReturnTags}, + {"maxTsmaCalcDelay", &tsMaxTsmaCalcDelay}}; if (taosCfgSetOption(debugOptions, tListLen(debugOptions), pItem, true) != 0) { taosCfgSetOption(options, tListLen(options), pItem, false); diff --git a/source/common/src/tmsg.c b/source/common/src/tmsg.c index 4200d3d498..d0a844b185 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -67,6 +67,8 @@ static int32_t tDecodeSVAlterTbReqCommon(SDecoder *pDecoder, SVAlterTbReq *pReq); static int32_t tDecodeSBatchDeleteReqCommon(SDecoder *pDecoder, SBatchDeleteReq *pReq); +static int32_t tEncodeTableTSMAInfoRsp(SEncoder *pEncoder, const STableTSMAInfoRsp *pRsp); +static int32_t tDecodeTableTSMAInfoRsp(SDecoder* pDecoder, STableTSMAInfoRsp* pRsp); int32_t tInitSubmitMsgIter(const SSubmitReq *pMsg, SSubmitMsgIter *pIter) { if (pMsg == NULL) { @@ -887,6 +889,16 @@ int32_t tSerializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pReq } if (tEncodeI64(&encoder, pReq->deleteMark) < 0) return -1; if (tEncodeI64(&encoder, pReq->lastTs) < 0) return -1; + if (tEncodeI64(&encoder, pReq->normSourceTbUid) < 0) return -1; + if (tEncodeI32(&encoder, taosArrayGetSize(pReq->pVgroupVerList)) < 0) return -1; + + for(int32_t i = 0; i < taosArrayGetSize(pReq->pVgroupVerList); ++i) { + SVgroupVer* p = taosArrayGet(pReq->pVgroupVerList, i); + if (tEncodeI32(&encoder, p->vgId) < 0) return -1; + if (tEncodeI64(&encoder, p->ver) < 0) return -1; + } + if (tEncodeI8(&encoder, pReq->recursiveTsma) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->baseTsmaName) < 0) return -1; tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -937,6 +949,29 @@ int32_t tDeserializeSMCreateSmaReq(void *buf, int32_t bufLen, SMCreateSmaReq *pR } if (tDecodeI64(&decoder, &pReq->deleteMark) < 0) return -1; if (tDecodeI64(&decoder, &pReq->lastTs) < 0) return -1; + if (tDecodeI64(&decoder, &pReq->normSourceTbUid) < 0) return -1; + + int32_t numOfVgVer; + if (tDecodeI32(&decoder, &numOfVgVer) < 0) return -1; + if (numOfVgVer > 0) { + pReq->pVgroupVerList = taosArrayInit(numOfVgVer, sizeof(SVgroupVer)); + if (pReq->pVgroupVerList == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + for (int32_t i = 0; i < numOfVgVer; ++i) { + SVgroupVer v = {0}; + if (tDecodeI32(&decoder, &v.vgId) < 0) return -1; + if (tDecodeI64(&decoder, &v.ver) < 0) return -1; + if (taosArrayPush(pReq->pVgroupVerList, &v) == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + } + } + if (tDecodeI8(&decoder, &pReq->recursiveTsma) < 0) return -1; + if (tDecodeCStrTo(&decoder, pReq->baseTsmaName) < 0) return -1; tEndDecode(&decoder); tDecoderClear(&decoder); return 0; @@ -947,6 +982,7 @@ void tFreeSMCreateSmaReq(SMCreateSmaReq *pReq) { taosMemoryFreeClear(pReq->tagsFilter); taosMemoryFreeClear(pReq->sql); taosMemoryFreeClear(pReq->ast); + taosArrayDestroy(pReq->pVgroupVerList); } int32_t tSerializeSMDropSmaReq(void *buf, int32_t bufLen, SMDropSmaReq *pReq) { @@ -3632,6 +3668,14 @@ int32_t tSerializeSDbHbRspImp(SEncoder *pEncoder, const SDbHbRsp *pRsp) { if (tEncodeI8(pEncoder, 0) < 0) return -1; } + if (pRsp->pTsmaRsp) { + if (tEncodeI8(pEncoder, 1) < 0) return -1; + if (tEncodeTableTSMAInfoRsp(pEncoder, pRsp->pTsmaRsp) < 0) return -1; + } else { + if (tEncodeI8(pEncoder, 0) < 0) return -1; + } + if (tEncodeI32(pEncoder, pRsp->dbTsmaVersion) < 0) return -1; + return 0; } @@ -3712,6 +3756,17 @@ int32_t tDeserializeSDbHbRspImp(SDecoder *decoder, SDbHbRsp *pRsp) { if (NULL == pRsp->cfgRsp) return -1; if (tDeserializeSDbCfgRspImpl(decoder, pRsp->cfgRsp) < 0) return -1; } + if (!tDecodeIsEnd(decoder)) { + if (tDecodeI8(decoder, &flag) < 0) return -1; + if (flag) { + pRsp->pTsmaRsp = taosMemoryCalloc(1, sizeof(STableTSMAInfoRsp)); + if (!pRsp->pTsmaRsp) return -1; + if (tDecodeTableTSMAInfoRsp(decoder, pRsp->pTsmaRsp) < 0) return -1; + } + } + if (!tDecodeIsEnd(decoder)) { + if (tDecodeI32(decoder, &pRsp->dbTsmaVersion) < 0) return -1; + } return 0; } @@ -3761,6 +3816,10 @@ void tFreeSDbHbRsp(SDbHbRsp *pDbRsp) { tFreeSDbCfgRsp(pDbRsp->cfgRsp); taosMemoryFree(pDbRsp->cfgRsp); } + if (pDbRsp->pTsmaRsp) { + tFreeTableTSMAInfoRsp(pDbRsp->pTsmaRsp); + taosMemoryFree(pDbRsp->pTsmaRsp); + } } void tFreeSDbHbBatchRsp(SDbHbBatchRsp *pRsp) { @@ -7763,6 +7822,7 @@ int32_t tSerializeSCMCreateStreamReq(void *buf, int32_t bufLen, const SCMCreateS if (tEncodeCStr(&encoder, pField->name) < 0) return -1; } + if (tEncodeI64(&encoder, pReq->smaId) < 0) return -1; tEndEncode(&encoder); int32_t tlen = encoder.pos; @@ -7889,6 +7949,9 @@ int32_t tDeserializeSCMCreateStreamReq(void *buf, int32_t bufLen, SCMCreateStrea } } } + if (!tDecodeIsEnd(&decoder)) { + if (tDecodeI64(&decoder, &pReq->smaId)< 0) return -1; + } tEndDecode(&decoder); tDecoderClear(&decoder); @@ -8283,8 +8346,8 @@ static int32_t tDecodeSVDropTbRsp(SDecoder *pCoder, SVDropTbRsp *pReq) { } int32_t tEncodeSVDropTbBatchReq(SEncoder *pCoder, const SVDropTbBatchReq *pReq) { - int32_t nReqs = taosArrayGetSize(pReq->pArray); - SVDropTbReq *pDropTbReq; + int32_t nReqs = taosArrayGetSize(pReq->pArray); + SVDropTbReq *pDropTbReq; if (tStartEncode(pCoder) < 0) return -1; @@ -9936,3 +9999,443 @@ void tFreeSViewHbRsp(SViewHbRsp *pRsp) { taosArrayDestroy(pRsp->pViewRsp); } + +int32_t tSerializeTableTSMAInfoReq(void* buf, int32_t bufLen, const STableTSMAInfoReq* pReq) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeCStr(&encoder, pReq->name) < 0) return -1; + if (tEncodeI8(&encoder, pReq->fetchingWithTsmaName) < 0) return -1; + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeTableTSMAInfoReq(void* buf, int32_t bufLen, STableTSMAInfoReq* pReq) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeCStrTo(&decoder, pReq->name) < 0) return -1; + if (tDecodeI8(&decoder, (uint8_t*)&pReq->fetchingWithTsmaName) < 0) return -1; + + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + +static int32_t tEncodeTableTSMAInfo(SEncoder* pEncoder, const STableTSMAInfo* pTsmaInfo) { + if (tEncodeCStr(pEncoder, pTsmaInfo->name) < 0) return -1; + if (tEncodeU64(pEncoder, pTsmaInfo->tsmaId) < 0) return -1; + if (tEncodeCStr(pEncoder, pTsmaInfo->tb) < 0) return -1; + if (tEncodeCStr(pEncoder, pTsmaInfo->dbFName) < 0) return -1; + if (tEncodeU64(pEncoder, pTsmaInfo->suid) < 0) return -1; + if (tEncodeU64(pEncoder, pTsmaInfo->destTbUid) < 0) return -1; + if (tEncodeU64(pEncoder, pTsmaInfo->dbId) < 0) return -1; + if (tEncodeI32(pEncoder, pTsmaInfo->version) < 0) return -1; + if (tEncodeCStr(pEncoder, pTsmaInfo->targetTb) < 0) return -1; + if (tEncodeCStr(pEncoder, pTsmaInfo->targetDbFName) < 0) return -1; + if (tEncodeI64(pEncoder, pTsmaInfo->interval) < 0) return -1; + if (tEncodeI8(pEncoder, pTsmaInfo->unit) < 0) return -1; + + int32_t size = pTsmaInfo->pFuncs ? pTsmaInfo->pFuncs->size : 0; + if (tEncodeI32(pEncoder, size) < 0) return -1; + for (int32_t i = 0; i < size; ++i) { + STableTSMAFuncInfo* pFuncInfo = taosArrayGet(pTsmaInfo->pFuncs, i); + if (tEncodeI32(pEncoder, pFuncInfo->funcId) < 0) return -1; + if (tEncodeI16(pEncoder, pFuncInfo->colId) < 0) return -1; + } + + size = pTsmaInfo->pTags ? pTsmaInfo->pTags->size : 0; + if (tEncodeI32(pEncoder, size) < 0) return -1; + for (int32_t i = 0; i < size; ++i) { + const SSchema* pSchema = taosArrayGet(pTsmaInfo->pTags, i); + if (tEncodeSSchema(pEncoder, pSchema) < 0) return -1; + } + size = pTsmaInfo->pUsedCols ? pTsmaInfo->pUsedCols->size : 0; + if (tEncodeI32(pEncoder, size) < 0) return -1; + for (int32_t i = 0; i < size; ++i) { + const SSchema* pSchema = taosArrayGet(pTsmaInfo->pUsedCols, i); + if (tEncodeSSchema(pEncoder, pSchema) < 0) return -1; + } + + if (tEncodeCStr(pEncoder, pTsmaInfo->ast) < 0) return -1; + if (tEncodeI64(pEncoder, pTsmaInfo->streamUid) < 0) return -1; + if (tEncodeI64(pEncoder, pTsmaInfo->reqTs) < 0) return -1; + if (tEncodeI64(pEncoder, pTsmaInfo->rspTs) < 0) return -1; + if (tEncodeI64(pEncoder, pTsmaInfo->delayDuration) < 0) return -1; + if (tEncodeI8(pEncoder, pTsmaInfo->fillHistoryFinished) < 0) return -1; + return 0; +} + +static int32_t tDecodeTableTSMAInfo(SDecoder* pDecoder, STableTSMAInfo* pTsmaInfo) { + if (tDecodeCStrTo(pDecoder, pTsmaInfo->name) < 0) return -1; + if (tDecodeU64(pDecoder, &pTsmaInfo->tsmaId) < 0) return -1; + if (tDecodeCStrTo(pDecoder, pTsmaInfo->tb) < 0) return -1; + if (tDecodeCStrTo(pDecoder, pTsmaInfo->dbFName) < 0) return -1; + if (tDecodeU64(pDecoder, &pTsmaInfo->suid) < 0) return -1; + if (tDecodeU64(pDecoder, &pTsmaInfo->destTbUid) < 0) return -1; + if (tDecodeU64(pDecoder, &pTsmaInfo->dbId) < 0) return -1; + if (tDecodeI32(pDecoder, &pTsmaInfo->version) < 0) return -1; + if (tDecodeCStrTo(pDecoder, pTsmaInfo->targetTb) < 0) return -1; + if (tDecodeCStrTo(pDecoder, pTsmaInfo->targetDbFName) < 0) return -1; + if (tDecodeI64(pDecoder, &pTsmaInfo->interval) < 0) return -1; + if (tDecodeI8(pDecoder, &pTsmaInfo->unit) < 0) return -1; + int32_t size = 0; + if (tDecodeI32(pDecoder, &size) < 0) return -1; + if (size > 0) { + pTsmaInfo->pFuncs = taosArrayInit(size, sizeof(STableTSMAFuncInfo)); + if (!pTsmaInfo->pFuncs) return -1; + for (int32_t i = 0; i < size; ++i) { + STableTSMAFuncInfo funcInfo = {0}; + if (tDecodeI32(pDecoder, &funcInfo.funcId) < 0) return -1; + if (tDecodeI16(pDecoder, &funcInfo.colId) < 0) return -1; + if (!taosArrayPush(pTsmaInfo->pFuncs, &funcInfo)) return -1; + } + } + + if (tDecodeI32(pDecoder, &size) < 0) return -1; + if (size > 0) { + pTsmaInfo->pTags = taosArrayInit(size, sizeof(SSchema)); + if (!pTsmaInfo->pTags) return -1; + for (int32_t i = 0; i < size; ++i) { + SSchema schema = {0}; + if(tDecodeSSchema(pDecoder, &schema) < 0) return -1; + taosArrayPush(pTsmaInfo->pTags, &schema); + } + } + + if (tDecodeI32(pDecoder, &size) < 0) return -1; + if (size > 0) { + pTsmaInfo->pUsedCols = taosArrayInit(size, sizeof(SSchema)); + if (!pTsmaInfo->pUsedCols) return -1; + for (int32_t i = 0; i < size; ++i) { + SSchema schema = {0}; + if (tDecodeSSchema(pDecoder, &schema) < 0) return -1; + taosArrayPush(pTsmaInfo->pUsedCols, &schema); + } + } + if (tDecodeCStrAlloc(pDecoder, &pTsmaInfo->ast) < 0) return -1; + if (tDecodeI64(pDecoder, &pTsmaInfo->streamUid) < 0) return -1; + if (tDecodeI64(pDecoder, &pTsmaInfo->reqTs) < 0) return -1; + if (tDecodeI64(pDecoder, &pTsmaInfo->rspTs) < 0) return -1; + if (tDecodeI64(pDecoder, &pTsmaInfo->delayDuration) < 0) return -1; + if (tDecodeI8(pDecoder, (int8_t*)&pTsmaInfo->fillHistoryFinished) < 0) return -1; + return 0; +} + +static int32_t tEncodeTableTSMAInfoRsp(SEncoder *pEncoder, const STableTSMAInfoRsp *pRsp) { + int32_t size = pRsp->pTsmas ? pRsp->pTsmas->size : 0; + if (tEncodeI32(pEncoder, size) < 0) return -1; + for (int32_t i = 0; i < size; ++i) { + STableTSMAInfo* pInfo = taosArrayGetP(pRsp->pTsmas, i); + if (tEncodeTableTSMAInfo(pEncoder, pInfo) < 0) return -1; + } + return 0; +} + +static int32_t tDecodeTableTSMAInfoRsp(SDecoder* pDecoder, STableTSMAInfoRsp* pRsp) { + int32_t size = 0; + if (tDecodeI32(pDecoder, &size) < 0) return -1; + if (size <= 0) return 0; + pRsp->pTsmas = taosArrayInit(size, POINTER_BYTES); + if (!pRsp->pTsmas) return -1; + for (int32_t i = 0; i < size; ++i) { + STableTSMAInfo *pTsma = taosMemoryCalloc(1, sizeof(STableTSMAInfo)); + if (!pTsma) return -1; + taosArrayPush(pRsp->pTsmas, &pTsma); + if (tDecodeTableTSMAInfo(pDecoder, pTsma) < 0) return -1; + } + return 0; +} + +int32_t tSerializeTableTSMAInfoRsp(void* buf, int32_t bufLen, const STableTSMAInfoRsp* pRsp) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeTableTSMAInfoRsp(&encoder, pRsp) < 0) return -1; + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeTableTSMAInfoRsp(void* buf, int32_t bufLen, STableTSMAInfoRsp* pRsp) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeTableTSMAInfoRsp(&decoder, pRsp) < 0) return -1; + + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + +void tFreeTableTSMAInfo(void* p) { + STableTSMAInfo *pTsmaInfo = p; + if (pTsmaInfo) { + taosArrayDestroy(pTsmaInfo->pFuncs); + taosArrayDestroy(pTsmaInfo->pTags); + taosArrayDestroy(pTsmaInfo->pUsedCols); + taosMemoryFree(pTsmaInfo->ast); + } +} + +void tFreeAndClearTableTSMAInfo(void* p) { + STableTSMAInfo* pTsmaInfo = (STableTSMAInfo*)p; + if (pTsmaInfo) { + tFreeTableTSMAInfo(pTsmaInfo); + taosMemoryFree(pTsmaInfo); + } +} + +int32_t tCloneTbTSMAInfo(STableTSMAInfo* pInfo, STableTSMAInfo** pRes) { + int32_t code = TSDB_CODE_SUCCESS; + if (NULL == pInfo) { + return TSDB_CODE_SUCCESS; + } + STableTSMAInfo* pRet = taosMemoryCalloc(1, sizeof(STableTSMAInfo)); + if (!pRet) return TSDB_CODE_OUT_OF_MEMORY; + + *pRet = *pInfo; + if (pInfo->pFuncs) { + pRet->pFuncs = taosArrayDup(pInfo->pFuncs, NULL); + if (!pRet->pFuncs) code = TSDB_CODE_OUT_OF_MEMORY; + } + if (pInfo->pTags && code == TSDB_CODE_SUCCESS) { + pRet->pTags = taosArrayDup(pInfo->pTags, NULL); + if (!pRet->pTags) code = TSDB_CODE_OUT_OF_MEMORY; + } + if (pInfo->pUsedCols && code == TSDB_CODE_SUCCESS) { + pRet->pUsedCols = taosArrayDup(pInfo->pUsedCols, NULL); + if (!pRet->pUsedCols) code = TSDB_CODE_OUT_OF_MEMORY; + } + if (pInfo->ast && code == TSDB_CODE_SUCCESS) { + pRet->ast = taosStrdup(pInfo->ast); + if (!pRet->ast) code = TSDB_CODE_OUT_OF_MEMORY; + } + if (code) tFreeTableTSMAInfo(pRet); + *pRes = pRet; + return code; +} + +void tFreeTableTSMAInfoRsp(STableTSMAInfoRsp *pRsp) { + if (pRsp && pRsp->pTsmas) { + taosArrayDestroyP(pRsp->pTsmas, tFreeAndClearTableTSMAInfo); + } +} + +static int32_t tEncodeStreamProgressReq(SEncoder *pEncoder, const SStreamProgressReq *pReq) { + if (tEncodeI64(pEncoder, pReq->streamId) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->vgId) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->fetchIdx) < 0) return -1; + if (tEncodeI32(pEncoder, pReq->subFetchIdx) < 0) return -1; + return 0; +} + +int32_t tSerializeStreamProgressReq(void* buf, int32_t bufLen, const SStreamProgressReq* pReq) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeStreamProgressReq(&encoder, pReq) < 0) return -1; + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +static int32_t tDecodeStreamProgressReq(SDecoder* pDecoder, SStreamProgressReq* pReq) { + if (tDecodeI64(pDecoder, &pReq->streamId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->vgId) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->fetchIdx) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->subFetchIdx) < 0) return -1; + return 0; +} + +int32_t tDeserializeStreamProgressReq(void* buf, int32_t bufLen, SStreamProgressReq* pReq) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, (char *)buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeStreamProgressReq(&decoder, pReq) < 0) return -1; + + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + +static int32_t tEncodeStreamProgressRsp(SEncoder* pEncoder, const SStreamProgressRsp* pRsp) { + if (tEncodeI64(pEncoder, pRsp->streamId) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->vgId) < 0) return -1; + if (tEncodeI8(pEncoder, pRsp->fillHisFinished) < 0) return -1; + if (tEncodeI64(pEncoder, pRsp->progressDelay) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->fetchIdx) < 0) return -1; + if (tEncodeI32(pEncoder, pRsp->subFetchIdx) < 0) return -1; + return 0; +} + +int32_t tSerializeStreamProgressRsp(void* buf, int32_t bufLen, const SStreamProgressRsp* pRsp) { + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + + if (tStartEncode(&encoder) < 0) return -1; + if (tEncodeStreamProgressRsp(&encoder, pRsp) < 0) return -1; + + tEndEncode(&encoder); + + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +static int32_t tDecodeStreamProgressRsp(SDecoder* pDecoder, SStreamProgressRsp* pRsp) { + if (tDecodeI64(pDecoder, &pRsp->streamId) < 0) return -1; + if (tDecodeI32(pDecoder, &pRsp->vgId) < 0) return -1; + if (tDecodeI8(pDecoder, (int8_t*)&pRsp->fillHisFinished) < 0) return -1; + if (tDecodeI64(pDecoder, &pRsp->progressDelay) < 0) return -1; + if (tDecodeI32(pDecoder, &pRsp->fetchIdx) < 0) return -1; + if (tDecodeI32(pDecoder, &pRsp->subFetchIdx) < 0) return -1; + return 0; +} + +int32_t tDeserializeSStreamProgressRsp(void* buf, int32_t bufLen, SStreamProgressRsp* pRsp) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + + if (tStartDecode(&decoder) < 0) return -1; + if (tDecodeStreamProgressRsp(&decoder, pRsp) < 0) return -1; + + tEndDecode(&decoder); + + tDecoderClear(&decoder); + return 0; +} + +int32_t tEncodeSMDropTbReqOnSingleVg(SEncoder *pEncoder, const SMDropTbReqsOnSingleVg *pReq) { + const SVgroupInfo* pVgInfo = &pReq->vgInfo; + if (tEncodeI32(pEncoder, pVgInfo->vgId) < 0) return -1; + if (tEncodeU32(pEncoder, pVgInfo->hashBegin) < 0) return -1; + if (tEncodeU32(pEncoder, pVgInfo->hashEnd) < 0) return -1; + if (tEncodeSEpSet(pEncoder, &pVgInfo->epSet) < 0) return -1; + if (tEncodeI32(pEncoder, pVgInfo->numOfTable) < 0) return -1; + int32_t size = pReq->pTbs ? pReq->pTbs->size: 0; + if (tEncodeI32(pEncoder, size) < 0) return -1; + for (int32_t i = 0; i < size; ++i) { + const SVDropTbReq* pInfo = taosArrayGet(pReq->pTbs, i); + if (tEncodeSVDropTbReq(pEncoder, pInfo) < 0) return -1; + } + return 0; +} + +int32_t tDecodeSMDropTbReqOnSingleVg(SDecoder* pDecoder, SMDropTbReqsOnSingleVg* pReq) { + if (tDecodeI32(pDecoder, &pReq->vgInfo.vgId) < 0) return -1; + if (tDecodeU32(pDecoder, &pReq->vgInfo.hashBegin) < 0) return -1; + if (tDecodeU32(pDecoder, &pReq->vgInfo.hashEnd) < 0) return -1; + if (tDecodeSEpSet(pDecoder, &pReq->vgInfo.epSet) < 0) return -1; + if (tDecodeI32(pDecoder, &pReq->vgInfo.numOfTable) < 0) return -1; + int32_t size = 0; + if (tDecodeI32(pDecoder, &size) < 0) return -1; + pReq->pTbs = taosArrayInit(size, sizeof(SVDropTbReq)); + if (!pReq->pTbs) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + SVDropTbReq pTbReq = {0}; + for (int32_t i = 0; i < size; ++i) { + if (tDecodeSVDropTbReq(pDecoder, &pTbReq) < 0) return -1; + taosArrayPush(pReq->pTbs, &pTbReq); + } + return 0; +} + +void tFreeSMDropTbReqOnSingleVg(void *p) { + SMDropTbReqsOnSingleVg* pReq = p; + taosArrayDestroy(pReq->pTbs); +} + +int32_t tSerializeSMDropTbsReq(void* buf, int32_t bufLen, const SMDropTbsReq* pReq){ + SEncoder encoder = {0}; + tEncoderInit(&encoder, buf, bufLen); + tStartEncode(&encoder); + int32_t size = pReq->pVgReqs ? pReq->pVgReqs->size : 0; + if (tEncodeI32(&encoder, size) < 0) return -1; + for (int32_t i = 0; i < size; ++i) { + SMDropTbReqsOnSingleVg* pVgReq = taosArrayGet(pReq->pVgReqs, i); + if (tEncodeSMDropTbReqOnSingleVg(&encoder, pVgReq) < 0) return -1; + } + tEndEncode(&encoder); + int32_t tlen = encoder.pos; + tEncoderClear(&encoder); + return tlen; +} + +int32_t tDeserializeSMDropTbsReq(void* buf, int32_t bufLen, SMDropTbsReq* pReq) { + SDecoder decoder = {0}; + tDecoderInit(&decoder, buf, bufLen); + tStartDecode(&decoder); + int32_t size = 0; + if (tDecodeI32(&decoder, &size) < 0) return -1; + pReq->pVgReqs = taosArrayInit(size, sizeof(SMDropTbReqsOnSingleVg)); + if (!pReq->pVgReqs) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + for (int32_t i = 0; i < size; ++i) { + SMDropTbReqsOnSingleVg vgReq = {0}; + tDecodeSMDropTbReqOnSingleVg(&decoder, &vgReq); + taosArrayPush(pReq->pVgReqs, &vgReq); + } + tEndDecode(&decoder); + tDecoderClear(&decoder); + return 0; +} + +void tFreeSMDropTbsReq(void* p) { + SMDropTbsReq* pReq = p; + taosArrayDestroyEx(pReq->pVgReqs, tFreeSMDropTbReqOnSingleVg); +} + +int32_t tEncodeVFetchTtlExpiredTbsRsp(SEncoder* pCoder, const SVFetchTtlExpiredTbsRsp* pRsp) { + if (tEncodeI32(pCoder, pRsp->vgId) < 0) return -1; + int32_t size = pRsp->pExpiredTbs ? pRsp->pExpiredTbs->size : 0; + if (tEncodeI32(pCoder, size) < 0) return -1; + for (int32_t i = 0; i < size; ++i) { + if (tEncodeSVDropTbReq(pCoder, taosArrayGet(pRsp->pExpiredTbs, i)) < 0) return -1; + } + return 0; +} + +int32_t tDecodeVFetchTtlExpiredTbsRsp(SDecoder* pCoder, SVFetchTtlExpiredTbsRsp* pRsp) { + if (tDecodeI32(pCoder, &pRsp->vgId) < 0) return -1; + int32_t size = 0; + if (tDecodeI32(pCoder, &size) < 0) return -1; + if (size > 0) { + pRsp->pExpiredTbs = taosArrayInit(size, sizeof(SVDropTbReq)); + if (!pRsp->pExpiredTbs) return TSDB_CODE_OUT_OF_MEMORY; + SVDropTbReq tb = {0}; + for (int32_t i = 0; i < size; ++i) { + if (tDecodeSVDropTbReq(pCoder, &tb) < 0) return -1; + taosArrayPush(pRsp->pExpiredTbs, &tb); + } + } + return 0; +} + +void tFreeFetchTtlExpiredTbsRsp(void* p) { + SVFetchTtlExpiredTbsRsp* pRsp = p; + taosArrayDestroy(pRsp->pExpiredTbs); +} diff --git a/source/common/src/ttime.c b/source/common/src/ttime.c index e77d08574e..52379f10d7 100644 --- a/source/common/src/ttime.c +++ b/source/common/src/ttime.c @@ -581,7 +581,7 @@ int32_t convertStringToTimestamp(int16_t type, char* inputData, int64_t timePrec return TSDB_CODE_SUCCESS; } -static int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision) { +int32_t getDuration(int64_t val, char unit, int64_t* result, int32_t timePrecision) { switch (unit) { case 's': if (val > INT64_MAX / MILLISECOND_PER_SECOND) { diff --git a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c index 86b58c3fa7..09267d12b4 100644 --- a/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c +++ b/source/dnode/mgmt/mgmt_mnode/src/mmHandle.c @@ -164,6 +164,14 @@ SArray *mmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_STREAM, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_PAUSE_STREAM, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_RESUME_STREAM, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_GRANT_RSP, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_CREATE_TSMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_TSMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_STB_DROP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_STB_DROP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_MND_DROP_TB_WITH_TSMA, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH_TTL_EXPIRED_TBS_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TABLE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_RETRIEVE_IP_WHITE, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_GET_USER_WHITELIST, mmPutMsgToReadQueue, 0) == NULL) goto _OVER; @@ -222,6 +230,10 @@ SArray *mmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_PAUSE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_RESUME_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_STREAM_TASK_STOP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_STREAM_CREATE, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_STREAM_DROP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_STREAM_CREATE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_STREAM_DROP_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_CHECK_POINT_SOURCE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_UPDATE_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_RESET_RSP, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER; diff --git a/source/dnode/mgmt/mgmt_snode/src/smHandle.c b/source/dnode/mgmt/mgmt_snode/src/smHandle.c index 1b1dcc9b54..880e96adfb 100644 --- a/source/dnode/mgmt/mgmt_snode/src/smHandle.c +++ b/source/dnode/mgmt/mgmt_snode/src/smHandle.c @@ -91,6 +91,7 @@ SArray *smGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_RESET, smPutNodeMsgToMgmtQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_HEARTBEAT_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_REQ_CHKPT_RSP, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_GET_STREAM_PROGRESS, smPutNodeMsgToStreamQueue, 1) == NULL) goto _OVER; code = 0; _OVER: diff --git a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c index c9c1cad643..4ada92d20e 100644 --- a/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c +++ b/source/dnode/mgmt/mgmt_vnode/src/vmHandle.c @@ -884,6 +884,7 @@ SArray *vmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_SCH_TASK_NOTIFY, vmPutMsgToFetchQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_STB, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_TTL_TABLE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_FETCH_TTL_EXPIRED_TBS, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_STB, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_DROP_STB, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_CREATE_TABLE, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; @@ -930,6 +931,7 @@ SArray *vmGetMsgHandles() { if (dmSetMgmtHandle(pArray, TDMT_VND_STREAM_TASK_RESET, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_HEARTBEAT_RSP, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_MND_STREAM_REQ_CHKPT_RSP, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER; + if (dmSetMgmtHandle(pArray, TDMT_VND_GET_STREAM_PROGRESS, vmPutMsgToStreamQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_REPLICA, vmPutMsgToMgmtQueue, 0) == NULL) goto _OVER; if (dmSetMgmtHandle(pArray, TDMT_VND_ALTER_CONFIG, vmPutMsgToWriteQueue, 0) == NULL) goto _OVER; diff --git a/source/dnode/mnode/impl/inc/mndDb.h b/source/dnode/mnode/impl/inc/mndDb.h index 5569a6ec9f..8704286826 100644 --- a/source/dnode/mnode/impl/inc/mndDb.h +++ b/source/dnode/mnode/impl/inc/mndDb.h @@ -29,6 +29,7 @@ void mndReleaseDb(SMnode *pMnode, SDbObj *pDb); int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs, void **ppRsp, int32_t *pRspLen); int32_t mndExtractDbInfo(SMnode *pMnode, SDbObj *pDb, SUseDbRsp *pRsp, const SUseDbReq *pReq); bool mndIsDbReady(SMnode *pMnode, SDbObj *pDb); +void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SArray *pVgList); SSdbRaw *mndDbActionEncode(SDbObj *pDb); const char *mndGetDbStr(const char *src); diff --git a/source/dnode/mnode/impl/inc/mndDef.h b/source/dnode/mnode/impl/inc/mndDef.h index 005bb535bc..f41e56a9a0 100644 --- a/source/dnode/mnode/impl/inc/mndDef.h +++ b/source/dnode/mnode/impl/inc/mndDef.h @@ -398,6 +398,7 @@ typedef struct { SRWLatch lock; int64_t stateTs; int64_t compactStartTime; + int32_t tsmaVersion; } SDbObj; typedef struct { @@ -457,12 +458,14 @@ typedef struct { int32_t tagsFilterLen; int32_t sqlLen; int32_t astLen; + int32_t version; char* expr; char* tagsFilter; char* sql; char* ast; SSchemaWrapper schemaRow; // for dstVgroup SSchemaWrapper schemaTag; // for dstVgroup + char baseSmaName[TSDB_TABLE_FNAME_LEN]; } SSmaObj; typedef struct { diff --git a/source/dnode/mnode/impl/inc/mndSma.h b/source/dnode/mnode/impl/inc/mndSma.h index 48e93c43fb..6e466aeea6 100644 --- a/source/dnode/mnode/impl/inc/mndSma.h +++ b/source/dnode/mnode/impl/inc/mndSma.h @@ -29,6 +29,9 @@ void mndReleaseSma(SMnode *pMnode, SSmaObj *pSma); int32_t mndDropSmasByStb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb, SStbObj *pStb); int32_t mndDropSmasByDb(SMnode *pMnode, STrans *pTrans, SDbObj *pDb); int32_t mndGetTableSma(SMnode *pMnode, char *tbFName, STableIndexRsp *rsp, bool *exist); +int32_t mndValidateTSMAInfo(SMnode *pMnode, STSMAVersion *pTsmaVersions, int32_t numOfTsmas, void **ppRsp, + int32_t *pRspLen); +int32_t mndGetDbTsmas(SMnode *pMnode, const char *dbFName, uint64_t dbUid, STableTSMAInfoRsp *pRsp, bool *exist); #ifdef __cplusplus } diff --git a/source/dnode/mnode/impl/src/mndDb.c b/source/dnode/mnode/impl/src/mndDb.c index 2eed36d3d7..26649df530 100644 --- a/source/dnode/mnode/impl/src/mndDb.c +++ b/source/dnode/mnode/impl/src/mndDb.c @@ -36,7 +36,7 @@ #include "tjson.h" #define DB_VER_NUMBER 1 -#define DB_RESERVE_SIZE 32 +#define DB_RESERVE_SIZE 28 static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw); static int32_t mndDbActionInsert(SSdb *pSdb, SDbObj *pDb); @@ -146,6 +146,7 @@ SSdbRaw *mndDbActionEncode(SDbObj *pDb) { SDB_SET_INT32(pRaw, dataPos, pDb->cfg.s3KeepLocal, _OVER) SDB_SET_INT8(pRaw, dataPos, pDb->cfg.s3Compact, _OVER) SDB_SET_INT8(pRaw, dataPos, pDb->cfg.withArbitrator, _OVER) + SDB_SET_INT32(pRaw, dataPos, pDb->tsmaVersion, _OVER); SDB_SET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER) SDB_SET_DATALEN(pRaw, dataPos, _OVER) @@ -241,6 +242,7 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) { SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.s3KeepLocal, _OVER) SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.s3Compact, _OVER) SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.withArbitrator, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pDb->tsmaVersion, _OVER); SDB_GET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER) taosInitRWLatch(&pDb->lock); @@ -347,6 +349,7 @@ static int32_t mndDbActionUpdate(SSdb *pSdb, SDbObj *pOld, SDbObj *pNew) { pOld->cfg.s3Compact = pNew->cfg.s3Compact; pOld->cfg.withArbitrator = pNew->cfg.withArbitrator; pOld->compactStartTime = pNew->compactStartTime; + pOld->tsmaVersion = pNew->tsmaVersion; taosWUnLockLatch(&pOld->lock); return 0; } @@ -681,6 +684,7 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate, dbObj.uid = mndGenerateUid(dbObj.name, TSDB_DB_FNAME_LEN); dbObj.cfgVersion = 1; dbObj.vgVersion = 1; + dbObj.tsmaVersion = 1; memcpy(dbObj.createUser, pUser->user, TSDB_USER_LEN); dbObj.cfg = (SDbCfg){ .numOfVgroups = pCreate->numOfVgroups, @@ -1521,7 +1525,7 @@ static int32_t mndGetDBTableNum(SDbObj *pDb, SMnode *pMnode) { return numOfTables; } -static void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SArray *pVgList) { +void mndBuildDBVgroupInfo(SDbObj *pDb, SMnode *pMnode, SArray *pVgList) { int32_t vindex = 0; SSdb *pSdb = pMnode->pSdb; @@ -1682,6 +1686,7 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs, pDbCacheInfo->cfgVersion = htonl(pDbCacheInfo->cfgVersion); pDbCacheInfo->numOfTable = htonl(pDbCacheInfo->numOfTable); pDbCacheInfo->stateTs = be64toh(pDbCacheInfo->stateTs); + pDbCacheInfo->tsmaVersion = htonl(pDbCacheInfo->tsmaVersion); SDbHbRsp rsp = {0}; @@ -1720,7 +1725,8 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs, int32_t numOfTable = mndGetDBTableNum(pDb, pMnode); if (pDbCacheInfo->vgVersion >= pDb->vgVersion && pDbCacheInfo->cfgVersion >= pDb->cfgVersion && - numOfTable == pDbCacheInfo->numOfTable && pDbCacheInfo->stateTs == pDb->stateTs) { + numOfTable == pDbCacheInfo->numOfTable && pDbCacheInfo->stateTs == pDb->stateTs && + pDbCacheInfo->tsmaVersion >= pDb->tsmaVersion) { mTrace("db:%s, valid dbinfo, vgVersion:%d cfgVersion:%d stateTs:%" PRId64 " numOfTables:%d, not changed vgVersion:%d cfgVersion:%d stateTs:%" PRId64 " numOfTables:%d", pDbCacheInfo->dbFName, pDbCacheInfo->vgVersion, pDbCacheInfo->cfgVersion, pDbCacheInfo->stateTs, @@ -1739,6 +1745,16 @@ int32_t mndValidateDbInfo(SMnode *pMnode, SDbCacheInfo *pDbs, int32_t numOfDbs, mndDumpDbCfgInfo(rsp.cfgRsp, pDb); } + if (pDbCacheInfo->tsmaVersion != pDb->tsmaVersion) { + rsp.pTsmaRsp = taosMemoryCalloc(1, sizeof(STableTSMAInfoRsp)); + if (rsp.pTsmaRsp) rsp.pTsmaRsp->pTsmas = taosArrayInit(4, POINTER_BYTES); + if (rsp.pTsmaRsp && rsp.pTsmaRsp->pTsmas) { + rsp.dbTsmaVersion = pDb->tsmaVersion; + bool exist = false; + mndGetDbTsmas(pMnode, 0, pDb->uid, rsp.pTsmaRsp, &exist); + } + } + if (pDbCacheInfo->vgVersion < pDb->vgVersion || numOfTable != pDbCacheInfo->numOfTable || pDbCacheInfo->stateTs != pDb->stateTs) { rsp.useDbRsp = taosMemoryCalloc(1, sizeof(SUseDbRsp)); diff --git a/source/dnode/mnode/impl/src/mndProfile.c b/source/dnode/mnode/impl/src/mndProfile.c index e0559b4c48..22d2eb5a59 100644 --- a/source/dnode/mnode/impl/src/mndProfile.c +++ b/source/dnode/mnode/impl/src/mndProfile.c @@ -25,6 +25,7 @@ #include "mndStb.h" #include "mndUser.h" #include "mndView.h" +#include "mndSma.h" #include "tglobal.h" #include "tversion.h" @@ -606,6 +607,16 @@ static int32_t mndProcessQueryHeartBeat(SMnode *pMnode, SRpcMsg *pMsg, SClientHb break; } #endif + case HEARTBEAT_KEY_TSMA: { + void * rspMsg = NULL; + int32_t rspLen = 0; + mndValidateTSMAInfo(pMnode, kv->value, kv->valueLen / sizeof(STSMAVersion), &rspMsg, &rspLen); + if (rspMsg && rspLen > 0) { + SKv kv = {.key = HEARTBEAT_KEY_TSMA, .valueLen = rspLen, .value = rspMsg}; + taosArrayPush(hbRsp.info, &kv); + } + break; + } default: mError("invalid kv key:%d", kv->key); hbRsp.status = TSDB_CODE_APP_ERROR; diff --git a/source/dnode/mnode/impl/src/mndScheduler.c b/source/dnode/mnode/impl/src/mndScheduler.c index 9aba428ff6..fc2e3b4619 100644 --- a/source/dnode/mnode/impl/src/mndScheduler.c +++ b/source/dnode/mnode/impl/src/mndScheduler.c @@ -109,7 +109,7 @@ int32_t mndSetSinkTaskInfo(SStreamObj* pStream, SStreamTask* pTask) { mDebug("mndSetSinkTaskInfo to sma or table, taskId:%s", pTask->id.idStr); - if (pStream->smaId != 0) { + if (pStream->smaId != 0 && pStream->subTableWithoutMd5 != 1) { pInfo->type = TASK_OUTPUT__SMA; pInfo->smaSink.smaId = pStream->smaId; } else { diff --git a/source/dnode/mnode/impl/src/mndShow.c b/source/dnode/mnode/impl/src/mndShow.c index b3124fa99f..8c6ab6e518 100644 --- a/source/dnode/mnode/impl/src/mndShow.c +++ b/source/dnode/mnode/impl/src/mndShow.c @@ -131,6 +131,8 @@ static int32_t convertToRetrieveType(char *name, int32_t len) { type = TSDB_MGMT_TABLE_GRANTS_LOGS; } else if (strncasecmp(name, TSDB_INS_TABLE_MACHINES, len) == 0) { type = TSDB_MGMT_TABLE_MACHINES; + } else if (strncasecmp(name, TSDB_INS_TABLE_TSMAS, len) == 0) { + type = TSDB_MGMT_TABLE_TSMAS; } else { mError("invalid show name:%s len:%d", name, len); } diff --git a/source/dnode/mnode/impl/src/mndSma.c b/source/dnode/mnode/impl/src/mndSma.c index 05189d5a53..dd569b4c59 100644 --- a/source/dnode/mnode/impl/src/mndSma.c +++ b/source/dnode/mnode/impl/src/mndSma.c @@ -31,6 +31,7 @@ #include "mndVgroup.h" #include "parser.h" #include "tname.h" +#include "functionMgt.h" #define TSDB_SMA_VER_NUMBER 1 #define TSDB_SMA_RESERVE_SIZE 64 @@ -47,11 +48,36 @@ static int32_t mndProcessGetTbSmaReq(SRpcMsg *pReq); static int32_t mndRetrieveSma(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); static void mndDestroySmaObj(SSmaObj *pSmaObj); +static int32_t mndProcessCreateTSMAReq(SRpcMsg* pReq); +static int32_t mndProcessDropTSMAReq(SRpcMsg* pReq); + // sma and tag index comm func static int32_t mndProcessDropIdxReq(SRpcMsg *pReq); static int32_t mndRetrieveIdx(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); static void mndCancelRetrieveIdx(SMnode *pMnode, void *pIter); +static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows); +static void mndCancelRetrieveTSMA(SMnode *pMnode, void *pIter); +static int32_t mndProcessGetTbTSMAReq(SRpcMsg *pReq); + +typedef struct SCreateTSMACxt { + SMnode * pMnode; + const SRpcMsg *pRpcReq; + union { + const SMCreateSmaReq *pCreateSmaReq; + const SMDropSmaReq * pDropSmaReq; + }; + SDbObj *pDb; + SStbObj *pSrcStb; + SSmaObj *pSma; + const SSmaObj *pBaseSma; + SCMCreateStreamReq *pCreateStreamReq; + SMDropStreamReq *pDropStreamReq; + const char *streamName; + const char *targetStbFullName; + SNodeList *pProjects; +} SCreateTSMACxt; + int32_t mndInitSma(SMnode *pMnode) { SSdbTable table = { .sdbType = SDB_SMA, @@ -72,6 +98,14 @@ int32_t mndInitSma(SMnode *pMnode) { mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_INDEX, mndRetrieveIdx); mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_INDEX, mndCancelRetrieveIdx); + + mndSetMsgHandle(pMnode, TDMT_MND_CREATE_TSMA, mndProcessCreateTSMAReq); + mndSetMsgHandle(pMnode, TDMT_MND_DROP_TSMA, mndProcessDropTSMAReq); + mndSetMsgHandle(pMnode, TDMT_MND_GET_TABLE_TSMA, mndProcessGetTbTSMAReq); + mndSetMsgHandle(pMnode, TDMT_MND_GET_TSMA, mndProcessGetTbTSMAReq); + mndAddShowRetrieveHandle(pMnode, TSDB_MGMT_TABLE_TSMAS, mndRetrieveTSMA); + mndAddShowFreeIterHandle(pMnode, TSDB_MGMT_TABLE_TSMAS, mndCancelRetrieveTSMA); + return sdbSetTable(pMnode->pSdb, table); } @@ -89,7 +123,7 @@ static SSdbRaw *mndSmaActionEncode(SSmaObj *pSma) { SDB_SET_BINARY(pRaw, dataPos, pSma->name, TSDB_TABLE_FNAME_LEN, _OVER) SDB_SET_BINARY(pRaw, dataPos, pSma->stb, TSDB_TABLE_FNAME_LEN, _OVER) SDB_SET_BINARY(pRaw, dataPos, pSma->db, TSDB_DB_FNAME_LEN, _OVER) - SDB_SET_BINARY(pRaw, dataPos, pSma->dstTbName, TSDB_DB_FNAME_LEN, _OVER) + SDB_SET_BINARY(pRaw, dataPos, pSma->dstTbName, TSDB_TABLE_FNAME_LEN, _OVER) SDB_SET_INT64(pRaw, dataPos, pSma->createdTime, _OVER) SDB_SET_INT64(pRaw, dataPos, pSma->uid, _OVER) SDB_SET_INT64(pRaw, dataPos, pSma->stbUid, _OVER) @@ -106,6 +140,7 @@ static SSdbRaw *mndSmaActionEncode(SSmaObj *pSma) { SDB_SET_INT32(pRaw, dataPos, pSma->tagsFilterLen, _OVER) SDB_SET_INT32(pRaw, dataPos, pSma->sqlLen, _OVER) SDB_SET_INT32(pRaw, dataPos, pSma->astLen, _OVER) + SDB_SET_INT32(pRaw, dataPos, pSma->version, _OVER) if (pSma->exprLen > 0) { SDB_SET_BINARY(pRaw, dataPos, pSma->expr, pSma->exprLen, _OVER) @@ -119,6 +154,7 @@ static SSdbRaw *mndSmaActionEncode(SSmaObj *pSma) { if (pSma->astLen > 0) { SDB_SET_BINARY(pRaw, dataPos, pSma->ast, pSma->astLen, _OVER) } + SDB_SET_BINARY(pRaw, dataPos, pSma->baseSmaName, TSDB_TABLE_FNAME_LEN, _OVER) SDB_SET_RESERVE(pRaw, dataPos, TSDB_SMA_RESERVE_SIZE, _OVER) SDB_SET_DATALEN(pRaw, dataPos, _OVER) @@ -160,7 +196,7 @@ static SSdbRow *mndSmaActionDecode(SSdbRaw *pRaw) { SDB_GET_BINARY(pRaw, dataPos, pSma->name, TSDB_TABLE_FNAME_LEN, _OVER) SDB_GET_BINARY(pRaw, dataPos, pSma->stb, TSDB_TABLE_FNAME_LEN, _OVER) SDB_GET_BINARY(pRaw, dataPos, pSma->db, TSDB_DB_FNAME_LEN, _OVER) - SDB_GET_BINARY(pRaw, dataPos, pSma->dstTbName, TSDB_DB_FNAME_LEN, _OVER) + SDB_GET_BINARY(pRaw, dataPos, pSma->dstTbName, TSDB_TABLE_FNAME_LEN, _OVER) SDB_GET_INT64(pRaw, dataPos, &pSma->createdTime, _OVER) SDB_GET_INT64(pRaw, dataPos, &pSma->uid, _OVER) SDB_GET_INT64(pRaw, dataPos, &pSma->stbUid, _OVER) @@ -177,6 +213,7 @@ static SSdbRow *mndSmaActionDecode(SSdbRaw *pRaw) { SDB_GET_INT32(pRaw, dataPos, &pSma->tagsFilterLen, _OVER) SDB_GET_INT32(pRaw, dataPos, &pSma->sqlLen, _OVER) SDB_GET_INT32(pRaw, dataPos, &pSma->astLen, _OVER) + SDB_GET_INT32(pRaw, dataPos, &pSma->version, _OVER) if (pSma->exprLen > 0) { pSma->expr = taosMemoryCalloc(pSma->exprLen, 1); @@ -201,6 +238,7 @@ static SSdbRow *mndSmaActionDecode(SSdbRaw *pRaw) { if (pSma->ast == NULL) goto _OVER; SDB_GET_BINARY(pRaw, dataPos, pSma->ast, pSma->astLen, _OVER) } + SDB_GET_BINARY(pRaw, dataPos, pSma->baseSmaName, TSDB_TABLE_FNAME_LEN, _OVER) SDB_GET_RESERVE(pRaw, dataPos, TSDB_SMA_RESERVE_SIZE, _OVER) @@ -375,6 +413,14 @@ static int32_t mndSetCreateSmaRedoLogs(SMnode *pMnode, STrans *pTrans, SSmaObj * return 0; } +static int32_t mndSetCreateSmaUndoLogs(SMnode* pMnode, STrans* pTrans, SSmaObj* pSma) { + SSdbRaw * pUndoRaw = mndSmaActionEncode(pSma); + if (!pUndoRaw) return -1; + if (mndTransAppendUndolog(pTrans, pUndoRaw) != 0) return -1; + if (sdbSetRawStatus(pUndoRaw, SDB_STATUS_DROPPED) != 0) return -1; + return 0; +} + static int32_t mndSetCreateSmaCommitLogs(SMnode *pMnode, STrans *pTrans, SSmaObj *pSma) { SSdbRaw *pCommitRaw = mndSmaActionEncode(pSma); if (pCommitRaw == NULL) return -1; @@ -567,7 +613,6 @@ static int32_t mndCreateSma(SMnode *pMnode, SRpcMsg *pReq, SMCreateSmaReq *pCrea streamObj.conf.triggerParam = pCreate->maxDelay; streamObj.ast = taosStrdup(smaObj.ast); streamObj.indexForMultiAggBalance = -1; - streamObj.subTableWithoutMd5 = 1; // check the maxDelay if (streamObj.conf.triggerParam < TSDB_MIN_ROLLUP_MAX_DELAY) { @@ -687,9 +732,7 @@ static int32_t mndCheckCreateSmaReq(SMCreateSmaReq *pCreate) { static void mndGetStreamNameFromSmaName(char *streamName, char *smaName) { SName n; tNameFromString(&n, smaName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); - streamName[0] = '1'; - streamName[1] = '.'; - strcpy(streamName + 2, tNameGetTableName(&n)); + sprintf(streamName, "%d.%s", n.acctId, n.tname); } static int32_t mndProcessCreateSmaReq(SRpcMsg *pReq) { @@ -1092,6 +1135,7 @@ int32_t mndGetTableSma(SMnode *pMnode, char *tbFName, STableIndexRsp *rsp, bool if (pIter == NULL) break; if (pSma->stb[0] != tbFName[0] || strcmp(pSma->stb, tbFName)) { + sdbRelease(pSdb, pSma); continue; } @@ -1107,6 +1151,7 @@ int32_t mndGetTableSma(SMnode *pMnode, char *tbFName, STableIndexRsp *rsp, bool if (pVg == NULL) { code = -1; sdbRelease(pSdb, pSma); + sdbCancelFetch(pSdb, pIter); return code; } info.epSet = mndGetVgroupEpset(pMnode, pVg); @@ -1116,6 +1161,7 @@ int32_t mndGetTableSma(SMnode *pMnode, char *tbFName, STableIndexRsp *rsp, bool terrno = TSDB_CODE_OUT_OF_MEMORY; code = -1; sdbRelease(pSdb, pSma); + sdbCancelFetch(pSdb, pIter); return code; } @@ -1127,6 +1173,7 @@ int32_t mndGetTableSma(SMnode *pMnode, char *tbFName, STableIndexRsp *rsp, bool code = -1; taosMemoryFree(info.expr); sdbRelease(pSdb, pSma); + sdbCancelFetch(pSdb, pIter); return code; } @@ -1345,3 +1392,1053 @@ static void mndCancelRetrieveIdx(SMnode *pMnode, void *pIter) { } taosMemoryFree(p); } + +static void initSMAObj(SCreateTSMACxt* pCxt) { + memcpy(pCxt->pSma->name, pCxt->pCreateSmaReq->name, TSDB_TABLE_FNAME_LEN); + memcpy(pCxt->pSma->stb, pCxt->pCreateSmaReq->stb, TSDB_TABLE_FNAME_LEN); + memcpy(pCxt->pSma->db, pCxt->pDb->name, TSDB_DB_FNAME_LEN); + if (pCxt->pBaseSma) memcpy(pCxt->pSma->baseSmaName, pCxt->pBaseSma->name, TSDB_TABLE_FNAME_LEN); + pCxt->pSma->createdTime = taosGetTimestampMs(); + pCxt->pSma->uid = mndGenerateUid(pCxt->pCreateSmaReq->name, TSDB_TABLE_FNAME_LEN); + + memcpy(pCxt->pSma->dstTbName, pCxt->targetStbFullName, TSDB_TABLE_FNAME_LEN); + pCxt->pSma->dstTbUid = 0; // not used + pCxt->pSma->stbUid = pCxt->pSrcStb ? pCxt->pSrcStb->uid : pCxt->pCreateSmaReq->normSourceTbUid; + pCxt->pSma->dbUid = pCxt->pDb->uid; + pCxt->pSma->interval = pCxt->pCreateSmaReq->interval; + pCxt->pSma->intervalUnit = pCxt->pCreateSmaReq->intervalUnit; + pCxt->pSma->timezone = tsTimezone; + pCxt->pSma->version = 1; + + pCxt->pSma->exprLen = pCxt->pCreateSmaReq->exprLen; + pCxt->pSma->sqlLen = pCxt->pCreateSmaReq->sqlLen; + pCxt->pSma->astLen = pCxt->pCreateSmaReq->astLen; + pCxt->pSma->expr = pCxt->pCreateSmaReq->expr; + pCxt->pSma->sql = pCxt->pCreateSmaReq->sql; + pCxt->pSma->ast = pCxt->pCreateSmaReq->ast; +} + +static void initStreamObj(SStreamObj *pStream, const char *streamName, const SMCreateSmaReq *pCreateReq, + const SDbObj *pDb, SSmaObj *pSma) { + tstrncpy(pStream->name, streamName, TSDB_STREAM_FNAME_LEN); + tstrncpy(pStream->sourceDb, pDb->name, TSDB_DB_FNAME_LEN); + tstrncpy(pStream->targetDb, pDb->name, TSDB_DB_FNAME_LEN); + pStream->createTime = taosGetTimestampMs(); + pStream->updateTime = pStream->createTime; + pStream->uid = mndGenerateUid(streamName, strlen(streamName)); + pStream->sourceDbUid = pDb->uid; + pStream->targetDbUid = pDb->uid; + pStream->version = 1; + pStream->sql = taosStrdup(pCreateReq->sql); + pStream->smaId = pSma->uid; + pStream->conf.watermark = 0; + pStream->deleteMark = 0; + pStream->conf.fillHistory = STREAM_FILL_HISTORY_ON; + pStream->conf.trigger = STREAM_TRIGGER_WINDOW_CLOSE; + pStream->conf.triggerParam = 10000; + pStream->ast = taosStrdup(pSma->ast); +} + +static void mndCreateTSMABuildCreateStreamReq(SCreateTSMACxt *pCxt) { + tstrncpy(pCxt->pCreateStreamReq->name, pCxt->streamName, TSDB_STREAM_FNAME_LEN); + tstrncpy(pCxt->pCreateStreamReq->sourceDB, pCxt->pDb->name, TSDB_DB_FNAME_LEN); + tstrncpy(pCxt->pCreateStreamReq->targetStbFullName, pCxt->targetStbFullName, TSDB_TABLE_FNAME_LEN); + pCxt->pCreateStreamReq->igExists = false; + pCxt->pCreateStreamReq->triggerType = STREAM_TRIGGER_MAX_DELAY; + pCxt->pCreateStreamReq->igExpired = false; + pCxt->pCreateStreamReq->fillHistory = STREAM_FILL_HISTORY_ON; + pCxt->pCreateStreamReq->maxDelay = 10000; + pCxt->pCreateStreamReq->watermark = 0; + pCxt->pCreateStreamReq->numOfTags = pCxt->pSrcStb ? pCxt->pSrcStb->numOfTags + 1 : 1; + pCxt->pCreateStreamReq->checkpointFreq = 0; + pCxt->pCreateStreamReq->createStb = 1; + pCxt->pCreateStreamReq->targetStbUid = 0; + pCxt->pCreateStreamReq->fillNullCols = NULL; + pCxt->pCreateStreamReq->igUpdate = 0; + pCxt->pCreateStreamReq->lastTs = pCxt->pCreateSmaReq->lastTs; + pCxt->pCreateStreamReq->smaId = pCxt->pSma->uid; + pCxt->pCreateStreamReq->ast = strdup(pCxt->pCreateSmaReq->ast); + pCxt->pCreateStreamReq->sql = strdup(pCxt->pCreateSmaReq->sql); + + // construct tags + pCxt->pCreateStreamReq->pTags = taosArrayInit(pCxt->pCreateStreamReq->numOfTags, sizeof(SField)); + SField f = {0}; + if (pCxt->pSrcStb) { + for (int32_t idx = 0; idx < pCxt->pCreateStreamReq->numOfTags - 1; ++idx) { + SSchema *pSchema = &pCxt->pSrcStb->pTags[idx]; + f.bytes = pSchema->bytes; + f.type = pSchema->type; + f.flags = pSchema->flags; + tstrncpy(f.name, pSchema->name, TSDB_COL_NAME_LEN); + taosArrayPush(pCxt->pCreateStreamReq->pTags, &f); + } + } + f.bytes = TSDB_TABLE_FNAME_LEN - 1 + VARSTR_HEADER_SIZE; + f.flags = COL_SMA_ON; + f.type = TSDB_DATA_TYPE_BINARY; + tstrncpy(f.name, "tbname", strlen("tbname") + 1); + taosArrayPush(pCxt->pCreateStreamReq->pTags, &f); + + // construct output cols + SNode* pNode; + FOREACH(pNode, pCxt->pProjects) { + SExprNode* pExprNode = (SExprNode*)pNode; + f.bytes = pExprNode->resType.bytes; + f.type = pExprNode->resType.type; + f.flags = COL_SMA_ON; + strcpy(f.name, pExprNode->userAlias); + taosArrayPush(pCxt->pCreateStreamReq->pCols, &f); + } +} + +static void mndCreateTSMABuildDropStreamReq(SCreateTSMACxt* pCxt) { + tstrncpy(pCxt->pDropStreamReq->name, pCxt->streamName, TSDB_STREAM_FNAME_LEN); + pCxt->pDropStreamReq->igNotExists = false; + pCxt->pDropStreamReq->sql = strdup(pCxt->pDropSmaReq->name); + pCxt->pDropStreamReq->sqlLen = strlen(pCxt->pDropStreamReq->sql); +} + +static int32_t mndSetUpdateDbTsmaVersionPrepareLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pOld, SDbObj *pNew) { + SSdbRaw *pRedoRaw = mndDbActionEncode(pOld); + if (pRedoRaw == NULL) return -1; + if (mndTransAppendPrepareLog(pTrans, pRedoRaw) != 0) { + sdbFreeRaw(pRedoRaw); + return -1; + } + + (void)sdbSetRawStatus(pRedoRaw, SDB_STATUS_READY); + return 0; +} + +static int32_t mndSetUpdateDbTsmaVersionCommitLogs(SMnode *pMnode, STrans *pTrans, SDbObj *pOld, SDbObj *pNew) { + SSdbRaw *pCommitRaw = mndDbActionEncode(pNew); + if (pCommitRaw == NULL) return -1; + if (mndTransAppendCommitlog(pTrans, pCommitRaw) != 0) { + sdbFreeRaw(pCommitRaw); + return -1; + } + + (void)sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY); + return 0; +} + +static int32_t mndCreateTSMATxnPrepare(SCreateTSMACxt* pCxt) { + int32_t code = -1; + STransAction createStreamRedoAction = {0}; + STransAction createStreamUndoAction = {0}; + STrans *pTrans = + mndTransCreate(pCxt->pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, pCxt->pRpcReq, "create-tsma"); + if (!pTrans) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _OVER; + } + mndTransSetDbName(pTrans, pCxt->pDb->name, NULL); + if (mndTransCheckConflict(pCxt->pMnode, pTrans) != 0) goto _OVER; + + mndTransSetSerial(pTrans); + mInfo("trans:%d, used to create tsma:%s stream:%s", pTrans->id, pCxt->pCreateSmaReq->name, + pCxt->pCreateStreamReq->name); + + mndGetMnodeEpSet(pCxt->pMnode, &createStreamRedoAction.epSet); + createStreamRedoAction.acceptableCode = TSDB_CODE_MND_STREAM_ALREADY_EXIST; + createStreamRedoAction.msgType = TDMT_STREAM_CREATE; + createStreamRedoAction.contLen = tSerializeSCMCreateStreamReq(0, 0, pCxt->pCreateStreamReq); + createStreamRedoAction.pCont = taosMemoryCalloc(1, createStreamRedoAction.contLen); + if (!createStreamRedoAction.pCont) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _OVER; + } + if (createStreamRedoAction.contLen != tSerializeSCMCreateStreamReq(createStreamRedoAction.pCont, createStreamRedoAction.contLen, pCxt->pCreateStreamReq)) { + mError("sma: %s, failed to create due to create stream req encode failure", pCxt->pCreateSmaReq->name); + terrno = TSDB_CODE_INVALID_MSG; + goto _OVER; + } + + createStreamUndoAction.epSet = createStreamRedoAction.epSet; + createStreamUndoAction.acceptableCode = TSDB_CODE_MND_STREAM_NOT_EXIST; + createStreamUndoAction.actionType = TDMT_STREAM_DROP; + createStreamUndoAction.contLen = tSerializeSMDropStreamReq(0, 0, pCxt->pDropStreamReq); + createStreamUndoAction.pCont = taosMemoryCalloc(1, createStreamUndoAction.contLen); + if (!createStreamUndoAction.pCont) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _OVER; + } + if (createStreamUndoAction.contLen != tSerializeSMDropStreamReq(createStreamUndoAction.pCont, createStreamUndoAction.contLen, pCxt->pDropStreamReq)) { + mError("sma: %s, failed to create due to drop stream req encode failure", pCxt->pCreateSmaReq->name); + terrno = TSDB_CODE_INVALID_MSG; + goto _OVER; + } + + SDbObj newDb = {0}; + memcpy(&newDb, pCxt->pDb, sizeof(SDbObj)); + newDb.tsmaVersion++; + if (mndSetUpdateDbTsmaVersionPrepareLogs(pCxt->pMnode, pTrans, pCxt->pDb, &newDb) != 0) goto _OVER; + if (mndSetUpdateDbTsmaVersionCommitLogs(pCxt->pMnode, pTrans, pCxt->pDb, &newDb) != 0) goto _OVER; + if (mndSetCreateSmaRedoLogs(pCxt->pMnode, pTrans, pCxt->pSma) != 0) goto _OVER; + if (mndSetCreateSmaUndoLogs(pCxt->pMnode, pTrans, pCxt->pSma) != 0) goto _OVER; + if (mndSetCreateSmaCommitLogs(pCxt->pMnode, pTrans, pCxt->pSma) != 0) goto _OVER; + if (mndTransAppendRedoAction(pTrans, &createStreamRedoAction) != 0) goto _OVER; + if (mndTransAppendUndoAction(pTrans, &createStreamUndoAction) != 0) goto _OVER; + if (mndTransPrepare(pCxt->pMnode, pTrans) != 0) goto _OVER; + + code = TSDB_CODE_SUCCESS; + +_OVER: + mndTransDrop(pTrans); + return code; +} + +static int32_t mndCreateTSMA(SCreateTSMACxt *pCxt) { + int32_t code; + SSmaObj sma = {0}; + SCMCreateStreamReq createStreamReq = {0}; + SMDropStreamReq dropStreamReq = {0}; + + pCxt->pSma = &sma; + initSMAObj(pCxt); + + SNodeList* pProjects = NULL; + terrno = nodesStringToList(pCxt->pCreateSmaReq->expr, &pProjects); + if (TSDB_CODE_SUCCESS != terrno) { + code = -1; + goto _OVER; + } + pCxt->pProjects = pProjects; + + pCxt->pCreateStreamReq = &createStreamReq; + if (pCxt->pCreateSmaReq->pVgroupVerList) { + pCxt->pCreateStreamReq->pVgroupVerList = taosArrayDup(pCxt->pCreateSmaReq->pVgroupVerList, NULL); + if (!pCxt->pCreateStreamReq->pVgroupVerList) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + code = -1; + goto _OVER; + } + } + if (LIST_LENGTH(pProjects) > 0) { + createStreamReq.pCols = taosArrayInit(LIST_LENGTH(pProjects), sizeof(SField)); + if (!createStreamReq.pCols) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + code = -1; + goto _OVER; + } + } + pCxt->pDropStreamReq = &dropStreamReq; + mndCreateTSMABuildCreateStreamReq(pCxt); + mndCreateTSMABuildDropStreamReq(pCxt); + + if (TSDB_CODE_SUCCESS != mndCreateTSMATxnPrepare(pCxt)) { + code = -1; + goto _OVER; + } else { + mInfo("sma:%s, uid:%" PRIi64 " create on stb:%" PRIi64 " dstTb:%s dstVg:%d", pCxt->pCreateSmaReq->name, sma.uid, + sma.stbUid, sma.dstTbName, sma.dstVgId); + code = 0; + } + +_OVER: + tFreeSCMCreateStreamReq(pCxt->pCreateStreamReq); + if (pCxt->pDropStreamReq) tFreeMDropStreamReq(pCxt->pDropStreamReq); + pCxt->pCreateStreamReq = NULL; + if (pProjects) nodesDestroyList(pProjects); + pCxt->pProjects = NULL; + return code; +} + +static void mndTSMAGenerateOutputName(const char* tsmaName, char* streamName, char* targetStbName) { + SName smaName; + tNameFromString(&smaName, tsmaName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + sprintf(streamName, "%d.%s", smaName.acctId, smaName.tname); + snprintf(targetStbName, TSDB_TABLE_FNAME_LEN, "%s"TSMA_RES_STB_POSTFIX, tsmaName); +} + +static int32_t mndProcessCreateTSMAReq(SRpcMsg* pReq) { +#ifdef WINDOWS + terrno = TSDB_CODE_MND_INVALID_PLATFORM; + goto _OVER; +#endif + SMnode * pMnode = pReq->info.node; + int32_t code = -1; + SDbObj * pDb = NULL; + SStbObj * pStb = NULL; + SSmaObj * pSma = NULL; + SSmaObj * pBaseTsma = NULL; + SStreamObj * pStream = NULL; + int64_t mTraceId = TRACE_GET_ROOTID(&pReq->info.traceId); + SMCreateSmaReq createReq = {0}; + + if (sdbGetSize(pMnode->pSdb, SDB_SMA) >= tsMaxTsmaNum) { + terrno = TSDB_CODE_MND_MAX_TSMA_NUM_EXCEEDED; + goto _OVER; + } + + if (tDeserializeSMCreateSmaReq(pReq->pCont, pReq->contLen, &createReq) != 0) { + terrno = TSDB_CODE_INVALID_MSG; + goto _OVER; + } + + mInfo("start to create tsma: %s", createReq.name); + if (mndCheckCreateSmaReq(&createReq)) + goto _OVER; + + if (createReq.normSourceTbUid == 0) { + pStb = mndAcquireStb(pMnode, createReq.stb); + if (!pStb && !createReq.recursiveTsma) { + mError("tsma:%s, failed to create since stb:%s not exist", createReq.name, createReq.stb); + terrno = TSDB_CODE_MND_STB_NOT_EXIST; + goto _OVER; + } + } + + char streamName[TSDB_TABLE_FNAME_LEN] = {0}; + char streamTargetStbFullName[TSDB_TABLE_FNAME_LEN] = {0}; + mndTSMAGenerateOutputName(createReq.name, streamName, streamTargetStbFullName); + + pSma = sdbAcquire(pMnode->pSdb, SDB_SMA, createReq.name); + if (pSma && createReq.igExists) { + mInfo("tsma:%s, already exists in sma:%s, ignore exist is set", createReq.name, pSma->name); + code = 0; + goto _OVER; + } + if (pSma) { + terrno = TSDB_CODE_MND_SMA_ALREADY_EXIST; + goto _OVER; + } + + SStbObj *pTargetStb = mndAcquireStb(pMnode, streamTargetStbFullName); + if (pTargetStb) { + terrno = TSDB_CODE_TDB_STB_ALREADY_EXIST; + mError("tsma: %s, failed to create since output stable already exists: %s", createReq.name, + streamTargetStbFullName); + goto _OVER; + } + + pStream = mndAcquireStream(pMnode, streamName); + if (pStream != NULL) { + mError("tsma:%s, failed to create since stream:%s already exist", createReq.name, streamName); + terrno = TSDB_CODE_MND_SMA_ALREADY_EXIST; + goto _OVER; + } + + pDb = mndAcquireDbBySma(pMnode, createReq.name); + if (pDb == NULL) { + terrno = TSDB_CODE_MND_DB_NOT_SELECTED; + goto _OVER; + } + + if (mndCheckDbPrivilege(pMnode, pReq->info.conn.user, MND_OPER_WRITE_DB, pDb) != 0) { + goto _OVER; + } + + if (createReq.recursiveTsma) { + pBaseTsma = sdbAcquire(pMnode->pSdb, SDB_SMA, createReq.baseTsmaName); + if (!pBaseTsma) { + mError("base tsma: %s not found when creating recursive tsma", createReq.baseTsmaName); + terrno = TSDB_CODE_MND_SMA_NOT_EXIST; + goto _OVER; + } + if (!pStb) { + createReq.normSourceTbUid = pBaseTsma->stbUid; + } + } + + SCreateTSMACxt cxt = { + .pMnode = pMnode, + .pCreateSmaReq = &createReq, + .pCreateStreamReq = NULL, + .streamName = streamName, + .targetStbFullName = streamTargetStbFullName, + .pDb = pDb, + .pRpcReq = pReq, + .pSma = NULL, + .pBaseSma = pBaseTsma, + .pSrcStb = pStb, + }; + + code = mndCreateTSMA(&cxt); + if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; + +_OVER: + if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { + mError("tsma:%s, failed to create since %s", createReq.name, terrstr()); + } + + if (pStb) mndReleaseStb(pMnode, pStb); + if (pBaseTsma) mndReleaseSma(pMnode, pBaseTsma); + mndReleaseSma(pMnode, pSma); + mndReleaseStream(pMnode, pStream); + mndReleaseDb(pMnode, pDb); + tFreeSMCreateSmaReq(&createReq); + + return code; +} + +static int32_t mndDropTSMA(SCreateTSMACxt* pCxt) { + int32_t code = -1; + STransAction dropStreamRedoAction = {0}; + STrans *pTrans = mndTransCreate(pCxt->pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, pCxt->pRpcReq, "drop-tsma"); + if (!pTrans) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _OVER; + } + SMDropStreamReq dropStreamReq = {0}; + pCxt->pDropStreamReq = &dropStreamReq; + mndCreateTSMABuildDropStreamReq(pCxt); + mndTransSetDbName(pTrans, pCxt->pDb->name, NULL); + if (mndTransCheckConflict(pCxt->pMnode, pTrans) != 0) goto _OVER; + mndTransSetSerial(pTrans); + mndGetMnodeEpSet(pCxt->pMnode, &dropStreamRedoAction.epSet); + dropStreamRedoAction.acceptableCode = TSDB_CODE_MND_STREAM_NOT_EXIST; + dropStreamRedoAction.msgType = TDMT_STREAM_DROP; + dropStreamRedoAction.contLen = tSerializeSMDropStreamReq(0, 0, pCxt->pDropStreamReq); + dropStreamRedoAction.pCont = taosMemoryCalloc(1, dropStreamRedoAction.contLen); + if (!dropStreamRedoAction.pCont) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _OVER; + } + if (dropStreamRedoAction.contLen != + tSerializeSMDropStreamReq(dropStreamRedoAction.pCont, dropStreamRedoAction.contLen, pCxt->pDropStreamReq)) { + mError("tsma: %s, failed to drop due to drop stream req encode failure", pCxt->pDropSmaReq->name); + terrno = TSDB_CODE_INVALID_MSG; + goto _OVER; + } + + // output stable is not dropped when dropping stream, dropping it when dropping tsma + SMDropStbReq dropStbReq = {0}; + dropStbReq.igNotExists = false; + tstrncpy(dropStbReq.name, pCxt->targetStbFullName, TSDB_TABLE_FNAME_LEN); + dropStbReq.sql = "drop"; + dropStbReq.sqlLen = 5; + + STransAction dropStbRedoAction = {0}; + mndGetMnodeEpSet(pCxt->pMnode, &dropStbRedoAction.epSet); + dropStbRedoAction.acceptableCode = TSDB_CODE_MND_STB_NOT_EXIST; + dropStbRedoAction.msgType = TDMT_MND_STB_DROP; + dropStbRedoAction.contLen = tSerializeSMDropStbReq(0, 0, &dropStbReq); + dropStbRedoAction.pCont = taosMemoryCalloc(1, dropStbRedoAction.contLen); + if (!dropStbRedoAction.pCont) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _OVER; + } + if (dropStbRedoAction.contLen != tSerializeSMDropStbReq(dropStbRedoAction.pCont, dropStbRedoAction.contLen, &dropStbReq)) { + mError("tsma: %s, failedto drop due to drop stb req encode failure", pCxt->pDropSmaReq->name); + terrno = TSDB_CODE_INVALID_MSG; + goto _OVER; + } + + SDbObj newDb = {0}; + memcpy(&newDb, pCxt->pDb, sizeof(SDbObj)); + newDb.tsmaVersion++; + if (mndSetUpdateDbTsmaVersionPrepareLogs(pCxt->pMnode, pTrans, pCxt->pDb, &newDb) != 0) goto _OVER; + if (mndSetUpdateDbTsmaVersionCommitLogs(pCxt->pMnode, pTrans, pCxt->pDb, &newDb) != 0) goto _OVER; + if (mndSetDropSmaRedoLogs(pCxt->pMnode, pTrans, pCxt->pSma) != 0) goto _OVER; + if (mndSetDropSmaCommitLogs(pCxt->pMnode, pTrans, pCxt->pSma) != 0) goto _OVER; + if (mndTransAppendRedoAction(pTrans, &dropStreamRedoAction) != 0) goto _OVER; + if (mndTransAppendRedoAction(pTrans, &dropStbRedoAction) != 0) goto _OVER; + if (mndTransPrepare(pCxt->pMnode, pTrans) != 0) goto _OVER; + code = TSDB_CODE_SUCCESS; +_OVER: + tFreeMDropStreamReq(pCxt->pDropStreamReq); + mndTransDrop(pTrans); + return code; +} + +static bool hasRecursiveTsmasBasedOnMe(SMnode* pMnode, const SSmaObj* pSma) { + SSmaObj *pSmaObj = NULL; + void * pIter = NULL; + while (1) { + pIter = sdbFetch(pMnode->pSdb, SDB_SMA, pIter, (void **)&pSmaObj); + if (pIter == NULL) break; + if (0 == strncmp(pSmaObj->baseSmaName, pSma->name, TSDB_TABLE_FNAME_LEN)) { + sdbRelease(pMnode->pSdb, pSmaObj); + sdbCancelFetch(pMnode->pSdb, pIter); + return true; + } + sdbRelease(pMnode->pSdb, pSmaObj); + } + return false; +} + +static int32_t mndProcessDropTSMAReq(SRpcMsg* pReq) { + int32_t code = -1; + SMDropSmaReq dropReq = {0}; + SSmaObj * pSma = NULL; + SDbObj * pDb = NULL; + SMnode * pMnode = pReq->info.node; + if (tDeserializeSMDropSmaReq(pReq->pCont, pReq->contLen, &dropReq) != TSDB_CODE_SUCCESS) { + terrno = TSDB_CODE_INVALID_MSG; + goto _OVER; + } + + char streamName[TSDB_TABLE_FNAME_LEN] = {0}; + char streamTargetStbFullName[TSDB_TABLE_FNAME_LEN] = {0}; + mndTSMAGenerateOutputName(dropReq.name, streamName, streamTargetStbFullName); + + SStbObj* pStb = mndAcquireStb(pMnode, streamTargetStbFullName); + + pSma = mndAcquireSma(pMnode, dropReq.name); + if (!pSma && dropReq.igNotExists) { + code = 0; + goto _OVER; + } + if (!pSma) { + terrno = TSDB_CODE_MND_SMA_NOT_EXIST; + goto _OVER; + } + pDb = mndAcquireDbBySma(pMnode, dropReq.name); + if (!pDb) { + terrno = TSDB_CODE_MND_DB_NOT_EXIST; + goto _OVER; + } + + if (mndCheckDbPrivilege(pMnode, pReq->info.conn.user, MND_OPER_WRITE_DB, pDb) != 0) { + goto _OVER; + } + + if (hasRecursiveTsmasBasedOnMe(pMnode, pSma)) { + terrno = TSDB_CODE_MND_INVALID_DROP_TSMA; + goto _OVER; + } + + SCreateTSMACxt cxt = { + .pDb = pDb, + .pMnode = pMnode, + .pRpcReq = pReq, + .pSma = pSma, + .streamName = streamName, + .targetStbFullName = streamTargetStbFullName, + .pDropSmaReq = &dropReq, + }; + + code = mndDropTSMA(&cxt); + + if (code == 0) code = TSDB_CODE_ACTION_IN_PROGRESS; +_OVER: + + mndReleaseStb(pMnode, pStb); + mndReleaseSma(pMnode, pSma); + mndReleaseDb(pMnode, pDb); + return code; +} + +static int32_t mndRetrieveTSMA(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows) { + SDbObj * pDb = NULL; + int32_t numOfRows = 0; + SSmaObj * pSma = NULL; + SMnode * pMnode = pReq->info.node; + SColumnInfoData *pColInfo; + if (pShow->db[0]) { + pDb = mndAcquireDb(pMnode, pShow->db); + } + if (pShow->pIter == NULL) { + pShow->pIter = taosMemoryCalloc(1, sizeof(SSmaAndTagIter)); + } + SSmaAndTagIter *pIter = pShow->pIter; + while (numOfRows < rows) { + pIter->pSmaIter = sdbFetch(pMnode->pSdb, SDB_SMA, pIter->pSmaIter, (void **)&pSma); + if (pIter->pSmaIter == NULL) break; + SDbObj* pSrcDb = mndAcquireDb(pMnode, pSma->db); + + if ((pDb && pSma->dbUid != pDb->uid) || !pSrcDb) { + sdbRelease(pMnode->pSdb, pSma); + if (pSrcDb) mndReleaseDb(pMnode, pSrcDb); + continue; + } + + int32_t cols = 0; + SName n = {0}; + + tNameFromString(&n, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + char smaName[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_TO_VARSTR(smaName, (char *)tNameGetTableName(&n)); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char *)smaName, false); + + char db[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_TO_VARSTR(db, (char *)mndGetDbStr(pSma->db)); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char*)db, false); + + tNameFromString(&n, pSma->stb, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + char srcTb[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_TO_VARSTR(srcTb, (char *)tNameGetTableName(&n)); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char*)srcTb, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char*)db, false); + + tNameFromString(&n, pSma->dstTbName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + char targetTb[TSDB_TABLE_FNAME_LEN + VARSTR_HEADER_SIZE] = {0}; + STR_TO_VARSTR(targetTb, (char*)tNameGetTableName(&n)); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char*)targetTb, false); + + // stream name + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char*)smaName, false); + + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, (const char*)(&pSma->createdTime), false); + + // interval + char interval[64 + VARSTR_HEADER_SIZE] = {0}; + int32_t len = snprintf(interval + VARSTR_HEADER_SIZE, 64, "%" PRId64 "%c", pSma->interval, + getPrecisionUnit(pSrcDb->cfg.precision)); + varDataSetLen(interval, len); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, interval, false); + + // create sql + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + char buf[TSDB_MAX_SAVED_SQL_LEN + VARSTR_HEADER_SIZE] = {0}; + len = snprintf(buf + VARSTR_HEADER_SIZE, TSDB_MAX_SAVED_SQL_LEN, "%s", pSma->sql); + varDataSetLen(buf, TMIN(len, TSDB_MAX_SAVED_SQL_LEN)); + colDataSetVal(pColInfo, numOfRows, buf, false); + + // func list + len = 0; + char * start = buf + VARSTR_HEADER_SIZE; + SNode *pNode = NULL, *pFunc = NULL; + nodesStringToNode(pSma->ast, &pNode); + if (pNode) { + FOREACH(pFunc, ((SSelectStmt *)pNode)->pProjectionList) { + if (nodeType(pFunc) == QUERY_NODE_FUNCTION) { + SFunctionNode *pFuncNode = (SFunctionNode *)pFunc; + if (!fmIsTSMASupportedFunc(pFuncNode->funcId)) continue; + len += snprintf(start, TSDB_MAX_SAVED_SQL_LEN - len, "%s%s", start != buf + VARSTR_HEADER_SIZE ? "," : "", + ((SExprNode *)pFunc)->userAlias); + if (len >= TSDB_MAX_SAVED_SQL_LEN) { + len = TSDB_MAX_SAVED_SQL_LEN; + break; + } + start = buf + VARSTR_HEADER_SIZE + len; + } + } + nodesDestroyNode(pNode); + } + varDataSetLen(buf, len); + pColInfo = taosArrayGet(pBlock->pDataBlock, cols++); + colDataSetVal(pColInfo, numOfRows, buf, false); + + numOfRows++; + mndReleaseSma(pMnode, pSma); + mndReleaseDb(pMnode, pSrcDb); + } + mndReleaseDb(pMnode, pDb); + pShow->numOfRows += numOfRows; + if (numOfRows < rows) { + taosMemoryFree(pShow->pIter); + pShow->pIter = NULL; + } + return numOfRows; +} + +static void mndCancelRetrieveTSMA(SMnode *pMnode, void *pIter) { + SSmaAndTagIter *p = pIter; + if (p != NULL) { + SSdb *pSdb = pMnode->pSdb; + sdbCancelFetch(pSdb, p->pSmaIter); + } + taosMemoryFree(p); +} + +int32_t dumpTSMAInfoFromSmaObj(const SSmaObj* pSma, const SStbObj* pDestStb, STableTSMAInfo* pInfo, const SSmaObj* pBaseTsma) { + int32_t code = 0; + pInfo->interval = pSma->interval; + pInfo->unit = pSma->intervalUnit; + pInfo->tsmaId = pSma->uid; + pInfo->version = pSma->version; + pInfo->tsmaId = pSma->uid; + pInfo->destTbUid = pDestStb->uid; + SName sName = {0}; + tNameFromString(&sName, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + tstrncpy(pInfo->name, sName.tname, TSDB_TABLE_NAME_LEN); + tstrncpy(pInfo->targetDbFName, pSma->db, TSDB_DB_FNAME_LEN); + tNameFromString(&sName, pSma->dstTbName, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + tstrncpy(pInfo->targetTb, sName.tname, TSDB_TABLE_NAME_LEN); + tstrncpy(pInfo->dbFName, pSma->db, TSDB_DB_FNAME_LEN); + tNameFromString(&sName, pSma->stb, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + tstrncpy(pInfo->tb, sName.tname, TSDB_TABLE_NAME_LEN); + pInfo->pFuncs = taosArrayInit(8, sizeof(STableTSMAFuncInfo)); + if (!pInfo->pFuncs) return TSDB_CODE_OUT_OF_MEMORY; + + SNode *pNode, *pFunc; + if (TSDB_CODE_SUCCESS != nodesStringToNode(pBaseTsma ? pBaseTsma->ast : pSma->ast, &pNode)) { + taosArrayDestroy(pInfo->pFuncs); + pInfo->pFuncs = NULL; + return TSDB_CODE_TSMA_INVALID_STAT; + } + if (pNode) { + SSelectStmt *pSelect = (SSelectStmt *)pNode; + FOREACH(pFunc, pSelect->pProjectionList) { + STableTSMAFuncInfo funcInfo = {0}; + SFunctionNode * pFuncNode = (SFunctionNode *)pFunc; + if (!fmIsTSMASupportedFunc(pFuncNode->funcId)) continue; + funcInfo.funcId = pFuncNode->funcId; + funcInfo.colId = ((SColumnNode *)pFuncNode->pParameterList->pHead->pNode)->colId; + if (!taosArrayPush(pInfo->pFuncs, &funcInfo)) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + taosArrayDestroy(pInfo->pFuncs); + nodesDestroyNode(pNode); + return code; + } + } + nodesDestroyNode(pNode); + } + pInfo->ast = taosStrdup(pSma->ast); + if (!pInfo->ast) code = TSDB_CODE_OUT_OF_MEMORY; + + if (code == TSDB_CODE_SUCCESS && pDestStb->numOfTags > 0) { + pInfo->pTags = taosArrayInit(pDestStb->numOfTags, sizeof(SSchema)); + if (!pInfo->pTags) { + code = TSDB_CODE_OUT_OF_MEMORY; + } else { + for (int32_t i = 0; i < pDestStb->numOfTags; ++i) { + taosArrayPush(pInfo->pTags, &pDestStb->pTags[i]); + } + } + } + if (code == TSDB_CODE_SUCCESS) { + pInfo->pUsedCols = taosArrayInit(pDestStb->numOfColumns - 3, sizeof(SSchema)); + if (!pInfo->pUsedCols) + code = TSDB_CODE_OUT_OF_MEMORY; + else { + // skip _wstart, _wend, _duration + for (int32_t i = 1; i < pDestStb->numOfColumns - 2; ++i) { + taosArrayPush(pInfo->pUsedCols, &pDestStb->pColumns[i]); + } + } + } + return code; +} + +// @note remember to mndReleaseSma(*ppOut) +static int32_t mndGetDeepestBaseForTsma(SMnode* pMnode, SSmaObj* pSma, SSmaObj** ppOut) { + int32_t code = 0; + SSmaObj* pRecursiveTsma = NULL; + if (pSma->baseSmaName[0]) { + pRecursiveTsma = mndAcquireSma(pMnode, pSma->baseSmaName); + if (!pRecursiveTsma) { + mError("base tsma: %s for tsma: %s not found", pSma->baseSmaName, pSma->name); + return TSDB_CODE_MND_SMA_NOT_EXIST; + } + while (pRecursiveTsma->baseSmaName[0]) { + SSmaObj* pTmpSma = pRecursiveTsma; + pRecursiveTsma = mndAcquireSma(pMnode, pTmpSma->baseSmaName); + if (!pRecursiveTsma) { + mError("base tsma: %s for tsma: %s not found", pTmpSma->baseSmaName, pTmpSma->name); + mndReleaseSma(pMnode, pTmpSma); + return TSDB_CODE_MND_SMA_NOT_EXIST; + } + mndReleaseSma(pMnode, pTmpSma); + } + } + *ppOut = pRecursiveTsma; + return code; +} + + +static int32_t mndGetTSMA(SMnode *pMnode, char *tsmaFName, STableTSMAInfoRsp *rsp, bool *exist) { + int32_t code = -1; + SSmaObj *pSma = NULL; + SSmaObj *pBaseTsma = NULL; + SStbObj *pDstStb = NULL; + + pSma = sdbAcquire(pMnode->pSdb, SDB_SMA, tsmaFName); + if (pSma) { + pDstStb = mndAcquireStb(pMnode, pSma->dstTbName); + if (!pDstStb) { + sdbRelease(pMnode->pSdb, pSma); + return TSDB_CODE_SUCCESS; + } + + STableTSMAInfo *pTsma = taosMemoryCalloc(1, sizeof(STableTSMAInfo)); + if (!pTsma) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + sdbRelease(pMnode->pSdb, pSma); + mndReleaseStb(pMnode, pDstStb); + return code; + } + + terrno = mndGetDeepestBaseForTsma(pMnode, pSma, &pBaseTsma); + if (terrno == 0) { + terrno = dumpTSMAInfoFromSmaObj(pSma, pDstStb, pTsma, pBaseTsma); + } + mndReleaseStb(pMnode, pDstStb); + sdbRelease(pMnode->pSdb, pSma); + if (pBaseTsma) mndReleaseSma(pMnode, pBaseTsma); + if (terrno) { + tFreeTableTSMAInfo(pTsma); + return code; + } + if (NULL == taosArrayPush(rsp->pTsmas, &pTsma)) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + tFreeTableTSMAInfo(pTsma); + } + *exist = true; + } + return 0; +} + +typedef bool (*tsmaFilter)(const SSmaObj* pSma, void* param); + +static int32_t mndGetSomeTsmas(SMnode* pMnode, STableTSMAInfoRsp* pRsp, tsmaFilter filtered, void* param, bool* exist) { + int32_t code = -1; + SSmaObj * pSma = NULL; + SSmaObj * pBaseTsma = NULL; + SSdb * pSdb = pMnode->pSdb; + void * pIter = NULL; + SStreamObj * pStreamObj = NULL; + SStbObj * pStb = NULL; + + while (1) { + pIter = sdbFetch(pSdb, SDB_SMA, pIter, (void **)&pSma); + if (pIter == NULL) break; + + if (filtered(pSma, param)) { + sdbRelease(pSdb, pSma); + continue; + } + + pStb = mndAcquireStb(pMnode, pSma->dstTbName); + if (!pStb) { + sdbRelease(pSdb, pSma); + continue; + } + + SName smaName; + char streamName[TSDB_TABLE_FNAME_LEN] = {0}; + tNameFromString(&smaName, pSma->name, T_NAME_ACCT | T_NAME_DB | T_NAME_TABLE); + sprintf(streamName, "%d.%s", smaName.acctId, smaName.tname); + pStreamObj = mndAcquireStream(pMnode, streamName); + if (!pStreamObj) { + sdbRelease(pSdb, pSma); + continue; + } + + int64_t streamId = pStreamObj->uid; + mndReleaseStream(pMnode, pStreamObj); + + STableTSMAInfo *pTsma = taosMemoryCalloc(1, sizeof(STableTSMAInfo)); + if (!pTsma) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + mndReleaseStb(pMnode, pStb); + sdbRelease(pSdb, pSma); + sdbCancelFetch(pSdb, pIter); + return code; + } + pTsma->streamUid = streamId; + + terrno = mndGetDeepestBaseForTsma(pMnode, pSma, &pBaseTsma); + if (terrno == 0) { + terrno = dumpTSMAInfoFromSmaObj(pSma, pStb, pTsma, pBaseTsma); + } + mndReleaseStb(pMnode, pStb); + sdbRelease(pSdb, pSma); + if (pBaseTsma) mndReleaseSma(pMnode, pBaseTsma); + if (terrno) { + tFreeTableTSMAInfo(pTsma); + sdbCancelFetch(pSdb, pIter); + return code; + } + if (NULL == taosArrayPush(pRsp->pTsmas, &pTsma)) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + tFreeTableTSMAInfo(pTsma); + sdbCancelFetch(pSdb, pIter); + return code; + } + *exist = true; + } + return TSDB_CODE_SUCCESS; +} + +static bool tsmaTbFilter(const SSmaObj* pSma, void* param) { + const char* tbFName = param; + return pSma->stb[0] != tbFName[0] || strcmp(pSma->stb, tbFName) != 0; +} + +static int32_t mndGetTableTSMA(SMnode *pMnode, char *tbFName, STableTSMAInfoRsp *pRsp, bool *exist) { + return mndGetSomeTsmas(pMnode, pRsp, tsmaTbFilter, tbFName, exist); +} + +static bool tsmaDbFilter(const SSmaObj* pSma, void* param) { + uint64_t *dbUid = param; + return pSma->dbUid != *dbUid; +} + +int32_t mndGetDbTsmas(SMnode *pMnode, const char *dbFName, uint64_t dbUid, STableTSMAInfoRsp *pRsp, bool *exist) { + return mndGetSomeTsmas(pMnode, pRsp, tsmaDbFilter, &dbUid, exist); +} + +static int32_t mndProcessGetTbTSMAReq(SRpcMsg *pReq) { + STableTSMAInfoRsp rsp = {0}; + int32_t code = -1; + STableTSMAInfoReq tsmaReq = {0}; + bool exist = false; + SMnode * pMnode = pReq->info.node; + + if (tDeserializeTableTSMAInfoReq(pReq->pCont, pReq->contLen, &tsmaReq) != 0) { + terrno = TSDB_CODE_INVALID_MSG; + goto _OVER; + } + + rsp.pTsmas = taosArrayInit(4, POINTER_BYTES); + if (NULL == rsp.pTsmas) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + code = -1; + goto _OVER; + } + + if (tsmaReq.fetchingWithTsmaName) { + code = mndGetTSMA(pMnode, tsmaReq.name, &rsp, &exist); + } else { + code = mndGetTableTSMA(pMnode, tsmaReq.name, &rsp, &exist); + } + if (code) { + goto _OVER; + } + + if (!exist) { + code = -1; + terrno = TSDB_CODE_MND_SMA_NOT_EXIST; + } else { + int32_t contLen = tSerializeTableTSMAInfoRsp(NULL, 0, &rsp); + void *pRsp = rpcMallocCont(contLen); + if (pRsp == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + code = -1; + goto _OVER; + } + + tSerializeTableTSMAInfoRsp(pRsp, contLen, &rsp); + + pReq->info.rsp = pRsp; + pReq->info.rspLen = contLen; + + code = 0; + } + +_OVER: + if (code != 0) { + mError("failed to get table tsma %s since %s fetching with tsma name %d", tsmaReq.name, terrstr(), + tsmaReq.fetchingWithTsmaName); + } + + tFreeTableTSMAInfoRsp(&rsp); + return code; +} + +static int32_t mkNonExistTSMAInfo(const STSMAVersion *pTsmaVer, STableTSMAInfo **ppTsma) { + STableTSMAInfo *pInfo = taosMemoryCalloc(1, sizeof(STableTSMAInfo)); + if (!pInfo) { + return TSDB_CODE_OUT_OF_MEMORY; + } + pInfo->pFuncs = NULL; + pInfo->tsmaId = pTsmaVer->tsmaId; + tstrncpy(pInfo->dbFName, pTsmaVer->dbFName, TSDB_DB_FNAME_LEN); + tstrncpy(pInfo->tb, pTsmaVer->tbName, TSDB_TABLE_NAME_LEN); + tstrncpy(pInfo->name, pTsmaVer->name, TSDB_TABLE_NAME_LEN); + pInfo->dbId = pTsmaVer->dbId; + pInfo->ast = taosMemoryCalloc(1, 1); + *ppTsma = pInfo; + return TSDB_CODE_SUCCESS; +} + +int32_t mndValidateTSMAInfo(SMnode *pMnode, STSMAVersion *pTsmaVersions, int32_t numOfTsmas, void **ppRsp, + int32_t *pRspLen) { + int32_t code = -1; + STSMAHbRsp hbRsp = {0}; + int32_t rspLen = 0; + void * pRsp = NULL; + char tsmaFName[TSDB_TABLE_FNAME_LEN] = {0}; + STableTSMAInfo * pTsmaInfo = NULL; + + hbRsp.pTsmas = taosArrayInit(numOfTsmas, POINTER_BYTES); + if (!hbRsp.pTsmas) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return -1; + } + + for (int32_t i = 0; i < numOfTsmas; ++i) { + STSMAVersion* pTsmaVer = &pTsmaVersions[i]; + pTsmaVer->dbId = be64toh(pTsmaVer->dbId); + pTsmaVer->tsmaId = be64toh(pTsmaVer->tsmaId); + pTsmaVer->version = ntohl(pTsmaVer->version); + + snprintf(tsmaFName, sizeof(tsmaFName), "%s.%s", pTsmaVer->dbFName, pTsmaVer->name); + SSmaObj* pSma = mndAcquireSma(pMnode, tsmaFName); + if (!pSma) { + terrno = mkNonExistTSMAInfo(pTsmaVer, &pTsmaInfo); + if (terrno) goto _OVER; + taosArrayPush(hbRsp.pTsmas, &pTsmaInfo); + continue; + } + + if (pSma->uid != pTsmaVer->tsmaId) { + mDebug("tsma: %s.%" PRIx64 " tsmaId mismatch with current %" PRIx64, tsmaFName, pTsmaVer->tsmaId, pSma->uid); + terrno = mkNonExistTSMAInfo(pTsmaVer, &pTsmaInfo); + mndReleaseSma(pMnode, pSma); + if (terrno) goto _OVER; + taosArrayPush(hbRsp.pTsmas, &pTsmaInfo); + continue; + } else if (pSma->version == pTsmaVer->version) { + mndReleaseSma(pMnode, pSma); + continue; + } + + SStbObj* pDestStb = mndAcquireStb(pMnode, pSma->dstTbName); + if (!pDestStb) { + mInfo("tsma: %s.%" PRIx64 " dest stb: %s not found, maybe dropped", tsmaFName, pTsmaVer->tsmaId, pSma->dstTbName); + terrno = mkNonExistTSMAInfo(pTsmaVer, &pTsmaInfo); + mndReleaseSma(pMnode, pSma); + if (terrno) goto _OVER; + taosArrayPush(hbRsp.pTsmas, &pTsmaInfo); + continue; + } + + // dump smaObj into rsp + STableTSMAInfo * pInfo = NULL; + pInfo = taosMemoryCalloc(1, sizeof(STableTSMAInfo)); + if (!pInfo) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + mndReleaseSma(pMnode, pSma); + mndReleaseStb(pMnode, pDestStb); + goto _OVER; + } + + SSmaObj* pBaseSma = NULL; + terrno = mndGetDeepestBaseForTsma(pMnode, pSma, &pBaseSma); + if (terrno == 0) terrno = dumpTSMAInfoFromSmaObj(pSma, pDestStb, pInfo, pBaseSma); + + mndReleaseStb(pMnode, pDestStb); + mndReleaseSma(pMnode, pSma); + if (pBaseSma) mndReleaseSma(pMnode, pBaseSma); + if (terrno) { + tFreeTableTSMAInfo(pInfo); + goto _OVER; + } + + taosArrayPush(hbRsp.pTsmas, pInfo); + } + + rspLen = tSerializeTSMAHbRsp(NULL, 0, &hbRsp); + if (rspLen < 0) { + terrno = TSDB_CODE_INVALID_MSG; + goto _OVER; + } + + pRsp = taosMemoryMalloc(rspLen); + if (!pRsp) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + rspLen = 0; + goto _OVER; + } + + tSerializeTSMAHbRsp(pRsp, rspLen, &hbRsp); + code = 0; +_OVER: + tFreeTSMAHbRsp(&hbRsp); + *ppRsp = pRsp; + *pRspLen = rspLen; + return code; +} diff --git a/source/dnode/mnode/impl/src/mndStb.c b/source/dnode/mnode/impl/src/mndStb.c index c418241605..033c55a581 100644 --- a/source/dnode/mnode/impl/src/mndStb.c +++ b/source/dnode/mnode/impl/src/mndStb.c @@ -62,6 +62,10 @@ static int32_t mndAlterStbAndUpdateTagIdxImp(SMnode *pMnode, SRpcMsg *pReq, SDb static int32_t mndProcessCreateIndexReq(SRpcMsg *pReq); static int32_t mndProcessDropIndexReq(SRpcMsg *pReq); +static int32_t mndProcessDropStbReqFromMNode(SRpcMsg *pReq); +static int32_t mndProcessDropTbWithTsma(SRpcMsg* pReq); +static int32_t mndProcessFetchTtlExpiredTbs(SRpcMsg *pReq); + int32_t mndInitStb(SMnode *pMnode) { SSdbTable table = { .sdbType = SDB_STB, @@ -87,6 +91,11 @@ int32_t mndInitStb(SMnode *pMnode) { mndSetMsgHandle(pMnode, TDMT_VND_S3MIGRATE_RSP, mndProcessS3MigrateDbRsp); mndSetMsgHandle(pMnode, TDMT_MND_S3MIGRATE_DB_TIMER, mndProcessS3MigrateDbTimer); mndSetMsgHandle(pMnode, TDMT_MND_TABLE_CFG, mndProcessTableCfgReq); + mndSetMsgHandle(pMnode, TDMT_MND_STB_DROP, mndProcessDropStbReqFromMNode); + mndSetMsgHandle(pMnode, TDMT_MND_STB_DROP_RSP, mndTransProcessRsp); + mndSetMsgHandle(pMnode, TDMT_MND_DROP_TB_WITH_TSMA, mndProcessDropTbWithTsma); + mndSetMsgHandle(pMnode, TDMT_VND_FETCH_TTL_EXPIRED_TBS_RSP, mndProcessFetchTtlExpiredTbs); + mndSetMsgHandle(pMnode, TDMT_VND_DROP_TABLE_RSP, mndTransProcessRsp); // mndSetMsgHandle(pMnode, TDMT_MND_SYSTABLE_RETRIEVE, mndProcessRetrieveStbReq); // mndSetMsgHandle(pMnode, TDMT_MND_CREATE_INDEX, mndProcessCreateIndexReq); @@ -936,7 +945,7 @@ static int32_t mndProcessTtlTimer(SRpcMsg *pReq) { pHead->vgId = htonl(pVgroup->vgId); tSerializeSVDropTtlTableReq((char *)pHead + sizeof(SMsgHead), reqLen, &ttlReq); - SRpcMsg rpcMsg = {.msgType = TDMT_VND_DROP_TTL_TABLE, .pCont = pHead, .contLen = contLen, .info = pReq->info}; + SRpcMsg rpcMsg = {.msgType = TDMT_VND_FETCH_TTL_EXPIRED_TBS, .pCont = pHead, .contLen = contLen, .info = pReq->info}; SEpSet epSet = mndGetVgroupEpset(pMnode, pVgroup); int32_t code = tmsgSendReq(&epSet, &rpcMsg); if (code != 0) { @@ -2532,11 +2541,6 @@ static int32_t mndCheckDropStbForStream(SMnode *pMnode, const char *stbFullName, pIter = sdbFetch(pSdb, SDB_STREAM, pIter, (void **)&pStream); if (pIter == NULL) break; - if (pStream->smaId != 0) { - sdbRelease(pSdb, pStream); - continue; - } - if (pStream->targetStbUid == suid) { sdbCancelFetch(pSdb, pIter); sdbRelease(pSdb, pStream); @@ -3227,6 +3231,11 @@ static int32_t mndRetrieveStb(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBloc continue; } + if (isTsmaResSTb(pStb->name)) { + sdbRelease(pSdb, pStb); + continue; + } + cols = 0; SName name = {0}; @@ -3693,3 +3702,376 @@ static int32_t mndProcessDropIndexReq(SRpcMsg *pReq) { _OVER: return code; }*/ + +static int32_t mndProcessDropStbReqFromMNode(SRpcMsg *pReq) { + int32_t code = mndProcessDropStbReq(pReq); + if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { + pReq->info.rsp = rpcMallocCont(1); + pReq->info.rspLen = 1; + pReq->info.noResp = false; + pReq->code = code; + } + return code; +} + +typedef struct SVDropTbVgReqs { + SVDropTbBatchReq req; + SVgroupInfo info; +} SVDropTbVgReqs; + +typedef struct SMDropTbDbInfo { + SArray *dbVgInfos; + int32_t hashPrefix; + int32_t hashSuffix; + int32_t hashMethod; +} SMDropTbDbInfo; + +typedef struct SMDropTbTsmaInfo { + char tsmaResTbDbFName[TSDB_DB_FNAME_LEN]; + char tsmaResTbNamePrefix[TSDB_TABLE_NAME_LEN]; + int32_t suid; + SMDropTbDbInfo dbInfo; // reference to DbInfo in pDbMap +} SMDropTbTsmaInfo; + +typedef struct SMDropTbTsmaInfos { + SArray* pTsmaInfos; // SMDropTbTsmaInfo +} SMDropTbTsmaInfos; + +typedef struct SMndDropTbsWithTsmaCtx { + SHashObj* pTsmaMap; // + SHashObj* pDbMap; // + SHashObj* pVgMap; // + SArray* pResTbNames; // SArray +} SMndDropTbsWithTsmaCtx; + +static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode* pMnode, SMndDropTbsWithTsmaCtx* pCtx, SArray* pTbs, int32_t vgId); + +static void mndDestroyDropTbsWithTsmaCtx(SMndDropTbsWithTsmaCtx* p) { + if (!p) return; + + if (p->pDbMap) { + void* pIter = taosHashIterate(p->pDbMap, NULL); + while (pIter) { + SMDropTbDbInfo* pInfo = pIter; + taosArrayDestroy(pInfo->dbVgInfos); + pIter = taosHashIterate(p->pDbMap, pIter); + } + taosHashCleanup(p->pDbMap); + } + if (p->pResTbNames) { + taosArrayDestroyP(p->pResTbNames, taosMemoryFree); + } + if (p->pTsmaMap) { + void* pIter = taosHashIterate(p->pTsmaMap, NULL); + while (pIter) { + SMDropTbTsmaInfos* pInfos = pIter; + taosArrayDestroy(pInfos->pTsmaInfos); + pIter = taosHashIterate(p->pTsmaMap, pIter); + } + taosHashCleanup(p->pTsmaMap); + } + + if (p->pVgMap) { + void* pIter = taosHashIterate(p->pVgMap, NULL); + while (pIter) { + SVDropTbVgReqs *pReqs = pIter; + taosArrayDestroy(pReqs->req.pArray); + pIter = taosHashIterate(p->pVgMap, pIter); + } + taosHashCleanup(p->pVgMap); + } + taosMemoryFree(p); +} + +static int32_t mndInitDropTbsWithTsmaCtx(SMndDropTbsWithTsmaCtx** ppCtx) { + int32_t code = 0; + SMndDropTbsWithTsmaCtx* pCtx = taosMemoryCalloc(1, sizeof(SMndDropTbsWithTsmaCtx)); + if (!pCtx) return TSDB_CODE_OUT_OF_MEMORY; + pCtx->pTsmaMap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), true, HASH_NO_LOCK); + if (!pCtx->pTsmaMap) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _end; + } + + pCtx->pDbMap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), true, HASH_NO_LOCK); + if (!pCtx->pDbMap) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _end; + } + pCtx->pResTbNames = taosArrayInit(TARRAY_MIN_SIZE, POINTER_BYTES); + + pCtx->pVgMap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); + if (!pCtx->pVgMap) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _end; + } + *ppCtx = pCtx; +_end: + if (code) mndDestroyDropTbsWithTsmaCtx(pCtx); + return code; +} + + +static void* mndBuildVDropTbsReq(SMnode* pMnode, const SVgroupInfo* pVgInfo, const SVDropTbBatchReq* pReq, int32_t *len) { + int32_t contLen = 0; + int32_t ret = 0; + SMsgHead *pHead = NULL; + SEncoder encoder = {0}; + + tEncodeSize(tEncodeSVDropTbBatchReq, pReq, contLen, ret); + if (ret < 0) return NULL; + + contLen += sizeof(SMsgHead); + pHead = taosMemoryMalloc(contLen); + if (pHead == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return NULL; + } + + pHead->contLen = htonl(contLen); + pHead->vgId = htonl(pVgInfo->vgId); + + void *pBuf = POINTER_SHIFT(pHead, sizeof(SMsgHead)); + + tEncoderInit(&encoder, pBuf, contLen - sizeof(SMsgHead)); + tEncodeSVDropTbBatchReq(&encoder, pReq); + tEncoderClear(&encoder); + + *len = contLen; + return pHead; +} + +static int32_t mndSetDropTbsRedoActions(SMnode* pMnode, STrans* pTrans, const SVDropTbVgReqs* pVgReqs, void* pCont, int32_t contLen) { + STransAction action = {0}; + action.epSet = pVgReqs->info.epSet; + action.pCont = pCont; + action.contLen = contLen; + action.msgType = TDMT_VND_DROP_TABLE; + action.acceptableCode = TSDB_CODE_TDB_TABLE_NOT_EXIST; + return mndTransAppendRedoAction(pTrans, &action); +} + +static int32_t mndCreateDropTbsTxnPrepare(SRpcMsg* pRsp, SMndDropTbsWithTsmaCtx* pCtx) { + SMnode *pMnode = pRsp->info.node; + STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_GLOBAL, pRsp, "drop-tbs"); + mndTransSetChangeless(pTrans); + if (pTrans == NULL) goto _OVER; + + if (mndTransCheckConflict(pMnode, pTrans) != 0) goto _OVER; + + void* pIter = taosHashIterate(pCtx->pVgMap, NULL); + while (pIter) { + const SVDropTbVgReqs* pVgReqs = pIter; + int32_t len = 0; + void* p = mndBuildVDropTbsReq(pMnode, &pVgReqs->info, &pVgReqs->req, &len); + if (!p || mndSetDropTbsRedoActions(pMnode, pTrans, pVgReqs, p, len) != 0) { + taosHashCancelIterate(pCtx->pVgMap, pIter); + goto _OVER; + } + pIter = taosHashIterate(pCtx->pVgMap, pIter); + } + if (mndTransPrepare(pMnode, pTrans) != 0) goto _OVER; + +_OVER: + mndTransDrop(pTrans); + return terrno; +} + +static int32_t mndProcessDropTbWithTsma(SRpcMsg* pReq) { + int32_t code = -1; + SMnode *pMnode = pReq->info.node; + SDbObj *pDb = NULL; + SStbObj *pStb = NULL; + SMDropTbsReq dropReq = {0}; + bool locked = false; + if (tDeserializeSMDropTbsReq(pReq->pCont, pReq->contLen, &dropReq) != 0) { + terrno = TSDB_CODE_INVALID_MSG; + goto _OVER; + } + + SMndDropTbsWithTsmaCtx* pCtx = NULL; + terrno = mndInitDropTbsWithTsmaCtx(&pCtx); + if (terrno) goto _OVER; + for (int32_t i = 0; i < dropReq.pVgReqs->size; ++i) { + SMDropTbReqsOnSingleVg* pReq = taosArrayGet(dropReq.pVgReqs, i); + terrno = mndDropTbAddTsmaResTbsForSingleVg(pMnode, pCtx, pReq->pTbs, pReq->vgInfo.vgId); + if (terrno) goto _OVER; + } + if (mndCreateDropTbsTxnPrepare(pReq, pCtx) == 0) + code = 0; +_OVER: + tFreeSMDropTbsReq(&dropReq); + if (pCtx) mndDestroyDropTbsWithTsmaCtx(pCtx); + return code; +} + +static int32_t mndDropTbAdd(SMnode *pMnode, SHashObj *pVgHashMap, const SVgroupInfo *pVgInfo, char *name, tb_uid_t suid, + bool ignoreNotExists) { + SVDropTbReq req = {.name = name, .suid = suid, .igNotExists = ignoreNotExists}; + + SVDropTbVgReqs * pReqs = taosHashGet(pVgHashMap, &pVgInfo->vgId, sizeof(pVgInfo->vgId)); + SVDropTbVgReqs reqs = {0}; + if (pReqs == NULL) { + reqs.info = *pVgInfo; + reqs.req.pArray = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SVDropTbReq)); + taosArrayPush(reqs.req.pArray, &req); + taosHashPut(pVgHashMap, &pVgInfo->vgId, sizeof(pVgInfo->vgId), &reqs, sizeof(reqs)); + } else { + taosArrayPush(pReqs->req.pArray, &req); + } + return 0; +} + +static int32_t mndGetDbVgInfoForTsma(SMnode* pMnode, const char* dbname, SMDropTbTsmaInfo* pInfo) { + int32_t code = 0; + SDbObj* pDb = mndAcquireDb(pMnode, dbname); + if (!pDb) { + code = TSDB_CODE_MND_DB_NOT_EXIST; + goto _end; + } + + pInfo->dbInfo.dbVgInfos = taosArrayInit(pDb->cfg.numOfVgroups, sizeof(SVgroupInfo)); + if ( !pInfo->dbInfo.dbVgInfos) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _end; + } + mndBuildDBVgroupInfo(pDb, pMnode, pInfo->dbInfo.dbVgInfos); + + pInfo->dbInfo.hashPrefix = pDb->cfg.hashPrefix; + pInfo->dbInfo.hashSuffix = pDb->cfg.hashSuffix; + pInfo->dbInfo.hashMethod = pDb->cfg.hashMethod; + +_end: + if (pDb) mndReleaseDb(pMnode, pDb); + if (code && pInfo->dbInfo.dbVgInfos) { + taosArrayDestroy(pInfo->dbInfo.dbVgInfos); + pInfo->dbInfo.dbVgInfos = NULL; + } + return code; +} + +int32_t vgHashValCmp(const void* lp, const void* rp) { + uint32_t* key = (uint32_t*)lp; + SVgroupInfo* pVg = (SVgroupInfo*)rp; + + if (*key < pVg->hashBegin) { + return -1; + } else if (*key > pVg->hashEnd) { + return 1; + } + + return 0; +} + +static int32_t mndDropTbAddTsmaResTbsForSingleVg(SMnode* pMnode, SMndDropTbsWithTsmaCtx* pCtx, SArray* pTbs, int32_t vgId) { + int32_t code = 0; + + SVgObj* pVgObj = mndAcquireVgroup(pMnode, vgId); + if (!pVgObj) { + code = 0; + goto _end; + } + SVgroupInfo vgInfo = {.hashBegin = pVgObj->hashBegin, .hashEnd = pVgObj->hashEnd, .numOfTable = pVgObj->numOfTables, .vgId = pVgObj->vgId}; + vgInfo.epSet = mndGetVgroupEpset(pMnode, pVgObj); + mndReleaseVgroup(pMnode, pVgObj); + + // get all stb uids + for (int32_t i = 0; i < pTbs->size; ++i) { + const SVDropTbReq* pTb = taosArrayGet(pTbs, i); + if (taosHashGet(pCtx->pTsmaMap, &pTb->suid, sizeof(pTb->suid))) { + + } else { + SMDropTbTsmaInfos infos = {0}; + infos.pTsmaInfos = taosArrayInit(2, sizeof(SMDropTbTsmaInfo)); + if (!infos.pTsmaInfos) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _end; + } + taosHashPut(pCtx->pTsmaMap, &pTb->suid, sizeof(pTb->suid), &infos, sizeof(infos)); + } + } + + void *pIter = NULL; + SSmaObj *pSma = NULL; + char buf[TSDB_TABLE_FNAME_LEN] = {0}; + // get used tsmas and it's dbs + while (1) { + pIter = sdbFetch(pMnode->pSdb, SDB_SMA, pIter, (void **)&pSma); + if (!pIter) break; + SMDropTbTsmaInfos* pInfos = taosHashGet(pCtx->pTsmaMap, &pSma->stbUid, sizeof(pSma->stbUid)); + if (pInfos) { + SMDropTbTsmaInfo info = {0}; + int32_t len = sprintf(buf, "%s", pSma->name); + len = taosCreateMD5Hash(buf, len); + sprintf(info.tsmaResTbDbFName, "%s", pSma->db); + snprintf(info.tsmaResTbNamePrefix, TSDB_TABLE_NAME_LEN, "%s", buf); + SMDropTbDbInfo* pDbInfo = taosHashGet(pCtx->pDbMap, pSma->db, TSDB_DB_FNAME_LEN); + info.suid = pSma->dstTbUid; + if (!pDbInfo) { + code = mndGetDbVgInfoForTsma(pMnode, pSma->db, &info); + if (code != TSDB_CODE_SUCCESS) { + sdbCancelFetch(pMnode->pSdb, pIter); + sdbRelease(pMnode->pSdb, pSma); + goto _end; + } + taosHashPut(pCtx->pDbMap, pSma->db, TSDB_DB_FNAME_LEN, &info.dbInfo, sizeof(SMDropTbDbInfo)); + } else { + info.dbInfo = *pDbInfo; + } + taosArrayPush(pInfos->pTsmaInfos, &info); + } + sdbRelease(pMnode->pSdb, pSma); + } + + // generate vg req map + for (int32_t i = 0; i < pTbs->size; ++i) { + SVDropTbReq* pTb = taosArrayGet(pTbs, i); + mndDropTbAdd(pMnode, pCtx->pVgMap, &vgInfo, pTb->name, pTb->suid, pTb->igNotExists); + + SMDropTbTsmaInfos *pInfos = taosHashGet(pCtx->pTsmaMap, &pTb->suid, sizeof(pTb->suid)); + SArray *pVgInfos = NULL; + char buf[TSDB_TABLE_FNAME_LEN]; + for (int32_t j = 0; j < pInfos->pTsmaInfos->size; ++j) { + SMDropTbTsmaInfo *pInfo = taosArrayGet(pInfos->pTsmaInfos, j); + int32_t len = sprintf(buf, "%s.%s_%s", pInfo->tsmaResTbDbFName, pInfo->tsmaResTbNamePrefix, pTb->name); + uint32_t hashVal = + taosGetTbHashVal(buf, len, pInfo->dbInfo.hashMethod, pInfo->dbInfo.hashPrefix, pInfo->dbInfo.hashSuffix); + const SVgroupInfo *pVgInfo = taosArraySearch(pInfo->dbInfo.dbVgInfos, &hashVal, vgHashValCmp, TD_EQ); + void* p = taosStrdup(buf + strlen(pInfo->tsmaResTbDbFName) + TSDB_NAME_DELIMITER_LEN); + taosArrayPush(pCtx->pResTbNames, &p); + mndDropTbAdd(pMnode, pCtx->pVgMap, pVgInfo, p, pInfo->suid, true); + } + } +_end: + return code; +} + +static int32_t mndProcessFetchTtlExpiredTbs(SRpcMsg *pRsp) { + int32_t code = -1; + SDecoder decoder = {0}; + SMnode *pMnode = pRsp->info.node; + SVFetchTtlExpiredTbsRsp rsp = {0}; + SMndDropTbsWithTsmaCtx *pCtx = NULL; + if (pRsp->code != TSDB_CODE_SUCCESS) goto _end; + if (pRsp->contLen == 0) { + code = 0; + goto _end; + } + + tDecoderInit(&decoder, pRsp->pCont, pRsp->contLen); + terrno = tDecodeVFetchTtlExpiredTbsRsp(&decoder, &rsp); + if (terrno) goto _end; + + terrno = mndInitDropTbsWithTsmaCtx(&pCtx); + if (terrno) goto _end; + + terrno = mndDropTbAddTsmaResTbsForSingleVg(pMnode, pCtx, rsp.pExpiredTbs, rsp.vgId); + if (terrno) goto _end; + if (mndCreateDropTbsTxnPrepare(pRsp, pCtx) == 0) + code = 0; +_end: + if (pCtx) mndDestroyDropTbsWithTsmaCtx(pCtx); + tDecoderClear(&decoder); + tFreeFetchTtlExpiredTbsRsp(&rsp); + return code; +} diff --git a/source/dnode/mnode/impl/src/mndStream.c b/source/dnode/mnode/impl/src/mndStream.c index 364cc062d1..9d386ca2f8 100644 --- a/source/dnode/mnode/impl/src/mndStream.c +++ b/source/dnode/mnode/impl/src/mndStream.c @@ -41,6 +41,10 @@ static int32_t mndStreamActionDelete(SSdb *pSdb, SStreamObj *pStream); static int32_t mndStreamActionUpdate(SSdb *pSdb, SStreamObj *pOldStream, SStreamObj *pNewStream); static int32_t mndProcessCreateStreamReq(SRpcMsg *pReq); static int32_t mndProcessDropStreamReq(SRpcMsg *pReq); + +static int32_t mndProcessCreateStreamReqFromMNode(SRpcMsg *pReq); +static int32_t mndProcessDropStreamReqFromMNode(SRpcMsg *pReq); + static int32_t mndProcessStreamCheckpointTmr(SRpcMsg *pReq); static int32_t mndProcessStreamDoCheckpoint(SRpcMsg *pReq); static int32_t mndProcessStreamCheckpointInCandid(SRpcMsg *pReq); @@ -102,6 +106,13 @@ int32_t mndInitStream(SMnode *pMnode) { mndSetMsgHandle(pMnode, TDMT_VND_STREAM_TASK_UPDATE_RSP, mndTransProcessRsp); mndSetMsgHandle(pMnode, TDMT_VND_STREAM_TASK_RESET_RSP, mndTransProcessRsp); + // for msgs inside mnode + // TODO change the name + mndSetMsgHandle(pMnode, TDMT_STREAM_CREATE, mndProcessCreateStreamReqFromMNode); + mndSetMsgHandle(pMnode, TDMT_STREAM_CREATE_RSP, mndTransProcessRsp); + mndSetMsgHandle(pMnode, TDMT_STREAM_DROP, mndProcessDropStreamReqFromMNode); + mndSetMsgHandle(pMnode, TDMT_STREAM_DROP_RSP, mndTransProcessRsp); + mndSetMsgHandle(pMnode, TDMT_VND_STREAM_CHECK_POINT_SOURCE_RSP, mndTransProcessRsp); mndSetMsgHandle(pMnode, TDMT_MND_STREAM_CHECKPOINT_TIMER, mndProcessStreamCheckpointTmr); mndSetMsgHandle(pMnode, TDMT_MND_STREAM_BEGIN_CHECKPOINT, mndProcessStreamDoCheckpoint); @@ -335,7 +346,10 @@ static int32_t mndBuildStreamObjFromCreateReq(SMnode *pMnode, SStreamObj *pObj, pObj->createTime = taosGetTimestampMs(); pObj->updateTime = pObj->createTime; pObj->version = 1; - pObj->smaId = 0; + if (pCreate->smaId > 0) { + pObj->subTableWithoutMd5 = 1; + } + pObj->smaId = pCreate->smaId; pObj->indexForMultiAggBalance = -1; pObj->uid = mndGenerateUid(pObj->name, strlen(pObj->name)); @@ -1213,6 +1227,24 @@ static int32_t mndProcessDropStreamReq(SRpcMsg *pReq) { } } + if (pStream->smaId != 0) { + void *pIter = NULL; + SSmaObj *pSma = NULL; + pIter = sdbFetch(pMnode->pSdb, SDB_SMA, pIter, (void**)&pSma); + while (pIter) { + if (pSma && pSma->uid == pStream->smaId) { + sdbRelease(pMnode->pSdb, pSma); + sdbRelease(pMnode->pSdb, pStream); + sdbCancelFetch(pMnode->pSdb, pIter); + tFreeMDropStreamReq(&dropReq); + terrno = TSDB_CODE_TSMA_MUST_BE_DROPPED; + return -1; + } + if (pSma) sdbRelease(pMnode->pSdb, pSma); + pIter = sdbFetch(pMnode->pSdb, SDB_SMA, pIter, (void**)&pSma); + } + } + if (mndCheckDbPrivilegeByName(pMnode, pReq->info.conn.user, MND_OPER_WRITE_DB, pStream->targetDb) != 0) { sdbRelease(pMnode->pSdb, pStream); tFreeMDropStreamReq(&dropReq); @@ -2372,3 +2404,25 @@ int32_t mndProcessStreamReqCheckpoint(SRpcMsg *pReq) { return 0; } + +static int32_t mndProcessCreateStreamReqFromMNode(SRpcMsg *pReq) { + int32_t code = mndProcessCreateStreamReq(pReq); + if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { + pReq->info.rsp = rpcMallocCont(1); + pReq->info.rspLen = 1; + pReq->info.noResp = false; + pReq->code = code; + } + return code; +} + +static int32_t mndProcessDropStreamReqFromMNode(SRpcMsg *pReq) { + int32_t code = mndProcessDropStreamReq(pReq); + if (code != 0 && code != TSDB_CODE_ACTION_IN_PROGRESS) { + pReq->info.rsp = rpcMallocCont(1); + pReq->info.rspLen = 1; + pReq->info.noResp = false; + pReq->code = code; + } + return code; +} diff --git a/source/dnode/mnode/sdb/inc/sdb.h b/source/dnode/mnode/sdb/inc/sdb.h index 12a34b0305..0b2de2b151 100644 --- a/source/dnode/mnode/sdb/inc/sdb.h +++ b/source/dnode/mnode/sdb/inc/sdb.h @@ -352,6 +352,11 @@ void sdbTraverse(SSdb *pSdb, ESdbType type, sdbTraverseFp fp, void *p1, void *p2 */ int32_t sdbGetSize(SSdb *pSdb, ESdbType type); +/** + * @brief get valid number of rows, removed rows are ignored + */ +int32_t sdbGetValidSize(SSdb* pSdb, ESdbType type); + /** * @brief Get the max id of the table, keyType of table should be INT32 * diff --git a/source/dnode/mnode/sdb/src/sdbHash.c b/source/dnode/mnode/sdb/src/sdbHash.c index 05231f8359..e7a86b082f 100644 --- a/source/dnode/mnode/sdb/src/sdbHash.c +++ b/source/dnode/mnode/sdb/src/sdbHash.c @@ -510,3 +510,15 @@ int64_t sdbGetTableVer(SSdb *pSdb, ESdbType type) { return pSdb->tableVer[type]; } + +bool countValid(SMnode *pMnode, void *pObj, void *p1, void *p2, void *p3) { + int32_t* pInt = p1; + (*pInt) += 1; + return true; +} + +int32_t sdbGetValidSize(SSdb* pSdb, ESdbType type) { + int32_t num = 0; + sdbTraverse(pSdb, type, countValid, &num, 0, 0); + return num; +} diff --git a/source/dnode/vnode/src/inc/vnd.h b/source/dnode/vnode/src/inc/vnd.h index f9f4b603fd..304716744c 100644 --- a/source/dnode/vnode/src/inc/vnd.h +++ b/source/dnode/vnode/src/inc/vnd.h @@ -120,6 +120,7 @@ void vnodeQueryClose(SVnode* pVnode); int32_t vnodeGetTableMeta(SVnode* pVnode, SRpcMsg* pMsg, bool direct); int vnodeGetTableCfg(SVnode* pVnode, SRpcMsg* pMsg, bool direct); int32_t vnodeGetBatchMeta(SVnode* pVnode, SRpcMsg* pMsg); +int32_t vnodeGetStreamProgress(SVnode* pVnode, SRpcMsg* pMsg, bool direct); // vnodeCommit.c int32_t vnodeBegin(SVnode* pVnode); diff --git a/source/dnode/vnode/src/inc/vnodeInt.h b/source/dnode/vnode/src/inc/vnodeInt.h index 13a13d81ca..d79565813b 100644 --- a/source/dnode/vnode/src/inc/vnodeInt.h +++ b/source/dnode/vnode/src/inc/vnodeInt.h @@ -294,6 +294,7 @@ int32_t tqProcessTaskDispatchRsp(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskRetrieveReq(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskRetrieveRsp(STQ* pTq, SRpcMsg* pMsg); int32_t tqProcessTaskScanHistory(STQ* pTq, SRpcMsg* pMsg); +int32_t tqStreamProgressRetrieveReq(STQ* pTq, SRpcMsg* pMsg); // sma int32_t smaInit(); diff --git a/source/dnode/vnode/src/tq/tq.c b/source/dnode/vnode/src/tq/tq.c index ef3e643926..00ca0319d0 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -1031,6 +1031,44 @@ int32_t tqProcessTaskRetrieveRsp(STQ* pTq, SRpcMsg* pMsg) { return 0; } +int32_t tqStreamProgressRetrieveReq(STQ *pTq, SRpcMsg *pMsg) { + char* msgStr = pMsg->pCont; + char* msgBody = POINTER_SHIFT(msgStr, sizeof(SMsgHead)); + int32_t msgLen = pMsg->contLen - sizeof(SMsgHead); + int32_t code = 0; + SStreamProgressReq req; + char* pRspBuf = taosMemoryCalloc(1, sizeof(SMsgHead) + sizeof(SStreamProgressRsp)); + SStreamProgressRsp* pRsp = POINTER_SHIFT(pRspBuf, sizeof(SMsgHead)); + if (!pRspBuf) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + code = -1; + goto _OVER; + } + + code = tDeserializeStreamProgressReq(msgBody, msgLen, &req); + if (code == TSDB_CODE_SUCCESS) { + code = tqGetStreamExecInfo(pTq->pVnode, req.streamId, &pRsp->progressDelay, &pRsp->fillHisFinished); + } + if (code == TSDB_CODE_SUCCESS) { + pRsp->fetchIdx = req.fetchIdx; + pRsp->subFetchIdx = req.subFetchIdx; + pRsp->vgId = req.vgId; + pRsp->streamId = req.streamId; + tSerializeStreamProgressRsp(pRsp, sizeof(SStreamProgressRsp) + sizeof(SMsgHead), pRsp); + SRpcMsg rsp = {.info = pMsg->info, .code = 0}; + rsp.pCont = pRspBuf; + pRspBuf = NULL; + rsp.contLen = sizeof(SMsgHead) + sizeof(SStreamProgressRsp); + tmsgSendRsp(&rsp); + } + +_OVER: + if (pRspBuf) { + taosMemoryFree(pRspBuf); + } + return code; +} + int32_t tqProcessTaskCheckPointSourceReq(STQ* pTq, SRpcMsg* pMsg, SRpcMsg* pRsp) { int32_t vgId = TD_VID(pTq->pVnode); SStreamMeta* pMeta = pTq->pStreamMeta; diff --git a/source/dnode/vnode/src/tq/tqPush.c b/source/dnode/vnode/src/tq/tqPush.c index 8fee1d5904..9a38776386 100644 --- a/source/dnode/vnode/src/tq/tqPush.c +++ b/source/dnode/vnode/src/tq/tqPush.c @@ -45,7 +45,7 @@ int32_t tqPushMsg(STQ* pTq, tmsg_t msgType) { // 1. the vnode has already been restored. // 2. the vnode should be the leader. // 3. the stream is not suspended yet. - if ((!tsDisableStream) && (numOfTasks > 0) && (msgType == TDMT_VND_SUBMIT || msgType == TDMT_VND_DELETE)) { + if ((!tsDisableStream) && (numOfTasks > 0) /* && (msgType == TDMT_VND_SUBMIT || msgType == TDMT_VND_DELETE)*/) { tqScanWalAsync(pTq, true); } diff --git a/source/dnode/vnode/src/tq/tqSink.c b/source/dnode/vnode/src/tq/tqSink.c index b060de029c..f7003ca41b 100644 --- a/source/dnode/vnode/src/tq/tqSink.c +++ b/source/dnode/vnode/src/tq/tqSink.c @@ -794,8 +794,8 @@ int32_t setDstTableDataUid(SVnode* pVnode, SStreamTask* pTask, SSDataBlock* pDat return TDB_CODE_SUCCESS; } -int32_t tqSetDstTableDataPayload(uint64_t suid, const STSchema* pTSchema, int32_t blockIndex, SSDataBlock* pDataBlock, - SSubmitTbData* pTableData, const char* id) { +int32_t tqSetDstTableDataPayload(uint64_t suid, const STSchema *pTSchema, int32_t blockIndex, SSDataBlock* pDataBlock, + SSubmitTbData* pTableData, const char* id) { int32_t numOfRows = pDataBlock->info.rows; tqDebug("s-task:%s sink data pipeline, build submit msg from %dth resBlock, including %d rows, dst suid:%" PRId64, id, diff --git a/source/dnode/vnode/src/tq/tqUtil.c b/source/dnode/vnode/src/tq/tqUtil.c index 5e5c77265b..8099d6a6f2 100644 --- a/source/dnode/vnode/src/tq/tqUtil.c +++ b/source/dnode/vnode/src/tq/tqUtil.c @@ -531,6 +531,11 @@ int32_t tqGetStreamExecInfo(SVnode* pVnode, int64_t streamId, int64_t* pDelay, b *fhFinished = !HAS_RELATED_FILLHISTORY_TASK(pTask); int64_t ver = walReaderGetCurrentVer(pTask->exec.pWalReader); + if (ver == -1) { + ver = pTask->chkInfo.processedVer; + } else { + ver--; + } SVersionRange verRange = {0}; walReaderValidVersionRange(pTask->exec.pWalReader, &verRange.minVer, &verRange.maxVer); @@ -545,13 +550,17 @@ int32_t tqGetStreamExecInfo(SVnode* pVnode, int64_t streamId, int64_t* pDelay, b int64_t latest = 0; code = walFetchHead(pReader, ver); - if (code != TSDB_CODE_SUCCESS) { + if (code == TSDB_CODE_SUCCESS) { cur = pReader->pHead->head.ingestTs; } - code = walFetchHead(pReader, verRange.maxVer); - if (code != TSDB_CODE_SUCCESS) { - latest = pReader->pHead->head.ingestTs; + if (ver == verRange.maxVer) { + latest = cur; + } else { + code = walFetchHead(pReader, verRange.maxVer); + if (code == TSDB_CODE_SUCCESS) { + latest = pReader->pHead->head.ingestTs; + } } if (pDelay != NULL) { // delay in ms diff --git a/source/dnode/vnode/src/tsdb/tsdbRead2.c b/source/dnode/vnode/src/tsdb/tsdbRead2.c index b6d171d203..76ec4da24c 100644 --- a/source/dnode/vnode/src/tsdb/tsdbRead2.c +++ b/source/dnode/vnode/src/tsdb/tsdbRead2.c @@ -5037,12 +5037,11 @@ int32_t tsdbReaderReset2(STsdbReader* pReader, SQueryTableDataCond* pCond) { bool asc = ASCENDING_TRAVERSE(pReader->info.order); int32_t step = asc ? 1 : -1; - int64_t ts = 0; if (asc) { - ts = (pReader->info.window.skey > INT64_MIN)? pReader->info.window.skey-1:pReader->info.window.skey; + ts = (pReader->info.window.skey > INT64_MIN) ? pReader->info.window.skey - 1 : pReader->info.window.skey; } else { - ts = (pReader->info.window.ekey < INT64_MAX)? pReader->info.window.ekey + 1:pReader->info.window.ekey; + ts = (pReader->info.window.ekey < INT64_MAX) ? pReader->info.window.ekey + 1 : pReader->info.window.ekey; } resetAllDataBlockScanInfo(pStatus->pTableMap, ts, step); diff --git a/source/dnode/vnode/src/vnd/vnodeQuery.c b/source/dnode/vnode/src/vnd/vnodeQuery.c index a85192546f..9a510ed362 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -323,6 +323,9 @@ int32_t vnodeGetBatchMeta(SVnode *pVnode, SRpcMsg *pMsg) { case TDMT_VND_TABLE_CFG: vnodeGetTableCfg(pVnode, &reqMsg, false); break; + case TDMT_VND_GET_STREAM_PROGRESS: + vnodeGetStreamProgress(pVnode, &reqMsg, false); + break; default: qError("invalid req msgType %d", req->msgType); reqMsg.code = TSDB_CODE_INVALID_MSG; @@ -711,3 +714,54 @@ void *vnodeGetIvtIdx(void *pVnode) { int32_t vnodeGetTableSchema(void *pVnode, int64_t uid, STSchema **pSchema, int64_t *suid) { return tsdbGetTableSchema(((SVnode *)pVnode)->pMeta, uid, pSchema, suid); } + +int32_t vnodeGetStreamProgress(SVnode* pVnode, SRpcMsg* pMsg, bool direct) { + int32_t code = 0; + SStreamProgressReq req; + SStreamProgressRsp rsp = {0}; + SRpcMsg rpcMsg = {.info = pMsg->info, .code = 0}; + char * buf = NULL; + int32_t rspLen = 0; + code = tDeserializeStreamProgressReq(pMsg->pCont, pMsg->contLen, &req); + + if (code == TSDB_CODE_SUCCESS) { + rsp.fetchIdx = req.fetchIdx; + rsp.subFetchIdx = req.subFetchIdx; + rsp.vgId = req.vgId; + rsp.streamId = req.streamId; + rspLen = tSerializeStreamProgressRsp(0, 0, &rsp); + if (direct) { + buf = rpcMallocCont(rspLen); + } else { + buf = taosMemoryCalloc(1, rspLen); + } + if (!buf) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + code = -1; + goto _OVER; + } + } + + if (code == TSDB_CODE_SUCCESS) { + code = tqGetStreamExecInfo(pVnode, req.streamId, &rsp.progressDelay, &rsp.fillHisFinished); + } + if (code == TSDB_CODE_SUCCESS) { + tSerializeStreamProgressRsp(buf, rspLen, &rsp); + rpcMsg.pCont = buf; + buf = NULL; + rpcMsg.contLen = rspLen; + rpcMsg.code = code; + rpcMsg.msgType = pMsg->msgType; + if (direct) { + tmsgSendRsp(&rpcMsg); + } else { + *pMsg = rpcMsg; + } + } + +_OVER: + if (buf) { + taosMemoryFree(buf); + } + return code; +} diff --git a/source/dnode/vnode/src/vnd/vnodeSvr.c b/source/dnode/vnode/src/vnd/vnodeSvr.c index 7a6b1e69d9..5d8b587d30 100644 --- a/source/dnode/vnode/src/vnd/vnodeSvr.c +++ b/source/dnode/vnode/src/vnd/vnodeSvr.c @@ -50,6 +50,7 @@ static int32_t vnodeProcessArbCheckSyncReq(SVnode *pVnode, void *pReq, int32_t l static int32_t vnodePreCheckAssignedLogSyncd(SVnode *pVnode, char *member0Token, char *member1Token); static int32_t vnodeCheckAssignedLogSyncd(SVnode *pVnode, char *member0Token, char *member1Token); +static int32_t vnodeProcessFetchTtlExpiredTbs(SVnode* pVnode, int64_t ver, void* pReq, int32_t len, SRpcMsg* pRsp); extern int32_t vnodeProcessKillCompactReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp); extern int32_t vnodeQueryCompactProgress(SVnode *pVnode, SRpcMsg *pMsg); @@ -484,6 +485,7 @@ int32_t vnodePreProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg) { case TDMT_VND_ALTER_TABLE: { code = vnodePreProcessAlterTableMsg(pVnode, pMsg); } break; + case TDMT_VND_FETCH_TTL_EXPIRED_TBS: case TDMT_VND_DROP_TTL_TABLE: { code = vnodePreProcessDropTtlMsg(pVnode, pMsg); } break; @@ -563,6 +565,9 @@ int32_t vnodeProcessWriteMsg(SVnode *pVnode, SRpcMsg *pMsg, int64_t ver, SRpcMsg case TDMT_VND_DROP_TTL_TABLE: if (vnodeProcessDropTtlTbReq(pVnode, ver, pReq, len, pRsp) < 0) goto _err; break; + case TDMT_VND_FETCH_TTL_EXPIRED_TBS: + if (vnodeProcessFetchTtlExpiredTbs(pVnode, ver, pReq, len, pRsp) < 0) goto _err; + break; case TDMT_VND_TRIM: if (vnodeProcessTrimReq(pVnode, ver, pReq, len, pRsp) < 0) goto _err; break; @@ -838,6 +843,8 @@ int32_t vnodeProcessStreamMsg(SVnode *pVnode, SRpcMsg *pMsg, SQueueInfo *pInfo) return tqProcessStreamReqCheckpointRsp(pVnode->pTq, pMsg); case TDMT_STREAM_TASK_CHECKPOINT_READY_RSP: return tqProcessTaskCheckpointReadyRsp(pVnode->pTq, pMsg); + case TDMT_VND_GET_STREAM_PROGRESS: + return tqStreamProgressRetrieveReq(pVnode->pTq, pMsg); default: vError("unknown msg type:%d in stream queue", pMsg->msgType); return TSDB_CODE_APP_ERROR; @@ -924,6 +931,75 @@ end: return ret; } +static int32_t vnodeProcessFetchTtlExpiredTbs(SVnode* pVnode, int64_t ver, void* pReq, int32_t len, SRpcMsg* pRsp) { + int32_t code = -1; + SMetaReader mr = {0}; + SVDropTtlTableReq ttlReq = {0}; + SVFetchTtlExpiredTbsRsp rsp = {0}; + SEncoder encoder = {0}; + SArray* pNames = NULL; + pRsp->msgType = TDMT_VND_FETCH_TTL_EXPIRED_TBS_RSP; + pRsp->code = TSDB_CODE_SUCCESS; + pRsp->pCont = NULL; + pRsp->contLen = 0; + + if (tDeserializeSVDropTtlTableReq(pReq, len, &ttlReq) != 0) { + terrno = TSDB_CODE_INVALID_MSG; + goto _end; + } + + ASSERT(ttlReq.nUids == taosArrayGetSize(ttlReq.pTbUids)); + + tb_uid_t suid; + char ctbName[TSDB_TABLE_NAME_LEN]; + SVDropTbReq expiredTb = {.igNotExists = true}; + metaReaderDoInit(&mr, pVnode->pMeta, 0); + rsp.vgId = TD_VID(pVnode); + rsp.pExpiredTbs = taosArrayInit(ttlReq.nUids, sizeof(SVDropTbReq)); + if (!rsp.pExpiredTbs) goto _end; + + pNames = taosArrayInit(ttlReq.nUids, TSDB_TABLE_NAME_LEN); + if (!pNames) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + goto _end; + } + char buf[TSDB_TABLE_NAME_LEN]; + for (int32_t i = 0; i < ttlReq.nUids; ++i) { + tb_uid_t* uid = taosArrayGet(ttlReq.pTbUids, i); + expiredTb.suid = *uid; + terrno = metaReaderGetTableEntryByUid(&mr, *uid); + if (terrno < 0) goto _end; + strncpy(buf, mr.me.name, TSDB_TABLE_NAME_LEN); + void* p = taosArrayPush(pNames, buf); + expiredTb.name = p; + if (mr.me.type == TSDB_CHILD_TABLE) { + expiredTb.suid = mr.me.ctbEntry.suid; + } + taosArrayPush(rsp.pExpiredTbs, &expiredTb); + } + + int32_t ret = 0; + tEncodeSize(tEncodeVFetchTtlExpiredTbsRsp, &rsp, pRsp->contLen, ret); + pRsp->pCont = rpcMallocCont(pRsp->contLen); + if (pRsp->pCont == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + code = -1; + goto _end; + } + tEncoderInit(&encoder, pRsp->pCont, pRsp->contLen); + terrno = tEncodeVFetchTtlExpiredTbsRsp(&encoder, &rsp); + tEncoderClear(&encoder); + + if (terrno == 0) code = 0; +_end: + metaReaderClear(&mr); + tFreeFetchTtlExpiredTbsRsp(&rsp); + taosArrayDestroy(ttlReq.pTbUids); + if (pNames) taosArrayDestroy(pNames); + pRsp->code = terrno; + return code; +} + static int32_t vnodeProcessCreateStbReq(SVnode *pVnode, int64_t ver, void *pReq, int32_t len, SRpcMsg *pRsp) { SVCreateStbReq req = {0}; SDecoder coder; diff --git a/source/libs/catalog/inc/catalogInt.h b/source/libs/catalog/inc/catalogInt.h index dc30e88b29..c5c14950b2 100644 --- a/source/libs/catalog/inc/catalogInt.h +++ b/source/libs/catalog/inc/catalogInt.h @@ -31,6 +31,7 @@ extern "C" { #define CTG_DEFAULT_CACHE_DB_NUMBER 20 #define CTG_DEFAULT_CACHE_TBLMETA_NUMBER 1000 #define CTG_DEFAULT_CACHE_VIEW_NUMBER 256 +#define CTG_DEFAULT_CACHE_TSMA_NUMBER 10 #define CTG_DEFAULT_RENT_SECOND 10 #define CTG_DEFAULT_RENT_SLOT_SIZE 10 #define CTG_DEFAULT_MAX_RETRY_TIMES 3 @@ -69,6 +70,7 @@ typedef enum { CTG_CI_UDF, CTG_CI_SVR_VER, CTG_CI_VIEW, + CTG_CI_TBL_TSMA, CTG_CI_MAX_VALUE, } CTG_CACHE_ITEM; @@ -85,6 +87,7 @@ enum { CTG_RENT_DB = 1, CTG_RENT_STABLE, CTG_RENT_VIEW, + CTG_RENT_TSMA, }; enum { @@ -101,6 +104,8 @@ enum { CTG_OP_DROP_TB_INDEX, CTG_OP_UPDATE_VIEW_META, CTG_OP_DROP_VIEW_META, + CTG_OP_UPDATE_TB_TSMA, + CTG_OP_DROP_TB_TSMA, CTG_OP_CLEAR_CACHE, CTG_OP_MAX }; @@ -123,6 +128,8 @@ typedef enum { CTG_TASK_GET_TB_HASH_BATCH, CTG_TASK_GET_TB_TAG, CTG_TASK_GET_VIEW, + CTG_TASK_GET_TB_TSMA, + CTG_TASK_GET_TSMA, } CTG_TASK_TYPE; typedef enum { @@ -255,14 +262,47 @@ typedef struct SCtgViewsCtx { SArray* pFetchs; } SCtgViewsCtx; +typedef enum { + FETCH_TSMA_SOURCE_TB_META, + FETCH_TB_TSMA, + FETCH_TSMA_STREAM_PROGRESS, +} CTG_TSMA_FETCH_TYPE; + +typedef struct SCtgTSMAFetch { + CTG_TSMA_FETCH_TYPE fetchType; + int32_t dbIdx; + int32_t tbIdx; + int32_t fetchIdx; + int32_t resIdx; + + // tb meta + int32_t flag; + int32_t vgId; + + // stream progress + int32_t subFetchNum; + int32_t finishedSubFetchNum; + int32_t vgNum; + + // tb tsma + SName tsmaSourceTbName; +} SCtgTSMAFetch; + +typedef struct SCtgTbTSMACtx { + int32_t fetchNum; + SArray* pNames; // SArray + SArray* pResList; + SArray* pFetches; +} SCtgTbTSMACtx; typedef STableIndexRsp STableIndex; +typedef STableTSMAInfo STSMACache; typedef struct SCtgTbCache { - SRWLatch metaLock; - SRWLatch indexLock; - STableMeta* pMeta; - STableIndex* pIndex; + SRWLatch metaLock; + SRWLatch indexLock; + STableMeta* pMeta; + STableIndex* pIndex; } SCtgTbCache; typedef struct SCtgVgCache { @@ -280,6 +320,10 @@ typedef struct SCtgViewCache { SViewMeta* pMeta; } SCtgViewCache; +typedef struct SCtgTSMACache { + SRWLatch tsmaLock; + SArray* pTsmas; // SArray +} SCtgTSMACache; typedef struct SCtgDBCache { SRWLatch dbLock; // RC between destroy tbCache/stbCache and all reads @@ -290,6 +334,8 @@ typedef struct SCtgDBCache { SHashObj* viewCache; // key:viewname, value:SCtgViewCache SHashObj* tbCache; // key:tbname, value:SCtgTbCache SHashObj* stbCache; // key:suid, value:char* + SHashObj* tsmaCache; // key:tbname, value: SCtgTSMACache + int32_t tsmaVersion; uint64_t dbCacheNum[CTG_CI_MAX_VALUE]; uint64_t dbCacheSize; } SCtgDBCache; @@ -325,6 +371,7 @@ typedef struct SCatalog { SCtgRentMgmt dbRent; SCtgRentMgmt stbRent; SCtgRentMgmt viewRent; + SCtgRentMgmt tsmaRent; SCtgCacheStat cacheStat; } SCatalog; @@ -370,6 +417,8 @@ typedef struct SCtgJob { int32_t tbCfgNum; int32_t svrVerNum; int32_t viewNum; + int32_t tbTsmaNum; + int32_t tsmaNum; // currently, only 1 is possible } SCtgJob; typedef struct SCtgMsgCtx { @@ -548,6 +597,24 @@ typedef struct SCtgDropViewMetaMsg { uint64_t viewId; } SCtgDropViewMetaMsg; +typedef struct SCtgUpdateTbTSMAMsg { + SCatalog* pCtg; + STableTSMAInfo* pTsma; + int32_t dbTsmaVersion; + uint64_t dbId; +} SCtgUpdateTbTSMAMsg; + +typedef struct SCtgDropTbTSMAMsg { + SCatalog* pCtg; + char dbFName[TSDB_DB_FNAME_LEN]; + char tbName[TSDB_TABLE_NAME_LEN]; + char tsmaName[TSDB_TABLE_NAME_LEN]; + uint64_t tsmaId; + uint64_t dbId; + uint64_t tbId; + bool dropAllForTb; +} SCtgDropTbTSMAMsg; + typedef struct SCtgCacheOperation { int32_t opId; @@ -726,7 +793,9 @@ typedef struct SCtgCacheItemInfo { (CTG_FLAG_IS_UNKNOWN_STB(_flag) || (CTG_FLAG_IS_STB(_flag) && (tbType) == TSDB_SUPER_TABLE) || \ (CTG_FLAG_IS_NOT_STB(_flag) && (tbType) != TSDB_SUPER_TABLE)) -#define CTG_IS_BATCH_TASK(_taskType) ((CTG_TASK_GET_TB_META_BATCH == (_taskType)) || (CTG_TASK_GET_TB_HASH_BATCH == (_taskType)) || (CTG_TASK_GET_VIEW == (_taskType))) +#define CTG_IS_BATCH_TASK(_taskType) \ + ((CTG_TASK_GET_TB_META_BATCH == (_taskType)) || (CTG_TASK_GET_TB_HASH_BATCH == (_taskType)) || \ + (CTG_TASK_GET_VIEW == (_taskType)) || (CTG_TASK_GET_TB_TSMA == (_taskType))) #define CTG_GET_TASK_MSGCTX(_task, _id) \ (CTG_IS_BATCH_TASK((_task)->type) ? taosArrayGet((_task)->msgCtxs, (_id)) : &(_task)->msgCtx) @@ -917,7 +986,7 @@ int32_t ctgOpUpdateEpset(SCtgCacheOperation* operation); int32_t ctgAcquireVgInfoFromCache(SCatalog* pCtg, const char* dbFName, SCtgDBCache** pCache); void ctgReleaseDBCache(SCatalog* pCtg, SCtgDBCache* dbCache); void ctgRUnlockVgInfo(SCtgDBCache* dbCache); -int32_t ctgTbMetaExistInCache(SCatalog* pCtg, char* dbFName, char* tbName, int32_t* exist); +int32_t ctgTbMetaExistInCache(SCatalog* pCtg, const char* dbFName, const char* tbName, int32_t* exist); int32_t ctgReadTbMetaFromCache(SCatalog* pCtg, SCtgTbMetaCtx* ctx, STableMeta** pTableMeta); int32_t ctgReadTbVerFromCache(SCatalog* pCtg, SName* pTableName, int32_t* sver, int32_t* tver, int32_t* tbType, uint64_t* suid, char* stbName); @@ -943,10 +1012,12 @@ int32_t ctgMetaRentGet(SCtgRentMgmt* mgmt, void** res, uint32_t* num, int32_t si int32_t ctgMetaRentRemove(SCtgRentMgmt *mgmt, int64_t id, __compar_fn_t sortCompare, __compar_fn_t searchCompare); void ctgRemoveStbRent(SCatalog *pCtg, SCtgDBCache *dbCache); void ctgRemoveViewRent(SCatalog *pCtg, SCtgDBCache *dbCache); +void ctgRemoveTSMARent(SCatalog* pCtg, SCtgDBCache* dbCache); int32_t ctgUpdateRentStbVersion(SCatalog *pCtg, char *dbFName, char *tbName, uint64_t dbId, uint64_t suid, SCtgTbCache *pCache); int32_t ctgUpdateRentViewVersion(SCatalog *pCtg, char *dbFName, char *viewName, uint64_t dbId, uint64_t viewId, - SCtgViewCache *pCache); + SCtgViewCache *pCache); +int32_t ctgUpdateRentTSMAVersion(SCatalog* pCtg, char* dbFName, const STSMACache* pCache); int32_t ctgUpdateTbMetaToCache(SCatalog* pCtg, STableMetaOutput* pOut, bool syncReq); int32_t ctgUpdateViewMetaToCache(SCatalog *pCtg, SViewMetaRsp *pRsp, bool syncReq); int32_t ctgStartUpdateThread(); @@ -976,7 +1047,7 @@ int32_t ctgGetUdfInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const ch SCtgTask* pTask); int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const char* user, SGetUserAuthRsp* out, SCtgTask* pTask); -int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo* pConn, char* dbFName, char* tbName, +int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo* pConn, const char* dbFName, const char* tbName, STableMetaOutput* out, SCtgTaskReq* tReq); int32_t ctgGetTbMetaFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, STableMetaOutput* out, SCtgTaskReq* tReq); @@ -1018,9 +1089,11 @@ void ctgFreeDbCache(SCtgDBCache* dbCache); int32_t ctgStbVersionSortCompare(const void* key1, const void* key2); int32_t ctgViewVersionSortCompare(const void* key1, const void* key2); int32_t ctgDbCacheInfoSortCompare(const void* key1, const void* key2); +int32_t ctgTSMAVersionSortCompare(const void* key1, const void* key2); int32_t ctgStbVersionSearchCompare(const void* key1, const void* key2); int32_t ctgDbCacheInfoSearchCompare(const void* key1, const void* key2); int32_t ctgViewVersionSearchCompare(const void* key1, const void* key2); +int32_t ctgTSMAVersionSearchCompare(const void* key1, const void* key2); void ctgFreeSTableMetaOutput(STableMetaOutput* pOutput); int32_t ctgUpdateMsgCtx(SCtgMsgCtx* pCtx, int32_t reqType, void* out, char* target); int32_t ctgAddMsgCtx(SArray* pCtxs, int32_t reqType, void* out, char* target); @@ -1073,6 +1146,26 @@ int32_t ctgGetCachedStbNameFromSuid(SCatalog* pCtg, char* dbFName, uint64_t suid int32_t ctgGetTbTagCb(SCtgTask* pTask); int32_t ctgGetUserCb(SCtgTask* pTask); +int32_t ctgGetTbTSMAFromCache(SCatalog* pCtg, SCtgTbTSMACtx* pCtx, int32_t dbIdx, int32_t* fetchIdx, int32_t baseResIdx, + SArray* pList); +int32_t ctgGetTSMAFromCache(SCatalog* pCtg, SCtgTbTSMACtx* pCtx, SName* pTsmaName); +int32_t ctgGetTbTSMAFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* name, STableTSMAInfoRsp* out, + SCtgTaskReq* tReq, int32_t reqType); +int32_t ctgUpdateTbTSMAEnqueue(SCatalog* pCtg, STSMACache** pTsma, int32_t tsmaVersion, bool syncOp); +int32_t ctgDropTSMAForTbEnqueue(SCatalog* pCtg, SName* pName, bool syncOp); +int32_t ctgDropTbTSMAEnqueue(SCatalog* pCtg, const STSMACache* pTsma, bool syncOp); +int32_t ctgOpDropTbTSMA(SCtgCacheOperation* operation); +int32_t ctgOpUpdateTbTSMA(SCtgCacheOperation* operation); +uint64_t ctgGetTbTSMACacheSize(STSMACache* pTsmaInfo); +void ctgFreeTbTSMAInfo(void* p); +bool hasOutOfDateTSMACache(SArray* pTsmas); +bool isCtgTSMACacheOutOfDate(STSMACache* pTsmaCache); +int32_t ctgGetStreamProgressFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTbName, + SVgroupInfo* vgroupInfo, SStreamProgressRsp* out, SCtgTaskReq* tReq, + void* bInput); +int32_t ctgAddTSMAFetch(SArray** pFetchs, int32_t dbIdx, int32_t tbIdx, int32_t* fetchIdx, int32_t resIdx, int32_t flag, + CTG_TSMA_FETCH_TYPE fetchType, const SName* sourceTbName); + extern SCatalogMgmt gCtgMgmt; extern SCtgDebug gCTGDebug; extern SCtgAsyncFps gCtgAsyncFps[]; diff --git a/source/libs/catalog/src/catalog.c b/source/libs/catalog/src/catalog.c index c2d88e5ce3..e7d5a89d6f 100644 --- a/source/libs/catalog/src/catalog.c +++ b/source/libs/catalog/src/catalog.c @@ -759,6 +759,10 @@ int32_t catalogInit(SCatalogCfg* cfg) { gCtgMgmt.cfg.maxViewCacheNum = CTG_DEFAULT_CACHE_VIEW_NUMBER; } + if (gCtgMgmt.cfg.maxTSMACacheNum == 0) { + gCtgMgmt.cfg.maxTSMACacheNum = CTG_DEFAULT_CACHE_TSMA_NUMBER; + } + if (gCtgMgmt.cfg.dbRentSec == 0) { gCtgMgmt.cfg.dbRentSec = CTG_DEFAULT_RENT_SECOND; } @@ -770,13 +774,19 @@ int32_t catalogInit(SCatalogCfg* cfg) { if (gCtgMgmt.cfg.viewRentSec == 0) { gCtgMgmt.cfg.viewRentSec = CTG_DEFAULT_RENT_SECOND; } + + if (gCtgMgmt.cfg.tsmaRentSec == 0) { + gCtgMgmt.cfg.tsmaRentSec = CTG_DEFAULT_RENT_SECOND; + } } else { gCtgMgmt.cfg.maxDBCacheNum = CTG_DEFAULT_CACHE_DB_NUMBER; gCtgMgmt.cfg.maxTblCacheNum = CTG_DEFAULT_CACHE_TBLMETA_NUMBER; gCtgMgmt.cfg.maxViewCacheNum = CTG_DEFAULT_CACHE_VIEW_NUMBER; + gCtgMgmt.cfg.maxTSMACacheNum = CTG_DEFAULT_CACHE_TSMA_NUMBER; gCtgMgmt.cfg.dbRentSec = CTG_DEFAULT_RENT_SECOND; gCtgMgmt.cfg.stbRentSec = CTG_DEFAULT_RENT_SECOND; gCtgMgmt.cfg.viewRentSec = CTG_DEFAULT_RENT_SECOND; + gCtgMgmt.cfg.tsmaRentSec = CTG_DEFAULT_RENT_SECOND; } gCtgMgmt.pCluster = taosHashInit(CTG_DEFAULT_CACHE_CLUSTER_NUMBER, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), @@ -862,6 +872,7 @@ int32_t catalogGetHandle(uint64_t clusterId, SCatalog** catalogHandle) { CTG_ERR_JRET(ctgMetaRentInit(&clusterCtg->dbRent, gCtgMgmt.cfg.dbRentSec, CTG_RENT_DB, sizeof(SDbCacheInfo))); CTG_ERR_JRET(ctgMetaRentInit(&clusterCtg->stbRent, gCtgMgmt.cfg.stbRentSec, CTG_RENT_STABLE, sizeof(SSTableVersion))); CTG_ERR_JRET(ctgMetaRentInit(&clusterCtg->viewRent, gCtgMgmt.cfg.viewRentSec, CTG_RENT_VIEW, sizeof(SViewVersion))); + CTG_ERR_JRET(ctgMetaRentInit(&clusterCtg->tsmaRent, gCtgMgmt.cfg.tsmaRentSec, CTG_RENT_TSMA, sizeof(STSMAVersion))); clusterCtg->dbCache = taosHashInit(gCtgMgmt.cfg.maxDBCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); @@ -1562,6 +1573,16 @@ int32_t catalogGetExpiredUsers(SCatalog* pCtg, SUserAuthVersion** users, uint32_ CTG_API_LEAVE(TSDB_CODE_SUCCESS); } +int32_t catalogGetExpiredTsmas(SCatalog* pCtg, STSMAVersion** tsmas, uint32_t* num) { + CTG_API_ENTER(); + + if (!pCtg || !tsmas || !num) { + CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); + } + + CTG_API_LEAVE(ctgMetaRentGet(&pCtg->tsmaRent, (void**)tsmas, num, sizeof(STSMAVersion))); +} + int32_t catalogGetDBCfg(SCatalog* pCtg, SRequestConnInfo* pConn, const char* dbFName, SDbCfgInfo* pDbCfg) { CTG_API_ENTER(); @@ -1769,6 +1790,122 @@ int32_t catalogGetViewMeta(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* CTG_API_LEAVE(TSDB_CODE_OPS_NOT_SUPPORT); } +int32_t catalogAsyncUpdateTSMA(SCatalog* pCtg, STableTSMAInfo** ppTsma, int32_t tsmaVersion) { + CTG_API_ENTER(); + if (!pCtg || !ppTsma) { + CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); + } + int32_t code = 0; + CTG_ERR_JRET(ctgUpdateTbTSMAEnqueue(pCtg, ppTsma, tsmaVersion, false)); + +_return: + CTG_API_LEAVE(code); +} + +int32_t catalogUpdateTSMA(SCatalog* pCtg, STableTSMAInfo** pTsma) { + CTG_API_ENTER(); + if (!pCtg || !pTsma) { + CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); + } + int32_t code = 0; + CTG_ERR_JRET(ctgUpdateTbTSMAEnqueue(pCtg, pTsma, 0, true)); + +_return: + CTG_API_LEAVE(code); +} + +int32_t catalogRemoveTSMA(SCatalog* pCtg, const STableTSMAInfo* pTsma) { + CTG_API_ENTER(); + int32_t code = 0; + + if (!pCtg || !pTsma) { + CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); + } + + if (!pCtg->dbCache) { + return TSDB_CODE_SUCCESS; + } + CTG_ERR_JRET(ctgDropTbTSMAEnqueue(pCtg, pTsma, true)); +_return: + CTG_API_LEAVE(code); +} + +int32_t ctgGetTbTsmas(SCatalog* pCtg, SRequestConnInfo* pConn, SName* pTableName, SArray** ppRes) { + STableTSMAInfoRsp tsmasRsp = {0}; + int32_t code = ctgGetTbTSMAFromMnode(pCtg, pConn, pTableName, &tsmasRsp, NULL, TDMT_MND_GET_TABLE_TSMA); + if (code == TSDB_CODE_MND_SMA_NOT_EXIST) { + code = 0; + goto _return; + } + CTG_ERR_JRET(code); + assert(tsmasRsp.pTsmas); + assert(tsmasRsp.pTsmas->size > 0); + *ppRes = tsmasRsp.pTsmas; + tsmasRsp.pTsmas = NULL; + + for (int32_t i = 0; i < (*ppRes)->size; ++i) { + CTG_ERR_JRET(ctgUpdateTbTSMAEnqueue(pCtg, taosArrayGet((*ppRes), i), 0, false)); + } + return TSDB_CODE_SUCCESS; + +_return: + if (tsmasRsp.pTsmas) { + tFreeTableTSMAInfoRsp(&tsmasRsp); + } + CTG_RET(code); +} + +int32_t catalogGetTableTsmas(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTableName, SArray** pRes) { + CTG_API_ENTER(); + + if (NULL == pCtg || NULL == pConn || NULL == pTableName || NULL == pRes) { + CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); + } + + int32_t code = 0; + CTG_ERR_JRET(ctgGetTbTsmas(pCtg, pConn, (SName*)pTableName, pRes)); + +_return: + + CTG_API_LEAVE(code); +} + +int32_t ctgGetTsma(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTsmaName, STableTSMAInfo** pTsma) { + STableTSMAInfoRsp tsmaRsp = {0}; + int32_t code = ctgGetTbTSMAFromMnode(pCtg, pConn, pTsmaName, &tsmaRsp, NULL, TDMT_MND_GET_TSMA); + if (code == TSDB_CODE_MND_SMA_NOT_EXIST) { + code = 0; + goto _return; + } + + CTG_ERR_JRET(code); + + ASSERT(tsmaRsp.pTsmas && tsmaRsp.pTsmas->size == 1); + *pTsma = taosArrayGetP(tsmaRsp.pTsmas, 0); + taosArrayDestroy(tsmaRsp.pTsmas); + tsmaRsp.pTsmas = NULL; + +_return: + if (tsmaRsp.pTsmas) { + tFreeTableTSMAInfoRsp(&tsmaRsp); + } + CTG_RET(code); +} + +int32_t catalogGetTsma(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTsmaName, STableTSMAInfo** pTsma) { + CTG_API_ENTER(); + + if (!pCtg || !pConn || !pTsmaName) { + CTG_API_LEAVE(TSDB_CODE_CTG_INVALID_INPUT); + } + + int32_t code = 0; + CTG_ERR_JRET(ctgGetTsma(pCtg, pConn, pTsmaName, pTsma)); + +_return: + CTG_API_LEAVE(code); +} + int32_t catalogClearCache(void) { CTG_API_ENTER_NOLOCK(); diff --git a/source/libs/catalog/src/ctgAsync.c b/source/libs/catalog/src/ctgAsync.c index 39d3aa0ff7..601e01f7e9 100644 --- a/source/libs/catalog/src/ctgAsync.c +++ b/source/libs/catalog/src/ctgAsync.c @@ -476,6 +476,37 @@ int32_t ctgHandleForceUpdateView(SCatalog* pCtg, const SCatalogReq* pReq) { return TSDB_CODE_SUCCESS; } +int32_t ctgInitGetTbTSMATask(SCtgJob* pJob, int32_t taskId, void* param) { + SCtgTask task = {0}; + task.type = CTG_TASK_GET_TB_TSMA; + task.taskId = taskId; + task.pJob = pJob; + + SCtgTbTSMACtx* pTaskCtx = taosMemoryCalloc(1, sizeof(SCtgTbTSMACtx)); + if (!pTaskCtx) CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + task.taskCtx = pTaskCtx; + pTaskCtx->pNames = param; + pTaskCtx->pResList = taosArrayInit(pJob->tbTsmaNum, sizeof(SMetaRes)); + + taosArrayPush(pJob->pTasks, &task); + return TSDB_CODE_SUCCESS; +} + +int32_t ctgInitGetTSMATask(SCtgJob* pJob, int32_t taskId, void* param) { + SCtgTask task = {0}; + task.type = CTG_TASK_GET_TSMA; + task.taskId = taskId; + task.pJob = pJob; + + SCtgTbTSMACtx* pTaskCtx = taosMemoryCalloc(1, sizeof(SCtgTbTSMACtx)); + if (!pTaskCtx) CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + task.taskCtx = pTaskCtx; + pTaskCtx->pNames = param; + pTaskCtx->pResList = taosArrayInit(pJob->tsmaNum, sizeof(SMetaRes)); + + taosArrayPush(pJob->pTasks, &task); + return 0; +} int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob* pJob, const SCatalogReq* pReq) { SHashObj* pDb = taosHashInit(taskNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); @@ -573,6 +604,14 @@ int32_t ctgHandleForceUpdate(SCatalog* pCtg, int32_t taskNum, SCtgJob* pJob, con ctgDropTbIndexEnqueue(pCtg, name, true); } + for (int32_t i = 0; i < pJob->tbTsmaNum; ++i) { + STablesReq* pTbReq = taosArrayGet(pReq->pTableTSMAs, i); + for (int32_t j = 0; j < pTbReq->pTables->size; ++j) { + SName* name = taosArrayGet(pTbReq->pTables, j); + ctgDropTSMAForTbEnqueue(pCtg, name, true); + } + } + // REFRESH VIEW META return ctgHandleForceUpdateView(pCtg, pReq); } @@ -614,9 +653,11 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const int32_t tbCfgNum = (int32_t)taosArrayGetSize(pReq->pTableCfg); int32_t tbTagNum = (int32_t)taosArrayGetSize(pReq->pTableTag); int32_t viewNum = (int32_t)ctgGetTablesReqNum(pReq->pView); + int32_t tbTsmaNum = (int32_t)taosArrayGetSize(pReq->pTableTSMAs); + int32_t tsmaNum = (int32_t)taosArrayGetSize(pReq->pTSMAs); int32_t taskNum = tbMetaNum + dbVgNum + udfNum + tbHashNum + qnodeNum + dnodeNum + svrVerNum + dbCfgNum + indexNum + - userNum + dbInfoNum + tbIndexNum + tbCfgNum + tbTagNum + viewNum; + userNum + dbInfoNum + tbIndexNum + tbCfgNum + tbTagNum + viewNum + tbTsmaNum; *job = taosMemoryCalloc(1, sizeof(SCtgJob)); if (NULL == *job) { @@ -649,6 +690,8 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const pJob->svrVerNum = svrVerNum; pJob->tbTagNum = tbTagNum; pJob->viewNum = viewNum; + pJob->tbTsmaNum = tbTsmaNum; + pJob->tsmaNum = tsmaNum; #if CTG_BATCH_FETCH pJob->pBatchs = @@ -741,6 +784,13 @@ int32_t ctgInitJob(SCatalog* pCtg, SRequestConnInfo* pConn, SCtgJob** job, const CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_VIEW, pReq->pView, NULL)); } + if (tbTsmaNum > 0) { + CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_TB_TSMA, pReq->pTableTSMAs, NULL)); + } + if (tsmaNum > 0) { + CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_TSMA, pReq->pTSMAs, NULL)); + } + if (qnodeNum) { CTG_ERR_JRET(ctgInitTask(pJob, CTG_TASK_GET_QNODE, NULL, NULL)); } @@ -2574,6 +2624,386 @@ int32_t ctgLaunchGetViewsTask(SCtgTask* pTask) { return TSDB_CODE_SUCCESS; } +int32_t ctgAsyncRefreshTbTsma(SCtgTaskReq* pReq, const SCtgTSMAFetch* pFetch) { + int32_t code = 0; + SCtgTask* pTask = pReq->pTask; + SCatalog* pCtg = pTask->pJob->pCtg; + SRequestConnInfo* pConn = &pTask->pJob->conn; + SCtgTbTSMACtx* pTaskCtx = pTask->taskCtx; + + SCtgDBCache* pDbCache = NULL; + STablesReq* pTbReq = taosArrayGet(pTaskCtx->pNames, pFetch->dbIdx); + + ctgAcquireVgInfoFromCache(pCtg, pTbReq->dbFName, &pDbCache); + if (pDbCache) { + + ctgReleaseVgInfoToCache(pCtg, pDbCache); + } else { + SBuildUseDBInput input = {0}; + tstrncpy(input.db, pTbReq->dbFName, tListLen(input.db)); + input.vgVersion = CTG_DEFAULT_INVALID_VERSION; + + CTG_ERR_JRET(ctgGetDBVgInfoFromMnode(pCtg, pConn, &input, NULL, pReq)); + } +_return: + return code; +} + +int32_t ctgLaunchGetTbTSMATask(SCtgTask* pTask) { + SCatalog* pCtg = pTask->pJob->pCtg; + SCtgTbTSMACtx* pCtx = (SCtgTbTSMACtx*)pTask->taskCtx; + SRequestConnInfo* pConn = &pTask->pJob->conn; + SArray* pRes = NULL; + SCtgJob* pJob = pTask->pJob; + + int32_t dbNum = taosArrayGetSize(pCtx->pNames); + int32_t fetchIdx = 0, baseResIdx = 0; + + for (int32_t idx = 0; idx < dbNum; ++idx) { + STablesReq* pReq = taosArrayGet(pCtx->pNames, idx); + CTG_ERR_RET(ctgGetTbTSMAFromCache(pCtg, pCtx, idx, &fetchIdx, baseResIdx, pReq->pTables)); + baseResIdx += taosArrayGetSize(pReq->pTables); + } + pCtx->fetchNum = taosArrayGetSize(pCtx->pFetches); + if (pCtx->fetchNum <= 0) { + TSWAP(pTask->res, pCtx->pResList); + CTG_ERR_RET(ctgHandleTaskEnd(pTask, 0)); + return TSDB_CODE_SUCCESS; + } + + pTask->msgCtxs = taosArrayInit_s(sizeof(SCtgMsgCtx), pCtx->fetchNum); + for (int32_t i = 0; i < pCtx->fetchNum; ++i) { + SCtgTSMAFetch* pFetch = taosArrayGet(pCtx->pFetches, i); + STablesReq* pReq = taosArrayGet(pCtx->pNames, pFetch->dbIdx); + SName* pName = taosArrayGet(pReq->pTables, pFetch->tbIdx); + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, i); + if (!pMsgCtx->pBatchs) pMsgCtx->pBatchs = pJob->pBatchs; + + SCtgTaskReq tReq; + tReq.pTask = pTask; + tReq.msgIdx = pFetch->fetchIdx; + + switch (pFetch->fetchType) { + case FETCH_TSMA_SOURCE_TB_META: { + CTG_ERR_RET(ctgAsyncRefreshTbMeta(&tReq, pFetch->flag, pName, &pFetch->vgId)); + } break; + case FETCH_TB_TSMA: { + CTG_ERR_RET( + ctgGetTbTSMAFromMnode(pCtg, pConn, &pFetch->tsmaSourceTbName, NULL, &tReq, TDMT_MND_GET_TABLE_TSMA)); + } break; + default: + ASSERT(0); + break; + } + } + + return TSDB_CODE_SUCCESS; +} + +int32_t ctgLaunchGetTSMATask(SCtgTask* pTask) { + SCatalog* pCtg = pTask->pJob->pCtg; + SCtgTbTSMACtx* pCtx = (SCtgTbTSMACtx*)pTask->taskCtx; + SRequestConnInfo* pConn = &pTask->pJob->conn; + SArray* pRes = NULL; + SCtgJob* pJob = pTask->pJob; + // currently, only support fetching one tsma + ASSERT(pCtx->pNames->size == 1); + STablesReq* pReq = taosArrayGet(pCtx->pNames, 0); + ASSERT(pReq->pTables->size == 1); + SName* pTsmaName = taosArrayGet(pReq->pTables, 0); + CTG_ERR_RET(ctgGetTSMAFromCache(pCtg, pCtx, pTsmaName)); + + if (pCtx->pResList->size == 0) { + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, 0); + if (!pMsgCtx->pBatchs) pMsgCtx->pBatchs = pJob->pBatchs; + SCtgTaskReq tReq = {.pTask = pTask, .msgIdx = 0}; + taosArrayPush(pCtx->pResList, &(SMetaRes){0}); + CTG_ERR_RET(ctgGetTbTSMAFromMnode(pCtg, pConn, pTsmaName, NULL, &tReq, TDMT_MND_GET_TSMA)); + } else { + SMetaRes* pRes = taosArrayGet(pCtx->pResList, 0); + STableTSMAInfoRsp* pRsp = (STableTSMAInfoRsp*)pRes->pRes; + ASSERT(pRsp->pTsmas->size == 1); + const STSMACache* pTsma = taosArrayGetP(pRsp->pTsmas, 0); + TSWAP(pTask->res, pCtx->pResList); + // get tsma target stable meta if not existed in cache + int32_t exists = false; + CTG_ERR_RET(ctgTbMetaExistInCache(pCtg, pTsma->targetDbFName, pTsma->targetTb, &exists)); + if (!exists) { + SCtgTaskReq tReq = {.pTask = pTask, .msgIdx = 0}; + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, 0); + if (!pMsgCtx->pBatchs) pMsgCtx->pBatchs = pJob->pBatchs; + CTG_RET(ctgGetTbMetaFromMnodeImpl(pCtg, pConn, pTsma->targetDbFName, pTsma->targetTb, NULL, &tReq)); + } else { + CTG_ERR_RET(ctgHandleTaskEnd(pTask, 0)); + } + return TSDB_CODE_SUCCESS; + } + + return 0; +} + +int32_t ctgHandleGetTSMARsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) { + int32_t code = 0; + SCtgTask* pTask = tReq->pTask; + SCatalog* pCtg = pTask->pJob->pCtg; + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx); + SCtgTbTSMACtx* pCtx = pTask->taskCtx; + SMetaRes* pRes = taosArrayGet(pCtx->pResList, 0); + STablesReq* pTbReq = taosArrayGet(pCtx->pNames, 0); + SName* pName = taosArrayGet(pTbReq->pTables, 0); + SRequestConnInfo* pConn = &pTask->pJob->conn; + CTG_ERR_JRET(ctgProcessRspMsg(pMsgCtx->out, reqType, pMsg->pData, pMsg->len, rspCode, pMsgCtx->target)); + + switch (reqType) { + case TDMT_MND_TABLE_META: { + STableMetaOutput* pOut = (STableMetaOutput*)pMsgCtx->out; + if (!CTG_IS_META_NULL(pOut->metaType)) { + CTG_ERR_JRET(ctgUpdateTbMetaToCache(pCtg, pOut, CTG_FLAG_SYNC_OP)); + } + } break; + case TDMT_MND_GET_TSMA: { + STableTSMAInfoRsp* pOut = pMsgCtx->out; + pRes->code = 0; + if (pOut->pTsmas->size > 0) { + ASSERT(pOut->pTsmas->size == 1); + pRes->pRes = pOut; + pMsgCtx->out = NULL; + TSWAP(pTask->res, pCtx->pResList); + + STableTSMAInfo* pTsma = taosArrayGetP(pOut->pTsmas, 0); + int32_t exists = false; + CTG_ERR_JRET(ctgTbMetaExistInCache(pCtg, pTsma->targetDbFName, pTsma->targetTb, &exists)); + if (!exists) { + TSWAP(pMsgCtx->lastOut, pMsgCtx->out); + CTG_RET(ctgGetTbMetaFromMnodeImpl(pCtg, pConn, pTsma->targetDbFName, pTsma->targetTb, NULL, tReq)); + } + } + } break; + default: + ASSERT(0); + } + +_return: + if (code) { + if (TSDB_CODE_MND_SMA_NOT_EXIST == code) { + code = TSDB_CODE_SUCCESS; + } else { + ctgTaskError("Get tsma for %d.%s.%s failed with err: %s", pName->acctId, pName->dbname, pName->tname, + tstrerror(code)); + } + } + ctgHandleTaskEnd(pTask, code); + CTG_RET(code); +} + +static int32_t ctgTsmaFetchStreamProgress(SCtgTaskReq* tReq, SHashObj* pVgHash, const STableTSMAInfoRsp* pTsmas) { + int32_t code = 0; + SCtgTask* pTask = tReq->pTask; + SCatalog* pCtg = pTask->pJob->pCtg; + int32_t subFetchIdx = 0; + SCtgTbTSMACtx* pCtx = pTask->taskCtx; + SCtgTSMAFetch* pFetch = taosArrayGet(pCtx->pFetches, tReq->msgIdx); + SRequestConnInfo* pConn = &pTask->pJob->conn; + STablesReq* pTbReq = taosArrayGet(pCtx->pNames, pFetch->dbIdx); + const SName* pTbName = taosArrayGet(pTbReq->pTables, pFetch->tbIdx); + SVgroupInfo* pVgInfo = NULL; + + pFetch->vgNum = taosHashGetSize(pVgHash); + for (int32_t i = 0; i < taosArrayGetSize(pTsmas->pTsmas); ++i) { + STableTSMAInfo* pTsmaInfo = taosArrayGetP(pTsmas->pTsmas, i); + pVgInfo = taosHashIterate(pVgHash, NULL); + pTsmaInfo->reqTs = taosGetTimestampMs(); + while (pVgInfo) { + // make StreamProgressReq, send it + SStreamProgressReq req = {.fetchIdx = pFetch->fetchIdx, + .streamId = pTsmaInfo->streamUid, + .subFetchIdx = subFetchIdx++, + .vgId = pVgInfo->vgId}; + CTG_ERR_JRET(ctgGetStreamProgressFromVnode(pCtg, pConn, pTbName, pVgInfo, NULL, tReq, &req)); + pFetch->subFetchNum++; + pVgInfo = taosHashIterate(pVgHash, pVgInfo); + } + } +_return: + CTG_RET(code); +} + +int32_t ctgHandleGetTbTSMARsp(SCtgTaskReq* tReq, int32_t reqType, const SDataBuf* pMsg, int32_t rspCode) { + bool taskDone = false; + int32_t code = 0; + SCtgTask* pTask = tReq->pTask; + SCatalog* pCtg = pTask->pJob->pCtg; + SCtgMsgCtx* pMsgCtx = CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx); + SCtgTbTSMACtx* pCtx = pTask->taskCtx; + SCtgTSMAFetch* pFetch = taosArrayGet(pCtx->pFetches, tReq->msgIdx); + SArray* pTsmas = NULL; + SMetaRes* pRes = taosArrayGet(pCtx->pResList, pFetch->resIdx); + SHashObj* pVgHash = NULL; + SCtgDBCache* pDbCache = NULL; + STableTSMAInfo* pTsma = NULL; + SRequestConnInfo* pConn = &pTask->pJob->conn; + STablesReq* pTbReq = taosArrayGet(pCtx->pNames, pFetch->dbIdx); + SName* pTbName = taosArrayGet(pTbReq->pTables, pFetch->tbIdx); + + if (reqType != TDMT_VND_GET_STREAM_PROGRESS) + CTG_ERR_JRET(ctgProcessRspMsg(pMsgCtx->out, reqType, pMsg->pData, pMsg->len, rspCode, pMsgCtx->target)); + + switch (reqType) { + case TDMT_MND_GET_TABLE_TSMA: { + STableTSMAInfoRsp* pOut = pMsgCtx->out; + pFetch->fetchType = FETCH_TSMA_STREAM_PROGRESS; + pRes->pRes = pOut; + pMsgCtx->out = NULL; + + if (pOut->pTsmas && taosArrayGetSize(pOut->pTsmas) > 0) { + // fetch progress + ctgAcquireVgInfoFromCache(pCtg, pTbReq->dbFName, &pDbCache); + if (!pDbCache) { + // do not know which vnodes to fetch, fetch vnode list first + SBuildUseDBInput input = {0}; + tstrncpy(input.db, pTbReq->dbFName, tListLen(input.db)); + input.vgVersion = CTG_DEFAULT_INVALID_VERSION; + CTG_ERR_JRET(ctgGetDBVgInfoFromMnode(pCtg, pConn, &input, NULL, tReq)); + } else { + // fetch progress from every vnode + CTG_ERR_JRET(ctgTsmaFetchStreamProgress(tReq, pDbCache->vgCache.vgInfo->vgHash, pOut)); + ctgReleaseVgInfoToCache(pCtg, pDbCache); + pDbCache = NULL; + } + } else { + // no tsmas + if (atomic_sub_fetch_32(&pCtx->fetchNum, 1) == 0) { + TSWAP(pTask->res, pCtx->pResList); + taskDone = true; + } + } + } break; + case TDMT_VND_GET_STREAM_PROGRESS: { + SStreamProgressRsp rsp = {0}; + CTG_ERR_JRET(ctgProcessRspMsg(&rsp, reqType, pMsg->pData, pMsg->len, rspCode, pMsgCtx->target)); + // update progress into res + STableTSMAInfoRsp* pTsmasRsp = pRes->pRes; + SArray* pTsmas = pTsmasRsp->pTsmas; + SStreamProgressRsp* pRsp = &rsp; + int32_t tsmaIdx = pRsp->subFetchIdx / pFetch->vgNum; + STableTSMAInfo* pTsmaInfo = taosArrayGetP(pTsmas, tsmaIdx); + if (pTsmaInfo->rspTs == 0) pTsmaInfo->fillHistoryFinished = true; + pTsmaInfo->rspTs = taosGetTimestampMs(); + pTsmaInfo->delayDuration = TMAX(pRsp->progressDelay, pTsmaInfo->delayDuration); + pTsmaInfo->fillHistoryFinished = pTsmaInfo->fillHistoryFinished && pRsp->fillHisFinished; + qDebug("received stream progress for tsma %s rsp history: %d vnode: %d, delay: %" PRId64, pTsmaInfo->name, + pRsp->fillHisFinished, pRsp->subFetchIdx, pRsp->progressDelay); + + if (atomic_add_fetch_32(&pFetch->finishedSubFetchNum, 1) == pFetch->subFetchNum) { + // subfetch all finished + for (int32_t i = 0; i < taosArrayGetSize(pTsmas); ++i) { + STableTSMAInfo* pInfo = taosArrayGetP(pTsmas, i); + CTG_ERR_JRET(tCloneTbTSMAInfo(pInfo, &pTsma)); + CTG_ERR_JRET(ctgUpdateTbTSMAEnqueue(pCtg, &pTsma, 0, false)); + } + + if (atomic_sub_fetch_32(&pCtx->fetchNum, 1) == 0) { + TSWAP(pTask->res, pCtx->pResList); + taskDone = true; + } + } + } break; + case TDMT_MND_USE_DB: { + SUseDbOutput* pOut = (SUseDbOutput*)pMsgCtx->out; + + switch (pFetch->fetchType) { + case FETCH_TSMA_SOURCE_TB_META: { + SVgroupInfo vgInfo = {0}; + CTG_ERR_JRET(ctgGetVgInfoFromHashValue(pCtg, &pConn->mgmtEps, pOut->dbVgroup, pTbName, &vgInfo)); + + pFetch->vgId = vgInfo.vgId; + CTG_ERR_JRET(ctgGetTbMetaFromVnode(pCtg, pConn, pTbName, &vgInfo, NULL, tReq)); + } break; + case FETCH_TSMA_STREAM_PROGRESS: { + STableTSMAInfoRsp* pTsmas = pRes->pRes; + TSWAP(pOut->dbVgroup->vgHash, pVgHash); + CTG_ERR_JRET(ctgTsmaFetchStreamProgress(tReq, pVgHash, pTsmas)); + } break; + default: + ASSERT(0); + } + } break; + case TDMT_VND_TABLE_META: { + // handle source tb meta + ASSERT(pFetch->fetchType == FETCH_TSMA_SOURCE_TB_META); + STableMetaOutput* pOut = (STableMetaOutput*)pMsgCtx->out; + pFetch->fetchType = FETCH_TB_TSMA; + pFetch->tsmaSourceTbName = *pTbName; + if (CTG_IS_META_NULL(pOut->metaType)) { + ctgTaskError("no tbmeta found when fetching tsma source tb meta: %s.%s", pTbName->dbname, pTbName->tname); + ctgRemoveTbMetaFromCache(pCtg, pTbName, false); + CTG_ERR_JRET(CTG_ERR_CODE_TABLE_NOT_EXIST); + } + if (META_TYPE_BOTH_TABLE == pOut->metaType) { + // rewrite tsma fetch table with it's super table name + sprintf(pFetch->tsmaSourceTbName.tname, "%s", pOut->tbName); + } + CTG_ERR_JRET(ctgGetTbTSMAFromMnode(pCtg, pConn, &pFetch->tsmaSourceTbName, NULL, tReq, TDMT_MND_GET_TABLE_TSMA)); + } break; + default: + ASSERT(0); + } + +_return: + if (pDbCache) { + ctgReleaseVgInfoToCache(pCtg, pDbCache); + } + if (pTsma) { + tFreeTableTSMAInfo(pTsma); + pTsma = NULL; + } + if (pVgHash) { + taosHashCleanup(pVgHash); + } + if (code) { + SMetaRes* pRes = taosArrayGet(pCtx->pResList, pFetch->resIdx); + pRes->code = code; + if (TSDB_CODE_MND_SMA_NOT_EXIST == code) { + code = TSDB_CODE_SUCCESS; + } else { + ctgTaskError("Get tsma for %d.%s.%s faield with err: %s", pTbName->acctId, pTbName->dbname, pTbName->tname, + tstrerror(code)); + } + bool allSubFetchFinished = false; + if (pMsgCtx->reqType == TDMT_VND_GET_STREAM_PROGRESS) { + allSubFetchFinished = atomic_add_fetch_32(&pFetch->finishedSubFetchNum, 1) >= pFetch->subFetchNum; + } + if ((allSubFetchFinished || pFetch->subFetchNum == 0) && 0 == atomic_sub_fetch_32(&pCtx->fetchNum, 1)) { + TSWAP(pTask->res, pCtx->pResList); + taskDone = true; + } + } + if (pTask->res && taskDone) { + ctgHandleTaskEnd(pTask, code); + } + + CTG_RET(code); +} + +int32_t ctgDumpTbTSMARes(SCtgTask* pTask) { + if (pTask->subTask) { + return TSDB_CODE_SUCCESS; + } + + SCtgJob* pJob = pTask->pJob; + pJob->jobRes.pTableTsmas = pTask->res; + return TSDB_CODE_SUCCESS; +} + +int32_t ctgDumpTSMARes(SCtgTask* pTask) { + if (pTask->subTask) { + return TSDB_CODE_SUCCESS; + } + + SCtgJob* pJob = pTask->pJob; + pJob->jobRes.pTsmas = pTask->res; + return TSDB_CODE_SUCCESS; +} int32_t ctgRelaunchGetTbMetaTask(SCtgTask* pTask) { ctgResetTbMetaTask(pTask); @@ -2692,6 +3122,8 @@ SCtgAsyncFps gCtgAsyncFps[] = { {ctgInitGetTbHashsTask, ctgLaunchGetTbHashsTask, ctgHandleGetTbHashsRsp, ctgDumpTbHashsRes, NULL, NULL}, {ctgInitGetTbTagTask, ctgLaunchGetTbTagTask, ctgHandleGetTbTagRsp, ctgDumpTbTagRes, NULL, NULL}, {ctgInitGetViewsTask, ctgLaunchGetViewsTask, ctgHandleGetViewsRsp, ctgDumpViewsRes, NULL, NULL}, + {ctgInitGetTbTSMATask, ctgLaunchGetTbTSMATask, ctgHandleGetTbTSMARsp, ctgDumpTbTSMARes, NULL, NULL}, + {ctgInitGetTSMATask, ctgLaunchGetTSMATask, ctgHandleGetTSMARsp, ctgDumpTSMARes, NULL, NULL}, }; int32_t ctgMakeAsyncRes(SCtgJob* pJob) { diff --git a/source/libs/catalog/src/ctgCache.c b/source/libs/catalog/src/ctgCache.c index f81f9a6954..0554257810 100644 --- a/source/libs/catalog/src/ctgCache.c +++ b/source/libs/catalog/src/ctgCache.c @@ -32,6 +32,8 @@ SCtgOperation gCtgCacheOperation[CTG_OP_MAX] = {{CTG_OP_UPDATE_VGROUP, "update v {CTG_OP_DROP_TB_INDEX, "drop tbIndex", ctgOpDropTbIndex}, {CTG_OP_UPDATE_VIEW_META, "update viewMeta", ctgOpUpdateViewMeta}, {CTG_OP_DROP_VIEW_META, "drop viewMeta", ctgOpDropViewMeta}, + {CTG_OP_UPDATE_TB_TSMA, "update tbTSMA", ctgOpUpdateTbTSMA}, + {CTG_OP_DROP_TB_TSMA, "drop tbTSMA", ctgOpDropTbTSMA}, {CTG_OP_CLEAR_CACHE, "clear cache", ctgOpClearCache}}; SCtgCacheItemInfo gCtgStatItem[CTG_CI_MAX_VALUE] = { @@ -52,6 +54,7 @@ SCtgCacheItemInfo gCtgStatItem[CTG_CI_MAX_VALUE] = { {"TblTag ", CTG_CI_FLAG_LEVEL_DB}, //CTG_CI_TBL_TAG, {"IndexInfo ", CTG_CI_FLAG_LEVEL_DB}, //CTG_CI_INDEX_INFO, {"viewMeta ", CTG_CI_FLAG_LEVEL_DB}, //CTG_CI_VIEW, + {"TblTSMA ", CTG_CI_FLAG_LEVEL_DB}, //CTG_CI_TBL_TSMA {"User ", CTG_CI_FLAG_LEVEL_CLUSTER}, //CTG_CI_USER, {"UDF ", CTG_CI_FLAG_LEVEL_CLUSTER}, //CTG_CI_UDF, {"SvrVer ", CTG_CI_FLAG_LEVEL_CLUSTER} //CTG_CI_SVR_VER, @@ -209,6 +212,17 @@ void ctgReleaseVgMetaToCache(SCatalog *pCtg, SCtgDBCache *dbCache, SCtgTbCache * } } +void ctgReleaseTSMAToCache(SCatalog* pCtg, SCtgDBCache* dbCache, SCtgTSMACache* pCache) { + if (pCache && dbCache) { + CTG_UNLOCK(CTG_READ, &pCache->tsmaLock); + taosHashRelease(dbCache->tsmaCache, pCache); + } + + if (dbCache) { + ctgReleaseDBCache(pCtg, dbCache); + } +} + int32_t ctgAcquireVgInfoFromCache(SCatalog *pCtg, const char *dbFName, SCtgDBCache **pCache) { SCtgDBCache *dbCache = NULL; ctgAcquireDBCache(pCtg, dbFName, &dbCache); @@ -245,7 +259,7 @@ _return: return TSDB_CODE_SUCCESS; } -int32_t ctgAcquireTbMetaFromCache(SCatalog *pCtg, char *dbFName, char *tbName, SCtgDBCache **pDb, SCtgTbCache **pTb) { +int32_t ctgAcquireTbMetaFromCache(SCatalog *pCtg, const char *dbFName, const char *tbName, SCtgDBCache **pDb, SCtgTbCache **pTb) { SCtgDBCache *dbCache = NULL; SCtgTbCache *pCache = NULL; ctgAcquireDBCache(pCtg, dbFName, &dbCache); @@ -489,7 +503,7 @@ _return: return TSDB_CODE_SUCCESS; } -int32_t ctgTbMetaExistInCache(SCatalog *pCtg, char *dbFName, char *tbName, int32_t *exist) { +int32_t ctgTbMetaExistInCache(SCatalog *pCtg, const char *dbFName, const char *tbName, int32_t *exist) { SCtgDBCache *dbCache = NULL; SCtgTbCache *tbCache = NULL; ctgAcquireTbMetaFromCache(pCtg, dbFName, tbName, &dbCache, &tbCache); @@ -1381,6 +1395,13 @@ int32_t ctgAddNewDBCache(SCatalog *pCtg, const char *dbFName, uint64_t dbId) { CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); } + newDBCache.tsmaCache = taosHashInit(gCtgMgmt.cfg.maxTSMACacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), + true, HASH_ENTRY_LOCK); + if (!newDBCache.tsmaCache) { + ctgError("taosHashInit %d tsmaCache failed", gCtgMgmt.cfg.maxTSMACacheNum); + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + code = taosHashPut(pCtg->dbCache, dbFName, strlen(dbFName), &newDBCache, sizeof(SCtgDBCache)); if (code) { if (HASH_NODE_EXIST(code)) { @@ -1394,7 +1415,7 @@ int32_t ctgAddNewDBCache(SCatalog *pCtg, const char *dbFName, uint64_t dbId) { CTG_CACHE_NUM_INC(CTG_CI_DB, 1); - SDbCacheInfo dbCacheInfo = {.dbId = newDBCache.dbId, .vgVersion = -1, .stateTs = 0, .cfgVersion = -1}; + SDbCacheInfo dbCacheInfo = {.dbId = newDBCache.dbId, .vgVersion = -1, .stateTs = 0, .cfgVersion = -1, .tsmaVersion = -1}; tstrncpy(dbCacheInfo.dbFName, dbFName, sizeof(dbCacheInfo.dbFName)); ctgDebug("db added to cache, dbFName:%s, dbId:0x%" PRIx64, dbFName, dbId); @@ -1424,6 +1445,7 @@ int32_t ctgRemoveDBFromCache(SCatalog *pCtg, SCtgDBCache *dbCache, const char *d atomic_store_8(&dbCache->deleted, 1); ctgRemoveStbRent(pCtg, dbCache); ctgRemoveViewRent(pCtg, dbCache); + ctgRemoveTSMARent(pCtg, dbCache); ctgFreeDbCache(dbCache); CTG_UNLOCK(CTG_WRITE, &dbCache->dbLock); @@ -1780,7 +1802,7 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) { bool newAdded = false; SDbCacheInfo dbCacheInfo = { - .dbId = msg->dbId, .vgVersion = dbInfo->vgVersion, .cfgVersion = -1, .numOfTable = dbInfo->numOfTable, .stateTs = dbInfo->stateTs}; + .dbId = msg->dbId, .vgVersion = dbInfo->vgVersion, .cfgVersion = -1, .numOfTable = dbInfo->numOfTable, .stateTs = dbInfo->stateTs, .tsmaVersion = -1}; SCtgDBCache *dbCache = NULL; CTG_ERR_JRET(ctgGetAddDBCache(msg->pCtg, dbFName, msg->dbId, &dbCache)); @@ -1824,6 +1846,7 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) { if (dbCache->cfgCache.cfgInfo) { dbCacheInfo.cfgVersion = dbCache->cfgCache.cfgInfo->cfgVersion; + dbCacheInfo.tsmaVersion = dbCache->tsmaVersion; } vgCache->vgInfo = dbInfo; @@ -1891,6 +1914,7 @@ int32_t ctgOpUpdateDbCfg(SCtgCacheOperation *operation) { } else { cacheInfo.vgVersion = -1; } + cacheInfo.tsmaVersion = dbCache->tsmaVersion; ctgWLockDbCfgInfo(dbCache); @@ -2074,7 +2098,8 @@ int32_t ctgOpDropStbMeta(SCtgCacheOperation *operation) { } tblType = pTbCache->pMeta->tableType; - atomic_sub_fetch_64(&dbCache->dbCacheSize, ctgGetTbMetaCacheSize(pTbCache->pMeta) + ctgGetTbIndexCacheSize(pTbCache->pIndex)); + atomic_sub_fetch_64(&dbCache->dbCacheSize, + ctgGetTbMetaCacheSize(pTbCache->pMeta) + ctgGetTbIndexCacheSize(pTbCache->pIndex)); ctgFreeTbCacheImpl(pTbCache, true); if (taosHashRemove(dbCache->tbCache, msg->stbName, strlen(msg->stbName))) { @@ -2126,7 +2151,8 @@ int32_t ctgOpDropTbMeta(SCtgCacheOperation *operation) { } tblType = pTbCache->pMeta->tableType; - atomic_sub_fetch_64(&dbCache->dbCacheSize, ctgGetTbMetaCacheSize(pTbCache->pMeta) + ctgGetTbIndexCacheSize(pTbCache->pIndex)); + atomic_sub_fetch_64(&dbCache->dbCacheSize, ctgGetTbMetaCacheSize(pTbCache->pMeta) + + ctgGetTbIndexCacheSize(pTbCache->pIndex)); ctgFreeTbCacheImpl(pTbCache, true); if (taosHashRemove(dbCache->tbCache, msg->tbName, strlen(msg->tbName))) { @@ -2554,6 +2580,7 @@ void ctgFreeCacheOperationData(SCtgCacheOperation *op) { case CTG_OP_UPDATE_VG_EPSET: case CTG_OP_DROP_TB_INDEX: case CTG_OP_DROP_VIEW_META: + case CTG_OP_DROP_TB_TSMA: case CTG_OP_CLEAR_CACHE: { taosMemoryFreeClear(op->data); break; @@ -2582,6 +2609,14 @@ void ctgFreeCacheOperationData(SCtgCacheOperation *op) { taosMemoryFreeClear(op->data); break; } + case CTG_OP_UPDATE_TB_TSMA: { + SCtgUpdateTbTSMAMsg *msg = op->data; + if (msg->pTsma) { + tFreeTableTSMAInfo(msg->pTsma); + taosMemoryFreeClear(msg->pTsma); + } + break; + } default: { qError("invalid cache op id:%d", op->opId); break; @@ -2982,20 +3017,21 @@ int32_t ctgRemoveTbMetaFromCache(SCatalog *pCtg, SName *pTableName, bool syncReq CTG_ERR_JRET(ctgReadTbMetaFromCache(pCtg, &tbCtx, &tblMeta)); - if (NULL == tblMeta) { - ctgDebug("table already not in cache, db:%s, tblName:%s", pTableName->dbname, pTableName->tname); - return TSDB_CODE_SUCCESS; - } + if (NULL != tblMeta) { + char dbFName[TSDB_DB_FNAME_LEN]; + tNameGetFullDbName(pTableName, dbFName); - char dbFName[TSDB_DB_FNAME_LEN]; - tNameGetFullDbName(pTableName, dbFName); - - if (TSDB_SUPER_TABLE == tblMeta->tableType) { - CTG_ERR_JRET(ctgDropStbMetaEnqueue(pCtg, dbFName, tbCtx.tbInfo.dbId, pTableName->tname, tblMeta->suid, syncReq)); + if (TSDB_SUPER_TABLE == tblMeta->tableType) { + CTG_ERR_JRET(ctgDropStbMetaEnqueue(pCtg, dbFName, tbCtx.tbInfo.dbId, pTableName->tname, tblMeta->suid, syncReq)); + } else { + CTG_ERR_JRET(ctgDropTbMetaEnqueue(pCtg, dbFName, tbCtx.tbInfo.dbId, pTableName->tname, syncReq)); + } } else { - CTG_ERR_JRET(ctgDropTbMetaEnqueue(pCtg, dbFName, tbCtx.tbInfo.dbId, pTableName->tname, syncReq)); + ctgDebug("table already not in cache, db:%s, tblName:%s", pTableName->dbname, pTableName->tname); } + CTG_ERR_JRET(ctgDropTSMAForTbEnqueue(pCtg, pTableName, syncReq)); + _return: taosMemoryFreeClear(tblMeta); @@ -3136,5 +3172,462 @@ int32_t ctgGetViewsFromCache(SCatalog *pCtg, SRequestConnInfo *pConn, SCtgViewsC return TSDB_CODE_SUCCESS; } +int32_t ctgGetTbTSMAFromCache(SCatalog* pCtg, SCtgTbTSMACtx* pCtx, int32_t dbIdx, int32_t* fetchIdx, int32_t baseResIdx, + SArray* pList) { + int32_t code = 0; + SCtgDBCache * dbCache = NULL; + SCtgTSMACache *pCache = NULL; + char dbFName[TSDB_DB_FNAME_LEN] = {0}; + int32_t flag = CTG_FLAG_UNKNOWN_STB; + uint64_t lastSuid = 0; + STableMeta * pTableMeta = NULL; + SName * pName = taosArrayGet(pList, 0); + int32_t tbNum = taosArrayGetSize(pList); + SCtgTbCache * pTbCache = NULL; + if (IS_SYS_DBNAME(pName->dbname)) { + return TSDB_CODE_SUCCESS; + } + tNameGetFullDbName(pName, dbFName); + // get db cache + CTG_ERR_RET(ctgAcquireDBCache(pCtg, dbFName, &dbCache)); + if (!dbCache) { + ctgDebug("DB %s not in cache", dbFName); + for (int32_t i = 0; i < tbNum; ++i) { + ctgAddTSMAFetch(&pCtx->pFetches, dbIdx, i, fetchIdx, baseResIdx + i, flag, FETCH_TSMA_SOURCE_TB_META, NULL); + taosArrayPush(pCtx->pResList, &(SMetaData){0}); + } + return TSDB_CODE_SUCCESS; + } + + for (int32_t i = 0; i < tbNum; ++i) { + // get tb cache + pName = taosArrayGet(pList, i); + pTbCache = taosHashAcquire(dbCache->tbCache, pName->tname, strlen(pName->tname)); + if (!pTbCache || !pTbCache->pMeta) { + ctgDebug("tb: %s.%s not in cache", dbFName, pName->tname); + ctgAddTSMAFetch(&pCtx->pFetches, dbIdx, i, fetchIdx, baseResIdx + i, flag, FETCH_TSMA_SOURCE_TB_META, NULL); + taosArrayPush(pCtx->pResList, &(SMetaRes){0}); + continue; + } + uint64_t suid = pTbCache->pMeta->suid; + int8_t tbType = pTbCache->pMeta->tableType; + taosHashRelease(dbCache->tbCache, pTbCache); + SName tsmaSourceTbName = *pName; + + // if child table, get stable name + if (tbType == TSDB_CHILD_TABLE) { + char* stbName = taosHashAcquire(dbCache->stbCache, &suid, sizeof(uint64_t)); + if (stbName) { + snprintf(tsmaSourceTbName.tname, TMIN(TSDB_TABLE_NAME_LEN, strlen(stbName) + 1), "%s", stbName); + taosHashRelease(dbCache->stbCache, stbName); + } else { + ctgDebug("stb in db: %s, uid: %" PRId64 " not in cache", dbFName, suid); + ctgAddTSMAFetch(&pCtx->pFetches, dbIdx, i, fetchIdx, baseResIdx + i, flag, FETCH_TSMA_SOURCE_TB_META, NULL); + taosArrayPush(pCtx->pResList, &(SMetaRes){0}); + continue; + } + } + + // get tsma cache + pCache = taosHashAcquire(dbCache->tsmaCache, tsmaSourceTbName.tname, strlen(tsmaSourceTbName.tname)); + if (!pCache || !pCache->pTsmas || pCache->pTsmas->size == 0) { + taosArrayPush(pCtx->pResList, &(SMetaRes){0}); + continue; + } + + CTG_LOCK(CTG_READ, &pCache->tsmaLock); + if (hasOutOfDateTSMACache(pCache->pTsmas)) { + CTG_UNLOCK(CTG_READ, &pCache->tsmaLock); + taosHashRelease(dbCache->tsmaCache, pCache); + ctgDebug("tsma for tb: %s.%s not in cache", tsmaSourceTbName.tname, dbFName); + ctgAddTSMAFetch(&pCtx->pFetches, dbIdx, i, fetchIdx, baseResIdx + i, flag, FETCH_TB_TSMA, &tsmaSourceTbName); + taosArrayPush(pCtx->pResList, &(SMetaRes){0}); + CTG_CACHE_NHIT_INC(CTG_CI_TBL_TSMA, 1); + continue; + } + + CTG_CACHE_HIT_INC(CTG_CI_TBL_TSMA, 1); + + STableTSMAInfoRsp *pRsp = taosMemoryCalloc(1, sizeof(STableTSMAInfoRsp)); + if (!pRsp) { + ctgReleaseTSMAToCache(pCtg, dbCache, pCache); + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + pRsp->pTsmas = taosArrayInit(pCache->pTsmas->size, POINTER_BYTES); + if (!pRsp->pTsmas) { + ctgReleaseTSMAToCache(pCtg, dbCache, pCache); + taosMemoryFreeClear(pRsp); + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + SMetaRes res = {0}; + for (int32_t i = 0; i < pCache->pTsmas->size; ++i) { + STSMACache *pTsmaOut = NULL; + STSMACache *pTsmaCache = taosArrayGetP(pCache->pTsmas, i); + code = tCloneTbTSMAInfo(pTsmaCache, &pTsmaOut); + if (code) { + ctgReleaseTSMAToCache(pCtg, dbCache, pCache); + tFreeTableTSMAInfoRsp(pRsp); + taosMemoryFreeClear(pRsp); + CTG_ERR_RET(code); + } + taosArrayPush(pRsp->pTsmas, &pTsmaOut); + } + res.pRes = pRsp; + taosArrayPush(pCtx->pResList, &res); + CTG_UNLOCK(CTG_READ, &pCache->tsmaLock); + taosHashRelease(dbCache->tsmaCache, pCache); + } + ctgReleaseDBCache(pCtg, dbCache); + CTG_RET(code); +} + +int32_t ctgGetTSMAFromCache(SCatalog* pCtg, SCtgTbTSMACtx* pCtx, SName* pTsmaName) { + char dbFName[TSDB_DB_FNAME_LEN] = {0}; + SCtgDBCache *pDbCache = NULL; + int32_t code = TSDB_CODE_SUCCESS; + SMetaRes res = {0}; + bool found = false; + STSMACache * pTsmaOut = NULL; + + tNameGetFullDbName(pTsmaName, dbFName); + + CTG_ERR_RET(ctgAcquireDBCache(pCtg, dbFName, &pDbCache)); + if (!pDbCache) { + ctgDebug("DB %s not in cache", dbFName); + CTG_RET(code); + } + + void *pIter = taosHashIterate(pDbCache->tsmaCache, NULL); + + while (pIter && !found) { + SCtgTSMACache* pCtgCache = pIter; + CTG_LOCK(CTG_READ, &pCtgCache->tsmaLock); + int32_t size = pCtgCache ? (pCtgCache->pTsmas ? pCtgCache->pTsmas->size : 0) : 0; + for (int32_t i = 0; i < size; ++i) { + STSMACache* pCache = taosArrayGetP(pCtgCache->pTsmas, i); + if (memcmp(pCache->name, pTsmaName->tname, TSDB_TABLE_NAME_LEN) == 0) { + found = true; + CTG_CACHE_NHIT_INC(CTG_CI_TBL_TSMA, 1); + code = tCloneTbTSMAInfo(pCache, &pTsmaOut); + break; + } + } + CTG_UNLOCK(CTG_READ, &pCtgCache->tsmaLock); + pIter = taosHashIterate(pDbCache->tsmaCache, pIter); + } + taosHashCancelIterate(pDbCache->tsmaCache, pIter); + if (found && code == TSDB_CODE_SUCCESS) { + res.pRes = taosMemoryCalloc(1, sizeof(STableTSMAInfoRsp)); + if (!res.pRes) { + tFreeAndClearTableTSMAInfo(pTsmaOut); + CTG_RET(TSDB_CODE_OUT_OF_MEMORY); + } + STableTSMAInfoRsp* pRsp = res.pRes; + pRsp->pTsmas = taosArrayInit(1, POINTER_BYTES); + if (!pRsp->pTsmas) { + tFreeAndClearTableTSMAInfo(pTsmaOut); + CTG_RET(TSDB_CODE_OUT_OF_MEMORY); + } + + taosArrayPush(pRsp->pTsmas, &pTsmaOut); + taosArrayPush(pCtx->pResList, &res); + } + + ctgReleaseDBCache(pCtg, pDbCache); + CTG_RET(code); +} + +int32_t ctgUpdateTbTSMAEnqueue(SCatalog *pCtg, STSMACache **pTsma, int32_t tsmaVersion, bool syncOp) { + int32_t code = 0; + SCtgCacheOperation *op = taosMemoryCalloc(1, sizeof(SCtgCacheOperation)); + op->opId = CTG_OP_UPDATE_TB_TSMA; + op->syncOp = syncOp; + + SCtgUpdateTbTSMAMsg *msg = taosMemoryMalloc(sizeof(SCtgUpdateTbTSMAMsg)); + if (NULL == msg) { + ctgError("malloc %d failed", (int32_t)sizeof(SCtgUpdateTbTSMAMsg)); + taosMemoryFree(op); + CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + } + + msg->pCtg = pCtg; + msg->pTsma = *pTsma; + msg->dbTsmaVersion = tsmaVersion; + msg->dbId = (*pTsma)->dbId; + + op->data = msg; + + CTG_ERR_JRET(ctgEnqueue(pCtg, op)); + + *pTsma = NULL; + return TSDB_CODE_SUCCESS; + +_return: + CTG_RET(code); +} + +int32_t ctgDropTbTSMAEnqueue(SCatalog* pCtg, const STSMACache* pTsma, bool syncOp) { + int32_t code = 0; + SCtgCacheOperation* op = taosMemoryCalloc(1, sizeof(SCtgCacheOperation)); + if (!op) CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + + op->opId = CTG_OP_DROP_TB_TSMA; + op->syncOp = syncOp; + + SCtgDropTbTSMAMsg* msg = taosMemoryCalloc(1, sizeof(SCtgDropTbTSMAMsg)); + if (!msg) { + ctgError("malloc %d failed", (int32_t)sizeof(SCtgDropTbTSMAMsg)); + taosMemoryFree(op); + CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + } + + msg->pCtg = pCtg; + msg->dbId = pTsma->dbId; + msg->tbId = pTsma->suid; + msg->tsmaId = pTsma->tsmaId; + tstrncpy(msg->dbFName, pTsma->dbFName, TSDB_DB_FNAME_LEN); + tstrncpy(msg->tbName, pTsma->tb, TSDB_TABLE_NAME_LEN); + tstrncpy(msg->tsmaName, pTsma->name, TSDB_TABLE_NAME_LEN); + + op->data = msg; + CTG_ERR_JRET(ctgEnqueue(pCtg, op)); + return TSDB_CODE_SUCCESS; +_return: + CTG_RET(code); +} + +static SCtgCacheOperation* createDropAllTbTsmaCtgCacheOp(SCatalog* pCtg, const STSMACache* pCache, bool syncOp) { + SCtgCacheOperation* pOp = taosMemoryCalloc(1, sizeof(SCtgCacheOperation)); + if (!pOp) return NULL; + + SCtgDropTbTSMAMsg* pMsg = taosMemoryCalloc(1, sizeof(SCtgDropTbTSMAMsg)); + if (!pMsg) { + taosMemoryFree(pOp); + return NULL; + } + pOp->opId = CTG_OP_DROP_TB_TSMA; + pOp->syncOp = syncOp; + pMsg->pCtg = pCtg; + pMsg->dbId = pCache->dbId; + pMsg->tbId = pCache->suid; + pMsg->tsmaId = pCache->tsmaId; + pMsg->dropAllForTb = true; + tstrncpy(pMsg->tsmaName, pCache->name, TSDB_TABLE_NAME_LEN); + tstrncpy(pMsg->dbFName, pCache->dbFName, TSDB_DB_FNAME_LEN); + tstrncpy(pMsg->tbName, pCache->tb, TSDB_TABLE_NAME_LEN); + pOp->data = pMsg; + return pOp; +} + +int32_t ctgDropTSMAForTbEnqueue(SCatalog *pCtg, SName *pName, bool syncOp) { + ctgDebug("drop tsma meta for tb: %s.%s", pName->dbname, pName->tname); + int32_t code = 0; + SCtgDBCache* pDbCache = NULL; + SCtgCacheOperation* pOp = NULL; + char dbFName[TSDB_DB_FNAME_LEN]; + tNameGetFullDbName(pName, dbFName); + CTG_ERR_JRET(ctgGetDBCache(pCtg, dbFName, &pDbCache)); + if (NULL == pDbCache || !pDbCache->tsmaCache) { + goto _return; + } + + SCtgTSMACache *pCtgCache = taosHashGet(pDbCache->tsmaCache, pName->tname, strlen(pName->tname)); + if (!pCtgCache || !pCtgCache->pTsmas || pCtgCache->pTsmas->size == 0) { + goto _return; + } + + CTG_LOCK(CTG_READ, &pCtgCache->tsmaLock); + STSMACache *pCache = taosArrayGetP(pCtgCache->pTsmas, 0); + pOp = createDropAllTbTsmaCtgCacheOp(pCtg, pCache, syncOp); + if (!pOp) { + code = TSDB_CODE_OUT_OF_MEMORY; + CTG_UNLOCK(CTG_READ, &pCtgCache->tsmaLock); + goto _return; + } + CTG_UNLOCK(CTG_READ, &pCtgCache->tsmaLock); + CTG_ERR_JRET(ctgEnqueue(pCtg, pOp)); + + return TSDB_CODE_SUCCESS; + +_return: + if (pOp) { + taosMemoryFree(pOp->data); + taosMemoryFree(pOp); + } + CTG_RET(code); +} + +int32_t ctgWriteTbTSMAToCache(SCatalog *pCtg, SCtgDBCache *dbCache, char *dbFName, char *tbName, + STSMACache **ppTsmaCache) { + if (NULL == dbCache->tsmaCache) { + ctgError("db is dropping, dbId:0x%" PRIx64, dbCache->dbId); + CTG_ERR_RET(TSDB_CODE_CTG_DB_DROPPED); + } + + STSMACache *pTsmaCache = *ppTsmaCache; + int32_t code = TSDB_CODE_SUCCESS; + + SCtgTSMACache* pCache = taosHashGet(dbCache->tsmaCache, tbName, strlen(tbName)); + if (!pCache) { + SCtgTSMACache cache = {0}; + cache.pTsmas = taosArrayInit(4, sizeof(POINTER_BYTES)); + if (!cache.pTsmas) CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + taosArrayPush(cache.pTsmas, &pTsmaCache); + if (taosHashPut(dbCache->tsmaCache, tbName, strlen(tbName), &cache, sizeof(cache))) { + ctgError("taosHashPut new tsmacache for tb: %s.%s failed", dbFName, tbName); + CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + } + atomic_add_fetch_64(&dbCache->dbCacheSize, strlen(tbName) + sizeof(STSMACache) + ctgGetTbTSMACacheSize(pTsmaCache)); + CTG_DB_NUM_INC(CTG_CI_TBL_TSMA); + ctgDebug("tb %s tsma updated to cache, name: %s", tbName, pTsmaCache->name); + CTG_ERR_JRET(ctgUpdateRentTSMAVersion(pCtg, dbFName, pTsmaCache)); + *ppTsmaCache = NULL; + goto _return; + } + + CTG_LOCK(CTG_WRITE, &pCache->tsmaLock); + + if (pCache->pTsmas) { + uint64_t cacheSize = 0; + for (int32_t i = 0; i < pCache->pTsmas->size; ++i) { + STableTSMAInfo* pInfo = taosArrayGetP(pCache->pTsmas, i); + if (pInfo->tsmaId == pTsmaCache->tsmaId) { + ctgDebug("tsma: %s removed from cache, history from %d to %d, reqTs from %" PRId64 " to %" PRId64 + "rspTs from %" PRId64 " to %" PRId64 " delay from %" PRId64 " to %" PRId64, + pInfo->name, pInfo->fillHistoryFinished, pTsmaCache->fillHistoryFinished, pInfo->reqTs, + pTsmaCache->reqTs, pInfo->rspTs, pTsmaCache->rspTs, pInfo->delayDuration, pTsmaCache->delayDuration); + cacheSize = ctgGetTbTSMACacheSize(pInfo); + taosArrayRemove(pCache->pTsmas, i); + atomic_sub_fetch_64(&dbCache->dbCacheSize, cacheSize); + tFreeTableTSMAInfo(pInfo); + taosMemoryFreeClear(pInfo); + break; + } + } + } else { + pCache->pTsmas = taosArrayInit(4, sizeof(POINTER_BYTES)); + if (!pCache->pTsmas) { + CTG_UNLOCK(CTG_WRITE, &pCache->tsmaLock); + CTG_ERR_JRET(TSDB_CODE_OUT_OF_MEMORY); + } + } + // push the new cache + taosArrayPush(pCache->pTsmas, &pTsmaCache); + *ppTsmaCache = NULL; + + atomic_add_fetch_64(&dbCache->dbCacheSize, ctgGetTbTSMACacheSize(pTsmaCache)); + CTG_ERR_RET(ctgUpdateRentTSMAVersion(pCtg, dbFName, pTsmaCache)); + CTG_UNLOCK(CTG_WRITE, &pCache->tsmaLock); + ctgDebug("table %s tsma updated to cache, tsma: %s", tbName, pTsmaCache->name); +_return: + CTG_RET(code); +} + +int32_t ctgOpDropTbTSMA(SCtgCacheOperation *operation) { + int32_t code = 0; + SCtgDropTbTSMAMsg * msg = operation->data; + SCatalog *pCtg = msg->pCtg; + SCtgDBCache *dbCache = NULL; + + if (pCtg->stopUpdate) { + goto _return; + } + + CTG_ERR_JRET(ctgGetDBCache(pCtg, msg->dbFName, &dbCache)); + if (NULL == dbCache || !dbCache->tsmaCache || (msg->dbId != dbCache->dbId && msg->dbId != 0)) { + goto _return; + } + + SCtgTSMACache* pCtgCache = taosHashGet(dbCache->tsmaCache, msg->tbName, strlen(msg->tbName)); + if (!pCtgCache || !pCtgCache->pTsmas || pCtgCache->pTsmas->size == 0) { + goto _return; + } + + uint64_t cacheSize = 0; + STSMACache *pCache = NULL; + if (msg->dropAllForTb) { + CTG_LOCK(CTG_WRITE, &pCtgCache->tsmaLock); + for (int32_t i = 0; i < pCtgCache->pTsmas->size; ++i) { + pCache = taosArrayGetP(pCtgCache->pTsmas, i); + cacheSize += ctgGetTbTSMACacheSize(pCache); + ctgMetaRentRemove(&msg->pCtg->tsmaRent, pCache->tsmaId, ctgTSMAVersionSearchCompare, ctgTSMAVersionSearchCompare); + CTG_DB_NUM_DEC(CTG_CI_TBL_TSMA); + } + taosArrayDestroyP(pCtgCache->pTsmas, tFreeAndClearTableTSMAInfo); + pCtgCache->pTsmas = NULL; + ctgDebug("all tsmas for table dropped: %s.%s", msg->dbFName, msg->tbName); + taosHashRemove(dbCache->tsmaCache, msg->tbName, TSDB_TABLE_NAME_LEN); + CTG_UNLOCK(CTG_WRITE, &pCtgCache->tsmaLock); + } else { + CTG_LOCK(CTG_WRITE, &pCtgCache->tsmaLock); + pCache = taosArrayGetP(pCtgCache->pTsmas, 0); + if (msg->tbId != 0 && pCache->suid != msg->tbId) { + // table id mismatch, skip drops + CTG_UNLOCK(CTG_WRITE, &pCtgCache->tsmaLock); + goto _return; + } + for (int32_t i = 0; i < pCtgCache->pTsmas->size; ++i) { + pCache = taosArrayGetP(pCtgCache->pTsmas, i); + if (pCache->tsmaId != msg->tsmaId) { + continue; + } + cacheSize = ctgGetTbTSMACacheSize(pCache); + ctgMetaRentRemove(&msg->pCtg->tsmaRent, pCache->tsmaId, ctgTSMAVersionSearchCompare, ctgTSMAVersionSearchCompare); + taosArrayRemove(pCtgCache->pTsmas, i); + tFreeAndClearTableTSMAInfo(pCache); + CTG_DB_NUM_DEC(CTG_CI_TBL_TSMA); + break; + } + CTG_UNLOCK(CTG_WRITE, &pCtgCache->tsmaLock); + } + atomic_sub_fetch_64(&dbCache->dbCacheSize, cacheSize); + +_return: + + taosMemoryFreeClear(msg); + CTG_RET(code); +} + +int32_t ctgOpUpdateTbTSMA(SCtgCacheOperation *operation) { + int32_t code = 0; + SCtgUpdateTbTSMAMsg *msg = operation->data; + SCatalog * pCtg = msg->pCtg; + STableTSMAInfo * pTsmaInfo = msg->pTsma; + SCtgDBCache * dbCache = NULL; + + if (pCtg->stopUpdate) { + goto _return; + } + + CTG_ERR_JRET(ctgGetAddDBCache(pCtg, pTsmaInfo->dbFName, pTsmaInfo->dbId, &dbCache)); + CTG_ERR_JRET(ctgWriteTbTSMAToCache(pCtg, dbCache, pTsmaInfo->dbFName, pTsmaInfo->tb, &pTsmaInfo)); + if (dbCache && msg->dbTsmaVersion > 0) { + dbCache->tsmaVersion = msg->dbTsmaVersion; + SDbCacheInfo cacheInfo = {0}; + cacheInfo.dbId = dbCache->dbId; + if (dbCache->cfgCache.cfgInfo) { + cacheInfo.cfgVersion = dbCache->cfgCache.cfgInfo->cfgVersion; + tstrncpy(cacheInfo.dbFName, dbCache->cfgCache.cfgInfo->db, TSDB_DB_FNAME_LEN); + } + if (dbCache->vgCache.vgInfo) { + cacheInfo.vgVersion = dbCache->vgCache.vgInfo->vgVersion; + cacheInfo.numOfTable = dbCache->vgCache.vgInfo->numOfTable; + cacheInfo.stateTs = dbCache->vgCache.vgInfo->stateTs; + } + cacheInfo.tsmaVersion = dbCache->tsmaVersion; + CTG_ERR_JRET(ctgMetaRentUpdate(&msg->pCtg->dbRent, &cacheInfo, cacheInfo.dbId, sizeof(SDbCacheInfo), + ctgDbCacheInfoSortCompare, ctgDbCacheInfoSearchCompare)); + } + +_return: + + if (pTsmaInfo) { + tFreeTableTSMAInfo(pTsmaInfo); + taosMemoryFreeClear(pTsmaInfo); + } + + taosMemoryFreeClear(msg); + CTG_RET(code); +} diff --git a/source/libs/catalog/src/ctgRemote.c b/source/libs/catalog/src/ctgRemote.c index f374c7fe6e..bbd9b39f6c 100644 --- a/source/libs/catalog/src/ctgRemote.c +++ b/source/libs/catalog/src/ctgRemote.c @@ -337,6 +337,35 @@ int32_t ctgProcessRspMsg(void* out, int32_t reqType, char* msg, int32_t msgSize, qDebug("Got view-meta from mnode, viewFName:%s", target); break; } + case TDMT_MND_GET_TSMA: + case TDMT_MND_GET_TABLE_TSMA: { + if (TSDB_CODE_SUCCESS != rspCode) { + if (TSDB_CODE_MND_SMA_NOT_EXIST != rspCode) { + qError("error rsp for get table tsma, error:%s, tbFName:%s", tstrerror(rspCode), target); + } + CTG_ERR_RET(rspCode); + } + + code = queryProcessMsgRsp[TMSG_INDEX(reqType)](out, msg, msgSize); + if (code) { + qError("Process get table tsma rsp failed, error:%s, tbFName:%s", tstrerror(code), target); + CTG_ERR_RET(code); + } + + qDebug("Got table tsma from mnode, tbFName:%s", target); + break; + } + case TDMT_VND_GET_STREAM_PROGRESS: { + if (TSDB_CODE_SUCCESS != rspCode) { + CTG_ERR_RET(rspCode); + } + code = queryProcessMsgRsp[TMSG_INDEX(reqType)](out, msg, msgSize); + if (code) { + qError("Process get stream progress rsp failed, err: %s, tbFName: %s", tstrerror(code), target); + CTG_ERR_RET(code); + } + break; + } default: if (TSDB_CODE_SUCCESS != rspCode) { qError("Got error rsp, error:%s", tstrerror(rspCode)); @@ -528,10 +557,20 @@ int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgT SCtgTbMetasCtx* ctx = (SCtgTbMetasCtx*)pTask->taskCtx; SCtgFetch* fetch = taosArrayGet(ctx->pFetchs, tReq->msgIdx); pName = ctgGetFetchName(ctx->pNames, fetch); + } else if (CTG_TASK_GET_TB_TSMA == pTask->type){ + SCtgTbTSMACtx* pCtx = pTask->taskCtx; + SCtgTSMAFetch* pFetch = taosArrayGet(pCtx->pFetches, tReq->msgIdx); + STablesReq* pTbReq = taosArrayGet(pCtx->pNames, pFetch->dbIdx); + pName = taosArrayGet(pTbReq->pTables, pFetch->tbIdx); } else { SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx; pName = ctx->pName; } + } else if (TDMT_VND_GET_STREAM_PROGRESS == msgType) { + SCtgTbTSMACtx* pCtx = pTask->taskCtx; + SCtgTSMAFetch* pFetch = taosArrayGet(pCtx->pFetches, tReq->msgIdx); + STablesReq* pTbReq = taosArrayGet(pCtx->pNames, pFetch->dbIdx); + pName = taosArrayGet(pTbReq->pTables, pFetch->tbIdx); } else { ctgError("invalid vnode msgType %d", msgType); CTG_ERR_JRET(TSDB_CODE_APP_ERROR); @@ -578,10 +617,20 @@ int32_t ctgAddBatch(SCatalog* pCtg, int32_t vgId, SRequestConnInfo* pConn, SCtgT SCtgTbMetasCtx* ctx = (SCtgTbMetasCtx*)pTask->taskCtx; SCtgFetch* fetch = taosArrayGet(ctx->pFetchs, tReq->msgIdx); pName = ctgGetFetchName(ctx->pNames, fetch); + } else if (CTG_TASK_GET_TB_TSMA == pTask->type){ + SCtgTbTSMACtx* pCtx = pTask->taskCtx; + SCtgTSMAFetch* pFetch = taosArrayGet(pCtx->pFetches, tReq->msgIdx); + STablesReq* pTbReq = taosArrayGet(pCtx->pNames, pFetch->dbIdx); + pName = taosArrayGet(pTbReq->pTables, pFetch->tbIdx); } else { SCtgTbMetaCtx* ctx = (SCtgTbMetaCtx*)pTask->taskCtx; pName = ctx->pName; } + } else if (TDMT_VND_GET_STREAM_PROGRESS == msgType) { + SCtgTbTSMACtx* pCtx = pTask->taskCtx; + SCtgTSMAFetch* pFetch = taosArrayGet(pCtx->pFetches, tReq->msgIdx); + STablesReq* pTbReq = taosArrayGet(pCtx->pNames, pFetch->dbIdx); + pName = taosArrayGet(pTbReq->pTables, pFetch->tbIdx); } else { ctgError("invalid vnode msgType %d", msgType); CTG_ERR_JRET(TSDB_CODE_APP_ERROR); @@ -1104,7 +1153,7 @@ int32_t ctgGetUserDbAuthFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const return TSDB_CODE_SUCCESS; } -int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo* pConn, char* dbFName, char* tbName, +int32_t ctgGetTbMetaFromMnodeImpl(SCatalog* pCtg, SRequestConnInfo* pConn, const char* dbFName, const char* tbName, STableMetaOutput* out, SCtgTaskReq* tReq) { SCtgTask* pTask = tReq ? tReq->pTask : NULL; SBuildTableInput bInput = {.vgId = 0, .dbFName = dbFName, .tbName = tbName}; @@ -1463,4 +1512,120 @@ int32_t ctgGetViewInfoFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, SName* return TSDB_CODE_SUCCESS; } +int32_t ctgGetTbTSMAFromMnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* name, STableTSMAInfoRsp* out, + SCtgTaskReq* tReq, int32_t reqType) { + char* msg = NULL; + int32_t msgLen = 0; + SCtgTask* pTask = tReq ? tReq->pTask : NULL; + void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemoryMalloc : (MallocType)rpcMallocCont; + char tbFName[TSDB_TABLE_FNAME_LEN]; + tNameExtractFullName(name, tbFName); + ctgDebug("try to get tb index from mnode, tbFName:%s", tbFName); + + int32_t code = queryBuildMsg[TMSG_INDEX(reqType)]((void*)tbFName, &msg, 0, &msgLen, mallocFp); + if (code) { + ctgError("Build get index msg failed, code:%s, tbFName:%s", tstrerror(code), tbFName); + CTG_ERR_RET(code); + } + + if (pTask) { + void* pOut = taosMemoryCalloc(1, sizeof(STableTSMAInfoRsp)); + if (NULL == pOut) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + + CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx), reqType, pOut, (char*)tbFName)); + +#if CTG_BATCH_FETCH + CTG_RET(ctgAddBatch(pCtg, 0, pConn, tReq, reqType, msg, msgLen)); +#else + SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); + if (NULL == pTaskId) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + taosArrayPush(pTaskId, &pTask->taskId); + + CTG_RET(ctgAsyncSendMsg(pCtg, pConn, pTask->pJob, pTaskId, -1, NULL, NULL, 0, reqType, msg, msgLen)); +#endif + } + + SRpcMsg rpcMsg = { + .msgType = reqType, + .pCont = msg, + .contLen = msgLen, + }; + + SRpcMsg rpcRsp = {0}; + rpcSendRecv(pConn->pTrans, &pConn->mgmtEps, &rpcMsg, &rpcRsp); + + CTG_ERR_RET(ctgProcessRspMsg(out, reqType, rpcRsp.pCont, rpcRsp.contLen, rpcRsp.code, (char*)tbFName)); + + rpcFreeCont(rpcRsp.pCont); + + return TSDB_CODE_SUCCESS; +} + +int32_t ctgGetStreamProgressFromVnode(SCatalog* pCtg, SRequestConnInfo* pConn, const SName* pTbName, + SVgroupInfo* vgroupInfo, SStreamProgressRsp* out, SCtgTaskReq* tReq, + void* bInput) { + char* msg = NULL; + int32_t msgLen = 0; + int32_t reqType = TDMT_VND_GET_STREAM_PROGRESS; + char tbFName[TSDB_TABLE_FNAME_LEN]; + tNameExtractFullName(pTbName, tbFName); + SCtgTask* pTask = tReq ? tReq->pTask : NULL; + void* (*mallocFp)(int64_t) = pTask ? (MallocType)taosMemoryMalloc : (MallocType)rpcMallocCont; + + SEp* pEp = &vgroupInfo->epSet.eps[vgroupInfo->epSet.inUse]; + ctgDebug("try to get stream progress from vnode, vgId:%d, ep num:%d, ep %s:%d, target:%s", vgroupInfo->vgId, + vgroupInfo->epSet.numOfEps, pEp->fqdn, pEp->port, tbFName); + + int32_t code = queryBuildMsg[TMSG_INDEX(reqType)](bInput, &msg, 0, &msgLen, mallocFp); + if (code) { + ctgError("Build get stream progress failed, code:%s, tbFName:%s", tstrerror(code), tbFName); + CTG_ERR_RET(code); + } + + if (pTask) { + SStreamProgressRsp* pOut = taosMemoryCalloc(1, sizeof(SStreamProgressRsp)); + if (!pOut) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + CTG_ERR_RET(ctgUpdateMsgCtx(CTG_GET_TASK_MSGCTX(pTask, tReq->msgIdx), reqType, pOut, (char*)tbFName)); + + SRequestConnInfo vConn = {.pTrans = pConn->pTrans, + .requestId = pConn->requestId, + .requestObjRefId = pConn->requestObjRefId, + .mgmtEps = vgroupInfo->epSet}; +#if CTG_BATCH_FETCH + CTG_RET(ctgAddBatch(pCtg, vgroupInfo->vgId, &vConn, tReq, reqType, msg, msgLen)); +#else + char dbFName[TSDB_DB_FNAME_LEN]; + tNameGetFullDbName(pTbName, dbFName); + SArray* pTaskId = taosArrayInit(1, sizeof(int32_t)); + if (NULL == pTaskId) { + CTG_ERR_RET(TSDB_CODE_OUT_OF_MEMORY); + } + taosArrayPush(pTaskId, &pTask->taskId); + + CTG_RET( + ctgAsyncSendMsg(pCtg, &vConn, pTask->pJob, pTaskId, -1, NULL, dbFName, vgroupInfo->vgId, reqType, msg, msgLen)); +#endif + } + + SRpcMsg rpcMsg = { + .msgType = reqType, + .pCont = msg, + .contLen = msgLen, + }; + + SRpcMsg rpcRsp = {0}; + rpcSendRecv(pConn->pTrans, &vgroupInfo->epSet, &rpcMsg, &rpcRsp); + + CTG_ERR_RET(ctgProcessRspMsg(out, reqType, rpcRsp.pCont, rpcRsp.contLen, rpcRsp.code, (char*)tbFName)); + + rpcFreeCont(rpcRsp.pCont); + + return TSDB_CODE_SUCCESS; +} diff --git a/source/libs/catalog/src/ctgRent.c b/source/libs/catalog/src/ctgRent.c index a19eb19c02..67b85a7825 100755 --- a/source/libs/catalog/src/ctgRent.c +++ b/source/libs/catalog/src/ctgRent.c @@ -259,6 +259,24 @@ void ctgRemoveViewRent(SCatalog *pCtg, SCtgDBCache *dbCache) { } } +void ctgRemoveTSMARent(SCatalog *pCtg, SCtgDBCache *dbCache) { + if (!dbCache->tsmaCache) return; + + void* pIter = taosHashIterate(dbCache->tsmaCache, NULL); + while (pIter) { + SCtgTSMACache* pCtgCache = pIter; + CTG_LOCK(CTG_READ, &pCtgCache->tsmaLock); + int32_t size = (pCtgCache && pCtgCache->pTsmas) ? pCtgCache->pTsmas->size : 0; + for (int32_t i = 0; i < size; ++i) { + STSMACache* pCache = taosArrayGetP(pCtgCache->pTsmas, i); + if (TSDB_CODE_SUCCESS == ctgMetaRentRemove(&pCtg->tsmaRent, pCache->tsmaId, ctgTSMAVersionSortCompare, ctgTSMAVersionSearchCompare)) { + ctgDebug("tsma removed from rent, viewId: %" PRIx64 " name: %s.%s.%s", pCache->tsmaId, pCache->dbFName, pCache->tb, pCache->name); + } + } + CTG_UNLOCK(CTG_READ, &pCtgCache->tsmaLock); + pIter = taosHashIterate(dbCache->tsmaCache, pIter); + } +} int32_t ctgUpdateRentStbVersion(SCatalog *pCtg, char *dbFName, char *tbName, uint64_t dbId, uint64_t suid, SCtgTbCache *pCache) { @@ -300,3 +318,17 @@ int32_t ctgUpdateRentViewVersion(SCatalog *pCtg, char *dbFName, char *viewName, return TSDB_CODE_SUCCESS; } + +int32_t ctgUpdateRentTSMAVersion(SCatalog *pCtg, char *dbFName, const STSMACache *pCache) { + const STableTSMAInfo *pTsmaInfo = pCache; + STSMAVersion tsmaRent = {.dbId = pTsmaInfo->dbId, .tsmaId = pTsmaInfo->tsmaId, .version = pTsmaInfo->version}; + tstrncpy(tsmaRent.name, pTsmaInfo->name, TSDB_TABLE_NAME_LEN); + tstrncpy(tsmaRent.dbFName, dbFName, TSDB_DB_FNAME_LEN); + tstrncpy(tsmaRent.tbName, pTsmaInfo->tb, TSDB_TABLE_NAME_LEN); + CTG_ERR_RET(ctgMetaRentUpdate(&pCtg->tsmaRent, &tsmaRent, tsmaRent.tsmaId, sizeof(STSMAVersion), + ctgTSMAVersionSortCompare, ctgTSMAVersionSearchCompare)); + ctgDebug("db %s, 0x%" PRIx64 " tsma %s, 0x%" PRIx64 "version %d updated to tsmaRent", dbFName, tsmaRent.dbId, + pTsmaInfo->name, pTsmaInfo->tsmaId, pTsmaInfo->version); + + return TSDB_CODE_SUCCESS; +} diff --git a/source/libs/catalog/src/ctgUtil.c b/source/libs/catalog/src/ctgUtil.c index cacdfcb8d6..bc266d9201 100644 --- a/source/libs/catalog/src/ctgUtil.c +++ b/source/libs/catalog/src/ctgUtil.c @@ -190,6 +190,12 @@ void ctgFreeSMetaData(SMetaData* pData) { taosArrayDestroy(pData->pView); pData->pView = NULL; + taosArrayDestroy(pData->pTableTsmas); + pData->pTableTsmas = NULL; + + taosArrayDestroy(pData->pTsmas); + pData->pTsmas = NULL; + taosMemoryFreeClear(pData->pSvrVer); } @@ -297,6 +303,31 @@ void ctgFreeTbCache(SCtgDBCache* dbCache) { dbCache->tbCache = NULL; } +void ctgFreeTSMACacheImpl(SCtgTSMACache* pCache, bool lock) { + if (lock) { + CTG_LOCK(CTG_WRITE, &pCache->tsmaLock); + } + if (pCache->pTsmas) { + taosArrayDestroyP(pCache->pTsmas, tFreeAndClearTableTSMAInfo); + pCache->pTsmas = NULL; + } + if (lock) { + CTG_UNLOCK(CTG_WRITE, &pCache->tsmaLock); + } +} + +void ctgFreeTSMACache(SCtgDBCache* dbCache) { + if (!dbCache) return; + + SCtgTSMACache* pCache = taosHashIterate(dbCache->tsmaCache, NULL); + while (pCache) { + ctgFreeTSMACacheImpl(pCache, false); + pCache = taosHashIterate(dbCache->tsmaCache, pCache); + } + taosHashCleanup(dbCache->tsmaCache); + dbCache->tsmaCache = NULL; +} + void ctgFreeVgInfoCache(SCtgDBCache* dbCache) { freeVgInfo(dbCache->vgCache.vgInfo); } void ctgFreeCfgInfoCache(SCtgDBCache* dbCache) { freeDbCfgInfo(dbCache->cfgCache.cfgInfo); } @@ -310,6 +341,7 @@ void ctgFreeDbCache(SCtgDBCache* dbCache) { ctgFreeStbMetaCache(dbCache); ctgFreeTbCache(dbCache); ctgFreeViewCache(dbCache); + ctgFreeTSMACache(dbCache); } void ctgFreeInstDbCache(SHashObj* pDbCache) { @@ -353,6 +385,7 @@ void ctgFreeHandleImpl(SCatalog* pCtg) { ctgFreeMetaRent(&pCtg->dbRent); ctgFreeMetaRent(&pCtg->stbRent); ctgFreeMetaRent(&pCtg->viewRent); + ctgFreeMetaRent(&pCtg->tsmaRent); ctgFreeInstDbCache(pCtg->dbCache); ctgFreeInstUserCache(pCtg->userCache); @@ -382,6 +415,7 @@ void ctgFreeHandle(SCatalog* pCtg) { ctgFreeMetaRent(&pCtg->dbRent); ctgFreeMetaRent(&pCtg->stbRent); ctgFreeMetaRent(&pCtg->viewRent); + ctgFreeMetaRent(&pCtg->tsmaRent); ctgFreeInstDbCache(pCtg->dbCache); ctgFreeInstUserCache(pCtg->userCache); @@ -410,7 +444,8 @@ void ctgClearHandleMeta(SCatalog* pCtg, int64_t *pClearedSize, int64_t *pCleardN } taosHashRemove(dbCache->tbCache, key, len); - cacheSize = len + sizeof(SCtgTbCache) + ctgGetTbMetaCacheSize(pCache->pMeta) + ctgGetTbIndexCacheSize(pCache->pIndex); + cacheSize = + len + sizeof(SCtgTbCache) + ctgGetTbMetaCacheSize(pCache->pMeta) + ctgGetTbIndexCacheSize(pCache->pIndex); atomic_sub_fetch_64(&dbCache->dbCacheSize, cacheSize); *pClearedSize += cacheSize; (*pCleardNum)++; @@ -468,6 +503,7 @@ void ctgClearHandle(SCatalog* pCtg) { ctgFreeMetaRent(&pCtg->dbRent); ctgFreeMetaRent(&pCtg->stbRent); ctgFreeMetaRent(&pCtg->viewRent); + ctgFreeMetaRent(&pCtg->tsmaRent); ctgFreeInstDbCache(pCtg->dbCache); ctgFreeInstUserCache(pCtg->userCache); @@ -475,6 +511,7 @@ void ctgClearHandle(SCatalog* pCtg) { ctgMetaRentInit(&pCtg->dbRent, gCtgMgmt.cfg.dbRentSec, CTG_RENT_DB, sizeof(SDbCacheInfo)); ctgMetaRentInit(&pCtg->stbRent, gCtgMgmt.cfg.stbRentSec, CTG_RENT_STABLE, sizeof(SSTableVersion)); ctgMetaRentInit(&pCtg->viewRent, gCtgMgmt.cfg.viewRentSec, CTG_RENT_VIEW, sizeof(SViewVersion)); + ctgMetaRentInit(&pCtg->tsmaRent, gCtgMgmt.cfg.tsmaRentSec, CTG_RENT_TSMA, sizeof(STSMAVersion)); pCtg->dbCache = taosHashInit(gCtgMgmt.cfg.maxDBCacheNum, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_ENTRY_LOCK); @@ -592,6 +629,20 @@ void ctgFreeMsgCtx(SCtgMsgCtx* pCtx) { } break; } + case TDMT_MND_GET_TSMA: + case TDMT_MND_GET_TABLE_TSMA: { + if (pCtx->out) { + tFreeTableTSMAInfoRsp(pCtx->out); + taosMemoryFreeClear(pCtx->out); + } + break; + } + case TDMT_VND_GET_STREAM_PROGRESS: { + if (pCtx->out) { + taosMemoryFreeClear(pCtx->out); + } + break; + } default: qError("invalid reqType %d", pCtx->reqType); break; @@ -663,6 +714,20 @@ void ctgFreeViewMetaRes(void* res) { } } +void ctgFreeTbTSMARes(void* res) { + if (!res) { + return; + } + + SMetaRes* pRes = res; + if (pRes->pRes) { + STableTSMAInfoRsp * pTsmaRsp = pRes->pRes; + tFreeTableTSMAInfoRsp(pTsmaRsp); + taosMemoryFree(pTsmaRsp); + pRes->pRes = NULL; + } +} + void ctgFreeJsonTagVal(void* val) { if (NULL == val) { return; @@ -760,6 +825,16 @@ void ctgFreeTaskRes(CTG_TASK_TYPE type, void** pRes) { *pRes = NULL; // no need to free it break; } + case CTG_TASK_GET_TSMA: + case CTG_TASK_GET_TB_TSMA: { + SArray* pArr = (SArray*)*pRes; + int32_t num = taosArrayGetSize(pArr); + for (int32_t i = 0; i < num; ++i) { + ctgFreeTbTSMARes(taosArrayGet(pArr, i)); + } + *pRes = NULL; + break; + } default: qError("invalid task type %d", type); break; @@ -922,7 +997,16 @@ void ctgFreeTaskCtx(SCtgTask* pTask) { taosMemoryFreeClear(pTask->taskCtx); break; - } + } + case CTG_TASK_GET_TSMA: + case CTG_TASK_GET_TB_TSMA: { + SCtgTbTSMACtx* pTsmaCtx = pTask->taskCtx; + taosArrayDestroyEx(pTsmaCtx->pResList, ctgFreeTbTSMARes); + taosArrayDestroy(pTsmaCtx->pFetches); + taosArrayDestroyEx(pTask->msgCtxs, (FDelete)ctgFreeMsgCtx); + taosMemoryFreeClear(pTask->taskCtx); + break; + } default: qError("invalid task type %d", pTask->type); break; @@ -1328,6 +1412,15 @@ int32_t ctgViewVersionSearchCompare(const void* key1, const void* key2) { } } +int32_t ctgTSMAVersionSearchCompare(const void* key1, const void* key2) { + if (*(uint64_t*)key1 < ((STSMAVersion*)key2)->tsmaId) { + return -1; + } else if (*(uint64_t*)key1 > ((STSMAVersion*)key2)->tsmaId) { + return 1; + } else { + return 0; + } +} int32_t ctgStbVersionSortCompare(const void* key1, const void* key2) { if (((SSTableVersion*)key1)->suid < ((SSTableVersion*)key2)->suid) { @@ -1359,6 +1452,15 @@ int32_t ctgViewVersionSortCompare(const void* key1, const void* key2) { } } +int32_t ctgTSMAVersionSortCompare(const void* key1, const void* key2) { + if (((STSMAVersion*)key1)->tsmaId < ((STSMAVersion*)key2)->tsmaId) { + return -1; + } else if (((STSMAVersion*)key1)->tsmaId > ((STSMAVersion*)key2)->tsmaId) { + return 1; + } else { + return 0; + } +} int32_t ctgMakeVgArray(SDBVgInfo* dbInfo) { if (NULL == dbInfo) { @@ -1657,6 +1759,10 @@ static void ctgFreeViewMeta(void* p) { taosMemoryFree(pMeta); } +void ctgFreeTbTSMAInfo(void* p) { + tFreeTableTSMAInfoRsp(((SMetaRes*)p)->pRes); + taosMemoryFree(((SMetaRes*)p)->pRes); +} int32_t ctgChkSetTbAuthRes(SCatalog* pCtg, SCtgAuthReq* req, SCtgAuthRsp* res) { int32_t code = 0; @@ -1990,6 +2096,8 @@ void ctgDestroySMetaData(SMetaData* pData) { taosArrayDestroyEx(pData->pTableCfg, ctgFreeTableCfg); taosArrayDestroyEx(pData->pDnodeList, ctgFreeDnodeList); taosArrayDestroyEx(pData->pView, ctgFreeViewMeta); + taosArrayDestroyEx(pData->pTableTsmas, ctgFreeTbTSMAInfo); + taosArrayDestroyEx(pData->pTsmas, ctgFreeTbTSMAInfo); taosMemoryFreeClear(pData->pSvrVer); } @@ -2287,5 +2395,56 @@ int32_t dupViewMetaFromRsp(SViewMetaRsp* pRsp, SViewMeta* pViewMeta) { return TSDB_CODE_SUCCESS; } +uint64_t ctgGetTbTSMACacheSize(STableTSMAInfo* pTsmaInfo) { + if (!pTsmaInfo) return 0; + uint64_t size = sizeof(STableTSMAInfo); + if (pTsmaInfo->pFuncs) size += sizeof(STableTSMAFuncInfo) * pTsmaInfo->pFuncs->size; + if (pTsmaInfo->pTags) size += sizeof(SSchema) * pTsmaInfo->pTags->size; + if (pTsmaInfo->pUsedCols) size += sizeof(SSchema) * pTsmaInfo->pUsedCols->size; + return size; +} +bool hasOutOfDateTSMACache(SArray* pTsmas) { + if (!pTsmas || pTsmas->size == 0) { + return false; + } + for (int32_t i = 0; i < pTsmas->size; ++i) { + STSMACache* pTsmaInfo = taosArrayGetP(pTsmas, i); + if (isCtgTSMACacheOutOfDate(pTsmaInfo)) return true; + } + return false; +} +bool isCtgTSMACacheOutOfDate(STSMACache* pTsmaCache) { + int64_t now = taosGetTimestampMs(); + bool ret = !pTsmaCache->fillHistoryFinished || + (tsMaxTsmaCalcDelay * 1000 - pTsmaCache->delayDuration) < (now - pTsmaCache->reqTs); + if (ret) { + qDebug("tsma %s.%s in cache has been out of date, history finished: %d, remain valid after: %" PRId64 + " passed: %" PRId64, + pTsmaCache->dbFName, pTsmaCache->name, pTsmaCache->fillHistoryFinished, + tsMaxTsmaCalcDelay * 1000 - pTsmaCache->delayDuration, now - pTsmaCache->reqTs); + } + return ret; +} + +int32_t ctgAddTSMAFetch(SArray** pFetchs, int32_t dbIdx, int32_t tbIdx, int32_t* fetchIdx, int32_t resIdx, int32_t flag, + CTG_TSMA_FETCH_TYPE fetchType, const SName* sourceTbName) { + if (NULL == (*pFetchs)) { + *pFetchs = taosArrayInit(CTG_DEFAULT_FETCH_NUM, sizeof(SCtgTSMAFetch)); + } + + SCtgTSMAFetch fetch = {0}; + fetch.dbIdx = dbIdx; + fetch.tbIdx = tbIdx; + fetch.fetchIdx = (*fetchIdx)++; + fetch.resIdx = resIdx; + + fetch.flag = flag; + fetch.fetchType = fetchType; + if (sourceTbName) fetch.tsmaSourceTbName = *sourceTbName; + + taosArrayPush(*pFetchs, &fetch); + + return TSDB_CODE_SUCCESS; +} diff --git a/source/libs/executor/src/aggregateoperator.c b/source/libs/executor/src/aggregateoperator.c index 715c354873..2429fcff79 100644 --- a/source/libs/executor/src/aggregateoperator.c +++ b/source/libs/executor/src/aggregateoperator.c @@ -47,6 +47,7 @@ typedef struct SAggOperatorInfo { bool groupKeyOptimized; bool hasValidBlock; SSDataBlock* pNewGroupBlock; + bool hasCountFunc; } SAggOperatorInfo; static void destroyAggOperatorInfo(void* param); @@ -111,6 +112,7 @@ SOperatorInfo* createAggregateOperatorInfo(SOperatorInfo* downstream, SAggPhysiN pInfo->groupId = UINT64_MAX; pInfo->binfo.inputTsOrder = pAggNode->node.inputTsOrder; pInfo->binfo.outputTsOrder = pAggNode->node.outputTsOrder; + pInfo->hasCountFunc = pAggNode->hasCountLikeFunc; setOperatorInfo(pOperator, "TableAggregate", QUERY_NODE_PHYSICAL_PLAN_HASH_AGG, !pAggNode->node.forceCreateNonBlockingOptr, OP_NOT_OPENED, pInfo, pTaskInfo); @@ -317,18 +319,8 @@ static int32_t createDataBlockForEmptyInput(SOperatorInfo* pOperator, SSDataBloc } SqlFunctionCtx* pCtx = pOperator->exprSupp.pCtx; - bool hasCountFunc = false; - for (int32_t i = 0; i < pOperator->exprSupp.numOfExprs; ++i) { - const char* pName = pCtx[i].pExpr->pExpr->_function.functionName; - if ((strcmp(pName, "count") == 0) || (strcmp(pName, "hyperloglog") == 0) || - (strcmp(pName, "_hyperloglog_partial") == 0) || (strcmp(pName, "_hyperloglog_merge") == 0)) { - hasCountFunc = true; - break; - } - } - - if (!hasCountFunc) { + if (!pAggInfo->hasCountFunc) { return TSDB_CODE_SUCCESS; } diff --git a/source/libs/executor/src/mergeoperator.c b/source/libs/executor/src/mergeoperator.c index c1a51898bc..b1fba588ab 100755 --- a/source/libs/executor/src/mergeoperator.c +++ b/source/libs/executor/src/mergeoperator.c @@ -282,6 +282,7 @@ SSDataBlock* doNonSortMerge(SOperatorInfo* pOperator) { idx = NON_SORT_NEXT_SRC(pNonSortMerge, pNonSortMerge->lastSourceIdx); continue; } + pNonSortMerge->lastSourceIdx = idx - 1; break; } diff --git a/source/libs/executor/src/sysscanoperator.c b/source/libs/executor/src/sysscanoperator.c index 25b8dcfe6e..659ab79eb4 100644 --- a/source/libs/executor/src/sysscanoperator.c +++ b/source/libs/executor/src/sysscanoperator.c @@ -1408,6 +1408,11 @@ static SSDataBlock* sysTableBuildUserTables(SOperatorInfo* pOperator) { T_LONG_JMP(pTaskInfo->env, terrno); } + if (isTsmaResSTb(mr.me.name)) { + pAPI->metaReaderFn.clearReader(&mr); + continue; + } + // number of columns pColInfoData = taosArrayGet(p->pDataBlock, 3); colDataSetVal(pColInfoData, numOfRows, (char*)&mr.me.stbEntry.schemaRow.nCols, false); diff --git a/source/libs/function/inc/builtins.h b/source/libs/function/inc/builtins.h index af33c3ffa2..8c07a9d530 100644 --- a/source/libs/function/inc/builtins.h +++ b/source/libs/function/inc/builtins.h @@ -47,6 +47,7 @@ typedef struct SBuiltinFuncDefinition { const char* pPartialFunc; const char* pMiddleFunc; const char* pMergeFunc; + const char* pStateFunc; FCreateMergeFuncParameters createMergeParaFuc; FEstimateReturnRows estimateReturnRowsFunc; } SBuiltinFuncDefinition; diff --git a/source/libs/function/inc/functionMgtInt.h b/source/libs/function/inc/functionMgtInt.h index abbd2fa27a..a3f97af5d9 100644 --- a/source/libs/function/inc/functionMgtInt.h +++ b/source/libs/function/inc/functionMgtInt.h @@ -55,6 +55,8 @@ extern "C" { #define FUNC_MGT_SKIP_SCAN_CHECK_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(26) #define FUNC_MGT_IGNORE_NULL_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(27) #define FUNC_MGT_PRIMARY_KEY_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(28) +#define FUNC_MGT_TSMA_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(29) +#define FUNC_MGT_COUNT_LIKE_FUNC FUNC_MGT_FUNC_CLASSIFICATION_MASK(30) // funcs that should also return 0 when no rows found #define FUNC_MGT_TEST_MASK(val, mask) (((val) & (mask)) != 0) diff --git a/source/libs/function/src/builtins.c b/source/libs/function/src/builtins.c index 583255bd20..394eecd542 100644 --- a/source/libs/function/src/builtins.c +++ b/source/libs/function/src/builtins.c @@ -460,6 +460,24 @@ static int32_t translateAvgMerge(SFunctionNode* pFunc, char* pErrBuf, int32_t le return TSDB_CODE_SUCCESS; } +static int32_t translateAvgState(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + + uint8_t paraType = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type; + if (!IS_NUMERIC_TYPE(paraType) && !IS_NULL_TYPE(paraType)) + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + + pFunc->node.resType = (SDataType){.bytes = getAvgInfoSize() + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateAvgStateMerge(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + + pFunc->node.resType = (SDataType){.bytes = getAvgInfoSize() + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}; + return TSDB_CODE_SUCCESS; +} + static int32_t translateStddevPartial(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { if (1 != LIST_LENGTH(pFunc->pParameterList)) { return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); @@ -489,6 +507,35 @@ static int32_t translateStddevMerge(SFunctionNode* pFunc, char* pErrBuf, int32_t return TSDB_CODE_SUCCESS; } +static int32_t translateStddevState(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t paraType = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type; + if (!IS_NUMERIC_TYPE(paraType) && !IS_NULL_TYPE(paraType)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + pFunc->node.resType = (SDataType){.bytes = getStddevInfoSize() + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateStddevStateMerge(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t paraType = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type; + if (TSDB_DATA_TYPE_BINARY != paraType) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + pFunc->node.resType = (SDataType){.bytes = getStddevInfoSize() + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}; + + return TSDB_CODE_SUCCESS; +} + static int32_t translateWduration(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { // pseudo column do not need to check parameters pFunc->node.resType = (SDataType){.bytes = tDataTypes[TSDB_DATA_TYPE_BIGINT].bytes, .type = TSDB_DATA_TYPE_BIGINT, @@ -835,6 +882,31 @@ static int32_t translateSpreadMerge(SFunctionNode* pFunc, char* pErrBuf, int32_t return translateSpreadImpl(pFunc, pErrBuf, len, false); } +static int32_t translateSpreadState(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t paraType = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type; + if (!IS_NUMERIC_TYPE(paraType) && !IS_TIMESTAMP_TYPE(paraType)) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + pFunc->node.resType = (SDataType){.bytes = getSpreadInfoSize() + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateSpreadStateMerge(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + uint8_t paraType = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type; + if (paraType != TSDB_DATA_TYPE_BINARY) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + pFunc->node.resType = (SDataType){.bytes = getSpreadInfoSize() + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}; + return TSDB_CODE_SUCCESS; +} + static int32_t translateElapsed(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { int32_t numOfParams = LIST_LENGTH(pFunc->pParameterList); if (1 != numOfParams && 2 != numOfParams) { @@ -1318,6 +1390,24 @@ static int32_t translateHLLMerge(SFunctionNode* pFunc, char* pErrBuf, int32_t le return translateHLLImpl(pFunc, pErrBuf, len, false); } +static int32_t translateHLLState(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + return translateHLLPartial(pFunc, pErrBuf, len); +} + +static int32_t translateHLLStateMerge(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + if (getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type != TSDB_DATA_TYPE_BINARY) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + pFunc->node.resType = + (SDataType){.bytes = getHistogramInfoSize() + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}; + return TSDB_CODE_SUCCESS; +} + static bool validateStateOper(const SValueNode* pVal) { if (TSDB_DATA_TYPE_BINARY != pVal->node.resType.type) { return false; @@ -1805,6 +1895,28 @@ static int32_t translateFirstLastMerge(SFunctionNode* pFunc, char* pErrBuf, int3 return translateFirstLastImpl(pFunc, pErrBuf, len, false); } +static int32_t translateFirstLastState(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + SNode* pPara = nodesListGetNode(pFunc->pParameterList, 0); + int32_t paraBytes = getSDataTypeFromNode(pPara)->bytes; + + int32_t pkBytes = (pFunc->hasPk) ? pFunc->pkBytes : 0; + pFunc->node.resType = + (SDataType){.bytes = getFirstLastInfoSize(paraBytes, pkBytes) + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_BINARY}; + return TSDB_CODE_SUCCESS; +} + +static int32_t translateFirstLastStateMerge(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + SNode* pPara = nodesListGetNode(pFunc->pParameterList, 0); + int32_t paraBytes = getSDataTypeFromNode(pPara)->bytes; + uint8_t paraType = getSDataTypeFromNode(pPara)->type; + if (paraType != TSDB_DATA_TYPE_BINARY) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + pFunc->node.resType = (SDataType){.bytes = paraBytes, .type = TSDB_DATA_TYPE_BINARY}; + return TSDB_CODE_SUCCESS; +} + static int32_t translateUniqueMode(SFunctionNode* pFunc, char* pErrBuf, int32_t len, bool isUnique) { if (1 != LIST_LENGTH(pFunc->pParameterList)) { return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); @@ -2395,12 +2507,26 @@ static int32_t translateTableCountPseudoColumn(SFunctionNode* pFunc, char* pErrB return TSDB_CODE_SUCCESS; } +static int32_t translateMd5(SFunctionNode* pFunc, char* pErrBuf, int32_t len) { + if (1 != LIST_LENGTH(pFunc->pParameterList)) { + return invaildFuncParaNumErrMsg(pErrBuf, len, pFunc->functionName); + } + + uint8_t para1Type = getSDataTypeFromNode(nodesListGetNode(pFunc->pParameterList, 0))->type; + if (para1Type != TSDB_DATA_TYPE_VARCHAR) { + return invaildFuncParaTypeErrMsg(pErrBuf, len, pFunc->functionName); + } + + pFunc->node.resType = (SDataType){.bytes = MD5_OUTPUT_LEN, .type = TSDB_DATA_TYPE_VARCHAR}; + return TSDB_CODE_SUCCESS; +} + // clang-format off const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "count", .type = FUNCTION_TYPE_COUNT, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED | FUNC_MGT_IGNORE_NULL_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED | FUNC_MGT_IGNORE_NULL_FUNC | FUNC_MGT_TSMA_FUNC | FUNC_MGT_COUNT_LIKE_FUNC, .translateFunc = translateCount, .dataRequiredFunc = countDataRequired, .getEnvFunc = getCountFuncEnv, @@ -2413,12 +2539,13 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { #endif .combineFunc = combineFunction, .pPartialFunc = "count", + .pStateFunc = "count", .pMergeFunc = "sum" }, { .name = "sum", .type = FUNCTION_TYPE_SUM, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED | FUNC_MGT_IGNORE_NULL_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED | FUNC_MGT_IGNORE_NULL_FUNC | FUNC_MGT_TSMA_FUNC, .translateFunc = translateSum, .dataRequiredFunc = statisDataRequired, .getEnvFunc = getSumFuncEnv, @@ -2431,12 +2558,13 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { #endif .combineFunc = sumCombine, .pPartialFunc = "sum", + .pStateFunc = "sum", .pMergeFunc = "sum" }, { .name = "min", .type = FUNCTION_TYPE_MIN, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED | FUNC_MGT_SELECT_FUNC | FUNC_MGT_IGNORE_NULL_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED | FUNC_MGT_SELECT_FUNC | FUNC_MGT_IGNORE_NULL_FUNC | FUNC_MGT_TSMA_FUNC, .translateFunc = translateInOutNum, .dataRequiredFunc = statisDataRequired, .getEnvFunc = getMinmaxFuncEnv, @@ -2446,12 +2574,13 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .finalizeFunc = minmaxFunctionFinalize, .combineFunc = minCombine, .pPartialFunc = "min", + .pStateFunc = "min", .pMergeFunc = "min" }, { .name = "max", .type = FUNCTION_TYPE_MAX, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED | FUNC_MGT_SELECT_FUNC | FUNC_MGT_IGNORE_NULL_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED | FUNC_MGT_SELECT_FUNC | FUNC_MGT_IGNORE_NULL_FUNC | FUNC_MGT_TSMA_FUNC, .translateFunc = translateInOutNum, .dataRequiredFunc = statisDataRequired, .getEnvFunc = getMinmaxFuncEnv, @@ -2461,12 +2590,13 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .finalizeFunc = minmaxFunctionFinalize, .combineFunc = maxCombine, .pPartialFunc = "max", + .pStateFunc = "max", .pMergeFunc = "max" }, { .name = "stddev", .type = FUNCTION_TYPE_STDDEV, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TSMA_FUNC, .translateFunc = translateInNumOutDou, .getEnvFunc = getStddevFuncEnv, .initFunc = stddevFunctionSetup, @@ -2478,6 +2608,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { #endif .combineFunc = stddevCombine, .pPartialFunc = "_stddev_partial", + .pStateFunc = "_stddev_state", .pMergeFunc = "_stddev_merge" }, { @@ -2507,6 +2638,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .invertFunc = stddevInvertFunction, #endif .combineFunc = stddevCombine, + .pPartialFunc = "_stddev_state_merge", + .pMergeFunc = "_stddev_merge", }, { .name = "leastsquares", @@ -2526,7 +2659,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "avg", .type = FUNCTION_TYPE_AVG, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED | FUNC_MGT_IGNORE_NULL_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED | FUNC_MGT_IGNORE_NULL_FUNC | FUNC_MGT_TSMA_FUNC, .translateFunc = translateInNumOutDou, .dataRequiredFunc = statisDataRequired, .getEnvFunc = getAvgFuncEnv, @@ -2540,7 +2673,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .combineFunc = avgCombine, .pPartialFunc = "_avg_partial", .pMiddleFunc = "_avg_middle", - .pMergeFunc = "_avg_merge" + .pMergeFunc = "_avg_merge", + .pStateFunc = "_avg_state", }, { .name = "_avg_partial", @@ -2570,6 +2704,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .invertFunc = avgInvertFunction, #endif .combineFunc = avgCombine, + .pPartialFunc = "_avg_state_merge", + .pMergeFunc = "_avg_merge", }, { .name = "percentile", @@ -2668,7 +2804,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "spread", .type = FUNCTION_TYPE_SPREAD, - .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED | FUNC_MGT_TSMA_FUNC, .translateFunc = translateSpread, .dataRequiredFunc = statisDataRequired, .getEnvFunc = getSpreadFuncEnv, @@ -2681,6 +2817,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { #endif .combineFunc = spreadCombine, .pPartialFunc = "_spread_partial", + .pStateFunc = "_spread_state", .pMergeFunc = "_spread_merge" }, { @@ -2712,6 +2849,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .invertFunc = NULL, #endif .combineFunc = spreadCombine, + .pPartialFunc = "_spread_state_merge", + .pMergeFunc = "_spread_merge", }, { .name = "elapsed", @@ -2885,7 +3024,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .name = "first", .type = FUNCTION_TYPE_FIRST, .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC | - FUNC_MGT_KEEP_ORDER_FUNC | FUNC_MGT_FORBID_SYSTABLE_FUNC | FUNC_MGT_IGNORE_NULL_FUNC | FUNC_MGT_PRIMARY_KEY_FUNC, + FUNC_MGT_KEEP_ORDER_FUNC | FUNC_MGT_FORBID_SYSTABLE_FUNC | FUNC_MGT_IGNORE_NULL_FUNC | FUNC_MGT_PRIMARY_KEY_FUNC | FUNC_MGT_TSMA_FUNC, .translateFunc = translateFirstLast, .dynDataRequiredFunc = firstDynDataReq, .getEnvFunc = getFirstLastFuncEnv, @@ -2894,6 +3033,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .sprocessFunc = firstLastScalarFunction, .finalizeFunc = firstLastFinalize, .pPartialFunc = "_first_partial", + .pStateFunc = "_first_state", .pMergeFunc = "_first_merge", .combineFunc = firstCombine, }, @@ -2921,12 +3061,14 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .processFunc = firstFunctionMerge, .finalizeFunc = firstLastFinalize, .combineFunc = firstCombine, + .pPartialFunc = "_first_state_merge", + .pMergeFunc = "_first_merge", }, { .name = "last", .type = FUNCTION_TYPE_LAST, .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC | - FUNC_MGT_KEEP_ORDER_FUNC | FUNC_MGT_FORBID_SYSTABLE_FUNC | FUNC_MGT_IGNORE_NULL_FUNC | FUNC_MGT_PRIMARY_KEY_FUNC, + FUNC_MGT_KEEP_ORDER_FUNC | FUNC_MGT_FORBID_SYSTABLE_FUNC | FUNC_MGT_IGNORE_NULL_FUNC | FUNC_MGT_PRIMARY_KEY_FUNC | FUNC_MGT_TSMA_FUNC, .translateFunc = translateFirstLast, .dynDataRequiredFunc = lastDynDataReq, .getEnvFunc = getFirstLastFuncEnv, @@ -2935,6 +3077,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .sprocessFunc = firstLastScalarFunction, .finalizeFunc = firstLastFinalize, .pPartialFunc = "_last_partial", + .pStateFunc = "_last_state", .pMergeFunc = "_last_merge", .combineFunc = lastCombine, }, @@ -2962,6 +3105,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .processFunc = lastFunctionMerge, .finalizeFunc = firstLastFinalize, .combineFunc = lastCombine, + .pPartialFunc = "_last_state_merge", + .pMergeFunc = "_last_merge", }, { .name = "twa", @@ -3024,7 +3169,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { { .name = "hyperloglog", .type = FUNCTION_TYPE_HYPERLOGLOG, - .classification = FUNC_MGT_AGG_FUNC, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_COUNT_LIKE_FUNC | FUNC_MGT_TSMA_FUNC, .translateFunc = translateHLL, .getEnvFunc = getHLLFuncEnv, .initFunc = functionSetup, @@ -3036,6 +3181,7 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { #endif .combineFunc = hllCombine, .pPartialFunc = "_hyperloglog_partial", + .pStateFunc = "_hyperloglog_state", .pMergeFunc = "_hyperloglog_merge" }, { @@ -3065,6 +3211,8 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .invertFunc = NULL, #endif .combineFunc = hllCombine, + .pPartialFunc = "_hyperloglog_state_merge", + .pMergeFunc = "_hyperloglog_merge", }, { .name = "diff", @@ -3824,7 +3972,153 @@ const SBuiltinFuncDefinition funcMgtBuiltins[] = { .initFunc = NULL, .sprocessFunc = qPseudoTagFunction, .finalizeFunc = NULL - } + }, + { + .name = "_stddev_state", + .type = FUNCTION_TYPE_STDDEV_STATE, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TSMA_FUNC, + .translateFunc = translateStddevState, + .getEnvFunc = getStddevFuncEnv, + .initFunc = stddevFunctionSetup, + .processFunc = stddevFunction, + .finalizeFunc = stddevPartialFinalize, + .pPartialFunc = "_stddev_partial", + .pMergeFunc = "_stddev_state_merge", + }, + { + .name = "_stddev_state_merge", + .type = FUNCTION_TYPE_STDDEV_STATE_MERGE, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TSMA_FUNC, + .translateFunc = translateStddevStateMerge, + .getEnvFunc = getStddevFuncEnv, + .initFunc = stddevFunctionSetup, + .processFunc = stddevFunctionMerge, + .finalizeFunc = stddevPartialFinalize, + }, + { + .name = "_avg_state", + .type = FUNCTION_TYPE_AVG_STATE, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TSMA_FUNC, + .translateFunc = translateAvgState, + .getEnvFunc = getAvgFuncEnv, + .initFunc = avgFunctionSetup, + .processFunc = avgFunction, + .finalizeFunc = avgPartialFinalize, + .pPartialFunc = "_avg_partial", + .pMergeFunc = "_avg_state_merge" + }, + { + .name = "_avg_state_merge", + .type = FUNCTION_TYPE_AVG_STATE_MERGE, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TSMA_FUNC, + .translateFunc = translateAvgStateMerge, + .getEnvFunc = getAvgFuncEnv, + .initFunc = avgFunctionSetup, + .processFunc = avgFunctionMerge, + .finalizeFunc = avgPartialFinalize, + }, + { + .name = "_spread_state", + .type = FUNCTION_TYPE_SPREAD_STATE, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SPECIAL_DATA_REQUIRED | FUNC_MGT_TSMA_FUNC, + .translateFunc = translateSpreadState, + .getEnvFunc = getSpreadFuncEnv, + .initFunc = spreadFunctionSetup, + .processFunc = spreadFunction, + .finalizeFunc = spreadPartialFinalize, + .pPartialFunc = "_spread_partial", + .pMergeFunc = "_spread_state_merge" + }, + { + .name = "_spread_state_merge", + .type = FUNCTION_TYPE_SPREAD_STATE_MERGE, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_TSMA_FUNC, + .translateFunc = translateSpreadStateMerge, + .getEnvFunc = getSpreadFuncEnv, + .initFunc = spreadFunctionSetup, + .processFunc = spreadFunctionMerge, + .finalizeFunc = spreadPartialFinalize, + }, + { + .name = "_first_state", + .type = FUNCTION_TYPE_FIRST_STATE, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC | + FUNC_MGT_KEEP_ORDER_FUNC | FUNC_MGT_FORBID_SYSTABLE_FUNC | FUNC_MGT_TSMA_FUNC | FUNC_MGT_PRIMARY_KEY_FUNC, + .translateFunc = translateFirstLastState, + .getEnvFunc = getFirstLastFuncEnv, + .initFunc = functionSetup, + .processFunc = firstFunction, + .finalizeFunc = firstLastPartialFinalize, + .pPartialFunc = "_first_partial", + .pMergeFunc = "_first_state_merge" + }, + { + .name = "_first_state_merge", + .type = FUNCTION_TYPE_FIRST_STATE_MERGE, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC | + FUNC_MGT_KEEP_ORDER_FUNC | FUNC_MGT_FORBID_SYSTABLE_FUNC | FUNC_MGT_TSMA_FUNC | FUNC_MGT_PRIMARY_KEY_FUNC, + .translateFunc = translateFirstLastStateMerge, + .getEnvFunc = getFirstLastFuncEnv, + .initFunc = functionSetup, + .processFunc = firstFunctionMerge, + .finalizeFunc = firstLastPartialFinalize, + }, + { + .name = "_last_state", + .type = FUNCTION_TYPE_LAST_STATE, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC | + FUNC_MGT_KEEP_ORDER_FUNC | FUNC_MGT_FORBID_SYSTABLE_FUNC | FUNC_MGT_TSMA_FUNC | FUNC_MGT_PRIMARY_KEY_FUNC, + .translateFunc = translateFirstLastState, + .getEnvFunc = getFirstLastFuncEnv, + .initFunc = functionSetup, + .processFunc = lastFunction, + .finalizeFunc = firstLastPartialFinalize, + .pPartialFunc = "_last_partial", + .pMergeFunc = "_last_state_merge" + }, + { + .name = "_last_state_merge", + .type = FUNCTION_TYPE_LAST_STATE_MERGE, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_SELECT_FUNC | FUNC_MGT_MULTI_RES_FUNC | FUNC_MGT_IMPLICIT_TS_FUNC | + FUNC_MGT_KEEP_ORDER_FUNC | FUNC_MGT_FORBID_SYSTABLE_FUNC | FUNC_MGT_TSMA_FUNC | FUNC_MGT_PRIMARY_KEY_FUNC, + .translateFunc = translateFirstLastStateMerge, + .getEnvFunc = getFirstLastFuncEnv, + .initFunc = functionSetup, + .processFunc = lastFunctionMerge, + .finalizeFunc = firstLastPartialFinalize, + }, + { + .name = "_hyperloglog_state", + .type = FUNCTION_TYPE_HYPERLOGLOG_STATE, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_COUNT_LIKE_FUNC | FUNC_MGT_TSMA_FUNC, + .translateFunc = translateHLLState, + .getEnvFunc = getHLLFuncEnv, + .initFunc = functionSetup, + .processFunc = hllFunction, + .finalizeFunc = hllPartialFinalize, + .pPartialFunc = "_hyperloglog_partial", + .pMergeFunc = "_hyperloglog_state_merge", + }, + { + .name = "_hyperloglog_state_merge", + .type = FUNCTION_TYPE_HYPERLOGLOG_STATE_MERGE, + .classification = FUNC_MGT_AGG_FUNC | FUNC_MGT_COUNT_LIKE_FUNC | FUNC_MGT_TSMA_FUNC, + .translateFunc = translateHLLStateMerge, + .getEnvFunc = getHLLFuncEnv, + .initFunc = functionSetup, + .processFunc = hllFunctionMerge, + .finalizeFunc = hllPartialFinalize, + }, + { + .name = "md5", + .type = FUNCTION_TYPE_MD5, + .classification = FUNC_MGT_SCALAR_FUNC, + .translateFunc = translateMd5, + .getEnvFunc = NULL, + .initFunc = NULL, + .sprocessFunc = md5Function, + .finalizeFunc = NULL + }, }; // clang-format on diff --git a/source/libs/function/src/builtinsimpl.c b/source/libs/function/src/builtinsimpl.c index 36365abafb..56f2ccd630 100644 --- a/source/libs/function/src/builtinsimpl.c +++ b/source/libs/function/src/builtinsimpl.c @@ -867,6 +867,12 @@ int32_t sumFunction(SqlFunctionCtx* pCtx) { } _sum_over: + if (numOfElem == 0) { + if (tsCountAlwaysReturnValue && pCtx->pExpr->pExpr->_function.pFunctNode->hasOriginalFunc && + fmIsCountLikeFunc(pCtx->pExpr->pExpr->_function.pFunctNode->originalFuncId)) { + numOfElem = 1; + } + } // data in the check operation are all null, not output SET_VAL(GET_RES_INFO(pCtx), numOfElem, 1); return TSDB_CODE_SUCCESS; @@ -1448,6 +1454,12 @@ static void stddevTransferInfo(SStddevRes* pInput, SStddevRes* pOutput) { int32_t stddevFunctionMerge(SqlFunctionCtx* pCtx) { SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pCol = pInput->pData[0]; + + if (IS_NULL_TYPE(pCol->info.type)) { + SET_VAL(GET_RES_INFO(pCtx), 0, 1); + return TSDB_CODE_SUCCESS; + } + if (pCol->info.type != TSDB_DATA_TYPE_BINARY) { return TSDB_CODE_FUNC_FUNTION_PARA_TYPE; } @@ -1455,6 +1467,7 @@ int32_t stddevFunctionMerge(SqlFunctionCtx* pCtx) { SStddevRes* pInfo = GET_ROWCELL_INTERBUF(GET_RES_INFO(pCtx)); for (int32_t i = pInput->startRowIndex; i < pInput->startRowIndex + pInput->numOfRows; ++i) { + if (colDataIsNull_s(pCol, i)) continue; char* data = colDataGetData(pCol, i); SStddevRes* pInputInfo = (SStddevRes*)varDataVal(data); stddevTransferInfo(pInputInfo, pInfo); @@ -2846,6 +2859,12 @@ static int32_t firstLastTransferInfo(SqlFunctionCtx* pCtx, SFirstLastRes* pInput static int32_t firstLastFunctionMergeImpl(SqlFunctionCtx* pCtx, bool isFirstQuery) { SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pCol = pInput->pData[0]; + + if (IS_NULL_TYPE(pCol->info.type)) { + SET_VAL(GET_RES_INFO(pCtx), 0, 1); + return TSDB_CODE_SUCCESS; + } + if (pCol->info.type != TSDB_DATA_TYPE_BINARY) { return TSDB_CODE_FUNC_FUNTION_PARA_TYPE; } @@ -3852,6 +3871,12 @@ static void spreadTransferInfo(SSpreadInfo* pInput, SSpreadInfo* pOutput) { int32_t spreadFunctionMerge(SqlFunctionCtx* pCtx) { SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pCol = pInput->pData[0]; + + if (IS_NULL_TYPE(pCol->info.type)) { + SET_VAL(GET_RES_INFO(pCtx), 0, 1); + return TSDB_CODE_SUCCESS; + } + if (pCol->info.type != TSDB_DATA_TYPE_BINARY) { return TSDB_CODE_FUNC_FUNTION_PARA_TYPE; } @@ -3860,6 +3885,7 @@ int32_t spreadFunctionMerge(SqlFunctionCtx* pCtx) { int32_t start = pInput->startRowIndex; for (int32_t i = start; i < start + pInput->numOfRows; ++i) { + if(colDataIsNull_s(pCol, i)) continue; char* data = colDataGetData(pCol, i); SSpreadInfo* pInputInfo = (SSpreadInfo*)varDataVal(data); if (pInputInfo->hasResult) { @@ -4588,6 +4614,11 @@ int32_t hllFunctionMerge(SqlFunctionCtx* pCtx) { SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pCol = pInput->pData[0]; + if (IS_NULL_TYPE(pCol->info.type)) { + SET_VAL(GET_RES_INFO(pCtx), 0, 1); + return TSDB_CODE_SUCCESS; + } + if (pCol->info.type != TSDB_DATA_TYPE_BINARY) { return TSDB_CODE_SUCCESS; } @@ -4597,6 +4628,7 @@ int32_t hllFunctionMerge(SqlFunctionCtx* pCtx) { int32_t start = pInput->startRowIndex; for (int32_t i = start; i < start + pInput->numOfRows; ++i) { + if (colDataIsNull_s(pCol, i)) continue; char* data = colDataGetData(pCol, i); SHLLInfo* pInputInfo = (SHLLInfo*)varDataVal(data); hllTransferInfo(pInputInfo, pInfo); diff --git a/source/libs/function/src/detail/tavgfunction.c b/source/libs/function/src/detail/tavgfunction.c index 6bcbd1c3a7..66ed092f76 100644 --- a/source/libs/function/src/detail/tavgfunction.c +++ b/source/libs/function/src/detail/tavgfunction.c @@ -705,6 +705,12 @@ static void avgTransferInfo(SAvgRes* pInput, SAvgRes* pOutput) { int32_t avgFunctionMerge(SqlFunctionCtx* pCtx) { SInputColumnInfoData* pInput = &pCtx->input; SColumnInfoData* pCol = pInput->pData[0]; + + if (IS_NULL_TYPE(pCol->info.type)) { + SET_VAL(GET_RES_INFO(pCtx), 0, 1); + return TSDB_CODE_SUCCESS; + } + if (pCol->info.type != TSDB_DATA_TYPE_BINARY) { return TSDB_CODE_FUNC_FUNTION_PARA_TYPE; } @@ -714,6 +720,7 @@ int32_t avgFunctionMerge(SqlFunctionCtx* pCtx) { int32_t start = pInput->startRowIndex; for (int32_t i = start; i < start + pInput->numOfRows; ++i) { + if(colDataIsNull_s(pCol, i)) continue; char* data = colDataGetData(pCol, i); SAvgRes* pInputInfo = (SAvgRes*)varDataVal(data); avgTransferInfo(pInputInfo, pInfo); diff --git a/source/libs/function/src/functionMgt.c b/source/libs/function/src/functionMgt.c index 6f4949cf26..1e12595b28 100644 --- a/source/libs/function/src/functionMgt.c +++ b/source/libs/function/src/functionMgt.c @@ -413,6 +413,8 @@ static int32_t createPartialFunction(const SFunctionNode* pSrcFunc, SFunctionNod nodesDestroyList(pParameterList); return TSDB_CODE_OUT_OF_MEMORY; } + (*pPartialFunc)->hasOriginalFunc = true; + (*pPartialFunc)->originalFuncId = pSrcFunc->hasOriginalFunc ? pSrcFunc->originalFuncId : pSrcFunc->funcId; char name[TSDB_FUNC_NAME_LEN + TSDB_NAME_DELIMITER_LEN + TSDB_POINTER_PRINT_BYTES + 1] = {0}; int32_t len = snprintf(name, sizeof(name) - 1, "%s.%p", (*pPartialFunc)->functionName, pSrcFunc); taosCreateMD5Hash(name, len); @@ -475,6 +477,8 @@ static int32_t createMergeFunction(const SFunctionNode* pSrcFunc, const SFunctio } } if (TSDB_CODE_SUCCESS == code) { + pFunc->hasOriginalFunc = true; + pFunc->originalFuncId = pSrcFunc->hasOriginalFunc ? pSrcFunc->originalFuncId : pSrcFunc->funcId; // overwrite function restype set by translate function if (fmIsSameInOutType(pSrcFunc->funcId)) { pFunc->node.resType = pSrcFunc->node.resType; @@ -498,7 +502,7 @@ int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc } int32_t code = createPartialFunction(pFunc, pPartialFunc); - if (TSDB_CODE_SUCCESS == code) { + if (TSDB_CODE_SUCCESS == code && pMidFunc) { code = createMidFunction(pFunc, *pPartialFunc, pMidFunc); } if (TSDB_CODE_SUCCESS == code) { @@ -507,7 +511,7 @@ int32_t fmGetDistMethod(const SFunctionNode* pFunc, SFunctionNode** pPartialFunc if (TSDB_CODE_SUCCESS != code) { nodesDestroyNode((SNode*)*pPartialFunc); - nodesDestroyNode((SNode*)*pMidFunc); + if (pMidFunc) nodesDestroyNode((SNode*)*pMidFunc); nodesDestroyNode((SNode*)*pMergeFunc); } @@ -520,3 +524,122 @@ char* fmGetFuncName(int32_t funcId) { } return taosStrdup(funcMgtBuiltins[funcId].name); } + +/// @param [out] pStateFunc, not changed if error occured or no need to create state func +/// @retval 0 for succ, otherwise err occured +static int32_t fmCreateStateFunc(const SFunctionNode* pFunc, SFunctionNode** pStateFunc) { + if (funcMgtBuiltins[pFunc->funcId].pStateFunc) { + SNodeList* pParams = nodesCloneList(pFunc->pParameterList); + if (!pParams) return TSDB_CODE_OUT_OF_MEMORY; + *pStateFunc = createFunction(funcMgtBuiltins[pFunc->funcId].pStateFunc, pParams); + if (!*pStateFunc) { + nodesDestroyList(pParams); + return TSDB_CODE_FUNC_FUNTION_ERROR; + } + strcpy((*pStateFunc)->node.aliasName, pFunc->node.aliasName); + strcpy((*pStateFunc)->node.userAlias, pFunc->node.userAlias); + } + return TSDB_CODE_SUCCESS; +} + +bool fmIsTSMASupportedFunc(func_id_t funcId) { + return isSpecificClassifyFunc(funcId, FUNC_MGT_TSMA_FUNC) && + !isSpecificClassifyFunc(funcId, FUNC_MGT_FORBID_STREAM_FUNC); +} + +int32_t fmCreateStateFuncs(SNodeList* pFuncs) { + int32_t code; + SNode* pNode; + char buf[128] = {0}; + FOREACH(pNode, pFuncs) { + SFunctionNode* pFunc = (SFunctionNode*)pNode; + code = fmGetFuncInfo(pFunc, buf, 128); + if (code) break; + if (fmIsTSMASupportedFunc(pFunc->funcId)) { + SFunctionNode* pNewFunc = NULL; + code = fmCreateStateFunc(pFunc, &pNewFunc); + if (code) { + // error + break; + } else if (!pNewFunc) { + // no need state func + continue; + } else { + REPLACE_NODE(pNewFunc); + nodesDestroyNode(pNode); + } + } + } + return code; +} + +static int32_t fmCreateStateMergeFunc(SFunctionNode* pFunc, SFunctionNode** pStateMergeFunc) { + if (funcMgtBuiltins[pFunc->funcId].pMergeFunc) { + SNodeList* pParams = nodesCloneList(pFunc->pParameterList); + if (!pParams) return TSDB_CODE_OUT_OF_MEMORY; + *pStateMergeFunc = createFunction(funcMgtBuiltins[pFunc->funcId].pMergeFunc, pParams); + if (!*pStateMergeFunc) { + nodesDestroyList(pParams); + return TSDB_CODE_FUNC_FUNTION_ERROR; + } + strcpy((*pStateMergeFunc)->node.aliasName, pFunc->node.aliasName); + strcpy((*pStateMergeFunc)->node.userAlias, pFunc->node.userAlias); + } + return TSDB_CODE_SUCCESS; +} + +int32_t fmCreateStateMergeFuncs(SNodeList* pFuncs) { + int32_t code; + SNode* pNode; + char buf[128] = {0}; + FOREACH(pNode, pFuncs) { + SFunctionNode* pFunc = (SFunctionNode*)pNode; + if (fmIsTSMASupportedFunc(pFunc->funcId)) { + SFunctionNode* pNewFunc = NULL; + code = fmCreateStateMergeFunc(pFunc, &pNewFunc); + if (code) { + // error + break; + } else if (!pNewFunc) { + // no state merge func + continue; + } else { + REPLACE_NODE(pNewFunc); + nodesDestroyNode(pNode); + } + } + } + return code; +} + +int32_t fmGetFuncId(const char* name) { + if (NULL != gFunMgtService.pFuncNameHashTable) { + void* pVal = taosHashGet(gFunMgtService.pFuncNameHashTable, name, strlen(name)); + if (NULL != pVal) { + return *(int32_t*)pVal; + } + return -1; + } + for (int32_t i = 0; i < funcMgtBuiltinsNum; ++i) { + if (0 == strcmp(funcMgtBuiltins[i].name, name)) { + return i; + } + } + return -1; +} + +bool fmIsMyStateFunc(int32_t funcId, int32_t stateFuncId) { + const SBuiltinFuncDefinition* pFunc = &funcMgtBuiltins[funcId]; + const SBuiltinFuncDefinition* pStateFunc = &funcMgtBuiltins[stateFuncId]; + if (!pFunc->pStateFunc) { + return false; + } + if (strcmp(pFunc->pStateFunc, pStateFunc->name) == 0) return true; + int32_t stateMergeFuncId = fmGetFuncId(pFunc->pStateFunc); + const SBuiltinFuncDefinition* pStateMergeFunc = &funcMgtBuiltins[stateMergeFuncId]; + return strcmp(pStateFunc->name, pStateMergeFunc->pMergeFunc) == 0; +} + +bool fmIsCountLikeFunc(int32_t funcId) { + return isSpecificClassifyFunc(funcId, FUNC_MGT_COUNT_LIKE_FUNC); +} diff --git a/source/libs/nodes/src/nodesCloneFuncs.c b/source/libs/nodes/src/nodesCloneFuncs.c index 78725ef289..961c62160b 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -224,6 +224,8 @@ static int32_t functionNodeCopy(const SFunctionNode* pSrc, SFunctionNode* pDst) COPY_SCALAR_FIELD(udfBufSize); COPY_SCALAR_FIELD(hasPk); COPY_SCALAR_FIELD(pkBytes); + COPY_SCALAR_FIELD(hasOriginalFunc); + COPY_SCALAR_FIELD(originalFuncId); return TSDB_CODE_SUCCESS; } @@ -483,6 +485,7 @@ static int32_t logicScanCopy(const SScanLogicNode* pSrc, SScanLogicNode* pDst) { CLONE_OBJECT_FIELD(pFuncTypes, functParamClone); COPY_SCALAR_FIELD(paraTablesSort); COPY_SCALAR_FIELD(smallDataTsSort); + COPY_SCALAR_FIELD(needSplit); return TSDB_CODE_SUCCESS; } @@ -572,6 +575,8 @@ static int32_t logicMergeCopy(const SMergeLogicNode* pSrc, SMergeLogicNode* pDst CLONE_NODE_LIST_FIELD(pInputs); COPY_SCALAR_FIELD(numOfChannels); COPY_SCALAR_FIELD(srcGroupId); + COPY_SCALAR_FIELD(srcEndGroupId); + COPY_SCALAR_FIELD(numOfSubplans); COPY_SCALAR_FIELD(colsMerge); COPY_SCALAR_FIELD(needSort); COPY_SCALAR_FIELD(groupSort); diff --git a/source/libs/nodes/src/nodesCodeFuncs.c b/source/libs/nodes/src/nodesCodeFuncs.c index ad01ab47dd..8a6e432510 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -2468,6 +2468,7 @@ static const char* jkAggPhysiPlanGroupKeys = "GroupKeys"; static const char* jkAggPhysiPlanAggFuncs = "AggFuncs"; static const char* jkAggPhysiPlanMergeDataBlock = "MergeDataBlock"; static const char* jkAggPhysiPlanGroupKeyOptimized = "GroupKeyOptimized"; +static const char* jkAggPhysiPlanHasCountLikeFunc = "HasCountFunc"; static int32_t physiAggNodeToJson(const void* pObj, SJson* pJson) { const SAggPhysiNode* pNode = (const SAggPhysiNode*)pObj; @@ -2488,6 +2489,9 @@ static int32_t physiAggNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddBoolToObject(pJson, jkAggPhysiPlanGroupKeyOptimized, pNode->groupKeyOptimized); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddBoolToObject(pJson, jkAggPhysiPlanHasCountLikeFunc, pNode->hasCountLikeFunc); + } return code; } @@ -2511,6 +2515,9 @@ static int32_t jsonToPhysiAggNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = tjsonGetBoolValue(pJson, jkAggPhysiPlanGroupKeyOptimized, &pNode->groupKeyOptimized); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetBoolValue(pJson, jkAggPhysiPlanHasCountLikeFunc, &pNode->hasCountLikeFunc); + } return code; } @@ -4238,6 +4245,8 @@ static const char* jkFunctionParameter = "Parameters"; static const char* jkFunctionUdfBufSize = "UdfBufSize"; static const char* jkFunctionHasPk = "HasPk"; static const char* jkFunctionPkBytes = "PkBytes"; +static const char* jkFunctionIsMergeFunc = "IsMergeFunc"; +static const char* jkFunctionMergeFuncOf = "MergeFuncOf"; static int32_t functionNodeToJson(const void* pObj, SJson* pJson) { const SFunctionNode* pNode = (const SFunctionNode*)pObj; @@ -4264,6 +4273,13 @@ static int32_t functionNodeToJson(const void* pObj, SJson* pJson) { if (TSDB_CODE_SUCCESS == code) { code = tjsonAddIntegerToObject(pJson, jkFunctionPkBytes, pNode->pkBytes); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddBoolToObject(pJson, jkFunctionIsMergeFunc, pNode->hasOriginalFunc); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkFunctionMergeFuncOf, pNode->originalFuncId); + } + return code; } @@ -4292,6 +4308,13 @@ static int32_t jsonToFunctionNode(const SJson* pJson, void* pObj) { if (TSDB_CODE_SUCCESS == code) { code = tjsonGetIntValue(pJson, jkFunctionPkBytes, &pNode->pkBytes); } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetBoolValue(pJson, jkFunctionIsMergeFunc, &pNode->hasOriginalFunc); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetIntValue(pJson, jkFunctionMergeFuncOf, &pNode->originalFuncId); + } + return code; } @@ -7311,6 +7334,105 @@ static int32_t jsonToInsertStmt(const SJson* pJson, void* pObj) { return code; } +static const char* jkTSMAOptionFuncs = "Funcs"; +static const char* jkTSMAOptionCols = "Cols"; +static const char* jkTSMAOptionInterval = "Interval"; +static const char* jkTSMAOptionTsPrecision = "Precision"; + +static int32_t tsmaOptionToJson(const void* pObj, SJson* pJson) { + const STSMAOptions* pNode = (const STSMAOptions*)pObj; + int32_t code = nodeListToJson(pJson, jkTSMAOptionFuncs, pNode->pFuncs); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkTSMAOptionInterval, nodeToJson, pNode->pInterval); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddIntegerToObject(pJson, jkTSMAOptionTsPrecision, pNode->tsPrecision); + } + return code; +} + +static int32_t jsonToTSMAOption(const SJson* pJson, void* pObj) { + STSMAOptions* pNode = (STSMAOptions*)pObj; + int32_t code = jsonToNodeList(pJson, jkTSMAOptionFuncs, &pNode->pFuncs); + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkTSMAOptionInterval, &pNode->pInterval); + } + if (TSDB_CODE_SUCCESS == code) { + tjsonGetUTinyIntValue(pJson, jkTSMAOptionTsPrecision, &pNode->tsPrecision); + } + return code; +} + +static const char* jkCreateTSMAStmtIgnoreExists = "IgnoreExists"; +static const char* jkCreateTSMAStmtTsmaName = "TSMAName"; +static const char* jkCreateTSMAStmtDbName = "DbName"; +static const char* jkCreateTSMAStmtTableName = "TableName"; +static const char* jkCreateTSMAStmtpOptions = "Options"; + +static int32_t createTSMAStmtToJson(const void* pObj, SJson* pJson) { + const SCreateTSMAStmt* pNode = (const SCreateTSMAStmt*)pObj; + int32_t code = tjsonAddBoolToObject(pJson, jkCreateTSMAStmtIgnoreExists, pNode->ignoreExists); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddStringToObject(pJson, jkCreateTSMAStmtTsmaName, pNode->tsmaName); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddStringToObject(pJson, jkCreateTSMAStmtDbName, pNode->dbName); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddStringToObject(pJson, jkCreateTSMAStmtTableName, pNode->tableName); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddObject(pJson, jkCreateTSMAStmtpOptions, nodeToJson, pNode->pOptions); + } + return code; +} + +static int32_t jsonToCreateTSMAStmt(const SJson* pJson, void* pObj) { + SCreateTSMAStmt* pNode = (SCreateTSMAStmt*)pObj; + int32_t code = tjsonGetBoolValue(pJson, jkCreateTSMAStmtIgnoreExists, &pNode->ignoreExists); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetStringValue(pJson, jkCreateTSMAStmtTsmaName, pNode->tsmaName); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetStringValue(pJson, jkCreateTSMAStmtDbName, pNode->dbName); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetStringValue(pJson, jkCreateTSMAStmtTableName, pNode->tableName); + } + if (TSDB_CODE_SUCCESS == code) { + code = jsonToNodeObject(pJson, jkCreateTSMAStmtpOptions, (SNode**)&pNode->pOptions); + } + return code; +} + +static const char* jkDropTSMAStmtIgnoreNotExists = "IgnoreNotExists"; +static const char* jkDropTSMAStmtDbName = "DbName"; +static const char* jkDropTSMAStmtTsmaName = "TSMAName"; + +static int32_t dropTSMAStmtToJson(const void* pObj, SJson* pJson) { + const SDropTSMAStmt* pNode = (const SDropTSMAStmt*)pObj; + int32_t code = tjsonAddBoolToObject(pJson, jkDropTSMAStmtIgnoreNotExists, pNode->ignoreNotExists); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddStringToObject(pJson, jkDropTSMAStmtDbName, pNode->dbName); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonAddStringToObject(pJson, jkDropTSMAStmtTsmaName, pNode->tsmaName); + } + return code; +} + +static int32_t jsonToDropTSMAStmt(const SJson* pJson, void* pObj) { + SDropTSMAStmt* pNode = (SDropTSMAStmt*)pObj; + int32_t code = tjsonGetBoolValue(pJson, jkDropTSMAStmtIgnoreNotExists, &pNode->ignoreNotExists); + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetStringValue(pJson, jkDropTSMAStmtDbName, pNode->dbName); + } + if (TSDB_CODE_SUCCESS == code) { + code = tjsonGetStringValue(pJson, jkDropTSMAStmtTsmaName, pNode->tsmaName); + } + return code; +} + static int32_t specificNodeToJson(const void* pObj, SJson* pJson) { switch (nodeType(pObj)) { case QUERY_NODE_COLUMN: diff --git a/source/libs/nodes/src/nodesMsgFuncs.c b/source/libs/nodes/src/nodesMsgFuncs.c index 0c6adce23c..54cf685235 100644 --- a/source/libs/nodes/src/nodesMsgFuncs.c +++ b/source/libs/nodes/src/nodesMsgFuncs.c @@ -1109,7 +1109,9 @@ enum { FUNCTION_CODE_PARAMETERS, FUNCTION_CODE_UDF_BUF_SIZE, FUNCTION_NODE_HAS_PK, - FUNCTION_NODE_PK_BYTES + FUNCTION_NODE_PK_BYTES, + FUNCTION_CODE_IS_MERGE_FUNC, + FUNCTION_CODE_MERGE_FUNC_OF, }; static int32_t functionNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { @@ -1137,6 +1139,13 @@ static int32_t functionNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { if (TSDB_CODE_SUCCESS == code) { code = tlvEncodeI32(pEncoder, FUNCTION_NODE_PK_BYTES, pNode->pkBytes); } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeBool(pEncoder, FUNCTION_CODE_IS_MERGE_FUNC, pNode->hasOriginalFunc); + } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeI32(pEncoder, FUNCTION_CODE_MERGE_FUNC_OF, pNode->originalFuncId); + } + return code; } @@ -1171,6 +1180,12 @@ static int32_t msgToFunctionNode(STlvDecoder* pDecoder, void* pObj) { case FUNCTION_NODE_PK_BYTES: code = tlvDecodeI32(pTlv, &pNode->pkBytes); break; + case FUNCTION_CODE_IS_MERGE_FUNC: + code = tlvDecodeBool(pTlv, &pNode->hasOriginalFunc); + break; + case FUNCTION_CODE_MERGE_FUNC_OF: + code = tlvDecodeI32(pTlv, &pNode->originalFuncId); + break; default: break; } @@ -2839,7 +2854,8 @@ enum { PHY_AGG_CODE_GROUP_KEYS, PHY_AGG_CODE_AGG_FUNCS, PHY_AGG_CODE_MERGE_DATA_BLOCK, - PHY_AGG_CODE_GROUP_KEY_OPTIMIZE + PHY_AGG_CODE_GROUP_KEY_OPTIMIZE, + PHY_AGG_CODE_HAS_COUNT_LIKE_FUNCS, }; static int32_t physiAggNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { @@ -2861,6 +2877,9 @@ static int32_t physiAggNodeToMsg(const void* pObj, STlvEncoder* pEncoder) { if (TSDB_CODE_SUCCESS == code) { code = tlvEncodeBool(pEncoder, PHY_AGG_CODE_GROUP_KEY_OPTIMIZE, pNode->groupKeyOptimized); } + if (TSDB_CODE_SUCCESS == code) { + code = tlvEncodeBool(pEncoder, PHY_AGG_CODE_HAS_COUNT_LIKE_FUNCS, pNode->hasCountLikeFunc); + } return code; } @@ -2890,6 +2909,9 @@ static int32_t msgToPhysiAggNode(STlvDecoder* pDecoder, void* pObj) { case PHY_AGG_CODE_GROUP_KEY_OPTIMIZE: code = tlvDecodeBool(pTlv, &pNode->groupKeyOptimized); break; + case PHY_AGG_CODE_HAS_COUNT_LIKE_FUNCS: + code = tlvDecodeBool(pTlv, &pNode->hasCountLikeFunc); + break; default: break; } diff --git a/source/libs/nodes/src/nodesUtilFuncs.c b/source/libs/nodes/src/nodesUtilFuncs.c index 815dae11b0..ed6fa39585 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -519,6 +519,7 @@ SNode* nodesMakeNode(ENodeType type) { case QUERY_NODE_SHOW_GRANTS_FULL_STMT: case QUERY_NODE_SHOW_GRANTS_LOGS_STMT: case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT: + case QUERY_NODE_SHOW_TSMAS_STMT: return makeNode(type, sizeof(SShowStmt)); case QUERY_NODE_SHOW_TABLE_TAGS_STMT: return makeNode(type, sizeof(SShowTableTagsStmt)); @@ -561,6 +562,12 @@ SNode* nodesMakeNode(ENodeType type) { return makeNode(type, sizeof(SCreateViewStmt)); case QUERY_NODE_DROP_VIEW_STMT: return makeNode(type, sizeof(SDropViewStmt)); + case QUERY_NODE_CREATE_TSMA_STMT: + return makeNode(type, sizeof(SCreateTSMAStmt)); + case QUERY_NODE_DROP_TSMA_STMT: + return makeNode(type, sizeof(SDropTSMAStmt)); + case QUERY_NODE_TSMA_OPTIONS: + return makeNode(type, sizeof(STSMAOptions)); case QUERY_NODE_LOGIC_PLAN_SCAN: return makeNode(type, sizeof(SScanLogicNode)); case QUERY_NODE_LOGIC_PLAN_JOIN: @@ -809,6 +816,8 @@ void nodesDestroyNode(SNode* pNode) { taosMemoryFreeClear(pReal->pMeta); taosMemoryFreeClear(pReal->pVgroupList); taosArrayDestroyEx(pReal->pSmaIndexes, destroySmaIndex); + taosArrayDestroyP(pReal->tsmaTargetTbVgInfo, taosMemoryFree); + taosArrayDestroy(pReal->tsmaTargetTbInfo); break; } case QUERY_NODE_TEMP_TABLE: @@ -910,6 +919,12 @@ void nodesDestroyNode(SNode* pNode) { nodesDestroyNode(pOptions->pDeleteMark); break; } + case QUERY_NODE_TSMA_OPTIONS: { + STSMAOptions* pOptions = (STSMAOptions*)pNode; + nodesDestroyList(pOptions->pFuncs); + nodesDestroyNode(pOptions->pInterval); + break; + } case QUERY_NODE_LEFT_VALUE: // no pointer field case QUERY_NODE_COLUMN_REF: // no pointer field break; @@ -1184,7 +1199,8 @@ void nodesDestroyNode(SNode* pNode) { case QUERY_NODE_SHOW_VIEWS_STMT: case QUERY_NODE_SHOW_GRANTS_FULL_STMT: case QUERY_NODE_SHOW_GRANTS_LOGS_STMT: - case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT: { + case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT: + case QUERY_NODE_SHOW_TSMAS_STMT: { SShowStmt* pStmt = (SShowStmt*)pNode; nodesDestroyNode(pStmt->pDbName); nodesDestroyNode(pStmt->pTbName); @@ -1271,6 +1287,15 @@ void nodesDestroyNode(SNode* pNode) { } case QUERY_NODE_DROP_VIEW_STMT: break; + case QUERY_NODE_CREATE_TSMA_STMT: { + SCreateTSMAStmt* pStmt = (SCreateTSMAStmt*)pNode; + nodesDestroyNode((SNode*)pStmt->pOptions); + if (pStmt->pReq) { + tFreeSMCreateSmaReq(pStmt->pReq); + taosMemoryFreeClear(pStmt->pReq); + } + break; + } case QUERY_NODE_LOGIC_PLAN_SCAN: { SScanLogicNode* pLogicNode = (SScanLogicNode*)pNode; destroyLogicNode((SLogicNode*)pLogicNode); @@ -1285,6 +1310,8 @@ void nodesDestroyNode(SNode* pNode) { nodesDestroyList(pLogicNode->pTags); nodesDestroyNode(pLogicNode->pSubtable); taosArrayDestroyEx(pLogicNode->pFuncTypes, destroyFuncParam); + taosArrayDestroyP(pLogicNode->pTsmaTargetTbVgInfo, taosMemoryFree); + taosArrayDestroy(pLogicNode->pTsmaTargetTbInfo); break; } case QUERY_NODE_LOGIC_PLAN_JOIN: { @@ -1740,6 +1767,16 @@ int32_t nodesListMakeStrictAppendList(SNodeList** pTarget, SNodeList* pSrc) { return nodesListStrictAppendList(*pTarget, pSrc); } +int32_t nodesListMakePushFront(SNodeList** pList, SNode* pNode) { + if (*pList == NULL) { + *pList = nodesMakeList(); + if (*pList == NULL) { + terrno = TSDB_CODE_OUT_OF_MEMORY; + return TSDB_CODE_OUT_OF_MEMORY; + } + } + return nodesListPushFront(*pList, pNode); +} int32_t nodesListPushFront(SNodeList* pList, SNode* pNode) { if (NULL == pList || NULL == pNode) { @@ -1756,6 +1793,7 @@ int32_t nodesListPushFront(SNodeList* pList, SNode* pNode) { p->pNext = pList->pHead; } pList->pHead = p; + pList->pTail = pList->pTail ? pList->pTail : p; ++(pList->length); return TSDB_CODE_SUCCESS; } @@ -2610,3 +2648,70 @@ bool nodesIsTableStar(SNode* pNode) { return (QUERY_NODE_COLUMN == nodeType(pNode)) && ('\0' != ((SColumnNode*)pNode)->tableAlias[0]) && (0 == strcmp(((SColumnNode*)pNode)->colName, "*")); } + +void nodesSortList(SNodeList** pList, int32_t (*comp)(SNode* pNode1, SNode* pNode2)) { + if ((*pList)->length == 1) return; + + uint32_t inSize = 1; + SListCell* pHead = (*pList)->pHead; + while (1) { + SListCell* p = pHead; + pHead = NULL; + SListCell* pTail = NULL; + + uint32_t nMerges = 0; + while (p) { + ++nMerges; + SListCell* q = p; + uint32_t pSize = 0; + for (uint32_t i = 0; i < inSize; ++i) { + ++pSize; + q = q->pNext; + if (!q) { + break; + } + } + + uint32_t qSize = inSize; + + while (pSize > 0 || (qSize > 0 && q)) { + SListCell* pCell; + if (pSize == 0) { + pCell = q; + q = q->pNext; + --qSize; + } else if (qSize == 0 || !q) { + pCell = p; + p = p->pNext; + --pSize; + } else if (comp(q->pNode, p->pNode) >= 0) { + pCell = p; + p = p->pNext; + --pSize; + } else { + pCell = q; + q = q->pNext; + --qSize; + } + + if (pTail) { + pTail->pNext = pCell; + pCell->pPrev = pTail; + } else { + pHead = pCell; + pHead->pPrev = NULL; + } + pTail = pCell; + } + p = q; + } + pTail->pNext = NULL; + + if (nMerges <= 1) { + (*pList)->pHead = pHead; + (*pList)->pTail = pTail; + return; + } + inSize *= 2; + } +} diff --git a/source/libs/nodes/test/nodesTestMain.cpp b/source/libs/nodes/test/nodesTestMain.cpp index 356b13f4a7..4e50595b62 100644 --- a/source/libs/nodes/test/nodesTestMain.cpp +++ b/source/libs/nodes/test/nodesTestMain.cpp @@ -56,6 +56,69 @@ TEST(NodesTest, traverseTest) { nodesDestroyNode(pRoot); } +int32_t compareValueNode(SNode* pNode1, SNode* pNode2) { + SValueNode* p1 = (SValueNode*)pNode1; + SValueNode* p2 = (SValueNode*)pNode2; + + if (p1->datum.i < p2->datum.i) + return -1; + else if (p1->datum.i > p2->datum.i) + return 1; + else + return 0; +} + +void assert_sort_result(SNodeList* pList) { + SNode* pNode; + int32_t i = 0; + FOREACH(pNode, pList) { + SValueNode* p = (SValueNode*)pNode; + ASSERT_EQ(p->datum.i, i++); + } + SListCell* pCell = pList->pHead; + ASSERT_TRUE(pCell->pPrev == NULL); + ASSERT_TRUE(pList->pTail->pNext == NULL); + int32_t len = 1; + while (pCell) { + if (pCell->pNext) { + ASSERT_TRUE(pCell->pNext->pPrev == pCell); + } + pCell = pCell->pNext; + if (pCell) len++; + } + ASSERT_EQ(len, pList->length); +} + +TEST(NodesTest, sort) { + SValueNode *vn1 = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); + vn1->datum.i = 4; + + SValueNode *vn2 = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); + vn2->datum.i = 3; + + SValueNode *vn3 = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); + vn3->datum.i = 2; + + SValueNode *vn4 = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); + vn4->datum.i = 1; + + SValueNode *vn5 = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); + vn5->datum.i = 0; + + SNodeList* l = NULL; + nodesListMakeAppend(&l, (SNode*)vn1); + nodesListMakeAppend(&l, (SNode*)vn2); + nodesListMakeAppend(&l, (SNode*)vn3); + nodesListMakeAppend(&l, (SNode*)vn4); + nodesListMakeAppend(&l, (SNode*)vn5); + + nodesSortList(&l, compareValueNode); + + assert_sort_result(l); + + nodesDestroyList(l); +} + int main(int argc, char* argv[]) { testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); diff --git a/source/libs/parser/inc/parAst.h b/source/libs/parser/inc/parAst.h index b9df1b147c..782c90421a 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -274,6 +274,15 @@ SNode* createCreateViewStmt(SAstCreateContext* pCxt, bool orReplace, SNode* pVie SNode* createDropViewStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pView); SNode* createShowCompactDetailsStmt(SAstCreateContext* pCxt, SNode* pCompactIdNode); SNode* createShowCompactsStmt(SAstCreateContext* pCxt, ENodeType type); + +SNode* createCreateTSMAStmt(SAstCreateContext* pCxt, bool ignoreExists, SToken* tsmaName, SNode* pOptions, + SNode* pRealTable, SNode* pInterval); +SNode* createTSMAOptions(SAstCreateContext* pCxt, SNodeList* pFuncs); +SNode* createDefaultTSMAOptions(SAstCreateContext* pCxt); +SNode* createDropTSMAStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable); +SNode* createShowCreateTSMAStmt(SAstCreateContext* pCxt, SNode* pRealTable); +SNode* createShowTSMASStmt(SAstCreateContext* pCxt, SNode* dbName); + #ifdef __cplusplus } #endif diff --git a/source/libs/parser/inc/parInt.h b/source/libs/parser/inc/parInt.h index d88554442b..d58e9bd86a 100644 --- a/source/libs/parser/inc/parInt.h +++ b/source/libs/parser/inc/parInt.h @@ -37,6 +37,7 @@ int32_t extractResultSchema(const SNode* pRoot, int32_t* numOfCols, SSchema** pS int32_t calculateConstant(SParseContext* pParseCxt, SQuery* pQuery); int32_t translatePostCreateStream(SParseContext* pParseCxt, SQuery* pQuery, SSDataBlock* pBlock); int32_t translatePostCreateSmaIndex(SParseContext* pParseCxt, SQuery* pQuery, SSDataBlock* pBlock); +int32_t translatePostCreateTSMA(SParseContext* pParseCxt, SQuery* pQuery, SSDataBlock* pBlock); int32_t buildQueryAfterParse(SQuery** pQuery, SNode* pRootNode, int16_t placeholderNo, SArray** pPlaceholderValues); int32_t translateTable(STranslateContext* pCxt, SNode** pTable, SNode* pJoinParent); int32_t getMetaDataFromHash(const char* pKey, int32_t len, SHashObj* pHash, void** pOutput); diff --git a/source/libs/parser/inc/parUtil.h b/source/libs/parser/inc/parUtil.h index 7a25e3c4c7..be670b2708 100644 --- a/source/libs/parser/inc/parUtil.h +++ b/source/libs/parser/inc/parUtil.h @@ -110,6 +110,8 @@ typedef struct SParseMetaCache { SHashObj* pTableIndex; // key is tbFName, element is SArray* SHashObj* pTableCfg; // key is tbFName, element is STableCfg* SHashObj* pViews; // key is viewFName, element is SViewMeta* + SHashObj* pTableTSMAs; // key is tbFName, elements are SArray + SHashObj* pTSMAs; // key is tsmaFName, elemetns are STableTSMAInfo* SArray* pDnodes; // element is SEpSet bool dnodeRequired; } SParseMetaCache; @@ -153,6 +155,8 @@ int32_t reserveUdfInCache(const char* pFunc, SParseMetaCache* pMetaCache); int32_t reserveTableIndexInCache(int32_t acctId, const char* pDb, const char* pTable, SParseMetaCache* pMetaCache); int32_t reserveTableCfgInCache(int32_t acctId, const char* pDb, const char* pTable, SParseMetaCache* pMetaCache); int32_t reserveDnodeRequiredInCache(SParseMetaCache* pMetaCache); +int32_t reserveTableTSMAInfoInCache(int32_t acctId, const char* pDb, const char* pTable, SParseMetaCache* pMetaCache); +int32_t reserveTSMAInfoInCache(int32_t acctId, const char* pDb, const char* pTsmaName, SParseMetaCache* pMetaCache); int32_t getTableMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, STableMeta** pMeta); int32_t getViewMetaFromCache(SParseMetaCache* pMetaCache, const SName* pName, STableMeta** pMeta); int32_t buildTableMetaFromViewMeta(STableMeta** pMeta, SViewMeta* pViewMeta); @@ -168,6 +172,8 @@ int32_t getTableCfgFromCache(SParseMetaCache* pMetaCache, const SName* pName, ST int32_t getDnodeListFromCache(SParseMetaCache* pMetaCache, SArray** pDnodes); void destoryParseMetaCache(SParseMetaCache* pMetaCache, bool request); SNode* createSelectStmtImpl(bool isDistinct, SNodeList* pProjectionList, SNode* pTable, SNodeList* pHint); +int32_t getTableTsmasFromCache(SParseMetaCache* pMetaCache, const SName* pTbName, SArray** pTsmas); +int32_t getTsmaFromCache(SParseMetaCache* pMetaCache, const SName* pTsmaName, STableTSMAInfo** pTsma); /** * @brief return a - b with overflow check diff --git a/source/libs/parser/inc/sql.y b/source/libs/parser/inc/sql.y old mode 100755 new mode 100644 index e036985823..ccce47f34c --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -579,6 +579,23 @@ db_kind_opt(A) ::= . db_kind_opt(A) ::= USER. { A = SHOW_KIND_DATABASES_USER; } db_kind_opt(A) ::= SYSTEM. { A = SHOW_KIND_DATABASES_SYSTEM; } + +/************************************************ tsma ********************************************************/ +cmd ::= CREATE TSMA not_exists_opt(B) tsma_name(C) + ON full_table_name(E) tsma_func_list(D) + INTERVAL NK_LP duration_literal(F) NK_RP. { pCxt->pRootNode = createCreateTSMAStmt(pCxt, B, &C, D, E, releaseRawExprNode(pCxt, F)); } +cmd ::= CREATE RECURSIVE TSMA not_exists_opt(B) tsma_name(C) + ON full_table_name(D) INTERVAL NK_LP duration_literal(E) NK_RP. { pCxt->pRootNode = createCreateTSMAStmt(pCxt, B, &C, NULL, D, releaseRawExprNode(pCxt, E)); } +cmd ::= DROP TSMA exists_opt(B) full_tsma_name(C). { pCxt->pRootNode = createDropTSMAStmt(pCxt, B, C); } +cmd ::= SHOW db_name_cond_opt(B) TSMAS. { pCxt->pRootNode = createShowTSMASStmt(pCxt, B); } + +full_tsma_name(A) ::= tsma_name(B). { A = createRealTableNode(pCxt, NULL, &B, NULL); } +full_tsma_name(A) ::= db_name(B) NK_DOT tsma_name(C). { A = createRealTableNode(pCxt, &B, &C, NULL); } + +%type tsma_func_list { SNode* } +%destructor tsma_func_list { nodesDestroyNode($$); } +tsma_func_list(A) ::= FUNCTION NK_LP func_list(B) NK_RP. { A = createTSMAOptions(pCxt, B); } + /************************************************ create index ********************************************************/ cmd ::= CREATE SMA INDEX not_exists_opt(D) col_name(A) ON full_table_name(B) index_options(C). { pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, D, A, B, NULL, C); } @@ -1052,6 +1069,10 @@ cgroup_name(A) ::= NK_ID(B). %destructor index_name { } index_name(A) ::= NK_ID(B). { A = B; } +%type tsma_name { SToken } +%destructor tsma_name { } +tsma_name(A) ::= NK_ID(B). { A = B; } + /************************************************ expression **********************************************************/ expr_or_subquery(A) ::= expression(B). { A = B; } //expr_or_subquery(A) ::= subquery(B). { A = createTempTableNode(pCxt, releaseRawExprNode(pCxt, B), NULL); } diff --git a/source/libs/parser/src/parAstCreater.c b/source/libs/parser/src/parAstCreater.c index 85eef1ad5a..26361b53ec 100644 --- a/source/libs/parser/src/parAstCreater.c +++ b/source/libs/parser/src/parAstCreater.c @@ -246,6 +246,16 @@ static bool checkComment(SAstCreateContext* pCxt, const SToken* pCommentToken, b return TSDB_CODE_SUCCESS == pCxt->errCode; } +static bool checkTsmaName(SAstCreateContext* pCxt, SToken* pTsmaToken) { + trimEscape(pTsmaToken); + if (NULL == pTsmaToken) { + pCxt->errCode = TSDB_CODE_PAR_SYNTAX_ERROR; + } else if (pTsmaToken->n >= TSDB_TABLE_NAME_LEN - strlen(TSMA_RES_STB_POSTFIX)) { + pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_TSMA_NAME_TOO_LONG); + } + return pCxt->errCode == TSDB_CODE_SUCCESS; +} + SNode* createRawExprNode(SAstCreateContext* pCxt, const SToken* pToken, SNode* pNode) { CHECK_PARSER_STATUS(pCxt); SRawExprNode* target = (SRawExprNode*)nodesMakeNode(QUERY_NODE_RAW_EXPR); @@ -459,6 +469,7 @@ bool addHintNodeToList(SAstCreateContext* pCxt, SNodeList** ppHintList, EHintOpt int32_t paramNum) { void* value = NULL; switch (opt) { + case HINT_SKIP_TSMA: case HINT_BATCH_SCAN: case HINT_NO_BATCH_SCAN: { if (paramNum > 0) { @@ -584,6 +595,14 @@ SNodeList* createHintNodeList(SAstCreateContext* pCxt, const SToken* pLiteral) { } opt = HINT_HASH_JOIN; break; + case TK_SKIP_TSMA: + lastComma = false; + if (0 != opt || inParamList) { + quit = true; + break; + } + opt = HINT_SKIP_TSMA; + break; case TK_NK_LP: lastComma = false; if (0 == opt || inParamList) { @@ -1890,7 +1909,7 @@ static bool needDbShowStmt(ENodeType type) { return QUERY_NODE_SHOW_TABLES_STMT == type || QUERY_NODE_SHOW_STABLES_STMT == type || QUERY_NODE_SHOW_VGROUPS_STMT == type || QUERY_NODE_SHOW_INDEXES_STMT == type || QUERY_NODE_SHOW_TAGS_STMT == type || QUERY_NODE_SHOW_TABLE_TAGS_STMT == type || - QUERY_NODE_SHOW_VIEWS_STMT == type; + QUERY_NODE_SHOW_VIEWS_STMT == type || QUERY_NODE_SHOW_TSMAS_STMT == type; } SNode* createShowStmt(SAstCreateContext* pCxt, ENodeType type) { @@ -2836,3 +2855,86 @@ SNode* createInsertStmt(SAstCreateContext* pCxt, SNode* pTable, SNodeList* pCols } return (SNode*)pStmt; } + +SNode* createCreateTSMAStmt(SAstCreateContext* pCxt, bool ignoreExists, SToken* tsmaName, SNode* pOptions, + SNode* pRealTable, SNode* pInterval) { + CHECK_PARSER_STATUS(pCxt); + if (!checkTsmaName(pCxt, tsmaName)) { + nodesDestroyNode(pInterval); + return NULL; + } + + SCreateTSMAStmt* pStmt = (SCreateTSMAStmt*)nodesMakeNode(QUERY_NODE_CREATE_TSMA_STMT); + CHECK_OUT_OF_MEM(pStmt); + + pStmt->ignoreExists = ignoreExists; + if (!pOptions) { + // recursive tsma + pStmt->pOptions = (STSMAOptions*)nodesMakeNode(QUERY_NODE_TSMA_OPTIONS); + if (!pStmt->pOptions) { + nodesDestroyNode(pInterval); + nodesDestroyNode((SNode*)pStmt); + pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY; + snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "Out of memory"); + return NULL; + } + pStmt->pOptions->recursiveTsma = true; + } else { + pStmt->pOptions = (STSMAOptions*)pOptions; + } + pStmt->pOptions->pInterval = pInterval; + COPY_STRING_FORM_ID_TOKEN(pStmt->tsmaName, tsmaName); + + SRealTableNode* pTable = (SRealTableNode*)pRealTable; + memcpy(pStmt->dbName, pTable->table.dbName, TSDB_DB_NAME_LEN); + memcpy(pStmt->tableName, pTable->table.tableName, TSDB_TABLE_NAME_LEN); + memcpy(pStmt->originalTbName, pTable->table.tableName, TSDB_TABLE_NAME_LEN); + nodesDestroyNode(pRealTable); + + return (SNode*)pStmt; +} + +SNode* createTSMAOptions(SAstCreateContext* pCxt, SNodeList* pFuncs) { + CHECK_PARSER_STATUS(pCxt); + STSMAOptions* pOptions = (STSMAOptions*)nodesMakeNode(QUERY_NODE_TSMA_OPTIONS); + if (!pOptions) { + //nodesDestroyList(pTSMAFuncs); + pCxt->errCode = TSDB_CODE_OUT_OF_MEMORY; + snprintf(pCxt->pQueryCxt->pMsg, pCxt->pQueryCxt->msgLen, "Out of memory"); + return NULL; + } + pOptions->pFuncs = pFuncs; + return (SNode*)pOptions; +} + +SNode* createDefaultTSMAOptions(SAstCreateContext* pCxt) { + CHECK_PARSER_STATUS(pCxt); + STSMAOptions* pOptions = (STSMAOptions*)nodesMakeNode(QUERY_NODE_TSMA_OPTIONS); + CHECK_OUT_OF_MEM(pOptions); + return (SNode*)pOptions; +} + +SNode* createDropTSMAStmt(SAstCreateContext* pCxt, bool ignoreNotExists, SNode* pRealTable) { + CHECK_PARSER_STATUS(pCxt); + SDropTSMAStmt* pStmt = (SDropTSMAStmt*)nodesMakeNode(QUERY_NODE_DROP_TSMA_STMT); + CHECK_OUT_OF_MEM(pStmt); + + pStmt->ignoreNotExists = ignoreNotExists; + SRealTableNode* pTableNode = (SRealTableNode*)pRealTable; + + memcpy(pStmt->tsmaName, pTableNode->table.tableName, TSDB_TABLE_NAME_LEN); + memcpy(pStmt->dbName, pTableNode->table.dbName, TSDB_DB_NAME_LEN); + + nodesDestroyNode(pRealTable); + return (SNode*)pStmt; +} + +SNode* createShowTSMASStmt(SAstCreateContext* pCxt, SNode* dbName) { + CHECK_PARSER_STATUS(pCxt); + + SShowStmt* pStmt = (SShowStmt*)nodesMakeNode(QUERY_NODE_SHOW_TSMAS_STMT); + CHECK_OUT_OF_MEM(pStmt); + + pStmt->pDbName = dbName; + return (SNode*)pStmt; +} diff --git a/source/libs/parser/src/parAstParser.c b/source/libs/parser/src/parAstParser.c index f746304730..94e17eef4f 100644 --- a/source/libs/parser/src/parAstParser.c +++ b/source/libs/parser/src/parAstParser.c @@ -186,6 +186,10 @@ static int32_t collectMetaKeyFromRealTableImpl(SCollectMetaKeyCxt* pCxt, const c QUERY_NODE_SELECT_STMT == nodeType(pCxt->pStmt)) { code = collectMetaKeyFromInsTags(pCxt); } + if (TSDB_CODE_SUCCESS == code && QUERY_SMA_OPTIMIZE_ENABLE == tsQuerySmaOptimize && + QUERY_NODE_SELECT_STMT == nodeType(pCxt->pStmt)) { + code = reserveTableTSMAInfoInCache(pCxt->pParseCxt->acctId, pDb, pTable, pCxt->pMetaCache); + } return code; } @@ -760,6 +764,50 @@ static int32_t collectMetaKeyFromDropViewStmt(SCollectMetaKeyCxt* pCxt, SDropVie return code; } +static int32_t collectMetaKeyFromCreateTSMAStmt(SCollectMetaKeyCxt* pCxt, SCreateTSMAStmt* pStmt) { + int32_t code; + if (pStmt->pOptions->recursiveTsma) { + // if creating recursive tsma, the tablename is tsmaName + code = reserveTSMAInfoInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache); + if (TSDB_CODE_SUCCESS == code) { + char dstTbName[TSDB_TABLE_NAME_LEN] = {0}; + snprintf(dstTbName, TSDB_TABLE_NAME_LEN, "%s"TSMA_RES_STB_POSTFIX, pStmt->tableName); + code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, dstTbName, pCxt->pMetaCache); + if (TSDB_CODE_SUCCESS == code) { + code = reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pStmt->dbName, dstTbName, pCxt->pMetaCache); + } + } + } else { + code = reserveTableMetaInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache); + if (TSDB_CODE_SUCCESS == code) { + code = reserveTableVgroupInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, pCxt->pMetaCache); + } + } + if (TSDB_CODE_SUCCESS == code) { + code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache); + } + if (TSDB_CODE_SUCCESS == code) { + code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache); + } + return code; +} + +static int32_t collectMetaKeyFromDropTSMAStmt(SCollectMetaKeyCxt* pCxt, SDropTSMAStmt* pStmt) { + int32_t code; + code = reserveTSMAInfoInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tsmaName, pCxt->pMetaCache); + if (TSDB_CODE_SUCCESS == code) { + code = reserveDbVgInfoInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache); + } + if (TSDB_CODE_SUCCESS == code) { + code = reserveDbCfgInCache(pCxt->pParseCxt->acctId, pStmt->dbName, pCxt->pMetaCache); + } + return code; +} + +static int32_t collectMetaKeyFromShowTSMASStmt(SCollectMetaKeyCxt* pCxt, SShowStmt* pStmt) { + return reserveTableMetaInCache(pCxt->pParseCxt->acctId, TSDB_INFORMATION_SCHEMA_DB, TSDB_INS_TABLE_TSMAS, + pCxt->pMetaCache); +} static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) { pCxt->pStmt = pStmt; @@ -891,6 +939,13 @@ static int32_t collectMetaKeyFromQuery(SCollectMetaKeyCxt* pCxt, SNode* pStmt) { return collectMetaKeyFromCreateViewStmt(pCxt, (SCreateViewStmt*)pStmt); case QUERY_NODE_DROP_VIEW_STMT: return collectMetaKeyFromDropViewStmt(pCxt, (SDropViewStmt*)pStmt); + case QUERY_NODE_CREATE_TSMA_STMT: + return collectMetaKeyFromCreateTSMAStmt(pCxt, (SCreateTSMAStmt*)pStmt); + case QUERY_NODE_DROP_TSMA_STMT: + return collectMetaKeyFromDropTSMAStmt(pCxt, (SDropTSMAStmt*)pStmt); + break; + case QUERY_NODE_SHOW_TSMAS_STMT: + return collectMetaKeyFromShowTSMASStmt(pCxt, (SShowStmt*)pStmt); default: break; } diff --git a/source/libs/parser/src/parTokenizer.c b/source/libs/parser/src/parTokenizer.c index 3432a1c140..a69e4894a3 100644 --- a/source/libs/parser/src/parTokenizer.c +++ b/source/libs/parser/src/parTokenizer.c @@ -201,6 +201,7 @@ static SKeyword keywordTable[] = { {"RATIO", TK_RATIO}, {"PAUSE", TK_PAUSE}, {"READ", TK_READ}, + {"RECURSIVE", TK_RECURSIVE}, {"REDISTRIBUTE", TK_REDISTRIBUTE}, {"RENAME", TK_RENAME}, {"REPLACE", TK_REPLACE}, @@ -222,6 +223,7 @@ static SKeyword keywordTable[] = { {"SET", TK_SET}, {"SHOW", TK_SHOW}, {"SINGLE_STABLE", TK_SINGLE_STABLE}, + {"SKIP_TSMA", TK_SKIP_TSMA}, {"SLIDING", TK_SLIDING}, {"SLIMIT", TK_SLIMIT}, {"SMA", TK_SMA}, @@ -268,6 +270,8 @@ static SKeyword keywordTable[] = { {"TRIM", TK_TRIM}, {"TSDB_PAGESIZE", TK_TSDB_PAGESIZE}, {"TSERIES", TK_TSERIES}, + {"TSMA", TK_TSMA}, + {"TSMAS", TK_TSMAS}, {"TTL", TK_TTL}, {"UNION", TK_UNION}, {"UNSAFE", TK_UNSAFE}, diff --git a/source/libs/parser/src/parTranslater.c b/source/libs/parser/src/parTranslater.c index a078f8e2da..da3159432f 100644 --- a/source/libs/parser/src/parTranslater.c +++ b/source/libs/parser/src/parTranslater.c @@ -305,6 +305,10 @@ static const SSysTableShowAdapter sysTableShowAdapter[] = { { .showType = QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT, .pDbName = TSDB_INFORMATION_SCHEMA_DB, .pTableName = TSDB_INS_TABLE_MACHINES, + }, + { .showType = QUERY_NODE_SHOW_TSMAS_STMT, + .pDbName = TSDB_INFORMATION_SCHEMA_DB, + .pTableName = TSDB_INS_TABLE_TSMAS, .numOfShowCols = 1, .pShowCols = {"*"} }, @@ -317,7 +321,7 @@ static EDealRes translateValue(STranslateContext* pCxt, SValueNode* pVal); static EDealRes translateFunction(STranslateContext* pCxt, SFunctionNode** pFunc); static int32_t createSimpleSelectStmtFromProjList(const char* pDb, const char* pTable, SNodeList* pProjectionList, SSelectStmt** pStmt); -static int32_t createLastTsSelectStmt(char* pDb, char* pTable, STableMeta* pMeta, SNode** pQuery); +static int32_t createLastTsSelectStmt(char* pDb, const char* pTable, const char* pkColName, SNode** pQuery); static int32_t setQuery(STranslateContext* pCxt, SQuery* pQuery); static int32_t setRefreshMeta(STranslateContext* pCxt, SQuery* pQuery); @@ -703,6 +707,42 @@ static int32_t getDnodeList(STranslateContext* pCxt, SArray** pDnodes) { return code; } +static int32_t getTableTsmas(STranslateContext* pCxt, const SName* pName, SArray** ppTsmas) { + SParseContext* pParCxt = pCxt->pParseCxt; + int32_t code = 0; + if (pParCxt->async) { + code = getTableTsmasFromCache(pCxt->pMetaCache, pName, ppTsmas); + } else { + SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter, + .requestId = pParCxt->requestId, + .requestObjRefId = pParCxt->requestRid, + .mgmtEps = pParCxt->mgmtEpSet}; + code = catalogGetTableTsmas(pParCxt->pCatalog, &conn, pName, ppTsmas); + } + if (code) + parserError("0x%" PRIx64 " get table tsma for : %s.%s error, code:%s", pCxt->pParseCxt->requestId, pName->dbname, + pName->tname, tstrerror(code)); + return code; +} + +static int32_t getTsma(STranslateContext* pCxt, const SName* pName, STableTSMAInfo** pTsma) { + int32_t code = 0; + SParseContext* pParCxt = pCxt->pParseCxt; + if (pParCxt->async) { + code = getTsmaFromCache(pCxt->pMetaCache, pName, pTsma); + } else { + SRequestConnInfo conn = {.pTrans = pParCxt->pTransporter, + .requestId = pParCxt->requestId, + .requestObjRefId = pParCxt->requestRid, + .mgmtEps = pParCxt->mgmtEpSet}; + code = catalogGetTsma(pParCxt->pCatalog, &conn, pName, pTsma); + } + if (code) + parserError("0x%" PRIx64 " get tsma for: %s.%s error, code:%s", pCxt->pParseCxt->requestId, pName->dbname, + pName->tname, tstrerror(code)); + return code; +} + static int32_t initTranslateContext(SParseContext* pParseCxt, SParseMetaCache* pMetaCache, STranslateContext* pCxt) { pCxt->pParseCxt = pParseCxt; pCxt->errCode = TSDB_CODE_SUCCESS; @@ -3608,13 +3648,92 @@ static int32_t setTableIndex(STranslateContext* pCxt, SName* pName, SRealTableNo if (pCxt->createStream || QUERY_SMA_OPTIMIZE_DISABLE == tsQuerySmaOptimize) { return TSDB_CODE_SUCCESS; } - if (isSelectStmt(pCxt->pCurrStmt) && NULL != ((SSelectStmt*)pCxt->pCurrStmt)->pWindow && + if (0 && isSelectStmt(pCxt->pCurrStmt) && NULL != ((SSelectStmt*)pCxt->pCurrStmt)->pWindow && QUERY_NODE_INTERVAL_WINDOW == nodeType(((SSelectStmt*)pCxt->pCurrStmt)->pWindow)) { return getTableIndex(pCxt, pName, &pRealTable->pSmaIndexes); } return TSDB_CODE_SUCCESS; } +static int32_t setTableTsmas(STranslateContext* pCxt, SName* pName, SRealTableNode* pRealTable) { + int32_t code = 0; + if (pCxt->createStream || QUERY_SMA_OPTIMIZE_DISABLE == tsQuerySmaOptimize) { + return TSDB_CODE_SUCCESS; + } + if (isSelectStmt(pCxt->pCurrStmt) && pRealTable->pMeta->tableType != TSDB_SYSTEM_TABLE) { + code = getTableTsmas(pCxt, pName, &pRealTable->pTsmas); + // if select from a child table, fetch it's corresponding tsma target child table infos + if (TSDB_CODE_SUCCESS == code && pRealTable->pTsmas && + (pRealTable->pMeta->tableType == TSDB_CHILD_TABLE || pRealTable->pMeta->tableType == TSDB_NORMAL_TABLE)) { + if (pRealTable->tsmaTargetTbVgInfo) { + taosArrayDestroyP(pRealTable->tsmaTargetTbVgInfo, taosMemoryFree); + pRealTable->tsmaTargetTbVgInfo = NULL; + } + char buf[TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN + 1]; + for (int32_t i = 0; i < pRealTable->pTsmas->size; ++i) { + STableTSMAInfo* pTsma = taosArrayGetP(pRealTable->pTsmas, i); + SName tsmaTargetTbName = {0}; + toName(pCxt->pParseCxt->acctId, pRealTable->table.dbName, "", &tsmaTargetTbName); + int32_t len = snprintf(buf, TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN, "%s.%s_%s", pTsma->dbFName, pTsma->name, + pRealTable->table.tableName); + len = taosCreateMD5Hash(buf, len); + strncpy(tsmaTargetTbName.tname, buf, strlen(buf)); + collectUseTable(&tsmaTargetTbName, pCxt->pTargetTables); + SVgroupInfo vgInfo = {0}; + bool exists = false; + code = catalogGetCachedTableHashVgroup(pCxt->pParseCxt->pCatalog, &tsmaTargetTbName, &vgInfo, &exists); + if (TSDB_CODE_SUCCESS == code) { + ASSERT(exists); + if (!pRealTable->tsmaTargetTbVgInfo) { + pRealTable->tsmaTargetTbVgInfo = taosArrayInit(pRealTable->pTsmas->size, POINTER_BYTES); + if (!pRealTable->tsmaTargetTbVgInfo) { + code = TSDB_CODE_OUT_OF_MEMORY; + break; + } + } + SVgroupsInfo* pVgpsInfo = taosMemoryCalloc(1, sizeof(int32_t) + sizeof(SVgroupInfo)); + if (!pVgpsInfo) { + code = TSDB_CODE_OUT_OF_MEMORY; + break; + } + pVgpsInfo->numOfVgroups = 1; + pVgpsInfo->vgroups[0] = vgInfo; + taosArrayPush(pRealTable->tsmaTargetTbVgInfo, &pVgpsInfo); + } else { + break; + } + + STableMeta* pTableMeta = NULL; + if (code == TSDB_CODE_SUCCESS) { + SRequestConnInfo conn = {.pTrans = pCxt->pParseCxt->pTransporter, + .requestId = pCxt->pParseCxt->requestId, + .requestObjRefId = pCxt->pParseCxt->requestRid, + .mgmtEps = pCxt->pParseCxt->mgmtEpSet}; + code = catalogGetTableMeta(pCxt->pParseCxt->pCatalog, &conn, &tsmaTargetTbName, &pTableMeta); + } + STsmaTargetTbInfo ctbInfo = {0}; + if (!pRealTable->tsmaTargetTbInfo) { + pRealTable->tsmaTargetTbInfo = taosArrayInit(pRealTable->pTsmas->size, sizeof(STsmaTargetTbInfo)); + if (!pRealTable->tsmaTargetTbInfo) { + code = TSDB_CODE_OUT_OF_MEMORY; + break; + } + } + if (code == TSDB_CODE_SUCCESS) { + sprintf(ctbInfo.tableName, "%s", tsmaTargetTbName.tname); + ctbInfo.uid = pTableMeta->uid; + taosMemoryFree(pTableMeta); + } else if (TSDB_CODE_PAR_TABLE_NOT_EXIST == code) { + // ignore table not exists error + code = TSDB_CODE_SUCCESS; + } + taosArrayPush(pRealTable->tsmaTargetTbInfo, &ctbInfo); + } + } + } + return code; +} + static int32_t setTableCacheLastMode(STranslateContext* pCxt, SSelectStmt* pSelect) { if ((!pSelect->hasLastRowFunc && !pSelect->hasLastFunc) || QUERY_NODE_REAL_TABLE != nodeType(pSelect->pFromTable) || TSDB_SYSTEM_TABLE == ((SRealTableNode*)pSelect->pFromTable)->pMeta->tableType) { @@ -4207,6 +4326,9 @@ int32_t translateTable(STranslateContext* pCxt, SNode** pTable, SNode* pJoinPare if (TSDB_CODE_SUCCESS == code) { code = setTableIndex(pCxt, &name, pRealTable); } + if (TSDB_CODE_SUCCESS == code) { + code = setTableTsmas(pCxt, &name, pRealTable); + } } if (TSDB_CODE_SUCCESS == code) { pRealTable->table.precision = pRealTable->pMeta->tableInfo.precision; @@ -4930,8 +5052,8 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindo if (IS_CALENDAR_TIME_DURATION(pSliding->unit)) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SLIDING_UNIT); } - if ((pSliding->datum.i < - convertTimeFromPrecisionToUnit(tsMinSlidingTime, TSDB_TIME_PRECISION_MILLI, pSliding->unit)) || + if ((pSliding->datum.i < + convertTimePrecision(tsMinSlidingTime, TSDB_TIME_PRECISION_MILLI, pSliding->node.resType.precision)) || (pInter->datum.i / pSliding->datum.i > INTERVAL_SLIDING_FACTOR)) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SLIDING_TOO_SMALL); } @@ -5509,20 +5631,19 @@ static int32_t findEqualCondTbname(STranslateContext* pCxt, SNode* pWhere, SArra return TSDB_CODE_SUCCESS; } -static int32_t findVgroupsFromEqualTbname(STranslateContext* pCxt, SEqCondTbNameTableInfo* pInfo, - SVgroupsInfo* vgsInfo) { +static int32_t findVgroupsFromEqualTbname(STranslateContext* pCxt, SArray* aTbnames, const char* dbName, + int32_t numOfVgroups, SVgroupsInfo* vgsInfo) { int32_t nVgroups = 0; - int32_t nTbls = taosArrayGetSize(pInfo->aTbnames); + int32_t nTbls = taosArrayGetSize(aTbnames); - if (nTbls >= pInfo->pRealTable->pVgroupList->numOfVgroups) { + if (nTbls >= numOfVgroups) { vgsInfo->numOfVgroups = 0; return TSDB_CODE_SUCCESS; } for (int j = 0; j < nTbls; ++j) { - char* dbName = pInfo->pRealTable->table.dbName; SName snameTb; - char* tbName = taosArrayGetP(pInfo->aTbnames, j); + char* tbName = taosArrayGetP(aTbnames, j); toName(pCxt->pParseCxt->acctId, dbName, tbName, &snameTb); SVgroupInfo vgInfo = {0}; bool bExists; @@ -5552,16 +5673,54 @@ static int32_t setEqualTbnameTableVgroups(STranslateContext* pCxt, SSelectStmt* int32_t code = TSDB_CODE_SUCCESS; for (int i = 0; i < taosArrayGetSize(aTables); ++i) { SEqCondTbNameTableInfo* pInfo = taosArrayGet(aTables, i); - int32_t nTbls = taosArrayGetSize(pInfo->aTbnames); + int32_t nTbls = taosArrayGetSize(pInfo->aTbnames); + int32_t numOfVgs = pInfo->pRealTable->pVgroupList->numOfVgroups; SVgroupsInfo* vgsInfo = taosMemoryMalloc(sizeof(SVgroupsInfo) + nTbls * sizeof(SVgroupInfo)); - int32_t nVgroups = 0; - findVgroupsFromEqualTbname(pCxt, pInfo, vgsInfo); + findVgroupsFromEqualTbname(pCxt, pInfo->aTbnames, pInfo->pRealTable->table.dbName, numOfVgs, vgsInfo); if (vgsInfo->numOfVgroups != 0) { taosMemoryFree(pInfo->pRealTable->pVgroupList); pInfo->pRealTable->pVgroupList = vgsInfo; } else { taosMemoryFree(vgsInfo); + } + vgsInfo = NULL; + + if (pInfo->pRealTable->pTsmas) { + pInfo->pRealTable->tsmaTargetTbVgInfo = taosArrayInit(pInfo->pRealTable->pTsmas->size, POINTER_BYTES); + if (!pInfo->pRealTable->tsmaTargetTbVgInfo) return TSDB_CODE_OUT_OF_MEMORY; + + for (int32_t i = 0; i < pInfo->pRealTable->pTsmas->size; ++i) { + STableTSMAInfo* pTsma = taosArrayGetP(pInfo->pRealTable->pTsmas, i); + SArray *pTbNames = taosArrayInit(pInfo->aTbnames->size, POINTER_BYTES); + if (!pTbNames) return TSDB_CODE_OUT_OF_MEMORY; + + for (int32_t k = 0; k < pInfo->aTbnames->size; ++k) { + const char* pTbName = taosArrayGetP(pInfo->aTbnames, k); + char* pNewTbName = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN + TSDB_TABLE_NAME_LEN + 1); + if (!pNewTbName) { + code = TSDB_CODE_OUT_OF_MEMORY; + break; + } + taosArrayPush(pTbNames, &pNewTbName); + sprintf(pNewTbName, "%s.%s_%s", pTsma->dbFName, pTsma->name, pTbName); + int32_t len = taosCreateMD5Hash(pNewTbName, strlen(pNewTbName)); + } + if (TSDB_CODE_SUCCESS == code) { + vgsInfo = taosMemoryMalloc(sizeof(SVgroupsInfo) + nTbls * sizeof(SVgroupInfo)); + if (!vgsInfo) code = TSDB_CODE_OUT_OF_MEMORY; + } + if (TSDB_CODE_SUCCESS == code) { + findVgroupsFromEqualTbname(pCxt, pTbNames, pInfo->pRealTable->table.dbName, numOfVgs, vgsInfo); + if (vgsInfo->numOfVgroups != 0) { + taosArrayPush(pInfo->pRealTable->tsmaTargetTbVgInfo, &vgsInfo); + } else { + taosMemoryFree(vgsInfo); + } + } + taosArrayDestroyP(pTbNames, taosMemoryFree); + if (code) break; + } } } return TSDB_CODE_SUCCESS; @@ -7434,6 +7593,8 @@ typedef struct SSampleAstInfo { SNodeList* pPartitionByList; STableMeta* pRollupTableMeta; bool createSmaIndex; + SNodeList* pTags; + SNode* pSubTable; } SSampleAstInfo; static int32_t buildTableForSampleAst(SSampleAstInfo* pInfo, SNode** pOutput) { @@ -7455,6 +7616,7 @@ static int32_t addWstartToSampleProjects(SNodeList* pProjectionList) { return TSDB_CODE_OUT_OF_MEMORY; } strcpy(pFunc->functionName, "_wstart"); + strcpy(pFunc->node.userAlias, "_wstart"); return nodesListPushFront(pProjectionList, (SNode*)pFunc); } @@ -7464,6 +7626,7 @@ static int32_t addWendToSampleProjects(SNodeList* pProjectionList) { return TSDB_CODE_OUT_OF_MEMORY; } strcpy(pFunc->functionName, "_wend"); + strcpy(pFunc->node.userAlias, "_wend"); return nodesListAppend(pProjectionList, (SNode*)pFunc); } @@ -7473,10 +7636,11 @@ static int32_t addWdurationToSampleProjects(SNodeList* pProjectionList) { return TSDB_CODE_OUT_OF_MEMORY; } strcpy(pFunc->functionName, "_wduration"); + strcpy(pFunc->node.userAlias, "_wduration"); return nodesListAppend(pProjectionList, (SNode*)pFunc); } -static int32_t buildProjectsForSampleAst(SSampleAstInfo* pInfo, SNodeList** pList) { +static int32_t buildProjectsForSampleAst(SSampleAstInfo* pInfo, SNodeList** pList, int32_t *pProjectionTotalLen) { SNodeList* pProjectionList = pInfo->pFuncs; pInfo->pFuncs = NULL; @@ -7490,7 +7654,11 @@ static int32_t buildProjectsForSampleAst(SSampleAstInfo* pInfo, SNodeList** pLis if (TSDB_CODE_SUCCESS == code) { SNode* pProject = NULL; - FOREACH(pProject, pProjectionList) { sprintf(((SExprNode*)pProject)->aliasName, "#%p", pProject); } + if (pProjectionTotalLen) *pProjectionTotalLen = 0; + FOREACH(pProject, pProjectionList) { + sprintf(((SExprNode*)pProject)->aliasName, "#%p", pProject); + if (pProjectionTotalLen) *pProjectionTotalLen += ((SExprNode*)pProject)->resType.bytes; + } *pList = pProjectionList; } else { nodesDestroyList(pProjectionList); @@ -7518,7 +7686,7 @@ static int32_t buildIntervalForSampleAst(SSampleAstInfo* pInfo, SNode** pOutput) } static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, char** pAst, int32_t* pLen, char** pExpr, - int32_t* pExprLen) { + int32_t* pExprLen, int32_t* pProjectionTotalLen) { SSelectStmt* pSelect = (SSelectStmt*)nodesMakeNode(QUERY_NODE_SELECT_STMT); if (NULL == pSelect) { return TSDB_CODE_OUT_OF_MEMORY; @@ -7527,9 +7695,11 @@ static int32_t buildSampleAst(STranslateContext* pCxt, SSampleAstInfo* pInfo, ch int32_t code = buildTableForSampleAst(pInfo, &pSelect->pFromTable); if (TSDB_CODE_SUCCESS == code) { - code = buildProjectsForSampleAst(pInfo, &pSelect->pProjectionList); + code = buildProjectsForSampleAst(pInfo, &pSelect->pProjectionList, pProjectionTotalLen); } if (TSDB_CODE_SUCCESS == code) { + TSWAP(pInfo->pSubTable, pSelect->pSubtable); + TSWAP(pInfo->pTags, pSelect->pTags); TSWAP(pSelect->pPartitionByList, pInfo->pPartitionByList); code = buildIntervalForSampleAst(pInfo, &pSelect->pWindow); } @@ -7552,6 +7722,8 @@ static void clearSampleAstInfo(SSampleAstInfo* pInfo) { nodesDestroyNode(pInfo->pInterval); nodesDestroyNode(pInfo->pOffset); nodesDestroyNode(pInfo->pSliding); + nodesDestroyNode(pInfo->pSubTable); + nodesDestroyList(pInfo->pTags); } static SNode* makeIntervalVal(SRetention* pRetension, int8_t precision) { @@ -7675,7 +7847,7 @@ static int32_t getRollupAst(STranslateContext* pCxt, SCreateTableStmt* pStmt, SR SSampleAstInfo info = {0}; int32_t code = buildSampleAstInfoByTable(pCxt, pStmt, pRetension, precision, &info); if (TSDB_CODE_SUCCESS == code) { - code = buildSampleAst(pCxt, &info, pAst, pLen, NULL, NULL); + code = buildSampleAst(pCxt, &info, pAst, pLen, NULL, NULL, NULL); } clearSampleAstInfo(&info); return code; @@ -7780,6 +7952,7 @@ static int32_t doTranslateDropSuperTable(STranslateContext* pCxt, const SName* p static int32_t translateDropTable(STranslateContext* pCxt, SDropTableStmt* pStmt) { SDropTableClause* pClause = (SDropTableClause*)nodesListGetNode(pStmt->pTables, 0); SName tableName; + if (pStmt->withTsma) return TSDB_CODE_SUCCESS; return doTranslateDropSuperTable( pCxt, toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &tableName), pClause->ignoreNotExists); } @@ -8208,7 +8381,7 @@ static int32_t getSmaIndexAst(STranslateContext* pCxt, SCreateIndexStmt* pStmt, SSampleAstInfo info = {0}; int32_t code = buildSampleAstInfoByIndex(pCxt, pStmt, &info); if (TSDB_CODE_SUCCESS == code) { - code = buildSampleAst(pCxt, &info, pAst, pLen, pExpr, pExprLen); + code = buildSampleAst(pCxt, &info, pAst, pLen, pExpr, pExprLen, NULL); } clearSampleAstInfo(&info); return code; @@ -8266,7 +8439,7 @@ static int32_t buildCreateSmaReq(STranslateContext* pCxt, SCreateIndexStmt* pStm code = getTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pMetaCache); if (TSDB_CODE_SUCCESS == code) { pStmt->pOptions->tsPrecision = pMetaCache->tableInfo.precision; - code = createLastTsSelectStmt(pStmt->dbName, pStmt->tableName, pMetaCache, &pStmt->pPrevQuery); + code = createLastTsSelectStmt(pStmt->dbName, pStmt->tableName, pMetaCache->schema[0].name, &pStmt->pPrevQuery); } taosMemoryFreeClear(pMetaCache); } @@ -9562,14 +9735,14 @@ static int32_t translateStreamTargetTable(STranslateContext* pCxt, SCreateStream return code; } -static int32_t createLastTsSelectStmt(char* pDb, char* pTable, STableMeta* pMeta, SNode** pQuery) { +static int32_t createLastTsSelectStmt(char* pDb, const char* pTable, const char* pkColName, SNode** pQuery) { SColumnNode* col = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); if (NULL == col) { return TSDB_CODE_OUT_OF_MEMORY; } tstrncpy(col->tableAlias, pTable, tListLen(col->tableAlias)); - tstrncpy(col->colName, pMeta->schema[0].name, tListLen(col->colName)); + tstrncpy(col->colName, pkColName, tListLen(col->colName)); SNodeList* pParameterList = nodesMakeList(); if (NULL == pParameterList) { nodesDestroyNode((SNode*)col); @@ -9752,7 +9925,8 @@ static int32_t buildCreateStreamQuery(STranslateContext* pCxt, SCreateStreamStmt } if (TSDB_CODE_SUCCESS == code && pStmt->pOptions->fillHistory) { SRealTableNode* pTable = (SRealTableNode*)(((SSelectStmt*)pStmt->pQuery)->pFromTable); - code = createLastTsSelectStmt(pTable->table.dbName, pTable->table.tableName, pTable->pMeta, &pStmt->pPrevQuery); + code = createLastTsSelectStmt(pTable->table.dbName, pTable->table.tableName, pTable->pMeta->schema[0].name, + &pStmt->pPrevQuery); /* if (TSDB_CODE_SUCCESS == code) { STranslateContext cxt = {0}; @@ -10353,6 +10527,440 @@ static int32_t translateShowCreateView(STranslateContext* pCxt, SShowCreateViewS #endif } +static SColumnNode* createColumnNodeWithName(const char* name) { + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); + if (!pCol) return NULL; + tstrncpy(pCol->colName, name, TSDB_COL_NAME_LEN); + tstrncpy(pCol->node.aliasName, name, TSDB_COL_NAME_LEN); + tstrncpy(pCol->node.userAlias, name, TSDB_COL_NAME_LEN); + return pCol; +} + +static int32_t compareTsmaColWithColId(SNode* pNode1, SNode* pNode2) { + SColumnNode* pCol1 = (SColumnNode*)pNode1; + SColumnNode* pCol2 = (SColumnNode*)pNode2; + if (pCol1->colId < pCol2->colId) + return -1; + else if (pCol1->colId > pCol2->colId) + return 1; + else + return 0; +} + +static int32_t compareTsmaFuncWithFuncAndColId(SNode* pNode1, SNode* pNode2) { + SFunctionNode* pFunc1 = (SFunctionNode*)pNode1; + SFunctionNode* pFunc2 = (SFunctionNode*)pNode2; + if (pFunc1->funcId < pFunc2->funcId) + return -1; + else if (pFunc1->funcId > pFunc2->funcId) + return 1; + else { + SNode* pCol1 = pFunc1->pParameterList->pHead->pNode; + SNode* pCol2 = pFunc2->pParameterList->pHead->pNode; + return compareTsmaColWithColId(pCol1, pCol2); + } +} + +// pFuncs are already sorted by funcId and colId +static int32_t deduplicateTsmaFuncs(SNodeList* pFuncs) { + SNode* pLast = NULL; + SNode* pFunc = NULL; + SNodeList* pRes = NULL; + FOREACH(pFunc, pFuncs) { + if (pLast) { + if (compareTsmaFuncWithFuncAndColId(pLast, pFunc) == 0) { + ERASE_NODE(pFuncs); + continue; + } else { + pLast = pFunc; + } + } else { + pLast = pFunc; + } + } + return TSDB_CODE_SUCCESS; +} + +static int32_t buildTSMAAstStreamSubTable(SCreateTSMAStmt* pStmt, SMCreateSmaReq* pReq, const SNode* pTbname, SNode** pSubTable) { + int32_t code = 0; + SFunctionNode* pMd5Func = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); + SFunctionNode* pConcatFunc = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); + SValueNode* pVal = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); + if (!pMd5Func || !pConcatFunc || !pVal) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _end; + } + sprintf(pMd5Func->functionName, "%s", "md5"); + sprintf(pConcatFunc->functionName, "%s", "concat"); + pVal->literal = taosMemoryMalloc(TSDB_TABLE_FNAME_LEN + 1); + if (!pVal->literal) { + code = TSDB_CODE_OUT_OF_MEMORY; + goto _end; + } + sprintf(pVal->literal, "%s_", pReq->name); + pVal->node.resType.type = TSDB_DATA_TYPE_VARCHAR; + pVal->node.resType.bytes = strlen(pVal->literal); + code = nodesListMakeAppend(&pConcatFunc->pParameterList, (SNode*)pVal); + if (code != TSDB_CODE_SUCCESS) goto _end; + pVal = NULL; + + // not recursive tsma, md5(concat('1.test.tsma1_', tbname)) + // recursive tsma, md5(concat('1.test.tsma1_', `tbname`)), `tbname` is the last tag + code = nodesListStrictAppend(pConcatFunc->pParameterList, nodesCloneNode(pTbname)); + if (code != TSDB_CODE_SUCCESS) goto _end; + + code = nodesListMakeAppend(&pMd5Func->pParameterList, (SNode*)pConcatFunc); + if (code != TSDB_CODE_SUCCESS) goto _end; + pConcatFunc = NULL; + *pSubTable = (SNode*)pMd5Func; + +_end: + if (code) { + if (pMd5Func) nodesDestroyNode((SNode*)pMd5Func); + if (pConcatFunc) nodesDestroyNode((SNode*)pConcatFunc); + if (pVal) nodesDestroyNode((SNode*)pVal); + } + return code; +} + +static int32_t buildTSMAAst(STranslateContext* pCxt, SCreateTSMAStmt* pStmt, SMCreateSmaReq* pReq, + const char* tbName, int32_t numOfTags, const SSchema* pTags) { + int32_t code = TSDB_CODE_SUCCESS; + SSampleAstInfo info = {0}; + info.createSmaIndex = true; + info.pDbName = pStmt->dbName; + info.pTableName = tbName; + info.pFuncs = nodesCloneList(pStmt->pOptions->pFuncs); + info.pInterval = nodesCloneNode(pStmt->pOptions->pInterval); + if (!info.pFuncs || !info.pInterval) code = TSDB_CODE_OUT_OF_MEMORY; + + SFunctionNode* pTbnameFunc = NULL; + if (TSDB_CODE_SUCCESS == code) { + // append partition by tbname + pTbnameFunc = (SFunctionNode*)createTbnameFunction(); + if (pTbnameFunc) { + sprintf(pTbnameFunc->node.userAlias, "tbname"); + code = nodesListMakeStrictAppend(&info.pPartitionByList, (SNode*)pTbnameFunc); + } else { + code = TSDB_CODE_OUT_OF_MEMORY; + } + } + if (TSDB_CODE_SUCCESS == code) { + int32_t partitionTagNum = pStmt->pOptions->recursiveTsma ? numOfTags - 1 : numOfTags; + // append partition by tags + SNode* pTagCol = NULL; + for (int32_t idx = 0; idx < partitionTagNum; ++idx) { + pTagCol = (SNode*)createColumnNodeWithName(pTags[idx].name); + if (!pTagCol) { + code = TSDB_CODE_OUT_OF_MEMORY; + break; + } + nodesListAppend(info.pPartitionByList, pTagCol); + code = nodesListMakeStrictAppend(&info.pTags, nodesCloneNode(pTagCol)); + } + + // sub table + if (code == TSDB_CODE_SUCCESS) { + SFunctionNode* pSubTable = NULL; + pTagCol = NULL; + if (pTags && numOfTags > 0) { + pTagCol = (SNode*)createColumnNodeWithName(pTags[numOfTags - 1].name); + if (!pTagCol) code = TSDB_CODE_OUT_OF_MEMORY; + } + if (code == TSDB_CODE_SUCCESS) { + code = buildTSMAAstStreamSubTable(pStmt, pReq, pStmt->pOptions->recursiveTsma ? pTagCol : (SNode*)pTbnameFunc, (SNode**)&pSubTable); + info.pSubTable = (SNode*)pSubTable; + } + if (code == TSDB_CODE_SUCCESS) + code = nodesListMakeStrictAppend(&info.pTags, pStmt->pOptions->recursiveTsma ? pTagCol : nodesCloneNode((SNode*)pTbnameFunc)); + } + } + + if (code == TSDB_CODE_SUCCESS && !pStmt->pOptions->recursiveTsma) + code = fmCreateStateFuncs(info.pFuncs); + + if (code == TSDB_CODE_SUCCESS) { + int32_t pProjectionTotalLen = 0; + code = buildSampleAst(pCxt, &info, &pReq->ast, &pReq->astLen, &pReq->expr, &pReq->exprLen, &pProjectionTotalLen); + if (code == TSDB_CODE_SUCCESS && pProjectionTotalLen > TSDB_MAX_BYTES_PER_ROW) { + code = TSDB_CODE_PAR_INVALID_ROW_LENGTH; + } + } + clearSampleAstInfo(&info); + return code; +} + +static int32_t createColumnBySchema(const SSchema* pSchema, SColumnNode** ppCol) { + *ppCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); + int32_t code = 0; + if (!*ppCol) return TSDB_CODE_OUT_OF_MEMORY; + + (*ppCol)->colId = pSchema->colId; + (*ppCol)->node.resType.type = pSchema->type; + (*ppCol)->node.resType.bytes = pSchema->bytes; + strcpy((*ppCol)->colName, pSchema->name); + return TSDB_CODE_SUCCESS; +} + +static int32_t rewriteTSMAFuncs(STranslateContext* pCxt, SCreateTSMAStmt* pStmt, int32_t columnNum, + const SSchema* pCols) { + int32_t code = TSDB_CODE_SUCCESS; + SNode* pNode; + SFunctionNode* pFunc = NULL; + SColumnNode* pCol = NULL; + if (pStmt->pOptions->recursiveTsma) { + int32_t i = 0; + FOREACH(pNode, pStmt->pOptions->pFuncs) { + // rewrite all func parameters with tsma dest tb cols + pFunc = (SFunctionNode*)pNode; + const SSchema* pSchema = pCols + i; + code = createColumnBySchema(pSchema, &pCol); + if (code) break; + nodesListErase(pFunc->pParameterList, pFunc->pParameterList->pHead); + nodesListPushFront(pFunc->pParameterList, (SNode*)pCol); + snprintf(pFunc->node.userAlias, TSDB_COL_NAME_LEN, "%s", pSchema->name); + // for first or last, the second param will be pk ts col, here we should remove it + if (fmIsImplicitTsFunc(pFunc->funcId) && LIST_LENGTH(pFunc->pParameterList) == 2) { + nodesListErase(pFunc->pParameterList, pFunc->pParameterList->pTail); + } + ++i; + } + // recursive tsma, create func list from base tsma + if (TSDB_CODE_SUCCESS == code) { + code = fmCreateStateMergeFuncs(pStmt->pOptions->pFuncs); + } + } else { + FOREACH(pNode, pStmt->pOptions->pFuncs) { + pFunc = (SFunctionNode*)pNode; + if (!pFunc->pParameterList || LIST_LENGTH(pFunc->pParameterList) != 1 || + nodeType(pFunc->pParameterList->pHead->pNode) != QUERY_NODE_COLUMN) { + code = TSDB_CODE_TSMA_INVALID_FUNC_PARAM; + break; + } + SColumnNode* pCol = (SColumnNode*)pFunc->pParameterList->pHead->pNode; + int32_t i = 0; + for (; i < columnNum; ++i) { + if (strcmp(pCols[i].name, pCol->colName) == 0) { + pCol->colId = pCols[i].colId; + pCol->node.resType.type = pCols[i].type; + pCol->node.resType.bytes = pCols[i].bytes; + break; + } + } + if (i == columnNum) { + code = TSDB_CODE_TSMA_INVALID_FUNC_PARAM; + break; + } + code = fmGetFuncInfo(pFunc, NULL, 0); + if (TSDB_CODE_SUCCESS != code) break; + if (!fmIsTSMASupportedFunc(pFunc->funcId)) { + code = TSDB_CODE_TSMA_UNSUPPORTED_FUNC; + break; + } + + pCol = (SColumnNode*)pFunc->pParameterList->pHead->pNode; + snprintf(pFunc->node.userAlias, TSDB_COL_NAME_LEN, "%s(%s)", pFunc->functionName, pCol->colName); + } + } + if (TSDB_CODE_SUCCESS == code) { + nodesSortList(&pStmt->pOptions->pFuncs, compareTsmaFuncWithFuncAndColId); + deduplicateTsmaFuncs(pStmt->pOptions->pFuncs); + } + return code; +} + +static int32_t buildCreateTSMAReq(STranslateContext* pCxt, SCreateTSMAStmt* pStmt, SMCreateSmaReq* pReq, SName* useTbName) { + SName name; + tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tsmaName, &name), pReq->name); + memset(&name, 0, sizeof(SName)); + toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, useTbName); + tNameExtractFullName(useTbName, pReq->stb); + pReq->igExists = pStmt->ignoreExists; + pReq->interval = ((SValueNode*)pStmt->pOptions->pInterval)->datum.i; + pReq->intervalUnit = TIME_UNIT_MILLISECOND; + +#define TSMA_MIN_INTERVAL_MS 1 // 1ms +#define TSMA_MAX_INTERVAL_MS (60 * 60 * 1000) // 1h + if (pReq->interval > TSMA_MAX_INTERVAL_MS || pReq->interval < TSMA_MIN_INTERVAL_MS) { + return TSDB_CODE_TSMA_INVALID_INTERVAL; + } + + int32_t code = TSDB_CODE_SUCCESS; + + STableMeta* pTableMeta = NULL; + STableTSMAInfo* pRecursiveTsma = NULL; + int32_t numOfCols = 0, numOfTags = 0; + SSchema * pCols = NULL, *pTags = NULL; + if (pStmt->pOptions->recursiveTsma) { + // useTbName is base tsma name + code = getTsma(pCxt, useTbName, &pRecursiveTsma); + if (code == TSDB_CODE_SUCCESS) { + pReq->recursiveTsma = true; + tNameExtractFullName(useTbName, pReq->baseTsmaName); + SValueNode* pInterval = (SValueNode*)pStmt->pOptions->pInterval; + if (pRecursiveTsma->interval < pInterval->datum.i && pInterval->datum.i % pRecursiveTsma->interval == 0) { + } else { + code = TSDB_CODE_TSMA_INVALID_PARA; + } + } + if (code == TSDB_CODE_SUCCESS) { + SNode* pNode; + if (TSDB_CODE_SUCCESS != nodesStringToNode(pRecursiveTsma->ast, &pNode)) { + return TSDB_CODE_TSMA_INVALID_STAT; + } + SSelectStmt* pSelect = (SSelectStmt*)pNode; + FOREACH(pNode, pSelect->pProjectionList) { + SFunctionNode* pFuncNode = (SFunctionNode*)pNode; + if (!fmIsTSMASupportedFunc(pFuncNode->funcId)) continue; + nodesListMakeStrictAppend(&pStmt->pOptions->pFuncs, nodesCloneNode(pNode)); + } + nodesDestroyNode((SNode*)pSelect); + memset(useTbName, 0, sizeof(SName)); + memcpy(pStmt->originalTbName, pRecursiveTsma->tb, TSDB_TABLE_NAME_LEN); + tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pRecursiveTsma->tb, useTbName), pReq->stb); + numOfCols = pRecursiveTsma->pUsedCols->size; + numOfTags = pRecursiveTsma->pTags ? pRecursiveTsma->pTags->size : 0; + pCols = pRecursiveTsma->pUsedCols->pData; + pTags = pRecursiveTsma->pTags ? pRecursiveTsma->pTags->pData : NULL; + code = getTableMeta(pCxt, pStmt->dbName, pRecursiveTsma->targetTb, &pTableMeta); + } + } else { + code = getTableMeta(pCxt, pStmt->dbName, pStmt->tableName, &pTableMeta); + if (TSDB_CODE_SUCCESS == code) { + numOfCols = pTableMeta->tableInfo.numOfColumns; + numOfTags = pTableMeta->tableInfo.numOfTags; + pCols = pTableMeta->schema; + pTags = pTableMeta->schema + numOfCols; + if (pTableMeta->tableType == TSDB_NORMAL_TABLE) { + pReq->normSourceTbUid = pTableMeta->uid; + } else if (pTableMeta->tableType == TSDB_CHILD_TABLE) { + code = TSDB_CODE_TSMA_INVALID_TB; + } + } + } + + if (TSDB_CODE_SUCCESS == code) { + code = getSmaIndexSql(pCxt, &pReq->sql, &pReq->sqlLen); + } + + if (TSDB_CODE_SUCCESS == code) { + code = rewriteTSMAFuncs(pCxt, pStmt, numOfCols, pCols); + } + if (TSDB_CODE_SUCCESS == code && !pStmt->pOptions->recursiveTsma) { + if (LIST_LENGTH(pStmt->pOptions->pFuncs) + numOfTags + TSMA_RES_STB_EXTRA_COLUMN_NUM > TSDB_MAX_COLUMNS) { + code = TSDB_CODE_PAR_TOO_MANY_COLUMNS; + } + } + if (TSDB_CODE_SUCCESS == code) { + code = buildTSMAAst(pCxt, pStmt, pReq, pStmt->pOptions->recursiveTsma ? pRecursiveTsma->targetTb : pStmt->tableName, + numOfTags, pTags); + } + if (TSDB_CODE_SUCCESS == code) { + const char* pkColName = pTableMeta->schema[0].name; + const char* tbName = pStmt->pOptions->recursiveTsma ? pRecursiveTsma->targetTb : pStmt->tableName; + code = createLastTsSelectStmt(pStmt->dbName, tbName, pkColName, &pStmt->pPrevQuery); + } + + taosMemoryFreeClear(pTableMeta); + + return code; +} + +static int32_t translateCreateTSMA(STranslateContext* pCxt, SCreateTSMAStmt* pStmt) { + int32_t code = doTranslateValue(pCxt, (SValueNode*)pStmt->pOptions->pInterval); + + SName useTbName = {0}; + if (code == TSDB_CODE_SUCCESS) { + pStmt->pReq = taosMemoryCalloc(1, sizeof(SMCreateSmaReq)); + if (!pStmt->pReq) return TSDB_CODE_OUT_OF_MEMORY; + } + if (code == TSDB_CODE_SUCCESS) { + code = buildCreateTSMAReq(pCxt, pStmt, pStmt->pReq, &useTbName); + } + if ( TSDB_CODE_SUCCESS == code) { + code = collectUseTable(&useTbName, pCxt->pTargetTables); + } + if (TSDB_CODE_SUCCESS == code) { + if (!pStmt->pPrevQuery) { + code = buildCmdMsg(pCxt, TDMT_MND_CREATE_TSMA, (FSerializeFunc)tSerializeSMCreateSmaReq, pStmt->pReq); + } else { + TSWAP(pCxt->pPrevRoot, pStmt->pPrevQuery); + } + } + return code; +} + +static int32_t buildIntervalForCreateTSMA(SCreateTSMAStmt* pStmt, SInterval* pInterval) { + int32_t code = TSDB_CODE_SUCCESS; + pInterval->interval = ((SValueNode*)pStmt->pOptions->pInterval)->datum.i; + pInterval->intervalUnit = ((SValueNode*)pStmt->pOptions->pInterval)->unit; + pInterval->offset = 0; + pInterval->sliding = pInterval->interval; + pInterval->slidingUnit = pInterval->intervalUnit; + pInterval->precision = pStmt->pOptions->tsPrecision; + return code; +} + +int32_t translatePostCreateTSMA(SParseContext* pParseCxt, SQuery* pQuery, SSDataBlock* pBlock) { + SCreateTSMAStmt* pStmt = (SCreateTSMAStmt*)pQuery->pRoot; + STranslateContext cxt = {0}; + SInterval interval = {0}; + int64_t lastTs = 0; + + int32_t code = initTranslateContext(pParseCxt, NULL, &cxt); + if (TSDB_CODE_SUCCESS == code) { + code = buildIntervalForCreateTSMA(pStmt, &interval); + } + + if (TSDB_CODE_SUCCESS == code) { + code = createStreamReqVersionInfo(pBlock, &pStmt->pReq->pVgroupVerList, &lastTs, &interval); + } + + if (TSDB_CODE_SUCCESS == code) { + if (interval.interval > 0) { + pStmt->pReq->lastTs = taosTimeAdd(taosTimeTruncate(lastTs, &interval), interval.interval, interval.intervalUnit, interval.precision); + } else { + pStmt->pReq->lastTs = lastTs + 1; // start key of the next time window + } + code = buildCmdMsg(&cxt, TDMT_MND_CREATE_TSMA, (FSerializeFunc)tSerializeSMCreateSmaReq, pStmt->pReq); + } + + if (TSDB_CODE_SUCCESS == code) { + code = setQuery(&cxt, pQuery); + } + + if ( TSDB_CODE_SUCCESS == code) { + SName name = {0}; + toName(pParseCxt->acctId, pStmt->dbName, pStmt->originalTbName, &name); + code = collectUseTable(&name, cxt.pTargetTables); + } + + setRefreshMeta(&cxt, pQuery); + destroyTranslateContext(&cxt); + + tFreeSMCreateSmaReq(pStmt->pReq); + taosMemoryFreeClear(pStmt->pReq); + + return code; +} + +static int32_t translateDropTSMA(STranslateContext* pCxt, SDropTSMAStmt* pStmt) { + int32_t code = TSDB_CODE_SUCCESS; + SMDropSmaReq dropReq = {0}; + SName name; + tNameExtractFullName(toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tsmaName, &name), dropReq.name); + dropReq.igNotExists = pStmt->ignoreNotExists; + STableTSMAInfo* pTsma = NULL; + code = getTsma(pCxt, &name, &pTsma); + if (code == TSDB_CODE_SUCCESS) { + toName(pCxt->pParseCxt->acctId, pStmt->dbName, pTsma->tb, &name); + code = collectUseTable(&name, pCxt->pTargetTables); + } + if (TSDB_CODE_SUCCESS == code) + code = buildCmdMsg(pCxt, TDMT_MND_DROP_TSMA, (FSerializeFunc)tSerializeSMDropSmaReq, &dropReq); + return code; +} + static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { int32_t code = TSDB_CODE_SUCCESS; switch (nodeType(pNode)) { @@ -10535,7 +11143,14 @@ static int32_t translateQuery(STranslateContext* pCxt, SNode* pNode) { case QUERY_NODE_DROP_VIEW_STMT: code = translateDropView(pCxt, (SDropViewStmt*)pNode); break; - + case QUERY_NODE_CREATE_TSMA_STMT: + code = translateCreateTSMA(pCxt, (SCreateTSMAStmt*)pNode); + break; + case QUERY_NODE_SHOW_CREATE_TSMA_STMT: + break; + case QUERY_NODE_DROP_TSMA_STMT: + code = translateDropTSMA(pCxt, (SDropTSMAStmt*)pNode); + break; default: break; } @@ -11676,34 +12291,30 @@ typedef struct SVgroupDropTableBatch { char dbName[TSDB_DB_NAME_LEN]; } SVgroupDropTableBatch; -static void addDropTbReqIntoVgroup(SHashObj* pVgroupHashmap, SDropTableClause* pClause, SVgroupInfo* pVgInfo, - uint64_t suid) { - SVDropTbReq req = {.name = pClause->tableName, .suid = suid, .igNotExists = pClause->ignoreNotExists}; +static void addDropTbReqIntoVgroup(SHashObj* pVgroupHashmap, SVgroupInfo* pVgInfo, SVDropTbReq* pReq) { SVgroupDropTableBatch* pTableBatch = taosHashGet(pVgroupHashmap, &pVgInfo->vgId, sizeof(pVgInfo->vgId)); if (NULL == pTableBatch) { SVgroupDropTableBatch tBatch = {0}; tBatch.info = *pVgInfo; tBatch.req.pArray = taosArrayInit(TARRAY_MIN_SIZE, sizeof(SVDropTbReq)); - taosArrayPush(tBatch.req.pArray, &req); + taosArrayPush(tBatch.req.pArray, pReq); taosHashPut(pVgroupHashmap, &pVgInfo->vgId, sizeof(pVgInfo->vgId), &tBatch, sizeof(tBatch)); } else { // add to the correct vgroup - taosArrayPush(pTableBatch->req.pArray, &req); + taosArrayPush(pTableBatch->req.pArray, pReq); } } -static int32_t buildDropTableVgroupHashmap(STranslateContext* pCxt, SDropTableClause* pClause, bool* pIsSuperTable, - SHashObj* pVgroupHashmap) { - SName name; - toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &name); +static int32_t buildDropTableVgroupHashmap(STranslateContext* pCxt, SDropTableClause* pClause, const SName* name, + int8_t* tableType, SHashObj* pVgroupHashmap) { STableMeta* pTableMeta = NULL; - int32_t code = getTargetMeta(pCxt, &name, &pTableMeta, false); + int32_t code = getTargetMeta(pCxt, name, &pTableMeta, false); if (TSDB_CODE_SUCCESS == code) { - code = collectUseTable(&name, pCxt->pTargetTables); + code = collectUseTable(name, pCxt->pTargetTables); + *tableType = pTableMeta->tableType; } if (TSDB_CODE_SUCCESS == code && TSDB_SUPER_TABLE == pTableMeta->tableType) { - *pIsSuperTable = true; goto over; } @@ -11712,14 +12323,15 @@ static int32_t buildDropTableVgroupHashmap(STranslateContext* pCxt, SDropTableCl goto over; } - *pIsSuperTable = false; SVgroupInfo info = {0}; if (TSDB_CODE_SUCCESS == code) { code = getTableHashVgroup(pCxt, pClause->dbName, pClause->tableName, &info); } if (TSDB_CODE_SUCCESS == code) { - addDropTbReqIntoVgroup(pVgroupHashmap, pClause, &info, pTableMeta->suid); + SVDropTbReq req = {.suid = pTableMeta->suid, .igNotExists = pClause->ignoreNotExists}; + req.name = pClause->tableName; + addDropTbReqIntoVgroup(pVgroupHashmap, &info, &req); } over: @@ -11786,6 +12398,9 @@ SArray* serializeVgroupsDropTableBatch(SHashObj* pVgroupHashmap) { static int32_t rewriteDropTable(STranslateContext* pCxt, SQuery* pQuery) { SDropTableStmt* pStmt = (SDropTableStmt*)pQuery->pRoot; + int8_t tableType; + SNode* pNode; + SArray* pTsmas = NULL; SHashObj* pVgroupHashmap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_INT), false, HASH_NO_LOCK); if (NULL == pVgroupHashmap) { @@ -11793,24 +12408,64 @@ static int32_t rewriteDropTable(STranslateContext* pCxt, SQuery* pQuery) { } taosHashSetFreeFp(pVgroupHashmap, destroyDropTbReqBatch); - bool isSuperTable = false; - SNode* pNode; FOREACH(pNode, pStmt->pTables) { - int32_t code = buildDropTableVgroupHashmap(pCxt, (SDropTableClause*)pNode, &isSuperTable, pVgroupHashmap); + SDropTableClause* pClause = (SDropTableClause*)pNode; + SName name; + toName(pCxt->pParseCxt->acctId, pClause->dbName, pClause->tableName, &name); + int32_t code = buildDropTableVgroupHashmap(pCxt, pClause, &name, &tableType, pVgroupHashmap); if (TSDB_CODE_SUCCESS != code) { taosHashCleanup(pVgroupHashmap); return code; } - if (isSuperTable && LIST_LENGTH(pStmt->pTables) > 1) { + if (tableType == TSDB_SUPER_TABLE && LIST_LENGTH(pStmt->pTables) > 1) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_DROP_STABLE); } + if (pCxt->pMetaCache) code = getTableTsmasFromCache(pCxt->pMetaCache, &name, &pTsmas); + if (TSDB_CODE_SUCCESS != code) { + taosHashCleanup(pVgroupHashmap); + return code; + } + if (!pStmt->withTsma) { + pStmt->withTsma = pTsmas && pTsmas->size > 0; + } + pClause->pTsmas = pTsmas; + if (tableType == TSDB_NORMAL_TABLE && pTsmas && pTsmas->size > 0) { + taosHashCleanup(pVgroupHashmap); + return TSDB_CODE_TSMA_MUST_BE_DROPPED; + } } - if (isSuperTable || 0 == taosHashGetSize(pVgroupHashmap)) { + if (tableType == TSDB_SUPER_TABLE || 0 == taosHashGetSize(pVgroupHashmap)) { taosHashCleanup(pVgroupHashmap); return TSDB_CODE_SUCCESS; } + int32_t code = 0; + if (pStmt->withTsma) { + if (code == TSDB_CODE_SUCCESS) { + SMDropTbsReq req = {0}; + req.pVgReqs = taosArrayInit(taosHashGetSize(pVgroupHashmap), sizeof(SMDropTbReqsOnSingleVg)); + + SVgroupDropTableBatch* pTbBatch = NULL; + do { + pTbBatch = taosHashIterate(pVgroupHashmap, pTbBatch); + if (pTbBatch == NULL) { + break; + } + + SMDropTbReqsOnSingleVg reqOnVg = {0}; + reqOnVg.vgInfo = pTbBatch->info; + reqOnVg.pTbs = pTbBatch->req.pArray; + taosArrayPush(req.pVgReqs, &reqOnVg); + } while (true); + + code = buildCmdMsg(pCxt, TDMT_MND_DROP_TB_WITH_TSMA, (FSerializeFunc)tSerializeSMDropTbsReq, &req); + taosArrayDestroy(req.pVgReqs); + } + taosHashCleanup(pVgroupHashmap); + return code; + } + SArray* pBufArray = serializeVgroupsDropTableBatch(pVgroupHashmap); taosHashCleanup(pVgroupHashmap); if (NULL == pBufArray) { @@ -11822,6 +12477,16 @@ static int32_t rewriteDropTable(STranslateContext* pCxt, SQuery* pQuery) { static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pStmt, STableMeta* pTableMeta, SVAlterTbReq* pReq) { + SName tbName = {0}; + SArray* pTsmas = NULL; + int32_t code = TSDB_CODE_SUCCESS; + if (pCxt->pMetaCache) { + toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tbName); + code = getTableTsmasFromCache(pCxt->pMetaCache, &tbName, &pTsmas); + if (code != TSDB_CODE_SUCCESS) return code; + if (pTsmas && pTsmas->size > 0) return TSDB_CODE_TSMA_MUST_BE_DROPPED; + } + SSchema* pSchema = getTagSchema(pTableMeta, pStmt->colName); if (NULL == pSchema) { return generateSyntaxErrMsgExt(&pCxt->msgBuf, TSDB_CODE_PAR_INVALID_ALTER_TABLE, "Invalid tag name: %s", @@ -11838,8 +12503,6 @@ static int32_t buildUpdateTagValReq(STranslateContext* pCxt, SAlterTableStmt* pS pReq->colId = pSchema->colId; pReq->tagType = pSchema->type; - int32_t code = 0; - STag* pTag = NULL; SToken token; char tokenBuf[TSDB_MAX_TAGS_LEN]; @@ -11982,6 +12645,17 @@ static int32_t buildRenameColReq(STranslateContext* pCxt, SAlterTableStmt* pStmt if (NULL != getColSchema(pTableMeta, pStmt->newColName)) { return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_DUPLICATED_COLUMN); } + if (TSDB_NORMAL_TABLE == pTableMeta->tableType) { + SArray* pTsmas = NULL; + SName tbName; + int32_t code = 0; + toName(pCxt->pParseCxt->acctId, pStmt->dbName, pStmt->tableName, &tbName); + if (pCxt->pMetaCache) code = getTableTsmasFromCache(pCxt->pMetaCache, &tbName, &pTsmas); + if (TSDB_CODE_SUCCESS != code) return code; + if (pTsmas && pTsmas->size > 0) { + return TSDB_CODE_TSMA_MUST_BE_DROPPED; + } + } pReq->colName = taosStrdup(pStmt->colName); pReq->colNewName = taosStrdup(pStmt->newColName); @@ -12292,6 +12966,7 @@ static int32_t rewriteQuery(STranslateContext* pCxt, SQuery* pQuery) { case QUERY_NODE_SHOW_GRANTS_LOGS_STMT: case QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT: case QUERY_NODE_SHOW_ARBGROUPS_STMT: + case QUERY_NODE_SHOW_TSMAS_STMT: code = rewriteShow(pCxt, pQuery); break; case QUERY_NODE_SHOW_VGROUPS_STMT: diff --git a/source/libs/parser/src/parUtil.c b/source/libs/parser/src/parUtil.c index bd1e8331e7..0c4aa8f75a 100644 --- a/source/libs/parser/src/parUtil.c +++ b/source/libs/parser/src/parUtil.c @@ -16,6 +16,8 @@ #include "parUtil.h" #include "cJSON.h" #include "querynodes.h" +#include "tarray.h" +#include "tlog.h" #define USER_AUTH_KEY_MAX_LEN TSDB_USER_LEN + TSDB_TABLE_FNAME_LEN + 2 @@ -210,6 +212,8 @@ static char* getSyntaxErrFormat(int32_t errCode) { return "primary key column must be of type int, uint, bigint, ubigint, and varchar"; case TSDB_CODE_PAR_INVALID_PK_OP: return "primary key column can not be added, modified, and dropped"; + case TSDB_CODE_TSMA_NAME_TOO_LONG: + return "Tsma name too long"; default: return "Unknown error"; } @@ -723,6 +727,12 @@ int32_t buildCatalogReq(const SParseMetaCache* pMetaCache, SCatalogReq* pCatalog if (TSDB_CODE_SUCCESS == code) { code = buildTableReq(pMetaCache->pTableCfg, &pCatalogReq->pTableCfg); } + if (TSDB_CODE_SUCCESS == code) { + code = buildTableReqFromDb(pMetaCache->pTableMeta, &pCatalogReq->pTableTSMAs); + } + if (TSDB_CODE_SUCCESS == code) { + code = buildTableReqFromDb(pMetaCache->pTSMAs, &pCatalogReq->pTSMAs); + } #ifdef TD_ENTERPRISE if (TSDB_CODE_SUCCESS == code) { code = buildTableReqFromDb(pMetaCache->pTableMeta, &pCatalogReq->pView); @@ -796,6 +806,7 @@ static int32_t putDbDataToCache(const SArray* pDbReq, const SArray* pDbData, SHa } static int32_t putDbTableDataToCache(const SArray* pDbReq, const SArray* pTableData, SHashObj** pTable) { + if (!pTableData || pTableData->size == 0) return TSDB_CODE_SUCCESS; int32_t ndbs = taosArrayGetSize(pDbReq); int32_t tableNo = 0; for (int32_t i = 0; i < ndbs; ++i) { @@ -864,6 +875,12 @@ int32_t putMetaDataToCache(const SCatalogReq* pCatalogReq, const SMetaData* pMet if (TSDB_CODE_SUCCESS == code) { code = putTableDataToCache(pCatalogReq->pTableCfg, pMetaData->pTableCfg, &pMetaCache->pTableCfg); } + if (TSDB_CODE_SUCCESS == code) { + code = putDbTableDataToCache(pCatalogReq->pTableTSMAs, pMetaData->pTableTsmas, &pMetaCache->pTableTSMAs); + } + if (TSDB_CODE_SUCCESS == code) { + code = putDbTableDataToCache(pCatalogReq->pTSMAs, pMetaData->pTsmas, &pMetaCache->pTSMAs); + } #ifdef TD_ENTERPRISE if (TSDB_CODE_SUCCESS == code) { code = putDbTableDataToCache(pCatalogReq->pView, pMetaData->pView, &pMetaCache->pViews); @@ -1134,6 +1151,14 @@ int32_t reserveTableCfgInCache(int32_t acctId, const char* pDb, const char* pTab return reserveTableReqInCache(acctId, pDb, pTable, &pMetaCache->pTableCfg); } +int32_t reserveTableTSMAInfoInCache(int32_t acctId, const char *pDb, const char *pTable, SParseMetaCache *pMetaCache) { + return reserveTableReqInCache(acctId, pDb, pTable, &pMetaCache->pTableTSMAs); +} + +int32_t reserveTSMAInfoInCache(int32_t acctId, const char* pDb, const char* pTsmaName, SParseMetaCache* pMetaCache) { + return reserveTableReqInDbCache(acctId, pDb, pTsmaName, &pMetaCache->pTSMAs); +} + int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName, SArray** pIndexes) { char fullName[TSDB_TABLE_FNAME_LEN]; tNameExtractFullName(pName, fullName); @@ -1148,6 +1173,31 @@ int32_t getTableIndexFromCache(SParseMetaCache* pMetaCache, const SName* pName, return code; } +int32_t getTableTsmasFromCache(SParseMetaCache* pMetaCache, const SName* pTbName, SArray** pTsmas) { + char tbFName[TSDB_TABLE_FNAME_LEN]; + tNameExtractFullName(pTbName, tbFName); + STableTSMAInfoRsp* pTsmasRsp = NULL; + int32_t code = getMetaDataFromHash(tbFName, strlen(tbFName), pMetaCache->pTableTSMAs, (void**)&pTsmasRsp); + if (TSDB_CODE_SUCCESS == code && pTsmasRsp) { + *pTsmas = pTsmasRsp->pTsmas; + } + return TSDB_CODE_SUCCESS; +} + +int32_t getTsmaFromCache(SParseMetaCache* pMetaCache, const SName* pTsmaName, STableTSMAInfo** pTsma) { + char tsmaFName[TSDB_TABLE_FNAME_LEN]; + tNameExtractFullName(pTsmaName, tsmaFName); + STableTSMAInfoRsp* pTsmaRsp = NULL; + int32_t code = getMetaDataFromHash(tsmaFName, strlen(tsmaFName), pMetaCache->pTSMAs, (void**)&pTsmaRsp); + if (TSDB_CODE_SUCCESS == code && pTsmaRsp) { + ASSERT(pTsmaRsp->pTsmas->size == 1); + *pTsma = taosArrayGetP(pTsmaRsp->pTsmas, 0); + } else if (code == TSDB_CODE_PAR_INTERNAL_ERROR){ + code = TSDB_CODE_MND_SMA_NOT_EXIST; + } + return code; +} + STableCfg* tableCfgDup(STableCfg* pCfg) { STableCfg* pNew = taosMemoryMalloc(sizeof(*pNew)); @@ -1220,10 +1270,12 @@ void destoryParseMetaCache(SParseMetaCache* pMetaCache, bool request) { destoryParseTablesMetaReqHash(pMetaCache->pTableMeta); destoryParseTablesMetaReqHash(pMetaCache->pTableVgroup); destoryParseTablesMetaReqHash(pMetaCache->pViews); + destoryParseTablesMetaReqHash(pMetaCache->pTSMAs); } else { taosHashCleanup(pMetaCache->pTableMeta); taosHashCleanup(pMetaCache->pTableVgroup); taosHashCleanup(pMetaCache->pViews); + taosHashCleanup(pMetaCache->pTSMAs); } taosHashCleanup(pMetaCache->pDbVgroup); taosHashCleanup(pMetaCache->pDbCfg); @@ -1232,6 +1284,7 @@ void destoryParseMetaCache(SParseMetaCache* pMetaCache, bool request) { taosHashCleanup(pMetaCache->pUdf); taosHashCleanup(pMetaCache->pTableIndex); taosHashCleanup(pMetaCache->pTableCfg); + taosHashCleanup(pMetaCache->pTableTSMAs); } int64_t int64SafeSub(int64_t a, int64_t b) { diff --git a/source/libs/parser/src/parser.c b/source/libs/parser/src/parser.c index 92e25f3ee6..bdeccafa36 100644 --- a/source/libs/parser/src/parser.c +++ b/source/libs/parser/src/parser.c @@ -244,6 +244,10 @@ int32_t qContinueParsePostQuery(SParseContext* pCxt, SQuery* pQuery, SSDataBlock code = translatePostCreateSmaIndex(pCxt, pQuery, pBlock); break; } + case QUERY_NODE_CREATE_TSMA_STMT: { + code = translatePostCreateTSMA(pCxt, pQuery, pBlock); + break; + } default: break; } @@ -270,12 +274,16 @@ void destoryCatalogReq(SCatalogReq *pCatalogReq) { #ifdef TD_ENTERPRISE taosArrayDestroy(pCatalogReq->pView); #endif + taosArrayDestroy(pCatalogReq->pTableTSMAs); + taosArrayDestroy(pCatalogReq->pTSMAs); } else { taosArrayDestroyEx(pCatalogReq->pTableMeta, destoryTablesReq); taosArrayDestroyEx(pCatalogReq->pTableHash, destoryTablesReq); #ifdef TD_ENTERPRISE taosArrayDestroyEx(pCatalogReq->pView, destoryTablesReq); #endif + taosArrayDestroyEx(pCatalogReq->pTableTSMAs, destoryTablesReq); + taosArrayDestroyEx(pCatalogReq->pTSMAs, destoryTablesReq); } taosArrayDestroy(pCatalogReq->pUdf); taosArrayDestroy(pCatalogReq->pIndex); diff --git a/source/libs/parser/src/sql.c b/source/libs/parser/src/sql.c index 431070b0bb..df67fa27a1 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -1,3 +1,5 @@ +/* This file is automatically generated by Lemon from input grammar +** source file "sql.y". */ /* ** 2000-05-29 ** @@ -22,9 +24,8 @@ ** The following is the concatenation of all %include directives from the ** input grammar file: */ -#include -#include /************ Begin %include sections from the grammar ************************/ +#line 11 "sql.y" #include #include @@ -41,12 +42,382 @@ #include "parAst.h" #define YYSTACKDEPTH 0 +#line 46 "sql.c" /**************** End of %include directives **********************************/ -/* These constants specify the various numeric values for terminal symbols -** in a format understandable to "makeheaders". This section is blank unless -** "lemon" is run with the "-m" command-line option. -***************** Begin makeheaders token definitions *************************/ -/**************** End makeheaders token definitions ***************************/ +/* These constants specify the various numeric values for terminal symbols. +***************** Begin token definitions *************************************/ +#ifndef TK_OR +#define TK_OR 1 +#define TK_AND 2 +#define TK_UNION 3 +#define TK_ALL 4 +#define TK_MINUS 5 +#define TK_EXCEPT 6 +#define TK_INTERSECT 7 +#define TK_NK_BITAND 8 +#define TK_NK_BITOR 9 +#define TK_NK_LSHIFT 10 +#define TK_NK_RSHIFT 11 +#define TK_NK_PLUS 12 +#define TK_NK_MINUS 13 +#define TK_NK_STAR 14 +#define TK_NK_SLASH 15 +#define TK_NK_REM 16 +#define TK_NK_CONCAT 17 +#define TK_CREATE 18 +#define TK_ACCOUNT 19 +#define TK_NK_ID 20 +#define TK_PASS 21 +#define TK_NK_STRING 22 +#define TK_ALTER 23 +#define TK_PPS 24 +#define TK_TSERIES 25 +#define TK_STORAGE 26 +#define TK_STREAMS 27 +#define TK_QTIME 28 +#define TK_DBS 29 +#define TK_USERS 30 +#define TK_CONNS 31 +#define TK_STATE 32 +#define TK_NK_COMMA 33 +#define TK_HOST 34 +#define TK_USER 35 +#define TK_ENABLE 36 +#define TK_NK_INTEGER 37 +#define TK_SYSINFO 38 +#define TK_ADD 39 +#define TK_DROP 40 +#define TK_GRANT 41 +#define TK_ON 42 +#define TK_TO 43 +#define TK_REVOKE 44 +#define TK_FROM 45 +#define TK_SUBSCRIBE 46 +#define TK_READ 47 +#define TK_WRITE 48 +#define TK_NK_DOT 49 +#define TK_WITH 50 +#define TK_DNODE 51 +#define TK_PORT 52 +#define TK_DNODES 53 +#define TK_RESTORE 54 +#define TK_NK_IPTOKEN 55 +#define TK_FORCE 56 +#define TK_UNSAFE 57 +#define TK_CLUSTER 58 +#define TK_LOCAL 59 +#define TK_QNODE 60 +#define TK_BNODE 61 +#define TK_SNODE 62 +#define TK_MNODE 63 +#define TK_VNODE 64 +#define TK_DATABASE 65 +#define TK_USE 66 +#define TK_FLUSH 67 +#define TK_TRIM 68 +#define TK_S3MIGRATE 69 +#define TK_COMPACT 70 +#define TK_IF 71 +#define TK_NOT 72 +#define TK_EXISTS 73 +#define TK_BUFFER 74 +#define TK_CACHEMODEL 75 +#define TK_CACHESIZE 76 +#define TK_COMP 77 +#define TK_DURATION 78 +#define TK_NK_VARIABLE 79 +#define TK_MAXROWS 80 +#define TK_MINROWS 81 +#define TK_KEEP 82 +#define TK_PAGES 83 +#define TK_PAGESIZE 84 +#define TK_TSDB_PAGESIZE 85 +#define TK_PRECISION 86 +#define TK_REPLICA 87 +#define TK_VGROUPS 88 +#define TK_SINGLE_STABLE 89 +#define TK_RETENTIONS 90 +#define TK_SCHEMALESS 91 +#define TK_WAL_LEVEL 92 +#define TK_WAL_FSYNC_PERIOD 93 +#define TK_WAL_RETENTION_PERIOD 94 +#define TK_WAL_RETENTION_SIZE 95 +#define TK_WAL_ROLL_PERIOD 96 +#define TK_WAL_SEGMENT_SIZE 97 +#define TK_STT_TRIGGER 98 +#define TK_TABLE_PREFIX 99 +#define TK_TABLE_SUFFIX 100 +#define TK_S3_CHUNKSIZE 101 +#define TK_S3_KEEPLOCAL 102 +#define TK_S3_COMPACT 103 +#define TK_KEEP_TIME_OFFSET 104 +#define TK_NK_COLON 105 +#define TK_BWLIMIT 106 +#define TK_START 107 +#define TK_TIMESTAMP 108 +#define TK_END 109 +#define TK_TABLE 110 +#define TK_NK_LP 111 +#define TK_NK_RP 112 +#define TK_STABLE 113 +#define TK_COLUMN 114 +#define TK_MODIFY 115 +#define TK_RENAME 116 +#define TK_TAG 117 +#define TK_SET 118 +#define TK_NK_EQ 119 +#define TK_USING 120 +#define TK_TAGS 121 +#define TK_PRIMARY 122 +#define TK_KEY 123 +#define TK_BOOL 124 +#define TK_TINYINT 125 +#define TK_SMALLINT 126 +#define TK_INT 127 +#define TK_INTEGER 128 +#define TK_BIGINT 129 +#define TK_FLOAT 130 +#define TK_DOUBLE 131 +#define TK_BINARY 132 +#define TK_NCHAR 133 +#define TK_UNSIGNED 134 +#define TK_JSON 135 +#define TK_VARCHAR 136 +#define TK_MEDIUMBLOB 137 +#define TK_BLOB 138 +#define TK_VARBINARY 139 +#define TK_GEOMETRY 140 +#define TK_DECIMAL 141 +#define TK_COMMENT 142 +#define TK_MAX_DELAY 143 +#define TK_WATERMARK 144 +#define TK_ROLLUP 145 +#define TK_TTL 146 +#define TK_SMA 147 +#define TK_DELETE_MARK 148 +#define TK_FIRST 149 +#define TK_LAST 150 +#define TK_SHOW 151 +#define TK_PRIVILEGES 152 +#define TK_DATABASES 153 +#define TK_TABLES 154 +#define TK_STABLES 155 +#define TK_MNODES 156 +#define TK_QNODES 157 +#define TK_ARBGROUPS 158 +#define TK_FUNCTIONS 159 +#define TK_INDEXES 160 +#define TK_ACCOUNTS 161 +#define TK_APPS 162 +#define TK_CONNECTIONS 163 +#define TK_LICENCES 164 +#define TK_GRANTS 165 +#define TK_FULL 166 +#define TK_LOGS 167 +#define TK_MACHINES 168 +#define TK_QUERIES 169 +#define TK_SCORES 170 +#define TK_TOPICS 171 +#define TK_VARIABLES 172 +#define TK_BNODES 173 +#define TK_SNODES 174 +#define TK_TRANSACTIONS 175 +#define TK_DISTRIBUTED 176 +#define TK_CONSUMERS 177 +#define TK_SUBSCRIPTIONS 178 +#define TK_VNODES 179 +#define TK_ALIVE 180 +#define TK_VIEWS 181 +#define TK_VIEW 182 +#define TK_COMPACTS 183 +#define TK_NORMAL 184 +#define TK_CHILD 185 +#define TK_LIKE 186 +#define TK_TBNAME 187 +#define TK_QTAGS 188 +#define TK_AS 189 +#define TK_SYSTEM 190 +#define TK_TSMA 191 +#define TK_INTERVAL 192 +#define TK_RECURSIVE 193 +#define TK_TSMAS 194 +#define TK_FUNCTION 195 +#define TK_INDEX 196 +#define TK_COUNT 197 +#define TK_LAST_ROW 198 +#define TK_META 199 +#define TK_ONLY 200 +#define TK_TOPIC 201 +#define TK_CONSUMER 202 +#define TK_GROUP 203 +#define TK_DESC 204 +#define TK_DESCRIBE 205 +#define TK_RESET 206 +#define TK_QUERY 207 +#define TK_CACHE 208 +#define TK_EXPLAIN 209 +#define TK_ANALYZE 210 +#define TK_VERBOSE 211 +#define TK_NK_BOOL 212 +#define TK_RATIO 213 +#define TK_NK_FLOAT 214 +#define TK_OUTPUTTYPE 215 +#define TK_AGGREGATE 216 +#define TK_BUFSIZE 217 +#define TK_LANGUAGE 218 +#define TK_REPLACE 219 +#define TK_STREAM 220 +#define TK_INTO 221 +#define TK_PAUSE 222 +#define TK_RESUME 223 +#define TK_TRIGGER 224 +#define TK_AT_ONCE 225 +#define TK_WINDOW_CLOSE 226 +#define TK_IGNORE 227 +#define TK_EXPIRED 228 +#define TK_FILL_HISTORY 229 +#define TK_UPDATE 230 +#define TK_SUBTABLE 231 +#define TK_UNTREATED 232 +#define TK_KILL 233 +#define TK_CONNECTION 234 +#define TK_TRANSACTION 235 +#define TK_BALANCE 236 +#define TK_VGROUP 237 +#define TK_LEADER 238 +#define TK_MERGE 239 +#define TK_REDISTRIBUTE 240 +#define TK_SPLIT 241 +#define TK_DELETE 242 +#define TK_INSERT 243 +#define TK_NK_BIN 244 +#define TK_NK_HEX 245 +#define TK_NULL 246 +#define TK_NK_QUESTION 247 +#define TK_NK_ALIAS 248 +#define TK_NK_ARROW 249 +#define TK_ROWTS 250 +#define TK_QSTART 251 +#define TK_QEND 252 +#define TK_QDURATION 253 +#define TK_WSTART 254 +#define TK_WEND 255 +#define TK_WDURATION 256 +#define TK_IROWTS 257 +#define TK_ISFILLED 258 +#define TK_CAST 259 +#define TK_NOW 260 +#define TK_TODAY 261 +#define TK_TIMEZONE 262 +#define TK_CLIENT_VERSION 263 +#define TK_SERVER_VERSION 264 +#define TK_SERVER_STATUS 265 +#define TK_CURRENT_USER 266 +#define TK_CASE 267 +#define TK_WHEN 268 +#define TK_THEN 269 +#define TK_ELSE 270 +#define TK_BETWEEN 271 +#define TK_IS 272 +#define TK_NK_LT 273 +#define TK_NK_GT 274 +#define TK_NK_LE 275 +#define TK_NK_GE 276 +#define TK_NK_NE 277 +#define TK_MATCH 278 +#define TK_NMATCH 279 +#define TK_CONTAINS 280 +#define TK_IN 281 +#define TK_JOIN 282 +#define TK_INNER 283 +#define TK_LEFT 284 +#define TK_RIGHT 285 +#define TK_OUTER 286 +#define TK_SEMI 287 +#define TK_ANTI 288 +#define TK_ASOF 289 +#define TK_WINDOW 290 +#define TK_WINDOW_OFFSET 291 +#define TK_JLIMIT 292 +#define TK_SELECT 293 +#define TK_NK_HINT 294 +#define TK_DISTINCT 295 +#define TK_WHERE 296 +#define TK_PARTITION 297 +#define TK_BY 298 +#define TK_SESSION 299 +#define TK_STATE_WINDOW 300 +#define TK_EVENT_WINDOW 301 +#define TK_COUNT_WINDOW 302 +#define TK_SLIDING 303 +#define TK_FILL 304 +#define TK_VALUE 305 +#define TK_VALUE_F 306 +#define TK_NONE 307 +#define TK_PREV 308 +#define TK_NULL_F 309 +#define TK_LINEAR 310 +#define TK_NEXT 311 +#define TK_HAVING 312 +#define TK_RANGE 313 +#define TK_EVERY 314 +#define TK_ORDER 315 +#define TK_SLIMIT 316 +#define TK_SOFFSET 317 +#define TK_LIMIT 318 +#define TK_OFFSET 319 +#define TK_ASC 320 +#define TK_NULLS 321 +#define TK_ABORT 322 +#define TK_AFTER 323 +#define TK_ATTACH 324 +#define TK_BEFORE 325 +#define TK_BEGIN 326 +#define TK_BITAND 327 +#define TK_BITNOT 328 +#define TK_BITOR 329 +#define TK_BLOCKS 330 +#define TK_CHANGE 331 +#define TK_COMMA 332 +#define TK_CONCAT 333 +#define TK_CONFLICT 334 +#define TK_COPY 335 +#define TK_DEFERRED 336 +#define TK_DELIMITERS 337 +#define TK_DETACH 338 +#define TK_DIVIDE 339 +#define TK_DOT 340 +#define TK_EACH 341 +#define TK_FAIL 342 +#define TK_FILE 343 +#define TK_FOR 344 +#define TK_GLOB 345 +#define TK_ID 346 +#define TK_IMMEDIATE 347 +#define TK_IMPORT 348 +#define TK_INITIALLY 349 +#define TK_INSTEAD 350 +#define TK_ISNULL 351 +#define TK_MODULES 352 +#define TK_NK_BITNOT 353 +#define TK_NK_SEMI 354 +#define TK_NOTNULL 355 +#define TK_OF 356 +#define TK_PLUS 357 +#define TK_PRIVILEGE 358 +#define TK_RAISE 359 +#define TK_RESTRICT 360 +#define TK_ROW 361 +#define TK_STAR 362 +#define TK_STATEMENT 363 +#define TK_STRICT 364 +#define TK_STRING 365 +#define TK_TIMES 366 +#define TK_VALUES 367 +#define TK_VARIABLE 368 +#define TK_WAL 369 +#endif +/**************** End token definitions ***************************************/ /* The next sections is a series of control #defines. ** various aspects of the generated parser. @@ -104,30 +475,30 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 538 +#define YYNOCODE 544 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - SAlterOption yy5; - SShowTablesOption yy165; - SDataType yy232; - EFillMode yy318; - int8_t yy443; - int32_t yy488; - EJoinSubType yy506; - STokenPair yy525; - ENullOrder yy545; - EJoinType yy548; - EOrder yy670; - SNode* yy720; - int64_t yy817; - bool yy833; - SNodeList* yy984; - EOperatorType yy1024; - EShowKind yy1029; - SToken yy1045; + SNodeList* yy24; + SNode* yy40; + int64_t yy157; + EOrder yy258; + STokenPair yy505; + int32_t yy516; + ENullOrder yy585; + SDataType yy592; + EJoinType yy596; + EJoinSubType yy630; + SShowTablesOption yy685; + EOperatorType yy700; + SAlterOption yy733; + EShowKind yy769; + int8_t yy823; + SToken yy929; + EFillMode yy998; + bool yy1049; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -143,18 +514,18 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 918 -#define YYNRULE 726 -#define YYNRULE_WITH_ACTION 726 -#define YYNTOKEN 367 -#define YY_MAX_SHIFT 917 -#define YY_MIN_SHIFTREDUCE 1374 -#define YY_MAX_SHIFTREDUCE 2099 -#define YY_ERROR_ACTION 2100 -#define YY_ACCEPT_ACTION 2101 -#define YY_NO_ACTION 2102 -#define YY_MIN_REDUCE 2103 -#define YY_MAX_REDUCE 2828 +#define YYNSTATE 948 +#define YYNRULE 734 +#define YYNRULE_WITH_ACTION 734 +#define YYNTOKEN 370 +#define YY_MAX_SHIFT 947 +#define YY_MIN_SHIFTREDUCE 1408 +#define YY_MAX_SHIFTREDUCE 2141 +#define YY_ERROR_ACTION 2142 +#define YY_ACCEPT_ACTION 2143 +#define YY_NO_ACTION 2144 +#define YY_MIN_REDUCE 2145 +#define YY_MAX_REDUCE 2878 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -221,915 +592,936 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (3171) +#define YY_ACTTAB_COUNT (3232) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 2804, 2585, 760, 615, 705, 2445, 616, 2146, 2799, 184, - /* 10 */ 2799, 306, 47, 45, 2021, 520, 2585, 43, 42, 41, - /* 20 */ 447, 750, 1843, 2443, 802, 513, 2589, 2803, 759, 210, - /* 30 */ 512, 2800, 2802, 2800, 761, 1930, 2804, 1841, 2189, 1414, - /* 40 */ 1868, 2589, 473, 472, 40, 39, 2609, 2126, 46, 44, - /* 50 */ 43, 42, 41, 1871, 96, 9, 772, 149, 1421, 775, - /* 60 */ 2493, 580, 578, 1869, 397, 1925, 2103, 1850, 223, 2359, - /* 70 */ 2278, 419, 19, 2591, 2593, 444, 415, 66, 726, 1849, - /* 80 */ 2296, 1416, 1419, 1420, 819, 2357, 2799, 2627, 2591, 2594, - /* 90 */ 139, 138, 137, 136, 135, 134, 133, 132, 131, 819, - /* 100 */ 2575, 2575, 797, 623, 2805, 210, 616, 2146, 914, 2800, - /* 110 */ 761, 15, 889, 888, 887, 886, 476, 2716, 885, 884, - /* 120 */ 154, 879, 878, 877, 876, 875, 874, 873, 153, 867, - /* 130 */ 866, 865, 475, 474, 862, 861, 860, 190, 189, 859, - /* 140 */ 471, 858, 857, 2713, 2608, 2089, 814, 2647, 2065, 1932, - /* 150 */ 1933, 115, 2610, 801, 2612, 2613, 796, 191, 819, 760, - /* 160 */ 620, 2568, 2025, 193, 464, 2701, 617, 2799, 1868, 443, - /* 170 */ 2697, 186, 2709, 771, 468, 141, 770, 2352, 2354, 1996, - /* 180 */ 417, 696, 2425, 2799, 62, 759, 210, 1903, 1913, 211, - /* 190 */ 2800, 761, 1626, 1627, 1931, 1934, 694, 2748, 692, 277, - /* 200 */ 276, 759, 210, 2277, 772, 149, 2800, 761, 2104, 1844, - /* 210 */ 635, 1842, 854, 165, 164, 851, 850, 849, 162, 453, - /* 220 */ 40, 39, 311, 788, 46, 44, 43, 42, 41, 130, - /* 230 */ 819, 787, 129, 128, 127, 126, 125, 124, 123, 122, - /* 240 */ 121, 1853, 707, 1847, 1848, 1900, 1900, 1902, 1905, 1906, - /* 250 */ 1907, 1908, 1909, 1910, 1911, 1912, 793, 817, 816, 1924, - /* 260 */ 1926, 1927, 1928, 1929, 2, 47, 45, 529, 2421, 12, - /* 270 */ 395, 1843, 1866, 447, 856, 1843, 2292, 535, 2421, 563, - /* 280 */ 772, 149, 583, 709, 407, 245, 1841, 582, 1930, 618, - /* 290 */ 1841, 2154, 2721, 1993, 1994, 1995, 2721, 2721, 2721, 2721, - /* 300 */ 2721, 631, 33, 543, 1996, 584, 815, 2301, 40, 39, - /* 310 */ 396, 545, 46, 44, 43, 42, 41, 225, 1925, 119, - /* 320 */ 2709, 2710, 523, 147, 2714, 19, 214, 227, 1849, 815, - /* 330 */ 2301, 1959, 1849, 130, 453, 1904, 129, 128, 127, 126, - /* 340 */ 125, 124, 123, 122, 121, 819, 62, 40, 39, 140, - /* 350 */ 2125, 46, 44, 43, 42, 41, 658, 914, 1587, 1872, - /* 360 */ 764, 914, 418, 313, 15, 1998, 1999, 2000, 2001, 2002, - /* 370 */ 2569, 62, 706, 531, 1578, 844, 843, 842, 1582, 841, - /* 380 */ 1584, 1585, 840, 837, 2124, 1593, 834, 1595, 1596, 831, - /* 390 */ 828, 825, 2276, 1901, 774, 179, 2709, 2710, 1960, 147, - /* 400 */ 2714, 856, 1932, 1933, 2575, 2432, 2411, 2054, 571, 570, - /* 410 */ 569, 568, 567, 562, 561, 560, 559, 401, 1993, 1994, - /* 420 */ 1995, 549, 548, 547, 546, 540, 539, 538, 453, 533, - /* 430 */ 532, 416, 37, 317, 113, 524, 1686, 1687, 2575, 819, - /* 440 */ 1903, 1913, 1705, 511, 2378, 510, 710, 1931, 1934, 40, - /* 450 */ 39, 152, 203, 46, 44, 43, 42, 41, 1844, 2293, - /* 460 */ 1842, 177, 1844, 2115, 1842, 2346, 742, 741, 2052, 2053, - /* 470 */ 2055, 2056, 2057, 247, 29, 509, 2445, 618, 1849, 2154, - /* 480 */ 36, 445, 1954, 1955, 1956, 1957, 1958, 1962, 1963, 1964, - /* 490 */ 1965, 450, 1847, 1848, 2442, 802, 1847, 1848, 1900, 869, - /* 500 */ 1902, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 793, - /* 510 */ 817, 816, 1924, 1926, 1927, 1928, 1929, 2, 12, 47, - /* 520 */ 45, 2716, 625, 2484, 2804, 313, 176, 447, 206, 1843, - /* 530 */ 848, 371, 2799, 2350, 854, 165, 164, 851, 850, 849, - /* 540 */ 162, 2609, 1930, 705, 1841, 1868, 2046, 2712, 369, 75, - /* 550 */ 313, 2803, 74, 2066, 795, 2800, 2801, 35, 565, 2421, - /* 560 */ 2609, 2047, 398, 40, 39, 871, 1872, 46, 44, 43, - /* 570 */ 42, 41, 1925, 798, 243, 597, 595, 592, 590, 19, - /* 580 */ 815, 2301, 2627, 281, 1873, 1440, 1849, 1439, 772, 149, - /* 590 */ 46, 44, 43, 42, 41, 2575, 814, 797, 432, 2492, - /* 600 */ 140, 2627, 145, 2045, 710, 1587, 51, 663, 232, 459, - /* 610 */ 558, 557, 423, 422, 2575, 914, 797, 745, 15, 62, - /* 620 */ 1441, 1578, 844, 843, 842, 1582, 841, 1584, 1585, 792, - /* 630 */ 791, 612, 1593, 790, 1595, 1596, 789, 828, 825, 2608, - /* 640 */ 610, 765, 2647, 606, 602, 749, 387, 2610, 801, 2612, - /* 650 */ 2613, 796, 794, 819, 780, 2666, 1932, 1933, 2608, 63, - /* 660 */ 280, 2647, 1771, 1772, 279, 115, 2610, 801, 2612, 2613, - /* 670 */ 796, 872, 819, 2627, 2262, 151, 1940, 159, 2672, 2701, - /* 680 */ 712, 2484, 1868, 443, 2697, 1871, 1996, 50, 421, 420, - /* 690 */ 2394, 660, 40, 39, 1903, 1913, 46, 44, 43, 42, - /* 700 */ 41, 1931, 1934, 180, 2709, 2710, 847, 147, 2714, 85, - /* 710 */ 84, 516, 1698, 1699, 222, 662, 1844, 814, 1842, 661, - /* 720 */ 751, 746, 739, 735, 462, 40, 39, 508, 506, 46, - /* 730 */ 44, 43, 42, 41, 99, 201, 229, 404, 394, 748, - /* 740 */ 431, 495, 698, 356, 492, 488, 484, 481, 509, 574, - /* 750 */ 1847, 1848, 1900, 2192, 1902, 1905, 1906, 1907, 1908, 1909, - /* 760 */ 1910, 1911, 1912, 793, 817, 816, 1924, 1926, 1927, 1928, - /* 770 */ 1929, 2, 47, 45, 1935, 12, 2609, 10, 497, 2123, - /* 780 */ 447, 91, 1843, 1812, 90, 313, 632, 725, 700, 775, - /* 790 */ 699, 1873, 815, 2301, 263, 1930, 2609, 1841, 313, 2721, - /* 800 */ 1993, 1994, 1995, 2721, 2721, 2721, 2721, 2721, 50, 798, - /* 810 */ 185, 2156, 55, 458, 457, 466, 234, 2627, 174, 652, - /* 820 */ 648, 644, 640, 168, 262, 1925, 2304, 678, 677, 676, - /* 830 */ 2575, 2303, 797, 2575, 668, 146, 672, 2627, 2122, 1849, - /* 840 */ 671, 573, 233, 633, 2438, 670, 675, 426, 425, 1904, - /* 850 */ 2575, 669, 797, 89, 311, 424, 665, 664, 556, 40, - /* 860 */ 39, 846, 555, 46, 44, 43, 42, 41, 914, 97, - /* 870 */ 554, 48, 260, 117, 2608, 786, 2609, 2647, 433, 2492, - /* 880 */ 2359, 115, 2610, 801, 2612, 2613, 796, 442, 819, 798, - /* 890 */ 754, 2756, 2575, 193, 2608, 2701, 2357, 2647, 1811, 443, - /* 900 */ 2697, 115, 2610, 801, 2612, 2613, 796, 1901, 819, 1932, - /* 910 */ 1933, 2716, 501, 2819, 1440, 2701, 1439, 2627, 2096, 443, - /* 920 */ 2697, 1421, 815, 2301, 815, 2301, 60, 2749, 461, 460, - /* 930 */ 2575, 781, 797, 2673, 723, 2290, 1869, 2711, 2121, 503, - /* 940 */ 499, 250, 517, 2519, 518, 1419, 1420, 1903, 1913, 1441, - /* 950 */ 259, 252, 815, 2301, 1931, 1934, 2007, 257, 629, 1961, - /* 960 */ 40, 39, 1868, 2037, 46, 44, 43, 42, 41, 1844, - /* 970 */ 2286, 1842, 537, 1868, 2608, 2528, 249, 2647, 2529, 1872, - /* 980 */ 204, 115, 2610, 801, 2612, 2613, 796, 313, 819, 2609, - /* 990 */ 451, 703, 2575, 2819, 486, 2701, 321, 322, 174, 443, - /* 1000 */ 2697, 320, 798, 1847, 1848, 1900, 2303, 1902, 1905, 1906, - /* 1010 */ 1907, 1908, 1909, 1910, 1911, 1912, 793, 817, 816, 1924, - /* 1020 */ 1926, 1927, 1928, 1929, 2, 47, 45, 2609, 726, 175, - /* 1030 */ 2627, 726, 1541, 447, 2095, 1843, 2799, 2237, 2288, 2799, - /* 1040 */ 798, 34, 2769, 2575, 726, 797, 1951, 1540, 1930, 191, - /* 1050 */ 1841, 1966, 2799, 62, 2805, 210, 466, 2805, 210, 2800, - /* 1060 */ 761, 469, 2800, 761, 174, 1718, 1719, 1529, 2627, 174, - /* 1070 */ 2805, 210, 2303, 2609, 2426, 2800, 761, 2303, 1925, 2353, - /* 1080 */ 2354, 2575, 2497, 797, 815, 2301, 798, 2608, 737, 2120, - /* 1090 */ 2647, 2119, 1849, 2803, 115, 2610, 801, 2612, 2613, 796, - /* 1100 */ 685, 819, 815, 2301, 550, 2118, 2676, 2359, 2701, 1531, - /* 1110 */ 1717, 1720, 443, 2697, 2627, 697, 14, 13, 585, 2117, - /* 1120 */ 1423, 914, 551, 779, 48, 2608, 1867, 2575, 2647, 797, - /* 1130 */ 2284, 278, 115, 2610, 801, 2612, 2613, 796, 282, 819, - /* 1140 */ 1904, 711, 2359, 2575, 2819, 2575, 2701, 688, 205, 452, - /* 1150 */ 443, 2697, 815, 2301, 682, 680, 815, 2301, 2357, 2575, - /* 1160 */ 1545, 275, 1932, 1933, 854, 165, 164, 851, 850, 849, - /* 1170 */ 162, 2608, 552, 2575, 2647, 1544, 634, 2359, 115, 2610, - /* 1180 */ 801, 2612, 2613, 796, 467, 819, 1872, 2114, 1443, 1444, - /* 1190 */ 2819, 2113, 2701, 2357, 726, 2112, 443, 2697, 1901, 2111, - /* 1200 */ 1903, 1913, 2799, 288, 1873, 2110, 71, 1931, 1934, 70, - /* 1210 */ 678, 677, 676, 815, 2301, 815, 2301, 668, 146, 672, - /* 1220 */ 2805, 210, 1844, 671, 1842, 2800, 761, 1973, 670, 675, - /* 1230 */ 426, 425, 313, 2298, 669, 283, 654, 653, 424, 665, - /* 1240 */ 664, 2575, 2609, 662, 776, 2575, 587, 661, 2109, 2575, - /* 1250 */ 656, 655, 2108, 2575, 1868, 798, 1847, 1848, 1900, 2575, - /* 1260 */ 1902, 1905, 1906, 1907, 1908, 1909, 1910, 1911, 1912, 793, - /* 1270 */ 817, 816, 1924, 1926, 1927, 1928, 1929, 2, 47, 45, - /* 1280 */ 2609, 674, 673, 2627, 815, 2301, 447, 2018, 1843, 815, - /* 1290 */ 2301, 815, 2301, 798, 107, 2792, 2575, 726, 797, 2107, - /* 1300 */ 2516, 1930, 2575, 1841, 291, 2799, 2575, 815, 2301, 778, - /* 1310 */ 2106, 325, 815, 2301, 767, 815, 2301, 2359, 783, 2294, - /* 1320 */ 2673, 2627, 150, 2805, 210, 2672, 2609, 812, 2800, 761, - /* 1330 */ 96, 1925, 813, 810, 2575, 352, 797, 815, 2301, 798, - /* 1340 */ 2608, 2733, 2101, 2647, 100, 1849, 163, 115, 2610, 801, - /* 1350 */ 2612, 2613, 796, 2575, 819, 852, 2297, 470, 2350, 2674, - /* 1360 */ 2359, 2701, 883, 881, 2575, 443, 2697, 2627, 853, 365, - /* 1370 */ 2404, 2350, 2336, 2279, 914, 1746, 2358, 15, 2608, 3, - /* 1380 */ 2575, 2647, 797, 2238, 666, 115, 2610, 801, 2612, 2613, - /* 1390 */ 796, 53, 819, 2131, 909, 473, 472, 2819, 142, 2701, - /* 1400 */ 77, 2762, 763, 443, 2697, 1857, 155, 156, 1523, 1525, - /* 1410 */ 87, 1873, 527, 156, 2116, 1932, 1933, 292, 1930, 268, - /* 1420 */ 1850, 733, 266, 479, 2608, 54, 270, 2647, 478, 269, - /* 1430 */ 184, 115, 2610, 801, 2612, 2613, 796, 272, 819, 2609, - /* 1440 */ 271, 274, 667, 2819, 273, 2701, 2176, 2174, 1925, 443, - /* 1450 */ 2697, 1526, 798, 1903, 1913, 88, 2165, 49, 112, 49, - /* 1460 */ 1931, 1934, 1849, 2163, 1504, 101, 1521, 109, 679, 681, - /* 1470 */ 1477, 194, 2596, 2098, 2099, 1844, 726, 1842, 683, 1901, - /* 1480 */ 2627, 163, 14, 13, 2799, 686, 1762, 64, 49, 1852, - /* 1490 */ 49, 785, 1769, 2575, 319, 797, 1851, 76, 331, 330, - /* 1500 */ 2041, 743, 2805, 210, 333, 332, 1505, 2800, 761, 1847, - /* 1510 */ 1848, 1900, 1478, 1902, 1905, 1906, 1907, 1908, 1909, 1910, - /* 1520 */ 1911, 1912, 793, 817, 816, 1924, 1926, 1927, 1928, 1929, - /* 1530 */ 2, 307, 400, 399, 2598, 216, 2051, 2608, 2050, 73, - /* 1540 */ 2647, 161, 454, 163, 115, 2610, 801, 2612, 2613, 796, - /* 1550 */ 297, 819, 823, 335, 334, 1930, 782, 463, 2701, 161, - /* 1560 */ 777, 773, 443, 2697, 337, 336, 1967, 1914, 163, 1715, - /* 1570 */ 339, 338, 299, 323, 144, 2017, 807, 143, 2609, 341, - /* 1580 */ 340, 161, 343, 342, 1587, 1925, 345, 344, 347, 346, - /* 1590 */ 2628, 798, 1858, 2231, 1853, 349, 348, 768, 351, 350, - /* 1600 */ 1578, 844, 843, 842, 1582, 841, 1584, 1585, 840, 837, - /* 1610 */ 2609, 1593, 834, 1595, 1596, 831, 828, 825, 364, 2627, - /* 1620 */ 327, 2157, 1571, 798, 863, 864, 1861, 1863, 2230, 2430, - /* 1630 */ 2147, 1600, 2575, 2752, 797, 740, 438, 747, 1608, 477, - /* 1640 */ 817, 816, 1924, 1926, 1927, 1928, 1929, 1615, 1496, 1494, - /* 1650 */ 434, 2627, 804, 2431, 2153, 2347, 1613, 719, 2753, 2763, - /* 1660 */ 166, 755, 756, 1855, 2575, 304, 797, 312, 309, 2263, - /* 1670 */ 1854, 5, 480, 907, 485, 413, 2608, 1876, 493, 2647, - /* 1680 */ 494, 218, 504, 116, 2610, 801, 2612, 2613, 796, 217, - /* 1690 */ 819, 505, 2609, 507, 220, 1739, 359, 2701, 1866, 521, - /* 1700 */ 1867, 2700, 2697, 528, 231, 798, 530, 536, 701, 534, - /* 1710 */ 576, 2647, 2609, 553, 541, 383, 2610, 801, 2612, 2613, - /* 1720 */ 796, 564, 819, 2423, 566, 798, 572, 575, 577, 1834, - /* 1730 */ 589, 1810, 2609, 2627, 588, 586, 237, 236, 591, 593, - /* 1740 */ 240, 594, 596, 598, 1874, 798, 2575, 4, 797, 624, - /* 1750 */ 613, 2609, 621, 2627, 248, 614, 1869, 93, 622, 626, - /* 1760 */ 251, 456, 455, 1835, 798, 1875, 2575, 1877, 797, 627, - /* 1770 */ 630, 628, 1878, 2627, 2439, 254, 657, 817, 816, 1924, - /* 1780 */ 1926, 1927, 1928, 1929, 256, 94, 2575, 95, 797, 636, - /* 1790 */ 2608, 261, 2627, 2647, 689, 118, 702, 116, 2610, 801, - /* 1800 */ 2612, 2613, 796, 659, 819, 2575, 2291, 797, 265, 2287, - /* 1810 */ 799, 2701, 690, 2647, 267, 784, 2697, 116, 2610, 801, - /* 1820 */ 2612, 2613, 796, 169, 819, 170, 2289, 2285, 171, 172, - /* 1830 */ 2608, 2701, 2609, 2647, 2506, 406, 2697, 178, 2610, 801, - /* 1840 */ 2612, 2613, 796, 391, 819, 798, 2503, 1870, 98, 2608, - /* 1850 */ 360, 704, 2647, 157, 2502, 284, 181, 2610, 801, 2612, - /* 1860 */ 2613, 796, 714, 819, 2609, 2485, 715, 713, 718, 289, - /* 1870 */ 744, 721, 2768, 2627, 720, 287, 294, 798, 805, 296, - /* 1880 */ 8, 2767, 753, 731, 727, 2759, 2575, 2740, 797, 730, - /* 1890 */ 729, 2609, 728, 303, 2822, 758, 757, 439, 766, 769, - /* 1900 */ 148, 298, 1871, 2015, 798, 2627, 183, 2013, 61, 2720, - /* 1910 */ 305, 197, 314, 361, 301, 762, 2820, 2717, 2575, 158, - /* 1920 */ 797, 300, 302, 1, 2682, 803, 2453, 2452, 2451, 362, - /* 1930 */ 2608, 449, 2627, 2647, 808, 809, 160, 116, 2610, 801, - /* 1940 */ 2612, 2613, 796, 363, 819, 2575, 212, 797, 106, 2302, - /* 1950 */ 308, 2701, 2567, 2566, 108, 2562, 2698, 2561, 2553, 2798, - /* 1960 */ 821, 2552, 2608, 2544, 2543, 2647, 2559, 436, 1398, 178, - /* 1970 */ 2610, 801, 2612, 2613, 796, 2609, 819, 2558, 2550, 2549, - /* 1980 */ 2538, 2537, 366, 354, 2556, 2555, 2547, 2546, 798, 2608, - /* 1990 */ 911, 908, 2647, 167, 913, 52, 388, 2610, 801, 2612, - /* 2000 */ 2613, 796, 378, 819, 389, 2609, 2535, 390, 411, 379, - /* 2010 */ 368, 2534, 2532, 2531, 2351, 2527, 2627, 2760, 798, 370, - /* 2020 */ 412, 2526, 2525, 82, 2520, 482, 483, 1794, 1795, 2575, - /* 2030 */ 215, 797, 487, 2518, 489, 490, 491, 1793, 2517, 414, - /* 2040 */ 2515, 496, 2514, 2513, 498, 500, 2627, 2512, 502, 1782, - /* 2050 */ 2489, 437, 219, 2488, 221, 1742, 83, 1741, 2466, 2575, - /* 2060 */ 2465, 797, 2464, 514, 515, 2463, 2462, 2413, 519, 1685, - /* 2070 */ 2410, 522, 2409, 2608, 2403, 2400, 2647, 526, 525, 2399, - /* 2080 */ 388, 2610, 801, 2612, 2613, 796, 224, 819, 2398, 86, - /* 2090 */ 2397, 2402, 2401, 2396, 226, 2395, 2609, 2393, 2392, 2391, - /* 2100 */ 228, 542, 2390, 2608, 544, 2388, 2647, 2387, 2386, 798, - /* 2110 */ 381, 2610, 801, 2612, 2613, 796, 2609, 819, 2385, 2408, - /* 2120 */ 2384, 2383, 2382, 2406, 2389, 2381, 2380, 2379, 2377, 795, - /* 2130 */ 230, 2371, 92, 2609, 2376, 2375, 2374, 2627, 2373, 2372, - /* 2140 */ 2370, 2369, 2368, 2367, 2407, 2405, 798, 2366, 2365, 2364, - /* 2150 */ 2575, 1691, 797, 235, 2363, 579, 2362, 2627, 2361, 2360, - /* 2160 */ 581, 752, 402, 403, 2196, 238, 2195, 2194, 1542, 239, - /* 2170 */ 2575, 241, 797, 1546, 2627, 2193, 242, 2191, 2188, 601, - /* 2180 */ 2187, 2180, 2167, 600, 604, 2142, 1422, 2575, 2141, 797, - /* 2190 */ 1538, 2487, 599, 2483, 2608, 244, 2473, 2647, 603, 605, - /* 2200 */ 607, 181, 2610, 801, 2612, 2613, 796, 609, 819, 446, - /* 2210 */ 611, 608, 79, 2461, 2608, 2460, 2609, 2647, 708, 192, - /* 2220 */ 2595, 387, 2610, 801, 2612, 2613, 796, 255, 819, 798, - /* 2230 */ 2667, 2608, 202, 619, 2647, 2609, 917, 80, 388, 2610, - /* 2240 */ 801, 2612, 2613, 796, 246, 819, 253, 258, 798, 2437, - /* 2250 */ 2280, 2190, 358, 2186, 638, 637, 639, 2627, 2184, 641, - /* 2260 */ 1470, 2821, 2609, 642, 2182, 643, 645, 646, 200, 647, - /* 2270 */ 2575, 2179, 797, 649, 651, 798, 2627, 905, 901, 897, - /* 2280 */ 893, 650, 355, 2162, 2160, 2161, 2159, 2138, 2282, 2575, - /* 2290 */ 1619, 797, 448, 72, 1620, 2281, 264, 1528, 1527, 1524, - /* 2300 */ 1522, 1511, 1520, 2627, 1519, 2177, 1518, 1517, 880, 1516, - /* 2310 */ 882, 1513, 427, 1512, 2608, 2175, 2575, 2647, 797, 1510, - /* 2320 */ 428, 388, 2610, 801, 2612, 2613, 796, 114, 819, 2166, - /* 2330 */ 328, 429, 2164, 2608, 684, 430, 2647, 687, 2609, 2137, - /* 2340 */ 373, 2610, 801, 2612, 2613, 796, 2136, 819, 2135, 691, - /* 2350 */ 2134, 798, 2133, 693, 120, 695, 1776, 1778, 1775, 1780, - /* 2360 */ 2608, 706, 2482, 2647, 811, 28, 2486, 372, 2610, 801, - /* 2370 */ 2612, 2613, 796, 286, 819, 1766, 2609, 67, 56, 2627, - /* 2380 */ 1748, 57, 1750, 2472, 1752, 716, 717, 2459, 173, 798, - /* 2390 */ 2458, 290, 2575, 732, 797, 1727, 722, 1726, 2804, 6, - /* 2400 */ 2609, 724, 20, 30, 17, 2068, 2042, 293, 316, 435, - /* 2410 */ 734, 736, 21, 798, 7, 315, 295, 2627, 738, 22, - /* 2420 */ 2049, 182, 2609, 207, 196, 195, 2596, 32, 31, 81, - /* 2430 */ 2575, 208, 797, 2008, 285, 798, 2608, 2036, 2006, 2647, - /* 2440 */ 2010, 2627, 209, 374, 2610, 801, 2612, 2613, 796, 2088, - /* 2450 */ 819, 65, 2089, 24, 2575, 2083, 797, 23, 2082, 440, - /* 2460 */ 2087, 2086, 441, 2627, 18, 1990, 310, 1989, 59, 58, - /* 2470 */ 2457, 2436, 103, 25, 2608, 187, 2575, 2647, 797, 102, - /* 2480 */ 1942, 380, 2610, 801, 2612, 2613, 796, 11, 819, 13, - /* 2490 */ 1941, 1859, 188, 198, 1917, 1893, 1916, 1915, 2608, 1952, - /* 2500 */ 2609, 2647, 2435, 830, 833, 384, 2610, 801, 2612, 2613, - /* 2510 */ 796, 836, 819, 798, 1885, 839, 38, 16, 26, 800, - /* 2520 */ 2608, 27, 199, 2647, 318, 2044, 324, 375, 2610, 801, - /* 2530 */ 2612, 2613, 796, 104, 819, 806, 326, 329, 69, 105, - /* 2540 */ 820, 2627, 2652, 2651, 822, 1919, 1601, 818, 68, 109, - /* 2550 */ 465, 1598, 824, 826, 2575, 829, 797, 827, 832, 1597, - /* 2560 */ 835, 1594, 1588, 1586, 838, 353, 110, 1614, 111, 78, - /* 2570 */ 1610, 1468, 2609, 855, 1507, 1506, 1592, 1577, 845, 1591, - /* 2580 */ 1503, 1500, 1499, 1498, 1497, 798, 1590, 1589, 1495, 2609, - /* 2590 */ 1493, 1492, 1491, 1536, 868, 870, 1535, 213, 2608, 1489, - /* 2600 */ 1488, 2647, 798, 1487, 1486, 385, 2610, 801, 2612, 2613, - /* 2610 */ 796, 2609, 819, 2627, 1485, 1484, 1483, 1530, 1532, 1474, - /* 2620 */ 1480, 1479, 1476, 2185, 798, 1475, 2575, 1473, 797, 890, - /* 2630 */ 2627, 892, 891, 2183, 2181, 894, 896, 898, 895, 2178, - /* 2640 */ 902, 900, 899, 2575, 903, 797, 904, 2158, 2609, 906, - /* 2650 */ 1411, 2132, 2627, 1399, 910, 2102, 916, 357, 912, 2102, - /* 2660 */ 1845, 798, 367, 915, 2102, 2575, 2102, 797, 2102, 2102, - /* 2670 */ 2608, 2102, 2102, 2647, 2102, 2102, 2102, 376, 2610, 801, - /* 2680 */ 2612, 2613, 796, 2102, 819, 2102, 2102, 2608, 2102, 2627, - /* 2690 */ 2647, 2102, 2102, 2102, 386, 2610, 801, 2612, 2613, 796, - /* 2700 */ 2102, 819, 2575, 2102, 797, 2102, 2102, 2102, 2102, 2608, - /* 2710 */ 2102, 2609, 2647, 2102, 2102, 2102, 377, 2610, 801, 2612, - /* 2720 */ 2613, 796, 2102, 819, 798, 2102, 2102, 2102, 2102, 2102, - /* 2730 */ 2102, 2609, 2102, 2102, 2102, 2102, 2102, 2102, 2102, 2102, - /* 2740 */ 2102, 2102, 2102, 2102, 798, 2102, 2608, 2102, 2102, 2647, - /* 2750 */ 2609, 2102, 2627, 392, 2610, 801, 2612, 2613, 796, 2102, - /* 2760 */ 819, 2102, 2102, 798, 2102, 2575, 2102, 797, 2102, 2102, - /* 2770 */ 2102, 2102, 2627, 2102, 2102, 2102, 2102, 2102, 2102, 2102, - /* 2780 */ 2102, 2102, 2102, 2102, 2102, 2575, 2102, 797, 2102, 2102, - /* 2790 */ 2102, 2627, 2102, 2102, 2102, 2102, 2102, 2102, 2102, 2102, - /* 2800 */ 2102, 2102, 2102, 2102, 2575, 2102, 797, 2102, 2102, 2608, - /* 2810 */ 2102, 2102, 2647, 2102, 2102, 2102, 393, 2610, 801, 2612, - /* 2820 */ 2613, 796, 2102, 819, 2102, 2102, 2102, 2102, 2102, 2608, - /* 2830 */ 2102, 2102, 2647, 2102, 2609, 2102, 2621, 2610, 801, 2612, - /* 2840 */ 2613, 796, 2102, 819, 2102, 2102, 2102, 798, 2608, 2102, - /* 2850 */ 2102, 2647, 2609, 2102, 2102, 2620, 2610, 801, 2612, 2613, - /* 2860 */ 796, 2102, 819, 2102, 2102, 798, 2102, 2102, 2102, 2609, - /* 2870 */ 2102, 2102, 2102, 2102, 2102, 2627, 2102, 2102, 2102, 2102, - /* 2880 */ 2102, 2102, 798, 2102, 2102, 2102, 2102, 2102, 2575, 2102, - /* 2890 */ 797, 2102, 2102, 2627, 2102, 2102, 2102, 2102, 2102, 2102, - /* 2900 */ 2102, 2102, 2102, 2102, 2102, 2102, 2575, 2102, 797, 2102, - /* 2910 */ 2627, 2102, 2102, 2102, 2102, 2102, 2102, 2102, 2102, 2102, - /* 2920 */ 2102, 2102, 2102, 2575, 2102, 797, 2102, 2102, 2102, 2102, - /* 2930 */ 2102, 2102, 2608, 2102, 2102, 2647, 2102, 2102, 2102, 2619, - /* 2940 */ 2610, 801, 2612, 2613, 796, 2102, 819, 2102, 2102, 2102, - /* 2950 */ 2608, 2102, 2102, 2647, 2102, 2102, 2609, 408, 2610, 801, - /* 2960 */ 2612, 2613, 796, 2102, 819, 2102, 2102, 2608, 2102, 798, - /* 2970 */ 2647, 2102, 2609, 2102, 409, 2610, 801, 2612, 2613, 796, - /* 2980 */ 2102, 819, 2102, 2102, 2102, 798, 2102, 2102, 2102, 2102, - /* 2990 */ 2102, 2102, 2102, 2102, 2102, 2609, 2102, 2627, 2102, 2102, - /* 3000 */ 2102, 2102, 2102, 2102, 2102, 2102, 2102, 2102, 798, 2102, - /* 3010 */ 2575, 2102, 797, 2627, 2102, 2102, 2102, 2102, 2102, 2102, - /* 3020 */ 2102, 2102, 2102, 2102, 2102, 2102, 2575, 2102, 797, 2102, - /* 3030 */ 2102, 2102, 2102, 2102, 2102, 2102, 2627, 2102, 2102, 2102, - /* 3040 */ 2102, 2102, 2102, 2102, 2102, 2102, 2102, 2102, 2102, 2575, - /* 3050 */ 2102, 797, 2102, 2102, 2608, 2102, 2102, 2647, 2609, 2102, - /* 3060 */ 2102, 405, 2610, 801, 2612, 2613, 796, 2102, 819, 2102, - /* 3070 */ 2608, 798, 2102, 2647, 2102, 2102, 2102, 410, 2610, 801, - /* 3080 */ 2612, 2613, 796, 2102, 819, 2102, 2102, 2102, 2102, 2102, - /* 3090 */ 2102, 2102, 2102, 799, 2102, 2102, 2647, 2102, 2102, 2627, - /* 3100 */ 383, 2610, 801, 2612, 2613, 796, 2102, 819, 2102, 2102, - /* 3110 */ 2102, 2102, 2575, 2102, 797, 2102, 2102, 2102, 2102, 2102, - /* 3120 */ 2102, 2102, 2102, 2102, 2102, 2102, 2102, 2102, 2102, 2102, - /* 3130 */ 2102, 2102, 2102, 2102, 2102, 2102, 2102, 2102, 2102, 2102, - /* 3140 */ 2102, 2102, 2102, 2102, 2102, 2102, 2102, 2102, 2102, 2102, - /* 3150 */ 2102, 2102, 2102, 2102, 2102, 2102, 2608, 2102, 2102, 2647, - /* 3160 */ 2102, 2102, 2102, 382, 2610, 801, 2612, 2613, 796, 2102, - /* 3170 */ 819, + /* 0 */ 37, 335, 2617, 2436, 630, 478, 876, 631, 2188, 2401, + /* 10 */ 480, 2494, 47, 45, 2063, 249, 455, 33, 172, 633, + /* 20 */ 462, 2196, 1884, 40, 39, 2399, 2345, 46, 44, 43, + /* 30 */ 42, 41, 2492, 835, 188, 1972, 312, 1882, 2231, 46, + /* 40 */ 44, 43, 42, 41, 40, 39, 790, 153, 46, 44, + /* 50 */ 43, 42, 41, 768, 40, 39, 9, 2146, 46, 44, + /* 60 */ 43, 42, 41, 467, 2401, 1967, 369, 436, 435, 29, + /* 70 */ 66, 466, 19, 2143, 849, 1909, 446, 2541, 134, 1890, + /* 80 */ 2399, 133, 132, 131, 130, 129, 128, 127, 126, 125, + /* 90 */ 845, 2343, 638, 2401, 134, 631, 2188, 133, 132, 131, + /* 100 */ 130, 129, 128, 127, 126, 125, 2577, 233, 944, 797, + /* 110 */ 144, 15, 919, 918, 917, 916, 490, 676, 915, 914, + /* 120 */ 158, 909, 908, 907, 906, 905, 904, 903, 157, 897, + /* 130 */ 896, 895, 489, 488, 892, 891, 890, 194, 193, 889, + /* 140 */ 485, 888, 887, 434, 433, 844, 678, 251, 2108, 1974, + /* 150 */ 1975, 633, 92, 2196, 1910, 91, 179, 493, 2107, 744, + /* 160 */ 3, 384, 492, 62, 190, 2759, 789, 2849, 145, 788, + /* 170 */ 680, 570, 53, 2334, 679, 569, 2849, 62, 382, 76, + /* 180 */ 2038, 2494, 75, 568, 727, 2855, 214, 1945, 1955, 767, + /* 190 */ 2850, 779, 411, 1563, 777, 214, 457, 1973, 1976, 2850, + /* 200 */ 779, 2145, 2491, 835, 247, 612, 610, 607, 605, 1474, + /* 210 */ 744, 1473, 1885, 646, 1883, 40, 39, 2677, 2849, 46, + /* 220 */ 44, 43, 42, 41, 90, 143, 142, 141, 140, 139, + /* 230 */ 138, 137, 136, 135, 467, 1565, 2855, 214, 1913, 286, + /* 240 */ 51, 2850, 779, 285, 1475, 849, 1888, 1889, 1942, 62, + /* 250 */ 1944, 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954, 826, + /* 260 */ 847, 846, 1966, 1968, 1969, 1970, 1971, 2, 47, 45, + /* 270 */ 1474, 649, 1473, 409, 1909, 1907, 462, 726, 1884, 422, + /* 280 */ 2038, 1942, 577, 1759, 1760, 598, 766, 149, 2218, 63, + /* 290 */ 597, 1972, 195, 1882, 723, 947, 2771, 2035, 2036, 2037, + /* 300 */ 2771, 2771, 2771, 2771, 2771, 1475, 557, 207, 599, 2634, + /* 310 */ 697, 371, 635, 410, 559, 430, 101, 2467, 632, 417, + /* 320 */ 2388, 1967, 444, 1912, 716, 537, 2001, 204, 19, 790, + /* 330 */ 153, 1758, 1761, 2168, 2638, 1890, 935, 931, 927, 923, + /* 340 */ 2167, 368, 86, 85, 530, 319, 653, 226, 2494, 2618, + /* 350 */ 40, 39, 445, 2541, 46, 44, 43, 42, 41, 319, + /* 360 */ 522, 520, 1913, 464, 944, 431, 2854, 15, 2853, 2491, + /* 370 */ 835, 408, 2038, 714, 509, 647, 545, 506, 502, 498, + /* 380 */ 495, 523, 844, 1912, 2640, 2643, 118, 2624, 712, 341, + /* 390 */ 710, 283, 282, 2002, 2624, 849, 2771, 2035, 2036, 2037, + /* 400 */ 2771, 2771, 2771, 2771, 2771, 1974, 1975, 205, 2474, 2453, + /* 410 */ 467, 585, 584, 583, 582, 581, 576, 575, 574, 573, + /* 420 */ 414, 849, 319, 806, 563, 562, 561, 560, 554, 553, + /* 430 */ 552, 319, 547, 546, 429, 2060, 648, 2487, 538, 1720, + /* 440 */ 1721, 1732, 1733, 1945, 1955, 1739, 792, 183, 2759, 2760, + /* 450 */ 35, 151, 2764, 1973, 1976, 482, 40, 39, 2394, 2396, + /* 460 */ 46, 44, 43, 42, 41, 886, 1914, 339, 1885, 812, + /* 470 */ 1883, 725, 322, 50, 181, 2131, 2157, 321, 36, 460, + /* 480 */ 1996, 1997, 1998, 1999, 2000, 2004, 2005, 2006, 2007, 2035, + /* 490 */ 2036, 2037, 317, 40, 39, 1890, 291, 46, 44, 43, + /* 500 */ 42, 41, 1888, 1889, 1942, 12, 1944, 1947, 1948, 1949, + /* 510 */ 1950, 1951, 1952, 1953, 1954, 826, 847, 846, 1966, 1968, + /* 520 */ 1969, 1970, 1971, 2, 12, 47, 45, 2395, 2396, 2401, + /* 530 */ 2659, 210, 1884, 462, 2088, 1884, 428, 1621, 2040, 2041, + /* 540 */ 2042, 2043, 2044, 793, 877, 2399, 844, 1882, 1972, 2089, + /* 550 */ 1882, 724, 317, 1612, 874, 873, 872, 1616, 871, 1618, + /* 560 */ 1619, 870, 867, 195, 1627, 864, 1629, 1630, 861, 858, + /* 570 */ 855, 2677, 703, 543, 2463, 40, 39, 1621, 1967, 46, + /* 580 */ 44, 43, 42, 41, 2624, 19, 830, 715, 2468, 1890, + /* 590 */ 1914, 2087, 1890, 1612, 874, 873, 872, 1616, 871, 1618, + /* 600 */ 1619, 825, 824, 284, 1627, 823, 1629, 1630, 822, 858, + /* 610 */ 855, 2234, 534, 2568, 1910, 589, 627, 728, 944, 706, + /* 620 */ 2319, 944, 778, 229, 15, 625, 700, 698, 621, 617, + /* 630 */ 2849, 2658, 650, 281, 2697, 487, 486, 50, 119, 2660, + /* 640 */ 834, 2662, 2663, 829, 2332, 849, 845, 2343, 777, 214, + /* 650 */ 197, 511, 2751, 2850, 779, 319, 458, 2747, 595, 593, + /* 660 */ 1891, 404, 1974, 1975, 500, 227, 144, 527, 2067, 728, + /* 670 */ 2096, 1909, 526, 681, 1909, 2645, 215, 1982, 72, 2079, + /* 680 */ 781, 71, 238, 1909, 2798, 696, 695, 694, 2481, 2138, + /* 690 */ 651, 886, 686, 150, 690, 723, 640, 2533, 689, 2659, + /* 700 */ 1945, 1955, 2328, 688, 693, 439, 438, 588, 237, 687, + /* 710 */ 1973, 1976, 831, 437, 683, 682, 845, 2343, 845, 2343, + /* 720 */ 744, 586, 1885, 763, 1883, 1885, 2059, 1883, 2849, 760, + /* 730 */ 759, 2094, 2095, 2097, 2098, 2099, 218, 2647, 55, 12, + /* 740 */ 2677, 10, 821, 1660, 1661, 2659, 2855, 214, 730, 2533, + /* 750 */ 820, 2850, 779, 2624, 2542, 830, 1888, 1889, 793, 1888, + /* 760 */ 1889, 1942, 62, 1944, 1947, 1948, 1949, 1950, 1951, 1952, + /* 770 */ 1953, 1954, 826, 847, 846, 1966, 1968, 1969, 1970, 1971, + /* 780 */ 2, 47, 45, 1977, 102, 473, 2677, 1575, 515, 462, + /* 790 */ 2578, 1884, 884, 169, 168, 881, 880, 879, 166, 2624, + /* 800 */ 2658, 830, 1574, 2697, 1972, 2137, 1882, 119, 2660, 834, + /* 810 */ 2662, 2663, 829, 899, 849, 517, 513, 155, 1787, 164, + /* 820 */ 2722, 2751, 111, 62, 2166, 458, 2747, 2659, 2320, 2330, + /* 830 */ 769, 764, 757, 753, 1967, 98, 2165, 1894, 549, 2463, + /* 840 */ 831, 1946, 2198, 744, 845, 2343, 2658, 2336, 1890, 2697, + /* 850 */ 1946, 2849, 432, 119, 2660, 834, 2662, 2663, 829, 902, + /* 860 */ 849, 2338, 2304, 2003, 531, 197, 2318, 2751, 2677, 2855, + /* 870 */ 214, 458, 2747, 600, 2850, 779, 2659, 944, 2624, 901, + /* 880 */ 48, 2624, 2420, 830, 2766, 696, 695, 694, 231, 831, + /* 890 */ 2624, 2806, 686, 150, 690, 2766, 845, 2343, 689, 2799, + /* 900 */ 845, 2343, 1943, 688, 693, 439, 438, 2164, 1448, 687, + /* 910 */ 2763, 1943, 2216, 437, 683, 682, 532, 2677, 1974, 1975, + /* 920 */ 551, 2762, 1909, 525, 814, 524, 2723, 1455, 2658, 2326, + /* 930 */ 2624, 2697, 830, 778, 699, 119, 2660, 834, 2662, 2663, + /* 940 */ 829, 2849, 849, 2163, 319, 790, 153, 2869, 34, 2751, + /* 950 */ 1450, 1453, 1454, 458, 2747, 523, 1945, 1955, 2008, 777, + /* 960 */ 214, 2624, 1853, 294, 2850, 779, 1973, 1976, 208, 476, + /* 970 */ 884, 169, 168, 881, 880, 879, 166, 2658, 790, 153, + /* 980 */ 2697, 1885, 117, 1883, 119, 2660, 834, 2662, 2663, 829, + /* 990 */ 721, 849, 472, 471, 579, 2463, 2869, 2624, 2751, 156, + /* 1000 */ 2162, 878, 458, 2747, 2392, 319, 78, 2335, 884, 169, + /* 1010 */ 168, 881, 880, 879, 166, 1888, 1889, 1942, 2546, 1944, + /* 1020 */ 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954, 826, 847, + /* 1030 */ 846, 1966, 1968, 1969, 1970, 1971, 2, 47, 45, 2401, + /* 1040 */ 1913, 729, 180, 744, 236, 462, 481, 1884, 572, 571, + /* 1050 */ 2279, 2849, 845, 2343, 2624, 2399, 845, 2343, 2659, 2161, + /* 1060 */ 1972, 89, 1882, 123, 2759, 2760, 287, 151, 2764, 2855, + /* 1070 */ 214, 831, 564, 2819, 2850, 779, 565, 288, 2659, 2766, + /* 1080 */ 40, 39, 1455, 819, 46, 44, 43, 42, 41, 1946, + /* 1090 */ 1967, 831, 1477, 1478, 744, 465, 184, 2759, 2760, 2677, + /* 1100 */ 151, 2764, 2849, 178, 1890, 2761, 1453, 1454, 743, 178, + /* 1110 */ 2854, 2345, 2624, 2624, 830, 845, 2343, 2346, 2849, 2677, + /* 1120 */ 2855, 214, 2280, 40, 39, 2850, 779, 46, 44, 43, + /* 1130 */ 42, 41, 2624, 944, 830, 566, 48, 2853, 845, 2343, + /* 1140 */ 2659, 2850, 2852, 845, 2343, 2565, 1852, 794, 1812, 1813, + /* 1150 */ 1943, 154, 2160, 831, 2722, 755, 480, 98, 652, 2658, + /* 1160 */ 326, 327, 2697, 2340, 178, 325, 119, 2660, 834, 2662, + /* 1170 */ 2663, 829, 2345, 849, 1974, 1975, 475, 474, 2869, 2658, + /* 1180 */ 2751, 2677, 2697, 2339, 458, 2747, 182, 2660, 834, 2662, + /* 1190 */ 2663, 829, 1913, 849, 2624, 483, 830, 2854, 845, 2343, + /* 1200 */ 744, 845, 2343, 178, 882, 2849, 2624, 2392, 2849, 209, + /* 1210 */ 1909, 2345, 1945, 1955, 672, 671, 845, 2343, 289, 1457, + /* 1220 */ 2634, 297, 1973, 1976, 2853, 1908, 2855, 214, 2850, 2851, + /* 1230 */ 2158, 2850, 779, 816, 2810, 2723, 796, 1885, 718, 1883, + /* 1240 */ 717, 2658, 674, 673, 2697, 2638, 2812, 60, 119, 2660, + /* 1250 */ 834, 2662, 2663, 829, 2159, 849, 2156, 1993, 741, 1579, + /* 1260 */ 2869, 121, 2751, 43, 42, 41, 458, 2747, 1914, 14, + /* 1270 */ 13, 1888, 1889, 1942, 1578, 1944, 1947, 1948, 1949, 1950, + /* 1280 */ 1951, 1952, 1953, 1954, 826, 847, 846, 1966, 1968, 1969, + /* 1290 */ 1970, 1971, 2, 47, 45, 2640, 2642, 459, 2401, 845, + /* 1300 */ 2343, 462, 2659, 1884, 883, 1621, 849, 2392, 2624, 680, + /* 1310 */ 2624, 845, 2343, 679, 805, 831, 1972, 2842, 1882, 330, + /* 1320 */ 2155, 1612, 874, 873, 872, 1616, 871, 1618, 1619, 870, + /* 1330 */ 867, 810, 1627, 864, 1629, 1630, 861, 858, 855, 782, + /* 1340 */ 2659, 845, 2343, 2677, 2154, 602, 1967, 2153, 2152, 378, + /* 1350 */ 845, 2343, 2378, 831, 188, 2783, 2624, 772, 830, 313, + /* 1360 */ 1890, 337, 845, 2343, 845, 2343, 845, 2343, 487, 486, + /* 1370 */ 842, 2151, 2150, 2149, 2624, 692, 691, 2446, 1898, 2148, + /* 1380 */ 2015, 2677, 843, 220, 365, 146, 484, 913, 911, 944, + /* 1390 */ 785, 1972, 15, 1891, 2624, 167, 830, 88, 2624, 2321, + /* 1400 */ 2401, 2624, 2624, 2658, 160, 2659, 2697, 2173, 939, 160, + /* 1410 */ 119, 2660, 834, 2662, 2663, 829, 2400, 849, 828, 541, + /* 1420 */ 1914, 1967, 2869, 2049, 2751, 2624, 2624, 2624, 458, 2747, + /* 1430 */ 1974, 1975, 159, 2624, 274, 1890, 276, 272, 1943, 275, + /* 1440 */ 278, 2658, 280, 277, 2697, 279, 2677, 684, 119, 2660, + /* 1450 */ 834, 2662, 2663, 829, 1559, 849, 685, 298, 1893, 2624, + /* 1460 */ 2869, 830, 2751, 2207, 818, 2205, 458, 2747, 1945, 1955, + /* 1470 */ 751, 1557, 49, 1892, 54, 49, 761, 198, 1973, 1976, + /* 1480 */ 1555, 2140, 2141, 1803, 167, 701, 305, 704, 1810, 14, + /* 1490 */ 13, 344, 343, 1885, 324, 1883, 1560, 77, 116, 64, + /* 1500 */ 49, 49, 77, 2199, 165, 103, 2658, 113, 167, 2697, + /* 1510 */ 346, 345, 791, 400, 2660, 834, 2662, 2663, 829, 827, + /* 1520 */ 849, 813, 2716, 348, 347, 74, 853, 1888, 1889, 1942, + /* 1530 */ 165, 1944, 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954, + /* 1540 */ 826, 847, 846, 1966, 1968, 1969, 1970, 1971, 2, 2083, + /* 1550 */ 167, 2093, 2659, 147, 2092, 937, 303, 350, 349, 413, + /* 1560 */ 412, 352, 351, 795, 165, 831, 893, 148, 1899, 468, + /* 1570 */ 1894, 354, 353, 328, 356, 355, 802, 894, 2009, 1956, + /* 1580 */ 1756, 1746, 1972, 340, 477, 2678, 2659, 1605, 358, 357, + /* 1590 */ 1530, 360, 359, 2677, 362, 361, 364, 363, 2273, 831, + /* 1600 */ 2272, 1528, 1902, 1904, 377, 1634, 2624, 1538, 830, 1642, + /* 1610 */ 1511, 2189, 1967, 2472, 2802, 758, 847, 846, 1966, 1968, + /* 1620 */ 1969, 1970, 1971, 783, 451, 765, 799, 2677, 447, 1649, + /* 1630 */ 491, 2473, 1647, 2195, 2389, 1896, 773, 737, 774, 2803, + /* 1640 */ 2624, 2813, 830, 170, 315, 310, 318, 2305, 494, 1539, + /* 1650 */ 1895, 5, 1512, 2658, 499, 507, 2697, 426, 508, 1917, + /* 1660 */ 119, 2660, 834, 2662, 2663, 829, 519, 849, 2659, 222, + /* 1670 */ 224, 372, 2726, 518, 2751, 221, 786, 521, 458, 2747, + /* 1680 */ 1780, 831, 1907, 535, 1908, 542, 235, 2658, 544, 548, + /* 1690 */ 2697, 550, 591, 555, 119, 2660, 834, 2662, 2663, 829, + /* 1700 */ 567, 849, 578, 2465, 587, 580, 2724, 590, 2751, 2677, + /* 1710 */ 592, 603, 458, 2747, 2659, 604, 601, 608, 240, 241, + /* 1720 */ 606, 609, 2624, 244, 830, 611, 1915, 831, 613, 628, + /* 1730 */ 4, 629, 636, 639, 1910, 637, 252, 641, 1916, 94, + /* 1740 */ 255, 1918, 643, 2659, 258, 642, 645, 1919, 2488, 1920, + /* 1750 */ 2482, 675, 654, 677, 260, 2677, 831, 95, 96, 1875, + /* 1760 */ 97, 1851, 267, 122, 707, 720, 722, 100, 2624, 2658, + /* 1770 */ 830, 708, 2697, 161, 405, 2333, 119, 2660, 834, 2662, + /* 1780 */ 2663, 829, 1911, 849, 2677, 373, 271, 732, 815, 2659, + /* 1790 */ 2751, 470, 469, 1876, 458, 2747, 2329, 2624, 273, 830, + /* 1800 */ 173, 2555, 831, 174, 2331, 2327, 2552, 847, 846, 1966, + /* 1810 */ 1968, 1969, 1970, 1971, 175, 2658, 176, 290, 2697, 295, + /* 1820 */ 2659, 2551, 120, 2660, 834, 2662, 2663, 829, 733, 849, + /* 1830 */ 2677, 731, 736, 831, 2534, 738, 2751, 293, 739, 748, + /* 1840 */ 2750, 2747, 762, 2624, 2658, 830, 2818, 2697, 8, 800, + /* 1850 */ 2817, 120, 2660, 834, 2662, 2663, 829, 300, 849, 302, + /* 1860 */ 771, 2677, 2790, 309, 749, 2751, 776, 747, 746, 817, + /* 1870 */ 2747, 187, 304, 452, 2624, 787, 830, 775, 1912, 784, + /* 1880 */ 2872, 152, 2057, 2055, 798, 2767, 201, 2502, 320, 374, + /* 1890 */ 832, 803, 162, 2697, 804, 2659, 2770, 120, 2660, 834, + /* 1900 */ 2662, 2663, 829, 306, 849, 2501, 307, 2500, 831, 311, + /* 1910 */ 375, 2751, 2659, 308, 216, 421, 2747, 456, 163, 333, + /* 1920 */ 61, 2658, 811, 836, 2697, 831, 2732, 840, 182, 2660, + /* 1930 */ 834, 2662, 2663, 829, 269, 849, 2677, 1, 2848, 2659, + /* 1940 */ 314, 808, 838, 841, 2344, 376, 2616, 338, 110, 2624, + /* 1950 */ 189, 830, 831, 2677, 112, 2615, 2611, 2610, 1432, 670, + /* 1960 */ 666, 662, 658, 379, 268, 938, 2624, 2602, 830, 2601, + /* 1970 */ 2593, 2592, 367, 941, 171, 745, 2809, 403, 2608, 52, + /* 1980 */ 2677, 418, 419, 383, 381, 943, 851, 2607, 2599, 391, + /* 1990 */ 2576, 402, 2598, 2624, 2587, 830, 2658, 2575, 2574, 2697, + /* 2000 */ 83, 2659, 2586, 185, 2660, 834, 2662, 2663, 829, 99, + /* 2010 */ 849, 2569, 266, 2658, 831, 2605, 2697, 2604, 449, 2596, + /* 2020 */ 120, 2660, 834, 2662, 2663, 829, 2595, 849, 2584, 392, + /* 2030 */ 496, 2583, 2581, 2580, 2751, 2393, 497, 1835, 1836, 2748, + /* 2040 */ 2658, 219, 2677, 2697, 501, 2567, 503, 401, 2660, 834, + /* 2050 */ 2662, 2663, 829, 504, 849, 2624, 505, 830, 1834, 2566, + /* 2060 */ 427, 2564, 780, 2870, 510, 2563, 512, 2562, 514, 2561, + /* 2070 */ 516, 1823, 2538, 223, 2537, 225, 1783, 84, 1782, 2515, + /* 2080 */ 450, 254, 2514, 2659, 2513, 528, 529, 2512, 2511, 2455, + /* 2090 */ 265, 533, 1719, 2452, 256, 263, 831, 536, 2451, 2445, + /* 2100 */ 261, 644, 2658, 539, 540, 2697, 2442, 228, 2441, 401, + /* 2110 */ 2660, 834, 2662, 2663, 829, 87, 849, 2659, 232, 253, + /* 2120 */ 2440, 2439, 2444, 2443, 2677, 230, 2438, 2437, 2435, 2434, + /* 2130 */ 831, 2433, 556, 2432, 558, 2430, 2429, 2624, 2428, 830, + /* 2140 */ 2427, 2450, 2426, 2425, 2424, 2448, 2431, 2423, 2422, 2421, + /* 2150 */ 2419, 2418, 2417, 2416, 2415, 2414, 234, 2413, 2677, 93, + /* 2160 */ 2412, 2411, 2410, 2659, 2409, 2480, 2449, 2447, 2408, 2407, + /* 2170 */ 2406, 2624, 239, 830, 2405, 594, 828, 2404, 1725, 2403, + /* 2180 */ 596, 2402, 415, 2238, 2658, 1576, 2237, 2697, 2236, 416, + /* 2190 */ 242, 394, 2660, 834, 2662, 2663, 829, 1580, 849, 243, + /* 2200 */ 2659, 2235, 245, 2233, 2677, 2230, 2229, 2222, 1572, 614, + /* 2210 */ 615, 2209, 2184, 831, 1456, 616, 2183, 2624, 2658, 830, + /* 2220 */ 620, 2697, 618, 246, 622, 185, 2660, 834, 2662, 2663, + /* 2230 */ 829, 619, 849, 623, 624, 626, 248, 80, 2644, 206, + /* 2240 */ 250, 2677, 770, 196, 81, 634, 2536, 2532, 2522, 2510, + /* 2250 */ 257, 259, 2509, 262, 2624, 2486, 830, 2479, 264, 2322, + /* 2260 */ 2232, 2228, 655, 657, 2658, 656, 1504, 2697, 2226, 659, + /* 2270 */ 660, 400, 2660, 834, 2662, 2663, 829, 661, 849, 461, + /* 2280 */ 2717, 663, 2659, 2224, 664, 2871, 2221, 665, 667, 668, + /* 2290 */ 2204, 2202, 669, 2203, 2201, 831, 2180, 2324, 1653, 1654, + /* 2300 */ 2323, 2658, 2219, 2659, 2697, 910, 1562, 1561, 401, 2660, + /* 2310 */ 834, 2662, 2663, 829, 1558, 849, 831, 1556, 73, 1554, + /* 2320 */ 912, 1553, 1552, 2677, 2659, 1551, 1550, 1545, 440, 1547, + /* 2330 */ 270, 2217, 1546, 441, 2208, 1544, 2624, 831, 830, 442, + /* 2340 */ 2206, 443, 2179, 2178, 2677, 705, 2177, 709, 2176, 711, + /* 2350 */ 2175, 713, 702, 124, 28, 1817, 2535, 2624, 1819, 830, + /* 2360 */ 1816, 463, 724, 292, 1807, 2677, 1821, 67, 2531, 1789, + /* 2370 */ 2521, 1791, 2508, 56, 734, 2507, 2854, 20, 2624, 2110, + /* 2380 */ 830, 17, 30, 2658, 299, 752, 2697, 2084, 2659, 6, + /* 2390 */ 401, 2660, 834, 2662, 2663, 829, 750, 849, 448, 21, + /* 2400 */ 22, 831, 200, 7, 719, 65, 57, 2697, 2659, 177, + /* 2410 */ 296, 396, 2660, 834, 2662, 2663, 829, 735, 849, 1768, + /* 2420 */ 1767, 831, 740, 742, 754, 2658, 211, 756, 2697, 2677, + /* 2430 */ 2645, 32, 386, 2660, 834, 2662, 2663, 829, 301, 849, + /* 2440 */ 2091, 1793, 2624, 2050, 830, 212, 186, 199, 31, 2677, + /* 2450 */ 2078, 2052, 82, 24, 2659, 2125, 2124, 2048, 213, 453, + /* 2460 */ 2129, 2128, 2624, 2130, 830, 454, 2131, 831, 59, 2032, + /* 2470 */ 2659, 2506, 2031, 2485, 23, 105, 316, 323, 191, 2484, + /* 2480 */ 106, 2478, 104, 831, 107, 25, 2086, 202, 13, 2658, + /* 2490 */ 329, 2659, 2697, 801, 69, 2677, 385, 2660, 834, 2662, + /* 2500 */ 2663, 829, 58, 849, 831, 331, 807, 332, 2624, 2658, + /* 2510 */ 830, 2677, 2697, 1984, 809, 334, 387, 2660, 834, 2662, + /* 2520 */ 2663, 829, 11, 849, 2624, 18, 830, 1900, 1959, 1958, + /* 2530 */ 1983, 192, 2677, 203, 2477, 1935, 860, 108, 342, 852, + /* 2540 */ 479, 863, 866, 869, 856, 2624, 1957, 830, 38, 1994, + /* 2550 */ 16, 26, 859, 1927, 27, 2658, 833, 70, 2697, 837, + /* 2560 */ 336, 109, 393, 2660, 834, 2662, 2663, 829, 113, 849, + /* 2570 */ 839, 2658, 2702, 2701, 2697, 1961, 848, 68, 397, 2660, + /* 2580 */ 834, 2662, 2663, 829, 1635, 849, 854, 857, 850, 1632, + /* 2590 */ 1631, 862, 2658, 1626, 865, 2697, 868, 1628, 1625, 388, + /* 2600 */ 2660, 834, 2662, 2663, 829, 1622, 849, 366, 1620, 114, + /* 2610 */ 1611, 115, 1648, 875, 1624, 2659, 1644, 1623, 1502, 79, + /* 2620 */ 885, 1541, 1540, 1537, 1534, 1533, 1532, 1531, 831, 1529, + /* 2630 */ 1570, 898, 1527, 1526, 1525, 900, 217, 1569, 2659, 1523, + /* 2640 */ 1520, 1522, 1521, 1519, 1518, 1517, 1566, 1564, 1514, 1513, + /* 2650 */ 1510, 831, 1509, 1508, 2659, 2227, 2677, 1507, 920, 922, + /* 2660 */ 921, 2225, 924, 2223, 926, 925, 930, 831, 2220, 2624, + /* 2670 */ 928, 830, 932, 2200, 929, 936, 934, 2659, 933, 2677, + /* 2680 */ 1445, 2174, 1433, 940, 370, 942, 2144, 1886, 380, 946, + /* 2690 */ 831, 945, 2624, 2144, 830, 2677, 2144, 2144, 2144, 2144, + /* 2700 */ 2144, 2144, 2144, 2144, 2144, 2144, 2144, 2144, 2624, 2144, + /* 2710 */ 830, 2144, 2144, 2144, 2144, 2144, 2658, 2144, 2677, 2697, + /* 2720 */ 2144, 2144, 2144, 398, 2660, 834, 2662, 2663, 829, 2144, + /* 2730 */ 849, 2624, 2144, 830, 2144, 2144, 2144, 2144, 2144, 2658, + /* 2740 */ 2144, 2144, 2697, 2144, 2144, 2144, 389, 2660, 834, 2662, + /* 2750 */ 2663, 829, 2144, 849, 2144, 2658, 2144, 2659, 2697, 2144, + /* 2760 */ 2144, 2144, 399, 2660, 834, 2662, 2663, 829, 2144, 849, + /* 2770 */ 831, 2144, 2144, 2144, 2144, 2144, 2144, 2144, 2658, 2144, + /* 2780 */ 2144, 2697, 2659, 2144, 2144, 390, 2660, 834, 2662, 2663, + /* 2790 */ 829, 2144, 849, 2144, 2144, 831, 2144, 2144, 2677, 2659, + /* 2800 */ 2144, 2144, 2144, 2144, 2144, 2144, 2144, 2144, 2144, 2144, + /* 2810 */ 2144, 2624, 831, 830, 2144, 2144, 2144, 2144, 2144, 2144, + /* 2820 */ 2144, 2144, 2144, 2677, 2144, 2144, 2144, 2144, 2144, 2144, + /* 2830 */ 2144, 2144, 2144, 2144, 2144, 2144, 2624, 2144, 830, 2144, + /* 2840 */ 2677, 2144, 2144, 2144, 2144, 2144, 2144, 2144, 2144, 2144, + /* 2850 */ 2144, 2144, 2144, 2624, 2144, 830, 2144, 2144, 2658, 2144, + /* 2860 */ 2144, 2697, 2144, 2659, 2144, 406, 2660, 834, 2662, 2663, + /* 2870 */ 829, 2144, 849, 2144, 2144, 2144, 831, 2144, 2144, 2144, + /* 2880 */ 2144, 2144, 2144, 2658, 2144, 2659, 2697, 2144, 2144, 2144, + /* 2890 */ 407, 2660, 834, 2662, 2663, 829, 2144, 849, 831, 2144, + /* 2900 */ 2658, 2144, 2144, 2697, 2677, 2144, 2144, 2671, 2660, 834, + /* 2910 */ 2662, 2663, 829, 2144, 849, 2144, 2144, 2624, 2144, 830, + /* 2920 */ 2144, 2144, 2144, 2144, 2144, 2144, 2677, 2144, 2144, 2659, + /* 2930 */ 2144, 2144, 2144, 2144, 2144, 2144, 2144, 2144, 2144, 2624, + /* 2940 */ 2144, 830, 831, 2144, 2144, 2144, 2144, 2144, 2144, 2144, + /* 2950 */ 2144, 2144, 2144, 2144, 2144, 2144, 2144, 2144, 2144, 2144, + /* 2960 */ 2144, 2144, 2144, 2144, 2658, 2144, 2659, 2697, 2144, 2144, + /* 2970 */ 2677, 2670, 2660, 834, 2662, 2663, 829, 2144, 849, 831, + /* 2980 */ 2144, 2144, 2144, 2624, 2144, 830, 2658, 2144, 2144, 2697, + /* 2990 */ 2144, 2144, 2144, 2669, 2660, 834, 2662, 2663, 829, 2144, + /* 3000 */ 849, 2144, 2659, 2144, 2144, 2144, 2144, 2677, 2144, 2144, + /* 3010 */ 2144, 2144, 2144, 2144, 2144, 831, 2144, 2144, 2144, 2144, + /* 3020 */ 2624, 2144, 830, 2144, 2144, 2144, 2144, 2144, 2144, 2144, + /* 3030 */ 2658, 2144, 2144, 2697, 2144, 2144, 2144, 423, 2660, 834, + /* 3040 */ 2662, 2663, 829, 2677, 849, 2144, 2144, 2144, 2144, 2144, + /* 3050 */ 2144, 2659, 2144, 2144, 2144, 2144, 2624, 2144, 830, 2144, + /* 3060 */ 2144, 2144, 2144, 2144, 831, 2144, 2144, 2658, 2144, 2144, + /* 3070 */ 2697, 2144, 2144, 2144, 424, 2660, 834, 2662, 2663, 829, + /* 3080 */ 2144, 849, 2659, 2144, 2144, 2144, 2144, 2144, 2144, 2144, + /* 3090 */ 2144, 2144, 2677, 2144, 2144, 831, 2144, 2144, 2144, 2144, + /* 3100 */ 2144, 2144, 2144, 2658, 2144, 2624, 2697, 830, 2144, 2144, + /* 3110 */ 420, 2660, 834, 2662, 2663, 829, 2659, 849, 2144, 2144, + /* 3120 */ 2144, 2144, 2144, 2677, 2144, 2144, 2144, 2144, 2144, 831, + /* 3130 */ 2144, 2144, 2144, 2144, 2144, 2144, 2624, 2144, 830, 2144, + /* 3140 */ 2144, 2144, 2144, 2144, 2144, 2144, 2144, 2144, 2144, 2144, + /* 3150 */ 2144, 2144, 2658, 2144, 2144, 2697, 2144, 2677, 2144, 425, + /* 3160 */ 2660, 834, 2662, 2663, 829, 2144, 849, 2144, 2144, 2144, + /* 3170 */ 2624, 2144, 830, 2144, 2144, 2144, 2144, 2144, 2144, 2144, + /* 3180 */ 2144, 2144, 2144, 832, 2144, 2144, 2697, 2144, 2144, 2144, + /* 3190 */ 396, 2660, 834, 2662, 2663, 829, 2144, 849, 2144, 2144, + /* 3200 */ 2144, 2144, 2144, 2144, 2144, 2144, 2144, 2144, 2144, 2144, + /* 3210 */ 2144, 2144, 2144, 2144, 2144, 2144, 2144, 2658, 2144, 2144, + /* 3220 */ 2697, 2144, 2144, 2144, 395, 2660, 834, 2662, 2663, 829, + /* 3230 */ 2144, 849, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 501, 399, 501, 377, 411, 426, 380, 381, 509, 503, - /* 10 */ 509, 505, 12, 13, 14, 382, 399, 14, 15, 16, - /* 20 */ 20, 20, 22, 444, 445, 448, 424, 528, 527, 528, - /* 30 */ 453, 532, 533, 532, 533, 35, 3, 37, 0, 4, - /* 40 */ 20, 424, 12, 13, 8, 9, 370, 370, 12, 13, - /* 50 */ 14, 15, 16, 20, 391, 42, 382, 383, 23, 383, - /* 60 */ 467, 428, 429, 20, 431, 65, 0, 37, 435, 411, - /* 70 */ 0, 408, 72, 471, 472, 473, 418, 4, 501, 79, - /* 80 */ 417, 46, 47, 48, 482, 427, 509, 411, 471, 472, - /* 90 */ 24, 25, 26, 27, 28, 29, 30, 31, 32, 482, - /* 100 */ 424, 424, 426, 377, 527, 528, 380, 381, 108, 532, - /* 110 */ 533, 111, 74, 75, 76, 77, 78, 474, 80, 81, + /* 0 */ 496, 497, 416, 0, 380, 419, 415, 383, 384, 414, + /* 10 */ 406, 429, 12, 13, 14, 381, 421, 2, 414, 385, + /* 20 */ 20, 387, 22, 8, 9, 430, 422, 12, 13, 14, + /* 30 */ 15, 16, 450, 451, 509, 35, 511, 37, 0, 12, + /* 40 */ 13, 14, 15, 16, 8, 9, 385, 386, 12, 13, + /* 50 */ 14, 15, 16, 20, 8, 9, 42, 0, 12, 13, + /* 60 */ 14, 15, 16, 477, 414, 65, 34, 39, 40, 33, + /* 70 */ 4, 421, 72, 370, 488, 20, 472, 473, 21, 79, + /* 80 */ 430, 24, 25, 26, 27, 28, 29, 30, 31, 32, + /* 90 */ 385, 386, 380, 414, 21, 383, 384, 24, 25, 26, + /* 100 */ 27, 28, 29, 30, 31, 32, 454, 65, 108, 430, + /* 110 */ 405, 111, 74, 75, 76, 77, 78, 412, 80, 81, /* 120 */ 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, /* 130 */ 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, - /* 140 */ 102, 103, 104, 500, 468, 112, 20, 471, 112, 149, - /* 150 */ 150, 475, 476, 477, 478, 479, 480, 411, 482, 501, - /* 160 */ 14, 413, 14, 487, 416, 489, 20, 509, 20, 493, - /* 170 */ 494, 497, 498, 499, 422, 501, 502, 425, 426, 166, - /* 180 */ 434, 21, 436, 509, 111, 527, 528, 187, 188, 513, - /* 190 */ 532, 533, 149, 150, 194, 195, 36, 521, 38, 39, - /* 200 */ 40, 527, 528, 0, 382, 383, 532, 533, 0, 209, - /* 210 */ 71, 211, 142, 143, 144, 145, 146, 147, 148, 471, - /* 220 */ 8, 9, 189, 412, 12, 13, 14, 15, 16, 21, - /* 230 */ 482, 420, 24, 25, 26, 27, 28, 29, 30, 31, - /* 240 */ 32, 211, 121, 243, 244, 245, 245, 247, 248, 249, + /* 140 */ 102, 103, 104, 115, 116, 20, 118, 381, 112, 149, + /* 150 */ 150, 385, 110, 387, 20, 113, 18, 454, 112, 507, + /* 160 */ 33, 23, 459, 111, 503, 504, 505, 515, 507, 508, + /* 170 */ 142, 168, 45, 416, 146, 172, 515, 111, 40, 41, + /* 180 */ 166, 429, 44, 180, 20, 533, 534, 187, 188, 386, + /* 190 */ 538, 539, 54, 37, 533, 534, 444, 197, 198, 538, + /* 200 */ 539, 0, 450, 451, 66, 67, 68, 69, 70, 20, + /* 210 */ 507, 22, 212, 20, 214, 8, 9, 414, 515, 12, + /* 220 */ 13, 14, 15, 16, 182, 24, 25, 26, 27, 28, + /* 230 */ 29, 30, 31, 32, 477, 79, 533, 534, 20, 144, + /* 240 */ 111, 538, 539, 148, 55, 488, 246, 247, 248, 111, /* 250 */ 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, - /* 260 */ 260, 261, 262, 263, 264, 12, 13, 382, 383, 265, - /* 270 */ 18, 22, 20, 20, 71, 22, 413, 382, 383, 27, - /* 280 */ 382, 383, 30, 20, 72, 378, 37, 35, 35, 382, - /* 290 */ 37, 384, 279, 280, 281, 282, 283, 284, 285, 286, - /* 300 */ 287, 20, 2, 51, 166, 53, 382, 383, 8, 9, - /* 310 */ 58, 59, 12, 13, 14, 15, 16, 432, 65, 497, - /* 320 */ 498, 499, 70, 501, 502, 72, 402, 432, 79, 382, - /* 330 */ 383, 119, 79, 21, 471, 187, 24, 25, 26, 27, - /* 340 */ 28, 29, 30, 31, 32, 482, 111, 8, 9, 402, - /* 350 */ 370, 12, 13, 14, 15, 16, 409, 108, 108, 20, - /* 360 */ 33, 108, 110, 290, 111, 283, 284, 285, 286, 287, - /* 370 */ 413, 111, 122, 121, 124, 125, 126, 127, 128, 129, - /* 380 */ 130, 131, 132, 133, 370, 135, 136, 137, 138, 139, - /* 390 */ 140, 141, 0, 245, 496, 497, 498, 499, 186, 501, - /* 400 */ 502, 71, 149, 150, 424, 153, 154, 243, 156, 157, - /* 410 */ 158, 159, 160, 161, 162, 163, 164, 165, 280, 281, - /* 420 */ 282, 169, 170, 171, 172, 173, 174, 175, 471, 177, - /* 430 */ 178, 179, 490, 491, 389, 183, 184, 185, 424, 482, - /* 440 */ 187, 188, 190, 208, 0, 210, 382, 194, 195, 8, - /* 450 */ 9, 406, 410, 12, 13, 14, 15, 16, 209, 414, - /* 460 */ 211, 369, 209, 371, 211, 423, 302, 303, 304, 305, - /* 470 */ 306, 307, 308, 378, 33, 240, 426, 382, 79, 384, - /* 480 */ 268, 269, 270, 271, 272, 273, 274, 275, 276, 277, - /* 490 */ 278, 441, 243, 244, 444, 445, 243, 244, 245, 13, - /* 500 */ 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, - /* 510 */ 257, 258, 259, 260, 261, 262, 263, 264, 265, 12, - /* 520 */ 13, 474, 458, 459, 501, 290, 18, 20, 189, 22, - /* 530 */ 421, 23, 509, 424, 142, 143, 144, 145, 146, 147, - /* 540 */ 148, 370, 35, 411, 37, 20, 22, 500, 40, 41, - /* 550 */ 290, 528, 44, 112, 383, 532, 533, 2, 382, 383, - /* 560 */ 370, 37, 54, 8, 9, 79, 20, 12, 13, 14, - /* 570 */ 15, 16, 65, 383, 66, 67, 68, 69, 70, 72, - /* 580 */ 382, 383, 411, 143, 245, 20, 79, 22, 382, 383, - /* 590 */ 12, 13, 14, 15, 16, 424, 20, 426, 466, 467, - /* 600 */ 402, 411, 37, 79, 382, 108, 111, 409, 432, 37, - /* 610 */ 166, 167, 39, 40, 424, 108, 426, 193, 111, 111, - /* 620 */ 55, 124, 125, 126, 127, 128, 129, 130, 131, 132, - /* 630 */ 133, 51, 135, 136, 137, 138, 139, 140, 141, 468, - /* 640 */ 60, 314, 471, 63, 64, 383, 475, 476, 477, 478, - /* 650 */ 479, 480, 481, 482, 483, 484, 149, 150, 468, 151, - /* 660 */ 144, 471, 222, 223, 148, 475, 476, 477, 478, 479, - /* 670 */ 480, 398, 482, 411, 401, 485, 14, 487, 488, 489, - /* 680 */ 458, 459, 20, 493, 494, 20, 166, 111, 115, 116, - /* 690 */ 0, 118, 8, 9, 187, 188, 12, 13, 14, 15, - /* 700 */ 16, 194, 195, 497, 498, 499, 121, 501, 502, 201, - /* 710 */ 202, 203, 187, 188, 206, 142, 209, 20, 211, 146, - /* 720 */ 296, 297, 298, 299, 37, 8, 9, 219, 220, 12, - /* 730 */ 13, 14, 15, 16, 218, 189, 65, 221, 230, 477, - /* 740 */ 224, 233, 226, 34, 236, 237, 238, 239, 240, 88, - /* 750 */ 243, 244, 245, 0, 247, 248, 249, 250, 251, 252, - /* 760 */ 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, - /* 770 */ 263, 264, 12, 13, 14, 265, 370, 267, 70, 370, - /* 780 */ 20, 110, 22, 211, 113, 290, 382, 50, 225, 383, - /* 790 */ 227, 245, 382, 383, 35, 35, 370, 37, 290, 279, - /* 800 */ 280, 281, 282, 283, 284, 285, 286, 287, 111, 383, - /* 810 */ 51, 385, 402, 241, 242, 403, 155, 411, 411, 60, - /* 820 */ 61, 62, 63, 411, 65, 65, 419, 74, 75, 76, - /* 830 */ 424, 419, 426, 424, 81, 82, 83, 411, 370, 79, - /* 840 */ 87, 180, 181, 439, 440, 92, 93, 94, 95, 187, - /* 850 */ 424, 98, 426, 182, 189, 102, 103, 104, 168, 8, - /* 860 */ 9, 412, 172, 12, 13, 14, 15, 16, 108, 110, - /* 870 */ 180, 111, 113, 189, 468, 72, 370, 471, 466, 467, - /* 880 */ 411, 475, 476, 477, 478, 479, 480, 418, 482, 383, - /* 890 */ 13, 385, 424, 487, 468, 489, 427, 471, 211, 493, - /* 900 */ 494, 475, 476, 477, 478, 479, 480, 245, 482, 149, - /* 910 */ 150, 474, 204, 487, 20, 489, 22, 411, 201, 493, - /* 920 */ 494, 23, 382, 383, 382, 383, 189, 521, 241, 242, - /* 930 */ 424, 486, 426, 488, 197, 412, 20, 500, 370, 231, - /* 940 */ 232, 182, 402, 0, 402, 47, 48, 187, 188, 55, - /* 950 */ 191, 192, 382, 383, 194, 195, 79, 198, 199, 186, - /* 960 */ 8, 9, 20, 112, 12, 13, 14, 15, 16, 209, - /* 970 */ 412, 211, 402, 20, 468, 448, 217, 471, 448, 20, - /* 980 */ 454, 475, 476, 477, 478, 479, 480, 290, 482, 370, - /* 990 */ 403, 448, 424, 487, 51, 489, 143, 144, 411, 493, - /* 1000 */ 494, 148, 383, 243, 244, 245, 419, 247, 248, 249, - /* 1010 */ 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, - /* 1020 */ 260, 261, 262, 263, 264, 12, 13, 370, 501, 392, - /* 1030 */ 411, 501, 22, 20, 317, 22, 509, 400, 412, 509, - /* 1040 */ 383, 268, 385, 424, 501, 426, 243, 37, 35, 411, - /* 1050 */ 37, 278, 509, 111, 527, 528, 403, 527, 528, 532, - /* 1060 */ 533, 403, 532, 533, 411, 149, 150, 37, 411, 411, - /* 1070 */ 527, 528, 419, 370, 436, 532, 533, 419, 65, 425, - /* 1080 */ 426, 424, 407, 426, 382, 383, 383, 468, 385, 370, - /* 1090 */ 471, 370, 79, 3, 475, 476, 477, 478, 479, 480, - /* 1100 */ 4, 482, 382, 383, 402, 370, 487, 411, 489, 79, - /* 1110 */ 194, 195, 493, 494, 411, 19, 1, 2, 108, 370, - /* 1120 */ 14, 108, 402, 427, 111, 468, 20, 424, 471, 426, - /* 1130 */ 412, 35, 475, 476, 477, 478, 479, 480, 463, 482, - /* 1140 */ 187, 448, 411, 424, 487, 424, 489, 51, 189, 418, - /* 1150 */ 493, 494, 382, 383, 58, 59, 382, 383, 427, 424, - /* 1160 */ 22, 65, 149, 150, 142, 143, 144, 145, 146, 147, - /* 1170 */ 148, 468, 402, 424, 471, 37, 402, 411, 475, 476, - /* 1180 */ 477, 478, 479, 480, 418, 482, 20, 370, 56, 57, - /* 1190 */ 487, 370, 489, 427, 501, 370, 493, 494, 245, 370, - /* 1200 */ 187, 188, 509, 412, 245, 370, 110, 194, 195, 113, - /* 1210 */ 74, 75, 76, 382, 383, 382, 383, 81, 82, 83, - /* 1220 */ 527, 528, 209, 87, 211, 532, 533, 112, 92, 93, - /* 1230 */ 94, 95, 290, 402, 98, 402, 387, 388, 102, 103, - /* 1240 */ 104, 424, 370, 142, 448, 424, 108, 146, 370, 424, - /* 1250 */ 387, 388, 370, 424, 20, 383, 243, 244, 245, 424, - /* 1260 */ 247, 248, 249, 250, 251, 252, 253, 254, 255, 256, - /* 1270 */ 257, 258, 259, 260, 261, 262, 263, 264, 12, 13, - /* 1280 */ 370, 396, 397, 411, 382, 383, 20, 4, 22, 382, - /* 1290 */ 383, 382, 383, 383, 389, 385, 424, 501, 426, 370, - /* 1300 */ 0, 35, 424, 37, 402, 509, 424, 382, 383, 402, - /* 1310 */ 370, 402, 382, 383, 33, 382, 383, 411, 486, 414, - /* 1320 */ 488, 411, 485, 527, 528, 488, 370, 402, 532, 533, - /* 1330 */ 391, 65, 402, 427, 424, 402, 426, 382, 383, 383, - /* 1340 */ 468, 385, 367, 471, 182, 79, 33, 475, 476, 477, - /* 1350 */ 478, 479, 480, 424, 482, 421, 417, 402, 424, 487, - /* 1360 */ 411, 489, 396, 397, 424, 493, 494, 411, 421, 404, - /* 1370 */ 0, 424, 407, 0, 108, 213, 427, 111, 468, 33, - /* 1380 */ 424, 471, 426, 400, 13, 475, 476, 477, 478, 479, - /* 1390 */ 480, 45, 482, 373, 374, 12, 13, 487, 33, 489, - /* 1400 */ 121, 437, 312, 493, 494, 22, 33, 33, 37, 37, - /* 1410 */ 45, 245, 42, 33, 371, 149, 150, 65, 35, 114, - /* 1420 */ 37, 33, 117, 448, 468, 112, 114, 471, 453, 117, - /* 1430 */ 503, 475, 476, 477, 478, 479, 480, 114, 482, 370, - /* 1440 */ 117, 114, 13, 487, 117, 489, 0, 0, 65, 493, - /* 1450 */ 494, 79, 383, 187, 188, 176, 0, 33, 111, 33, - /* 1460 */ 194, 195, 79, 0, 37, 113, 37, 120, 22, 22, - /* 1470 */ 37, 33, 49, 149, 150, 209, 501, 211, 22, 245, - /* 1480 */ 411, 33, 1, 2, 509, 22, 112, 33, 33, 37, - /* 1490 */ 33, 108, 112, 424, 33, 426, 37, 33, 12, 13, - /* 1500 */ 112, 525, 527, 528, 12, 13, 79, 532, 533, 243, - /* 1510 */ 244, 245, 79, 247, 248, 249, 250, 251, 252, 253, - /* 1520 */ 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, - /* 1530 */ 264, 536, 12, 13, 111, 235, 112, 468, 112, 33, - /* 1540 */ 471, 33, 22, 33, 475, 476, 477, 478, 479, 480, - /* 1550 */ 112, 482, 33, 12, 13, 35, 487, 37, 489, 33, - /* 1560 */ 112, 504, 493, 494, 12, 13, 112, 112, 33, 112, - /* 1570 */ 12, 13, 518, 112, 386, 292, 112, 33, 370, 12, - /* 1580 */ 13, 33, 12, 13, 108, 65, 12, 13, 12, 13, - /* 1590 */ 411, 383, 209, 399, 211, 12, 13, 316, 12, 13, - /* 1600 */ 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, - /* 1610 */ 370, 135, 136, 137, 138, 139, 140, 141, 112, 411, - /* 1620 */ 112, 0, 112, 383, 13, 13, 243, 244, 399, 437, - /* 1630 */ 381, 112, 424, 437, 426, 524, 524, 524, 112, 386, - /* 1640 */ 257, 258, 259, 260, 261, 262, 263, 112, 37, 37, - /* 1650 */ 447, 411, 524, 437, 383, 423, 112, 455, 437, 437, - /* 1660 */ 112, 508, 508, 211, 424, 495, 426, 511, 529, 401, - /* 1670 */ 211, 293, 449, 52, 51, 470, 468, 20, 42, 471, - /* 1680 */ 469, 391, 224, 475, 476, 477, 478, 479, 480, 465, - /* 1690 */ 482, 460, 370, 460, 391, 207, 451, 489, 20, 382, - /* 1700 */ 20, 493, 494, 383, 45, 383, 433, 433, 468, 383, - /* 1710 */ 186, 471, 370, 382, 430, 475, 476, 477, 478, 479, - /* 1720 */ 480, 383, 482, 382, 433, 383, 430, 430, 430, 209, - /* 1730 */ 395, 211, 370, 411, 109, 107, 382, 394, 382, 106, - /* 1740 */ 382, 393, 382, 382, 20, 383, 424, 50, 426, 460, - /* 1750 */ 375, 370, 375, 411, 391, 379, 20, 391, 379, 426, - /* 1760 */ 391, 241, 242, 243, 383, 20, 424, 20, 426, 384, - /* 1770 */ 384, 450, 20, 411, 440, 391, 375, 257, 258, 259, - /* 1780 */ 260, 261, 262, 263, 391, 391, 424, 391, 426, 382, - /* 1790 */ 468, 391, 411, 471, 373, 382, 228, 475, 476, 477, - /* 1800 */ 478, 479, 480, 411, 482, 424, 411, 426, 411, 411, - /* 1810 */ 468, 489, 373, 471, 411, 493, 494, 475, 476, 477, - /* 1820 */ 478, 479, 480, 411, 482, 411, 411, 411, 411, 411, - /* 1830 */ 468, 489, 370, 471, 424, 493, 494, 475, 476, 477, - /* 1840 */ 478, 479, 480, 375, 482, 383, 424, 20, 111, 468, - /* 1850 */ 460, 464, 471, 462, 424, 389, 475, 476, 477, 478, - /* 1860 */ 479, 480, 215, 482, 370, 459, 457, 214, 426, 389, - /* 1870 */ 301, 382, 517, 411, 449, 456, 442, 383, 300, 442, - /* 1880 */ 309, 517, 200, 311, 522, 523, 424, 520, 426, 424, - /* 1890 */ 310, 370, 294, 449, 537, 289, 288, 318, 313, 315, - /* 1900 */ 383, 519, 20, 121, 383, 411, 517, 291, 111, 507, - /* 1910 */ 506, 384, 389, 442, 515, 534, 535, 474, 424, 389, - /* 1920 */ 426, 516, 514, 512, 492, 424, 424, 424, 424, 442, - /* 1930 */ 468, 424, 411, 471, 192, 438, 389, 475, 476, 477, - /* 1940 */ 478, 479, 480, 407, 482, 424, 510, 426, 389, 383, - /* 1950 */ 530, 489, 424, 424, 111, 424, 494, 424, 424, 531, - /* 1960 */ 415, 424, 468, 424, 424, 471, 424, 446, 22, 475, - /* 1970 */ 476, 477, 478, 479, 480, 370, 482, 424, 424, 424, - /* 1980 */ 424, 424, 382, 389, 424, 424, 424, 424, 383, 468, - /* 1990 */ 372, 38, 471, 376, 375, 452, 475, 476, 477, 478, - /* 2000 */ 479, 480, 405, 482, 405, 370, 424, 461, 443, 405, - /* 2010 */ 390, 424, 424, 424, 424, 0, 411, 523, 383, 368, - /* 2020 */ 443, 0, 0, 45, 0, 37, 234, 37, 37, 424, - /* 2030 */ 37, 426, 234, 0, 37, 37, 234, 37, 0, 234, - /* 2040 */ 0, 37, 0, 0, 37, 22, 411, 0, 37, 229, - /* 2050 */ 0, 446, 217, 0, 217, 211, 218, 209, 0, 424, - /* 2060 */ 0, 426, 0, 205, 204, 0, 0, 154, 49, 49, - /* 2070 */ 0, 37, 0, 468, 0, 0, 471, 51, 37, 0, - /* 2080 */ 475, 476, 477, 478, 479, 480, 49, 482, 0, 45, - /* 2090 */ 0, 0, 0, 0, 49, 0, 370, 0, 0, 0, - /* 2100 */ 172, 37, 0, 468, 172, 0, 471, 0, 0, 383, - /* 2110 */ 475, 476, 477, 478, 479, 480, 370, 482, 0, 0, - /* 2120 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 383, - /* 2130 */ 49, 0, 45, 370, 0, 0, 0, 411, 0, 0, - /* 2140 */ 0, 0, 0, 0, 0, 0, 383, 0, 0, 0, - /* 2150 */ 424, 22, 426, 154, 0, 153, 0, 411, 0, 0, - /* 2160 */ 152, 526, 50, 50, 0, 65, 0, 0, 22, 65, - /* 2170 */ 424, 65, 426, 22, 411, 0, 65, 0, 0, 42, - /* 2180 */ 0, 0, 0, 51, 51, 0, 14, 424, 0, 426, - /* 2190 */ 37, 0, 37, 0, 468, 45, 0, 471, 37, 42, - /* 2200 */ 37, 475, 476, 477, 478, 479, 480, 42, 482, 446, - /* 2210 */ 37, 51, 42, 0, 468, 0, 370, 471, 1, 33, - /* 2220 */ 49, 475, 476, 477, 478, 479, 480, 200, 482, 383, - /* 2230 */ 484, 468, 49, 49, 471, 370, 19, 42, 475, 476, - /* 2240 */ 477, 478, 479, 480, 43, 482, 42, 49, 383, 0, - /* 2250 */ 0, 0, 35, 0, 51, 37, 42, 411, 0, 37, - /* 2260 */ 73, 535, 370, 51, 0, 42, 37, 51, 51, 42, - /* 2270 */ 424, 0, 426, 37, 42, 383, 411, 60, 61, 62, - /* 2280 */ 63, 51, 65, 0, 0, 0, 0, 0, 0, 424, - /* 2290 */ 22, 426, 446, 119, 37, 0, 117, 37, 37, 37, - /* 2300 */ 37, 22, 37, 411, 37, 0, 37, 37, 33, 37, - /* 2310 */ 33, 37, 22, 37, 468, 0, 424, 471, 426, 37, - /* 2320 */ 22, 475, 476, 477, 478, 479, 480, 110, 482, 0, - /* 2330 */ 113, 22, 0, 468, 53, 22, 471, 37, 370, 0, - /* 2340 */ 475, 476, 477, 478, 479, 480, 0, 482, 0, 37, - /* 2350 */ 0, 383, 0, 37, 20, 22, 37, 37, 37, 112, - /* 2360 */ 468, 122, 0, 471, 147, 111, 0, 475, 476, 477, - /* 2370 */ 478, 479, 480, 49, 482, 123, 370, 111, 189, 411, - /* 2380 */ 37, 189, 22, 0, 216, 22, 189, 0, 212, 383, - /* 2390 */ 0, 192, 424, 37, 426, 189, 196, 189, 3, 50, - /* 2400 */ 370, 196, 33, 111, 295, 112, 112, 111, 191, 37, - /* 2410 */ 111, 109, 33, 383, 50, 198, 112, 411, 107, 33, - /* 2420 */ 112, 111, 370, 49, 33, 111, 49, 33, 111, 111, - /* 2430 */ 424, 33, 426, 79, 217, 383, 468, 112, 112, 471, - /* 2440 */ 37, 411, 111, 475, 476, 477, 478, 479, 480, 112, - /* 2450 */ 482, 3, 112, 33, 424, 37, 426, 295, 37, 37, - /* 2460 */ 37, 37, 37, 411, 295, 112, 49, 112, 33, 279, - /* 2470 */ 0, 0, 42, 33, 468, 49, 424, 471, 426, 111, - /* 2480 */ 109, 475, 476, 477, 478, 479, 480, 266, 482, 2, - /* 2490 */ 109, 22, 49, 49, 112, 22, 112, 112, 468, 243, - /* 2500 */ 370, 471, 0, 111, 111, 475, 476, 477, 478, 479, - /* 2510 */ 480, 111, 482, 383, 112, 111, 111, 111, 111, 246, - /* 2520 */ 468, 111, 111, 471, 112, 112, 111, 475, 476, 477, - /* 2530 */ 478, 479, 480, 42, 482, 193, 191, 49, 111, 111, - /* 2540 */ 121, 411, 111, 111, 37, 112, 112, 111, 111, 120, - /* 2550 */ 37, 112, 111, 37, 424, 37, 426, 111, 37, 112, - /* 2560 */ 37, 112, 112, 112, 37, 33, 111, 37, 111, 111, - /* 2570 */ 22, 73, 370, 72, 37, 37, 134, 123, 122, 134, - /* 2580 */ 37, 37, 37, 37, 37, 383, 134, 134, 37, 370, - /* 2590 */ 37, 37, 37, 79, 105, 105, 79, 33, 468, 37, - /* 2600 */ 37, 471, 383, 37, 22, 475, 476, 477, 478, 479, - /* 2610 */ 480, 370, 482, 411, 37, 37, 37, 37, 79, 22, - /* 2620 */ 37, 37, 37, 0, 383, 37, 424, 37, 426, 37, - /* 2630 */ 411, 42, 51, 0, 0, 37, 42, 37, 51, 0, - /* 2640 */ 37, 42, 51, 424, 51, 426, 42, 0, 370, 37, - /* 2650 */ 37, 0, 411, 22, 33, 538, 20, 22, 21, 538, - /* 2660 */ 22, 383, 22, 21, 538, 424, 538, 426, 538, 538, - /* 2670 */ 468, 538, 538, 471, 538, 538, 538, 475, 476, 477, - /* 2680 */ 478, 479, 480, 538, 482, 538, 538, 468, 538, 411, - /* 2690 */ 471, 538, 538, 538, 475, 476, 477, 478, 479, 480, - /* 2700 */ 538, 482, 424, 538, 426, 538, 538, 538, 538, 468, - /* 2710 */ 538, 370, 471, 538, 538, 538, 475, 476, 477, 478, - /* 2720 */ 479, 480, 538, 482, 383, 538, 538, 538, 538, 538, - /* 2730 */ 538, 370, 538, 538, 538, 538, 538, 538, 538, 538, - /* 2740 */ 538, 538, 538, 538, 383, 538, 468, 538, 538, 471, - /* 2750 */ 370, 538, 411, 475, 476, 477, 478, 479, 480, 538, - /* 2760 */ 482, 538, 538, 383, 538, 424, 538, 426, 538, 538, - /* 2770 */ 538, 538, 411, 538, 538, 538, 538, 538, 538, 538, - /* 2780 */ 538, 538, 538, 538, 538, 424, 538, 426, 538, 538, - /* 2790 */ 538, 411, 538, 538, 538, 538, 538, 538, 538, 538, - /* 2800 */ 538, 538, 538, 538, 424, 538, 426, 538, 538, 468, - /* 2810 */ 538, 538, 471, 538, 538, 538, 475, 476, 477, 478, - /* 2820 */ 479, 480, 538, 482, 538, 538, 538, 538, 538, 468, - /* 2830 */ 538, 538, 471, 538, 370, 538, 475, 476, 477, 478, - /* 2840 */ 479, 480, 538, 482, 538, 538, 538, 383, 468, 538, - /* 2850 */ 538, 471, 370, 538, 538, 475, 476, 477, 478, 479, - /* 2860 */ 480, 538, 482, 538, 538, 383, 538, 538, 538, 370, - /* 2870 */ 538, 538, 538, 538, 538, 411, 538, 538, 538, 538, - /* 2880 */ 538, 538, 383, 538, 538, 538, 538, 538, 424, 538, - /* 2890 */ 426, 538, 538, 411, 538, 538, 538, 538, 538, 538, - /* 2900 */ 538, 538, 538, 538, 538, 538, 424, 538, 426, 538, - /* 2910 */ 411, 538, 538, 538, 538, 538, 538, 538, 538, 538, - /* 2920 */ 538, 538, 538, 424, 538, 426, 538, 538, 538, 538, - /* 2930 */ 538, 538, 468, 538, 538, 471, 538, 538, 538, 475, - /* 2940 */ 476, 477, 478, 479, 480, 538, 482, 538, 538, 538, - /* 2950 */ 468, 538, 538, 471, 538, 538, 370, 475, 476, 477, - /* 2960 */ 478, 479, 480, 538, 482, 538, 538, 468, 538, 383, - /* 2970 */ 471, 538, 370, 538, 475, 476, 477, 478, 479, 480, - /* 2980 */ 538, 482, 538, 538, 538, 383, 538, 538, 538, 538, - /* 2990 */ 538, 538, 538, 538, 538, 370, 538, 411, 538, 538, - /* 3000 */ 538, 538, 538, 538, 538, 538, 538, 538, 383, 538, - /* 3010 */ 424, 538, 426, 411, 538, 538, 538, 538, 538, 538, - /* 3020 */ 538, 538, 538, 538, 538, 538, 424, 538, 426, 538, - /* 3030 */ 538, 538, 538, 538, 538, 538, 411, 538, 538, 538, - /* 3040 */ 538, 538, 538, 538, 538, 538, 538, 538, 538, 424, - /* 3050 */ 538, 426, 538, 538, 468, 538, 538, 471, 370, 538, - /* 3060 */ 538, 475, 476, 477, 478, 479, 480, 538, 482, 538, - /* 3070 */ 468, 383, 538, 471, 538, 538, 538, 475, 476, 477, - /* 3080 */ 478, 479, 480, 538, 482, 538, 538, 538, 538, 538, - /* 3090 */ 538, 538, 538, 468, 538, 538, 471, 538, 538, 411, - /* 3100 */ 475, 476, 477, 478, 479, 480, 538, 482, 538, 538, - /* 3110 */ 538, 538, 424, 538, 426, 538, 538, 538, 538, 538, - /* 3120 */ 538, 538, 538, 538, 538, 538, 538, 538, 538, 538, - /* 3130 */ 538, 538, 538, 538, 538, 538, 538, 538, 538, 538, - /* 3140 */ 538, 538, 538, 538, 538, 538, 538, 538, 538, 538, - /* 3150 */ 538, 538, 538, 538, 538, 538, 468, 538, 538, 471, - /* 3160 */ 538, 538, 538, 475, 476, 477, 478, 479, 480, 538, - /* 3170 */ 482, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3180 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3190 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3200 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3210 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3220 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3230 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3240 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3250 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3260 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3270 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3280 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3290 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3300 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3310 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3320 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3330 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3340 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3350 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3360 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3370 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3380 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3390 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3400 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3410 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3420 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3430 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3440 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3450 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3460 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3470 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3480 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3490 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3500 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3510 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3520 */ 367, 367, 367, 367, 367, 367, 367, 367, 367, 367, - /* 3530 */ 367, 367, 367, 367, 367, 367, 367, 367, + /* 260 */ 260, 261, 262, 263, 264, 265, 266, 267, 12, 13, + /* 270 */ 20, 20, 22, 18, 20, 20, 20, 1, 22, 72, + /* 280 */ 166, 248, 27, 149, 150, 30, 483, 37, 0, 151, + /* 290 */ 35, 35, 414, 37, 414, 19, 282, 283, 284, 285, + /* 300 */ 286, 287, 288, 289, 290, 55, 51, 413, 53, 402, + /* 310 */ 22, 35, 14, 58, 59, 437, 221, 439, 20, 224, + /* 320 */ 426, 65, 227, 20, 229, 70, 119, 51, 72, 385, + /* 330 */ 386, 197, 198, 373, 427, 79, 60, 61, 62, 63, + /* 340 */ 373, 65, 204, 205, 206, 293, 71, 209, 429, 416, + /* 350 */ 8, 9, 472, 473, 12, 13, 14, 15, 16, 293, + /* 360 */ 222, 223, 20, 444, 108, 110, 3, 111, 3, 450, + /* 370 */ 451, 233, 166, 21, 236, 385, 121, 239, 240, 241, + /* 380 */ 242, 243, 20, 20, 477, 478, 110, 427, 36, 113, + /* 390 */ 38, 39, 40, 186, 427, 488, 282, 283, 284, 285, + /* 400 */ 286, 287, 288, 289, 290, 149, 150, 189, 153, 154, + /* 410 */ 477, 156, 157, 158, 159, 160, 161, 162, 163, 164, + /* 420 */ 165, 488, 293, 147, 169, 170, 171, 172, 173, 174, + /* 430 */ 175, 293, 177, 178, 179, 4, 446, 447, 183, 184, + /* 440 */ 185, 187, 188, 187, 188, 190, 502, 503, 504, 505, + /* 450 */ 2, 507, 508, 197, 198, 425, 8, 9, 428, 429, + /* 460 */ 12, 13, 14, 15, 16, 71, 248, 191, 212, 193, + /* 470 */ 214, 121, 196, 111, 372, 112, 374, 201, 271, 272, + /* 480 */ 273, 274, 275, 276, 277, 278, 279, 280, 281, 283, + /* 490 */ 284, 285, 189, 8, 9, 79, 220, 12, 13, 14, + /* 500 */ 15, 16, 246, 247, 248, 268, 250, 251, 252, 253, + /* 510 */ 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, + /* 520 */ 264, 265, 266, 267, 268, 12, 13, 428, 429, 414, + /* 530 */ 373, 189, 22, 20, 22, 22, 421, 108, 286, 287, + /* 540 */ 288, 289, 290, 386, 121, 430, 20, 37, 35, 37, + /* 550 */ 37, 122, 189, 124, 125, 126, 127, 128, 129, 130, + /* 560 */ 131, 132, 133, 414, 135, 136, 137, 138, 139, 140, + /* 570 */ 141, 414, 4, 385, 386, 8, 9, 108, 65, 12, + /* 580 */ 13, 14, 15, 16, 427, 72, 429, 19, 439, 79, + /* 590 */ 248, 79, 79, 124, 125, 126, 127, 128, 129, 130, + /* 600 */ 131, 132, 133, 35, 135, 136, 137, 138, 139, 140, + /* 610 */ 141, 0, 385, 0, 20, 88, 51, 385, 108, 51, + /* 620 */ 0, 108, 507, 435, 111, 60, 58, 59, 63, 64, + /* 630 */ 515, 474, 385, 65, 477, 12, 13, 111, 481, 482, + /* 640 */ 483, 484, 485, 486, 415, 488, 385, 386, 533, 534, + /* 650 */ 493, 70, 495, 538, 539, 293, 499, 500, 431, 432, + /* 660 */ 37, 434, 149, 150, 51, 438, 405, 454, 14, 385, + /* 670 */ 246, 20, 459, 412, 20, 49, 519, 14, 110, 112, + /* 680 */ 315, 113, 155, 20, 527, 74, 75, 76, 441, 204, + /* 690 */ 443, 71, 81, 82, 83, 414, 464, 465, 87, 373, + /* 700 */ 187, 188, 415, 92, 93, 94, 95, 180, 181, 98, + /* 710 */ 197, 198, 386, 102, 103, 104, 385, 386, 385, 386, + /* 720 */ 507, 194, 212, 192, 214, 212, 295, 214, 515, 305, + /* 730 */ 306, 307, 308, 309, 310, 311, 405, 111, 405, 268, + /* 740 */ 414, 270, 415, 149, 150, 373, 533, 534, 464, 465, + /* 750 */ 423, 538, 539, 427, 473, 429, 246, 247, 386, 246, + /* 760 */ 247, 248, 111, 250, 251, 252, 253, 254, 255, 256, + /* 770 */ 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, + /* 780 */ 267, 12, 13, 14, 182, 37, 414, 22, 207, 20, + /* 790 */ 454, 22, 142, 143, 144, 145, 146, 147, 148, 427, + /* 800 */ 474, 429, 37, 477, 35, 320, 37, 481, 482, 483, + /* 810 */ 484, 485, 486, 13, 488, 234, 235, 491, 216, 493, + /* 820 */ 494, 495, 392, 111, 373, 499, 500, 373, 0, 415, + /* 830 */ 299, 300, 301, 302, 65, 394, 373, 214, 385, 386, + /* 840 */ 386, 187, 388, 507, 385, 386, 474, 417, 79, 477, + /* 850 */ 187, 515, 411, 481, 482, 483, 484, 485, 486, 401, + /* 860 */ 488, 420, 404, 186, 405, 493, 0, 495, 414, 533, + /* 870 */ 534, 499, 500, 108, 538, 539, 373, 108, 427, 79, + /* 880 */ 111, 427, 0, 429, 480, 74, 75, 76, 435, 386, + /* 890 */ 427, 388, 81, 82, 83, 480, 385, 386, 87, 527, + /* 900 */ 385, 386, 248, 92, 93, 94, 95, 373, 4, 98, + /* 910 */ 506, 248, 0, 102, 103, 104, 405, 414, 149, 150, + /* 920 */ 405, 506, 20, 211, 492, 213, 494, 23, 474, 415, + /* 930 */ 427, 477, 429, 507, 22, 481, 482, 483, 484, 485, + /* 940 */ 486, 515, 488, 373, 293, 385, 386, 493, 271, 495, + /* 950 */ 46, 47, 48, 499, 500, 243, 187, 188, 281, 533, + /* 960 */ 534, 427, 214, 415, 538, 539, 197, 198, 460, 37, + /* 970 */ 142, 143, 144, 145, 146, 147, 148, 474, 385, 386, + /* 980 */ 477, 212, 392, 214, 481, 482, 483, 484, 485, 486, + /* 990 */ 454, 488, 244, 245, 385, 386, 493, 427, 495, 409, + /* 1000 */ 373, 424, 499, 500, 427, 293, 121, 417, 142, 143, + /* 1010 */ 144, 145, 146, 147, 148, 246, 247, 248, 410, 250, + /* 1020 */ 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, + /* 1030 */ 261, 262, 263, 264, 265, 266, 267, 12, 13, 414, + /* 1040 */ 20, 454, 395, 507, 435, 20, 421, 22, 166, 167, + /* 1050 */ 403, 515, 385, 386, 427, 430, 385, 386, 373, 373, + /* 1060 */ 35, 176, 37, 503, 504, 505, 143, 507, 508, 533, + /* 1070 */ 534, 386, 405, 388, 538, 539, 405, 469, 373, 480, + /* 1080 */ 8, 9, 23, 72, 12, 13, 14, 15, 16, 187, + /* 1090 */ 65, 386, 56, 57, 507, 406, 503, 504, 505, 414, + /* 1100 */ 507, 508, 515, 414, 79, 506, 47, 48, 50, 414, + /* 1110 */ 507, 422, 427, 427, 429, 385, 386, 422, 515, 414, + /* 1120 */ 533, 534, 403, 8, 9, 538, 539, 12, 13, 14, + /* 1130 */ 15, 16, 427, 108, 429, 405, 111, 534, 385, 386, + /* 1140 */ 373, 538, 539, 385, 386, 0, 214, 454, 225, 226, + /* 1150 */ 248, 491, 373, 386, 494, 388, 406, 394, 405, 474, + /* 1160 */ 143, 144, 477, 405, 414, 148, 481, 482, 483, 484, + /* 1170 */ 485, 486, 422, 488, 149, 150, 244, 245, 493, 474, + /* 1180 */ 495, 414, 477, 420, 499, 500, 481, 482, 483, 484, + /* 1190 */ 485, 486, 20, 488, 427, 406, 429, 507, 385, 386, + /* 1200 */ 507, 385, 386, 414, 424, 515, 427, 427, 515, 189, + /* 1210 */ 20, 422, 187, 188, 390, 391, 385, 386, 405, 14, + /* 1220 */ 402, 405, 197, 198, 534, 20, 533, 534, 538, 539, + /* 1230 */ 374, 538, 539, 492, 529, 494, 405, 212, 228, 214, + /* 1240 */ 230, 474, 390, 391, 477, 427, 440, 189, 481, 482, + /* 1250 */ 483, 484, 485, 486, 373, 488, 373, 246, 200, 22, + /* 1260 */ 493, 189, 495, 14, 15, 16, 499, 500, 248, 1, + /* 1270 */ 2, 246, 247, 248, 37, 250, 251, 252, 253, 254, + /* 1280 */ 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, + /* 1290 */ 265, 266, 267, 12, 13, 477, 478, 479, 414, 385, + /* 1300 */ 386, 20, 373, 22, 424, 108, 488, 427, 427, 142, + /* 1310 */ 427, 385, 386, 146, 430, 386, 35, 388, 37, 405, + /* 1320 */ 373, 124, 125, 126, 127, 128, 129, 130, 131, 132, + /* 1330 */ 133, 405, 135, 136, 137, 138, 139, 140, 141, 33, + /* 1340 */ 373, 385, 386, 414, 373, 108, 65, 373, 373, 407, + /* 1350 */ 385, 386, 410, 386, 509, 388, 427, 13, 429, 542, + /* 1360 */ 79, 405, 385, 386, 385, 386, 385, 386, 12, 13, + /* 1370 */ 405, 373, 373, 373, 427, 399, 400, 0, 22, 373, + /* 1380 */ 112, 414, 405, 238, 405, 33, 405, 399, 400, 108, + /* 1390 */ 33, 35, 111, 37, 427, 33, 429, 45, 427, 0, + /* 1400 */ 414, 427, 427, 474, 33, 373, 477, 376, 377, 33, + /* 1410 */ 481, 482, 483, 484, 485, 486, 430, 488, 386, 42, + /* 1420 */ 248, 65, 493, 79, 495, 427, 427, 427, 499, 500, + /* 1430 */ 149, 150, 33, 427, 114, 79, 114, 117, 248, 117, + /* 1440 */ 114, 474, 114, 117, 477, 117, 414, 13, 481, 482, + /* 1450 */ 483, 484, 485, 486, 37, 488, 13, 65, 37, 427, + /* 1460 */ 493, 429, 495, 0, 108, 0, 499, 500, 187, 188, + /* 1470 */ 33, 37, 33, 37, 112, 33, 531, 33, 197, 198, + /* 1480 */ 37, 149, 150, 112, 33, 22, 524, 22, 112, 1, + /* 1490 */ 2, 12, 13, 212, 33, 214, 79, 33, 111, 33, + /* 1500 */ 33, 33, 33, 0, 33, 113, 474, 120, 33, 477, + /* 1510 */ 12, 13, 510, 481, 482, 483, 484, 485, 486, 487, + /* 1520 */ 488, 489, 490, 12, 13, 33, 33, 246, 247, 248, + /* 1530 */ 33, 250, 251, 252, 253, 254, 255, 256, 257, 258, + /* 1540 */ 259, 260, 261, 262, 263, 264, 265, 266, 267, 112, + /* 1550 */ 33, 112, 373, 33, 112, 52, 112, 12, 13, 12, + /* 1560 */ 13, 12, 13, 112, 33, 386, 13, 389, 212, 22, + /* 1570 */ 214, 12, 13, 112, 12, 13, 112, 13, 112, 112, + /* 1580 */ 112, 112, 35, 112, 37, 414, 373, 112, 12, 13, + /* 1590 */ 37, 12, 13, 414, 12, 13, 12, 13, 402, 386, + /* 1600 */ 402, 37, 246, 247, 112, 112, 427, 37, 429, 112, + /* 1610 */ 37, 384, 65, 440, 440, 530, 260, 261, 262, 263, + /* 1620 */ 264, 265, 266, 317, 530, 530, 530, 414, 453, 112, + /* 1630 */ 389, 440, 112, 386, 426, 214, 514, 461, 514, 440, + /* 1640 */ 427, 440, 429, 112, 535, 501, 517, 404, 455, 79, + /* 1650 */ 214, 296, 79, 474, 51, 42, 477, 476, 475, 20, + /* 1660 */ 481, 482, 483, 484, 485, 486, 466, 488, 373, 394, + /* 1670 */ 394, 457, 493, 227, 495, 471, 319, 466, 499, 500, + /* 1680 */ 210, 386, 20, 385, 20, 386, 45, 474, 436, 386, + /* 1690 */ 477, 436, 186, 433, 481, 482, 483, 484, 485, 486, + /* 1700 */ 385, 488, 386, 385, 433, 436, 493, 433, 495, 414, + /* 1710 */ 433, 109, 499, 500, 373, 398, 107, 106, 397, 385, + /* 1720 */ 385, 396, 427, 385, 429, 385, 20, 386, 385, 378, + /* 1730 */ 50, 382, 378, 466, 20, 382, 394, 429, 20, 394, + /* 1740 */ 394, 20, 456, 373, 394, 387, 387, 20, 447, 20, + /* 1750 */ 441, 378, 385, 414, 394, 414, 386, 394, 394, 212, + /* 1760 */ 394, 214, 394, 385, 376, 231, 470, 111, 427, 474, + /* 1770 */ 429, 376, 477, 468, 378, 414, 481, 482, 483, 484, + /* 1780 */ 485, 486, 20, 488, 414, 466, 414, 218, 493, 373, + /* 1790 */ 495, 244, 245, 246, 499, 500, 414, 427, 414, 429, + /* 1800 */ 414, 427, 386, 414, 414, 414, 427, 260, 261, 262, + /* 1810 */ 263, 264, 265, 266, 414, 474, 414, 392, 477, 392, + /* 1820 */ 373, 427, 481, 482, 483, 484, 485, 486, 463, 488, + /* 1830 */ 414, 217, 429, 386, 465, 455, 495, 462, 385, 427, + /* 1840 */ 499, 500, 304, 427, 474, 429, 523, 477, 312, 303, + /* 1850 */ 523, 481, 482, 483, 484, 485, 486, 448, 488, 448, + /* 1860 */ 203, 414, 526, 455, 314, 495, 292, 313, 297, 499, + /* 1870 */ 500, 523, 525, 321, 427, 318, 429, 291, 20, 316, + /* 1880 */ 543, 386, 121, 294, 427, 480, 387, 427, 392, 448, + /* 1890 */ 474, 195, 392, 477, 445, 373, 513, 481, 482, 483, + /* 1900 */ 484, 485, 486, 522, 488, 427, 521, 427, 386, 512, + /* 1910 */ 448, 495, 373, 520, 516, 499, 500, 427, 392, 392, + /* 1920 */ 111, 474, 441, 195, 477, 386, 498, 442, 481, 482, + /* 1930 */ 483, 484, 485, 486, 35, 488, 414, 518, 537, 373, + /* 1940 */ 536, 427, 427, 441, 386, 410, 427, 392, 392, 427, + /* 1950 */ 51, 429, 386, 414, 111, 427, 427, 427, 22, 60, + /* 1960 */ 61, 62, 63, 385, 65, 38, 427, 427, 429, 427, + /* 1970 */ 427, 427, 392, 375, 379, 528, 529, 467, 427, 458, + /* 1980 */ 414, 449, 449, 371, 393, 378, 418, 427, 427, 408, + /* 1990 */ 0, 408, 427, 427, 427, 429, 474, 0, 0, 477, + /* 2000 */ 45, 373, 427, 481, 482, 483, 484, 485, 486, 110, + /* 2010 */ 488, 0, 113, 474, 386, 427, 477, 427, 452, 427, + /* 2020 */ 481, 482, 483, 484, 485, 486, 427, 488, 427, 408, + /* 2030 */ 37, 427, 427, 427, 495, 427, 237, 37, 37, 500, + /* 2040 */ 474, 37, 414, 477, 237, 0, 37, 481, 482, 483, + /* 2050 */ 484, 485, 486, 37, 488, 427, 237, 429, 37, 0, + /* 2060 */ 237, 0, 540, 541, 37, 0, 37, 0, 22, 0, + /* 2070 */ 37, 232, 0, 220, 0, 220, 214, 221, 212, 0, + /* 2080 */ 452, 182, 0, 373, 0, 208, 207, 0, 0, 154, + /* 2090 */ 191, 49, 49, 0, 195, 196, 386, 37, 0, 0, + /* 2100 */ 201, 202, 474, 37, 51, 477, 0, 49, 0, 481, + /* 2110 */ 482, 483, 484, 485, 486, 45, 488, 373, 172, 220, + /* 2120 */ 0, 0, 0, 0, 414, 49, 0, 0, 0, 0, + /* 2130 */ 386, 0, 37, 0, 172, 0, 0, 427, 0, 429, + /* 2140 */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + /* 2150 */ 0, 0, 0, 0, 0, 0, 49, 0, 414, 45, + /* 2160 */ 0, 0, 0, 373, 0, 0, 0, 0, 0, 0, + /* 2170 */ 0, 427, 154, 429, 0, 153, 386, 0, 22, 0, + /* 2180 */ 152, 0, 50, 0, 474, 22, 0, 477, 0, 50, + /* 2190 */ 65, 481, 482, 483, 484, 485, 486, 22, 488, 65, + /* 2200 */ 373, 0, 65, 0, 414, 0, 0, 0, 37, 37, + /* 2210 */ 51, 0, 0, 386, 14, 42, 0, 427, 474, 429, + /* 2220 */ 42, 477, 37, 65, 37, 481, 482, 483, 484, 485, + /* 2230 */ 486, 51, 488, 51, 42, 37, 45, 42, 49, 49, + /* 2240 */ 43, 414, 532, 33, 42, 49, 0, 0, 0, 0, + /* 2250 */ 42, 203, 0, 49, 427, 0, 429, 0, 49, 0, + /* 2260 */ 0, 0, 37, 42, 474, 51, 73, 477, 0, 37, + /* 2270 */ 51, 481, 482, 483, 484, 485, 486, 42, 488, 452, + /* 2280 */ 490, 37, 373, 0, 51, 541, 0, 42, 37, 51, + /* 2290 */ 0, 0, 42, 0, 0, 386, 0, 0, 22, 37, + /* 2300 */ 0, 474, 0, 373, 477, 33, 37, 37, 481, 482, + /* 2310 */ 483, 484, 485, 486, 37, 488, 386, 37, 119, 37, + /* 2320 */ 33, 37, 37, 414, 373, 37, 37, 22, 22, 37, + /* 2330 */ 117, 0, 37, 22, 0, 37, 427, 386, 429, 22, + /* 2340 */ 0, 22, 0, 0, 414, 37, 0, 37, 0, 37, + /* 2350 */ 0, 22, 53, 20, 111, 37, 0, 427, 37, 429, + /* 2360 */ 37, 452, 122, 49, 123, 414, 112, 111, 0, 37, + /* 2370 */ 0, 22, 0, 189, 22, 0, 3, 33, 427, 112, + /* 2380 */ 429, 298, 111, 474, 111, 111, 477, 112, 373, 50, + /* 2390 */ 481, 482, 483, 484, 485, 486, 37, 488, 37, 33, + /* 2400 */ 33, 386, 33, 50, 474, 3, 189, 477, 373, 215, + /* 2410 */ 195, 481, 482, 483, 484, 485, 486, 189, 488, 189, + /* 2420 */ 189, 386, 199, 199, 109, 474, 49, 107, 477, 414, + /* 2430 */ 49, 33, 481, 482, 483, 484, 485, 486, 112, 488, + /* 2440 */ 112, 219, 427, 79, 429, 33, 111, 111, 111, 414, + /* 2450 */ 112, 37, 111, 33, 373, 37, 37, 112, 111, 37, + /* 2460 */ 37, 37, 427, 112, 429, 37, 112, 386, 33, 112, + /* 2470 */ 373, 0, 112, 0, 298, 42, 49, 112, 49, 0, + /* 2480 */ 42, 0, 111, 386, 42, 33, 112, 111, 2, 474, + /* 2490 */ 111, 373, 477, 192, 111, 414, 481, 482, 483, 484, + /* 2500 */ 485, 486, 282, 488, 386, 196, 112, 111, 427, 474, + /* 2510 */ 429, 414, 477, 109, 192, 191, 481, 482, 483, 484, + /* 2520 */ 485, 486, 269, 488, 427, 298, 429, 22, 112, 112, + /* 2530 */ 109, 49, 414, 49, 0, 22, 111, 42, 49, 37, + /* 2540 */ 37, 111, 111, 111, 37, 427, 112, 429, 111, 246, + /* 2550 */ 111, 111, 37, 112, 111, 474, 249, 111, 477, 112, + /* 2560 */ 111, 111, 481, 482, 483, 484, 485, 486, 120, 488, + /* 2570 */ 192, 474, 111, 111, 477, 112, 111, 111, 481, 482, + /* 2580 */ 483, 484, 485, 486, 112, 488, 111, 111, 121, 112, + /* 2590 */ 112, 37, 474, 134, 37, 477, 37, 112, 134, 481, + /* 2600 */ 482, 483, 484, 485, 486, 112, 488, 33, 112, 111, + /* 2610 */ 123, 111, 37, 122, 134, 373, 22, 134, 73, 111, + /* 2620 */ 72, 37, 37, 37, 37, 37, 37, 37, 386, 37, + /* 2630 */ 79, 105, 37, 37, 37, 105, 33, 79, 373, 37, + /* 2640 */ 22, 37, 37, 37, 37, 37, 79, 37, 37, 37, + /* 2650 */ 37, 386, 37, 22, 373, 0, 414, 37, 37, 42, + /* 2660 */ 51, 0, 37, 0, 42, 51, 42, 386, 0, 427, + /* 2670 */ 37, 429, 37, 0, 51, 37, 42, 373, 51, 414, + /* 2680 */ 37, 0, 22, 33, 22, 21, 544, 22, 22, 20, + /* 2690 */ 386, 21, 427, 544, 429, 414, 544, 544, 544, 544, + /* 2700 */ 544, 544, 544, 544, 544, 544, 544, 544, 427, 544, + /* 2710 */ 429, 544, 544, 544, 544, 544, 474, 544, 414, 477, + /* 2720 */ 544, 544, 544, 481, 482, 483, 484, 485, 486, 544, + /* 2730 */ 488, 427, 544, 429, 544, 544, 544, 544, 544, 474, + /* 2740 */ 544, 544, 477, 544, 544, 544, 481, 482, 483, 484, + /* 2750 */ 485, 486, 544, 488, 544, 474, 544, 373, 477, 544, + /* 2760 */ 544, 544, 481, 482, 483, 484, 485, 486, 544, 488, + /* 2770 */ 386, 544, 544, 544, 544, 544, 544, 544, 474, 544, + /* 2780 */ 544, 477, 373, 544, 544, 481, 482, 483, 484, 485, + /* 2790 */ 486, 544, 488, 544, 544, 386, 544, 544, 414, 373, + /* 2800 */ 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + /* 2810 */ 544, 427, 386, 429, 544, 544, 544, 544, 544, 544, + /* 2820 */ 544, 544, 544, 414, 544, 544, 544, 544, 544, 544, + /* 2830 */ 544, 544, 544, 544, 544, 544, 427, 544, 429, 544, + /* 2840 */ 414, 544, 544, 544, 544, 544, 544, 544, 544, 544, + /* 2850 */ 544, 544, 544, 427, 544, 429, 544, 544, 474, 544, + /* 2860 */ 544, 477, 544, 373, 544, 481, 482, 483, 484, 485, + /* 2870 */ 486, 544, 488, 544, 544, 544, 386, 544, 544, 544, + /* 2880 */ 544, 544, 544, 474, 544, 373, 477, 544, 544, 544, + /* 2890 */ 481, 482, 483, 484, 485, 486, 544, 488, 386, 544, + /* 2900 */ 474, 544, 544, 477, 414, 544, 544, 481, 482, 483, + /* 2910 */ 484, 485, 486, 544, 488, 544, 544, 427, 544, 429, + /* 2920 */ 544, 544, 544, 544, 544, 544, 414, 544, 544, 373, + /* 2930 */ 544, 544, 544, 544, 544, 544, 544, 544, 544, 427, + /* 2940 */ 544, 429, 386, 544, 544, 544, 544, 544, 544, 544, + /* 2950 */ 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + /* 2960 */ 544, 544, 544, 544, 474, 544, 373, 477, 544, 544, + /* 2970 */ 414, 481, 482, 483, 484, 485, 486, 544, 488, 386, + /* 2980 */ 544, 544, 544, 427, 544, 429, 474, 544, 544, 477, + /* 2990 */ 544, 544, 544, 481, 482, 483, 484, 485, 486, 544, + /* 3000 */ 488, 544, 373, 544, 544, 544, 544, 414, 544, 544, + /* 3010 */ 544, 544, 544, 544, 544, 386, 544, 544, 544, 544, + /* 3020 */ 427, 544, 429, 544, 544, 544, 544, 544, 544, 544, + /* 3030 */ 474, 544, 544, 477, 544, 544, 544, 481, 482, 483, + /* 3040 */ 484, 485, 486, 414, 488, 544, 544, 544, 544, 544, + /* 3050 */ 544, 373, 544, 544, 544, 544, 427, 544, 429, 544, + /* 3060 */ 544, 544, 544, 544, 386, 544, 544, 474, 544, 544, + /* 3070 */ 477, 544, 544, 544, 481, 482, 483, 484, 485, 486, + /* 3080 */ 544, 488, 373, 544, 544, 544, 544, 544, 544, 544, + /* 3090 */ 544, 544, 414, 544, 544, 386, 544, 544, 544, 544, + /* 3100 */ 544, 544, 544, 474, 544, 427, 477, 429, 544, 544, + /* 3110 */ 481, 482, 483, 484, 485, 486, 373, 488, 544, 544, + /* 3120 */ 544, 544, 544, 414, 544, 544, 544, 544, 544, 386, + /* 3130 */ 544, 544, 544, 544, 544, 544, 427, 544, 429, 544, + /* 3140 */ 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + /* 3150 */ 544, 544, 474, 544, 544, 477, 544, 414, 544, 481, + /* 3160 */ 482, 483, 484, 485, 486, 544, 488, 544, 544, 544, + /* 3170 */ 427, 544, 429, 544, 544, 544, 544, 544, 544, 544, + /* 3180 */ 544, 544, 544, 474, 544, 544, 477, 544, 544, 544, + /* 3190 */ 481, 482, 483, 484, 485, 486, 544, 488, 544, 544, + /* 3200 */ 544, 544, 544, 544, 544, 544, 544, 544, 544, 544, + /* 3210 */ 544, 544, 544, 544, 544, 544, 544, 474, 544, 544, + /* 3220 */ 477, 544, 544, 544, 481, 482, 483, 484, 485, 486, + /* 3230 */ 544, 488, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3240 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3250 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3260 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3270 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3280 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3290 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3300 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3310 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3320 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3330 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3340 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3350 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3360 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3370 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3380 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3390 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3400 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3410 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3420 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3430 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3440 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3450 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3460 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3470 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3480 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3490 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3500 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3510 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3520 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3530 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3540 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3550 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3560 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3570 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3580 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3590 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, + /* 3600 */ 370, 370, }; -#define YY_SHIFT_COUNT (917) +#define YY_SHIFT_COUNT (947) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2651) +#define YY_SHIFT_MAX (2681) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 508, 0, 253, 0, 507, 507, 507, 507, 507, 507, - /* 10 */ 507, 507, 507, 507, 507, 507, 760, 1013, 1013, 1266, - /* 20 */ 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, - /* 30 */ 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, - /* 40 */ 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, 1013, - /* 50 */ 697, 942, 235, 576, 260, 495, 260, 260, 576, 576, - /* 60 */ 260, 1383, 260, 252, 1383, 73, 260, 20, 1520, 916, - /* 70 */ 126, 126, 1520, 1520, 35, 35, 916, 525, 43, 146, - /* 80 */ 146, 1, 126, 126, 126, 126, 126, 126, 126, 126, - /* 90 */ 126, 126, 126, 263, 281, 126, 126, 139, 20, 126, - /* 100 */ 263, 126, 20, 126, 126, 20, 126, 126, 20, 126, - /* 110 */ 20, 20, 20, 126, 330, 212, 212, 497, 1136, 13, - /* 120 */ 312, 249, 249, 249, 249, 249, 249, 249, 249, 249, - /* 130 */ 249, 249, 249, 249, 249, 249, 249, 249, 249, 249, - /* 140 */ 573, 33, 525, 43, 1132, 1132, 1030, 665, 665, 665, - /* 150 */ 510, 510, 203, 486, 1030, 139, 20, 121, 20, 4, - /* 160 */ 20, 20, 399, 20, 399, 399, 585, 709, 250, 1476, - /* 170 */ 1476, 1476, 1476, 1476, 1476, 753, 2217, 208, 339, 520, - /* 180 */ 520, 717, 164, 424, 82, 565, 138, 148, 662, 30, - /* 190 */ 30, 546, 898, 959, 524, 524, 524, 737, 953, 524, - /* 200 */ 894, 1166, 1106, 1101, 1162, 1166, 1166, 1234, 877, 877, - /* 210 */ 1090, 1346, 1283, 486, 1378, 1623, 1636, 1657, 1458, 139, - /* 220 */ 1657, 139, 1488, 1678, 1680, 1659, 1680, 1659, 1524, 1678, - /* 230 */ 1680, 1678, 1659, 1524, 1524, 1524, 1625, 1628, 1678, 1678, - /* 240 */ 1633, 1678, 1678, 1678, 1724, 1697, 1724, 1697, 1657, 139, - /* 250 */ 139, 1736, 139, 1745, 1747, 139, 1745, 139, 1752, 139, - /* 260 */ 139, 1678, 139, 1724, 20, 20, 20, 20, 20, 20, - /* 270 */ 20, 20, 20, 20, 20, 1678, 709, 709, 1724, 399, - /* 280 */ 399, 399, 1568, 1737, 1657, 330, 1827, 1647, 1653, 1736, - /* 290 */ 330, 1378, 1678, 399, 1569, 1578, 1569, 1578, 1571, 1682, - /* 300 */ 1569, 1572, 1580, 1598, 1378, 1606, 1608, 1579, 1584, 1585, - /* 310 */ 1680, 1882, 1782, 1616, 1745, 330, 330, 1797, 1578, 399, - /* 320 */ 399, 399, 399, 1578, 399, 1742, 330, 585, 330, 1680, - /* 330 */ 399, 399, 399, 399, 399, 399, 399, 399, 399, 399, - /* 340 */ 399, 399, 399, 399, 399, 399, 399, 399, 399, 399, - /* 350 */ 399, 399, 1843, 399, 1678, 330, 1946, 1953, 1724, 3171, - /* 360 */ 3171, 3171, 3171, 3171, 3171, 3171, 3171, 3171, 38, 759, - /* 370 */ 66, 1096, 441, 36, 851, 300, 555, 684, 70, 392, - /* 380 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 1022, - /* 390 */ 516, 160, 578, 578, 708, 671, 690, 661, 580, 572, - /* 400 */ 687, 444, 1010, 1138, 440, 3, 1115, 773, 3, 3, - /* 410 */ 3, 853, 853, 943, 1300, 1313, 1370, 1365, 1279, 1373, - /* 420 */ 1305, 1312, 1323, 1327, 1372, 1371, 1429, 1446, 1447, 1456, - /* 430 */ 1463, 563, 1374, 1380, 1352, 1388, 1424, 1426, 1438, 1324, - /* 440 */ 327, 1281, 1448, 1481, 1454, 803, 1455, 1423, 1457, 1461, - /* 450 */ 1464, 1508, 1510, 1486, 1492, 1541, 1552, 1558, 1567, 1570, - /* 460 */ 1574, 1576, 1583, 1586, 1506, 1519, 1526, 1535, 1544, 1548, - /* 470 */ 1347, 1427, 1452, 1459, 1611, 1612, 1433, 1621, 2015, 2021, - /* 480 */ 2022, 1978, 2024, 1988, 1792, 1990, 1991, 1993, 1798, 2033, - /* 490 */ 1997, 1998, 1802, 2000, 2038, 1805, 2040, 2004, 2042, 2007, - /* 500 */ 2043, 2023, 2047, 2011, 1820, 2050, 1835, 2053, 1837, 1838, - /* 510 */ 1844, 1848, 2058, 2060, 2062, 1858, 1860, 2065, 2066, 1913, - /* 520 */ 2019, 2020, 2070, 2034, 2072, 2074, 2041, 2026, 2075, 2037, - /* 530 */ 2079, 2044, 2088, 2090, 2091, 2045, 2092, 2093, 2095, 2097, - /* 540 */ 2098, 2099, 1928, 2064, 2102, 1932, 2105, 2107, 2108, 2118, - /* 550 */ 2119, 2120, 2121, 2122, 2123, 2124, 2125, 2126, 2127, 2128, - /* 560 */ 2134, 2135, 2136, 2138, 2139, 2081, 2131, 2087, 2140, 2141, - /* 570 */ 2142, 2143, 2144, 2145, 2147, 2148, 2129, 2149, 1999, 2154, - /* 580 */ 2002, 2156, 2008, 2158, 2159, 2146, 2112, 2151, 2113, 2164, - /* 590 */ 2100, 2166, 2104, 2153, 2167, 2106, 2175, 2111, 2177, 2178, - /* 600 */ 2155, 2132, 2137, 2180, 2161, 2133, 2157, 2181, 2163, 2160, - /* 610 */ 2165, 2182, 2173, 2185, 2150, 2170, 2186, 2171, 2183, 2172, - /* 620 */ 2184, 2188, 2201, 2195, 2191, 2193, 2196, 2213, 2204, 2027, - /* 630 */ 2215, 2171, 2198, 2249, 2250, 2187, 2251, 2253, 2218, 2203, - /* 640 */ 2214, 2258, 2222, 2212, 2223, 2264, 2229, 2216, 2227, 2271, - /* 650 */ 2236, 2230, 2232, 2283, 2284, 2285, 2286, 2287, 2288, 2174, - /* 660 */ 2179, 2257, 2268, 2295, 2260, 2261, 2262, 2263, 2265, 2267, - /* 670 */ 2269, 2270, 2272, 2275, 2277, 2274, 2276, 2279, 2282, 2305, - /* 680 */ 2290, 2315, 2298, 2329, 2309, 2281, 2332, 2313, 2300, 2339, - /* 690 */ 2346, 2348, 2312, 2350, 2316, 2352, 2333, 2334, 2319, 2320, - /* 700 */ 2321, 2247, 2254, 2366, 2189, 2239, 2252, 2266, 2168, 2171, - /* 710 */ 2324, 2362, 2192, 2343, 2360, 2383, 2176, 2363, 2197, 2199, - /* 720 */ 2387, 2390, 2206, 2200, 2208, 2205, 2395, 2369, 2109, 2292, - /* 730 */ 2293, 2296, 2294, 2356, 2372, 2299, 2349, 2302, 2364, 2311, - /* 740 */ 2304, 2379, 2386, 2308, 2310, 2314, 2317, 2325, 2391, 2374, - /* 750 */ 2377, 2318, 2394, 2162, 2354, 2326, 2398, 2331, 2403, 2337, - /* 760 */ 2340, 2448, 2420, 2169, 2418, 2421, 2422, 2423, 2424, 2425, - /* 770 */ 2353, 2355, 2417, 2190, 2435, 2426, 2470, 2471, 2368, 2430, - /* 780 */ 2440, 2371, 2221, 2381, 2487, 2469, 2256, 2382, 2384, 2392, - /* 790 */ 2393, 2400, 2404, 2405, 2385, 2443, 2406, 2407, 2444, 2402, - /* 800 */ 2473, 2273, 2410, 2412, 2413, 2411, 2415, 2342, 2427, 2502, - /* 810 */ 2491, 2345, 2428, 2429, 2171, 2488, 2431, 2432, 2433, 2436, - /* 820 */ 2437, 2419, 2434, 2507, 2513, 2441, 2439, 2516, 2446, 2447, - /* 830 */ 2518, 2392, 2449, 2521, 2393, 2450, 2523, 2400, 2451, 2527, - /* 840 */ 2404, 2442, 2445, 2452, 2453, 2454, 2456, 2455, 2532, 2457, - /* 850 */ 2530, 2458, 2532, 2532, 2548, 2498, 2501, 2537, 2538, 2543, - /* 860 */ 2544, 2545, 2546, 2547, 2551, 2553, 2554, 2555, 2514, 2489, - /* 870 */ 2517, 2490, 2564, 2562, 2563, 2566, 2582, 2577, 2578, 2579, - /* 880 */ 2539, 2275, 2580, 2277, 2583, 2584, 2585, 2588, 2597, 2590, - /* 890 */ 2623, 2592, 2581, 2589, 2633, 2598, 2587, 2594, 2634, 2600, - /* 900 */ 2591, 2599, 2639, 2603, 2593, 2604, 2647, 2612, 2613, 2651, - /* 910 */ 2631, 2621, 2635, 2637, 2638, 2640, 2642, 2636, + /* 0 */ 138, 0, 256, 0, 513, 513, 513, 513, 513, 513, + /* 10 */ 513, 513, 513, 513, 513, 513, 769, 1025, 1025, 1281, + /* 20 */ 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, + /* 30 */ 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, + /* 40 */ 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, 1025, + /* 50 */ 362, 651, 712, 526, 52, 129, 52, 52, 526, 526, + /* 60 */ 52, 1356, 52, 255, 1356, 66, 52, 55, 1547, 134, + /* 70 */ 134, 125, 125, 1547, 1547, 904, 904, 134, 254, 594, + /* 80 */ 298, 298, 33, 125, 125, 125, 125, 125, 125, 125, + /* 90 */ 125, 125, 125, 125, 164, 193, 251, 125, 125, 275, + /* 100 */ 55, 125, 164, 125, 55, 125, 125, 125, 125, 55, + /* 110 */ 125, 125, 55, 125, 55, 55, 55, 125, 394, 207, + /* 120 */ 207, 469, 811, 14, 73, 510, 510, 510, 510, 510, + /* 130 */ 510, 510, 510, 510, 510, 510, 510, 510, 510, 510, + /* 140 */ 510, 510, 510, 510, 28, 363, 254, 594, 1036, 1036, + /* 150 */ 156, 303, 303, 303, 471, 471, 620, 800, 156, 275, + /* 160 */ 55, 350, 55, 55, 237, 55, 416, 55, 416, 416, + /* 170 */ 423, 32, 429, 1197, 1197, 1197, 1197, 1197, 1197, 276, + /* 180 */ 611, 57, 342, 114, 114, 485, 424, 531, 252, 250, + /* 190 */ 206, 654, 663, 623, 623, 218, 1059, 1020, 512, 512, + /* 200 */ 512, 1058, 512, 902, 189, 1172, 1205, 1167, 602, 1172, + /* 210 */ 1172, 1190, 1344, 1344, 365, 127, 431, 800, 1355, 1603, + /* 220 */ 1613, 1639, 1446, 275, 1639, 275, 1470, 1662, 1664, 1641, + /* 230 */ 1664, 1641, 1506, 1662, 1664, 1662, 1641, 1506, 1506, 1506, + /* 240 */ 1602, 1609, 1662, 1662, 1611, 1662, 1662, 1662, 1706, 1680, + /* 250 */ 1706, 1680, 1639, 275, 275, 1714, 275, 1718, 1721, 275, + /* 260 */ 1718, 275, 1727, 275, 1729, 275, 275, 1662, 275, 1706, + /* 270 */ 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, + /* 280 */ 55, 1662, 32, 32, 1706, 416, 416, 416, 1534, 1656, + /* 290 */ 1639, 394, 1762, 1569, 1614, 1714, 394, 1355, 1662, 416, + /* 300 */ 1538, 1546, 1538, 1546, 1536, 1657, 1538, 1550, 1554, 1571, + /* 310 */ 1355, 1574, 1586, 1552, 1557, 1563, 1664, 1858, 1761, 1589, + /* 320 */ 1718, 394, 394, 1546, 416, 416, 416, 416, 1546, 416, + /* 330 */ 1696, 394, 416, 1729, 394, 1809, 416, 1728, 1729, 394, + /* 340 */ 423, 394, 1664, 416, 416, 416, 416, 416, 416, 416, + /* 350 */ 416, 416, 416, 416, 416, 416, 416, 416, 416, 416, + /* 360 */ 416, 416, 416, 416, 416, 1843, 416, 1662, 394, 1936, + /* 370 */ 1927, 1706, 3232, 3232, 3232, 3232, 3232, 3232, 3232, 3232, + /* 380 */ 3232, 38, 1899, 201, 568, 36, 46, 567, 15, 448, + /* 390 */ 1072, 828, 866, 1115, 1115, 1115, 1115, 1115, 1115, 1115, + /* 400 */ 1115, 1115, 650, 95, 527, 352, 27, 27, 581, 42, + /* 410 */ 3, 565, 748, 932, 882, 765, 1237, 923, 1017, 1017, + /* 420 */ 1249, 1268, 677, 1249, 1249, 1249, 613, 1145, 1362, 1377, + /* 430 */ 1352, 885, 1399, 1320, 1322, 1326, 1328, 1417, 1434, 1443, + /* 440 */ 288, 912, 1463, 1465, 1010, 1371, 1376, 1392, 1437, 1439, + /* 450 */ 1442, 1444, 1332, 1306, 1357, 1451, 1461, 1464, 1488, 1466, + /* 460 */ 1011, 1467, 626, 1468, 1469, 1471, 1475, 1479, 1498, 1511, + /* 470 */ 1545, 1549, 1559, 1562, 1576, 1579, 1582, 1584, 1492, 1493, + /* 480 */ 1497, 1517, 1520, 1531, 1387, 1570, 1421, 1436, 1553, 1564, + /* 490 */ 1573, 1503, 1990, 1997, 1998, 1955, 2011, 1993, 1799, 2000, + /* 500 */ 2001, 2004, 1807, 2045, 2009, 2016, 1819, 2021, 2059, 1823, + /* 510 */ 2061, 2027, 2065, 2029, 2067, 2046, 2069, 2033, 1839, 2072, + /* 520 */ 1853, 2074, 1855, 1856, 1862, 1866, 2079, 2082, 2084, 1877, + /* 530 */ 1879, 2087, 2088, 1935, 2042, 2043, 2093, 2060, 2098, 2099, + /* 540 */ 2066, 2053, 2106, 2058, 2108, 2070, 2120, 2121, 2122, 2076, + /* 550 */ 2123, 2126, 2127, 2128, 2129, 2131, 1946, 2095, 2133, 1962, + /* 560 */ 2135, 2136, 2138, 2140, 2141, 2142, 2143, 2144, 2145, 2146, + /* 570 */ 2147, 2148, 2149, 2150, 2151, 2152, 2153, 2154, 2155, 2107, + /* 580 */ 2157, 2114, 2160, 2161, 2162, 2164, 2165, 2166, 2167, 2168, + /* 590 */ 2169, 2156, 2170, 2018, 2174, 2022, 2177, 2028, 2179, 2181, + /* 600 */ 2163, 2132, 2175, 2139, 2183, 2125, 2186, 2134, 2171, 2188, + /* 610 */ 2137, 2201, 2158, 2203, 2205, 2172, 2159, 2173, 2206, 2185, + /* 620 */ 2180, 2178, 2207, 2187, 2182, 2192, 2211, 2198, 2212, 2191, + /* 630 */ 2195, 2210, 2189, 2190, 2200, 2196, 2216, 2197, 2202, 2246, + /* 640 */ 2247, 2248, 2249, 2208, 2048, 2252, 2189, 2204, 2255, 2189, + /* 650 */ 2209, 2257, 2259, 2193, 2260, 2261, 2225, 2214, 2221, 2268, + /* 660 */ 2232, 2219, 2235, 2283, 2244, 2233, 2245, 2286, 2251, 2238, + /* 670 */ 2250, 2290, 2291, 2293, 2294, 2296, 2297, 2199, 2213, 2262, + /* 680 */ 2276, 2300, 2269, 2270, 2277, 2280, 2282, 2284, 2285, 2288, + /* 690 */ 2289, 2272, 2287, 2292, 2295, 2305, 2298, 2302, 2306, 2331, + /* 700 */ 2311, 2334, 2317, 2299, 2340, 2319, 2308, 2342, 2343, 2346, + /* 710 */ 2310, 2348, 2312, 2350, 2329, 2333, 2318, 2321, 2323, 2254, + /* 720 */ 2243, 2356, 2184, 2240, 2241, 2256, 2222, 2189, 2314, 2368, + /* 730 */ 2217, 2332, 2349, 2370, 2194, 2352, 2228, 2215, 2372, 2375, + /* 740 */ 2230, 2223, 2231, 2224, 2373, 2344, 2083, 2271, 2267, 2273, + /* 750 */ 2275, 2359, 2361, 2274, 2339, 2315, 2353, 2320, 2326, 2366, + /* 760 */ 2367, 2328, 2335, 2336, 2337, 2338, 2369, 2377, 2381, 2341, + /* 770 */ 2398, 2176, 2364, 2345, 2412, 2347, 2414, 2351, 2354, 2402, + /* 780 */ 2420, 2227, 2418, 2419, 2422, 2423, 2424, 2428, 2357, 2360, + /* 790 */ 2427, 2220, 2435, 2429, 2471, 2473, 2371, 2433, 2365, 2374, + /* 800 */ 2376, 2379, 2301, 2383, 2479, 2438, 2309, 2481, 2394, 2396, + /* 810 */ 2322, 2442, 2324, 2452, 2404, 2253, 2421, 2486, 2505, 2303, + /* 820 */ 2416, 2417, 2425, 2430, 2431, 2432, 2437, 2434, 2482, 2439, + /* 830 */ 2440, 2484, 2441, 2513, 2307, 2443, 2446, 2534, 2447, 2449, + /* 840 */ 2378, 2495, 2450, 2448, 2189, 2489, 2461, 2462, 2463, 2465, + /* 850 */ 2466, 2467, 2472, 2502, 2503, 2475, 2477, 2507, 2476, 2478, + /* 860 */ 2515, 2425, 2485, 2554, 2430, 2493, 2557, 2431, 2496, 2559, + /* 870 */ 2432, 2459, 2464, 2480, 2483, 2487, 2491, 2498, 2574, 2500, + /* 880 */ 2575, 2508, 2574, 2574, 2594, 2545, 2548, 2584, 2585, 2586, + /* 890 */ 2587, 2588, 2589, 2590, 2592, 2595, 2596, 2597, 2551, 2526, + /* 900 */ 2558, 2530, 2603, 2602, 2604, 2605, 2618, 2606, 2607, 2608, + /* 910 */ 2567, 2272, 2610, 2287, 2611, 2612, 2613, 2615, 2631, 2620, + /* 920 */ 2655, 2621, 2609, 2617, 2661, 2625, 2614, 2622, 2663, 2633, + /* 930 */ 2623, 2624, 2668, 2635, 2627, 2634, 2673, 2638, 2643, 2681, + /* 940 */ 2660, 2650, 2662, 2664, 2665, 2666, 2670, 2669, }; -#define YY_REDUCE_COUNT (367) -#define YY_REDUCE_MIN (-501) -#define YY_REDUCE_MAX (2688) +#define YY_REDUCE_COUNT (380) +#define YY_REDUCE_MIN (-496) +#define YY_REDUCE_MAX (2743) static const short yy_reduce_ofst[] = { - /* 0 */ 975, -324, 190, 406, 426, 506, 657, 703, 910, 956, - /* 10 */ 619, 872, 1069, 1208, 1322, 1342, 171, 1362, 1381, 1462, - /* 20 */ 1494, 1521, 1605, 1635, 1726, 1746, 1763, 1846, 1240, 1865, - /* 30 */ 1892, 1968, 2006, 2030, 2052, 2130, 2202, 2219, 2241, 2278, - /* 40 */ 2341, 2361, 2380, 2464, 2482, 2499, 2586, 2602, 2625, 2688, - /* 50 */ -326, -342, -423, -102, 527, 530, 543, 693, -178, 206, - /* 60 */ 796, -398, -499, -367, -383, -501, 23, 412, -252, 50, - /* 70 */ -53, 198, -137, -43, -374, -274, -421, -254, -248, -93, - /* 80 */ 95, 262, -76, 410, 540, 542, -115, -105, 570, 702, - /* 90 */ 720, 770, 176, 64, 404, 774, 831, -337, 132, 833, - /* 100 */ 222, 902, 469, 907, 909, 587, 925, 930, 731, 933, - /* 110 */ 653, 766, 658, 955, 45, -58, -58, -189, 637, -494, - /* 120 */ 92, -323, -20, 14, 409, 468, 568, 719, 721, 735, - /* 130 */ 749, 817, 821, 825, 829, 835, 878, 882, 929, 940, - /* 140 */ 42, -357, 638, 654, 849, 863, 885, -357, 47, 437, - /* 150 */ 445, 832, 905, 273, 966, 939, -407, 675, 696, 837, - /* 160 */ 906, 407, 109, 949, 934, 947, 965, 1020, 449, 523, - /* 170 */ 558, 626, 718, 791, 449, 983, 526, 1043, 964, 927, - /* 180 */ 927, 995, 976, 1054, 1057, 1188, 927, 1179, 1179, 1194, - /* 190 */ 1229, 1192, 1249, 1196, 1111, 1112, 1113, 1203, 1179, 1128, - /* 200 */ 1253, 1216, 1271, 1232, 1202, 1221, 1222, 1179, 1153, 1154, - /* 210 */ 1139, 1170, 1156, 1268, 1223, 1205, 1211, 1231, 1224, 1290, - /* 220 */ 1233, 1303, 1245, 1317, 1320, 1273, 1326, 1274, 1284, 1331, - /* 230 */ 1338, 1341, 1291, 1296, 1297, 1298, 1335, 1343, 1354, 1356, - /* 240 */ 1348, 1358, 1360, 1361, 1375, 1376, 1377, 1379, 1289, 1363, - /* 250 */ 1366, 1333, 1369, 1385, 1321, 1384, 1386, 1393, 1334, 1394, - /* 260 */ 1396, 1407, 1400, 1401, 1392, 1395, 1397, 1398, 1403, 1412, - /* 270 */ 1414, 1415, 1416, 1417, 1418, 1413, 1421, 1439, 1468, 1410, - /* 280 */ 1422, 1430, 1387, 1391, 1390, 1466, 1406, 1409, 1419, 1442, - /* 290 */ 1480, 1425, 1489, 1465, 1355, 1434, 1364, 1437, 1367, 1382, - /* 300 */ 1389, 1405, 1399, 1408, 1444, 1402, 1404, 1357, 1428, 1420, - /* 310 */ 1517, 1443, 1411, 1436, 1527, 1523, 1530, 1432, 1471, 1501, - /* 320 */ 1502, 1503, 1504, 1487, 1507, 1497, 1547, 1536, 1559, 1566, - /* 330 */ 1528, 1529, 1531, 1533, 1534, 1537, 1539, 1540, 1542, 1553, - /* 340 */ 1554, 1555, 1556, 1557, 1560, 1561, 1562, 1563, 1582, 1587, - /* 350 */ 1588, 1589, 1545, 1590, 1600, 1594, 1618, 1617, 1619, 1543, - /* 360 */ 1546, 1565, 1577, 1597, 1599, 1604, 1620, 1651, + /* 0 */ -297, 157, 326, 372, 454, 503, 685, 767, 929, 967, + /* 10 */ 1179, 1213, 1295, 1341, 1370, 1416, 1032, 1447, 1522, 1539, + /* 20 */ 705, 1566, 1628, 1710, 1744, 1790, 1827, 1909, 1930, 1951, + /* 30 */ 2015, 2035, 2081, 2097, 2118, 2242, 2265, 2281, 2304, 2384, + /* 40 */ 2409, 2426, 2490, 2512, 2556, 2593, 2629, 2678, 2709, 2743, + /* 50 */ -339, 115, 213, -56, -348, 336, 536, 587, 560, 593, + /* 60 */ 693, 818, 426, 227, -93, 603, 690, -396, -414, -248, + /* 70 */ -81, -295, 261, -243, -67, -376, -288, -418, -122, 30, + /* 80 */ -366, -234, -197, 331, 333, 459, 511, 188, 453, 515, + /* 90 */ 667, 671, 730, 609, 232, -10, 247, 753, 758, 441, + /* 100 */ -120, 813, 284, 816, -405, 831, 914, 926, 956, 689, + /* 110 */ 965, 977, -350, 979, 750, 625, 789, 981, 590, -496, + /* 120 */ -496, 327, 647, -475, 102, -40, -33, 451, 463, 534, + /* 130 */ 570, 627, 686, 779, 881, 883, 947, 971, 974, 975, + /* 140 */ 998, 999, 1000, 1006, -106, 404, 149, 99, 824, 852, + /* 150 */ 976, 404, 415, 599, 432, 741, 430, 458, 988, 763, + /* 160 */ 281, 608, -321, 884, 660, 695, 577, 986, 780, 880, + /* 170 */ 942, 1031, -409, 229, 287, 414, 514, 548, -409, 508, + /* 180 */ 719, 856, 806, 845, 845, 817, 945, 962, 1002, 1178, + /* 190 */ 845, 1171, 1171, 1196, 1198, 1173, 1227, 1174, 1085, 1094, + /* 200 */ 1095, 1175, 1096, 1171, 1241, 1191, 1247, 1208, 1176, 1199, + /* 210 */ 1201, 1171, 1122, 1124, 1109, 1144, 1129, 1243, 1193, 1181, + /* 220 */ 1183, 1200, 1204, 1275, 1211, 1276, 1214, 1298, 1299, 1252, + /* 230 */ 1303, 1255, 1260, 1315, 1316, 1318, 1269, 1271, 1274, 1277, + /* 240 */ 1317, 1321, 1334, 1335, 1325, 1338, 1340, 1343, 1351, 1349, + /* 250 */ 1354, 1353, 1267, 1342, 1345, 1308, 1346, 1358, 1286, 1350, + /* 260 */ 1359, 1360, 1301, 1363, 1309, 1364, 1366, 1367, 1368, 1373, + /* 270 */ 1339, 1361, 1372, 1382, 1384, 1386, 1389, 1390, 1391, 1400, + /* 280 */ 1402, 1378, 1388, 1395, 1396, 1374, 1379, 1394, 1296, 1305, + /* 290 */ 1319, 1425, 1369, 1365, 1375, 1403, 1427, 1380, 1453, 1412, + /* 300 */ 1323, 1409, 1327, 1411, 1336, 1347, 1348, 1381, 1385, 1393, + /* 310 */ 1408, 1383, 1397, 1337, 1401, 1404, 1495, 1405, 1419, 1398, + /* 320 */ 1499, 1496, 1500, 1441, 1457, 1460, 1478, 1480, 1462, 1490, + /* 330 */ 1449, 1526, 1514, 1481, 1527, 1428, 1515, 1485, 1502, 1555, + /* 340 */ 1535, 1556, 1558, 1519, 1528, 1529, 1530, 1540, 1542, 1543, + /* 350 */ 1544, 1551, 1560, 1561, 1565, 1567, 1575, 1588, 1590, 1592, + /* 360 */ 1599, 1601, 1604, 1605, 1606, 1568, 1608, 1578, 1580, 1598, + /* 370 */ 1595, 1607, 1521, 1510, 1532, 1533, 1581, 1583, 1621, 1591, + /* 380 */ 1612, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 10 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 20 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 30 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 40 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 50 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 60 */ 2454, 2100, 2100, 2417, 2100, 2100, 2100, 2100, 2100, 2100, - /* 70 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2424, 2100, 2100, - /* 80 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 90 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2200, 2100, 2100, - /* 100 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 110 */ 2100, 2100, 2100, 2100, 2198, 2703, 2100, 2100, 2100, 2732, - /* 120 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 130 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 140 */ 2100, 2715, 2100, 2100, 2171, 2171, 2100, 2715, 2715, 2715, - /* 150 */ 2675, 2675, 2198, 2100, 2100, 2200, 2100, 2496, 2100, 2100, - /* 160 */ 2100, 2100, 2100, 2100, 2100, 2100, 2335, 2130, 2494, 2100, - /* 170 */ 2100, 2100, 2100, 2100, 2100, 2100, 2480, 2100, 2761, 2707, - /* 180 */ 2708, 2823, 2100, 2764, 2726, 2100, 2721, 2100, 2100, 2100, - /* 190 */ 2100, 2429, 2100, 2751, 2100, 2100, 2100, 2100, 2100, 2100, - /* 200 */ 2100, 2100, 2100, 2283, 2474, 2100, 2100, 2100, 2100, 2100, - /* 210 */ 2807, 2705, 2745, 2100, 2755, 2100, 2521, 2100, 2510, 2200, - /* 220 */ 2100, 2200, 2467, 2412, 2100, 2422, 2100, 2422, 2419, 2100, - /* 230 */ 2100, 2100, 2422, 2419, 2419, 2419, 2272, 2268, 2100, 2100, - /* 240 */ 2266, 2100, 2100, 2100, 2100, 2155, 2100, 2155, 2100, 2200, - /* 250 */ 2200, 2100, 2200, 2100, 2100, 2200, 2100, 2200, 2100, 2200, - /* 260 */ 2200, 2100, 2200, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 270 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 280 */ 2100, 2100, 2508, 2490, 2100, 2198, 2100, 2478, 2476, 2100, - /* 290 */ 2198, 2755, 2100, 2100, 2777, 2772, 2777, 2772, 2791, 2787, - /* 300 */ 2777, 2796, 2793, 2757, 2755, 2738, 2734, 2826, 2813, 2809, - /* 310 */ 2100, 2100, 2743, 2741, 2100, 2198, 2198, 2100, 2772, 2100, - /* 320 */ 2100, 2100, 2100, 2772, 2100, 2100, 2198, 2100, 2198, 2100, - /* 330 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 340 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 350 */ 2100, 2100, 2299, 2100, 2100, 2198, 2100, 2139, 2100, 2469, - /* 360 */ 2499, 2450, 2450, 2338, 2338, 2338, 2201, 2105, 2100, 2100, - /* 370 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 380 */ 2790, 2789, 2626, 2100, 2679, 2678, 2677, 2668, 2625, 2295, - /* 390 */ 2100, 2100, 2624, 2623, 2100, 2100, 2100, 2100, 2100, 2100, - /* 400 */ 2100, 2100, 2100, 2100, 2100, 2617, 2100, 2100, 2618, 2616, - /* 410 */ 2615, 2441, 2440, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 420 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 430 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 440 */ 2810, 2814, 2100, 2704, 2100, 2100, 2100, 2597, 2100, 2100, - /* 450 */ 2100, 2100, 2100, 2565, 2560, 2551, 2542, 2557, 2548, 2536, - /* 460 */ 2554, 2545, 2533, 2530, 2100, 2100, 2100, 2100, 2100, 2100, - /* 470 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 480 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 490 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 500 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 510 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2418, - /* 520 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 530 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 540 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 550 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 560 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 570 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 580 */ 2100, 2100, 2433, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 590 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 600 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 610 */ 2100, 2100, 2100, 2100, 2100, 2100, 2144, 2604, 2100, 2100, - /* 620 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 630 */ 2100, 2607, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 640 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 650 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 660 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 670 */ 2100, 2100, 2100, 2244, 2243, 2100, 2100, 2100, 2100, 2100, - /* 680 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 690 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 700 */ 2100, 2608, 2100, 2100, 2100, 2494, 2100, 2100, 2100, 2599, - /* 710 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 720 */ 2100, 2100, 2100, 2100, 2100, 2100, 2806, 2758, 2100, 2100, - /* 730 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 740 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 750 */ 2597, 2100, 2788, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 760 */ 2804, 2100, 2808, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 770 */ 2714, 2710, 2100, 2100, 2706, 2100, 2100, 2100, 2100, 2100, - /* 780 */ 2665, 2100, 2100, 2100, 2699, 2100, 2100, 2100, 2100, 2334, - /* 790 */ 2333, 2332, 2331, 2100, 2100, 2100, 2100, 2100, 2100, 2608, - /* 800 */ 2100, 2611, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 810 */ 2100, 2100, 2100, 2100, 2596, 2100, 2650, 2649, 2100, 2100, - /* 820 */ 2100, 2100, 2100, 2100, 2100, 2328, 2100, 2100, 2100, 2100, - /* 830 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 840 */ 2100, 2312, 2310, 2309, 2308, 2100, 2305, 2100, 2345, 2100, - /* 850 */ 2100, 2100, 2341, 2340, 2100, 2100, 2100, 2100, 2100, 2100, - /* 860 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 870 */ 2100, 2100, 2219, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 880 */ 2100, 2211, 2100, 2210, 2100, 2100, 2100, 2100, 2100, 2100, - /* 890 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 900 */ 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, 2100, - /* 910 */ 2100, 2129, 2100, 2100, 2100, 2100, 2100, 2100, + /* 0 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 10 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 20 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 30 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 40 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 50 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 60 */ 2503, 2142, 2142, 2459, 2142, 2142, 2142, 2142, 2142, 2142, + /* 70 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2466, 2142, + /* 80 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 90 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2242, + /* 100 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 110 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2240, 2753, + /* 120 */ 2142, 2142, 2142, 2782, 2142, 2142, 2142, 2142, 2142, 2142, + /* 130 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 140 */ 2142, 2142, 2142, 2142, 2142, 2765, 2142, 2142, 2213, 2213, + /* 150 */ 2142, 2765, 2765, 2765, 2725, 2725, 2240, 2142, 2142, 2242, + /* 160 */ 2142, 2545, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 170 */ 2377, 2172, 2543, 2142, 2142, 2142, 2142, 2142, 2142, 2529, + /* 180 */ 2142, 2142, 2811, 2757, 2758, 2873, 2142, 2814, 2776, 2142, + /* 190 */ 2771, 2142, 2142, 2142, 2142, 2471, 2142, 2801, 2142, 2142, + /* 200 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2325, 2523, 2142, + /* 210 */ 2142, 2142, 2142, 2142, 2857, 2755, 2795, 2142, 2805, 2142, + /* 220 */ 2570, 2142, 2559, 2242, 2142, 2242, 2516, 2454, 2142, 2464, + /* 230 */ 2142, 2464, 2461, 2142, 2142, 2142, 2464, 2461, 2461, 2461, + /* 240 */ 2314, 2310, 2142, 2142, 2308, 2142, 2142, 2142, 2142, 2197, + /* 250 */ 2142, 2197, 2142, 2242, 2242, 2142, 2242, 2142, 2142, 2242, + /* 260 */ 2142, 2242, 2142, 2242, 2142, 2242, 2242, 2142, 2242, 2142, + /* 270 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 280 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2557, 2539, + /* 290 */ 2142, 2240, 2142, 2527, 2525, 2142, 2240, 2805, 2142, 2142, + /* 300 */ 2827, 2822, 2827, 2822, 2841, 2837, 2827, 2846, 2843, 2807, + /* 310 */ 2805, 2788, 2784, 2876, 2863, 2859, 2142, 2142, 2793, 2791, + /* 320 */ 2142, 2240, 2240, 2822, 2142, 2142, 2142, 2142, 2822, 2142, + /* 330 */ 2142, 2240, 2142, 2142, 2240, 2142, 2142, 2142, 2142, 2240, + /* 340 */ 2142, 2240, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 350 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 360 */ 2142, 2142, 2142, 2142, 2142, 2341, 2142, 2142, 2240, 2142, + /* 370 */ 2181, 2142, 2518, 2548, 2499, 2499, 2380, 2380, 2380, 2243, + /* 380 */ 2147, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 390 */ 2142, 2142, 2142, 2840, 2839, 2676, 2142, 2729, 2728, 2727, + /* 400 */ 2718, 2675, 2337, 2142, 2142, 2142, 2674, 2673, 2142, 2142, + /* 410 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2490, 2489, + /* 420 */ 2667, 2142, 2142, 2668, 2666, 2665, 2142, 2142, 2142, 2142, + /* 430 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 440 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 450 */ 2142, 2142, 2142, 2860, 2864, 2142, 2142, 2142, 2754, 2142, + /* 460 */ 2142, 2142, 2646, 2142, 2142, 2142, 2142, 2614, 2609, 2600, + /* 470 */ 2591, 2606, 2597, 2585, 2603, 2594, 2582, 2579, 2142, 2142, + /* 480 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 490 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 500 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 510 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 520 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 530 */ 2142, 2142, 2142, 2460, 2142, 2142, 2142, 2142, 2142, 2142, + /* 540 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 550 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 560 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 570 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 580 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 590 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2475, 2142, 2142, + /* 600 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 610 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 620 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 630 */ 2142, 2186, 2653, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 640 */ 2142, 2142, 2142, 2142, 2142, 2142, 2656, 2142, 2142, 2657, + /* 650 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 660 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 670 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 680 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 690 */ 2142, 2286, 2285, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 700 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 710 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2658, + /* 720 */ 2142, 2142, 2142, 2543, 2142, 2142, 2142, 2648, 2142, 2142, + /* 730 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 740 */ 2142, 2142, 2142, 2142, 2856, 2808, 2142, 2142, 2142, 2142, + /* 750 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 760 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2646, 2142, + /* 770 */ 2838, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2854, 2142, + /* 780 */ 2858, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2764, 2760, + /* 790 */ 2142, 2142, 2756, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 800 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 810 */ 2142, 2142, 2142, 2715, 2142, 2142, 2142, 2749, 2142, 2142, + /* 820 */ 2142, 2142, 2376, 2375, 2374, 2373, 2142, 2142, 2142, 2142, + /* 830 */ 2142, 2142, 2658, 2142, 2661, 2142, 2142, 2142, 2142, 2142, + /* 840 */ 2142, 2142, 2142, 2142, 2645, 2142, 2700, 2699, 2142, 2142, + /* 850 */ 2142, 2142, 2142, 2142, 2142, 2370, 2142, 2142, 2142, 2142, + /* 860 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 870 */ 2142, 2354, 2352, 2351, 2350, 2142, 2347, 2142, 2387, 2142, + /* 880 */ 2142, 2142, 2383, 2382, 2142, 2142, 2142, 2142, 2142, 2142, + /* 890 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 900 */ 2142, 2142, 2261, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 910 */ 2142, 2253, 2142, 2252, 2142, 2142, 2142, 2142, 2142, 2142, + /* 920 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 930 */ 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, 2142, + /* 940 */ 2142, 2171, 2142, 2142, 2142, 2142, 2142, 2142, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1258,7 +1650,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* BWLIMIT => nothing */ 0, /* START => nothing */ 0, /* TIMESTAMP => nothing */ - 319, /* END => ABORT */ + 322, /* END => ABORT */ 0, /* TABLE => nothing */ 0, /* NK_LP => nothing */ 0, /* NK_RP => nothing */ @@ -1272,7 +1664,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* USING => nothing */ 0, /* TAGS => nothing */ 0, /* PRIMARY => nothing */ - 319, /* KEY => ABORT */ + 322, /* KEY => ABORT */ 0, /* BOOL => nothing */ 0, /* TINYINT => nothing */ 0, /* SMALLINT => nothing */ @@ -1331,7 +1723,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* VNODES => nothing */ 0, /* ALIVE => nothing */ 0, /* VIEWS => nothing */ - 319, /* VIEW => ABORT */ + 322, /* VIEW => ABORT */ 0, /* COMPACTS => nothing */ 0, /* NORMAL => nothing */ 0, /* CHILD => nothing */ @@ -1340,9 +1732,12 @@ static const YYCODETYPE yyFallback[] = { 0, /* QTAGS => nothing */ 0, /* AS => nothing */ 0, /* SYSTEM => nothing */ - 0, /* INDEX => nothing */ - 0, /* FUNCTION => nothing */ + 0, /* TSMA => nothing */ 0, /* INTERVAL => nothing */ + 0, /* RECURSIVE => nothing */ + 0, /* TSMAS => nothing */ + 0, /* FUNCTION => nothing */ + 0, /* INDEX => nothing */ 0, /* COUNT => nothing */ 0, /* LAST_ROW => nothing */ 0, /* META => nothing */ @@ -1433,7 +1828,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* LEFT => nothing */ 0, /* RIGHT => nothing */ 0, /* OUTER => nothing */ - 319, /* SEMI => ABORT */ + 322, /* SEMI => ABORT */ 0, /* ANTI => nothing */ 0, /* ASOF => nothing */ 0, /* WINDOW => nothing */ @@ -1469,53 +1864,53 @@ static const YYCODETYPE yyFallback[] = { 0, /* ASC => nothing */ 0, /* NULLS => nothing */ 0, /* ABORT => nothing */ - 319, /* AFTER => ABORT */ - 319, /* ATTACH => ABORT */ - 319, /* BEFORE => ABORT */ - 319, /* BEGIN => ABORT */ - 319, /* BITAND => ABORT */ - 319, /* BITNOT => ABORT */ - 319, /* BITOR => ABORT */ - 319, /* BLOCKS => ABORT */ - 319, /* CHANGE => ABORT */ - 319, /* COMMA => ABORT */ - 319, /* CONCAT => ABORT */ - 319, /* CONFLICT => ABORT */ - 319, /* COPY => ABORT */ - 319, /* DEFERRED => ABORT */ - 319, /* DELIMITERS => ABORT */ - 319, /* DETACH => ABORT */ - 319, /* DIVIDE => ABORT */ - 319, /* DOT => ABORT */ - 319, /* EACH => ABORT */ - 319, /* FAIL => ABORT */ - 319, /* FILE => ABORT */ - 319, /* FOR => ABORT */ - 319, /* GLOB => ABORT */ - 319, /* ID => ABORT */ - 319, /* IMMEDIATE => ABORT */ - 319, /* IMPORT => ABORT */ - 319, /* INITIALLY => ABORT */ - 319, /* INSTEAD => ABORT */ - 319, /* ISNULL => ABORT */ - 319, /* MODULES => ABORT */ - 319, /* NK_BITNOT => ABORT */ - 319, /* NK_SEMI => ABORT */ - 319, /* NOTNULL => ABORT */ - 319, /* OF => ABORT */ - 319, /* PLUS => ABORT */ - 319, /* PRIVILEGE => ABORT */ - 319, /* RAISE => ABORT */ - 319, /* RESTRICT => ABORT */ - 319, /* ROW => ABORT */ - 319, /* STAR => ABORT */ - 319, /* STATEMENT => ABORT */ - 319, /* STRICT => ABORT */ - 319, /* STRING => ABORT */ - 319, /* TIMES => ABORT */ - 319, /* VALUES => ABORT */ - 319, /* VARIABLE => ABORT */ - 319, /* WAL => ABORT */ + 322, /* AFTER => ABORT */ + 322, /* ATTACH => ABORT */ + 322, /* BEFORE => ABORT */ + 322, /* BEGIN => ABORT */ + 322, /* BITAND => ABORT */ + 322, /* BITNOT => ABORT */ + 322, /* BITOR => ABORT */ + 322, /* BLOCKS => ABORT */ + 322, /* CHANGE => ABORT */ + 322, /* COMMA => ABORT */ + 322, /* CONCAT => ABORT */ + 322, /* CONFLICT => ABORT */ + 322, /* COPY => ABORT */ + 322, /* DEFERRED => ABORT */ + 322, /* DELIMITERS => ABORT */ + 322, /* DETACH => ABORT */ + 322, /* DIVIDE => ABORT */ + 322, /* DOT => ABORT */ + 322, /* EACH => ABORT */ + 322, /* FAIL => ABORT */ + 322, /* FILE => ABORT */ + 322, /* FOR => ABORT */ + 322, /* GLOB => ABORT */ + 322, /* ID => ABORT */ + 322, /* IMMEDIATE => ABORT */ + 322, /* IMPORT => ABORT */ + 322, /* INITIALLY => ABORT */ + 322, /* INSTEAD => ABORT */ + 322, /* ISNULL => ABORT */ + 322, /* MODULES => ABORT */ + 322, /* NK_BITNOT => ABORT */ + 322, /* NK_SEMI => ABORT */ + 322, /* NOTNULL => ABORT */ + 322, /* OF => ABORT */ + 322, /* PLUS => ABORT */ + 322, /* PRIVILEGE => ABORT */ + 322, /* RAISE => ABORT */ + 322, /* RESTRICT => ABORT */ + 322, /* ROW => ABORT */ + 322, /* STAR => ABORT */ + 322, /* STATEMENT => ABORT */ + 322, /* STRICT => ABORT */ + 322, /* STRING => ABORT */ + 322, /* TIMES => ABORT */ + 322, /* VALUES => ABORT */ + 322, /* VARIABLE => ABORT */ + 322, /* WAL => ABORT */ }; #endif /* YYFALLBACK */ @@ -1569,6 +1964,7 @@ typedef struct yyParser yyParser; #ifndef NDEBUG #include +#include static FILE *yyTraceFILE = 0; static char *yyTracePrompt = 0; #endif /* NDEBUG */ @@ -1794,353 +2190,359 @@ static const char *const yyTokenName[] = { /* 188 */ "QTAGS", /* 189 */ "AS", /* 190 */ "SYSTEM", - /* 191 */ "INDEX", - /* 192 */ "FUNCTION", - /* 193 */ "INTERVAL", - /* 194 */ "COUNT", - /* 195 */ "LAST_ROW", - /* 196 */ "META", - /* 197 */ "ONLY", - /* 198 */ "TOPIC", - /* 199 */ "CONSUMER", - /* 200 */ "GROUP", - /* 201 */ "DESC", - /* 202 */ "DESCRIBE", - /* 203 */ "RESET", - /* 204 */ "QUERY", - /* 205 */ "CACHE", - /* 206 */ "EXPLAIN", - /* 207 */ "ANALYZE", - /* 208 */ "VERBOSE", - /* 209 */ "NK_BOOL", - /* 210 */ "RATIO", - /* 211 */ "NK_FLOAT", - /* 212 */ "OUTPUTTYPE", - /* 213 */ "AGGREGATE", - /* 214 */ "BUFSIZE", - /* 215 */ "LANGUAGE", - /* 216 */ "REPLACE", - /* 217 */ "STREAM", - /* 218 */ "INTO", - /* 219 */ "PAUSE", - /* 220 */ "RESUME", - /* 221 */ "TRIGGER", - /* 222 */ "AT_ONCE", - /* 223 */ "WINDOW_CLOSE", - /* 224 */ "IGNORE", - /* 225 */ "EXPIRED", - /* 226 */ "FILL_HISTORY", - /* 227 */ "UPDATE", - /* 228 */ "SUBTABLE", - /* 229 */ "UNTREATED", - /* 230 */ "KILL", - /* 231 */ "CONNECTION", - /* 232 */ "TRANSACTION", - /* 233 */ "BALANCE", - /* 234 */ "VGROUP", - /* 235 */ "LEADER", - /* 236 */ "MERGE", - /* 237 */ "REDISTRIBUTE", - /* 238 */ "SPLIT", - /* 239 */ "DELETE", - /* 240 */ "INSERT", - /* 241 */ "NK_BIN", - /* 242 */ "NK_HEX", - /* 243 */ "NULL", - /* 244 */ "NK_QUESTION", - /* 245 */ "NK_ALIAS", - /* 246 */ "NK_ARROW", - /* 247 */ "ROWTS", - /* 248 */ "QSTART", - /* 249 */ "QEND", - /* 250 */ "QDURATION", - /* 251 */ "WSTART", - /* 252 */ "WEND", - /* 253 */ "WDURATION", - /* 254 */ "IROWTS", - /* 255 */ "ISFILLED", - /* 256 */ "CAST", - /* 257 */ "NOW", - /* 258 */ "TODAY", - /* 259 */ "TIMEZONE", - /* 260 */ "CLIENT_VERSION", - /* 261 */ "SERVER_VERSION", - /* 262 */ "SERVER_STATUS", - /* 263 */ "CURRENT_USER", - /* 264 */ "CASE", - /* 265 */ "WHEN", - /* 266 */ "THEN", - /* 267 */ "ELSE", - /* 268 */ "BETWEEN", - /* 269 */ "IS", - /* 270 */ "NK_LT", - /* 271 */ "NK_GT", - /* 272 */ "NK_LE", - /* 273 */ "NK_GE", - /* 274 */ "NK_NE", - /* 275 */ "MATCH", - /* 276 */ "NMATCH", - /* 277 */ "CONTAINS", - /* 278 */ "IN", - /* 279 */ "JOIN", - /* 280 */ "INNER", - /* 281 */ "LEFT", - /* 282 */ "RIGHT", - /* 283 */ "OUTER", - /* 284 */ "SEMI", - /* 285 */ "ANTI", - /* 286 */ "ASOF", - /* 287 */ "WINDOW", - /* 288 */ "WINDOW_OFFSET", - /* 289 */ "JLIMIT", - /* 290 */ "SELECT", - /* 291 */ "NK_HINT", - /* 292 */ "DISTINCT", - /* 293 */ "WHERE", - /* 294 */ "PARTITION", - /* 295 */ "BY", - /* 296 */ "SESSION", - /* 297 */ "STATE_WINDOW", - /* 298 */ "EVENT_WINDOW", - /* 299 */ "COUNT_WINDOW", - /* 300 */ "SLIDING", - /* 301 */ "FILL", - /* 302 */ "VALUE", - /* 303 */ "VALUE_F", - /* 304 */ "NONE", - /* 305 */ "PREV", - /* 306 */ "NULL_F", - /* 307 */ "LINEAR", - /* 308 */ "NEXT", - /* 309 */ "HAVING", - /* 310 */ "RANGE", - /* 311 */ "EVERY", - /* 312 */ "ORDER", - /* 313 */ "SLIMIT", - /* 314 */ "SOFFSET", - /* 315 */ "LIMIT", - /* 316 */ "OFFSET", - /* 317 */ "ASC", - /* 318 */ "NULLS", - /* 319 */ "ABORT", - /* 320 */ "AFTER", - /* 321 */ "ATTACH", - /* 322 */ "BEFORE", - /* 323 */ "BEGIN", - /* 324 */ "BITAND", - /* 325 */ "BITNOT", - /* 326 */ "BITOR", - /* 327 */ "BLOCKS", - /* 328 */ "CHANGE", - /* 329 */ "COMMA", - /* 330 */ "CONCAT", - /* 331 */ "CONFLICT", - /* 332 */ "COPY", - /* 333 */ "DEFERRED", - /* 334 */ "DELIMITERS", - /* 335 */ "DETACH", - /* 336 */ "DIVIDE", - /* 337 */ "DOT", - /* 338 */ "EACH", - /* 339 */ "FAIL", - /* 340 */ "FILE", - /* 341 */ "FOR", - /* 342 */ "GLOB", - /* 343 */ "ID", - /* 344 */ "IMMEDIATE", - /* 345 */ "IMPORT", - /* 346 */ "INITIALLY", - /* 347 */ "INSTEAD", - /* 348 */ "ISNULL", - /* 349 */ "MODULES", - /* 350 */ "NK_BITNOT", - /* 351 */ "NK_SEMI", - /* 352 */ "NOTNULL", - /* 353 */ "OF", - /* 354 */ "PLUS", - /* 355 */ "PRIVILEGE", - /* 356 */ "RAISE", - /* 357 */ "RESTRICT", - /* 358 */ "ROW", - /* 359 */ "STAR", - /* 360 */ "STATEMENT", - /* 361 */ "STRICT", - /* 362 */ "STRING", - /* 363 */ "TIMES", - /* 364 */ "VALUES", - /* 365 */ "VARIABLE", - /* 366 */ "WAL", - /* 367 */ "cmd", - /* 368 */ "account_options", - /* 369 */ "alter_account_options", - /* 370 */ "literal", - /* 371 */ "alter_account_option", - /* 372 */ "ip_range_list", - /* 373 */ "white_list", - /* 374 */ "white_list_opt", - /* 375 */ "user_name", - /* 376 */ "sysinfo_opt", - /* 377 */ "privileges", - /* 378 */ "priv_level", - /* 379 */ "with_opt", - /* 380 */ "priv_type_list", - /* 381 */ "priv_type", - /* 382 */ "db_name", - /* 383 */ "table_name", - /* 384 */ "topic_name", - /* 385 */ "search_condition", - /* 386 */ "dnode_endpoint", - /* 387 */ "force_opt", - /* 388 */ "unsafe_opt", - /* 389 */ "not_exists_opt", - /* 390 */ "db_options", - /* 391 */ "exists_opt", - /* 392 */ "alter_db_options", - /* 393 */ "speed_opt", - /* 394 */ "start_opt", - /* 395 */ "end_opt", - /* 396 */ "integer_list", - /* 397 */ "variable_list", - /* 398 */ "retention_list", - /* 399 */ "signed", - /* 400 */ "alter_db_option", - /* 401 */ "retention", - /* 402 */ "full_table_name", - /* 403 */ "column_def_list", - /* 404 */ "tags_def_opt", - /* 405 */ "table_options", - /* 406 */ "multi_create_clause", - /* 407 */ "tags_def", - /* 408 */ "multi_drop_clause", - /* 409 */ "alter_table_clause", - /* 410 */ "alter_table_options", - /* 411 */ "column_name", - /* 412 */ "type_name", - /* 413 */ "tags_literal", - /* 414 */ "create_subtable_clause", - /* 415 */ "specific_cols_opt", - /* 416 */ "tags_literal_list", - /* 417 */ "drop_table_clause", - /* 418 */ "col_name_list", - /* 419 */ "column_def", - /* 420 */ "type_name_default_len", - /* 421 */ "duration_list", - /* 422 */ "rollup_func_list", - /* 423 */ "alter_table_option", - /* 424 */ "duration_literal", - /* 425 */ "rollup_func_name", - /* 426 */ "function_name", - /* 427 */ "col_name", - /* 428 */ "db_kind_opt", - /* 429 */ "table_kind_db_name_cond_opt", - /* 430 */ "like_pattern_opt", - /* 431 */ "db_name_cond_opt", - /* 432 */ "table_name_cond", - /* 433 */ "from_db_opt", - /* 434 */ "tag_list_opt", - /* 435 */ "table_kind", - /* 436 */ "tag_item", - /* 437 */ "column_alias", - /* 438 */ "index_options", - /* 439 */ "full_index_name", - /* 440 */ "index_name", - /* 441 */ "func_list", - /* 442 */ "sliding_opt", - /* 443 */ "sma_stream_opt", - /* 444 */ "func", - /* 445 */ "sma_func_name", - /* 446 */ "expression_list", - /* 447 */ "with_meta", - /* 448 */ "query_or_subquery", - /* 449 */ "where_clause_opt", - /* 450 */ "cgroup_name", - /* 451 */ "analyze_opt", - /* 452 */ "explain_options", - /* 453 */ "insert_query", - /* 454 */ "or_replace_opt", - /* 455 */ "agg_func_opt", - /* 456 */ "bufsize_opt", - /* 457 */ "language_opt", - /* 458 */ "full_view_name", - /* 459 */ "view_name", - /* 460 */ "stream_name", - /* 461 */ "stream_options", - /* 462 */ "col_list_opt", - /* 463 */ "tag_def_or_ref_opt", - /* 464 */ "subtable_opt", - /* 465 */ "ignore_opt", - /* 466 */ "column_stream_def_list", - /* 467 */ "column_stream_def", - /* 468 */ "expression", - /* 469 */ "on_vgroup_id", - /* 470 */ "dnode_list", - /* 471 */ "literal_func", - /* 472 */ "signed_literal", - /* 473 */ "literal_list", - /* 474 */ "table_alias", - /* 475 */ "expr_or_subquery", - /* 476 */ "pseudo_column", - /* 477 */ "column_reference", - /* 478 */ "function_expression", - /* 479 */ "case_when_expression", - /* 480 */ "star_func", - /* 481 */ "star_func_para_list", - /* 482 */ "noarg_func", - /* 483 */ "other_para_list", - /* 484 */ "star_func_para", - /* 485 */ "when_then_list", - /* 486 */ "case_when_else_opt", - /* 487 */ "common_expression", - /* 488 */ "when_then_expr", - /* 489 */ "predicate", - /* 490 */ "compare_op", - /* 491 */ "in_op", - /* 492 */ "in_predicate_value", - /* 493 */ "boolean_value_expression", - /* 494 */ "boolean_primary", - /* 495 */ "from_clause_opt", - /* 496 */ "table_reference_list", - /* 497 */ "table_reference", - /* 498 */ "table_primary", - /* 499 */ "joined_table", - /* 500 */ "alias_opt", - /* 501 */ "subquery", - /* 502 */ "parenthesized_joined_table", - /* 503 */ "join_type", - /* 504 */ "join_subtype", - /* 505 */ "join_on_clause_opt", - /* 506 */ "window_offset_clause_opt", - /* 507 */ "jlimit_clause_opt", - /* 508 */ "window_offset_literal", - /* 509 */ "query_specification", - /* 510 */ "hint_list", - /* 511 */ "set_quantifier_opt", - /* 512 */ "tag_mode_opt", - /* 513 */ "select_list", - /* 514 */ "partition_by_clause_opt", - /* 515 */ "range_opt", - /* 516 */ "every_opt", - /* 517 */ "fill_opt", - /* 518 */ "twindow_clause_opt", - /* 519 */ "group_by_clause_opt", - /* 520 */ "having_clause_opt", - /* 521 */ "select_item", - /* 522 */ "partition_list", - /* 523 */ "partition_item", - /* 524 */ "interval_sliding_duration_literal", - /* 525 */ "fill_mode", - /* 526 */ "group_by_list", - /* 527 */ "query_expression", - /* 528 */ "query_simple", - /* 529 */ "order_by_clause_opt", - /* 530 */ "slimit_clause_opt", - /* 531 */ "limit_clause_opt", - /* 532 */ "union_query_expression", - /* 533 */ "query_simple_or_subquery", - /* 534 */ "sort_specification_list", - /* 535 */ "sort_specification", - /* 536 */ "ordering_specification_opt", - /* 537 */ "null_ordering_opt", + /* 191 */ "TSMA", + /* 192 */ "INTERVAL", + /* 193 */ "RECURSIVE", + /* 194 */ "TSMAS", + /* 195 */ "FUNCTION", + /* 196 */ "INDEX", + /* 197 */ "COUNT", + /* 198 */ "LAST_ROW", + /* 199 */ "META", + /* 200 */ "ONLY", + /* 201 */ "TOPIC", + /* 202 */ "CONSUMER", + /* 203 */ "GROUP", + /* 204 */ "DESC", + /* 205 */ "DESCRIBE", + /* 206 */ "RESET", + /* 207 */ "QUERY", + /* 208 */ "CACHE", + /* 209 */ "EXPLAIN", + /* 210 */ "ANALYZE", + /* 211 */ "VERBOSE", + /* 212 */ "NK_BOOL", + /* 213 */ "RATIO", + /* 214 */ "NK_FLOAT", + /* 215 */ "OUTPUTTYPE", + /* 216 */ "AGGREGATE", + /* 217 */ "BUFSIZE", + /* 218 */ "LANGUAGE", + /* 219 */ "REPLACE", + /* 220 */ "STREAM", + /* 221 */ "INTO", + /* 222 */ "PAUSE", + /* 223 */ "RESUME", + /* 224 */ "TRIGGER", + /* 225 */ "AT_ONCE", + /* 226 */ "WINDOW_CLOSE", + /* 227 */ "IGNORE", + /* 228 */ "EXPIRED", + /* 229 */ "FILL_HISTORY", + /* 230 */ "UPDATE", + /* 231 */ "SUBTABLE", + /* 232 */ "UNTREATED", + /* 233 */ "KILL", + /* 234 */ "CONNECTION", + /* 235 */ "TRANSACTION", + /* 236 */ "BALANCE", + /* 237 */ "VGROUP", + /* 238 */ "LEADER", + /* 239 */ "MERGE", + /* 240 */ "REDISTRIBUTE", + /* 241 */ "SPLIT", + /* 242 */ "DELETE", + /* 243 */ "INSERT", + /* 244 */ "NK_BIN", + /* 245 */ "NK_HEX", + /* 246 */ "NULL", + /* 247 */ "NK_QUESTION", + /* 248 */ "NK_ALIAS", + /* 249 */ "NK_ARROW", + /* 250 */ "ROWTS", + /* 251 */ "QSTART", + /* 252 */ "QEND", + /* 253 */ "QDURATION", + /* 254 */ "WSTART", + /* 255 */ "WEND", + /* 256 */ "WDURATION", + /* 257 */ "IROWTS", + /* 258 */ "ISFILLED", + /* 259 */ "CAST", + /* 260 */ "NOW", + /* 261 */ "TODAY", + /* 262 */ "TIMEZONE", + /* 263 */ "CLIENT_VERSION", + /* 264 */ "SERVER_VERSION", + /* 265 */ "SERVER_STATUS", + /* 266 */ "CURRENT_USER", + /* 267 */ "CASE", + /* 268 */ "WHEN", + /* 269 */ "THEN", + /* 270 */ "ELSE", + /* 271 */ "BETWEEN", + /* 272 */ "IS", + /* 273 */ "NK_LT", + /* 274 */ "NK_GT", + /* 275 */ "NK_LE", + /* 276 */ "NK_GE", + /* 277 */ "NK_NE", + /* 278 */ "MATCH", + /* 279 */ "NMATCH", + /* 280 */ "CONTAINS", + /* 281 */ "IN", + /* 282 */ "JOIN", + /* 283 */ "INNER", + /* 284 */ "LEFT", + /* 285 */ "RIGHT", + /* 286 */ "OUTER", + /* 287 */ "SEMI", + /* 288 */ "ANTI", + /* 289 */ "ASOF", + /* 290 */ "WINDOW", + /* 291 */ "WINDOW_OFFSET", + /* 292 */ "JLIMIT", + /* 293 */ "SELECT", + /* 294 */ "NK_HINT", + /* 295 */ "DISTINCT", + /* 296 */ "WHERE", + /* 297 */ "PARTITION", + /* 298 */ "BY", + /* 299 */ "SESSION", + /* 300 */ "STATE_WINDOW", + /* 301 */ "EVENT_WINDOW", + /* 302 */ "COUNT_WINDOW", + /* 303 */ "SLIDING", + /* 304 */ "FILL", + /* 305 */ "VALUE", + /* 306 */ "VALUE_F", + /* 307 */ "NONE", + /* 308 */ "PREV", + /* 309 */ "NULL_F", + /* 310 */ "LINEAR", + /* 311 */ "NEXT", + /* 312 */ "HAVING", + /* 313 */ "RANGE", + /* 314 */ "EVERY", + /* 315 */ "ORDER", + /* 316 */ "SLIMIT", + /* 317 */ "SOFFSET", + /* 318 */ "LIMIT", + /* 319 */ "OFFSET", + /* 320 */ "ASC", + /* 321 */ "NULLS", + /* 322 */ "ABORT", + /* 323 */ "AFTER", + /* 324 */ "ATTACH", + /* 325 */ "BEFORE", + /* 326 */ "BEGIN", + /* 327 */ "BITAND", + /* 328 */ "BITNOT", + /* 329 */ "BITOR", + /* 330 */ "BLOCKS", + /* 331 */ "CHANGE", + /* 332 */ "COMMA", + /* 333 */ "CONCAT", + /* 334 */ "CONFLICT", + /* 335 */ "COPY", + /* 336 */ "DEFERRED", + /* 337 */ "DELIMITERS", + /* 338 */ "DETACH", + /* 339 */ "DIVIDE", + /* 340 */ "DOT", + /* 341 */ "EACH", + /* 342 */ "FAIL", + /* 343 */ "FILE", + /* 344 */ "FOR", + /* 345 */ "GLOB", + /* 346 */ "ID", + /* 347 */ "IMMEDIATE", + /* 348 */ "IMPORT", + /* 349 */ "INITIALLY", + /* 350 */ "INSTEAD", + /* 351 */ "ISNULL", + /* 352 */ "MODULES", + /* 353 */ "NK_BITNOT", + /* 354 */ "NK_SEMI", + /* 355 */ "NOTNULL", + /* 356 */ "OF", + /* 357 */ "PLUS", + /* 358 */ "PRIVILEGE", + /* 359 */ "RAISE", + /* 360 */ "RESTRICT", + /* 361 */ "ROW", + /* 362 */ "STAR", + /* 363 */ "STATEMENT", + /* 364 */ "STRICT", + /* 365 */ "STRING", + /* 366 */ "TIMES", + /* 367 */ "VALUES", + /* 368 */ "VARIABLE", + /* 369 */ "WAL", + /* 370 */ "cmd", + /* 371 */ "account_options", + /* 372 */ "alter_account_options", + /* 373 */ "literal", + /* 374 */ "alter_account_option", + /* 375 */ "ip_range_list", + /* 376 */ "white_list", + /* 377 */ "white_list_opt", + /* 378 */ "user_name", + /* 379 */ "sysinfo_opt", + /* 380 */ "privileges", + /* 381 */ "priv_level", + /* 382 */ "with_opt", + /* 383 */ "priv_type_list", + /* 384 */ "priv_type", + /* 385 */ "db_name", + /* 386 */ "table_name", + /* 387 */ "topic_name", + /* 388 */ "search_condition", + /* 389 */ "dnode_endpoint", + /* 390 */ "force_opt", + /* 391 */ "unsafe_opt", + /* 392 */ "not_exists_opt", + /* 393 */ "db_options", + /* 394 */ "exists_opt", + /* 395 */ "alter_db_options", + /* 396 */ "speed_opt", + /* 397 */ "start_opt", + /* 398 */ "end_opt", + /* 399 */ "integer_list", + /* 400 */ "variable_list", + /* 401 */ "retention_list", + /* 402 */ "signed", + /* 403 */ "alter_db_option", + /* 404 */ "retention", + /* 405 */ "full_table_name", + /* 406 */ "column_def_list", + /* 407 */ "tags_def_opt", + /* 408 */ "table_options", + /* 409 */ "multi_create_clause", + /* 410 */ "tags_def", + /* 411 */ "multi_drop_clause", + /* 412 */ "alter_table_clause", + /* 413 */ "alter_table_options", + /* 414 */ "column_name", + /* 415 */ "type_name", + /* 416 */ "tags_literal", + /* 417 */ "create_subtable_clause", + /* 418 */ "specific_cols_opt", + /* 419 */ "tags_literal_list", + /* 420 */ "drop_table_clause", + /* 421 */ "col_name_list", + /* 422 */ "column_def", + /* 423 */ "type_name_default_len", + /* 424 */ "duration_list", + /* 425 */ "rollup_func_list", + /* 426 */ "alter_table_option", + /* 427 */ "duration_literal", + /* 428 */ "rollup_func_name", + /* 429 */ "function_name", + /* 430 */ "col_name", + /* 431 */ "db_kind_opt", + /* 432 */ "table_kind_db_name_cond_opt", + /* 433 */ "like_pattern_opt", + /* 434 */ "db_name_cond_opt", + /* 435 */ "table_name_cond", + /* 436 */ "from_db_opt", + /* 437 */ "tag_list_opt", + /* 438 */ "table_kind", + /* 439 */ "tag_item", + /* 440 */ "column_alias", + /* 441 */ "tsma_name", + /* 442 */ "tsma_func_list", + /* 443 */ "full_tsma_name", + /* 444 */ "func_list", + /* 445 */ "index_options", + /* 446 */ "full_index_name", + /* 447 */ "index_name", + /* 448 */ "sliding_opt", + /* 449 */ "sma_stream_opt", + /* 450 */ "func", + /* 451 */ "sma_func_name", + /* 452 */ "expression_list", + /* 453 */ "with_meta", + /* 454 */ "query_or_subquery", + /* 455 */ "where_clause_opt", + /* 456 */ "cgroup_name", + /* 457 */ "analyze_opt", + /* 458 */ "explain_options", + /* 459 */ "insert_query", + /* 460 */ "or_replace_opt", + /* 461 */ "agg_func_opt", + /* 462 */ "bufsize_opt", + /* 463 */ "language_opt", + /* 464 */ "full_view_name", + /* 465 */ "view_name", + /* 466 */ "stream_name", + /* 467 */ "stream_options", + /* 468 */ "col_list_opt", + /* 469 */ "tag_def_or_ref_opt", + /* 470 */ "subtable_opt", + /* 471 */ "ignore_opt", + /* 472 */ "column_stream_def_list", + /* 473 */ "column_stream_def", + /* 474 */ "expression", + /* 475 */ "on_vgroup_id", + /* 476 */ "dnode_list", + /* 477 */ "literal_func", + /* 478 */ "signed_literal", + /* 479 */ "literal_list", + /* 480 */ "table_alias", + /* 481 */ "expr_or_subquery", + /* 482 */ "pseudo_column", + /* 483 */ "column_reference", + /* 484 */ "function_expression", + /* 485 */ "case_when_expression", + /* 486 */ "star_func", + /* 487 */ "star_func_para_list", + /* 488 */ "noarg_func", + /* 489 */ "other_para_list", + /* 490 */ "star_func_para", + /* 491 */ "when_then_list", + /* 492 */ "case_when_else_opt", + /* 493 */ "common_expression", + /* 494 */ "when_then_expr", + /* 495 */ "predicate", + /* 496 */ "compare_op", + /* 497 */ "in_op", + /* 498 */ "in_predicate_value", + /* 499 */ "boolean_value_expression", + /* 500 */ "boolean_primary", + /* 501 */ "from_clause_opt", + /* 502 */ "table_reference_list", + /* 503 */ "table_reference", + /* 504 */ "table_primary", + /* 505 */ "joined_table", + /* 506 */ "alias_opt", + /* 507 */ "subquery", + /* 508 */ "parenthesized_joined_table", + /* 509 */ "join_type", + /* 510 */ "join_subtype", + /* 511 */ "join_on_clause_opt", + /* 512 */ "window_offset_clause_opt", + /* 513 */ "jlimit_clause_opt", + /* 514 */ "window_offset_literal", + /* 515 */ "query_specification", + /* 516 */ "hint_list", + /* 517 */ "set_quantifier_opt", + /* 518 */ "tag_mode_opt", + /* 519 */ "select_list", + /* 520 */ "partition_by_clause_opt", + /* 521 */ "range_opt", + /* 522 */ "every_opt", + /* 523 */ "fill_opt", + /* 524 */ "twindow_clause_opt", + /* 525 */ "group_by_clause_opt", + /* 526 */ "having_clause_opt", + /* 527 */ "select_item", + /* 528 */ "partition_list", + /* 529 */ "partition_item", + /* 530 */ "interval_sliding_duration_literal", + /* 531 */ "fill_mode", + /* 532 */ "group_by_list", + /* 533 */ "query_expression", + /* 534 */ "query_simple", + /* 535 */ "order_by_clause_opt", + /* 536 */ "slimit_clause_opt", + /* 537 */ "limit_clause_opt", + /* 538 */ "union_query_expression", + /* 539 */ "query_simple_or_subquery", + /* 540 */ "sort_specification_list", + /* 541 */ "sort_specification", + /* 542 */ "ordering_specification_opt", + /* 543 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -2480,400 +2882,408 @@ static const char *const yyRuleName[] = { /* 329 */ "db_kind_opt ::=", /* 330 */ "db_kind_opt ::= USER", /* 331 */ "db_kind_opt ::= SYSTEM", - /* 332 */ "cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options", - /* 333 */ "cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP", - /* 334 */ "cmd ::= DROP INDEX exists_opt full_index_name", - /* 335 */ "full_index_name ::= index_name", - /* 336 */ "full_index_name ::= db_name NK_DOT index_name", - /* 337 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", - /* 338 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt", - /* 339 */ "func_list ::= func", - /* 340 */ "func_list ::= func_list NK_COMMA func", - /* 341 */ "func ::= sma_func_name NK_LP expression_list NK_RP", - /* 342 */ "sma_func_name ::= function_name", - /* 343 */ "sma_func_name ::= COUNT", - /* 344 */ "sma_func_name ::= FIRST", - /* 345 */ "sma_func_name ::= LAST", - /* 346 */ "sma_func_name ::= LAST_ROW", - /* 347 */ "sma_stream_opt ::=", - /* 348 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", - /* 349 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", - /* 350 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", - /* 351 */ "with_meta ::= AS", - /* 352 */ "with_meta ::= WITH META AS", - /* 353 */ "with_meta ::= ONLY META AS", - /* 354 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", - /* 355 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name", - /* 356 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt", - /* 357 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 358 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", - /* 359 */ "cmd ::= DESC full_table_name", - /* 360 */ "cmd ::= DESCRIBE full_table_name", - /* 361 */ "cmd ::= RESET QUERY CACHE", - /* 362 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", - /* 363 */ "cmd ::= EXPLAIN analyze_opt explain_options insert_query", - /* 364 */ "analyze_opt ::=", - /* 365 */ "analyze_opt ::= ANALYZE", - /* 366 */ "explain_options ::=", - /* 367 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 368 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 369 */ "cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt", - /* 370 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 371 */ "agg_func_opt ::=", - /* 372 */ "agg_func_opt ::= AGGREGATE", - /* 373 */ "bufsize_opt ::=", - /* 374 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 375 */ "language_opt ::=", - /* 376 */ "language_opt ::= LANGUAGE NK_STRING", - /* 377 */ "or_replace_opt ::=", - /* 378 */ "or_replace_opt ::= OR REPLACE", - /* 379 */ "cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery", - /* 380 */ "cmd ::= DROP VIEW exists_opt full_view_name", - /* 381 */ "full_view_name ::= view_name", - /* 382 */ "full_view_name ::= db_name NK_DOT view_name", - /* 383 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery", - /* 384 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 385 */ "cmd ::= PAUSE STREAM exists_opt stream_name", - /* 386 */ "cmd ::= RESUME STREAM exists_opt ignore_opt stream_name", - /* 387 */ "col_list_opt ::=", - /* 388 */ "col_list_opt ::= NK_LP column_stream_def_list NK_RP", - /* 389 */ "column_stream_def_list ::= column_stream_def", - /* 390 */ "column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def", - /* 391 */ "column_stream_def ::= column_name", - /* 392 */ "column_stream_def ::= column_name PRIMARY KEY", - /* 393 */ "tag_def_or_ref_opt ::=", - /* 394 */ "tag_def_or_ref_opt ::= tags_def", - /* 395 */ "tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP", - /* 396 */ "stream_options ::=", - /* 397 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 398 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 399 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", - /* 400 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 401 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", - /* 402 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", - /* 403 */ "stream_options ::= stream_options DELETE_MARK duration_literal", - /* 404 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER", - /* 405 */ "subtable_opt ::=", - /* 406 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", - /* 407 */ "ignore_opt ::=", - /* 408 */ "ignore_opt ::= IGNORE UNTREATED", - /* 409 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 410 */ "cmd ::= KILL QUERY NK_STRING", - /* 411 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 412 */ "cmd ::= KILL COMPACT NK_INTEGER", - /* 413 */ "cmd ::= BALANCE VGROUP", - /* 414 */ "cmd ::= BALANCE VGROUP LEADER on_vgroup_id", - /* 415 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 416 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 417 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 418 */ "on_vgroup_id ::=", - /* 419 */ "on_vgroup_id ::= ON NK_INTEGER", - /* 420 */ "dnode_list ::= DNODE NK_INTEGER", - /* 421 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 422 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 423 */ "cmd ::= query_or_subquery", - /* 424 */ "cmd ::= insert_query", - /* 425 */ "insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", - /* 426 */ "insert_query ::= INSERT INTO full_table_name query_or_subquery", - /* 427 */ "tags_literal ::= NK_INTEGER", - /* 428 */ "tags_literal ::= NK_INTEGER NK_PLUS duration_literal", - /* 429 */ "tags_literal ::= NK_INTEGER NK_MINUS duration_literal", - /* 430 */ "tags_literal ::= NK_PLUS NK_INTEGER", - /* 431 */ "tags_literal ::= NK_PLUS NK_INTEGER NK_PLUS duration_literal", - /* 432 */ "tags_literal ::= NK_PLUS NK_INTEGER NK_MINUS duration_literal", - /* 433 */ "tags_literal ::= NK_MINUS NK_INTEGER", - /* 434 */ "tags_literal ::= NK_MINUS NK_INTEGER NK_PLUS duration_literal", - /* 435 */ "tags_literal ::= NK_MINUS NK_INTEGER NK_MINUS duration_literal", - /* 436 */ "tags_literal ::= NK_FLOAT", - /* 437 */ "tags_literal ::= NK_PLUS NK_FLOAT", - /* 438 */ "tags_literal ::= NK_MINUS NK_FLOAT", - /* 439 */ "tags_literal ::= NK_BIN", - /* 440 */ "tags_literal ::= NK_BIN NK_PLUS duration_literal", - /* 441 */ "tags_literal ::= NK_BIN NK_MINUS duration_literal", - /* 442 */ "tags_literal ::= NK_PLUS NK_BIN", - /* 443 */ "tags_literal ::= NK_PLUS NK_BIN NK_PLUS duration_literal", - /* 444 */ "tags_literal ::= NK_PLUS NK_BIN NK_MINUS duration_literal", - /* 445 */ "tags_literal ::= NK_MINUS NK_BIN", - /* 446 */ "tags_literal ::= NK_MINUS NK_BIN NK_PLUS duration_literal", - /* 447 */ "tags_literal ::= NK_MINUS NK_BIN NK_MINUS duration_literal", - /* 448 */ "tags_literal ::= NK_HEX", - /* 449 */ "tags_literal ::= NK_HEX NK_PLUS duration_literal", - /* 450 */ "tags_literal ::= NK_HEX NK_MINUS duration_literal", - /* 451 */ "tags_literal ::= NK_PLUS NK_HEX", - /* 452 */ "tags_literal ::= NK_PLUS NK_HEX NK_PLUS duration_literal", - /* 453 */ "tags_literal ::= NK_PLUS NK_HEX NK_MINUS duration_literal", - /* 454 */ "tags_literal ::= NK_MINUS NK_HEX", - /* 455 */ "tags_literal ::= NK_MINUS NK_HEX NK_PLUS duration_literal", - /* 456 */ "tags_literal ::= NK_MINUS NK_HEX NK_MINUS duration_literal", - /* 457 */ "tags_literal ::= NK_STRING", - /* 458 */ "tags_literal ::= NK_STRING NK_PLUS duration_literal", - /* 459 */ "tags_literal ::= NK_STRING NK_MINUS duration_literal", - /* 460 */ "tags_literal ::= NK_BOOL", - /* 461 */ "tags_literal ::= NULL", - /* 462 */ "tags_literal ::= literal_func", - /* 463 */ "tags_literal ::= literal_func NK_PLUS duration_literal", - /* 464 */ "tags_literal ::= literal_func NK_MINUS duration_literal", - /* 465 */ "tags_literal_list ::= tags_literal", - /* 466 */ "tags_literal_list ::= tags_literal_list NK_COMMA tags_literal", - /* 467 */ "literal ::= NK_INTEGER", - /* 468 */ "literal ::= NK_FLOAT", - /* 469 */ "literal ::= NK_STRING", - /* 470 */ "literal ::= NK_BOOL", - /* 471 */ "literal ::= TIMESTAMP NK_STRING", - /* 472 */ "literal ::= duration_literal", - /* 473 */ "literal ::= NULL", - /* 474 */ "literal ::= NK_QUESTION", - /* 475 */ "duration_literal ::= NK_VARIABLE", - /* 476 */ "signed ::= NK_INTEGER", - /* 477 */ "signed ::= NK_PLUS NK_INTEGER", - /* 478 */ "signed ::= NK_MINUS NK_INTEGER", - /* 479 */ "signed ::= NK_FLOAT", - /* 480 */ "signed ::= NK_PLUS NK_FLOAT", - /* 481 */ "signed ::= NK_MINUS NK_FLOAT", - /* 482 */ "signed_literal ::= signed", - /* 483 */ "signed_literal ::= NK_STRING", - /* 484 */ "signed_literal ::= NK_BOOL", - /* 485 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 486 */ "signed_literal ::= duration_literal", - /* 487 */ "signed_literal ::= NULL", - /* 488 */ "signed_literal ::= literal_func", - /* 489 */ "signed_literal ::= NK_QUESTION", - /* 490 */ "literal_list ::= signed_literal", - /* 491 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 492 */ "db_name ::= NK_ID", - /* 493 */ "table_name ::= NK_ID", - /* 494 */ "column_name ::= NK_ID", - /* 495 */ "function_name ::= NK_ID", - /* 496 */ "view_name ::= NK_ID", - /* 497 */ "table_alias ::= NK_ID", - /* 498 */ "column_alias ::= NK_ID", - /* 499 */ "column_alias ::= NK_ALIAS", - /* 500 */ "user_name ::= NK_ID", - /* 501 */ "topic_name ::= NK_ID", - /* 502 */ "stream_name ::= NK_ID", - /* 503 */ "cgroup_name ::= NK_ID", - /* 504 */ "index_name ::= NK_ID", - /* 505 */ "expr_or_subquery ::= expression", - /* 506 */ "expression ::= literal", - /* 507 */ "expression ::= pseudo_column", - /* 508 */ "expression ::= column_reference", - /* 509 */ "expression ::= function_expression", - /* 510 */ "expression ::= case_when_expression", - /* 511 */ "expression ::= NK_LP expression NK_RP", - /* 512 */ "expression ::= NK_PLUS expr_or_subquery", - /* 513 */ "expression ::= NK_MINUS expr_or_subquery", - /* 514 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", - /* 515 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", - /* 516 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", - /* 517 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", - /* 518 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", - /* 519 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 520 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", - /* 521 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", - /* 522 */ "expression_list ::= expr_or_subquery", - /* 523 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", - /* 524 */ "column_reference ::= column_name", - /* 525 */ "column_reference ::= table_name NK_DOT column_name", - /* 526 */ "column_reference ::= NK_ALIAS", - /* 527 */ "column_reference ::= table_name NK_DOT NK_ALIAS", - /* 528 */ "pseudo_column ::= ROWTS", - /* 529 */ "pseudo_column ::= TBNAME", - /* 530 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 531 */ "pseudo_column ::= QSTART", - /* 532 */ "pseudo_column ::= QEND", - /* 533 */ "pseudo_column ::= QDURATION", - /* 534 */ "pseudo_column ::= WSTART", - /* 535 */ "pseudo_column ::= WEND", - /* 536 */ "pseudo_column ::= WDURATION", - /* 537 */ "pseudo_column ::= IROWTS", - /* 538 */ "pseudo_column ::= ISFILLED", - /* 539 */ "pseudo_column ::= QTAGS", - /* 540 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 541 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 542 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", - /* 543 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name_default_len NK_RP", - /* 544 */ "function_expression ::= literal_func", - /* 545 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 546 */ "literal_func ::= NOW", - /* 547 */ "literal_func ::= TODAY", - /* 548 */ "noarg_func ::= NOW", - /* 549 */ "noarg_func ::= TODAY", - /* 550 */ "noarg_func ::= TIMEZONE", - /* 551 */ "noarg_func ::= DATABASE", - /* 552 */ "noarg_func ::= CLIENT_VERSION", - /* 553 */ "noarg_func ::= SERVER_VERSION", - /* 554 */ "noarg_func ::= SERVER_STATUS", - /* 555 */ "noarg_func ::= CURRENT_USER", - /* 556 */ "noarg_func ::= USER", - /* 557 */ "star_func ::= COUNT", - /* 558 */ "star_func ::= FIRST", - /* 559 */ "star_func ::= LAST", - /* 560 */ "star_func ::= LAST_ROW", - /* 561 */ "star_func_para_list ::= NK_STAR", - /* 562 */ "star_func_para_list ::= other_para_list", - /* 563 */ "other_para_list ::= star_func_para", - /* 564 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 565 */ "star_func_para ::= expr_or_subquery", - /* 566 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 567 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", - /* 568 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", - /* 569 */ "when_then_list ::= when_then_expr", - /* 570 */ "when_then_list ::= when_then_list when_then_expr", - /* 571 */ "when_then_expr ::= WHEN common_expression THEN common_expression", - /* 572 */ "case_when_else_opt ::=", - /* 573 */ "case_when_else_opt ::= ELSE common_expression", - /* 574 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", - /* 575 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", - /* 576 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", - /* 577 */ "predicate ::= expr_or_subquery IS NULL", - /* 578 */ "predicate ::= expr_or_subquery IS NOT NULL", - /* 579 */ "predicate ::= expr_or_subquery in_op in_predicate_value", - /* 580 */ "compare_op ::= NK_LT", - /* 581 */ "compare_op ::= NK_GT", - /* 582 */ "compare_op ::= NK_LE", - /* 583 */ "compare_op ::= NK_GE", - /* 584 */ "compare_op ::= NK_NE", - /* 585 */ "compare_op ::= NK_EQ", - /* 586 */ "compare_op ::= LIKE", - /* 587 */ "compare_op ::= NOT LIKE", - /* 588 */ "compare_op ::= MATCH", - /* 589 */ "compare_op ::= NMATCH", - /* 590 */ "compare_op ::= CONTAINS", - /* 591 */ "in_op ::= IN", - /* 592 */ "in_op ::= NOT IN", - /* 593 */ "in_predicate_value ::= NK_LP literal_list NK_RP", - /* 594 */ "boolean_value_expression ::= boolean_primary", - /* 595 */ "boolean_value_expression ::= NOT boolean_primary", - /* 596 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 597 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 598 */ "boolean_primary ::= predicate", - /* 599 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 600 */ "common_expression ::= expr_or_subquery", - /* 601 */ "common_expression ::= boolean_value_expression", - /* 602 */ "from_clause_opt ::=", - /* 603 */ "from_clause_opt ::= FROM table_reference_list", - /* 604 */ "table_reference_list ::= table_reference", - /* 605 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 606 */ "table_reference ::= table_primary", - /* 607 */ "table_reference ::= joined_table", - /* 608 */ "table_primary ::= table_name alias_opt", - /* 609 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 610 */ "table_primary ::= subquery alias_opt", - /* 611 */ "table_primary ::= parenthesized_joined_table", - /* 612 */ "alias_opt ::=", - /* 613 */ "alias_opt ::= table_alias", - /* 614 */ "alias_opt ::= AS table_alias", - /* 615 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 616 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 617 */ "joined_table ::= table_reference join_type join_subtype JOIN table_reference join_on_clause_opt window_offset_clause_opt jlimit_clause_opt", - /* 618 */ "join_type ::=", - /* 619 */ "join_type ::= INNER", - /* 620 */ "join_type ::= LEFT", - /* 621 */ "join_type ::= RIGHT", - /* 622 */ "join_type ::= FULL", - /* 623 */ "join_subtype ::=", - /* 624 */ "join_subtype ::= OUTER", - /* 625 */ "join_subtype ::= SEMI", - /* 626 */ "join_subtype ::= ANTI", - /* 627 */ "join_subtype ::= ASOF", - /* 628 */ "join_subtype ::= WINDOW", - /* 629 */ "join_on_clause_opt ::=", - /* 630 */ "join_on_clause_opt ::= ON search_condition", - /* 631 */ "window_offset_clause_opt ::=", - /* 632 */ "window_offset_clause_opt ::= WINDOW_OFFSET NK_LP window_offset_literal NK_COMMA window_offset_literal NK_RP", - /* 633 */ "window_offset_literal ::= NK_VARIABLE", - /* 634 */ "window_offset_literal ::= NK_MINUS NK_VARIABLE", - /* 635 */ "jlimit_clause_opt ::=", - /* 636 */ "jlimit_clause_opt ::= JLIMIT NK_INTEGER", - /* 637 */ "query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", - /* 638 */ "hint_list ::=", - /* 639 */ "hint_list ::= NK_HINT", - /* 640 */ "tag_mode_opt ::=", - /* 641 */ "tag_mode_opt ::= TAGS", - /* 642 */ "set_quantifier_opt ::=", - /* 643 */ "set_quantifier_opt ::= DISTINCT", - /* 644 */ "set_quantifier_opt ::= ALL", - /* 645 */ "select_list ::= select_item", - /* 646 */ "select_list ::= select_list NK_COMMA select_item", - /* 647 */ "select_item ::= NK_STAR", - /* 648 */ "select_item ::= common_expression", - /* 649 */ "select_item ::= common_expression column_alias", - /* 650 */ "select_item ::= common_expression AS column_alias", - /* 651 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 652 */ "where_clause_opt ::=", - /* 653 */ "where_clause_opt ::= WHERE search_condition", - /* 654 */ "partition_by_clause_opt ::=", - /* 655 */ "partition_by_clause_opt ::= PARTITION BY partition_list", - /* 656 */ "partition_list ::= partition_item", - /* 657 */ "partition_list ::= partition_list NK_COMMA partition_item", - /* 658 */ "partition_item ::= expr_or_subquery", - /* 659 */ "partition_item ::= expr_or_subquery column_alias", - /* 660 */ "partition_item ::= expr_or_subquery AS column_alias", - /* 661 */ "twindow_clause_opt ::=", - /* 662 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP", - /* 663 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", - /* 664 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt", - /* 665 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt", - /* 666 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", - /* 667 */ "twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP", - /* 668 */ "twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 669 */ "sliding_opt ::=", - /* 670 */ "sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP", - /* 671 */ "interval_sliding_duration_literal ::= NK_VARIABLE", - /* 672 */ "interval_sliding_duration_literal ::= NK_STRING", - /* 673 */ "interval_sliding_duration_literal ::= NK_INTEGER", - /* 674 */ "fill_opt ::=", - /* 675 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 676 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP", - /* 677 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP", - /* 678 */ "fill_mode ::= NONE", - /* 679 */ "fill_mode ::= PREV", - /* 680 */ "fill_mode ::= NULL", - /* 681 */ "fill_mode ::= NULL_F", - /* 682 */ "fill_mode ::= LINEAR", - /* 683 */ "fill_mode ::= NEXT", - /* 684 */ "group_by_clause_opt ::=", - /* 685 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 686 */ "group_by_list ::= expr_or_subquery", - /* 687 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", - /* 688 */ "having_clause_opt ::=", - /* 689 */ "having_clause_opt ::= HAVING search_condition", - /* 690 */ "range_opt ::=", - /* 691 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", - /* 692 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_RP", - /* 693 */ "every_opt ::=", - /* 694 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 695 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 696 */ "query_simple ::= query_specification", - /* 697 */ "query_simple ::= union_query_expression", - /* 698 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", - /* 699 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", - /* 700 */ "query_simple_or_subquery ::= query_simple", - /* 701 */ "query_simple_or_subquery ::= subquery", - /* 702 */ "query_or_subquery ::= query_expression", - /* 703 */ "query_or_subquery ::= subquery", - /* 704 */ "order_by_clause_opt ::=", - /* 705 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 706 */ "slimit_clause_opt ::=", - /* 707 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 708 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 709 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 710 */ "limit_clause_opt ::=", - /* 711 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 712 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 713 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 714 */ "subquery ::= NK_LP query_expression NK_RP", - /* 715 */ "subquery ::= NK_LP subquery NK_RP", - /* 716 */ "search_condition ::= common_expression", - /* 717 */ "sort_specification_list ::= sort_specification", - /* 718 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 719 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", - /* 720 */ "ordering_specification_opt ::=", - /* 721 */ "ordering_specification_opt ::= ASC", - /* 722 */ "ordering_specification_opt ::= DESC", - /* 723 */ "null_ordering_opt ::=", - /* 724 */ "null_ordering_opt ::= NULLS FIRST", - /* 725 */ "null_ordering_opt ::= NULLS LAST", + /* 332 */ "cmd ::= CREATE TSMA not_exists_opt tsma_name ON full_table_name tsma_func_list INTERVAL NK_LP duration_literal NK_RP", + /* 333 */ "cmd ::= CREATE RECURSIVE TSMA not_exists_opt tsma_name ON full_table_name INTERVAL NK_LP duration_literal NK_RP", + /* 334 */ "cmd ::= DROP TSMA exists_opt full_tsma_name", + /* 335 */ "cmd ::= SHOW db_name_cond_opt TSMAS", + /* 336 */ "full_tsma_name ::= tsma_name", + /* 337 */ "full_tsma_name ::= db_name NK_DOT tsma_name", + /* 338 */ "tsma_func_list ::= FUNCTION NK_LP func_list NK_RP", + /* 339 */ "cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options", + /* 340 */ "cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP", + /* 341 */ "cmd ::= DROP INDEX exists_opt full_index_name", + /* 342 */ "full_index_name ::= index_name", + /* 343 */ "full_index_name ::= db_name NK_DOT index_name", + /* 344 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", + /* 345 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt", + /* 346 */ "func_list ::= func", + /* 347 */ "func_list ::= func_list NK_COMMA func", + /* 348 */ "func ::= sma_func_name NK_LP expression_list NK_RP", + /* 349 */ "sma_func_name ::= function_name", + /* 350 */ "sma_func_name ::= COUNT", + /* 351 */ "sma_func_name ::= FIRST", + /* 352 */ "sma_func_name ::= LAST", + /* 353 */ "sma_func_name ::= LAST_ROW", + /* 354 */ "sma_stream_opt ::=", + /* 355 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", + /* 356 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", + /* 357 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", + /* 358 */ "with_meta ::= AS", + /* 359 */ "with_meta ::= WITH META AS", + /* 360 */ "with_meta ::= ONLY META AS", + /* 361 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", + /* 362 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name", + /* 363 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt", + /* 364 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 365 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", + /* 366 */ "cmd ::= DESC full_table_name", + /* 367 */ "cmd ::= DESCRIBE full_table_name", + /* 368 */ "cmd ::= RESET QUERY CACHE", + /* 369 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", + /* 370 */ "cmd ::= EXPLAIN analyze_opt explain_options insert_query", + /* 371 */ "analyze_opt ::=", + /* 372 */ "analyze_opt ::= ANALYZE", + /* 373 */ "explain_options ::=", + /* 374 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 375 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 376 */ "cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt", + /* 377 */ "cmd ::= DROP FUNCTION exists_opt function_name", + /* 378 */ "agg_func_opt ::=", + /* 379 */ "agg_func_opt ::= AGGREGATE", + /* 380 */ "bufsize_opt ::=", + /* 381 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 382 */ "language_opt ::=", + /* 383 */ "language_opt ::= LANGUAGE NK_STRING", + /* 384 */ "or_replace_opt ::=", + /* 385 */ "or_replace_opt ::= OR REPLACE", + /* 386 */ "cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery", + /* 387 */ "cmd ::= DROP VIEW exists_opt full_view_name", + /* 388 */ "full_view_name ::= view_name", + /* 389 */ "full_view_name ::= db_name NK_DOT view_name", + /* 390 */ "cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery", + /* 391 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 392 */ "cmd ::= PAUSE STREAM exists_opt stream_name", + /* 393 */ "cmd ::= RESUME STREAM exists_opt ignore_opt stream_name", + /* 394 */ "col_list_opt ::=", + /* 395 */ "col_list_opt ::= NK_LP column_stream_def_list NK_RP", + /* 396 */ "column_stream_def_list ::= column_stream_def", + /* 397 */ "column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def", + /* 398 */ "column_stream_def ::= column_name", + /* 399 */ "column_stream_def ::= column_name PRIMARY KEY", + /* 400 */ "tag_def_or_ref_opt ::=", + /* 401 */ "tag_def_or_ref_opt ::= tags_def", + /* 402 */ "tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP", + /* 403 */ "stream_options ::=", + /* 404 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 405 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 406 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 407 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 408 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", + /* 409 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", + /* 410 */ "stream_options ::= stream_options DELETE_MARK duration_literal", + /* 411 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER", + /* 412 */ "subtable_opt ::=", + /* 413 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", + /* 414 */ "ignore_opt ::=", + /* 415 */ "ignore_opt ::= IGNORE UNTREATED", + /* 416 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 417 */ "cmd ::= KILL QUERY NK_STRING", + /* 418 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 419 */ "cmd ::= KILL COMPACT NK_INTEGER", + /* 420 */ "cmd ::= BALANCE VGROUP", + /* 421 */ "cmd ::= BALANCE VGROUP LEADER on_vgroup_id", + /* 422 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 423 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 424 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 425 */ "on_vgroup_id ::=", + /* 426 */ "on_vgroup_id ::= ON NK_INTEGER", + /* 427 */ "dnode_list ::= DNODE NK_INTEGER", + /* 428 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 429 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 430 */ "cmd ::= query_or_subquery", + /* 431 */ "cmd ::= insert_query", + /* 432 */ "insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", + /* 433 */ "insert_query ::= INSERT INTO full_table_name query_or_subquery", + /* 434 */ "tags_literal ::= NK_INTEGER", + /* 435 */ "tags_literal ::= NK_INTEGER NK_PLUS duration_literal", + /* 436 */ "tags_literal ::= NK_INTEGER NK_MINUS duration_literal", + /* 437 */ "tags_literal ::= NK_PLUS NK_INTEGER", + /* 438 */ "tags_literal ::= NK_PLUS NK_INTEGER NK_PLUS duration_literal", + /* 439 */ "tags_literal ::= NK_PLUS NK_INTEGER NK_MINUS duration_literal", + /* 440 */ "tags_literal ::= NK_MINUS NK_INTEGER", + /* 441 */ "tags_literal ::= NK_MINUS NK_INTEGER NK_PLUS duration_literal", + /* 442 */ "tags_literal ::= NK_MINUS NK_INTEGER NK_MINUS duration_literal", + /* 443 */ "tags_literal ::= NK_FLOAT", + /* 444 */ "tags_literal ::= NK_PLUS NK_FLOAT", + /* 445 */ "tags_literal ::= NK_MINUS NK_FLOAT", + /* 446 */ "tags_literal ::= NK_BIN", + /* 447 */ "tags_literal ::= NK_BIN NK_PLUS duration_literal", + /* 448 */ "tags_literal ::= NK_BIN NK_MINUS duration_literal", + /* 449 */ "tags_literal ::= NK_PLUS NK_BIN", + /* 450 */ "tags_literal ::= NK_PLUS NK_BIN NK_PLUS duration_literal", + /* 451 */ "tags_literal ::= NK_PLUS NK_BIN NK_MINUS duration_literal", + /* 452 */ "tags_literal ::= NK_MINUS NK_BIN", + /* 453 */ "tags_literal ::= NK_MINUS NK_BIN NK_PLUS duration_literal", + /* 454 */ "tags_literal ::= NK_MINUS NK_BIN NK_MINUS duration_literal", + /* 455 */ "tags_literal ::= NK_HEX", + /* 456 */ "tags_literal ::= NK_HEX NK_PLUS duration_literal", + /* 457 */ "tags_literal ::= NK_HEX NK_MINUS duration_literal", + /* 458 */ "tags_literal ::= NK_PLUS NK_HEX", + /* 459 */ "tags_literal ::= NK_PLUS NK_HEX NK_PLUS duration_literal", + /* 460 */ "tags_literal ::= NK_PLUS NK_HEX NK_MINUS duration_literal", + /* 461 */ "tags_literal ::= NK_MINUS NK_HEX", + /* 462 */ "tags_literal ::= NK_MINUS NK_HEX NK_PLUS duration_literal", + /* 463 */ "tags_literal ::= NK_MINUS NK_HEX NK_MINUS duration_literal", + /* 464 */ "tags_literal ::= NK_STRING", + /* 465 */ "tags_literal ::= NK_STRING NK_PLUS duration_literal", + /* 466 */ "tags_literal ::= NK_STRING NK_MINUS duration_literal", + /* 467 */ "tags_literal ::= NK_BOOL", + /* 468 */ "tags_literal ::= NULL", + /* 469 */ "tags_literal ::= literal_func", + /* 470 */ "tags_literal ::= literal_func NK_PLUS duration_literal", + /* 471 */ "tags_literal ::= literal_func NK_MINUS duration_literal", + /* 472 */ "tags_literal_list ::= tags_literal", + /* 473 */ "tags_literal_list ::= tags_literal_list NK_COMMA tags_literal", + /* 474 */ "literal ::= NK_INTEGER", + /* 475 */ "literal ::= NK_FLOAT", + /* 476 */ "literal ::= NK_STRING", + /* 477 */ "literal ::= NK_BOOL", + /* 478 */ "literal ::= TIMESTAMP NK_STRING", + /* 479 */ "literal ::= duration_literal", + /* 480 */ "literal ::= NULL", + /* 481 */ "literal ::= NK_QUESTION", + /* 482 */ "duration_literal ::= NK_VARIABLE", + /* 483 */ "signed ::= NK_INTEGER", + /* 484 */ "signed ::= NK_PLUS NK_INTEGER", + /* 485 */ "signed ::= NK_MINUS NK_INTEGER", + /* 486 */ "signed ::= NK_FLOAT", + /* 487 */ "signed ::= NK_PLUS NK_FLOAT", + /* 488 */ "signed ::= NK_MINUS NK_FLOAT", + /* 489 */ "signed_literal ::= signed", + /* 490 */ "signed_literal ::= NK_STRING", + /* 491 */ "signed_literal ::= NK_BOOL", + /* 492 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 493 */ "signed_literal ::= duration_literal", + /* 494 */ "signed_literal ::= NULL", + /* 495 */ "signed_literal ::= literal_func", + /* 496 */ "signed_literal ::= NK_QUESTION", + /* 497 */ "literal_list ::= signed_literal", + /* 498 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 499 */ "db_name ::= NK_ID", + /* 500 */ "table_name ::= NK_ID", + /* 501 */ "column_name ::= NK_ID", + /* 502 */ "function_name ::= NK_ID", + /* 503 */ "view_name ::= NK_ID", + /* 504 */ "table_alias ::= NK_ID", + /* 505 */ "column_alias ::= NK_ID", + /* 506 */ "column_alias ::= NK_ALIAS", + /* 507 */ "user_name ::= NK_ID", + /* 508 */ "topic_name ::= NK_ID", + /* 509 */ "stream_name ::= NK_ID", + /* 510 */ "cgroup_name ::= NK_ID", + /* 511 */ "index_name ::= NK_ID", + /* 512 */ "tsma_name ::= NK_ID", + /* 513 */ "expr_or_subquery ::= expression", + /* 514 */ "expression ::= literal", + /* 515 */ "expression ::= pseudo_column", + /* 516 */ "expression ::= column_reference", + /* 517 */ "expression ::= function_expression", + /* 518 */ "expression ::= case_when_expression", + /* 519 */ "expression ::= NK_LP expression NK_RP", + /* 520 */ "expression ::= NK_PLUS expr_or_subquery", + /* 521 */ "expression ::= NK_MINUS expr_or_subquery", + /* 522 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", + /* 523 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", + /* 524 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", + /* 525 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", + /* 526 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", + /* 527 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 528 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", + /* 529 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", + /* 530 */ "expression_list ::= expr_or_subquery", + /* 531 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", + /* 532 */ "column_reference ::= column_name", + /* 533 */ "column_reference ::= table_name NK_DOT column_name", + /* 534 */ "column_reference ::= NK_ALIAS", + /* 535 */ "column_reference ::= table_name NK_DOT NK_ALIAS", + /* 536 */ "pseudo_column ::= ROWTS", + /* 537 */ "pseudo_column ::= TBNAME", + /* 538 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 539 */ "pseudo_column ::= QSTART", + /* 540 */ "pseudo_column ::= QEND", + /* 541 */ "pseudo_column ::= QDURATION", + /* 542 */ "pseudo_column ::= WSTART", + /* 543 */ "pseudo_column ::= WEND", + /* 544 */ "pseudo_column ::= WDURATION", + /* 545 */ "pseudo_column ::= IROWTS", + /* 546 */ "pseudo_column ::= ISFILLED", + /* 547 */ "pseudo_column ::= QTAGS", + /* 548 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 549 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 550 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", + /* 551 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name_default_len NK_RP", + /* 552 */ "function_expression ::= literal_func", + /* 553 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 554 */ "literal_func ::= NOW", + /* 555 */ "literal_func ::= TODAY", + /* 556 */ "noarg_func ::= NOW", + /* 557 */ "noarg_func ::= TODAY", + /* 558 */ "noarg_func ::= TIMEZONE", + /* 559 */ "noarg_func ::= DATABASE", + /* 560 */ "noarg_func ::= CLIENT_VERSION", + /* 561 */ "noarg_func ::= SERVER_VERSION", + /* 562 */ "noarg_func ::= SERVER_STATUS", + /* 563 */ "noarg_func ::= CURRENT_USER", + /* 564 */ "noarg_func ::= USER", + /* 565 */ "star_func ::= COUNT", + /* 566 */ "star_func ::= FIRST", + /* 567 */ "star_func ::= LAST", + /* 568 */ "star_func ::= LAST_ROW", + /* 569 */ "star_func_para_list ::= NK_STAR", + /* 570 */ "star_func_para_list ::= other_para_list", + /* 571 */ "other_para_list ::= star_func_para", + /* 572 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 573 */ "star_func_para ::= expr_or_subquery", + /* 574 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 575 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", + /* 576 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", + /* 577 */ "when_then_list ::= when_then_expr", + /* 578 */ "when_then_list ::= when_then_list when_then_expr", + /* 579 */ "when_then_expr ::= WHEN common_expression THEN common_expression", + /* 580 */ "case_when_else_opt ::=", + /* 581 */ "case_when_else_opt ::= ELSE common_expression", + /* 582 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", + /* 583 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", + /* 584 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", + /* 585 */ "predicate ::= expr_or_subquery IS NULL", + /* 586 */ "predicate ::= expr_or_subquery IS NOT NULL", + /* 587 */ "predicate ::= expr_or_subquery in_op in_predicate_value", + /* 588 */ "compare_op ::= NK_LT", + /* 589 */ "compare_op ::= NK_GT", + /* 590 */ "compare_op ::= NK_LE", + /* 591 */ "compare_op ::= NK_GE", + /* 592 */ "compare_op ::= NK_NE", + /* 593 */ "compare_op ::= NK_EQ", + /* 594 */ "compare_op ::= LIKE", + /* 595 */ "compare_op ::= NOT LIKE", + /* 596 */ "compare_op ::= MATCH", + /* 597 */ "compare_op ::= NMATCH", + /* 598 */ "compare_op ::= CONTAINS", + /* 599 */ "in_op ::= IN", + /* 600 */ "in_op ::= NOT IN", + /* 601 */ "in_predicate_value ::= NK_LP literal_list NK_RP", + /* 602 */ "boolean_value_expression ::= boolean_primary", + /* 603 */ "boolean_value_expression ::= NOT boolean_primary", + /* 604 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 605 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 606 */ "boolean_primary ::= predicate", + /* 607 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 608 */ "common_expression ::= expr_or_subquery", + /* 609 */ "common_expression ::= boolean_value_expression", + /* 610 */ "from_clause_opt ::=", + /* 611 */ "from_clause_opt ::= FROM table_reference_list", + /* 612 */ "table_reference_list ::= table_reference", + /* 613 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 614 */ "table_reference ::= table_primary", + /* 615 */ "table_reference ::= joined_table", + /* 616 */ "table_primary ::= table_name alias_opt", + /* 617 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 618 */ "table_primary ::= subquery alias_opt", + /* 619 */ "table_primary ::= parenthesized_joined_table", + /* 620 */ "alias_opt ::=", + /* 621 */ "alias_opt ::= table_alias", + /* 622 */ "alias_opt ::= AS table_alias", + /* 623 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 624 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 625 */ "joined_table ::= table_reference join_type join_subtype JOIN table_reference join_on_clause_opt window_offset_clause_opt jlimit_clause_opt", + /* 626 */ "join_type ::=", + /* 627 */ "join_type ::= INNER", + /* 628 */ "join_type ::= LEFT", + /* 629 */ "join_type ::= RIGHT", + /* 630 */ "join_type ::= FULL", + /* 631 */ "join_subtype ::=", + /* 632 */ "join_subtype ::= OUTER", + /* 633 */ "join_subtype ::= SEMI", + /* 634 */ "join_subtype ::= ANTI", + /* 635 */ "join_subtype ::= ASOF", + /* 636 */ "join_subtype ::= WINDOW", + /* 637 */ "join_on_clause_opt ::=", + /* 638 */ "join_on_clause_opt ::= ON search_condition", + /* 639 */ "window_offset_clause_opt ::=", + /* 640 */ "window_offset_clause_opt ::= WINDOW_OFFSET NK_LP window_offset_literal NK_COMMA window_offset_literal NK_RP", + /* 641 */ "window_offset_literal ::= NK_VARIABLE", + /* 642 */ "window_offset_literal ::= NK_MINUS NK_VARIABLE", + /* 643 */ "jlimit_clause_opt ::=", + /* 644 */ "jlimit_clause_opt ::= JLIMIT NK_INTEGER", + /* 645 */ "query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt", + /* 646 */ "hint_list ::=", + /* 647 */ "hint_list ::= NK_HINT", + /* 648 */ "tag_mode_opt ::=", + /* 649 */ "tag_mode_opt ::= TAGS", + /* 650 */ "set_quantifier_opt ::=", + /* 651 */ "set_quantifier_opt ::= DISTINCT", + /* 652 */ "set_quantifier_opt ::= ALL", + /* 653 */ "select_list ::= select_item", + /* 654 */ "select_list ::= select_list NK_COMMA select_item", + /* 655 */ "select_item ::= NK_STAR", + /* 656 */ "select_item ::= common_expression", + /* 657 */ "select_item ::= common_expression column_alias", + /* 658 */ "select_item ::= common_expression AS column_alias", + /* 659 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 660 */ "where_clause_opt ::=", + /* 661 */ "where_clause_opt ::= WHERE search_condition", + /* 662 */ "partition_by_clause_opt ::=", + /* 663 */ "partition_by_clause_opt ::= PARTITION BY partition_list", + /* 664 */ "partition_list ::= partition_item", + /* 665 */ "partition_list ::= partition_list NK_COMMA partition_item", + /* 666 */ "partition_item ::= expr_or_subquery", + /* 667 */ "partition_item ::= expr_or_subquery column_alias", + /* 668 */ "partition_item ::= expr_or_subquery AS column_alias", + /* 669 */ "twindow_clause_opt ::=", + /* 670 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP", + /* 671 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", + /* 672 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt", + /* 673 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt", + /* 674 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", + /* 675 */ "twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP", + /* 676 */ "twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 677 */ "sliding_opt ::=", + /* 678 */ "sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP", + /* 679 */ "interval_sliding_duration_literal ::= NK_VARIABLE", + /* 680 */ "interval_sliding_duration_literal ::= NK_STRING", + /* 681 */ "interval_sliding_duration_literal ::= NK_INTEGER", + /* 682 */ "fill_opt ::=", + /* 683 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 684 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP", + /* 685 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP", + /* 686 */ "fill_mode ::= NONE", + /* 687 */ "fill_mode ::= PREV", + /* 688 */ "fill_mode ::= NULL", + /* 689 */ "fill_mode ::= NULL_F", + /* 690 */ "fill_mode ::= LINEAR", + /* 691 */ "fill_mode ::= NEXT", + /* 692 */ "group_by_clause_opt ::=", + /* 693 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 694 */ "group_by_list ::= expr_or_subquery", + /* 695 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", + /* 696 */ "having_clause_opt ::=", + /* 697 */ "having_clause_opt ::= HAVING search_condition", + /* 698 */ "range_opt ::=", + /* 699 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", + /* 700 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_RP", + /* 701 */ "every_opt ::=", + /* 702 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 703 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 704 */ "query_simple ::= query_specification", + /* 705 */ "query_simple ::= union_query_expression", + /* 706 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", + /* 707 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", + /* 708 */ "query_simple_or_subquery ::= query_simple", + /* 709 */ "query_simple_or_subquery ::= subquery", + /* 710 */ "query_or_subquery ::= query_expression", + /* 711 */ "query_or_subquery ::= subquery", + /* 712 */ "order_by_clause_opt ::=", + /* 713 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 714 */ "slimit_clause_opt ::=", + /* 715 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 716 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 717 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 718 */ "limit_clause_opt ::=", + /* 719 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 720 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 721 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 722 */ "subquery ::= NK_LP query_expression NK_RP", + /* 723 */ "subquery ::= NK_LP subquery NK_RP", + /* 724 */ "search_condition ::= common_expression", + /* 725 */ "sort_specification_list ::= sort_specification", + /* 726 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 727 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", + /* 728 */ "ordering_specification_opt ::=", + /* 729 */ "ordering_specification_opt ::= ASC", + /* 730 */ "ordering_specification_opt ::= DESC", + /* 731 */ "null_ordering_opt ::=", + /* 732 */ "null_ordering_opt ::= NULLS FIRST", + /* 733 */ "null_ordering_opt ::= NULLS LAST", }; #endif /* NDEBUG */ @@ -3000,247 +3410,292 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - case 367: /* cmd */ - case 370: /* literal */ - case 379: /* with_opt */ - case 385: /* search_condition */ - case 390: /* db_options */ - case 392: /* alter_db_options */ - case 394: /* start_opt */ - case 395: /* end_opt */ - case 399: /* signed */ - case 401: /* retention */ - case 402: /* full_table_name */ - case 405: /* table_options */ - case 409: /* alter_table_clause */ - case 410: /* alter_table_options */ - case 413: /* tags_literal */ - case 414: /* create_subtable_clause */ - case 417: /* drop_table_clause */ - case 419: /* column_def */ - case 424: /* duration_literal */ - case 425: /* rollup_func_name */ - case 427: /* col_name */ - case 430: /* like_pattern_opt */ - case 431: /* db_name_cond_opt */ - case 432: /* table_name_cond */ - case 433: /* from_db_opt */ - case 436: /* tag_item */ - case 438: /* index_options */ - case 439: /* full_index_name */ - case 442: /* sliding_opt */ - case 443: /* sma_stream_opt */ - case 444: /* func */ - case 448: /* query_or_subquery */ - case 449: /* where_clause_opt */ - case 452: /* explain_options */ - case 453: /* insert_query */ - case 458: /* full_view_name */ - case 461: /* stream_options */ - case 464: /* subtable_opt */ - case 467: /* column_stream_def */ - case 468: /* expression */ - case 471: /* literal_func */ - case 472: /* signed_literal */ - case 475: /* expr_or_subquery */ - case 476: /* pseudo_column */ - case 477: /* column_reference */ - case 478: /* function_expression */ - case 479: /* case_when_expression */ - case 484: /* star_func_para */ - case 486: /* case_when_else_opt */ - case 487: /* common_expression */ - case 488: /* when_then_expr */ - case 489: /* predicate */ - case 492: /* in_predicate_value */ - case 493: /* boolean_value_expression */ - case 494: /* boolean_primary */ - case 495: /* from_clause_opt */ - case 496: /* table_reference_list */ - case 497: /* table_reference */ - case 498: /* table_primary */ - case 499: /* joined_table */ - case 501: /* subquery */ - case 502: /* parenthesized_joined_table */ - case 505: /* join_on_clause_opt */ - case 506: /* window_offset_clause_opt */ - case 507: /* jlimit_clause_opt */ - case 508: /* window_offset_literal */ - case 509: /* query_specification */ - case 515: /* range_opt */ - case 516: /* every_opt */ - case 517: /* fill_opt */ - case 518: /* twindow_clause_opt */ - case 520: /* having_clause_opt */ - case 521: /* select_item */ - case 523: /* partition_item */ - case 524: /* interval_sliding_duration_literal */ - case 527: /* query_expression */ - case 528: /* query_simple */ - case 530: /* slimit_clause_opt */ - case 531: /* limit_clause_opt */ - case 532: /* union_query_expression */ - case 533: /* query_simple_or_subquery */ - case 535: /* sort_specification */ + case 370: /* cmd */ + case 373: /* literal */ + case 382: /* with_opt */ + case 388: /* search_condition */ + case 393: /* db_options */ + case 395: /* alter_db_options */ + case 397: /* start_opt */ + case 398: /* end_opt */ + case 402: /* signed */ + case 404: /* retention */ + case 405: /* full_table_name */ + case 408: /* table_options */ + case 412: /* alter_table_clause */ + case 413: /* alter_table_options */ + case 416: /* tags_literal */ + case 417: /* create_subtable_clause */ + case 420: /* drop_table_clause */ + case 422: /* column_def */ + case 427: /* duration_literal */ + case 428: /* rollup_func_name */ + case 430: /* col_name */ + case 433: /* like_pattern_opt */ + case 434: /* db_name_cond_opt */ + case 435: /* table_name_cond */ + case 436: /* from_db_opt */ + case 439: /* tag_item */ + case 443: /* full_tsma_name */ + case 445: /* index_options */ + case 446: /* full_index_name */ + case 448: /* sliding_opt */ + case 449: /* sma_stream_opt */ + case 450: /* func */ + case 454: /* query_or_subquery */ + case 455: /* where_clause_opt */ + case 458: /* explain_options */ + case 459: /* insert_query */ + case 464: /* full_view_name */ + case 467: /* stream_options */ + case 470: /* subtable_opt */ + case 473: /* column_stream_def */ + case 474: /* expression */ + case 477: /* literal_func */ + case 478: /* signed_literal */ + case 481: /* expr_or_subquery */ + case 482: /* pseudo_column */ + case 483: /* column_reference */ + case 484: /* function_expression */ + case 485: /* case_when_expression */ + case 490: /* star_func_para */ + case 492: /* case_when_else_opt */ + case 493: /* common_expression */ + case 494: /* when_then_expr */ + case 495: /* predicate */ + case 498: /* in_predicate_value */ + case 499: /* boolean_value_expression */ + case 500: /* boolean_primary */ + case 501: /* from_clause_opt */ + case 502: /* table_reference_list */ + case 503: /* table_reference */ + case 504: /* table_primary */ + case 505: /* joined_table */ + case 507: /* subquery */ + case 508: /* parenthesized_joined_table */ + case 511: /* join_on_clause_opt */ + case 512: /* window_offset_clause_opt */ + case 513: /* jlimit_clause_opt */ + case 514: /* window_offset_literal */ + case 515: /* query_specification */ + case 521: /* range_opt */ + case 522: /* every_opt */ + case 523: /* fill_opt */ + case 524: /* twindow_clause_opt */ + case 526: /* having_clause_opt */ + case 527: /* select_item */ + case 529: /* partition_item */ + case 530: /* interval_sliding_duration_literal */ + case 533: /* query_expression */ + case 534: /* query_simple */ + case 536: /* slimit_clause_opt */ + case 537: /* limit_clause_opt */ + case 538: /* union_query_expression */ + case 539: /* query_simple_or_subquery */ + case 541: /* sort_specification */ { - nodesDestroyNode((yypminor->yy720)); +#line 7 "sql.y" + nodesDestroyNode((yypminor->yy40)); +#line 3499 "sql.c" } break; - case 368: /* account_options */ - case 369: /* alter_account_options */ - case 371: /* alter_account_option */ - case 393: /* speed_opt */ - case 447: /* with_meta */ - case 456: /* bufsize_opt */ + case 371: /* account_options */ + case 372: /* alter_account_options */ + case 374: /* alter_account_option */ + case 396: /* speed_opt */ + case 453: /* with_meta */ + case 462: /* bufsize_opt */ { +#line 54 "sql.y" +#line 3511 "sql.c" } break; - case 372: /* ip_range_list */ - case 373: /* white_list */ - case 374: /* white_list_opt */ - case 396: /* integer_list */ - case 397: /* variable_list */ - case 398: /* retention_list */ - case 403: /* column_def_list */ - case 404: /* tags_def_opt */ - case 406: /* multi_create_clause */ - case 407: /* tags_def */ - case 408: /* multi_drop_clause */ - case 415: /* specific_cols_opt */ - case 416: /* tags_literal_list */ - case 418: /* col_name_list */ - case 421: /* duration_list */ - case 422: /* rollup_func_list */ - case 434: /* tag_list_opt */ - case 441: /* func_list */ - case 446: /* expression_list */ - case 462: /* col_list_opt */ - case 463: /* tag_def_or_ref_opt */ - case 466: /* column_stream_def_list */ - case 470: /* dnode_list */ - case 473: /* literal_list */ - case 481: /* star_func_para_list */ - case 483: /* other_para_list */ - case 485: /* when_then_list */ - case 510: /* hint_list */ - case 513: /* select_list */ - case 514: /* partition_by_clause_opt */ - case 519: /* group_by_clause_opt */ - case 522: /* partition_list */ - case 526: /* group_by_list */ - case 529: /* order_by_clause_opt */ - case 534: /* sort_specification_list */ + case 375: /* ip_range_list */ + case 376: /* white_list */ + case 377: /* white_list_opt */ + case 399: /* integer_list */ + case 400: /* variable_list */ + case 401: /* retention_list */ + case 406: /* column_def_list */ + case 407: /* tags_def_opt */ + case 409: /* multi_create_clause */ + case 410: /* tags_def */ + case 411: /* multi_drop_clause */ + case 418: /* specific_cols_opt */ + case 419: /* tags_literal_list */ + case 421: /* col_name_list */ + case 424: /* duration_list */ + case 425: /* rollup_func_list */ + case 437: /* tag_list_opt */ + case 444: /* func_list */ + case 452: /* expression_list */ + case 468: /* col_list_opt */ + case 469: /* tag_def_or_ref_opt */ + case 472: /* column_stream_def_list */ + case 476: /* dnode_list */ + case 479: /* literal_list */ + case 487: /* star_func_para_list */ + case 489: /* other_para_list */ + case 491: /* when_then_list */ + case 516: /* hint_list */ + case 519: /* select_list */ + case 520: /* partition_by_clause_opt */ + case 525: /* group_by_clause_opt */ + case 528: /* partition_list */ + case 532: /* group_by_list */ + case 535: /* order_by_clause_opt */ + case 540: /* sort_specification_list */ { - nodesDestroyList((yypminor->yy984)); +#line 85 "sql.y" + nodesDestroyList((yypminor->yy24)); +#line 3552 "sql.c" } break; - case 375: /* user_name */ - case 382: /* db_name */ - case 383: /* table_name */ - case 384: /* topic_name */ - case 386: /* dnode_endpoint */ - case 411: /* column_name */ - case 426: /* function_name */ - case 437: /* column_alias */ - case 440: /* index_name */ - case 445: /* sma_func_name */ - case 450: /* cgroup_name */ - case 457: /* language_opt */ - case 459: /* view_name */ - case 460: /* stream_name */ - case 469: /* on_vgroup_id */ - case 474: /* table_alias */ - case 480: /* star_func */ - case 482: /* noarg_func */ - case 500: /* alias_opt */ + case 378: /* user_name */ + case 385: /* db_name */ + case 386: /* table_name */ + case 387: /* topic_name */ + case 389: /* dnode_endpoint */ + case 414: /* column_name */ + case 429: /* function_name */ + case 440: /* column_alias */ + case 441: /* tsma_name */ + case 447: /* index_name */ + case 451: /* sma_func_name */ + case 456: /* cgroup_name */ + case 463: /* language_opt */ + case 465: /* view_name */ + case 466: /* stream_name */ + case 475: /* on_vgroup_id */ + case 480: /* table_alias */ + case 486: /* star_func */ + case 488: /* noarg_func */ + case 506: /* alias_opt */ { +#line 1053 "sql.y" +#line 3578 "sql.c" } break; - case 376: /* sysinfo_opt */ + case 379: /* sysinfo_opt */ { +#line 112 "sql.y" +#line 3585 "sql.c" } break; - case 377: /* privileges */ - case 380: /* priv_type_list */ - case 381: /* priv_type */ + case 380: /* privileges */ + case 383: /* priv_type_list */ + case 384: /* priv_type */ { +#line 121 "sql.y" +#line 3594 "sql.c" } break; - case 378: /* priv_level */ + case 381: /* priv_level */ { +#line 138 "sql.y" +#line 3601 "sql.c" } break; - case 387: /* force_opt */ - case 388: /* unsafe_opt */ - case 389: /* not_exists_opt */ - case 391: /* exists_opt */ - case 451: /* analyze_opt */ - case 454: /* or_replace_opt */ - case 455: /* agg_func_opt */ - case 465: /* ignore_opt */ - case 511: /* set_quantifier_opt */ - case 512: /* tag_mode_opt */ + case 390: /* force_opt */ + case 391: /* unsafe_opt */ + case 392: /* not_exists_opt */ + case 394: /* exists_opt */ + case 457: /* analyze_opt */ + case 460: /* or_replace_opt */ + case 461: /* agg_func_opt */ + case 471: /* ignore_opt */ + case 517: /* set_quantifier_opt */ + case 518: /* tag_mode_opt */ { +#line 167 "sql.y" +#line 3617 "sql.c" } break; - case 400: /* alter_db_option */ - case 423: /* alter_table_option */ + case 403: /* alter_db_option */ + case 426: /* alter_table_option */ { +#line 274 "sql.y" +#line 3625 "sql.c" } break; - case 412: /* type_name */ - case 420: /* type_name_default_len */ + case 415: /* type_name */ + case 423: /* type_name_default_len */ { +#line 401 "sql.y" +#line 3633 "sql.c" } break; - case 428: /* db_kind_opt */ - case 435: /* table_kind */ + case 431: /* db_kind_opt */ + case 438: /* table_kind */ { +#line 577 "sql.y" +#line 3641 "sql.c" } break; - case 429: /* table_kind_db_name_cond_opt */ + case 432: /* table_kind_db_name_cond_opt */ { +#line 542 "sql.y" +#line 3648 "sql.c" } break; - case 490: /* compare_op */ - case 491: /* in_op */ + case 442: /* tsma_func_list */ { - +#line 596 "sql.y" + nodesDestroyNode((yypminor->yy40)); +#line 3655 "sql.c" } break; - case 503: /* join_type */ + case 496: /* compare_op */ + case 497: /* in_op */ { +#line 1251 "sql.y" +#line 3663 "sql.c" } break; - case 504: /* join_subtype */ + case 509: /* join_type */ { +#line 1332 "sql.y" +#line 3670 "sql.c" } break; - case 525: /* fill_mode */ + case 510: /* join_subtype */ { +#line 1340 "sql.y" +#line 3677 "sql.c" } break; - case 536: /* ordering_specification_opt */ + case 531: /* fill_mode */ { +#line 1456 "sql.y" +#line 3684 "sql.c" } break; - case 537: /* null_ordering_opt */ + case 542: /* ordering_specification_opt */ { +#line 1541 "sql.y" +#line 3691 "sql.c" +} + break; + case 543: /* null_ordering_opt */ +{ +#line 1547 "sql.y" + +#line 3698 "sql.c" } break; /********* End destructor definitions *****************************************/ @@ -3407,7 +3862,7 @@ static YYACTIONTYPE yy_find_shift_action( #endif /* YYWILDCARD */ return yy_default[stateno]; }else{ - assert( i>=0 && i=0 && i<(int)(sizeof(yy_action)/sizeof(yy_action[0])) ); return yy_action[i]; } }while(1); @@ -3529,732 +3984,740 @@ static void yy_shift( /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side ** of that rule */ static const YYCODETYPE yyRuleInfoLhs[] = { - 367, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ - 367, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ - 368, /* (2) account_options ::= */ - 368, /* (3) account_options ::= account_options PPS literal */ - 368, /* (4) account_options ::= account_options TSERIES literal */ - 368, /* (5) account_options ::= account_options STORAGE literal */ - 368, /* (6) account_options ::= account_options STREAMS literal */ - 368, /* (7) account_options ::= account_options QTIME literal */ - 368, /* (8) account_options ::= account_options DBS literal */ - 368, /* (9) account_options ::= account_options USERS literal */ - 368, /* (10) account_options ::= account_options CONNS literal */ - 368, /* (11) account_options ::= account_options STATE literal */ - 369, /* (12) alter_account_options ::= alter_account_option */ - 369, /* (13) alter_account_options ::= alter_account_options alter_account_option */ - 371, /* (14) alter_account_option ::= PASS literal */ - 371, /* (15) alter_account_option ::= PPS literal */ - 371, /* (16) alter_account_option ::= TSERIES literal */ - 371, /* (17) alter_account_option ::= STORAGE literal */ - 371, /* (18) alter_account_option ::= STREAMS literal */ - 371, /* (19) alter_account_option ::= QTIME literal */ - 371, /* (20) alter_account_option ::= DBS literal */ - 371, /* (21) alter_account_option ::= USERS literal */ - 371, /* (22) alter_account_option ::= CONNS literal */ - 371, /* (23) alter_account_option ::= STATE literal */ - 372, /* (24) ip_range_list ::= NK_STRING */ - 372, /* (25) ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ - 373, /* (26) white_list ::= HOST ip_range_list */ - 374, /* (27) white_list_opt ::= */ - 374, /* (28) white_list_opt ::= white_list */ - 367, /* (29) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt white_list_opt */ - 367, /* (30) cmd ::= ALTER USER user_name PASS NK_STRING */ - 367, /* (31) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ - 367, /* (32) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ - 367, /* (33) cmd ::= ALTER USER user_name ADD white_list */ - 367, /* (34) cmd ::= ALTER USER user_name DROP white_list */ - 367, /* (35) cmd ::= DROP USER user_name */ - 376, /* (36) sysinfo_opt ::= */ - 376, /* (37) sysinfo_opt ::= SYSINFO NK_INTEGER */ - 367, /* (38) cmd ::= GRANT privileges ON priv_level with_opt TO user_name */ - 367, /* (39) cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ - 377, /* (40) privileges ::= ALL */ - 377, /* (41) privileges ::= priv_type_list */ - 377, /* (42) privileges ::= SUBSCRIBE */ - 380, /* (43) priv_type_list ::= priv_type */ - 380, /* (44) priv_type_list ::= priv_type_list NK_COMMA priv_type */ - 381, /* (45) priv_type ::= READ */ - 381, /* (46) priv_type ::= WRITE */ - 381, /* (47) priv_type ::= ALTER */ - 378, /* (48) priv_level ::= NK_STAR NK_DOT NK_STAR */ - 378, /* (49) priv_level ::= db_name NK_DOT NK_STAR */ - 378, /* (50) priv_level ::= db_name NK_DOT table_name */ - 378, /* (51) priv_level ::= topic_name */ - 379, /* (52) with_opt ::= */ - 379, /* (53) with_opt ::= WITH search_condition */ - 367, /* (54) cmd ::= CREATE DNODE dnode_endpoint */ - 367, /* (55) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ - 367, /* (56) cmd ::= DROP DNODE NK_INTEGER force_opt */ - 367, /* (57) cmd ::= DROP DNODE dnode_endpoint force_opt */ - 367, /* (58) cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ - 367, /* (59) cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ - 367, /* (60) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ - 367, /* (61) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ - 367, /* (62) cmd ::= ALTER ALL DNODES NK_STRING */ - 367, /* (63) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ - 367, /* (64) cmd ::= RESTORE DNODE NK_INTEGER */ - 386, /* (65) dnode_endpoint ::= NK_STRING */ - 386, /* (66) dnode_endpoint ::= NK_ID */ - 386, /* (67) dnode_endpoint ::= NK_IPTOKEN */ - 387, /* (68) force_opt ::= */ - 387, /* (69) force_opt ::= FORCE */ - 388, /* (70) unsafe_opt ::= UNSAFE */ - 367, /* (71) cmd ::= ALTER CLUSTER NK_STRING */ - 367, /* (72) cmd ::= ALTER CLUSTER NK_STRING NK_STRING */ - 367, /* (73) cmd ::= ALTER LOCAL NK_STRING */ - 367, /* (74) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ - 367, /* (75) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ - 367, /* (76) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ - 367, /* (77) cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ - 367, /* (78) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ - 367, /* (79) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ - 367, /* (80) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ - 367, /* (81) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ - 367, /* (82) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ - 367, /* (83) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ - 367, /* (84) cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ - 367, /* (85) cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ - 367, /* (86) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ - 367, /* (87) cmd ::= DROP DATABASE exists_opt db_name */ - 367, /* (88) cmd ::= USE db_name */ - 367, /* (89) cmd ::= ALTER DATABASE db_name alter_db_options */ - 367, /* (90) cmd ::= FLUSH DATABASE db_name */ - 367, /* (91) cmd ::= TRIM DATABASE db_name speed_opt */ - 367, /* (92) cmd ::= S3MIGRATE DATABASE db_name */ - 367, /* (93) cmd ::= COMPACT DATABASE db_name start_opt end_opt */ - 389, /* (94) not_exists_opt ::= IF NOT EXISTS */ - 389, /* (95) not_exists_opt ::= */ - 391, /* (96) exists_opt ::= IF EXISTS */ - 391, /* (97) exists_opt ::= */ - 390, /* (98) db_options ::= */ - 390, /* (99) db_options ::= db_options BUFFER NK_INTEGER */ - 390, /* (100) db_options ::= db_options CACHEMODEL NK_STRING */ - 390, /* (101) db_options ::= db_options CACHESIZE NK_INTEGER */ - 390, /* (102) db_options ::= db_options COMP NK_INTEGER */ - 390, /* (103) db_options ::= db_options DURATION NK_INTEGER */ - 390, /* (104) db_options ::= db_options DURATION NK_VARIABLE */ - 390, /* (105) db_options ::= db_options MAXROWS NK_INTEGER */ - 390, /* (106) db_options ::= db_options MINROWS NK_INTEGER */ - 390, /* (107) db_options ::= db_options KEEP integer_list */ - 390, /* (108) db_options ::= db_options KEEP variable_list */ - 390, /* (109) db_options ::= db_options PAGES NK_INTEGER */ - 390, /* (110) db_options ::= db_options PAGESIZE NK_INTEGER */ - 390, /* (111) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ - 390, /* (112) db_options ::= db_options PRECISION NK_STRING */ - 390, /* (113) db_options ::= db_options REPLICA NK_INTEGER */ - 390, /* (114) db_options ::= db_options VGROUPS NK_INTEGER */ - 390, /* (115) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ - 390, /* (116) db_options ::= db_options RETENTIONS retention_list */ - 390, /* (117) db_options ::= db_options SCHEMALESS NK_INTEGER */ - 390, /* (118) db_options ::= db_options WAL_LEVEL NK_INTEGER */ - 390, /* (119) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ - 390, /* (120) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ - 390, /* (121) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ - 390, /* (122) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ - 390, /* (123) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ - 390, /* (124) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ - 390, /* (125) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ - 390, /* (126) db_options ::= db_options STT_TRIGGER NK_INTEGER */ - 390, /* (127) db_options ::= db_options TABLE_PREFIX signed */ - 390, /* (128) db_options ::= db_options TABLE_SUFFIX signed */ - 390, /* (129) db_options ::= db_options S3_CHUNKSIZE NK_INTEGER */ - 390, /* (130) db_options ::= db_options S3_KEEPLOCAL NK_INTEGER */ - 390, /* (131) db_options ::= db_options S3_KEEPLOCAL NK_VARIABLE */ - 390, /* (132) db_options ::= db_options S3_COMPACT NK_INTEGER */ - 390, /* (133) db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ - 392, /* (134) alter_db_options ::= alter_db_option */ - 392, /* (135) alter_db_options ::= alter_db_options alter_db_option */ - 400, /* (136) alter_db_option ::= BUFFER NK_INTEGER */ - 400, /* (137) alter_db_option ::= CACHEMODEL NK_STRING */ - 400, /* (138) alter_db_option ::= CACHESIZE NK_INTEGER */ - 400, /* (139) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ - 400, /* (140) alter_db_option ::= KEEP integer_list */ - 400, /* (141) alter_db_option ::= KEEP variable_list */ - 400, /* (142) alter_db_option ::= PAGES NK_INTEGER */ - 400, /* (143) alter_db_option ::= REPLICA NK_INTEGER */ - 400, /* (144) alter_db_option ::= WAL_LEVEL NK_INTEGER */ - 400, /* (145) alter_db_option ::= STT_TRIGGER NK_INTEGER */ - 400, /* (146) alter_db_option ::= MINROWS NK_INTEGER */ - 400, /* (147) alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ - 400, /* (148) alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ - 400, /* (149) alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ - 400, /* (150) alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ - 400, /* (151) alter_db_option ::= S3_KEEPLOCAL NK_INTEGER */ - 400, /* (152) alter_db_option ::= S3_KEEPLOCAL NK_VARIABLE */ - 400, /* (153) alter_db_option ::= S3_COMPACT NK_INTEGER */ - 400, /* (154) alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ - 396, /* (155) integer_list ::= NK_INTEGER */ - 396, /* (156) integer_list ::= integer_list NK_COMMA NK_INTEGER */ - 397, /* (157) variable_list ::= NK_VARIABLE */ - 397, /* (158) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ - 398, /* (159) retention_list ::= retention */ - 398, /* (160) retention_list ::= retention_list NK_COMMA retention */ - 401, /* (161) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ - 401, /* (162) retention ::= NK_MINUS NK_COLON NK_VARIABLE */ - 393, /* (163) speed_opt ::= */ - 393, /* (164) speed_opt ::= BWLIMIT NK_INTEGER */ - 394, /* (165) start_opt ::= */ - 394, /* (166) start_opt ::= START WITH NK_INTEGER */ - 394, /* (167) start_opt ::= START WITH NK_STRING */ - 394, /* (168) start_opt ::= START WITH TIMESTAMP NK_STRING */ - 395, /* (169) end_opt ::= */ - 395, /* (170) end_opt ::= END WITH NK_INTEGER */ - 395, /* (171) end_opt ::= END WITH NK_STRING */ - 395, /* (172) end_opt ::= END WITH TIMESTAMP NK_STRING */ - 367, /* (173) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ - 367, /* (174) cmd ::= CREATE TABLE multi_create_clause */ - 367, /* (175) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ - 367, /* (176) cmd ::= DROP TABLE multi_drop_clause */ - 367, /* (177) cmd ::= DROP STABLE exists_opt full_table_name */ - 367, /* (178) cmd ::= ALTER TABLE alter_table_clause */ - 367, /* (179) cmd ::= ALTER STABLE alter_table_clause */ - 409, /* (180) alter_table_clause ::= full_table_name alter_table_options */ - 409, /* (181) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ - 409, /* (182) alter_table_clause ::= full_table_name DROP COLUMN column_name */ - 409, /* (183) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ - 409, /* (184) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - 409, /* (185) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - 409, /* (186) alter_table_clause ::= full_table_name DROP TAG column_name */ - 409, /* (187) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - 409, /* (188) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - 409, /* (189) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ tags_literal */ - 406, /* (190) multi_create_clause ::= create_subtable_clause */ - 406, /* (191) multi_create_clause ::= multi_create_clause create_subtable_clause */ - 414, /* (192) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP tags_literal_list NK_RP table_options */ - 408, /* (193) multi_drop_clause ::= drop_table_clause */ - 408, /* (194) multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ - 417, /* (195) drop_table_clause ::= exists_opt full_table_name */ - 415, /* (196) specific_cols_opt ::= */ - 415, /* (197) specific_cols_opt ::= NK_LP col_name_list NK_RP */ - 402, /* (198) full_table_name ::= table_name */ - 402, /* (199) full_table_name ::= db_name NK_DOT table_name */ - 403, /* (200) column_def_list ::= column_def */ - 403, /* (201) column_def_list ::= column_def_list NK_COMMA column_def */ - 419, /* (202) column_def ::= column_name type_name */ - 419, /* (203) column_def ::= column_name type_name PRIMARY KEY */ - 412, /* (204) type_name ::= BOOL */ - 412, /* (205) type_name ::= TINYINT */ - 412, /* (206) type_name ::= SMALLINT */ - 412, /* (207) type_name ::= INT */ - 412, /* (208) type_name ::= INTEGER */ - 412, /* (209) type_name ::= BIGINT */ - 412, /* (210) type_name ::= FLOAT */ - 412, /* (211) type_name ::= DOUBLE */ - 412, /* (212) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - 412, /* (213) type_name ::= TIMESTAMP */ - 412, /* (214) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - 412, /* (215) type_name ::= TINYINT UNSIGNED */ - 412, /* (216) type_name ::= SMALLINT UNSIGNED */ - 412, /* (217) type_name ::= INT UNSIGNED */ - 412, /* (218) type_name ::= BIGINT UNSIGNED */ - 412, /* (219) type_name ::= JSON */ - 412, /* (220) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - 412, /* (221) type_name ::= MEDIUMBLOB */ - 412, /* (222) type_name ::= BLOB */ - 412, /* (223) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - 412, /* (224) type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ - 412, /* (225) type_name ::= DECIMAL */ - 412, /* (226) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - 412, /* (227) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - 420, /* (228) type_name_default_len ::= BINARY */ - 420, /* (229) type_name_default_len ::= NCHAR */ - 420, /* (230) type_name_default_len ::= VARCHAR */ - 420, /* (231) type_name_default_len ::= VARBINARY */ - 404, /* (232) tags_def_opt ::= */ - 404, /* (233) tags_def_opt ::= tags_def */ - 407, /* (234) tags_def ::= TAGS NK_LP column_def_list NK_RP */ - 405, /* (235) table_options ::= */ - 405, /* (236) table_options ::= table_options COMMENT NK_STRING */ - 405, /* (237) table_options ::= table_options MAX_DELAY duration_list */ - 405, /* (238) table_options ::= table_options WATERMARK duration_list */ - 405, /* (239) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - 405, /* (240) table_options ::= table_options TTL NK_INTEGER */ - 405, /* (241) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - 405, /* (242) table_options ::= table_options DELETE_MARK duration_list */ - 410, /* (243) alter_table_options ::= alter_table_option */ - 410, /* (244) alter_table_options ::= alter_table_options alter_table_option */ - 423, /* (245) alter_table_option ::= COMMENT NK_STRING */ - 423, /* (246) alter_table_option ::= TTL NK_INTEGER */ - 421, /* (247) duration_list ::= duration_literal */ - 421, /* (248) duration_list ::= duration_list NK_COMMA duration_literal */ - 422, /* (249) rollup_func_list ::= rollup_func_name */ - 422, /* (250) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - 425, /* (251) rollup_func_name ::= function_name */ - 425, /* (252) rollup_func_name ::= FIRST */ - 425, /* (253) rollup_func_name ::= LAST */ - 418, /* (254) col_name_list ::= col_name */ - 418, /* (255) col_name_list ::= col_name_list NK_COMMA col_name */ - 427, /* (256) col_name ::= column_name */ - 367, /* (257) cmd ::= SHOW DNODES */ - 367, /* (258) cmd ::= SHOW USERS */ - 367, /* (259) cmd ::= SHOW USER PRIVILEGES */ - 367, /* (260) cmd ::= SHOW db_kind_opt DATABASES */ - 367, /* (261) cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ - 367, /* (262) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - 367, /* (263) cmd ::= SHOW db_name_cond_opt VGROUPS */ - 367, /* (264) cmd ::= SHOW MNODES */ - 367, /* (265) cmd ::= SHOW QNODES */ - 367, /* (266) cmd ::= SHOW ARBGROUPS */ - 367, /* (267) cmd ::= SHOW FUNCTIONS */ - 367, /* (268) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - 367, /* (269) cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ - 367, /* (270) cmd ::= SHOW STREAMS */ - 367, /* (271) cmd ::= SHOW ACCOUNTS */ - 367, /* (272) cmd ::= SHOW APPS */ - 367, /* (273) cmd ::= SHOW CONNECTIONS */ - 367, /* (274) cmd ::= SHOW LICENCES */ - 367, /* (275) cmd ::= SHOW GRANTS */ - 367, /* (276) cmd ::= SHOW GRANTS FULL */ - 367, /* (277) cmd ::= SHOW GRANTS LOGS */ - 367, /* (278) cmd ::= SHOW CLUSTER MACHINES */ - 367, /* (279) cmd ::= SHOW CREATE DATABASE db_name */ - 367, /* (280) cmd ::= SHOW CREATE TABLE full_table_name */ - 367, /* (281) cmd ::= SHOW CREATE STABLE full_table_name */ - 367, /* (282) cmd ::= SHOW QUERIES */ - 367, /* (283) cmd ::= SHOW SCORES */ - 367, /* (284) cmd ::= SHOW TOPICS */ - 367, /* (285) cmd ::= SHOW VARIABLES */ - 367, /* (286) cmd ::= SHOW CLUSTER VARIABLES */ - 367, /* (287) cmd ::= SHOW LOCAL VARIABLES */ - 367, /* (288) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ - 367, /* (289) cmd ::= SHOW BNODES */ - 367, /* (290) cmd ::= SHOW SNODES */ - 367, /* (291) cmd ::= SHOW CLUSTER */ - 367, /* (292) cmd ::= SHOW TRANSACTIONS */ - 367, /* (293) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - 367, /* (294) cmd ::= SHOW CONSUMERS */ - 367, /* (295) cmd ::= SHOW SUBSCRIPTIONS */ - 367, /* (296) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ - 367, /* (297) cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ - 367, /* (298) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ - 367, /* (299) cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ - 367, /* (300) cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ - 367, /* (301) cmd ::= SHOW VNODES */ - 367, /* (302) cmd ::= SHOW db_name_cond_opt ALIVE */ - 367, /* (303) cmd ::= SHOW CLUSTER ALIVE */ - 367, /* (304) cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ - 367, /* (305) cmd ::= SHOW CREATE VIEW full_table_name */ - 367, /* (306) cmd ::= SHOW COMPACTS */ - 367, /* (307) cmd ::= SHOW COMPACT NK_INTEGER */ - 429, /* (308) table_kind_db_name_cond_opt ::= */ - 429, /* (309) table_kind_db_name_cond_opt ::= table_kind */ - 429, /* (310) table_kind_db_name_cond_opt ::= db_name NK_DOT */ - 429, /* (311) table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ - 435, /* (312) table_kind ::= NORMAL */ - 435, /* (313) table_kind ::= CHILD */ - 431, /* (314) db_name_cond_opt ::= */ - 431, /* (315) db_name_cond_opt ::= db_name NK_DOT */ - 430, /* (316) like_pattern_opt ::= */ - 430, /* (317) like_pattern_opt ::= LIKE NK_STRING */ - 432, /* (318) table_name_cond ::= table_name */ - 433, /* (319) from_db_opt ::= */ - 433, /* (320) from_db_opt ::= FROM db_name */ - 434, /* (321) tag_list_opt ::= */ - 434, /* (322) tag_list_opt ::= tag_item */ - 434, /* (323) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ - 436, /* (324) tag_item ::= TBNAME */ - 436, /* (325) tag_item ::= QTAGS */ - 436, /* (326) tag_item ::= column_name */ - 436, /* (327) tag_item ::= column_name column_alias */ - 436, /* (328) tag_item ::= column_name AS column_alias */ - 428, /* (329) db_kind_opt ::= */ - 428, /* (330) db_kind_opt ::= USER */ - 428, /* (331) db_kind_opt ::= SYSTEM */ - 367, /* (332) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ - 367, /* (333) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ - 367, /* (334) cmd ::= DROP INDEX exists_opt full_index_name */ - 439, /* (335) full_index_name ::= index_name */ - 439, /* (336) full_index_name ::= db_name NK_DOT index_name */ - 438, /* (337) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - 438, /* (338) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ - 441, /* (339) func_list ::= func */ - 441, /* (340) func_list ::= func_list NK_COMMA func */ - 444, /* (341) func ::= sma_func_name NK_LP expression_list NK_RP */ - 445, /* (342) sma_func_name ::= function_name */ - 445, /* (343) sma_func_name ::= COUNT */ - 445, /* (344) sma_func_name ::= FIRST */ - 445, /* (345) sma_func_name ::= LAST */ - 445, /* (346) sma_func_name ::= LAST_ROW */ - 443, /* (347) sma_stream_opt ::= */ - 443, /* (348) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ - 443, /* (349) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ - 443, /* (350) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ - 447, /* (351) with_meta ::= AS */ - 447, /* (352) with_meta ::= WITH META AS */ - 447, /* (353) with_meta ::= ONLY META AS */ - 367, /* (354) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ - 367, /* (355) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ - 367, /* (356) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ - 367, /* (357) cmd ::= DROP TOPIC exists_opt topic_name */ - 367, /* (358) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - 367, /* (359) cmd ::= DESC full_table_name */ - 367, /* (360) cmd ::= DESCRIBE full_table_name */ - 367, /* (361) cmd ::= RESET QUERY CACHE */ - 367, /* (362) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - 367, /* (363) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ - 451, /* (364) analyze_opt ::= */ - 451, /* (365) analyze_opt ::= ANALYZE */ - 452, /* (366) explain_options ::= */ - 452, /* (367) explain_options ::= explain_options VERBOSE NK_BOOL */ - 452, /* (368) explain_options ::= explain_options RATIO NK_FLOAT */ - 367, /* (369) cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ - 367, /* (370) cmd ::= DROP FUNCTION exists_opt function_name */ - 455, /* (371) agg_func_opt ::= */ - 455, /* (372) agg_func_opt ::= AGGREGATE */ - 456, /* (373) bufsize_opt ::= */ - 456, /* (374) bufsize_opt ::= BUFSIZE NK_INTEGER */ - 457, /* (375) language_opt ::= */ - 457, /* (376) language_opt ::= LANGUAGE NK_STRING */ - 454, /* (377) or_replace_opt ::= */ - 454, /* (378) or_replace_opt ::= OR REPLACE */ - 367, /* (379) cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ - 367, /* (380) cmd ::= DROP VIEW exists_opt full_view_name */ - 458, /* (381) full_view_name ::= view_name */ - 458, /* (382) full_view_name ::= db_name NK_DOT view_name */ - 367, /* (383) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ - 367, /* (384) cmd ::= DROP STREAM exists_opt stream_name */ - 367, /* (385) cmd ::= PAUSE STREAM exists_opt stream_name */ - 367, /* (386) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ - 462, /* (387) col_list_opt ::= */ - 462, /* (388) col_list_opt ::= NK_LP column_stream_def_list NK_RP */ - 466, /* (389) column_stream_def_list ::= column_stream_def */ - 466, /* (390) column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def */ - 467, /* (391) column_stream_def ::= column_name */ - 467, /* (392) column_stream_def ::= column_name PRIMARY KEY */ - 463, /* (393) tag_def_or_ref_opt ::= */ - 463, /* (394) tag_def_or_ref_opt ::= tags_def */ - 463, /* (395) tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP */ - 461, /* (396) stream_options ::= */ - 461, /* (397) stream_options ::= stream_options TRIGGER AT_ONCE */ - 461, /* (398) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - 461, /* (399) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - 461, /* (400) stream_options ::= stream_options WATERMARK duration_literal */ - 461, /* (401) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ - 461, /* (402) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ - 461, /* (403) stream_options ::= stream_options DELETE_MARK duration_literal */ - 461, /* (404) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ - 464, /* (405) subtable_opt ::= */ - 464, /* (406) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - 465, /* (407) ignore_opt ::= */ - 465, /* (408) ignore_opt ::= IGNORE UNTREATED */ - 367, /* (409) cmd ::= KILL CONNECTION NK_INTEGER */ - 367, /* (410) cmd ::= KILL QUERY NK_STRING */ - 367, /* (411) cmd ::= KILL TRANSACTION NK_INTEGER */ - 367, /* (412) cmd ::= KILL COMPACT NK_INTEGER */ - 367, /* (413) cmd ::= BALANCE VGROUP */ - 367, /* (414) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ - 367, /* (415) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - 367, /* (416) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - 367, /* (417) cmd ::= SPLIT VGROUP NK_INTEGER */ - 469, /* (418) on_vgroup_id ::= */ - 469, /* (419) on_vgroup_id ::= ON NK_INTEGER */ - 470, /* (420) dnode_list ::= DNODE NK_INTEGER */ - 470, /* (421) dnode_list ::= dnode_list DNODE NK_INTEGER */ - 367, /* (422) cmd ::= DELETE FROM full_table_name where_clause_opt */ - 367, /* (423) cmd ::= query_or_subquery */ - 367, /* (424) cmd ::= insert_query */ - 453, /* (425) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ - 453, /* (426) insert_query ::= INSERT INTO full_table_name query_or_subquery */ - 413, /* (427) tags_literal ::= NK_INTEGER */ - 413, /* (428) tags_literal ::= NK_INTEGER NK_PLUS duration_literal */ - 413, /* (429) tags_literal ::= NK_INTEGER NK_MINUS duration_literal */ - 413, /* (430) tags_literal ::= NK_PLUS NK_INTEGER */ - 413, /* (431) tags_literal ::= NK_PLUS NK_INTEGER NK_PLUS duration_literal */ - 413, /* (432) tags_literal ::= NK_PLUS NK_INTEGER NK_MINUS duration_literal */ - 413, /* (433) tags_literal ::= NK_MINUS NK_INTEGER */ - 413, /* (434) tags_literal ::= NK_MINUS NK_INTEGER NK_PLUS duration_literal */ - 413, /* (435) tags_literal ::= NK_MINUS NK_INTEGER NK_MINUS duration_literal */ - 413, /* (436) tags_literal ::= NK_FLOAT */ - 413, /* (437) tags_literal ::= NK_PLUS NK_FLOAT */ - 413, /* (438) tags_literal ::= NK_MINUS NK_FLOAT */ - 413, /* (439) tags_literal ::= NK_BIN */ - 413, /* (440) tags_literal ::= NK_BIN NK_PLUS duration_literal */ - 413, /* (441) tags_literal ::= NK_BIN NK_MINUS duration_literal */ - 413, /* (442) tags_literal ::= NK_PLUS NK_BIN */ - 413, /* (443) tags_literal ::= NK_PLUS NK_BIN NK_PLUS duration_literal */ - 413, /* (444) tags_literal ::= NK_PLUS NK_BIN NK_MINUS duration_literal */ - 413, /* (445) tags_literal ::= NK_MINUS NK_BIN */ - 413, /* (446) tags_literal ::= NK_MINUS NK_BIN NK_PLUS duration_literal */ - 413, /* (447) tags_literal ::= NK_MINUS NK_BIN NK_MINUS duration_literal */ - 413, /* (448) tags_literal ::= NK_HEX */ - 413, /* (449) tags_literal ::= NK_HEX NK_PLUS duration_literal */ - 413, /* (450) tags_literal ::= NK_HEX NK_MINUS duration_literal */ - 413, /* (451) tags_literal ::= NK_PLUS NK_HEX */ - 413, /* (452) tags_literal ::= NK_PLUS NK_HEX NK_PLUS duration_literal */ - 413, /* (453) tags_literal ::= NK_PLUS NK_HEX NK_MINUS duration_literal */ - 413, /* (454) tags_literal ::= NK_MINUS NK_HEX */ - 413, /* (455) tags_literal ::= NK_MINUS NK_HEX NK_PLUS duration_literal */ - 413, /* (456) tags_literal ::= NK_MINUS NK_HEX NK_MINUS duration_literal */ - 413, /* (457) tags_literal ::= NK_STRING */ - 413, /* (458) tags_literal ::= NK_STRING NK_PLUS duration_literal */ - 413, /* (459) tags_literal ::= NK_STRING NK_MINUS duration_literal */ - 413, /* (460) tags_literal ::= NK_BOOL */ - 413, /* (461) tags_literal ::= NULL */ - 413, /* (462) tags_literal ::= literal_func */ - 413, /* (463) tags_literal ::= literal_func NK_PLUS duration_literal */ - 413, /* (464) tags_literal ::= literal_func NK_MINUS duration_literal */ - 416, /* (465) tags_literal_list ::= tags_literal */ - 416, /* (466) tags_literal_list ::= tags_literal_list NK_COMMA tags_literal */ - 370, /* (467) literal ::= NK_INTEGER */ - 370, /* (468) literal ::= NK_FLOAT */ - 370, /* (469) literal ::= NK_STRING */ - 370, /* (470) literal ::= NK_BOOL */ - 370, /* (471) literal ::= TIMESTAMP NK_STRING */ - 370, /* (472) literal ::= duration_literal */ - 370, /* (473) literal ::= NULL */ - 370, /* (474) literal ::= NK_QUESTION */ - 424, /* (475) duration_literal ::= NK_VARIABLE */ - 399, /* (476) signed ::= NK_INTEGER */ - 399, /* (477) signed ::= NK_PLUS NK_INTEGER */ - 399, /* (478) signed ::= NK_MINUS NK_INTEGER */ - 399, /* (479) signed ::= NK_FLOAT */ - 399, /* (480) signed ::= NK_PLUS NK_FLOAT */ - 399, /* (481) signed ::= NK_MINUS NK_FLOAT */ - 472, /* (482) signed_literal ::= signed */ - 472, /* (483) signed_literal ::= NK_STRING */ - 472, /* (484) signed_literal ::= NK_BOOL */ - 472, /* (485) signed_literal ::= TIMESTAMP NK_STRING */ - 472, /* (486) signed_literal ::= duration_literal */ - 472, /* (487) signed_literal ::= NULL */ - 472, /* (488) signed_literal ::= literal_func */ - 472, /* (489) signed_literal ::= NK_QUESTION */ - 473, /* (490) literal_list ::= signed_literal */ - 473, /* (491) literal_list ::= literal_list NK_COMMA signed_literal */ - 382, /* (492) db_name ::= NK_ID */ - 383, /* (493) table_name ::= NK_ID */ - 411, /* (494) column_name ::= NK_ID */ - 426, /* (495) function_name ::= NK_ID */ - 459, /* (496) view_name ::= NK_ID */ - 474, /* (497) table_alias ::= NK_ID */ - 437, /* (498) column_alias ::= NK_ID */ - 437, /* (499) column_alias ::= NK_ALIAS */ - 375, /* (500) user_name ::= NK_ID */ - 384, /* (501) topic_name ::= NK_ID */ - 460, /* (502) stream_name ::= NK_ID */ - 450, /* (503) cgroup_name ::= NK_ID */ - 440, /* (504) index_name ::= NK_ID */ - 475, /* (505) expr_or_subquery ::= expression */ - 468, /* (506) expression ::= literal */ - 468, /* (507) expression ::= pseudo_column */ - 468, /* (508) expression ::= column_reference */ - 468, /* (509) expression ::= function_expression */ - 468, /* (510) expression ::= case_when_expression */ - 468, /* (511) expression ::= NK_LP expression NK_RP */ - 468, /* (512) expression ::= NK_PLUS expr_or_subquery */ - 468, /* (513) expression ::= NK_MINUS expr_or_subquery */ - 468, /* (514) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ - 468, /* (515) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ - 468, /* (516) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ - 468, /* (517) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ - 468, /* (518) expression ::= expr_or_subquery NK_REM expr_or_subquery */ - 468, /* (519) expression ::= column_reference NK_ARROW NK_STRING */ - 468, /* (520) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ - 468, /* (521) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ - 446, /* (522) expression_list ::= expr_or_subquery */ - 446, /* (523) expression_list ::= expression_list NK_COMMA expr_or_subquery */ - 477, /* (524) column_reference ::= column_name */ - 477, /* (525) column_reference ::= table_name NK_DOT column_name */ - 477, /* (526) column_reference ::= NK_ALIAS */ - 477, /* (527) column_reference ::= table_name NK_DOT NK_ALIAS */ - 476, /* (528) pseudo_column ::= ROWTS */ - 476, /* (529) pseudo_column ::= TBNAME */ - 476, /* (530) pseudo_column ::= table_name NK_DOT TBNAME */ - 476, /* (531) pseudo_column ::= QSTART */ - 476, /* (532) pseudo_column ::= QEND */ - 476, /* (533) pseudo_column ::= QDURATION */ - 476, /* (534) pseudo_column ::= WSTART */ - 476, /* (535) pseudo_column ::= WEND */ - 476, /* (536) pseudo_column ::= WDURATION */ - 476, /* (537) pseudo_column ::= IROWTS */ - 476, /* (538) pseudo_column ::= ISFILLED */ - 476, /* (539) pseudo_column ::= QTAGS */ - 478, /* (540) function_expression ::= function_name NK_LP expression_list NK_RP */ - 478, /* (541) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - 478, /* (542) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - 478, /* (543) function_expression ::= CAST NK_LP expr_or_subquery AS type_name_default_len NK_RP */ - 478, /* (544) function_expression ::= literal_func */ - 471, /* (545) literal_func ::= noarg_func NK_LP NK_RP */ - 471, /* (546) literal_func ::= NOW */ - 471, /* (547) literal_func ::= TODAY */ - 482, /* (548) noarg_func ::= NOW */ - 482, /* (549) noarg_func ::= TODAY */ - 482, /* (550) noarg_func ::= TIMEZONE */ - 482, /* (551) noarg_func ::= DATABASE */ - 482, /* (552) noarg_func ::= CLIENT_VERSION */ - 482, /* (553) noarg_func ::= SERVER_VERSION */ - 482, /* (554) noarg_func ::= SERVER_STATUS */ - 482, /* (555) noarg_func ::= CURRENT_USER */ - 482, /* (556) noarg_func ::= USER */ - 480, /* (557) star_func ::= COUNT */ - 480, /* (558) star_func ::= FIRST */ - 480, /* (559) star_func ::= LAST */ - 480, /* (560) star_func ::= LAST_ROW */ - 481, /* (561) star_func_para_list ::= NK_STAR */ - 481, /* (562) star_func_para_list ::= other_para_list */ - 483, /* (563) other_para_list ::= star_func_para */ - 483, /* (564) other_para_list ::= other_para_list NK_COMMA star_func_para */ - 484, /* (565) star_func_para ::= expr_or_subquery */ - 484, /* (566) star_func_para ::= table_name NK_DOT NK_STAR */ - 479, /* (567) case_when_expression ::= CASE when_then_list case_when_else_opt END */ - 479, /* (568) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ - 485, /* (569) when_then_list ::= when_then_expr */ - 485, /* (570) when_then_list ::= when_then_list when_then_expr */ - 488, /* (571) when_then_expr ::= WHEN common_expression THEN common_expression */ - 486, /* (572) case_when_else_opt ::= */ - 486, /* (573) case_when_else_opt ::= ELSE common_expression */ - 489, /* (574) predicate ::= expr_or_subquery compare_op expr_or_subquery */ - 489, /* (575) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ - 489, /* (576) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ - 489, /* (577) predicate ::= expr_or_subquery IS NULL */ - 489, /* (578) predicate ::= expr_or_subquery IS NOT NULL */ - 489, /* (579) predicate ::= expr_or_subquery in_op in_predicate_value */ - 490, /* (580) compare_op ::= NK_LT */ - 490, /* (581) compare_op ::= NK_GT */ - 490, /* (582) compare_op ::= NK_LE */ - 490, /* (583) compare_op ::= NK_GE */ - 490, /* (584) compare_op ::= NK_NE */ - 490, /* (585) compare_op ::= NK_EQ */ - 490, /* (586) compare_op ::= LIKE */ - 490, /* (587) compare_op ::= NOT LIKE */ - 490, /* (588) compare_op ::= MATCH */ - 490, /* (589) compare_op ::= NMATCH */ - 490, /* (590) compare_op ::= CONTAINS */ - 491, /* (591) in_op ::= IN */ - 491, /* (592) in_op ::= NOT IN */ - 492, /* (593) in_predicate_value ::= NK_LP literal_list NK_RP */ - 493, /* (594) boolean_value_expression ::= boolean_primary */ - 493, /* (595) boolean_value_expression ::= NOT boolean_primary */ - 493, /* (596) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - 493, /* (597) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - 494, /* (598) boolean_primary ::= predicate */ - 494, /* (599) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - 487, /* (600) common_expression ::= expr_or_subquery */ - 487, /* (601) common_expression ::= boolean_value_expression */ - 495, /* (602) from_clause_opt ::= */ - 495, /* (603) from_clause_opt ::= FROM table_reference_list */ - 496, /* (604) table_reference_list ::= table_reference */ - 496, /* (605) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - 497, /* (606) table_reference ::= table_primary */ - 497, /* (607) table_reference ::= joined_table */ - 498, /* (608) table_primary ::= table_name alias_opt */ - 498, /* (609) table_primary ::= db_name NK_DOT table_name alias_opt */ - 498, /* (610) table_primary ::= subquery alias_opt */ - 498, /* (611) table_primary ::= parenthesized_joined_table */ - 500, /* (612) alias_opt ::= */ - 500, /* (613) alias_opt ::= table_alias */ - 500, /* (614) alias_opt ::= AS table_alias */ - 502, /* (615) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - 502, /* (616) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - 499, /* (617) joined_table ::= table_reference join_type join_subtype JOIN table_reference join_on_clause_opt window_offset_clause_opt jlimit_clause_opt */ - 503, /* (618) join_type ::= */ - 503, /* (619) join_type ::= INNER */ - 503, /* (620) join_type ::= LEFT */ - 503, /* (621) join_type ::= RIGHT */ - 503, /* (622) join_type ::= FULL */ - 504, /* (623) join_subtype ::= */ - 504, /* (624) join_subtype ::= OUTER */ - 504, /* (625) join_subtype ::= SEMI */ - 504, /* (626) join_subtype ::= ANTI */ - 504, /* (627) join_subtype ::= ASOF */ - 504, /* (628) join_subtype ::= WINDOW */ - 505, /* (629) join_on_clause_opt ::= */ - 505, /* (630) join_on_clause_opt ::= ON search_condition */ - 506, /* (631) window_offset_clause_opt ::= */ - 506, /* (632) window_offset_clause_opt ::= WINDOW_OFFSET NK_LP window_offset_literal NK_COMMA window_offset_literal NK_RP */ - 508, /* (633) window_offset_literal ::= NK_VARIABLE */ - 508, /* (634) window_offset_literal ::= NK_MINUS NK_VARIABLE */ - 507, /* (635) jlimit_clause_opt ::= */ - 507, /* (636) jlimit_clause_opt ::= JLIMIT NK_INTEGER */ - 509, /* (637) query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - 510, /* (638) hint_list ::= */ - 510, /* (639) hint_list ::= NK_HINT */ - 512, /* (640) tag_mode_opt ::= */ - 512, /* (641) tag_mode_opt ::= TAGS */ - 511, /* (642) set_quantifier_opt ::= */ - 511, /* (643) set_quantifier_opt ::= DISTINCT */ - 511, /* (644) set_quantifier_opt ::= ALL */ - 513, /* (645) select_list ::= select_item */ - 513, /* (646) select_list ::= select_list NK_COMMA select_item */ - 521, /* (647) select_item ::= NK_STAR */ - 521, /* (648) select_item ::= common_expression */ - 521, /* (649) select_item ::= common_expression column_alias */ - 521, /* (650) select_item ::= common_expression AS column_alias */ - 521, /* (651) select_item ::= table_name NK_DOT NK_STAR */ - 449, /* (652) where_clause_opt ::= */ - 449, /* (653) where_clause_opt ::= WHERE search_condition */ - 514, /* (654) partition_by_clause_opt ::= */ - 514, /* (655) partition_by_clause_opt ::= PARTITION BY partition_list */ - 522, /* (656) partition_list ::= partition_item */ - 522, /* (657) partition_list ::= partition_list NK_COMMA partition_item */ - 523, /* (658) partition_item ::= expr_or_subquery */ - 523, /* (659) partition_item ::= expr_or_subquery column_alias */ - 523, /* (660) partition_item ::= expr_or_subquery AS column_alias */ - 518, /* (661) twindow_clause_opt ::= */ - 518, /* (662) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ - 518, /* (663) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ - 518, /* (664) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - 518, /* (665) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - 518, /* (666) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ - 518, /* (667) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ - 518, /* (668) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - 442, /* (669) sliding_opt ::= */ - 442, /* (670) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ - 524, /* (671) interval_sliding_duration_literal ::= NK_VARIABLE */ - 524, /* (672) interval_sliding_duration_literal ::= NK_STRING */ - 524, /* (673) interval_sliding_duration_literal ::= NK_INTEGER */ - 517, /* (674) fill_opt ::= */ - 517, /* (675) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - 517, /* (676) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ - 517, /* (677) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ - 525, /* (678) fill_mode ::= NONE */ - 525, /* (679) fill_mode ::= PREV */ - 525, /* (680) fill_mode ::= NULL */ - 525, /* (681) fill_mode ::= NULL_F */ - 525, /* (682) fill_mode ::= LINEAR */ - 525, /* (683) fill_mode ::= NEXT */ - 519, /* (684) group_by_clause_opt ::= */ - 519, /* (685) group_by_clause_opt ::= GROUP BY group_by_list */ - 526, /* (686) group_by_list ::= expr_or_subquery */ - 526, /* (687) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ - 520, /* (688) having_clause_opt ::= */ - 520, /* (689) having_clause_opt ::= HAVING search_condition */ - 515, /* (690) range_opt ::= */ - 515, /* (691) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ - 515, /* (692) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ - 516, /* (693) every_opt ::= */ - 516, /* (694) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - 527, /* (695) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ - 528, /* (696) query_simple ::= query_specification */ - 528, /* (697) query_simple ::= union_query_expression */ - 532, /* (698) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ - 532, /* (699) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ - 533, /* (700) query_simple_or_subquery ::= query_simple */ - 533, /* (701) query_simple_or_subquery ::= subquery */ - 448, /* (702) query_or_subquery ::= query_expression */ - 448, /* (703) query_or_subquery ::= subquery */ - 529, /* (704) order_by_clause_opt ::= */ - 529, /* (705) order_by_clause_opt ::= ORDER BY sort_specification_list */ - 530, /* (706) slimit_clause_opt ::= */ - 530, /* (707) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - 530, /* (708) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - 530, /* (709) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 531, /* (710) limit_clause_opt ::= */ - 531, /* (711) limit_clause_opt ::= LIMIT NK_INTEGER */ - 531, /* (712) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - 531, /* (713) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 501, /* (714) subquery ::= NK_LP query_expression NK_RP */ - 501, /* (715) subquery ::= NK_LP subquery NK_RP */ - 385, /* (716) search_condition ::= common_expression */ - 534, /* (717) sort_specification_list ::= sort_specification */ - 534, /* (718) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - 535, /* (719) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ - 536, /* (720) ordering_specification_opt ::= */ - 536, /* (721) ordering_specification_opt ::= ASC */ - 536, /* (722) ordering_specification_opt ::= DESC */ - 537, /* (723) null_ordering_opt ::= */ - 537, /* (724) null_ordering_opt ::= NULLS FIRST */ - 537, /* (725) null_ordering_opt ::= NULLS LAST */ + 370, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + 370, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + 371, /* (2) account_options ::= */ + 371, /* (3) account_options ::= account_options PPS literal */ + 371, /* (4) account_options ::= account_options TSERIES literal */ + 371, /* (5) account_options ::= account_options STORAGE literal */ + 371, /* (6) account_options ::= account_options STREAMS literal */ + 371, /* (7) account_options ::= account_options QTIME literal */ + 371, /* (8) account_options ::= account_options DBS literal */ + 371, /* (9) account_options ::= account_options USERS literal */ + 371, /* (10) account_options ::= account_options CONNS literal */ + 371, /* (11) account_options ::= account_options STATE literal */ + 372, /* (12) alter_account_options ::= alter_account_option */ + 372, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + 374, /* (14) alter_account_option ::= PASS literal */ + 374, /* (15) alter_account_option ::= PPS literal */ + 374, /* (16) alter_account_option ::= TSERIES literal */ + 374, /* (17) alter_account_option ::= STORAGE literal */ + 374, /* (18) alter_account_option ::= STREAMS literal */ + 374, /* (19) alter_account_option ::= QTIME literal */ + 374, /* (20) alter_account_option ::= DBS literal */ + 374, /* (21) alter_account_option ::= USERS literal */ + 374, /* (22) alter_account_option ::= CONNS literal */ + 374, /* (23) alter_account_option ::= STATE literal */ + 375, /* (24) ip_range_list ::= NK_STRING */ + 375, /* (25) ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ + 376, /* (26) white_list ::= HOST ip_range_list */ + 377, /* (27) white_list_opt ::= */ + 377, /* (28) white_list_opt ::= white_list */ + 370, /* (29) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt white_list_opt */ + 370, /* (30) cmd ::= ALTER USER user_name PASS NK_STRING */ + 370, /* (31) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ + 370, /* (32) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ + 370, /* (33) cmd ::= ALTER USER user_name ADD white_list */ + 370, /* (34) cmd ::= ALTER USER user_name DROP white_list */ + 370, /* (35) cmd ::= DROP USER user_name */ + 379, /* (36) sysinfo_opt ::= */ + 379, /* (37) sysinfo_opt ::= SYSINFO NK_INTEGER */ + 370, /* (38) cmd ::= GRANT privileges ON priv_level with_opt TO user_name */ + 370, /* (39) cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ + 380, /* (40) privileges ::= ALL */ + 380, /* (41) privileges ::= priv_type_list */ + 380, /* (42) privileges ::= SUBSCRIBE */ + 383, /* (43) priv_type_list ::= priv_type */ + 383, /* (44) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + 384, /* (45) priv_type ::= READ */ + 384, /* (46) priv_type ::= WRITE */ + 384, /* (47) priv_type ::= ALTER */ + 381, /* (48) priv_level ::= NK_STAR NK_DOT NK_STAR */ + 381, /* (49) priv_level ::= db_name NK_DOT NK_STAR */ + 381, /* (50) priv_level ::= db_name NK_DOT table_name */ + 381, /* (51) priv_level ::= topic_name */ + 382, /* (52) with_opt ::= */ + 382, /* (53) with_opt ::= WITH search_condition */ + 370, /* (54) cmd ::= CREATE DNODE dnode_endpoint */ + 370, /* (55) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + 370, /* (56) cmd ::= DROP DNODE NK_INTEGER force_opt */ + 370, /* (57) cmd ::= DROP DNODE dnode_endpoint force_opt */ + 370, /* (58) cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ + 370, /* (59) cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ + 370, /* (60) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + 370, /* (61) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + 370, /* (62) cmd ::= ALTER ALL DNODES NK_STRING */ + 370, /* (63) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + 370, /* (64) cmd ::= RESTORE DNODE NK_INTEGER */ + 389, /* (65) dnode_endpoint ::= NK_STRING */ + 389, /* (66) dnode_endpoint ::= NK_ID */ + 389, /* (67) dnode_endpoint ::= NK_IPTOKEN */ + 390, /* (68) force_opt ::= */ + 390, /* (69) force_opt ::= FORCE */ + 391, /* (70) unsafe_opt ::= UNSAFE */ + 370, /* (71) cmd ::= ALTER CLUSTER NK_STRING */ + 370, /* (72) cmd ::= ALTER CLUSTER NK_STRING NK_STRING */ + 370, /* (73) cmd ::= ALTER LOCAL NK_STRING */ + 370, /* (74) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + 370, /* (75) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + 370, /* (76) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + 370, /* (77) cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ + 370, /* (78) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + 370, /* (79) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + 370, /* (80) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + 370, /* (81) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + 370, /* (82) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + 370, /* (83) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + 370, /* (84) cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ + 370, /* (85) cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ + 370, /* (86) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + 370, /* (87) cmd ::= DROP DATABASE exists_opt db_name */ + 370, /* (88) cmd ::= USE db_name */ + 370, /* (89) cmd ::= ALTER DATABASE db_name alter_db_options */ + 370, /* (90) cmd ::= FLUSH DATABASE db_name */ + 370, /* (91) cmd ::= TRIM DATABASE db_name speed_opt */ + 370, /* (92) cmd ::= S3MIGRATE DATABASE db_name */ + 370, /* (93) cmd ::= COMPACT DATABASE db_name start_opt end_opt */ + 392, /* (94) not_exists_opt ::= IF NOT EXISTS */ + 392, /* (95) not_exists_opt ::= */ + 394, /* (96) exists_opt ::= IF EXISTS */ + 394, /* (97) exists_opt ::= */ + 393, /* (98) db_options ::= */ + 393, /* (99) db_options ::= db_options BUFFER NK_INTEGER */ + 393, /* (100) db_options ::= db_options CACHEMODEL NK_STRING */ + 393, /* (101) db_options ::= db_options CACHESIZE NK_INTEGER */ + 393, /* (102) db_options ::= db_options COMP NK_INTEGER */ + 393, /* (103) db_options ::= db_options DURATION NK_INTEGER */ + 393, /* (104) db_options ::= db_options DURATION NK_VARIABLE */ + 393, /* (105) db_options ::= db_options MAXROWS NK_INTEGER */ + 393, /* (106) db_options ::= db_options MINROWS NK_INTEGER */ + 393, /* (107) db_options ::= db_options KEEP integer_list */ + 393, /* (108) db_options ::= db_options KEEP variable_list */ + 393, /* (109) db_options ::= db_options PAGES NK_INTEGER */ + 393, /* (110) db_options ::= db_options PAGESIZE NK_INTEGER */ + 393, /* (111) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ + 393, /* (112) db_options ::= db_options PRECISION NK_STRING */ + 393, /* (113) db_options ::= db_options REPLICA NK_INTEGER */ + 393, /* (114) db_options ::= db_options VGROUPS NK_INTEGER */ + 393, /* (115) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + 393, /* (116) db_options ::= db_options RETENTIONS retention_list */ + 393, /* (117) db_options ::= db_options SCHEMALESS NK_INTEGER */ + 393, /* (118) db_options ::= db_options WAL_LEVEL NK_INTEGER */ + 393, /* (119) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ + 393, /* (120) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ + 393, /* (121) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + 393, /* (122) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ + 393, /* (123) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + 393, /* (124) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ + 393, /* (125) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ + 393, /* (126) db_options ::= db_options STT_TRIGGER NK_INTEGER */ + 393, /* (127) db_options ::= db_options TABLE_PREFIX signed */ + 393, /* (128) db_options ::= db_options TABLE_SUFFIX signed */ + 393, /* (129) db_options ::= db_options S3_CHUNKSIZE NK_INTEGER */ + 393, /* (130) db_options ::= db_options S3_KEEPLOCAL NK_INTEGER */ + 393, /* (131) db_options ::= db_options S3_KEEPLOCAL NK_VARIABLE */ + 393, /* (132) db_options ::= db_options S3_COMPACT NK_INTEGER */ + 393, /* (133) db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ + 395, /* (134) alter_db_options ::= alter_db_option */ + 395, /* (135) alter_db_options ::= alter_db_options alter_db_option */ + 403, /* (136) alter_db_option ::= BUFFER NK_INTEGER */ + 403, /* (137) alter_db_option ::= CACHEMODEL NK_STRING */ + 403, /* (138) alter_db_option ::= CACHESIZE NK_INTEGER */ + 403, /* (139) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ + 403, /* (140) alter_db_option ::= KEEP integer_list */ + 403, /* (141) alter_db_option ::= KEEP variable_list */ + 403, /* (142) alter_db_option ::= PAGES NK_INTEGER */ + 403, /* (143) alter_db_option ::= REPLICA NK_INTEGER */ + 403, /* (144) alter_db_option ::= WAL_LEVEL NK_INTEGER */ + 403, /* (145) alter_db_option ::= STT_TRIGGER NK_INTEGER */ + 403, /* (146) alter_db_option ::= MINROWS NK_INTEGER */ + 403, /* (147) alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ + 403, /* (148) alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + 403, /* (149) alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ + 403, /* (150) alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + 403, /* (151) alter_db_option ::= S3_KEEPLOCAL NK_INTEGER */ + 403, /* (152) alter_db_option ::= S3_KEEPLOCAL NK_VARIABLE */ + 403, /* (153) alter_db_option ::= S3_COMPACT NK_INTEGER */ + 403, /* (154) alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ + 399, /* (155) integer_list ::= NK_INTEGER */ + 399, /* (156) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + 400, /* (157) variable_list ::= NK_VARIABLE */ + 400, /* (158) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + 401, /* (159) retention_list ::= retention */ + 401, /* (160) retention_list ::= retention_list NK_COMMA retention */ + 404, /* (161) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + 404, /* (162) retention ::= NK_MINUS NK_COLON NK_VARIABLE */ + 396, /* (163) speed_opt ::= */ + 396, /* (164) speed_opt ::= BWLIMIT NK_INTEGER */ + 397, /* (165) start_opt ::= */ + 397, /* (166) start_opt ::= START WITH NK_INTEGER */ + 397, /* (167) start_opt ::= START WITH NK_STRING */ + 397, /* (168) start_opt ::= START WITH TIMESTAMP NK_STRING */ + 398, /* (169) end_opt ::= */ + 398, /* (170) end_opt ::= END WITH NK_INTEGER */ + 398, /* (171) end_opt ::= END WITH NK_STRING */ + 398, /* (172) end_opt ::= END WITH TIMESTAMP NK_STRING */ + 370, /* (173) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + 370, /* (174) cmd ::= CREATE TABLE multi_create_clause */ + 370, /* (175) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + 370, /* (176) cmd ::= DROP TABLE multi_drop_clause */ + 370, /* (177) cmd ::= DROP STABLE exists_opt full_table_name */ + 370, /* (178) cmd ::= ALTER TABLE alter_table_clause */ + 370, /* (179) cmd ::= ALTER STABLE alter_table_clause */ + 412, /* (180) alter_table_clause ::= full_table_name alter_table_options */ + 412, /* (181) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + 412, /* (182) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + 412, /* (183) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + 412, /* (184) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + 412, /* (185) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + 412, /* (186) alter_table_clause ::= full_table_name DROP TAG column_name */ + 412, /* (187) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + 412, /* (188) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + 412, /* (189) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ tags_literal */ + 409, /* (190) multi_create_clause ::= create_subtable_clause */ + 409, /* (191) multi_create_clause ::= multi_create_clause create_subtable_clause */ + 417, /* (192) create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP tags_literal_list NK_RP table_options */ + 411, /* (193) multi_drop_clause ::= drop_table_clause */ + 411, /* (194) multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ + 420, /* (195) drop_table_clause ::= exists_opt full_table_name */ + 418, /* (196) specific_cols_opt ::= */ + 418, /* (197) specific_cols_opt ::= NK_LP col_name_list NK_RP */ + 405, /* (198) full_table_name ::= table_name */ + 405, /* (199) full_table_name ::= db_name NK_DOT table_name */ + 406, /* (200) column_def_list ::= column_def */ + 406, /* (201) column_def_list ::= column_def_list NK_COMMA column_def */ + 422, /* (202) column_def ::= column_name type_name */ + 422, /* (203) column_def ::= column_name type_name PRIMARY KEY */ + 415, /* (204) type_name ::= BOOL */ + 415, /* (205) type_name ::= TINYINT */ + 415, /* (206) type_name ::= SMALLINT */ + 415, /* (207) type_name ::= INT */ + 415, /* (208) type_name ::= INTEGER */ + 415, /* (209) type_name ::= BIGINT */ + 415, /* (210) type_name ::= FLOAT */ + 415, /* (211) type_name ::= DOUBLE */ + 415, /* (212) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + 415, /* (213) type_name ::= TIMESTAMP */ + 415, /* (214) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + 415, /* (215) type_name ::= TINYINT UNSIGNED */ + 415, /* (216) type_name ::= SMALLINT UNSIGNED */ + 415, /* (217) type_name ::= INT UNSIGNED */ + 415, /* (218) type_name ::= BIGINT UNSIGNED */ + 415, /* (219) type_name ::= JSON */ + 415, /* (220) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + 415, /* (221) type_name ::= MEDIUMBLOB */ + 415, /* (222) type_name ::= BLOB */ + 415, /* (223) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + 415, /* (224) type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ + 415, /* (225) type_name ::= DECIMAL */ + 415, /* (226) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + 415, /* (227) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + 423, /* (228) type_name_default_len ::= BINARY */ + 423, /* (229) type_name_default_len ::= NCHAR */ + 423, /* (230) type_name_default_len ::= VARCHAR */ + 423, /* (231) type_name_default_len ::= VARBINARY */ + 407, /* (232) tags_def_opt ::= */ + 407, /* (233) tags_def_opt ::= tags_def */ + 410, /* (234) tags_def ::= TAGS NK_LP column_def_list NK_RP */ + 408, /* (235) table_options ::= */ + 408, /* (236) table_options ::= table_options COMMENT NK_STRING */ + 408, /* (237) table_options ::= table_options MAX_DELAY duration_list */ + 408, /* (238) table_options ::= table_options WATERMARK duration_list */ + 408, /* (239) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + 408, /* (240) table_options ::= table_options TTL NK_INTEGER */ + 408, /* (241) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + 408, /* (242) table_options ::= table_options DELETE_MARK duration_list */ + 413, /* (243) alter_table_options ::= alter_table_option */ + 413, /* (244) alter_table_options ::= alter_table_options alter_table_option */ + 426, /* (245) alter_table_option ::= COMMENT NK_STRING */ + 426, /* (246) alter_table_option ::= TTL NK_INTEGER */ + 424, /* (247) duration_list ::= duration_literal */ + 424, /* (248) duration_list ::= duration_list NK_COMMA duration_literal */ + 425, /* (249) rollup_func_list ::= rollup_func_name */ + 425, /* (250) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + 428, /* (251) rollup_func_name ::= function_name */ + 428, /* (252) rollup_func_name ::= FIRST */ + 428, /* (253) rollup_func_name ::= LAST */ + 421, /* (254) col_name_list ::= col_name */ + 421, /* (255) col_name_list ::= col_name_list NK_COMMA col_name */ + 430, /* (256) col_name ::= column_name */ + 370, /* (257) cmd ::= SHOW DNODES */ + 370, /* (258) cmd ::= SHOW USERS */ + 370, /* (259) cmd ::= SHOW USER PRIVILEGES */ + 370, /* (260) cmd ::= SHOW db_kind_opt DATABASES */ + 370, /* (261) cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ + 370, /* (262) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + 370, /* (263) cmd ::= SHOW db_name_cond_opt VGROUPS */ + 370, /* (264) cmd ::= SHOW MNODES */ + 370, /* (265) cmd ::= SHOW QNODES */ + 370, /* (266) cmd ::= SHOW ARBGROUPS */ + 370, /* (267) cmd ::= SHOW FUNCTIONS */ + 370, /* (268) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + 370, /* (269) cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ + 370, /* (270) cmd ::= SHOW STREAMS */ + 370, /* (271) cmd ::= SHOW ACCOUNTS */ + 370, /* (272) cmd ::= SHOW APPS */ + 370, /* (273) cmd ::= SHOW CONNECTIONS */ + 370, /* (274) cmd ::= SHOW LICENCES */ + 370, /* (275) cmd ::= SHOW GRANTS */ + 370, /* (276) cmd ::= SHOW GRANTS FULL */ + 370, /* (277) cmd ::= SHOW GRANTS LOGS */ + 370, /* (278) cmd ::= SHOW CLUSTER MACHINES */ + 370, /* (279) cmd ::= SHOW CREATE DATABASE db_name */ + 370, /* (280) cmd ::= SHOW CREATE TABLE full_table_name */ + 370, /* (281) cmd ::= SHOW CREATE STABLE full_table_name */ + 370, /* (282) cmd ::= SHOW QUERIES */ + 370, /* (283) cmd ::= SHOW SCORES */ + 370, /* (284) cmd ::= SHOW TOPICS */ + 370, /* (285) cmd ::= SHOW VARIABLES */ + 370, /* (286) cmd ::= SHOW CLUSTER VARIABLES */ + 370, /* (287) cmd ::= SHOW LOCAL VARIABLES */ + 370, /* (288) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ + 370, /* (289) cmd ::= SHOW BNODES */ + 370, /* (290) cmd ::= SHOW SNODES */ + 370, /* (291) cmd ::= SHOW CLUSTER */ + 370, /* (292) cmd ::= SHOW TRANSACTIONS */ + 370, /* (293) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + 370, /* (294) cmd ::= SHOW CONSUMERS */ + 370, /* (295) cmd ::= SHOW SUBSCRIPTIONS */ + 370, /* (296) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ + 370, /* (297) cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ + 370, /* (298) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ + 370, /* (299) cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ + 370, /* (300) cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ + 370, /* (301) cmd ::= SHOW VNODES */ + 370, /* (302) cmd ::= SHOW db_name_cond_opt ALIVE */ + 370, /* (303) cmd ::= SHOW CLUSTER ALIVE */ + 370, /* (304) cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ + 370, /* (305) cmd ::= SHOW CREATE VIEW full_table_name */ + 370, /* (306) cmd ::= SHOW COMPACTS */ + 370, /* (307) cmd ::= SHOW COMPACT NK_INTEGER */ + 432, /* (308) table_kind_db_name_cond_opt ::= */ + 432, /* (309) table_kind_db_name_cond_opt ::= table_kind */ + 432, /* (310) table_kind_db_name_cond_opt ::= db_name NK_DOT */ + 432, /* (311) table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ + 438, /* (312) table_kind ::= NORMAL */ + 438, /* (313) table_kind ::= CHILD */ + 434, /* (314) db_name_cond_opt ::= */ + 434, /* (315) db_name_cond_opt ::= db_name NK_DOT */ + 433, /* (316) like_pattern_opt ::= */ + 433, /* (317) like_pattern_opt ::= LIKE NK_STRING */ + 435, /* (318) table_name_cond ::= table_name */ + 436, /* (319) from_db_opt ::= */ + 436, /* (320) from_db_opt ::= FROM db_name */ + 437, /* (321) tag_list_opt ::= */ + 437, /* (322) tag_list_opt ::= tag_item */ + 437, /* (323) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ + 439, /* (324) tag_item ::= TBNAME */ + 439, /* (325) tag_item ::= QTAGS */ + 439, /* (326) tag_item ::= column_name */ + 439, /* (327) tag_item ::= column_name column_alias */ + 439, /* (328) tag_item ::= column_name AS column_alias */ + 431, /* (329) db_kind_opt ::= */ + 431, /* (330) db_kind_opt ::= USER */ + 431, /* (331) db_kind_opt ::= SYSTEM */ + 370, /* (332) cmd ::= CREATE TSMA not_exists_opt tsma_name ON full_table_name tsma_func_list INTERVAL NK_LP duration_literal NK_RP */ + 370, /* (333) cmd ::= CREATE RECURSIVE TSMA not_exists_opt tsma_name ON full_table_name INTERVAL NK_LP duration_literal NK_RP */ + 370, /* (334) cmd ::= DROP TSMA exists_opt full_tsma_name */ + 370, /* (335) cmd ::= SHOW db_name_cond_opt TSMAS */ + 443, /* (336) full_tsma_name ::= tsma_name */ + 443, /* (337) full_tsma_name ::= db_name NK_DOT tsma_name */ + 442, /* (338) tsma_func_list ::= FUNCTION NK_LP func_list NK_RP */ + 370, /* (339) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ + 370, /* (340) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ + 370, /* (341) cmd ::= DROP INDEX exists_opt full_index_name */ + 446, /* (342) full_index_name ::= index_name */ + 446, /* (343) full_index_name ::= db_name NK_DOT index_name */ + 445, /* (344) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + 445, /* (345) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ + 444, /* (346) func_list ::= func */ + 444, /* (347) func_list ::= func_list NK_COMMA func */ + 450, /* (348) func ::= sma_func_name NK_LP expression_list NK_RP */ + 451, /* (349) sma_func_name ::= function_name */ + 451, /* (350) sma_func_name ::= COUNT */ + 451, /* (351) sma_func_name ::= FIRST */ + 451, /* (352) sma_func_name ::= LAST */ + 451, /* (353) sma_func_name ::= LAST_ROW */ + 449, /* (354) sma_stream_opt ::= */ + 449, /* (355) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ + 449, /* (356) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ + 449, /* (357) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ + 453, /* (358) with_meta ::= AS */ + 453, /* (359) with_meta ::= WITH META AS */ + 453, /* (360) with_meta ::= ONLY META AS */ + 370, /* (361) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + 370, /* (362) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ + 370, /* (363) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ + 370, /* (364) cmd ::= DROP TOPIC exists_opt topic_name */ + 370, /* (365) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + 370, /* (366) cmd ::= DESC full_table_name */ + 370, /* (367) cmd ::= DESCRIBE full_table_name */ + 370, /* (368) cmd ::= RESET QUERY CACHE */ + 370, /* (369) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + 370, /* (370) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ + 457, /* (371) analyze_opt ::= */ + 457, /* (372) analyze_opt ::= ANALYZE */ + 458, /* (373) explain_options ::= */ + 458, /* (374) explain_options ::= explain_options VERBOSE NK_BOOL */ + 458, /* (375) explain_options ::= explain_options RATIO NK_FLOAT */ + 370, /* (376) cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ + 370, /* (377) cmd ::= DROP FUNCTION exists_opt function_name */ + 461, /* (378) agg_func_opt ::= */ + 461, /* (379) agg_func_opt ::= AGGREGATE */ + 462, /* (380) bufsize_opt ::= */ + 462, /* (381) bufsize_opt ::= BUFSIZE NK_INTEGER */ + 463, /* (382) language_opt ::= */ + 463, /* (383) language_opt ::= LANGUAGE NK_STRING */ + 460, /* (384) or_replace_opt ::= */ + 460, /* (385) or_replace_opt ::= OR REPLACE */ + 370, /* (386) cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ + 370, /* (387) cmd ::= DROP VIEW exists_opt full_view_name */ + 464, /* (388) full_view_name ::= view_name */ + 464, /* (389) full_view_name ::= db_name NK_DOT view_name */ + 370, /* (390) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ + 370, /* (391) cmd ::= DROP STREAM exists_opt stream_name */ + 370, /* (392) cmd ::= PAUSE STREAM exists_opt stream_name */ + 370, /* (393) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ + 468, /* (394) col_list_opt ::= */ + 468, /* (395) col_list_opt ::= NK_LP column_stream_def_list NK_RP */ + 472, /* (396) column_stream_def_list ::= column_stream_def */ + 472, /* (397) column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def */ + 473, /* (398) column_stream_def ::= column_name */ + 473, /* (399) column_stream_def ::= column_name PRIMARY KEY */ + 469, /* (400) tag_def_or_ref_opt ::= */ + 469, /* (401) tag_def_or_ref_opt ::= tags_def */ + 469, /* (402) tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP */ + 467, /* (403) stream_options ::= */ + 467, /* (404) stream_options ::= stream_options TRIGGER AT_ONCE */ + 467, /* (405) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + 467, /* (406) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + 467, /* (407) stream_options ::= stream_options WATERMARK duration_literal */ + 467, /* (408) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + 467, /* (409) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ + 467, /* (410) stream_options ::= stream_options DELETE_MARK duration_literal */ + 467, /* (411) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ + 470, /* (412) subtable_opt ::= */ + 470, /* (413) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + 471, /* (414) ignore_opt ::= */ + 471, /* (415) ignore_opt ::= IGNORE UNTREATED */ + 370, /* (416) cmd ::= KILL CONNECTION NK_INTEGER */ + 370, /* (417) cmd ::= KILL QUERY NK_STRING */ + 370, /* (418) cmd ::= KILL TRANSACTION NK_INTEGER */ + 370, /* (419) cmd ::= KILL COMPACT NK_INTEGER */ + 370, /* (420) cmd ::= BALANCE VGROUP */ + 370, /* (421) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ + 370, /* (422) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + 370, /* (423) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + 370, /* (424) cmd ::= SPLIT VGROUP NK_INTEGER */ + 475, /* (425) on_vgroup_id ::= */ + 475, /* (426) on_vgroup_id ::= ON NK_INTEGER */ + 476, /* (427) dnode_list ::= DNODE NK_INTEGER */ + 476, /* (428) dnode_list ::= dnode_list DNODE NK_INTEGER */ + 370, /* (429) cmd ::= DELETE FROM full_table_name where_clause_opt */ + 370, /* (430) cmd ::= query_or_subquery */ + 370, /* (431) cmd ::= insert_query */ + 459, /* (432) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + 459, /* (433) insert_query ::= INSERT INTO full_table_name query_or_subquery */ + 416, /* (434) tags_literal ::= NK_INTEGER */ + 416, /* (435) tags_literal ::= NK_INTEGER NK_PLUS duration_literal */ + 416, /* (436) tags_literal ::= NK_INTEGER NK_MINUS duration_literal */ + 416, /* (437) tags_literal ::= NK_PLUS NK_INTEGER */ + 416, /* (438) tags_literal ::= NK_PLUS NK_INTEGER NK_PLUS duration_literal */ + 416, /* (439) tags_literal ::= NK_PLUS NK_INTEGER NK_MINUS duration_literal */ + 416, /* (440) tags_literal ::= NK_MINUS NK_INTEGER */ + 416, /* (441) tags_literal ::= NK_MINUS NK_INTEGER NK_PLUS duration_literal */ + 416, /* (442) tags_literal ::= NK_MINUS NK_INTEGER NK_MINUS duration_literal */ + 416, /* (443) tags_literal ::= NK_FLOAT */ + 416, /* (444) tags_literal ::= NK_PLUS NK_FLOAT */ + 416, /* (445) tags_literal ::= NK_MINUS NK_FLOAT */ + 416, /* (446) tags_literal ::= NK_BIN */ + 416, /* (447) tags_literal ::= NK_BIN NK_PLUS duration_literal */ + 416, /* (448) tags_literal ::= NK_BIN NK_MINUS duration_literal */ + 416, /* (449) tags_literal ::= NK_PLUS NK_BIN */ + 416, /* (450) tags_literal ::= NK_PLUS NK_BIN NK_PLUS duration_literal */ + 416, /* (451) tags_literal ::= NK_PLUS NK_BIN NK_MINUS duration_literal */ + 416, /* (452) tags_literal ::= NK_MINUS NK_BIN */ + 416, /* (453) tags_literal ::= NK_MINUS NK_BIN NK_PLUS duration_literal */ + 416, /* (454) tags_literal ::= NK_MINUS NK_BIN NK_MINUS duration_literal */ + 416, /* (455) tags_literal ::= NK_HEX */ + 416, /* (456) tags_literal ::= NK_HEX NK_PLUS duration_literal */ + 416, /* (457) tags_literal ::= NK_HEX NK_MINUS duration_literal */ + 416, /* (458) tags_literal ::= NK_PLUS NK_HEX */ + 416, /* (459) tags_literal ::= NK_PLUS NK_HEX NK_PLUS duration_literal */ + 416, /* (460) tags_literal ::= NK_PLUS NK_HEX NK_MINUS duration_literal */ + 416, /* (461) tags_literal ::= NK_MINUS NK_HEX */ + 416, /* (462) tags_literal ::= NK_MINUS NK_HEX NK_PLUS duration_literal */ + 416, /* (463) tags_literal ::= NK_MINUS NK_HEX NK_MINUS duration_literal */ + 416, /* (464) tags_literal ::= NK_STRING */ + 416, /* (465) tags_literal ::= NK_STRING NK_PLUS duration_literal */ + 416, /* (466) tags_literal ::= NK_STRING NK_MINUS duration_literal */ + 416, /* (467) tags_literal ::= NK_BOOL */ + 416, /* (468) tags_literal ::= NULL */ + 416, /* (469) tags_literal ::= literal_func */ + 416, /* (470) tags_literal ::= literal_func NK_PLUS duration_literal */ + 416, /* (471) tags_literal ::= literal_func NK_MINUS duration_literal */ + 419, /* (472) tags_literal_list ::= tags_literal */ + 419, /* (473) tags_literal_list ::= tags_literal_list NK_COMMA tags_literal */ + 373, /* (474) literal ::= NK_INTEGER */ + 373, /* (475) literal ::= NK_FLOAT */ + 373, /* (476) literal ::= NK_STRING */ + 373, /* (477) literal ::= NK_BOOL */ + 373, /* (478) literal ::= TIMESTAMP NK_STRING */ + 373, /* (479) literal ::= duration_literal */ + 373, /* (480) literal ::= NULL */ + 373, /* (481) literal ::= NK_QUESTION */ + 427, /* (482) duration_literal ::= NK_VARIABLE */ + 402, /* (483) signed ::= NK_INTEGER */ + 402, /* (484) signed ::= NK_PLUS NK_INTEGER */ + 402, /* (485) signed ::= NK_MINUS NK_INTEGER */ + 402, /* (486) signed ::= NK_FLOAT */ + 402, /* (487) signed ::= NK_PLUS NK_FLOAT */ + 402, /* (488) signed ::= NK_MINUS NK_FLOAT */ + 478, /* (489) signed_literal ::= signed */ + 478, /* (490) signed_literal ::= NK_STRING */ + 478, /* (491) signed_literal ::= NK_BOOL */ + 478, /* (492) signed_literal ::= TIMESTAMP NK_STRING */ + 478, /* (493) signed_literal ::= duration_literal */ + 478, /* (494) signed_literal ::= NULL */ + 478, /* (495) signed_literal ::= literal_func */ + 478, /* (496) signed_literal ::= NK_QUESTION */ + 479, /* (497) literal_list ::= signed_literal */ + 479, /* (498) literal_list ::= literal_list NK_COMMA signed_literal */ + 385, /* (499) db_name ::= NK_ID */ + 386, /* (500) table_name ::= NK_ID */ + 414, /* (501) column_name ::= NK_ID */ + 429, /* (502) function_name ::= NK_ID */ + 465, /* (503) view_name ::= NK_ID */ + 480, /* (504) table_alias ::= NK_ID */ + 440, /* (505) column_alias ::= NK_ID */ + 440, /* (506) column_alias ::= NK_ALIAS */ + 378, /* (507) user_name ::= NK_ID */ + 387, /* (508) topic_name ::= NK_ID */ + 466, /* (509) stream_name ::= NK_ID */ + 456, /* (510) cgroup_name ::= NK_ID */ + 447, /* (511) index_name ::= NK_ID */ + 441, /* (512) tsma_name ::= NK_ID */ + 481, /* (513) expr_or_subquery ::= expression */ + 474, /* (514) expression ::= literal */ + 474, /* (515) expression ::= pseudo_column */ + 474, /* (516) expression ::= column_reference */ + 474, /* (517) expression ::= function_expression */ + 474, /* (518) expression ::= case_when_expression */ + 474, /* (519) expression ::= NK_LP expression NK_RP */ + 474, /* (520) expression ::= NK_PLUS expr_or_subquery */ + 474, /* (521) expression ::= NK_MINUS expr_or_subquery */ + 474, /* (522) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + 474, /* (523) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + 474, /* (524) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + 474, /* (525) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + 474, /* (526) expression ::= expr_or_subquery NK_REM expr_or_subquery */ + 474, /* (527) expression ::= column_reference NK_ARROW NK_STRING */ + 474, /* (528) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + 474, /* (529) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + 452, /* (530) expression_list ::= expr_or_subquery */ + 452, /* (531) expression_list ::= expression_list NK_COMMA expr_or_subquery */ + 483, /* (532) column_reference ::= column_name */ + 483, /* (533) column_reference ::= table_name NK_DOT column_name */ + 483, /* (534) column_reference ::= NK_ALIAS */ + 483, /* (535) column_reference ::= table_name NK_DOT NK_ALIAS */ + 482, /* (536) pseudo_column ::= ROWTS */ + 482, /* (537) pseudo_column ::= TBNAME */ + 482, /* (538) pseudo_column ::= table_name NK_DOT TBNAME */ + 482, /* (539) pseudo_column ::= QSTART */ + 482, /* (540) pseudo_column ::= QEND */ + 482, /* (541) pseudo_column ::= QDURATION */ + 482, /* (542) pseudo_column ::= WSTART */ + 482, /* (543) pseudo_column ::= WEND */ + 482, /* (544) pseudo_column ::= WDURATION */ + 482, /* (545) pseudo_column ::= IROWTS */ + 482, /* (546) pseudo_column ::= ISFILLED */ + 482, /* (547) pseudo_column ::= QTAGS */ + 484, /* (548) function_expression ::= function_name NK_LP expression_list NK_RP */ + 484, /* (549) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + 484, /* (550) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + 484, /* (551) function_expression ::= CAST NK_LP expr_or_subquery AS type_name_default_len NK_RP */ + 484, /* (552) function_expression ::= literal_func */ + 477, /* (553) literal_func ::= noarg_func NK_LP NK_RP */ + 477, /* (554) literal_func ::= NOW */ + 477, /* (555) literal_func ::= TODAY */ + 488, /* (556) noarg_func ::= NOW */ + 488, /* (557) noarg_func ::= TODAY */ + 488, /* (558) noarg_func ::= TIMEZONE */ + 488, /* (559) noarg_func ::= DATABASE */ + 488, /* (560) noarg_func ::= CLIENT_VERSION */ + 488, /* (561) noarg_func ::= SERVER_VERSION */ + 488, /* (562) noarg_func ::= SERVER_STATUS */ + 488, /* (563) noarg_func ::= CURRENT_USER */ + 488, /* (564) noarg_func ::= USER */ + 486, /* (565) star_func ::= COUNT */ + 486, /* (566) star_func ::= FIRST */ + 486, /* (567) star_func ::= LAST */ + 486, /* (568) star_func ::= LAST_ROW */ + 487, /* (569) star_func_para_list ::= NK_STAR */ + 487, /* (570) star_func_para_list ::= other_para_list */ + 489, /* (571) other_para_list ::= star_func_para */ + 489, /* (572) other_para_list ::= other_para_list NK_COMMA star_func_para */ + 490, /* (573) star_func_para ::= expr_or_subquery */ + 490, /* (574) star_func_para ::= table_name NK_DOT NK_STAR */ + 485, /* (575) case_when_expression ::= CASE when_then_list case_when_else_opt END */ + 485, /* (576) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + 491, /* (577) when_then_list ::= when_then_expr */ + 491, /* (578) when_then_list ::= when_then_list when_then_expr */ + 494, /* (579) when_then_expr ::= WHEN common_expression THEN common_expression */ + 492, /* (580) case_when_else_opt ::= */ + 492, /* (581) case_when_else_opt ::= ELSE common_expression */ + 495, /* (582) predicate ::= expr_or_subquery compare_op expr_or_subquery */ + 495, /* (583) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + 495, /* (584) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + 495, /* (585) predicate ::= expr_or_subquery IS NULL */ + 495, /* (586) predicate ::= expr_or_subquery IS NOT NULL */ + 495, /* (587) predicate ::= expr_or_subquery in_op in_predicate_value */ + 496, /* (588) compare_op ::= NK_LT */ + 496, /* (589) compare_op ::= NK_GT */ + 496, /* (590) compare_op ::= NK_LE */ + 496, /* (591) compare_op ::= NK_GE */ + 496, /* (592) compare_op ::= NK_NE */ + 496, /* (593) compare_op ::= NK_EQ */ + 496, /* (594) compare_op ::= LIKE */ + 496, /* (595) compare_op ::= NOT LIKE */ + 496, /* (596) compare_op ::= MATCH */ + 496, /* (597) compare_op ::= NMATCH */ + 496, /* (598) compare_op ::= CONTAINS */ + 497, /* (599) in_op ::= IN */ + 497, /* (600) in_op ::= NOT IN */ + 498, /* (601) in_predicate_value ::= NK_LP literal_list NK_RP */ + 499, /* (602) boolean_value_expression ::= boolean_primary */ + 499, /* (603) boolean_value_expression ::= NOT boolean_primary */ + 499, /* (604) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + 499, /* (605) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + 500, /* (606) boolean_primary ::= predicate */ + 500, /* (607) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + 493, /* (608) common_expression ::= expr_or_subquery */ + 493, /* (609) common_expression ::= boolean_value_expression */ + 501, /* (610) from_clause_opt ::= */ + 501, /* (611) from_clause_opt ::= FROM table_reference_list */ + 502, /* (612) table_reference_list ::= table_reference */ + 502, /* (613) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + 503, /* (614) table_reference ::= table_primary */ + 503, /* (615) table_reference ::= joined_table */ + 504, /* (616) table_primary ::= table_name alias_opt */ + 504, /* (617) table_primary ::= db_name NK_DOT table_name alias_opt */ + 504, /* (618) table_primary ::= subquery alias_opt */ + 504, /* (619) table_primary ::= parenthesized_joined_table */ + 506, /* (620) alias_opt ::= */ + 506, /* (621) alias_opt ::= table_alias */ + 506, /* (622) alias_opt ::= AS table_alias */ + 508, /* (623) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + 508, /* (624) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + 505, /* (625) joined_table ::= table_reference join_type join_subtype JOIN table_reference join_on_clause_opt window_offset_clause_opt jlimit_clause_opt */ + 509, /* (626) join_type ::= */ + 509, /* (627) join_type ::= INNER */ + 509, /* (628) join_type ::= LEFT */ + 509, /* (629) join_type ::= RIGHT */ + 509, /* (630) join_type ::= FULL */ + 510, /* (631) join_subtype ::= */ + 510, /* (632) join_subtype ::= OUTER */ + 510, /* (633) join_subtype ::= SEMI */ + 510, /* (634) join_subtype ::= ANTI */ + 510, /* (635) join_subtype ::= ASOF */ + 510, /* (636) join_subtype ::= WINDOW */ + 511, /* (637) join_on_clause_opt ::= */ + 511, /* (638) join_on_clause_opt ::= ON search_condition */ + 512, /* (639) window_offset_clause_opt ::= */ + 512, /* (640) window_offset_clause_opt ::= WINDOW_OFFSET NK_LP window_offset_literal NK_COMMA window_offset_literal NK_RP */ + 514, /* (641) window_offset_literal ::= NK_VARIABLE */ + 514, /* (642) window_offset_literal ::= NK_MINUS NK_VARIABLE */ + 513, /* (643) jlimit_clause_opt ::= */ + 513, /* (644) jlimit_clause_opt ::= JLIMIT NK_INTEGER */ + 515, /* (645) query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + 516, /* (646) hint_list ::= */ + 516, /* (647) hint_list ::= NK_HINT */ + 518, /* (648) tag_mode_opt ::= */ + 518, /* (649) tag_mode_opt ::= TAGS */ + 517, /* (650) set_quantifier_opt ::= */ + 517, /* (651) set_quantifier_opt ::= DISTINCT */ + 517, /* (652) set_quantifier_opt ::= ALL */ + 519, /* (653) select_list ::= select_item */ + 519, /* (654) select_list ::= select_list NK_COMMA select_item */ + 527, /* (655) select_item ::= NK_STAR */ + 527, /* (656) select_item ::= common_expression */ + 527, /* (657) select_item ::= common_expression column_alias */ + 527, /* (658) select_item ::= common_expression AS column_alias */ + 527, /* (659) select_item ::= table_name NK_DOT NK_STAR */ + 455, /* (660) where_clause_opt ::= */ + 455, /* (661) where_clause_opt ::= WHERE search_condition */ + 520, /* (662) partition_by_clause_opt ::= */ + 520, /* (663) partition_by_clause_opt ::= PARTITION BY partition_list */ + 528, /* (664) partition_list ::= partition_item */ + 528, /* (665) partition_list ::= partition_list NK_COMMA partition_item */ + 529, /* (666) partition_item ::= expr_or_subquery */ + 529, /* (667) partition_item ::= expr_or_subquery column_alias */ + 529, /* (668) partition_item ::= expr_or_subquery AS column_alias */ + 524, /* (669) twindow_clause_opt ::= */ + 524, /* (670) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ + 524, /* (671) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + 524, /* (672) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + 524, /* (673) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + 524, /* (674) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ + 524, /* (675) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ + 524, /* (676) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + 448, /* (677) sliding_opt ::= */ + 448, /* (678) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ + 530, /* (679) interval_sliding_duration_literal ::= NK_VARIABLE */ + 530, /* (680) interval_sliding_duration_literal ::= NK_STRING */ + 530, /* (681) interval_sliding_duration_literal ::= NK_INTEGER */ + 523, /* (682) fill_opt ::= */ + 523, /* (683) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + 523, /* (684) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ + 523, /* (685) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ + 531, /* (686) fill_mode ::= NONE */ + 531, /* (687) fill_mode ::= PREV */ + 531, /* (688) fill_mode ::= NULL */ + 531, /* (689) fill_mode ::= NULL_F */ + 531, /* (690) fill_mode ::= LINEAR */ + 531, /* (691) fill_mode ::= NEXT */ + 525, /* (692) group_by_clause_opt ::= */ + 525, /* (693) group_by_clause_opt ::= GROUP BY group_by_list */ + 532, /* (694) group_by_list ::= expr_or_subquery */ + 532, /* (695) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + 526, /* (696) having_clause_opt ::= */ + 526, /* (697) having_clause_opt ::= HAVING search_condition */ + 521, /* (698) range_opt ::= */ + 521, /* (699) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + 521, /* (700) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ + 522, /* (701) every_opt ::= */ + 522, /* (702) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + 533, /* (703) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + 534, /* (704) query_simple ::= query_specification */ + 534, /* (705) query_simple ::= union_query_expression */ + 538, /* (706) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + 538, /* (707) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + 539, /* (708) query_simple_or_subquery ::= query_simple */ + 539, /* (709) query_simple_or_subquery ::= subquery */ + 454, /* (710) query_or_subquery ::= query_expression */ + 454, /* (711) query_or_subquery ::= subquery */ + 535, /* (712) order_by_clause_opt ::= */ + 535, /* (713) order_by_clause_opt ::= ORDER BY sort_specification_list */ + 536, /* (714) slimit_clause_opt ::= */ + 536, /* (715) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + 536, /* (716) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + 536, /* (717) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 537, /* (718) limit_clause_opt ::= */ + 537, /* (719) limit_clause_opt ::= LIMIT NK_INTEGER */ + 537, /* (720) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + 537, /* (721) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 507, /* (722) subquery ::= NK_LP query_expression NK_RP */ + 507, /* (723) subquery ::= NK_LP subquery NK_RP */ + 388, /* (724) search_condition ::= common_expression */ + 540, /* (725) sort_specification_list ::= sort_specification */ + 540, /* (726) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + 541, /* (727) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + 542, /* (728) ordering_specification_opt ::= */ + 542, /* (729) ordering_specification_opt ::= ASC */ + 542, /* (730) ordering_specification_opt ::= DESC */ + 543, /* (731) null_ordering_opt ::= */ + 543, /* (732) null_ordering_opt ::= NULLS FIRST */ + 543, /* (733) null_ordering_opt ::= NULLS LAST */ }; /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number @@ -4592,400 +5055,408 @@ static const signed char yyRuleInfoNRhs[] = { 0, /* (329) db_kind_opt ::= */ -1, /* (330) db_kind_opt ::= USER */ -1, /* (331) db_kind_opt ::= SYSTEM */ - -8, /* (332) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ - -9, /* (333) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ - -4, /* (334) cmd ::= DROP INDEX exists_opt full_index_name */ - -1, /* (335) full_index_name ::= index_name */ - -3, /* (336) full_index_name ::= db_name NK_DOT index_name */ - -10, /* (337) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - -12, /* (338) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ - -1, /* (339) func_list ::= func */ - -3, /* (340) func_list ::= func_list NK_COMMA func */ - -4, /* (341) func ::= sma_func_name NK_LP expression_list NK_RP */ - -1, /* (342) sma_func_name ::= function_name */ - -1, /* (343) sma_func_name ::= COUNT */ - -1, /* (344) sma_func_name ::= FIRST */ - -1, /* (345) sma_func_name ::= LAST */ - -1, /* (346) sma_func_name ::= LAST_ROW */ - 0, /* (347) sma_stream_opt ::= */ - -3, /* (348) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ - -3, /* (349) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ - -3, /* (350) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ - -1, /* (351) with_meta ::= AS */ - -3, /* (352) with_meta ::= WITH META AS */ - -3, /* (353) with_meta ::= ONLY META AS */ - -6, /* (354) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ - -7, /* (355) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ - -8, /* (356) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ - -4, /* (357) cmd ::= DROP TOPIC exists_opt topic_name */ - -7, /* (358) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - -2, /* (359) cmd ::= DESC full_table_name */ - -2, /* (360) cmd ::= DESCRIBE full_table_name */ - -3, /* (361) cmd ::= RESET QUERY CACHE */ - -4, /* (362) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - -4, /* (363) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ - 0, /* (364) analyze_opt ::= */ - -1, /* (365) analyze_opt ::= ANALYZE */ - 0, /* (366) explain_options ::= */ - -3, /* (367) explain_options ::= explain_options VERBOSE NK_BOOL */ - -3, /* (368) explain_options ::= explain_options RATIO NK_FLOAT */ - -12, /* (369) cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ - -4, /* (370) cmd ::= DROP FUNCTION exists_opt function_name */ - 0, /* (371) agg_func_opt ::= */ - -1, /* (372) agg_func_opt ::= AGGREGATE */ - 0, /* (373) bufsize_opt ::= */ - -2, /* (374) bufsize_opt ::= BUFSIZE NK_INTEGER */ - 0, /* (375) language_opt ::= */ - -2, /* (376) language_opt ::= LANGUAGE NK_STRING */ - 0, /* (377) or_replace_opt ::= */ - -2, /* (378) or_replace_opt ::= OR REPLACE */ - -6, /* (379) cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ - -4, /* (380) cmd ::= DROP VIEW exists_opt full_view_name */ - -1, /* (381) full_view_name ::= view_name */ - -3, /* (382) full_view_name ::= db_name NK_DOT view_name */ - -12, /* (383) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ - -4, /* (384) cmd ::= DROP STREAM exists_opt stream_name */ - -4, /* (385) cmd ::= PAUSE STREAM exists_opt stream_name */ - -5, /* (386) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ - 0, /* (387) col_list_opt ::= */ - -3, /* (388) col_list_opt ::= NK_LP column_stream_def_list NK_RP */ - -1, /* (389) column_stream_def_list ::= column_stream_def */ - -3, /* (390) column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def */ - -1, /* (391) column_stream_def ::= column_name */ - -3, /* (392) column_stream_def ::= column_name PRIMARY KEY */ - 0, /* (393) tag_def_or_ref_opt ::= */ - -1, /* (394) tag_def_or_ref_opt ::= tags_def */ - -4, /* (395) tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP */ - 0, /* (396) stream_options ::= */ - -3, /* (397) stream_options ::= stream_options TRIGGER AT_ONCE */ - -3, /* (398) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - -4, /* (399) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - -3, /* (400) stream_options ::= stream_options WATERMARK duration_literal */ - -4, /* (401) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ - -3, /* (402) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ - -3, /* (403) stream_options ::= stream_options DELETE_MARK duration_literal */ - -4, /* (404) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ - 0, /* (405) subtable_opt ::= */ - -4, /* (406) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - 0, /* (407) ignore_opt ::= */ - -2, /* (408) ignore_opt ::= IGNORE UNTREATED */ - -3, /* (409) cmd ::= KILL CONNECTION NK_INTEGER */ - -3, /* (410) cmd ::= KILL QUERY NK_STRING */ - -3, /* (411) cmd ::= KILL TRANSACTION NK_INTEGER */ - -3, /* (412) cmd ::= KILL COMPACT NK_INTEGER */ - -2, /* (413) cmd ::= BALANCE VGROUP */ - -4, /* (414) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ - -4, /* (415) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - -4, /* (416) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - -3, /* (417) cmd ::= SPLIT VGROUP NK_INTEGER */ - 0, /* (418) on_vgroup_id ::= */ - -2, /* (419) on_vgroup_id ::= ON NK_INTEGER */ - -2, /* (420) dnode_list ::= DNODE NK_INTEGER */ - -3, /* (421) dnode_list ::= dnode_list DNODE NK_INTEGER */ - -4, /* (422) cmd ::= DELETE FROM full_table_name where_clause_opt */ - -1, /* (423) cmd ::= query_or_subquery */ - -1, /* (424) cmd ::= insert_query */ - -7, /* (425) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ - -4, /* (426) insert_query ::= INSERT INTO full_table_name query_or_subquery */ - -1, /* (427) tags_literal ::= NK_INTEGER */ - -3, /* (428) tags_literal ::= NK_INTEGER NK_PLUS duration_literal */ - -3, /* (429) tags_literal ::= NK_INTEGER NK_MINUS duration_literal */ - -2, /* (430) tags_literal ::= NK_PLUS NK_INTEGER */ - -4, /* (431) tags_literal ::= NK_PLUS NK_INTEGER NK_PLUS duration_literal */ - -4, /* (432) tags_literal ::= NK_PLUS NK_INTEGER NK_MINUS duration_literal */ - -2, /* (433) tags_literal ::= NK_MINUS NK_INTEGER */ - -4, /* (434) tags_literal ::= NK_MINUS NK_INTEGER NK_PLUS duration_literal */ - -4, /* (435) tags_literal ::= NK_MINUS NK_INTEGER NK_MINUS duration_literal */ - -1, /* (436) tags_literal ::= NK_FLOAT */ - -2, /* (437) tags_literal ::= NK_PLUS NK_FLOAT */ - -2, /* (438) tags_literal ::= NK_MINUS NK_FLOAT */ - -1, /* (439) tags_literal ::= NK_BIN */ - -3, /* (440) tags_literal ::= NK_BIN NK_PLUS duration_literal */ - -3, /* (441) tags_literal ::= NK_BIN NK_MINUS duration_literal */ - -2, /* (442) tags_literal ::= NK_PLUS NK_BIN */ - -4, /* (443) tags_literal ::= NK_PLUS NK_BIN NK_PLUS duration_literal */ - -4, /* (444) tags_literal ::= NK_PLUS NK_BIN NK_MINUS duration_literal */ - -2, /* (445) tags_literal ::= NK_MINUS NK_BIN */ - -4, /* (446) tags_literal ::= NK_MINUS NK_BIN NK_PLUS duration_literal */ - -4, /* (447) tags_literal ::= NK_MINUS NK_BIN NK_MINUS duration_literal */ - -1, /* (448) tags_literal ::= NK_HEX */ - -3, /* (449) tags_literal ::= NK_HEX NK_PLUS duration_literal */ - -3, /* (450) tags_literal ::= NK_HEX NK_MINUS duration_literal */ - -2, /* (451) tags_literal ::= NK_PLUS NK_HEX */ - -4, /* (452) tags_literal ::= NK_PLUS NK_HEX NK_PLUS duration_literal */ - -4, /* (453) tags_literal ::= NK_PLUS NK_HEX NK_MINUS duration_literal */ - -2, /* (454) tags_literal ::= NK_MINUS NK_HEX */ - -4, /* (455) tags_literal ::= NK_MINUS NK_HEX NK_PLUS duration_literal */ - -4, /* (456) tags_literal ::= NK_MINUS NK_HEX NK_MINUS duration_literal */ - -1, /* (457) tags_literal ::= NK_STRING */ - -3, /* (458) tags_literal ::= NK_STRING NK_PLUS duration_literal */ - -3, /* (459) tags_literal ::= NK_STRING NK_MINUS duration_literal */ - -1, /* (460) tags_literal ::= NK_BOOL */ - -1, /* (461) tags_literal ::= NULL */ - -1, /* (462) tags_literal ::= literal_func */ - -3, /* (463) tags_literal ::= literal_func NK_PLUS duration_literal */ - -3, /* (464) tags_literal ::= literal_func NK_MINUS duration_literal */ - -1, /* (465) tags_literal_list ::= tags_literal */ - -3, /* (466) tags_literal_list ::= tags_literal_list NK_COMMA tags_literal */ - -1, /* (467) literal ::= NK_INTEGER */ - -1, /* (468) literal ::= NK_FLOAT */ - -1, /* (469) literal ::= NK_STRING */ - -1, /* (470) literal ::= NK_BOOL */ - -2, /* (471) literal ::= TIMESTAMP NK_STRING */ - -1, /* (472) literal ::= duration_literal */ - -1, /* (473) literal ::= NULL */ - -1, /* (474) literal ::= NK_QUESTION */ - -1, /* (475) duration_literal ::= NK_VARIABLE */ - -1, /* (476) signed ::= NK_INTEGER */ - -2, /* (477) signed ::= NK_PLUS NK_INTEGER */ - -2, /* (478) signed ::= NK_MINUS NK_INTEGER */ - -1, /* (479) signed ::= NK_FLOAT */ - -2, /* (480) signed ::= NK_PLUS NK_FLOAT */ - -2, /* (481) signed ::= NK_MINUS NK_FLOAT */ - -1, /* (482) signed_literal ::= signed */ - -1, /* (483) signed_literal ::= NK_STRING */ - -1, /* (484) signed_literal ::= NK_BOOL */ - -2, /* (485) signed_literal ::= TIMESTAMP NK_STRING */ - -1, /* (486) signed_literal ::= duration_literal */ - -1, /* (487) signed_literal ::= NULL */ - -1, /* (488) signed_literal ::= literal_func */ - -1, /* (489) signed_literal ::= NK_QUESTION */ - -1, /* (490) literal_list ::= signed_literal */ - -3, /* (491) literal_list ::= literal_list NK_COMMA signed_literal */ - -1, /* (492) db_name ::= NK_ID */ - -1, /* (493) table_name ::= NK_ID */ - -1, /* (494) column_name ::= NK_ID */ - -1, /* (495) function_name ::= NK_ID */ - -1, /* (496) view_name ::= NK_ID */ - -1, /* (497) table_alias ::= NK_ID */ - -1, /* (498) column_alias ::= NK_ID */ - -1, /* (499) column_alias ::= NK_ALIAS */ - -1, /* (500) user_name ::= NK_ID */ - -1, /* (501) topic_name ::= NK_ID */ - -1, /* (502) stream_name ::= NK_ID */ - -1, /* (503) cgroup_name ::= NK_ID */ - -1, /* (504) index_name ::= NK_ID */ - -1, /* (505) expr_or_subquery ::= expression */ - -1, /* (506) expression ::= literal */ - -1, /* (507) expression ::= pseudo_column */ - -1, /* (508) expression ::= column_reference */ - -1, /* (509) expression ::= function_expression */ - -1, /* (510) expression ::= case_when_expression */ - -3, /* (511) expression ::= NK_LP expression NK_RP */ - -2, /* (512) expression ::= NK_PLUS expr_or_subquery */ - -2, /* (513) expression ::= NK_MINUS expr_or_subquery */ - -3, /* (514) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ - -3, /* (515) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ - -3, /* (516) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ - -3, /* (517) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ - -3, /* (518) expression ::= expr_or_subquery NK_REM expr_or_subquery */ - -3, /* (519) expression ::= column_reference NK_ARROW NK_STRING */ - -3, /* (520) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ - -3, /* (521) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ - -1, /* (522) expression_list ::= expr_or_subquery */ - -3, /* (523) expression_list ::= expression_list NK_COMMA expr_or_subquery */ - -1, /* (524) column_reference ::= column_name */ - -3, /* (525) column_reference ::= table_name NK_DOT column_name */ - -1, /* (526) column_reference ::= NK_ALIAS */ - -3, /* (527) column_reference ::= table_name NK_DOT NK_ALIAS */ - -1, /* (528) pseudo_column ::= ROWTS */ - -1, /* (529) pseudo_column ::= TBNAME */ - -3, /* (530) pseudo_column ::= table_name NK_DOT TBNAME */ - -1, /* (531) pseudo_column ::= QSTART */ - -1, /* (532) pseudo_column ::= QEND */ - -1, /* (533) pseudo_column ::= QDURATION */ - -1, /* (534) pseudo_column ::= WSTART */ - -1, /* (535) pseudo_column ::= WEND */ - -1, /* (536) pseudo_column ::= WDURATION */ - -1, /* (537) pseudo_column ::= IROWTS */ - -1, /* (538) pseudo_column ::= ISFILLED */ - -1, /* (539) pseudo_column ::= QTAGS */ - -4, /* (540) function_expression ::= function_name NK_LP expression_list NK_RP */ - -4, /* (541) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - -6, /* (542) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - -6, /* (543) function_expression ::= CAST NK_LP expr_or_subquery AS type_name_default_len NK_RP */ - -1, /* (544) function_expression ::= literal_func */ - -3, /* (545) literal_func ::= noarg_func NK_LP NK_RP */ - -1, /* (546) literal_func ::= NOW */ - -1, /* (547) literal_func ::= TODAY */ - -1, /* (548) noarg_func ::= NOW */ - -1, /* (549) noarg_func ::= TODAY */ - -1, /* (550) noarg_func ::= TIMEZONE */ - -1, /* (551) noarg_func ::= DATABASE */ - -1, /* (552) noarg_func ::= CLIENT_VERSION */ - -1, /* (553) noarg_func ::= SERVER_VERSION */ - -1, /* (554) noarg_func ::= SERVER_STATUS */ - -1, /* (555) noarg_func ::= CURRENT_USER */ - -1, /* (556) noarg_func ::= USER */ - -1, /* (557) star_func ::= COUNT */ - -1, /* (558) star_func ::= FIRST */ - -1, /* (559) star_func ::= LAST */ - -1, /* (560) star_func ::= LAST_ROW */ - -1, /* (561) star_func_para_list ::= NK_STAR */ - -1, /* (562) star_func_para_list ::= other_para_list */ - -1, /* (563) other_para_list ::= star_func_para */ - -3, /* (564) other_para_list ::= other_para_list NK_COMMA star_func_para */ - -1, /* (565) star_func_para ::= expr_or_subquery */ - -3, /* (566) star_func_para ::= table_name NK_DOT NK_STAR */ - -4, /* (567) case_when_expression ::= CASE when_then_list case_when_else_opt END */ - -5, /* (568) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ - -1, /* (569) when_then_list ::= when_then_expr */ - -2, /* (570) when_then_list ::= when_then_list when_then_expr */ - -4, /* (571) when_then_expr ::= WHEN common_expression THEN common_expression */ - 0, /* (572) case_when_else_opt ::= */ - -2, /* (573) case_when_else_opt ::= ELSE common_expression */ - -3, /* (574) predicate ::= expr_or_subquery compare_op expr_or_subquery */ - -5, /* (575) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ - -6, /* (576) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ - -3, /* (577) predicate ::= expr_or_subquery IS NULL */ - -4, /* (578) predicate ::= expr_or_subquery IS NOT NULL */ - -3, /* (579) predicate ::= expr_or_subquery in_op in_predicate_value */ - -1, /* (580) compare_op ::= NK_LT */ - -1, /* (581) compare_op ::= NK_GT */ - -1, /* (582) compare_op ::= NK_LE */ - -1, /* (583) compare_op ::= NK_GE */ - -1, /* (584) compare_op ::= NK_NE */ - -1, /* (585) compare_op ::= NK_EQ */ - -1, /* (586) compare_op ::= LIKE */ - -2, /* (587) compare_op ::= NOT LIKE */ - -1, /* (588) compare_op ::= MATCH */ - -1, /* (589) compare_op ::= NMATCH */ - -1, /* (590) compare_op ::= CONTAINS */ - -1, /* (591) in_op ::= IN */ - -2, /* (592) in_op ::= NOT IN */ - -3, /* (593) in_predicate_value ::= NK_LP literal_list NK_RP */ - -1, /* (594) boolean_value_expression ::= boolean_primary */ - -2, /* (595) boolean_value_expression ::= NOT boolean_primary */ - -3, /* (596) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - -3, /* (597) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - -1, /* (598) boolean_primary ::= predicate */ - -3, /* (599) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - -1, /* (600) common_expression ::= expr_or_subquery */ - -1, /* (601) common_expression ::= boolean_value_expression */ - 0, /* (602) from_clause_opt ::= */ - -2, /* (603) from_clause_opt ::= FROM table_reference_list */ - -1, /* (604) table_reference_list ::= table_reference */ - -3, /* (605) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - -1, /* (606) table_reference ::= table_primary */ - -1, /* (607) table_reference ::= joined_table */ - -2, /* (608) table_primary ::= table_name alias_opt */ - -4, /* (609) table_primary ::= db_name NK_DOT table_name alias_opt */ - -2, /* (610) table_primary ::= subquery alias_opt */ - -1, /* (611) table_primary ::= parenthesized_joined_table */ - 0, /* (612) alias_opt ::= */ - -1, /* (613) alias_opt ::= table_alias */ - -2, /* (614) alias_opt ::= AS table_alias */ - -3, /* (615) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - -3, /* (616) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - -8, /* (617) joined_table ::= table_reference join_type join_subtype JOIN table_reference join_on_clause_opt window_offset_clause_opt jlimit_clause_opt */ - 0, /* (618) join_type ::= */ - -1, /* (619) join_type ::= INNER */ - -1, /* (620) join_type ::= LEFT */ - -1, /* (621) join_type ::= RIGHT */ - -1, /* (622) join_type ::= FULL */ - 0, /* (623) join_subtype ::= */ - -1, /* (624) join_subtype ::= OUTER */ - -1, /* (625) join_subtype ::= SEMI */ - -1, /* (626) join_subtype ::= ANTI */ - -1, /* (627) join_subtype ::= ASOF */ - -1, /* (628) join_subtype ::= WINDOW */ - 0, /* (629) join_on_clause_opt ::= */ - -2, /* (630) join_on_clause_opt ::= ON search_condition */ - 0, /* (631) window_offset_clause_opt ::= */ - -6, /* (632) window_offset_clause_opt ::= WINDOW_OFFSET NK_LP window_offset_literal NK_COMMA window_offset_literal NK_RP */ - -1, /* (633) window_offset_literal ::= NK_VARIABLE */ - -2, /* (634) window_offset_literal ::= NK_MINUS NK_VARIABLE */ - 0, /* (635) jlimit_clause_opt ::= */ - -2, /* (636) jlimit_clause_opt ::= JLIMIT NK_INTEGER */ - -14, /* (637) query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ - 0, /* (638) hint_list ::= */ - -1, /* (639) hint_list ::= NK_HINT */ - 0, /* (640) tag_mode_opt ::= */ - -1, /* (641) tag_mode_opt ::= TAGS */ - 0, /* (642) set_quantifier_opt ::= */ - -1, /* (643) set_quantifier_opt ::= DISTINCT */ - -1, /* (644) set_quantifier_opt ::= ALL */ - -1, /* (645) select_list ::= select_item */ - -3, /* (646) select_list ::= select_list NK_COMMA select_item */ - -1, /* (647) select_item ::= NK_STAR */ - -1, /* (648) select_item ::= common_expression */ - -2, /* (649) select_item ::= common_expression column_alias */ - -3, /* (650) select_item ::= common_expression AS column_alias */ - -3, /* (651) select_item ::= table_name NK_DOT NK_STAR */ - 0, /* (652) where_clause_opt ::= */ - -2, /* (653) where_clause_opt ::= WHERE search_condition */ - 0, /* (654) partition_by_clause_opt ::= */ - -3, /* (655) partition_by_clause_opt ::= PARTITION BY partition_list */ - -1, /* (656) partition_list ::= partition_item */ - -3, /* (657) partition_list ::= partition_list NK_COMMA partition_item */ - -1, /* (658) partition_item ::= expr_or_subquery */ - -2, /* (659) partition_item ::= expr_or_subquery column_alias */ - -3, /* (660) partition_item ::= expr_or_subquery AS column_alias */ - 0, /* (661) twindow_clause_opt ::= */ - -6, /* (662) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ - -4, /* (663) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ - -6, /* (664) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - -8, /* (665) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - -7, /* (666) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ - -4, /* (667) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ - -6, /* (668) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - 0, /* (669) sliding_opt ::= */ - -4, /* (670) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ - -1, /* (671) interval_sliding_duration_literal ::= NK_VARIABLE */ - -1, /* (672) interval_sliding_duration_literal ::= NK_STRING */ - -1, /* (673) interval_sliding_duration_literal ::= NK_INTEGER */ - 0, /* (674) fill_opt ::= */ - -4, /* (675) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - -6, /* (676) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ - -6, /* (677) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ - -1, /* (678) fill_mode ::= NONE */ - -1, /* (679) fill_mode ::= PREV */ - -1, /* (680) fill_mode ::= NULL */ - -1, /* (681) fill_mode ::= NULL_F */ - -1, /* (682) fill_mode ::= LINEAR */ - -1, /* (683) fill_mode ::= NEXT */ - 0, /* (684) group_by_clause_opt ::= */ - -3, /* (685) group_by_clause_opt ::= GROUP BY group_by_list */ - -1, /* (686) group_by_list ::= expr_or_subquery */ - -3, /* (687) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ - 0, /* (688) having_clause_opt ::= */ - -2, /* (689) having_clause_opt ::= HAVING search_condition */ - 0, /* (690) range_opt ::= */ - -6, /* (691) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ - -4, /* (692) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ - 0, /* (693) every_opt ::= */ - -4, /* (694) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - -4, /* (695) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ - -1, /* (696) query_simple ::= query_specification */ - -1, /* (697) query_simple ::= union_query_expression */ - -4, /* (698) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ - -3, /* (699) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ - -1, /* (700) query_simple_or_subquery ::= query_simple */ - -1, /* (701) query_simple_or_subquery ::= subquery */ - -1, /* (702) query_or_subquery ::= query_expression */ - -1, /* (703) query_or_subquery ::= subquery */ - 0, /* (704) order_by_clause_opt ::= */ - -3, /* (705) order_by_clause_opt ::= ORDER BY sort_specification_list */ - 0, /* (706) slimit_clause_opt ::= */ - -2, /* (707) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - -4, /* (708) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - -4, /* (709) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 0, /* (710) limit_clause_opt ::= */ - -2, /* (711) limit_clause_opt ::= LIMIT NK_INTEGER */ - -4, /* (712) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - -4, /* (713) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - -3, /* (714) subquery ::= NK_LP query_expression NK_RP */ - -3, /* (715) subquery ::= NK_LP subquery NK_RP */ - -1, /* (716) search_condition ::= common_expression */ - -1, /* (717) sort_specification_list ::= sort_specification */ - -3, /* (718) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - -3, /* (719) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ - 0, /* (720) ordering_specification_opt ::= */ - -1, /* (721) ordering_specification_opt ::= ASC */ - -1, /* (722) ordering_specification_opt ::= DESC */ - 0, /* (723) null_ordering_opt ::= */ - -2, /* (724) null_ordering_opt ::= NULLS FIRST */ - -2, /* (725) null_ordering_opt ::= NULLS LAST */ + -11, /* (332) cmd ::= CREATE TSMA not_exists_opt tsma_name ON full_table_name tsma_func_list INTERVAL NK_LP duration_literal NK_RP */ + -11, /* (333) cmd ::= CREATE RECURSIVE TSMA not_exists_opt tsma_name ON full_table_name INTERVAL NK_LP duration_literal NK_RP */ + -4, /* (334) cmd ::= DROP TSMA exists_opt full_tsma_name */ + -3, /* (335) cmd ::= SHOW db_name_cond_opt TSMAS */ + -1, /* (336) full_tsma_name ::= tsma_name */ + -3, /* (337) full_tsma_name ::= db_name NK_DOT tsma_name */ + -4, /* (338) tsma_func_list ::= FUNCTION NK_LP func_list NK_RP */ + -8, /* (339) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ + -9, /* (340) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ + -4, /* (341) cmd ::= DROP INDEX exists_opt full_index_name */ + -1, /* (342) full_index_name ::= index_name */ + -3, /* (343) full_index_name ::= db_name NK_DOT index_name */ + -10, /* (344) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + -12, /* (345) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ + -1, /* (346) func_list ::= func */ + -3, /* (347) func_list ::= func_list NK_COMMA func */ + -4, /* (348) func ::= sma_func_name NK_LP expression_list NK_RP */ + -1, /* (349) sma_func_name ::= function_name */ + -1, /* (350) sma_func_name ::= COUNT */ + -1, /* (351) sma_func_name ::= FIRST */ + -1, /* (352) sma_func_name ::= LAST */ + -1, /* (353) sma_func_name ::= LAST_ROW */ + 0, /* (354) sma_stream_opt ::= */ + -3, /* (355) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ + -3, /* (356) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ + -3, /* (357) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ + -1, /* (358) with_meta ::= AS */ + -3, /* (359) with_meta ::= WITH META AS */ + -3, /* (360) with_meta ::= ONLY META AS */ + -6, /* (361) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + -7, /* (362) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ + -8, /* (363) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ + -4, /* (364) cmd ::= DROP TOPIC exists_opt topic_name */ + -7, /* (365) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + -2, /* (366) cmd ::= DESC full_table_name */ + -2, /* (367) cmd ::= DESCRIBE full_table_name */ + -3, /* (368) cmd ::= RESET QUERY CACHE */ + -4, /* (369) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + -4, /* (370) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ + 0, /* (371) analyze_opt ::= */ + -1, /* (372) analyze_opt ::= ANALYZE */ + 0, /* (373) explain_options ::= */ + -3, /* (374) explain_options ::= explain_options VERBOSE NK_BOOL */ + -3, /* (375) explain_options ::= explain_options RATIO NK_FLOAT */ + -12, /* (376) cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ + -4, /* (377) cmd ::= DROP FUNCTION exists_opt function_name */ + 0, /* (378) agg_func_opt ::= */ + -1, /* (379) agg_func_opt ::= AGGREGATE */ + 0, /* (380) bufsize_opt ::= */ + -2, /* (381) bufsize_opt ::= BUFSIZE NK_INTEGER */ + 0, /* (382) language_opt ::= */ + -2, /* (383) language_opt ::= LANGUAGE NK_STRING */ + 0, /* (384) or_replace_opt ::= */ + -2, /* (385) or_replace_opt ::= OR REPLACE */ + -6, /* (386) cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ + -4, /* (387) cmd ::= DROP VIEW exists_opt full_view_name */ + -1, /* (388) full_view_name ::= view_name */ + -3, /* (389) full_view_name ::= db_name NK_DOT view_name */ + -12, /* (390) cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ + -4, /* (391) cmd ::= DROP STREAM exists_opt stream_name */ + -4, /* (392) cmd ::= PAUSE STREAM exists_opt stream_name */ + -5, /* (393) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ + 0, /* (394) col_list_opt ::= */ + -3, /* (395) col_list_opt ::= NK_LP column_stream_def_list NK_RP */ + -1, /* (396) column_stream_def_list ::= column_stream_def */ + -3, /* (397) column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def */ + -1, /* (398) column_stream_def ::= column_name */ + -3, /* (399) column_stream_def ::= column_name PRIMARY KEY */ + 0, /* (400) tag_def_or_ref_opt ::= */ + -1, /* (401) tag_def_or_ref_opt ::= tags_def */ + -4, /* (402) tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP */ + 0, /* (403) stream_options ::= */ + -3, /* (404) stream_options ::= stream_options TRIGGER AT_ONCE */ + -3, /* (405) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + -4, /* (406) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + -3, /* (407) stream_options ::= stream_options WATERMARK duration_literal */ + -4, /* (408) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + -3, /* (409) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ + -3, /* (410) stream_options ::= stream_options DELETE_MARK duration_literal */ + -4, /* (411) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ + 0, /* (412) subtable_opt ::= */ + -4, /* (413) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + 0, /* (414) ignore_opt ::= */ + -2, /* (415) ignore_opt ::= IGNORE UNTREATED */ + -3, /* (416) cmd ::= KILL CONNECTION NK_INTEGER */ + -3, /* (417) cmd ::= KILL QUERY NK_STRING */ + -3, /* (418) cmd ::= KILL TRANSACTION NK_INTEGER */ + -3, /* (419) cmd ::= KILL COMPACT NK_INTEGER */ + -2, /* (420) cmd ::= BALANCE VGROUP */ + -4, /* (421) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ + -4, /* (422) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + -4, /* (423) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + -3, /* (424) cmd ::= SPLIT VGROUP NK_INTEGER */ + 0, /* (425) on_vgroup_id ::= */ + -2, /* (426) on_vgroup_id ::= ON NK_INTEGER */ + -2, /* (427) dnode_list ::= DNODE NK_INTEGER */ + -3, /* (428) dnode_list ::= dnode_list DNODE NK_INTEGER */ + -4, /* (429) cmd ::= DELETE FROM full_table_name where_clause_opt */ + -1, /* (430) cmd ::= query_or_subquery */ + -1, /* (431) cmd ::= insert_query */ + -7, /* (432) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + -4, /* (433) insert_query ::= INSERT INTO full_table_name query_or_subquery */ + -1, /* (434) tags_literal ::= NK_INTEGER */ + -3, /* (435) tags_literal ::= NK_INTEGER NK_PLUS duration_literal */ + -3, /* (436) tags_literal ::= NK_INTEGER NK_MINUS duration_literal */ + -2, /* (437) tags_literal ::= NK_PLUS NK_INTEGER */ + -4, /* (438) tags_literal ::= NK_PLUS NK_INTEGER NK_PLUS duration_literal */ + -4, /* (439) tags_literal ::= NK_PLUS NK_INTEGER NK_MINUS duration_literal */ + -2, /* (440) tags_literal ::= NK_MINUS NK_INTEGER */ + -4, /* (441) tags_literal ::= NK_MINUS NK_INTEGER NK_PLUS duration_literal */ + -4, /* (442) tags_literal ::= NK_MINUS NK_INTEGER NK_MINUS duration_literal */ + -1, /* (443) tags_literal ::= NK_FLOAT */ + -2, /* (444) tags_literal ::= NK_PLUS NK_FLOAT */ + -2, /* (445) tags_literal ::= NK_MINUS NK_FLOAT */ + -1, /* (446) tags_literal ::= NK_BIN */ + -3, /* (447) tags_literal ::= NK_BIN NK_PLUS duration_literal */ + -3, /* (448) tags_literal ::= NK_BIN NK_MINUS duration_literal */ + -2, /* (449) tags_literal ::= NK_PLUS NK_BIN */ + -4, /* (450) tags_literal ::= NK_PLUS NK_BIN NK_PLUS duration_literal */ + -4, /* (451) tags_literal ::= NK_PLUS NK_BIN NK_MINUS duration_literal */ + -2, /* (452) tags_literal ::= NK_MINUS NK_BIN */ + -4, /* (453) tags_literal ::= NK_MINUS NK_BIN NK_PLUS duration_literal */ + -4, /* (454) tags_literal ::= NK_MINUS NK_BIN NK_MINUS duration_literal */ + -1, /* (455) tags_literal ::= NK_HEX */ + -3, /* (456) tags_literal ::= NK_HEX NK_PLUS duration_literal */ + -3, /* (457) tags_literal ::= NK_HEX NK_MINUS duration_literal */ + -2, /* (458) tags_literal ::= NK_PLUS NK_HEX */ + -4, /* (459) tags_literal ::= NK_PLUS NK_HEX NK_PLUS duration_literal */ + -4, /* (460) tags_literal ::= NK_PLUS NK_HEX NK_MINUS duration_literal */ + -2, /* (461) tags_literal ::= NK_MINUS NK_HEX */ + -4, /* (462) tags_literal ::= NK_MINUS NK_HEX NK_PLUS duration_literal */ + -4, /* (463) tags_literal ::= NK_MINUS NK_HEX NK_MINUS duration_literal */ + -1, /* (464) tags_literal ::= NK_STRING */ + -3, /* (465) tags_literal ::= NK_STRING NK_PLUS duration_literal */ + -3, /* (466) tags_literal ::= NK_STRING NK_MINUS duration_literal */ + -1, /* (467) tags_literal ::= NK_BOOL */ + -1, /* (468) tags_literal ::= NULL */ + -1, /* (469) tags_literal ::= literal_func */ + -3, /* (470) tags_literal ::= literal_func NK_PLUS duration_literal */ + -3, /* (471) tags_literal ::= literal_func NK_MINUS duration_literal */ + -1, /* (472) tags_literal_list ::= tags_literal */ + -3, /* (473) tags_literal_list ::= tags_literal_list NK_COMMA tags_literal */ + -1, /* (474) literal ::= NK_INTEGER */ + -1, /* (475) literal ::= NK_FLOAT */ + -1, /* (476) literal ::= NK_STRING */ + -1, /* (477) literal ::= NK_BOOL */ + -2, /* (478) literal ::= TIMESTAMP NK_STRING */ + -1, /* (479) literal ::= duration_literal */ + -1, /* (480) literal ::= NULL */ + -1, /* (481) literal ::= NK_QUESTION */ + -1, /* (482) duration_literal ::= NK_VARIABLE */ + -1, /* (483) signed ::= NK_INTEGER */ + -2, /* (484) signed ::= NK_PLUS NK_INTEGER */ + -2, /* (485) signed ::= NK_MINUS NK_INTEGER */ + -1, /* (486) signed ::= NK_FLOAT */ + -2, /* (487) signed ::= NK_PLUS NK_FLOAT */ + -2, /* (488) signed ::= NK_MINUS NK_FLOAT */ + -1, /* (489) signed_literal ::= signed */ + -1, /* (490) signed_literal ::= NK_STRING */ + -1, /* (491) signed_literal ::= NK_BOOL */ + -2, /* (492) signed_literal ::= TIMESTAMP NK_STRING */ + -1, /* (493) signed_literal ::= duration_literal */ + -1, /* (494) signed_literal ::= NULL */ + -1, /* (495) signed_literal ::= literal_func */ + -1, /* (496) signed_literal ::= NK_QUESTION */ + -1, /* (497) literal_list ::= signed_literal */ + -3, /* (498) literal_list ::= literal_list NK_COMMA signed_literal */ + -1, /* (499) db_name ::= NK_ID */ + -1, /* (500) table_name ::= NK_ID */ + -1, /* (501) column_name ::= NK_ID */ + -1, /* (502) function_name ::= NK_ID */ + -1, /* (503) view_name ::= NK_ID */ + -1, /* (504) table_alias ::= NK_ID */ + -1, /* (505) column_alias ::= NK_ID */ + -1, /* (506) column_alias ::= NK_ALIAS */ + -1, /* (507) user_name ::= NK_ID */ + -1, /* (508) topic_name ::= NK_ID */ + -1, /* (509) stream_name ::= NK_ID */ + -1, /* (510) cgroup_name ::= NK_ID */ + -1, /* (511) index_name ::= NK_ID */ + -1, /* (512) tsma_name ::= NK_ID */ + -1, /* (513) expr_or_subquery ::= expression */ + -1, /* (514) expression ::= literal */ + -1, /* (515) expression ::= pseudo_column */ + -1, /* (516) expression ::= column_reference */ + -1, /* (517) expression ::= function_expression */ + -1, /* (518) expression ::= case_when_expression */ + -3, /* (519) expression ::= NK_LP expression NK_RP */ + -2, /* (520) expression ::= NK_PLUS expr_or_subquery */ + -2, /* (521) expression ::= NK_MINUS expr_or_subquery */ + -3, /* (522) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + -3, /* (523) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + -3, /* (524) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + -3, /* (525) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + -3, /* (526) expression ::= expr_or_subquery NK_REM expr_or_subquery */ + -3, /* (527) expression ::= column_reference NK_ARROW NK_STRING */ + -3, /* (528) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + -3, /* (529) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + -1, /* (530) expression_list ::= expr_or_subquery */ + -3, /* (531) expression_list ::= expression_list NK_COMMA expr_or_subquery */ + -1, /* (532) column_reference ::= column_name */ + -3, /* (533) column_reference ::= table_name NK_DOT column_name */ + -1, /* (534) column_reference ::= NK_ALIAS */ + -3, /* (535) column_reference ::= table_name NK_DOT NK_ALIAS */ + -1, /* (536) pseudo_column ::= ROWTS */ + -1, /* (537) pseudo_column ::= TBNAME */ + -3, /* (538) pseudo_column ::= table_name NK_DOT TBNAME */ + -1, /* (539) pseudo_column ::= QSTART */ + -1, /* (540) pseudo_column ::= QEND */ + -1, /* (541) pseudo_column ::= QDURATION */ + -1, /* (542) pseudo_column ::= WSTART */ + -1, /* (543) pseudo_column ::= WEND */ + -1, /* (544) pseudo_column ::= WDURATION */ + -1, /* (545) pseudo_column ::= IROWTS */ + -1, /* (546) pseudo_column ::= ISFILLED */ + -1, /* (547) pseudo_column ::= QTAGS */ + -4, /* (548) function_expression ::= function_name NK_LP expression_list NK_RP */ + -4, /* (549) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + -6, /* (550) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + -6, /* (551) function_expression ::= CAST NK_LP expr_or_subquery AS type_name_default_len NK_RP */ + -1, /* (552) function_expression ::= literal_func */ + -3, /* (553) literal_func ::= noarg_func NK_LP NK_RP */ + -1, /* (554) literal_func ::= NOW */ + -1, /* (555) literal_func ::= TODAY */ + -1, /* (556) noarg_func ::= NOW */ + -1, /* (557) noarg_func ::= TODAY */ + -1, /* (558) noarg_func ::= TIMEZONE */ + -1, /* (559) noarg_func ::= DATABASE */ + -1, /* (560) noarg_func ::= CLIENT_VERSION */ + -1, /* (561) noarg_func ::= SERVER_VERSION */ + -1, /* (562) noarg_func ::= SERVER_STATUS */ + -1, /* (563) noarg_func ::= CURRENT_USER */ + -1, /* (564) noarg_func ::= USER */ + -1, /* (565) star_func ::= COUNT */ + -1, /* (566) star_func ::= FIRST */ + -1, /* (567) star_func ::= LAST */ + -1, /* (568) star_func ::= LAST_ROW */ + -1, /* (569) star_func_para_list ::= NK_STAR */ + -1, /* (570) star_func_para_list ::= other_para_list */ + -1, /* (571) other_para_list ::= star_func_para */ + -3, /* (572) other_para_list ::= other_para_list NK_COMMA star_func_para */ + -1, /* (573) star_func_para ::= expr_or_subquery */ + -3, /* (574) star_func_para ::= table_name NK_DOT NK_STAR */ + -4, /* (575) case_when_expression ::= CASE when_then_list case_when_else_opt END */ + -5, /* (576) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + -1, /* (577) when_then_list ::= when_then_expr */ + -2, /* (578) when_then_list ::= when_then_list when_then_expr */ + -4, /* (579) when_then_expr ::= WHEN common_expression THEN common_expression */ + 0, /* (580) case_when_else_opt ::= */ + -2, /* (581) case_when_else_opt ::= ELSE common_expression */ + -3, /* (582) predicate ::= expr_or_subquery compare_op expr_or_subquery */ + -5, /* (583) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + -6, /* (584) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + -3, /* (585) predicate ::= expr_or_subquery IS NULL */ + -4, /* (586) predicate ::= expr_or_subquery IS NOT NULL */ + -3, /* (587) predicate ::= expr_or_subquery in_op in_predicate_value */ + -1, /* (588) compare_op ::= NK_LT */ + -1, /* (589) compare_op ::= NK_GT */ + -1, /* (590) compare_op ::= NK_LE */ + -1, /* (591) compare_op ::= NK_GE */ + -1, /* (592) compare_op ::= NK_NE */ + -1, /* (593) compare_op ::= NK_EQ */ + -1, /* (594) compare_op ::= LIKE */ + -2, /* (595) compare_op ::= NOT LIKE */ + -1, /* (596) compare_op ::= MATCH */ + -1, /* (597) compare_op ::= NMATCH */ + -1, /* (598) compare_op ::= CONTAINS */ + -1, /* (599) in_op ::= IN */ + -2, /* (600) in_op ::= NOT IN */ + -3, /* (601) in_predicate_value ::= NK_LP literal_list NK_RP */ + -1, /* (602) boolean_value_expression ::= boolean_primary */ + -2, /* (603) boolean_value_expression ::= NOT boolean_primary */ + -3, /* (604) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + -3, /* (605) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + -1, /* (606) boolean_primary ::= predicate */ + -3, /* (607) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + -1, /* (608) common_expression ::= expr_or_subquery */ + -1, /* (609) common_expression ::= boolean_value_expression */ + 0, /* (610) from_clause_opt ::= */ + -2, /* (611) from_clause_opt ::= FROM table_reference_list */ + -1, /* (612) table_reference_list ::= table_reference */ + -3, /* (613) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + -1, /* (614) table_reference ::= table_primary */ + -1, /* (615) table_reference ::= joined_table */ + -2, /* (616) table_primary ::= table_name alias_opt */ + -4, /* (617) table_primary ::= db_name NK_DOT table_name alias_opt */ + -2, /* (618) table_primary ::= subquery alias_opt */ + -1, /* (619) table_primary ::= parenthesized_joined_table */ + 0, /* (620) alias_opt ::= */ + -1, /* (621) alias_opt ::= table_alias */ + -2, /* (622) alias_opt ::= AS table_alias */ + -3, /* (623) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + -3, /* (624) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + -8, /* (625) joined_table ::= table_reference join_type join_subtype JOIN table_reference join_on_clause_opt window_offset_clause_opt jlimit_clause_opt */ + 0, /* (626) join_type ::= */ + -1, /* (627) join_type ::= INNER */ + -1, /* (628) join_type ::= LEFT */ + -1, /* (629) join_type ::= RIGHT */ + -1, /* (630) join_type ::= FULL */ + 0, /* (631) join_subtype ::= */ + -1, /* (632) join_subtype ::= OUTER */ + -1, /* (633) join_subtype ::= SEMI */ + -1, /* (634) join_subtype ::= ANTI */ + -1, /* (635) join_subtype ::= ASOF */ + -1, /* (636) join_subtype ::= WINDOW */ + 0, /* (637) join_on_clause_opt ::= */ + -2, /* (638) join_on_clause_opt ::= ON search_condition */ + 0, /* (639) window_offset_clause_opt ::= */ + -6, /* (640) window_offset_clause_opt ::= WINDOW_OFFSET NK_LP window_offset_literal NK_COMMA window_offset_literal NK_RP */ + -1, /* (641) window_offset_literal ::= NK_VARIABLE */ + -2, /* (642) window_offset_literal ::= NK_MINUS NK_VARIABLE */ + 0, /* (643) jlimit_clause_opt ::= */ + -2, /* (644) jlimit_clause_opt ::= JLIMIT NK_INTEGER */ + -14, /* (645) query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + 0, /* (646) hint_list ::= */ + -1, /* (647) hint_list ::= NK_HINT */ + 0, /* (648) tag_mode_opt ::= */ + -1, /* (649) tag_mode_opt ::= TAGS */ + 0, /* (650) set_quantifier_opt ::= */ + -1, /* (651) set_quantifier_opt ::= DISTINCT */ + -1, /* (652) set_quantifier_opt ::= ALL */ + -1, /* (653) select_list ::= select_item */ + -3, /* (654) select_list ::= select_list NK_COMMA select_item */ + -1, /* (655) select_item ::= NK_STAR */ + -1, /* (656) select_item ::= common_expression */ + -2, /* (657) select_item ::= common_expression column_alias */ + -3, /* (658) select_item ::= common_expression AS column_alias */ + -3, /* (659) select_item ::= table_name NK_DOT NK_STAR */ + 0, /* (660) where_clause_opt ::= */ + -2, /* (661) where_clause_opt ::= WHERE search_condition */ + 0, /* (662) partition_by_clause_opt ::= */ + -3, /* (663) partition_by_clause_opt ::= PARTITION BY partition_list */ + -1, /* (664) partition_list ::= partition_item */ + -3, /* (665) partition_list ::= partition_list NK_COMMA partition_item */ + -1, /* (666) partition_item ::= expr_or_subquery */ + -2, /* (667) partition_item ::= expr_or_subquery column_alias */ + -3, /* (668) partition_item ::= expr_or_subquery AS column_alias */ + 0, /* (669) twindow_clause_opt ::= */ + -6, /* (670) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ + -4, /* (671) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + -6, /* (672) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + -8, /* (673) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + -7, /* (674) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ + -4, /* (675) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ + -6, /* (676) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + 0, /* (677) sliding_opt ::= */ + -4, /* (678) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ + -1, /* (679) interval_sliding_duration_literal ::= NK_VARIABLE */ + -1, /* (680) interval_sliding_duration_literal ::= NK_STRING */ + -1, /* (681) interval_sliding_duration_literal ::= NK_INTEGER */ + 0, /* (682) fill_opt ::= */ + -4, /* (683) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + -6, /* (684) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ + -6, /* (685) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ + -1, /* (686) fill_mode ::= NONE */ + -1, /* (687) fill_mode ::= PREV */ + -1, /* (688) fill_mode ::= NULL */ + -1, /* (689) fill_mode ::= NULL_F */ + -1, /* (690) fill_mode ::= LINEAR */ + -1, /* (691) fill_mode ::= NEXT */ + 0, /* (692) group_by_clause_opt ::= */ + -3, /* (693) group_by_clause_opt ::= GROUP BY group_by_list */ + -1, /* (694) group_by_list ::= expr_or_subquery */ + -3, /* (695) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + 0, /* (696) having_clause_opt ::= */ + -2, /* (697) having_clause_opt ::= HAVING search_condition */ + 0, /* (698) range_opt ::= */ + -6, /* (699) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + -4, /* (700) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ + 0, /* (701) every_opt ::= */ + -4, /* (702) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + -4, /* (703) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + -1, /* (704) query_simple ::= query_specification */ + -1, /* (705) query_simple ::= union_query_expression */ + -4, /* (706) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + -3, /* (707) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + -1, /* (708) query_simple_or_subquery ::= query_simple */ + -1, /* (709) query_simple_or_subquery ::= subquery */ + -1, /* (710) query_or_subquery ::= query_expression */ + -1, /* (711) query_or_subquery ::= subquery */ + 0, /* (712) order_by_clause_opt ::= */ + -3, /* (713) order_by_clause_opt ::= ORDER BY sort_specification_list */ + 0, /* (714) slimit_clause_opt ::= */ + -2, /* (715) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + -4, /* (716) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + -4, /* (717) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 0, /* (718) limit_clause_opt ::= */ + -2, /* (719) limit_clause_opt ::= LIMIT NK_INTEGER */ + -4, /* (720) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + -4, /* (721) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + -3, /* (722) subquery ::= NK_LP query_expression NK_RP */ + -3, /* (723) subquery ::= NK_LP subquery NK_RP */ + -1, /* (724) search_condition ::= common_expression */ + -1, /* (725) sort_specification_list ::= sort_specification */ + -3, /* (726) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + -3, /* (727) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + 0, /* (728) ordering_specification_opt ::= */ + -1, /* (729) ordering_specification_opt ::= ASC */ + -1, /* (730) ordering_specification_opt ::= DESC */ + 0, /* (731) null_ordering_opt ::= */ + -2, /* (732) null_ordering_opt ::= NULLS FIRST */ + -2, /* (733) null_ordering_opt ::= NULLS LAST */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -5015,8 +5486,9 @@ static YYACTIONTYPE yy_reduce( (void)yyLookahead; (void)yyLookaheadToken; yymsp = yypParser->yytos; + assert( yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ); #ifndef NDEBUG - if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){ + if( yyTraceFILE ){ yysize = yyRuleInfoNRhs[yyruleno]; if( yysize ){ fprintf(yyTraceFILE, "%sReduce %d [%s]%s, pop back to state %d.\n", @@ -5076,15 +5548,21 @@ static YYACTIONTYPE yy_reduce( /********** Begin reduce actions **********************************************/ YYMINORTYPE yylhsminor; case 0: /* cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ +#line 50 "sql.y" { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,368,&yymsp[0].minor); +#line 5553 "sql.c" + yy_destructor(yypParser,371,&yymsp[0].minor); break; case 1: /* cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ +#line 51 "sql.y" { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } - yy_destructor(yypParser,369,&yymsp[0].minor); +#line 5559 "sql.c" + yy_destructor(yypParser,372,&yymsp[0].minor); break; case 2: /* account_options ::= */ +#line 55 "sql.y" { } +#line 5565 "sql.c" break; case 3: /* account_options ::= account_options PPS literal */ case 4: /* account_options ::= account_options TSERIES literal */ yytestcase(yyruleno==4); @@ -5095,20 +5573,26 @@ 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,368,&yymsp[-2].minor); +{ yy_destructor(yypParser,371,&yymsp[-2].minor); +#line 56 "sql.y" { } - yy_destructor(yypParser,370,&yymsp[0].minor); +#line 5579 "sql.c" + yy_destructor(yypParser,373,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,371,&yymsp[0].minor); +{ yy_destructor(yypParser,374,&yymsp[0].minor); +#line 68 "sql.y" { } +#line 5587 "sql.c" } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,369,&yymsp[-1].minor); +{ yy_destructor(yypParser,372,&yymsp[-1].minor); +#line 69 "sql.y" { } - yy_destructor(yypParser,371,&yymsp[0].minor); +#line 5594 "sql.c" + yy_destructor(yypParser,374,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -5121,534 +5605,785 @@ static YYACTIONTYPE yy_reduce( case 21: /* alter_account_option ::= USERS literal */ yytestcase(yyruleno==21); case 22: /* alter_account_option ::= CONNS literal */ yytestcase(yyruleno==22); case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); +#line 73 "sql.y" { } - yy_destructor(yypParser,370,&yymsp[0].minor); +#line 5610 "sql.c" + yy_destructor(yypParser,373,&yymsp[0].minor); break; case 24: /* ip_range_list ::= NK_STRING */ -{ yylhsminor.yy984 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy984 = yylhsminor.yy984; +#line 86 "sql.y" +{ yylhsminor.yy24 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } +#line 5616 "sql.c" + yymsp[0].minor.yy24 = yylhsminor.yy24; break; case 25: /* ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ -{ yylhsminor.yy984 = addNodeToList(pCxt, yymsp[-2].minor.yy984, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy984 = yylhsminor.yy984; +#line 87 "sql.y" +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } +#line 5622 "sql.c" + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 26: /* white_list ::= HOST ip_range_list */ -{ yymsp[-1].minor.yy984 = yymsp[0].minor.yy984; } +#line 91 "sql.y" +{ yymsp[-1].minor.yy24 = yymsp[0].minor.yy24; } +#line 5628 "sql.c" break; case 27: /* white_list_opt ::= */ case 196: /* specific_cols_opt ::= */ yytestcase(yyruleno==196); case 232: /* tags_def_opt ::= */ yytestcase(yyruleno==232); case 321: /* tag_list_opt ::= */ yytestcase(yyruleno==321); - case 387: /* col_list_opt ::= */ yytestcase(yyruleno==387); - case 393: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==393); - case 654: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==654); - case 684: /* group_by_clause_opt ::= */ yytestcase(yyruleno==684); - case 704: /* order_by_clause_opt ::= */ yytestcase(yyruleno==704); -{ yymsp[1].minor.yy984 = NULL; } + case 394: /* col_list_opt ::= */ yytestcase(yyruleno==394); + case 400: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==400); + case 662: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==662); + case 692: /* group_by_clause_opt ::= */ yytestcase(yyruleno==692); + case 712: /* order_by_clause_opt ::= */ yytestcase(yyruleno==712); +#line 95 "sql.y" +{ yymsp[1].minor.yy24 = NULL; } +#line 5641 "sql.c" break; case 28: /* white_list_opt ::= white_list */ case 233: /* tags_def_opt ::= tags_def */ yytestcase(yyruleno==233); - case 394: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==394); - case 562: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==562); -{ yylhsminor.yy984 = yymsp[0].minor.yy984; } - yymsp[0].minor.yy984 = yylhsminor.yy984; + case 401: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==401); + case 570: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==570); +#line 96 "sql.y" +{ yylhsminor.yy24 = yymsp[0].minor.yy24; } +#line 5649 "sql.c" + yymsp[0].minor.yy24 = yylhsminor.yy24; break; case 29: /* cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt white_list_opt */ +#line 100 "sql.y" { - pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-4].minor.yy1045, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy443); - pCxt->pRootNode = addCreateUserStmtWhiteList(pCxt, pCxt->pRootNode, yymsp[0].minor.yy984); + pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-4].minor.yy929, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy823); + pCxt->pRootNode = addCreateUserStmtWhiteList(pCxt, pCxt->pRootNode, yymsp[0].minor.yy24); } +#line 5658 "sql.c" break; case 30: /* cmd ::= ALTER USER user_name PASS NK_STRING */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy1045, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +#line 104 "sql.y" +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy929, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +#line 5663 "sql.c" break; case 31: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy1045, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +#line 105 "sql.y" +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy929, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +#line 5668 "sql.c" break; case 32: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy1045, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +#line 106 "sql.y" +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy929, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +#line 5673 "sql.c" break; case 33: /* cmd ::= ALTER USER user_name ADD white_list */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy1045, TSDB_ALTER_USER_ADD_WHITE_LIST, yymsp[0].minor.yy984); } +#line 107 "sql.y" +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy929, TSDB_ALTER_USER_ADD_WHITE_LIST, yymsp[0].minor.yy24); } +#line 5678 "sql.c" break; case 34: /* cmd ::= ALTER USER user_name DROP white_list */ -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy1045, TSDB_ALTER_USER_DROP_WHITE_LIST, yymsp[0].minor.yy984); } +#line 108 "sql.y" +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy929, TSDB_ALTER_USER_DROP_WHITE_LIST, yymsp[0].minor.yy24); } +#line 5683 "sql.c" break; case 35: /* cmd ::= DROP USER user_name */ -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy1045); } +#line 109 "sql.y" +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy929); } +#line 5688 "sql.c" break; case 36: /* sysinfo_opt ::= */ -{ yymsp[1].minor.yy443 = 1; } +#line 113 "sql.y" +{ yymsp[1].minor.yy823 = 1; } +#line 5693 "sql.c" break; case 37: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ -{ yymsp[-1].minor.yy443 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +#line 114 "sql.y" +{ yymsp[-1].minor.yy823 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +#line 5698 "sql.c" break; case 38: /* cmd ::= GRANT privileges ON priv_level with_opt TO user_name */ -{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-5].minor.yy817, &yymsp[-3].minor.yy525, &yymsp[0].minor.yy1045, yymsp[-2].minor.yy720); } +#line 117 "sql.y" +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-5].minor.yy157, &yymsp[-3].minor.yy505, &yymsp[0].minor.yy929, yymsp[-2].minor.yy40); } +#line 5703 "sql.c" break; case 39: /* cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-5].minor.yy817, &yymsp[-3].minor.yy525, &yymsp[0].minor.yy1045, yymsp[-2].minor.yy720); } +#line 118 "sql.y" +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-5].minor.yy157, &yymsp[-3].minor.yy505, &yymsp[0].minor.yy929, yymsp[-2].minor.yy40); } +#line 5708 "sql.c" break; case 40: /* privileges ::= ALL */ -{ yymsp[0].minor.yy817 = PRIVILEGE_TYPE_ALL; } +#line 122 "sql.y" +{ yymsp[0].minor.yy157 = PRIVILEGE_TYPE_ALL; } +#line 5713 "sql.c" break; case 41: /* privileges ::= priv_type_list */ case 43: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==43); -{ yylhsminor.yy817 = yymsp[0].minor.yy817; } - yymsp[0].minor.yy817 = yylhsminor.yy817; +#line 123 "sql.y" +{ yylhsminor.yy157 = yymsp[0].minor.yy157; } +#line 5719 "sql.c" + yymsp[0].minor.yy157 = yylhsminor.yy157; break; case 42: /* privileges ::= SUBSCRIBE */ -{ yymsp[0].minor.yy817 = PRIVILEGE_TYPE_SUBSCRIBE; } +#line 124 "sql.y" +{ yymsp[0].minor.yy157 = PRIVILEGE_TYPE_SUBSCRIBE; } +#line 5725 "sql.c" break; case 44: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ -{ yylhsminor.yy817 = yymsp[-2].minor.yy817 | yymsp[0].minor.yy817; } - yymsp[-2].minor.yy817 = yylhsminor.yy817; +#line 129 "sql.y" +{ yylhsminor.yy157 = yymsp[-2].minor.yy157 | yymsp[0].minor.yy157; } +#line 5730 "sql.c" + yymsp[-2].minor.yy157 = yylhsminor.yy157; break; case 45: /* priv_type ::= READ */ -{ yymsp[0].minor.yy817 = PRIVILEGE_TYPE_READ; } +#line 133 "sql.y" +{ yymsp[0].minor.yy157 = PRIVILEGE_TYPE_READ; } +#line 5736 "sql.c" break; case 46: /* priv_type ::= WRITE */ -{ yymsp[0].minor.yy817 = PRIVILEGE_TYPE_WRITE; } +#line 134 "sql.y" +{ yymsp[0].minor.yy157 = PRIVILEGE_TYPE_WRITE; } +#line 5741 "sql.c" break; case 47: /* priv_type ::= ALTER */ -{ yymsp[0].minor.yy817 = PRIVILEGE_TYPE_ALTER; } +#line 135 "sql.y" +{ yymsp[0].minor.yy157 = PRIVILEGE_TYPE_ALTER; } +#line 5746 "sql.c" break; case 48: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ -{ yylhsminor.yy525.first = yymsp[-2].minor.yy0; yylhsminor.yy525.second = yymsp[0].minor.yy0; } - yymsp[-2].minor.yy525 = yylhsminor.yy525; +#line 139 "sql.y" +{ yylhsminor.yy505.first = yymsp[-2].minor.yy0; yylhsminor.yy505.second = yymsp[0].minor.yy0; } +#line 5751 "sql.c" + yymsp[-2].minor.yy505 = yylhsminor.yy505; break; case 49: /* priv_level ::= db_name NK_DOT NK_STAR */ -{ yylhsminor.yy525.first = yymsp[-2].minor.yy1045; yylhsminor.yy525.second = yymsp[0].minor.yy0; } - yymsp[-2].minor.yy525 = yylhsminor.yy525; +#line 140 "sql.y" +{ yylhsminor.yy505.first = yymsp[-2].minor.yy929; yylhsminor.yy505.second = yymsp[0].minor.yy0; } +#line 5757 "sql.c" + yymsp[-2].minor.yy505 = yylhsminor.yy505; break; case 50: /* priv_level ::= db_name NK_DOT table_name */ -{ yylhsminor.yy525.first = yymsp[-2].minor.yy1045; yylhsminor.yy525.second = yymsp[0].minor.yy1045; } - yymsp[-2].minor.yy525 = yylhsminor.yy525; +#line 141 "sql.y" +{ yylhsminor.yy505.first = yymsp[-2].minor.yy929; yylhsminor.yy505.second = yymsp[0].minor.yy929; } +#line 5763 "sql.c" + yymsp[-2].minor.yy505 = yylhsminor.yy505; break; case 51: /* priv_level ::= topic_name */ -{ yylhsminor.yy525.first = yymsp[0].minor.yy1045; yylhsminor.yy525.second = nil_token; } - yymsp[0].minor.yy525 = yylhsminor.yy525; +#line 142 "sql.y" +{ yylhsminor.yy505.first = yymsp[0].minor.yy929; yylhsminor.yy505.second = nil_token; } +#line 5769 "sql.c" + yymsp[0].minor.yy505 = yylhsminor.yy505; break; case 52: /* with_opt ::= */ case 165: /* start_opt ::= */ yytestcase(yyruleno==165); case 169: /* end_opt ::= */ yytestcase(yyruleno==169); case 316: /* like_pattern_opt ::= */ yytestcase(yyruleno==316); - case 405: /* subtable_opt ::= */ yytestcase(yyruleno==405); - case 572: /* case_when_else_opt ::= */ yytestcase(yyruleno==572); - case 602: /* from_clause_opt ::= */ yytestcase(yyruleno==602); - case 629: /* join_on_clause_opt ::= */ yytestcase(yyruleno==629); - case 631: /* window_offset_clause_opt ::= */ yytestcase(yyruleno==631); - case 635: /* jlimit_clause_opt ::= */ yytestcase(yyruleno==635); - case 652: /* where_clause_opt ::= */ yytestcase(yyruleno==652); - case 661: /* twindow_clause_opt ::= */ yytestcase(yyruleno==661); - case 669: /* sliding_opt ::= */ yytestcase(yyruleno==669); - case 674: /* fill_opt ::= */ yytestcase(yyruleno==674); - case 688: /* having_clause_opt ::= */ yytestcase(yyruleno==688); - case 690: /* range_opt ::= */ yytestcase(yyruleno==690); - case 693: /* every_opt ::= */ yytestcase(yyruleno==693); - case 706: /* slimit_clause_opt ::= */ yytestcase(yyruleno==706); - case 710: /* limit_clause_opt ::= */ yytestcase(yyruleno==710); -{ yymsp[1].minor.yy720 = NULL; } + case 412: /* subtable_opt ::= */ yytestcase(yyruleno==412); + case 580: /* case_when_else_opt ::= */ yytestcase(yyruleno==580); + case 610: /* from_clause_opt ::= */ yytestcase(yyruleno==610); + case 637: /* join_on_clause_opt ::= */ yytestcase(yyruleno==637); + case 639: /* window_offset_clause_opt ::= */ yytestcase(yyruleno==639); + case 643: /* jlimit_clause_opt ::= */ yytestcase(yyruleno==643); + case 660: /* where_clause_opt ::= */ yytestcase(yyruleno==660); + case 669: /* twindow_clause_opt ::= */ yytestcase(yyruleno==669); + case 677: /* sliding_opt ::= */ yytestcase(yyruleno==677); + case 682: /* fill_opt ::= */ yytestcase(yyruleno==682); + case 696: /* having_clause_opt ::= */ yytestcase(yyruleno==696); + case 698: /* range_opt ::= */ yytestcase(yyruleno==698); + case 701: /* every_opt ::= */ yytestcase(yyruleno==701); + case 714: /* slimit_clause_opt ::= */ yytestcase(yyruleno==714); + case 718: /* limit_clause_opt ::= */ yytestcase(yyruleno==718); +#line 144 "sql.y" +{ yymsp[1].minor.yy40 = NULL; } +#line 5793 "sql.c" break; case 53: /* with_opt ::= WITH search_condition */ - case 603: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==603); - case 630: /* join_on_clause_opt ::= ON search_condition */ yytestcase(yyruleno==630); - case 653: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==653); - case 689: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==689); -{ yymsp[-1].minor.yy720 = yymsp[0].minor.yy720; } + case 611: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==611); + case 638: /* join_on_clause_opt ::= ON search_condition */ yytestcase(yyruleno==638); + case 661: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==661); + case 697: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==697); +#line 145 "sql.y" +{ yymsp[-1].minor.yy40 = yymsp[0].minor.yy40; } +#line 5802 "sql.c" break; case 54: /* cmd ::= CREATE DNODE dnode_endpoint */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy1045, NULL); } +#line 148 "sql.y" +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy929, NULL); } +#line 5807 "sql.c" break; case 55: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy1045, &yymsp[0].minor.yy0); } +#line 149 "sql.y" +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy0); } +#line 5812 "sql.c" break; case 56: /* cmd ::= DROP DNODE NK_INTEGER force_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy833, false); } +#line 150 "sql.y" +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy1049, false); } +#line 5817 "sql.c" break; case 57: /* cmd ::= DROP DNODE dnode_endpoint force_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy1045, yymsp[0].minor.yy833, false); } +#line 151 "sql.y" +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy929, yymsp[0].minor.yy1049, false); } +#line 5822 "sql.c" break; case 58: /* cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, false, yymsp[0].minor.yy833); } +#line 152 "sql.y" +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, false, yymsp[0].minor.yy1049); } +#line 5827 "sql.c" break; case 59: /* cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy1045, false, yymsp[0].minor.yy833); } +#line 153 "sql.y" +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy929, false, yymsp[0].minor.yy1049); } +#line 5832 "sql.c" break; case 60: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ +#line 154 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, NULL); } +#line 5837 "sql.c" break; case 61: /* cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ +#line 155 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, &yymsp[-2].minor.yy0, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } +#line 5842 "sql.c" break; case 62: /* cmd ::= ALTER ALL DNODES NK_STRING */ +#line 156 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[0].minor.yy0, NULL); } +#line 5847 "sql.c" break; case 63: /* cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ +#line 157 "sql.y" { pCxt->pRootNode = createAlterDnodeStmt(pCxt, NULL, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } +#line 5852 "sql.c" break; case 64: /* cmd ::= RESTORE DNODE NK_INTEGER */ +#line 158 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_DNODE_STMT, &yymsp[0].minor.yy0); } +#line 5857 "sql.c" break; case 65: /* dnode_endpoint ::= NK_STRING */ case 66: /* dnode_endpoint ::= NK_ID */ yytestcase(yyruleno==66); case 67: /* dnode_endpoint ::= NK_IPTOKEN */ yytestcase(yyruleno==67); - case 343: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==343); - case 344: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==344); - case 345: /* sma_func_name ::= LAST */ yytestcase(yyruleno==345); - case 346: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==346); - case 492: /* db_name ::= NK_ID */ yytestcase(yyruleno==492); - case 493: /* table_name ::= NK_ID */ yytestcase(yyruleno==493); - case 494: /* column_name ::= NK_ID */ yytestcase(yyruleno==494); - case 495: /* function_name ::= NK_ID */ yytestcase(yyruleno==495); - case 496: /* view_name ::= NK_ID */ yytestcase(yyruleno==496); - case 497: /* table_alias ::= NK_ID */ yytestcase(yyruleno==497); - case 498: /* column_alias ::= NK_ID */ yytestcase(yyruleno==498); - case 499: /* column_alias ::= NK_ALIAS */ yytestcase(yyruleno==499); - case 500: /* user_name ::= NK_ID */ yytestcase(yyruleno==500); - case 501: /* topic_name ::= NK_ID */ yytestcase(yyruleno==501); - case 502: /* stream_name ::= NK_ID */ yytestcase(yyruleno==502); - case 503: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==503); - case 504: /* index_name ::= NK_ID */ yytestcase(yyruleno==504); - case 548: /* noarg_func ::= NOW */ yytestcase(yyruleno==548); - case 549: /* noarg_func ::= TODAY */ yytestcase(yyruleno==549); - case 550: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==550); - case 551: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==551); - case 552: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==552); - case 553: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==553); - case 554: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==554); - case 555: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==555); - case 556: /* noarg_func ::= USER */ yytestcase(yyruleno==556); - case 557: /* star_func ::= COUNT */ yytestcase(yyruleno==557); - case 558: /* star_func ::= FIRST */ yytestcase(yyruleno==558); - case 559: /* star_func ::= LAST */ yytestcase(yyruleno==559); - case 560: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==560); -{ yylhsminor.yy1045 = yymsp[0].minor.yy0; } - yymsp[0].minor.yy1045 = yylhsminor.yy1045; + case 350: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==350); + case 351: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==351); + case 352: /* sma_func_name ::= LAST */ yytestcase(yyruleno==352); + case 353: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==353); + case 499: /* db_name ::= NK_ID */ yytestcase(yyruleno==499); + case 500: /* table_name ::= NK_ID */ yytestcase(yyruleno==500); + case 501: /* column_name ::= NK_ID */ yytestcase(yyruleno==501); + case 502: /* function_name ::= NK_ID */ yytestcase(yyruleno==502); + case 503: /* view_name ::= NK_ID */ yytestcase(yyruleno==503); + case 504: /* table_alias ::= NK_ID */ yytestcase(yyruleno==504); + case 505: /* column_alias ::= NK_ID */ yytestcase(yyruleno==505); + case 506: /* column_alias ::= NK_ALIAS */ yytestcase(yyruleno==506); + case 507: /* user_name ::= NK_ID */ yytestcase(yyruleno==507); + case 508: /* topic_name ::= NK_ID */ yytestcase(yyruleno==508); + case 509: /* stream_name ::= NK_ID */ yytestcase(yyruleno==509); + case 510: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==510); + case 511: /* index_name ::= NK_ID */ yytestcase(yyruleno==511); + case 512: /* tsma_name ::= NK_ID */ yytestcase(yyruleno==512); + case 556: /* noarg_func ::= NOW */ yytestcase(yyruleno==556); + case 557: /* noarg_func ::= TODAY */ yytestcase(yyruleno==557); + case 558: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==558); + case 559: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==559); + case 560: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==560); + case 561: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==561); + case 562: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==562); + case 563: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==563); + case 564: /* noarg_func ::= USER */ yytestcase(yyruleno==564); + case 565: /* star_func ::= COUNT */ yytestcase(yyruleno==565); + case 566: /* star_func ::= FIRST */ yytestcase(yyruleno==566); + case 567: /* star_func ::= LAST */ yytestcase(yyruleno==567); + case 568: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==568); +#line 162 "sql.y" +{ yylhsminor.yy929 = yymsp[0].minor.yy0; } +#line 5895 "sql.c" + yymsp[0].minor.yy929 = yylhsminor.yy929; break; case 68: /* force_opt ::= */ case 95: /* not_exists_opt ::= */ yytestcase(yyruleno==95); case 97: /* exists_opt ::= */ yytestcase(yyruleno==97); - case 364: /* analyze_opt ::= */ yytestcase(yyruleno==364); - case 371: /* agg_func_opt ::= */ yytestcase(yyruleno==371); - case 377: /* or_replace_opt ::= */ yytestcase(yyruleno==377); - case 407: /* ignore_opt ::= */ yytestcase(yyruleno==407); - case 640: /* tag_mode_opt ::= */ yytestcase(yyruleno==640); - case 642: /* set_quantifier_opt ::= */ yytestcase(yyruleno==642); -{ yymsp[1].minor.yy833 = false; } + case 371: /* analyze_opt ::= */ yytestcase(yyruleno==371); + case 378: /* agg_func_opt ::= */ yytestcase(yyruleno==378); + case 384: /* or_replace_opt ::= */ yytestcase(yyruleno==384); + case 414: /* ignore_opt ::= */ yytestcase(yyruleno==414); + case 648: /* tag_mode_opt ::= */ yytestcase(yyruleno==648); + case 650: /* set_quantifier_opt ::= */ yytestcase(yyruleno==650); +#line 168 "sql.y" +{ yymsp[1].minor.yy1049 = false; } +#line 5909 "sql.c" break; case 69: /* force_opt ::= FORCE */ case 70: /* unsafe_opt ::= UNSAFE */ yytestcase(yyruleno==70); - case 365: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==365); - case 372: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==372); - case 641: /* tag_mode_opt ::= TAGS */ yytestcase(yyruleno==641); - case 643: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==643); -{ yymsp[0].minor.yy833 = true; } + case 372: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==372); + case 379: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==379); + case 649: /* tag_mode_opt ::= TAGS */ yytestcase(yyruleno==649); + case 651: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==651); +#line 169 "sql.y" +{ yymsp[0].minor.yy1049 = true; } +#line 5919 "sql.c" break; case 71: /* cmd ::= ALTER CLUSTER NK_STRING */ +#line 176 "sql.y" { pCxt->pRootNode = createAlterClusterStmt(pCxt, &yymsp[0].minor.yy0, NULL); } +#line 5924 "sql.c" break; case 72: /* cmd ::= ALTER CLUSTER NK_STRING NK_STRING */ +#line 177 "sql.y" { pCxt->pRootNode = createAlterClusterStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } +#line 5929 "sql.c" break; case 73: /* cmd ::= ALTER LOCAL NK_STRING */ +#line 180 "sql.y" { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } +#line 5934 "sql.c" break; case 74: /* cmd ::= ALTER LOCAL NK_STRING NK_STRING */ +#line 181 "sql.y" { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } +#line 5939 "sql.c" break; case 75: /* cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ +#line 184 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_QNODE_STMT, &yymsp[0].minor.yy0); } +#line 5944 "sql.c" break; case 76: /* cmd ::= DROP QNODE ON DNODE NK_INTEGER */ +#line 185 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_QNODE_STMT, &yymsp[0].minor.yy0); } +#line 5949 "sql.c" break; case 77: /* cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ +#line 186 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_QNODE_STMT, &yymsp[0].minor.yy0); } +#line 5954 "sql.c" break; case 78: /* cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ +#line 189 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_BNODE_STMT, &yymsp[0].minor.yy0); } +#line 5959 "sql.c" break; case 79: /* cmd ::= DROP BNODE ON DNODE NK_INTEGER */ +#line 190 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_BNODE_STMT, &yymsp[0].minor.yy0); } +#line 5964 "sql.c" break; case 80: /* cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ +#line 193 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_SNODE_STMT, &yymsp[0].minor.yy0); } +#line 5969 "sql.c" break; case 81: /* cmd ::= DROP SNODE ON DNODE NK_INTEGER */ +#line 194 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_SNODE_STMT, &yymsp[0].minor.yy0); } +#line 5974 "sql.c" break; case 82: /* cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ +#line 197 "sql.y" { pCxt->pRootNode = createCreateComponentNodeStmt(pCxt, QUERY_NODE_CREATE_MNODE_STMT, &yymsp[0].minor.yy0); } +#line 5979 "sql.c" break; case 83: /* cmd ::= DROP MNODE ON DNODE NK_INTEGER */ +#line 198 "sql.y" { pCxt->pRootNode = createDropComponentNodeStmt(pCxt, QUERY_NODE_DROP_MNODE_STMT, &yymsp[0].minor.yy0); } +#line 5984 "sql.c" break; case 84: /* cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ +#line 199 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_MNODE_STMT, &yymsp[0].minor.yy0); } +#line 5989 "sql.c" break; case 85: /* cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ +#line 202 "sql.y" { pCxt->pRootNode = createRestoreComponentNodeStmt(pCxt, QUERY_NODE_RESTORE_VNODE_STMT, &yymsp[0].minor.yy0); } +#line 5994 "sql.c" break; case 86: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy833, &yymsp[-1].minor.yy1045, yymsp[0].minor.yy720); } +#line 205 "sql.y" +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy1049, &yymsp[-1].minor.yy929, yymsp[0].minor.yy40); } +#line 5999 "sql.c" break; case 87: /* cmd ::= DROP DATABASE exists_opt db_name */ -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy833, &yymsp[0].minor.yy1045); } +#line 206 "sql.y" +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy1049, &yymsp[0].minor.yy929); } +#line 6004 "sql.c" break; case 88: /* cmd ::= USE db_name */ -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy1045); } +#line 207 "sql.y" +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy929); } +#line 6009 "sql.c" break; case 89: /* cmd ::= ALTER DATABASE db_name alter_db_options */ -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy1045, yymsp[0].minor.yy720); } +#line 208 "sql.y" +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy929, yymsp[0].minor.yy40); } +#line 6014 "sql.c" break; case 90: /* cmd ::= FLUSH DATABASE db_name */ -{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy1045); } +#line 209 "sql.y" +{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy929); } +#line 6019 "sql.c" break; case 91: /* cmd ::= TRIM DATABASE db_name speed_opt */ -{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy1045, yymsp[0].minor.yy488); } +#line 210 "sql.y" +{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy929, yymsp[0].minor.yy516); } +#line 6024 "sql.c" break; case 92: /* cmd ::= S3MIGRATE DATABASE db_name */ -{ pCxt->pRootNode = createS3MigrateDatabaseStmt(pCxt, &yymsp[0].minor.yy1045); } +#line 211 "sql.y" +{ pCxt->pRootNode = createS3MigrateDatabaseStmt(pCxt, &yymsp[0].minor.yy929); } +#line 6029 "sql.c" break; case 93: /* cmd ::= COMPACT DATABASE db_name start_opt end_opt */ -{ pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy1045, yymsp[-1].minor.yy720, yymsp[0].minor.yy720); } +#line 212 "sql.y" +{ pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy929, yymsp[-1].minor.yy40, yymsp[0].minor.yy40); } +#line 6034 "sql.c" break; case 94: /* not_exists_opt ::= IF NOT EXISTS */ -{ yymsp[-2].minor.yy833 = true; } +#line 216 "sql.y" +{ yymsp[-2].minor.yy1049 = true; } +#line 6039 "sql.c" break; case 96: /* exists_opt ::= IF EXISTS */ - case 378: /* or_replace_opt ::= OR REPLACE */ yytestcase(yyruleno==378); - case 408: /* ignore_opt ::= IGNORE UNTREATED */ yytestcase(yyruleno==408); -{ yymsp[-1].minor.yy833 = true; } + case 385: /* or_replace_opt ::= OR REPLACE */ yytestcase(yyruleno==385); + case 415: /* ignore_opt ::= IGNORE UNTREATED */ yytestcase(yyruleno==415); +#line 221 "sql.y" +{ yymsp[-1].minor.yy1049 = true; } +#line 6046 "sql.c" break; case 98: /* db_options ::= */ -{ yymsp[1].minor.yy720 = createDefaultDatabaseOptions(pCxt); } +#line 224 "sql.y" +{ yymsp[1].minor.yy40 = createDefaultDatabaseOptions(pCxt); } +#line 6051 "sql.c" break; case 99: /* db_options ::= db_options BUFFER NK_INTEGER */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 225 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } +#line 6056 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 100: /* db_options ::= db_options CACHEMODEL NK_STRING */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 226 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } +#line 6062 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 101: /* db_options ::= db_options CACHESIZE NK_INTEGER */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 227 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } +#line 6068 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 102: /* db_options ::= db_options COMP NK_INTEGER */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_COMP, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 228 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_COMP, &yymsp[0].minor.yy0); } +#line 6074 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 103: /* db_options ::= db_options DURATION NK_INTEGER */ case 104: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==104); -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 229 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } +#line 6081 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 105: /* db_options ::= db_options MAXROWS NK_INTEGER */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 231 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } +#line 6087 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 106: /* db_options ::= db_options MINROWS NK_INTEGER */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 232 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } +#line 6093 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 107: /* db_options ::= db_options KEEP integer_list */ case 108: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==108); -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_KEEP, yymsp[0].minor.yy984); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 233 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_KEEP, yymsp[0].minor.yy24); } +#line 6100 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 109: /* db_options ::= db_options PAGES NK_INTEGER */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 235 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } +#line 6106 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 110: /* db_options ::= db_options PAGESIZE NK_INTEGER */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 236 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } +#line 6112 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 111: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 237 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } +#line 6118 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 112: /* db_options ::= db_options PRECISION NK_STRING */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 238 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } +#line 6124 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 113: /* db_options ::= db_options REPLICA NK_INTEGER */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 239 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } +#line 6130 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 114: /* db_options ::= db_options VGROUPS NK_INTEGER */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 241 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } +#line 6136 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 115: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 242 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } +#line 6142 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 116: /* db_options ::= db_options RETENTIONS retention_list */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_RETENTIONS, yymsp[0].minor.yy984); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 243 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_RETENTIONS, yymsp[0].minor.yy24); } +#line 6148 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 117: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 244 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } +#line 6154 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 118: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_WAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 245 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_WAL, &yymsp[0].minor.yy0); } +#line 6160 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 119: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 246 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } +#line 6166 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 120: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 247 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } +#line 6172 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 121: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ +#line 248 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-3].minor.yy720, DB_OPTION_WAL_RETENTION_PERIOD, &t); + yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-3].minor.yy40, DB_OPTION_WAL_RETENTION_PERIOD, &t); } - yymsp[-3].minor.yy720 = yylhsminor.yy720; +#line 6182 "sql.c" + yymsp[-3].minor.yy40 = yylhsminor.yy40; break; case 122: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 253 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } +#line 6188 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 123: /* db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ +#line 254 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-3].minor.yy720, DB_OPTION_WAL_RETENTION_SIZE, &t); + yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-3].minor.yy40, DB_OPTION_WAL_RETENTION_SIZE, &t); } - yymsp[-3].minor.yy720 = yylhsminor.yy720; +#line 6198 "sql.c" + yymsp[-3].minor.yy40 = yylhsminor.yy40; break; case 124: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 259 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } +#line 6204 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 125: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 260 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } +#line 6210 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 126: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 261 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } +#line 6216 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 127: /* db_options ::= db_options TABLE_PREFIX signed */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_TABLE_PREFIX, yymsp[0].minor.yy720); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 262 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_TABLE_PREFIX, yymsp[0].minor.yy40); } +#line 6222 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 128: /* db_options ::= db_options TABLE_SUFFIX signed */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_TABLE_SUFFIX, yymsp[0].minor.yy720); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 263 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_TABLE_SUFFIX, yymsp[0].minor.yy40); } +#line 6228 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 129: /* db_options ::= db_options S3_CHUNKSIZE NK_INTEGER */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_S3_CHUNKSIZE, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 264 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_S3_CHUNKSIZE, &yymsp[0].minor.yy0); } +#line 6234 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 130: /* db_options ::= db_options S3_KEEPLOCAL NK_INTEGER */ case 131: /* db_options ::= db_options S3_KEEPLOCAL NK_VARIABLE */ yytestcase(yyruleno==131); -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_S3_KEEPLOCAL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 265 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_S3_KEEPLOCAL, &yymsp[0].minor.yy0); } +#line 6241 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 132: /* db_options ::= db_options S3_COMPACT NK_INTEGER */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_S3_COMPACT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 267 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_S3_COMPACT, &yymsp[0].minor.yy0); } +#line 6247 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 133: /* db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ -{ yylhsminor.yy720 = setDatabaseOption(pCxt, yymsp[-2].minor.yy720, DB_OPTION_KEEP_TIME_OFFSET, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 268 "sql.y" +{ yylhsminor.yy40 = setDatabaseOption(pCxt, yymsp[-2].minor.yy40, DB_OPTION_KEEP_TIME_OFFSET, &yymsp[0].minor.yy0); } +#line 6253 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 134: /* alter_db_options ::= alter_db_option */ -{ yylhsminor.yy720 = createAlterDatabaseOptions(pCxt); yylhsminor.yy720 = setAlterDatabaseOption(pCxt, yylhsminor.yy720, &yymsp[0].minor.yy5); } - yymsp[0].minor.yy720 = yylhsminor.yy720; +#line 270 "sql.y" +{ yylhsminor.yy40 = createAlterDatabaseOptions(pCxt); yylhsminor.yy40 = setAlterDatabaseOption(pCxt, yylhsminor.yy40, &yymsp[0].minor.yy733); } +#line 6259 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; case 135: /* alter_db_options ::= alter_db_options alter_db_option */ -{ yylhsminor.yy720 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy720, &yymsp[0].minor.yy5); } - yymsp[-1].minor.yy720 = yylhsminor.yy720; +#line 271 "sql.y" +{ yylhsminor.yy40 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy40, &yymsp[0].minor.yy733); } +#line 6265 "sql.c" + yymsp[-1].minor.yy40 = yylhsminor.yy40; break; case 136: /* alter_db_option ::= BUFFER NK_INTEGER */ -{ yymsp[-1].minor.yy5.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy5.val = yymsp[0].minor.yy0; } +#line 275 "sql.y" +{ yymsp[-1].minor.yy733.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy733.val = yymsp[0].minor.yy0; } +#line 6271 "sql.c" break; case 137: /* alter_db_option ::= CACHEMODEL NK_STRING */ -{ yymsp[-1].minor.yy5.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy5.val = yymsp[0].minor.yy0; } +#line 276 "sql.y" +{ yymsp[-1].minor.yy733.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy733.val = yymsp[0].minor.yy0; } +#line 6276 "sql.c" break; case 138: /* alter_db_option ::= CACHESIZE NK_INTEGER */ -{ yymsp[-1].minor.yy5.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy5.val = yymsp[0].minor.yy0; } +#line 277 "sql.y" +{ yymsp[-1].minor.yy733.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy733.val = yymsp[0].minor.yy0; } +#line 6281 "sql.c" break; case 139: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ -{ yymsp[-1].minor.yy5.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy5.val = yymsp[0].minor.yy0; } +#line 278 "sql.y" +{ yymsp[-1].minor.yy733.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy733.val = yymsp[0].minor.yy0; } +#line 6286 "sql.c" break; case 140: /* alter_db_option ::= KEEP integer_list */ case 141: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==141); -{ yymsp[-1].minor.yy5.type = DB_OPTION_KEEP; yymsp[-1].minor.yy5.pList = yymsp[0].minor.yy984; } +#line 279 "sql.y" +{ yymsp[-1].minor.yy733.type = DB_OPTION_KEEP; yymsp[-1].minor.yy733.pList = yymsp[0].minor.yy24; } +#line 6292 "sql.c" break; case 142: /* alter_db_option ::= PAGES NK_INTEGER */ -{ yymsp[-1].minor.yy5.type = DB_OPTION_PAGES; yymsp[-1].minor.yy5.val = yymsp[0].minor.yy0; } +#line 281 "sql.y" +{ yymsp[-1].minor.yy733.type = DB_OPTION_PAGES; yymsp[-1].minor.yy733.val = yymsp[0].minor.yy0; } +#line 6297 "sql.c" break; case 143: /* alter_db_option ::= REPLICA NK_INTEGER */ -{ yymsp[-1].minor.yy5.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy5.val = yymsp[0].minor.yy0; } +#line 282 "sql.y" +{ yymsp[-1].minor.yy733.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy733.val = yymsp[0].minor.yy0; } +#line 6302 "sql.c" break; case 144: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ -{ yymsp[-1].minor.yy5.type = DB_OPTION_WAL; yymsp[-1].minor.yy5.val = yymsp[0].minor.yy0; } +#line 284 "sql.y" +{ yymsp[-1].minor.yy733.type = DB_OPTION_WAL; yymsp[-1].minor.yy733.val = yymsp[0].minor.yy0; } +#line 6307 "sql.c" break; case 145: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ -{ yymsp[-1].minor.yy5.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy5.val = yymsp[0].minor.yy0; } +#line 285 "sql.y" +{ yymsp[-1].minor.yy733.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy733.val = yymsp[0].minor.yy0; } +#line 6312 "sql.c" break; case 146: /* alter_db_option ::= MINROWS NK_INTEGER */ -{ yymsp[-1].minor.yy5.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy5.val = yymsp[0].minor.yy0; } +#line 286 "sql.y" +{ yymsp[-1].minor.yy733.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy733.val = yymsp[0].minor.yy0; } +#line 6317 "sql.c" break; case 147: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ -{ yymsp[-1].minor.yy5.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-1].minor.yy5.val = yymsp[0].minor.yy0; } +#line 287 "sql.y" +{ yymsp[-1].minor.yy733.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-1].minor.yy733.val = yymsp[0].minor.yy0; } +#line 6322 "sql.c" break; case 148: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ +#line 288 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yymsp[-2].minor.yy5.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-2].minor.yy5.val = t; + yymsp[-2].minor.yy733.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-2].minor.yy733.val = t; } +#line 6331 "sql.c" break; case 149: /* alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ -{ yymsp[-1].minor.yy5.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-1].minor.yy5.val = yymsp[0].minor.yy0; } +#line 293 "sql.y" +{ yymsp[-1].minor.yy733.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-1].minor.yy733.val = yymsp[0].minor.yy0; } +#line 6336 "sql.c" break; case 150: /* alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ +#line 294 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yymsp[-2].minor.yy5.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-2].minor.yy5.val = t; + yymsp[-2].minor.yy733.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-2].minor.yy733.val = t; } +#line 6345 "sql.c" break; case 151: /* alter_db_option ::= S3_KEEPLOCAL NK_INTEGER */ case 152: /* alter_db_option ::= S3_KEEPLOCAL NK_VARIABLE */ yytestcase(yyruleno==152); -{ yymsp[-1].minor.yy5.type = DB_OPTION_S3_KEEPLOCAL; yymsp[-1].minor.yy5.val = yymsp[0].minor.yy0; } +#line 299 "sql.y" +{ yymsp[-1].minor.yy733.type = DB_OPTION_S3_KEEPLOCAL; yymsp[-1].minor.yy733.val = yymsp[0].minor.yy0; } +#line 6351 "sql.c" break; case 153: /* alter_db_option ::= S3_COMPACT NK_INTEGER */ -{ yymsp[-1].minor.yy5.type = DB_OPTION_S3_COMPACT, yymsp[-1].minor.yy5.val = yymsp[0].minor.yy0; } +#line 301 "sql.y" +{ yymsp[-1].minor.yy733.type = DB_OPTION_S3_COMPACT, yymsp[-1].minor.yy733.val = yymsp[0].minor.yy0; } +#line 6356 "sql.c" break; case 154: /* alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ -{ yymsp[-1].minor.yy5.type = DB_OPTION_KEEP_TIME_OFFSET; yymsp[-1].minor.yy5.val = yymsp[0].minor.yy0; } +#line 302 "sql.y" +{ yymsp[-1].minor.yy733.type = DB_OPTION_KEEP_TIME_OFFSET; yymsp[-1].minor.yy733.val = yymsp[0].minor.yy0; } +#line 6361 "sql.c" break; case 155: /* integer_list ::= NK_INTEGER */ -{ yylhsminor.yy984 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy984 = yylhsminor.yy984; +#line 306 "sql.y" +{ yylhsminor.yy24 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +#line 6366 "sql.c" + yymsp[0].minor.yy24 = yylhsminor.yy24; break; case 156: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 421: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==421); -{ yylhsminor.yy984 = addNodeToList(pCxt, yymsp[-2].minor.yy984, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy984 = yylhsminor.yy984; + case 428: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==428); +#line 307 "sql.y" +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +#line 6373 "sql.c" + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 157: /* variable_list ::= NK_VARIABLE */ -{ yylhsminor.yy984 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy984 = yylhsminor.yy984; +#line 311 "sql.y" +{ yylhsminor.yy24 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 6379 "sql.c" + yymsp[0].minor.yy24 = yylhsminor.yy24; break; case 158: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ -{ yylhsminor.yy984 = addNodeToList(pCxt, yymsp[-2].minor.yy984, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy984 = yylhsminor.yy984; +#line 312 "sql.y" +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 6385 "sql.c" + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 159: /* retention_list ::= retention */ case 190: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==190); @@ -5657,17 +6392,19 @@ static YYACTIONTYPE yy_reduce( case 249: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==249); case 254: /* col_name_list ::= col_name */ yytestcase(yyruleno==254); case 322: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==322); - case 339: /* func_list ::= func */ yytestcase(yyruleno==339); - case 389: /* column_stream_def_list ::= column_stream_def */ yytestcase(yyruleno==389); - case 465: /* tags_literal_list ::= tags_literal */ yytestcase(yyruleno==465); - case 490: /* literal_list ::= signed_literal */ yytestcase(yyruleno==490); - case 563: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==563); - case 569: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==569); - case 645: /* select_list ::= select_item */ yytestcase(yyruleno==645); - case 656: /* partition_list ::= partition_item */ yytestcase(yyruleno==656); - case 717: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==717); -{ yylhsminor.yy984 = createNodeList(pCxt, yymsp[0].minor.yy720); } - yymsp[0].minor.yy984 = yylhsminor.yy984; + case 346: /* func_list ::= func */ yytestcase(yyruleno==346); + case 396: /* column_stream_def_list ::= column_stream_def */ yytestcase(yyruleno==396); + case 472: /* tags_literal_list ::= tags_literal */ yytestcase(yyruleno==472); + case 497: /* literal_list ::= signed_literal */ yytestcase(yyruleno==497); + case 571: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==571); + case 577: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==577); + case 653: /* select_list ::= select_item */ yytestcase(yyruleno==653); + case 664: /* partition_list ::= partition_item */ yytestcase(yyruleno==664); + case 725: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==725); +#line 316 "sql.y" +{ yylhsminor.yy24 = createNodeList(pCxt, yymsp[0].minor.yy40); } +#line 6406 "sql.c" + yymsp[0].minor.yy24 = yylhsminor.yy24; break; case 160: /* retention_list ::= retention_list NK_COMMA retention */ case 194: /* multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ yytestcase(yyruleno==194); @@ -5675,1439 +6412,2164 @@ static YYACTIONTYPE yy_reduce( case 250: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==250); case 255: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==255); case 323: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==323); - case 340: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==340); - case 390: /* column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def */ yytestcase(yyruleno==390); - case 466: /* tags_literal_list ::= tags_literal_list NK_COMMA tags_literal */ yytestcase(yyruleno==466); - case 491: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==491); - case 564: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==564); - case 646: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==646); - case 657: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==657); - case 718: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==718); -{ yylhsminor.yy984 = addNodeToList(pCxt, yymsp[-2].minor.yy984, yymsp[0].minor.yy720); } - yymsp[-2].minor.yy984 = yylhsminor.yy984; + case 347: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==347); + case 397: /* column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def */ yytestcase(yyruleno==397); + case 473: /* tags_literal_list ::= tags_literal_list NK_COMMA tags_literal */ yytestcase(yyruleno==473); + case 498: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==498); + case 572: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==572); + case 654: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==654); + case 665: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==665); + case 726: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==726); +#line 317 "sql.y" +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, yymsp[0].minor.yy40); } +#line 6425 "sql.c" + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 161: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ case 162: /* retention ::= NK_MINUS NK_COLON NK_VARIABLE */ yytestcase(yyruleno==162); -{ yylhsminor.yy720 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 319 "sql.y" +{ yylhsminor.yy40 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 6432 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 163: /* speed_opt ::= */ - case 373: /* bufsize_opt ::= */ yytestcase(yyruleno==373); -{ yymsp[1].minor.yy488 = 0; } + case 380: /* bufsize_opt ::= */ yytestcase(yyruleno==380); +#line 324 "sql.y" +{ yymsp[1].minor.yy516 = 0; } +#line 6439 "sql.c" break; case 164: /* speed_opt ::= BWLIMIT NK_INTEGER */ - case 374: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==374); -{ yymsp[-1].minor.yy488 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } + case 381: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==381); +#line 325 "sql.y" +{ yymsp[-1].minor.yy516 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } +#line 6445 "sql.c" break; case 166: /* start_opt ::= START WITH NK_INTEGER */ case 170: /* end_opt ::= END WITH NK_INTEGER */ yytestcase(yyruleno==170); -{ yymsp[-2].minor.yy720 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +#line 328 "sql.y" +{ yymsp[-2].minor.yy40 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +#line 6451 "sql.c" break; case 167: /* start_opt ::= START WITH NK_STRING */ case 171: /* end_opt ::= END WITH NK_STRING */ yytestcase(yyruleno==171); -{ yymsp[-2].minor.yy720 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +#line 329 "sql.y" +{ yymsp[-2].minor.yy40 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +#line 6457 "sql.c" break; case 168: /* start_opt ::= START WITH TIMESTAMP NK_STRING */ case 172: /* end_opt ::= END WITH TIMESTAMP NK_STRING */ yytestcase(yyruleno==172); -{ yymsp[-3].minor.yy720 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +#line 330 "sql.y" +{ yymsp[-3].minor.yy40 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +#line 6463 "sql.c" break; case 173: /* cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ case 175: /* cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ yytestcase(yyruleno==175); -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy833, yymsp[-5].minor.yy720, yymsp[-3].minor.yy984, yymsp[-1].minor.yy984, yymsp[0].minor.yy720); } +#line 339 "sql.y" +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy1049, yymsp[-5].minor.yy40, yymsp[-3].minor.yy24, yymsp[-1].minor.yy24, yymsp[0].minor.yy40); } +#line 6469 "sql.c" break; case 174: /* cmd ::= CREATE TABLE multi_create_clause */ -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy984); } +#line 340 "sql.y" +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy24); } +#line 6474 "sql.c" break; case 176: /* cmd ::= DROP TABLE multi_drop_clause */ -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy984); } +#line 343 "sql.y" +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy24); } +#line 6479 "sql.c" break; case 177: /* cmd ::= DROP STABLE exists_opt full_table_name */ -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy833, yymsp[0].minor.yy720); } +#line 344 "sql.y" +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy1049, yymsp[0].minor.yy40); } +#line 6484 "sql.c" break; case 178: /* cmd ::= ALTER TABLE alter_table_clause */ - case 423: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==423); - case 424: /* cmd ::= insert_query */ yytestcase(yyruleno==424); -{ pCxt->pRootNode = yymsp[0].minor.yy720; } + case 430: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==430); + case 431: /* cmd ::= insert_query */ yytestcase(yyruleno==431); +#line 346 "sql.y" +{ pCxt->pRootNode = yymsp[0].minor.yy40; } +#line 6491 "sql.c" break; case 179: /* cmd ::= ALTER STABLE alter_table_clause */ -{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy720); } +#line 347 "sql.y" +{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy40); } +#line 6496 "sql.c" break; case 180: /* alter_table_clause ::= full_table_name alter_table_options */ -{ yylhsminor.yy720 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy720, yymsp[0].minor.yy720); } - yymsp[-1].minor.yy720 = yylhsminor.yy720; +#line 349 "sql.y" +{ yylhsminor.yy40 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy40, yymsp[0].minor.yy40); } +#line 6501 "sql.c" + yymsp[-1].minor.yy40 = yylhsminor.yy40; break; case 181: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ -{ yylhsminor.yy720 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy720, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy1045, yymsp[0].minor.yy232); } - yymsp[-4].minor.yy720 = yylhsminor.yy720; +#line 351 "sql.y" +{ yylhsminor.yy40 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy40, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy929, yymsp[0].minor.yy592); } +#line 6507 "sql.c" + yymsp[-4].minor.yy40 = yylhsminor.yy40; break; case 182: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ -{ yylhsminor.yy720 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy720, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy1045); } - yymsp[-3].minor.yy720 = yylhsminor.yy720; +#line 352 "sql.y" +{ yylhsminor.yy40 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy40, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy929); } +#line 6513 "sql.c" + yymsp[-3].minor.yy40 = yylhsminor.yy40; break; case 183: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ -{ yylhsminor.yy720 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy720, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy1045, yymsp[0].minor.yy232); } - yymsp[-4].minor.yy720 = yylhsminor.yy720; +#line 354 "sql.y" +{ yylhsminor.yy40 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy40, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy929, yymsp[0].minor.yy592); } +#line 6519 "sql.c" + yymsp[-4].minor.yy40 = yylhsminor.yy40; break; case 184: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ -{ yylhsminor.yy720 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy720, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy1045, &yymsp[0].minor.yy1045); } - yymsp[-4].minor.yy720 = yylhsminor.yy720; +#line 356 "sql.y" +{ yylhsminor.yy40 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy40, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy929, &yymsp[0].minor.yy929); } +#line 6525 "sql.c" + yymsp[-4].minor.yy40 = yylhsminor.yy40; break; case 185: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ -{ yylhsminor.yy720 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy720, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy1045, yymsp[0].minor.yy232); } - yymsp[-4].minor.yy720 = yylhsminor.yy720; +#line 358 "sql.y" +{ yylhsminor.yy40 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy40, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy929, yymsp[0].minor.yy592); } +#line 6531 "sql.c" + yymsp[-4].minor.yy40 = yylhsminor.yy40; break; case 186: /* alter_table_clause ::= full_table_name DROP TAG column_name */ -{ yylhsminor.yy720 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy720, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy1045); } - yymsp[-3].minor.yy720 = yylhsminor.yy720; +#line 359 "sql.y" +{ yylhsminor.yy40 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy40, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy929); } +#line 6537 "sql.c" + yymsp[-3].minor.yy40 = yylhsminor.yy40; break; case 187: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ -{ yylhsminor.yy720 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy720, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy1045, yymsp[0].minor.yy232); } - yymsp[-4].minor.yy720 = yylhsminor.yy720; +#line 361 "sql.y" +{ yylhsminor.yy40 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy40, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy929, yymsp[0].minor.yy592); } +#line 6543 "sql.c" + yymsp[-4].minor.yy40 = yylhsminor.yy40; break; case 188: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ -{ yylhsminor.yy720 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy720, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy1045, &yymsp[0].minor.yy1045); } - yymsp[-4].minor.yy720 = yylhsminor.yy720; +#line 363 "sql.y" +{ yylhsminor.yy40 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy40, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy929, &yymsp[0].minor.yy929); } +#line 6549 "sql.c" + yymsp[-4].minor.yy40 = yylhsminor.yy40; break; case 189: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ tags_literal */ -{ yylhsminor.yy720 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy720, &yymsp[-2].minor.yy1045, yymsp[0].minor.yy720); } - yymsp[-5].minor.yy720 = yylhsminor.yy720; +#line 365 "sql.y" +{ yylhsminor.yy40 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy40, &yymsp[-2].minor.yy929, yymsp[0].minor.yy40); } +#line 6555 "sql.c" + yymsp[-5].minor.yy40 = yylhsminor.yy40; break; case 191: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 570: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==570); -{ yylhsminor.yy984 = addNodeToList(pCxt, yymsp[-1].minor.yy984, yymsp[0].minor.yy720); } - yymsp[-1].minor.yy984 = yylhsminor.yy984; + case 578: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==578); +#line 370 "sql.y" +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-1].minor.yy24, yymsp[0].minor.yy40); } +#line 6562 "sql.c" + yymsp[-1].minor.yy24 = yylhsminor.yy24; break; case 192: /* create_subtable_clause ::= not_exists_opt full_table_name USING full_table_name specific_cols_opt TAGS NK_LP tags_literal_list NK_RP table_options */ -{ yylhsminor.yy720 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy833, yymsp[-8].minor.yy720, yymsp[-6].minor.yy720, yymsp[-5].minor.yy984, yymsp[-2].minor.yy984, yymsp[0].minor.yy720); } - yymsp[-9].minor.yy720 = yylhsminor.yy720; +#line 374 "sql.y" +{ yylhsminor.yy40 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy1049, yymsp[-8].minor.yy40, yymsp[-6].minor.yy40, yymsp[-5].minor.yy24, yymsp[-2].minor.yy24, yymsp[0].minor.yy40); } +#line 6568 "sql.c" + yymsp[-9].minor.yy40 = yylhsminor.yy40; break; case 195: /* drop_table_clause ::= exists_opt full_table_name */ -{ yylhsminor.yy720 = createDropTableClause(pCxt, yymsp[-1].minor.yy833, yymsp[0].minor.yy720); } - yymsp[-1].minor.yy720 = yylhsminor.yy720; +#line 381 "sql.y" +{ yylhsminor.yy40 = createDropTableClause(pCxt, yymsp[-1].minor.yy1049, yymsp[0].minor.yy40); } +#line 6574 "sql.c" + yymsp[-1].minor.yy40 = yylhsminor.yy40; break; case 197: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ - case 388: /* col_list_opt ::= NK_LP column_stream_def_list NK_RP */ yytestcase(yyruleno==388); -{ yymsp[-2].minor.yy984 = yymsp[-1].minor.yy984; } + case 395: /* col_list_opt ::= NK_LP column_stream_def_list NK_RP */ yytestcase(yyruleno==395); +#line 386 "sql.y" +{ yymsp[-2].minor.yy24 = yymsp[-1].minor.yy24; } +#line 6581 "sql.c" break; case 198: /* full_table_name ::= table_name */ -{ yylhsminor.yy720 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy1045, NULL); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 336: /* full_tsma_name ::= tsma_name */ yytestcase(yyruleno==336); +#line 388 "sql.y" +{ yylhsminor.yy40 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy929, NULL); } +#line 6587 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; case 199: /* full_table_name ::= db_name NK_DOT table_name */ -{ yylhsminor.yy720 = createRealTableNode(pCxt, &yymsp[-2].minor.yy1045, &yymsp[0].minor.yy1045, NULL); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 337: /* full_tsma_name ::= db_name NK_DOT tsma_name */ yytestcase(yyruleno==337); +#line 389 "sql.y" +{ yylhsminor.yy40 = createRealTableNode(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy929, NULL); } +#line 6594 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 202: /* column_def ::= column_name type_name */ -{ yylhsminor.yy720 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy1045, yymsp[0].minor.yy232, NULL, false); } - yymsp[-1].minor.yy720 = yylhsminor.yy720; +#line 396 "sql.y" +{ yylhsminor.yy40 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy929, yymsp[0].minor.yy592, NULL, false); } +#line 6600 "sql.c" + yymsp[-1].minor.yy40 = yylhsminor.yy40; break; case 203: /* column_def ::= column_name type_name PRIMARY KEY */ -{ yylhsminor.yy720 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy1045, yymsp[-2].minor.yy232, NULL, true); } - yymsp[-3].minor.yy720 = yylhsminor.yy720; +#line 397 "sql.y" +{ yylhsminor.yy40 = createColumnDefNode(pCxt, &yymsp[-3].minor.yy929, yymsp[-2].minor.yy592, NULL, true); } +#line 6606 "sql.c" + yymsp[-3].minor.yy40 = yylhsminor.yy40; break; case 204: /* type_name ::= BOOL */ -{ yymsp[0].minor.yy232 = createDataType(TSDB_DATA_TYPE_BOOL); } +#line 402 "sql.y" +{ yymsp[0].minor.yy592 = createDataType(TSDB_DATA_TYPE_BOOL); } +#line 6612 "sql.c" break; case 205: /* type_name ::= TINYINT */ -{ yymsp[0].minor.yy232 = createDataType(TSDB_DATA_TYPE_TINYINT); } +#line 403 "sql.y" +{ yymsp[0].minor.yy592 = createDataType(TSDB_DATA_TYPE_TINYINT); } +#line 6617 "sql.c" break; case 206: /* type_name ::= SMALLINT */ -{ yymsp[0].minor.yy232 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +#line 404 "sql.y" +{ yymsp[0].minor.yy592 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +#line 6622 "sql.c" break; case 207: /* type_name ::= INT */ case 208: /* type_name ::= INTEGER */ yytestcase(yyruleno==208); -{ yymsp[0].minor.yy232 = createDataType(TSDB_DATA_TYPE_INT); } +#line 405 "sql.y" +{ yymsp[0].minor.yy592 = createDataType(TSDB_DATA_TYPE_INT); } +#line 6628 "sql.c" break; case 209: /* type_name ::= BIGINT */ -{ yymsp[0].minor.yy232 = createDataType(TSDB_DATA_TYPE_BIGINT); } +#line 407 "sql.y" +{ yymsp[0].minor.yy592 = createDataType(TSDB_DATA_TYPE_BIGINT); } +#line 6633 "sql.c" break; case 210: /* type_name ::= FLOAT */ -{ yymsp[0].minor.yy232 = createDataType(TSDB_DATA_TYPE_FLOAT); } +#line 408 "sql.y" +{ yymsp[0].minor.yy592 = createDataType(TSDB_DATA_TYPE_FLOAT); } +#line 6638 "sql.c" break; case 211: /* type_name ::= DOUBLE */ -{ yymsp[0].minor.yy232 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +#line 409 "sql.y" +{ yymsp[0].minor.yy592 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +#line 6643 "sql.c" break; case 212: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy232 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +#line 410 "sql.y" +{ yymsp[-3].minor.yy592 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +#line 6648 "sql.c" break; case 213: /* type_name ::= TIMESTAMP */ -{ yymsp[0].minor.yy232 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +#line 411 "sql.y" +{ yymsp[0].minor.yy592 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +#line 6653 "sql.c" break; case 214: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy232 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +#line 412 "sql.y" +{ yymsp[-3].minor.yy592 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +#line 6658 "sql.c" break; case 215: /* type_name ::= TINYINT UNSIGNED */ -{ yymsp[-1].minor.yy232 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +#line 413 "sql.y" +{ yymsp[-1].minor.yy592 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +#line 6663 "sql.c" break; case 216: /* type_name ::= SMALLINT UNSIGNED */ -{ yymsp[-1].minor.yy232 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +#line 414 "sql.y" +{ yymsp[-1].minor.yy592 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +#line 6668 "sql.c" break; case 217: /* type_name ::= INT UNSIGNED */ -{ yymsp[-1].minor.yy232 = createDataType(TSDB_DATA_TYPE_UINT); } +#line 415 "sql.y" +{ yymsp[-1].minor.yy592 = createDataType(TSDB_DATA_TYPE_UINT); } +#line 6673 "sql.c" break; case 218: /* type_name ::= BIGINT UNSIGNED */ -{ yymsp[-1].minor.yy232 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +#line 416 "sql.y" +{ yymsp[-1].minor.yy592 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +#line 6678 "sql.c" break; case 219: /* type_name ::= JSON */ -{ yymsp[0].minor.yy232 = createDataType(TSDB_DATA_TYPE_JSON); } +#line 417 "sql.y" +{ yymsp[0].minor.yy592 = createDataType(TSDB_DATA_TYPE_JSON); } +#line 6683 "sql.c" break; case 220: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy232 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +#line 418 "sql.y" +{ yymsp[-3].minor.yy592 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +#line 6688 "sql.c" break; case 221: /* type_name ::= MEDIUMBLOB */ -{ yymsp[0].minor.yy232 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +#line 419 "sql.y" +{ yymsp[0].minor.yy592 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +#line 6693 "sql.c" break; case 222: /* type_name ::= BLOB */ -{ yymsp[0].minor.yy232 = createDataType(TSDB_DATA_TYPE_BLOB); } +#line 420 "sql.y" +{ yymsp[0].minor.yy592 = createDataType(TSDB_DATA_TYPE_BLOB); } +#line 6698 "sql.c" break; case 223: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy232 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +#line 421 "sql.y" +{ yymsp[-3].minor.yy592 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +#line 6703 "sql.c" break; case 224: /* type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy232 = createVarLenDataType(TSDB_DATA_TYPE_GEOMETRY, &yymsp[-1].minor.yy0); } +#line 422 "sql.y" +{ yymsp[-3].minor.yy592 = createVarLenDataType(TSDB_DATA_TYPE_GEOMETRY, &yymsp[-1].minor.yy0); } +#line 6708 "sql.c" break; case 225: /* type_name ::= DECIMAL */ -{ yymsp[0].minor.yy232 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 423 "sql.y" +{ yymsp[0].minor.yy592 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 6713 "sql.c" break; case 226: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy232 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 424 "sql.y" +{ yymsp[-3].minor.yy592 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 6718 "sql.c" break; case 227: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy232 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 425 "sql.y" +{ yymsp[-5].minor.yy592 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 6723 "sql.c" break; case 228: /* type_name_default_len ::= BINARY */ -{ yymsp[0].minor.yy232 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, NULL); } +#line 429 "sql.y" +{ yymsp[0].minor.yy592 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, NULL); } +#line 6728 "sql.c" break; case 229: /* type_name_default_len ::= NCHAR */ -{ yymsp[0].minor.yy232 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, NULL); } +#line 430 "sql.y" +{ yymsp[0].minor.yy592 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, NULL); } +#line 6733 "sql.c" break; case 230: /* type_name_default_len ::= VARCHAR */ -{ yymsp[0].minor.yy232 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, NULL); } +#line 431 "sql.y" +{ yymsp[0].minor.yy592 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, NULL); } +#line 6738 "sql.c" break; case 231: /* type_name_default_len ::= VARBINARY */ -{ yymsp[0].minor.yy232 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, NULL); } +#line 432 "sql.y" +{ yymsp[0].minor.yy592 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, NULL); } +#line 6743 "sql.c" break; case 234: /* tags_def ::= TAGS NK_LP column_def_list NK_RP */ - case 395: /* tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP */ yytestcase(yyruleno==395); -{ yymsp[-3].minor.yy984 = yymsp[-1].minor.yy984; } + case 402: /* tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP */ yytestcase(yyruleno==402); +#line 441 "sql.y" +{ yymsp[-3].minor.yy24 = yymsp[-1].minor.yy24; } +#line 6749 "sql.c" break; case 235: /* table_options ::= */ -{ yymsp[1].minor.yy720 = createDefaultTableOptions(pCxt); } +#line 443 "sql.y" +{ yymsp[1].minor.yy40 = createDefaultTableOptions(pCxt); } +#line 6754 "sql.c" break; case 236: /* table_options ::= table_options COMMENT NK_STRING */ -{ yylhsminor.yy720 = setTableOption(pCxt, yymsp[-2].minor.yy720, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 444 "sql.y" +{ yylhsminor.yy40 = setTableOption(pCxt, yymsp[-2].minor.yy40, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } +#line 6759 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 237: /* table_options ::= table_options MAX_DELAY duration_list */ -{ yylhsminor.yy720 = setTableOption(pCxt, yymsp[-2].minor.yy720, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy984); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 445 "sql.y" +{ yylhsminor.yy40 = setTableOption(pCxt, yymsp[-2].minor.yy40, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy24); } +#line 6765 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 238: /* table_options ::= table_options WATERMARK duration_list */ -{ yylhsminor.yy720 = setTableOption(pCxt, yymsp[-2].minor.yy720, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy984); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 446 "sql.y" +{ yylhsminor.yy40 = setTableOption(pCxt, yymsp[-2].minor.yy40, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy24); } +#line 6771 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 239: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ -{ yylhsminor.yy720 = setTableOption(pCxt, yymsp[-4].minor.yy720, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy984); } - yymsp[-4].minor.yy720 = yylhsminor.yy720; +#line 447 "sql.y" +{ yylhsminor.yy40 = setTableOption(pCxt, yymsp[-4].minor.yy40, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy24); } +#line 6777 "sql.c" + yymsp[-4].minor.yy40 = yylhsminor.yy40; break; case 240: /* table_options ::= table_options TTL NK_INTEGER */ -{ yylhsminor.yy720 = setTableOption(pCxt, yymsp[-2].minor.yy720, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 448 "sql.y" +{ yylhsminor.yy40 = setTableOption(pCxt, yymsp[-2].minor.yy40, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } +#line 6783 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 241: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ -{ yylhsminor.yy720 = setTableOption(pCxt, yymsp[-4].minor.yy720, TABLE_OPTION_SMA, yymsp[-1].minor.yy984); } - yymsp[-4].minor.yy720 = yylhsminor.yy720; +#line 449 "sql.y" +{ yylhsminor.yy40 = setTableOption(pCxt, yymsp[-4].minor.yy40, TABLE_OPTION_SMA, yymsp[-1].minor.yy24); } +#line 6789 "sql.c" + yymsp[-4].minor.yy40 = yylhsminor.yy40; break; case 242: /* table_options ::= table_options DELETE_MARK duration_list */ -{ yylhsminor.yy720 = setTableOption(pCxt, yymsp[-2].minor.yy720, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy984); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 450 "sql.y" +{ yylhsminor.yy40 = setTableOption(pCxt, yymsp[-2].minor.yy40, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy24); } +#line 6795 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 243: /* alter_table_options ::= alter_table_option */ -{ yylhsminor.yy720 = createAlterTableOptions(pCxt); yylhsminor.yy720 = setTableOption(pCxt, yylhsminor.yy720, yymsp[0].minor.yy5.type, &yymsp[0].minor.yy5.val); } - yymsp[0].minor.yy720 = yylhsminor.yy720; +#line 452 "sql.y" +{ yylhsminor.yy40 = createAlterTableOptions(pCxt); yylhsminor.yy40 = setTableOption(pCxt, yylhsminor.yy40, yymsp[0].minor.yy733.type, &yymsp[0].minor.yy733.val); } +#line 6801 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; case 244: /* alter_table_options ::= alter_table_options alter_table_option */ -{ yylhsminor.yy720 = setTableOption(pCxt, yymsp[-1].minor.yy720, yymsp[0].minor.yy5.type, &yymsp[0].minor.yy5.val); } - yymsp[-1].minor.yy720 = yylhsminor.yy720; +#line 453 "sql.y" +{ yylhsminor.yy40 = setTableOption(pCxt, yymsp[-1].minor.yy40, yymsp[0].minor.yy733.type, &yymsp[0].minor.yy733.val); } +#line 6807 "sql.c" + yymsp[-1].minor.yy40 = yylhsminor.yy40; break; case 245: /* alter_table_option ::= COMMENT NK_STRING */ -{ yymsp[-1].minor.yy5.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy5.val = yymsp[0].minor.yy0; } +#line 457 "sql.y" +{ yymsp[-1].minor.yy733.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy733.val = yymsp[0].minor.yy0; } +#line 6813 "sql.c" break; case 246: /* alter_table_option ::= TTL NK_INTEGER */ -{ yymsp[-1].minor.yy5.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy5.val = yymsp[0].minor.yy0; } +#line 458 "sql.y" +{ yymsp[-1].minor.yy733.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy733.val = yymsp[0].minor.yy0; } +#line 6818 "sql.c" break; case 247: /* duration_list ::= duration_literal */ - case 522: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==522); -{ yylhsminor.yy984 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy720)); } - yymsp[0].minor.yy984 = yylhsminor.yy984; + case 530: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==530); +#line 462 "sql.y" +{ yylhsminor.yy24 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy40)); } +#line 6824 "sql.c" + yymsp[0].minor.yy24 = yylhsminor.yy24; break; case 248: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 523: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==523); -{ yylhsminor.yy984 = addNodeToList(pCxt, yymsp[-2].minor.yy984, releaseRawExprNode(pCxt, yymsp[0].minor.yy720)); } - yymsp[-2].minor.yy984 = yylhsminor.yy984; + case 531: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==531); +#line 463 "sql.y" +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, releaseRawExprNode(pCxt, yymsp[0].minor.yy40)); } +#line 6831 "sql.c" + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; case 251: /* rollup_func_name ::= function_name */ -{ yylhsminor.yy720 = createFunctionNode(pCxt, &yymsp[0].minor.yy1045, NULL); } - yymsp[0].minor.yy720 = yylhsminor.yy720; +#line 470 "sql.y" +{ yylhsminor.yy40 = createFunctionNode(pCxt, &yymsp[0].minor.yy929, NULL); } +#line 6837 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; case 252: /* rollup_func_name ::= FIRST */ case 253: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==253); case 325: /* tag_item ::= QTAGS */ yytestcase(yyruleno==325); -{ yylhsminor.yy720 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy720 = yylhsminor.yy720; +#line 471 "sql.y" +{ yylhsminor.yy40 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } +#line 6845 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; case 256: /* col_name ::= column_name */ case 326: /* tag_item ::= column_name */ yytestcase(yyruleno==326); -{ yylhsminor.yy720 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy1045); } - yymsp[0].minor.yy720 = yylhsminor.yy720; +#line 479 "sql.y" +{ yylhsminor.yy40 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy929); } +#line 6852 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; case 257: /* cmd ::= SHOW DNODES */ +#line 482 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } +#line 6858 "sql.c" break; case 258: /* cmd ::= SHOW USERS */ +#line 483 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); } +#line 6863 "sql.c" break; case 259: /* cmd ::= SHOW USER PRIVILEGES */ +#line 484 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USER_PRIVILEGES_STMT); } +#line 6868 "sql.c" break; case 260: /* cmd ::= SHOW db_kind_opt DATABASES */ +#line 485 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); - setShowKind(pCxt, pCxt->pRootNode, yymsp[-1].minor.yy1029); + setShowKind(pCxt, pCxt->pRootNode, yymsp[-1].minor.yy769); } +#line 6876 "sql.c" break; case 261: /* cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ +#line 489 "sql.y" { - pCxt->pRootNode = createShowTablesStmt(pCxt, yymsp[-2].minor.yy165, yymsp[0].minor.yy720, OP_TYPE_LIKE); + pCxt->pRootNode = createShowTablesStmt(pCxt, yymsp[-2].minor.yy685, yymsp[0].minor.yy40, OP_TYPE_LIKE); } +#line 6883 "sql.c" break; case 262: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy720, yymsp[0].minor.yy720, OP_TYPE_LIKE); } +#line 492 "sql.y" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy40, yymsp[0].minor.yy40, OP_TYPE_LIKE); } +#line 6888 "sql.c" break; case 263: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy720, NULL, OP_TYPE_LIKE); } +#line 493 "sql.y" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy40, NULL, OP_TYPE_LIKE); } +#line 6893 "sql.c" break; case 264: /* cmd ::= SHOW MNODES */ +#line 494 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } +#line 6898 "sql.c" break; case 265: /* cmd ::= SHOW QNODES */ +#line 496 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); } +#line 6903 "sql.c" break; case 266: /* cmd ::= SHOW ARBGROUPS */ +#line 497 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_ARBGROUPS_STMT); } +#line 6908 "sql.c" break; case 267: /* cmd ::= SHOW FUNCTIONS */ +#line 498 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } +#line 6913 "sql.c" break; case 268: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy720, yymsp[-1].minor.yy720, OP_TYPE_EQUAL); } +#line 499 "sql.y" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy40, yymsp[-1].minor.yy40, OP_TYPE_EQUAL); } +#line 6918 "sql.c" break; case 269: /* cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy1045), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy1045), OP_TYPE_EQUAL); } +#line 500 "sql.y" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy929), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy929), OP_TYPE_EQUAL); } +#line 6923 "sql.c" break; case 270: /* cmd ::= SHOW STREAMS */ +#line 501 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } +#line 6928 "sql.c" break; case 271: /* cmd ::= SHOW ACCOUNTS */ +#line 502 "sql.y" { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } +#line 6933 "sql.c" break; case 272: /* cmd ::= SHOW APPS */ +#line 503 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); } +#line 6938 "sql.c" break; case 273: /* cmd ::= SHOW CONNECTIONS */ +#line 504 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); } +#line 6943 "sql.c" break; case 274: /* cmd ::= SHOW LICENCES */ case 275: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==275); +#line 505 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); } +#line 6949 "sql.c" break; case 276: /* cmd ::= SHOW GRANTS FULL */ +#line 507 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_GRANTS_FULL_STMT); } +#line 6954 "sql.c" break; case 277: /* cmd ::= SHOW GRANTS LOGS */ +#line 508 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_GRANTS_LOGS_STMT); } +#line 6959 "sql.c" break; case 278: /* cmd ::= SHOW CLUSTER MACHINES */ +#line 509 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT); } +#line 6964 "sql.c" break; case 279: /* cmd ::= SHOW CREATE DATABASE db_name */ -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy1045); } +#line 510 "sql.y" +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy929); } +#line 6969 "sql.c" break; case 280: /* cmd ::= SHOW CREATE TABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy720); } +#line 511 "sql.y" +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy40); } +#line 6974 "sql.c" break; case 281: /* cmd ::= SHOW CREATE STABLE full_table_name */ -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy720); } +#line 512 "sql.y" +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy40); } +#line 6979 "sql.c" break; case 282: /* cmd ::= SHOW QUERIES */ +#line 513 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } +#line 6984 "sql.c" break; case 283: /* cmd ::= SHOW SCORES */ +#line 514 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); } +#line 6989 "sql.c" break; case 284: /* cmd ::= SHOW TOPICS */ +#line 515 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); } +#line 6994 "sql.c" break; case 285: /* cmd ::= SHOW VARIABLES */ case 286: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==286); +#line 516 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); } +#line 7000 "sql.c" break; case 287: /* cmd ::= SHOW LOCAL VARIABLES */ +#line 518 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } +#line 7005 "sql.c" break; case 288: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ -{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy720); } +#line 519 "sql.y" +{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy40); } +#line 7010 "sql.c" break; case 289: /* cmd ::= SHOW BNODES */ +#line 520 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } +#line 7015 "sql.c" break; case 290: /* cmd ::= SHOW SNODES */ +#line 521 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); } +#line 7020 "sql.c" break; case 291: /* cmd ::= SHOW CLUSTER */ +#line 522 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); } +#line 7025 "sql.c" break; case 292: /* cmd ::= SHOW TRANSACTIONS */ +#line 523 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } +#line 7030 "sql.c" break; case 293: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy720); } +#line 524 "sql.y" +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy40); } +#line 7035 "sql.c" break; case 294: /* cmd ::= SHOW CONSUMERS */ +#line 525 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } +#line 7040 "sql.c" break; case 295: /* cmd ::= SHOW SUBSCRIPTIONS */ +#line 526 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } +#line 7045 "sql.c" break; case 296: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy720, yymsp[-1].minor.yy720, OP_TYPE_EQUAL); } +#line 527 "sql.y" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy40, yymsp[-1].minor.yy40, OP_TYPE_EQUAL); } +#line 7050 "sql.c" break; case 297: /* cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy1045), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy1045), OP_TYPE_EQUAL); } +#line 528 "sql.y" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy929), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy929), OP_TYPE_EQUAL); } +#line 7055 "sql.c" break; case 298: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy720, yymsp[0].minor.yy720, yymsp[-3].minor.yy984); } +#line 529 "sql.y" +{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy40, yymsp[0].minor.yy40, yymsp[-3].minor.yy24); } +#line 7060 "sql.c" break; case 299: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, createIdentifierValueNode(pCxt, &yymsp[0].minor.yy1045), createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy1045), yymsp[-4].minor.yy984); } +#line 530 "sql.y" +{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, createIdentifierValueNode(pCxt, &yymsp[0].minor.yy929), createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy929), yymsp[-4].minor.yy24); } +#line 7065 "sql.c" break; case 300: /* cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ +#line 531 "sql.y" { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } +#line 7070 "sql.c" break; case 301: /* cmd ::= SHOW VNODES */ +#line 532 "sql.y" { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, NULL); } +#line 7075 "sql.c" break; case 302: /* cmd ::= SHOW db_name_cond_opt ALIVE */ -{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy720, QUERY_NODE_SHOW_DB_ALIVE_STMT); } +#line 534 "sql.y" +{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy40, QUERY_NODE_SHOW_DB_ALIVE_STMT); } +#line 7080 "sql.c" break; case 303: /* cmd ::= SHOW CLUSTER ALIVE */ +#line 535 "sql.y" { pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); } +#line 7085 "sql.c" break; case 304: /* cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VIEWS_STMT, yymsp[-2].minor.yy720, yymsp[0].minor.yy720, OP_TYPE_LIKE); } +#line 536 "sql.y" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VIEWS_STMT, yymsp[-2].minor.yy40, yymsp[0].minor.yy40, OP_TYPE_LIKE); } +#line 7090 "sql.c" break; case 305: /* cmd ::= SHOW CREATE VIEW full_table_name */ -{ pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, yymsp[0].minor.yy720); } +#line 537 "sql.y" +{ pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, yymsp[0].minor.yy40); } +#line 7095 "sql.c" break; case 306: /* cmd ::= SHOW COMPACTS */ +#line 538 "sql.y" { pCxt->pRootNode = createShowCompactsStmt(pCxt, QUERY_NODE_SHOW_COMPACTS_STMT); } +#line 7100 "sql.c" break; case 307: /* cmd ::= SHOW COMPACT NK_INTEGER */ +#line 539 "sql.y" { pCxt->pRootNode = createShowCompactDetailsStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +#line 7105 "sql.c" break; case 308: /* table_kind_db_name_cond_opt ::= */ -{ yymsp[1].minor.yy165.kind = SHOW_KIND_ALL; yymsp[1].minor.yy165.dbName = nil_token; } +#line 543 "sql.y" +{ yymsp[1].minor.yy685.kind = SHOW_KIND_ALL; yymsp[1].minor.yy685.dbName = nil_token; } +#line 7110 "sql.c" break; case 309: /* table_kind_db_name_cond_opt ::= table_kind */ -{ yylhsminor.yy165.kind = yymsp[0].minor.yy1029; yylhsminor.yy165.dbName = nil_token; } - yymsp[0].minor.yy165 = yylhsminor.yy165; +#line 544 "sql.y" +{ yylhsminor.yy685.kind = yymsp[0].minor.yy769; yylhsminor.yy685.dbName = nil_token; } +#line 7115 "sql.c" + yymsp[0].minor.yy685 = yylhsminor.yy685; break; case 310: /* table_kind_db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy165.kind = SHOW_KIND_ALL; yylhsminor.yy165.dbName = yymsp[-1].minor.yy1045; } - yymsp[-1].minor.yy165 = yylhsminor.yy165; +#line 545 "sql.y" +{ yylhsminor.yy685.kind = SHOW_KIND_ALL; yylhsminor.yy685.dbName = yymsp[-1].minor.yy929; } +#line 7121 "sql.c" + yymsp[-1].minor.yy685 = yylhsminor.yy685; break; case 311: /* table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ -{ yylhsminor.yy165.kind = yymsp[-2].minor.yy1029; yylhsminor.yy165.dbName = yymsp[-1].minor.yy1045; } - yymsp[-2].minor.yy165 = yylhsminor.yy165; +#line 546 "sql.y" +{ yylhsminor.yy685.kind = yymsp[-2].minor.yy769; yylhsminor.yy685.dbName = yymsp[-1].minor.yy929; } +#line 7127 "sql.c" + yymsp[-2].minor.yy685 = yylhsminor.yy685; break; case 312: /* table_kind ::= NORMAL */ -{ yymsp[0].minor.yy1029 = SHOW_KIND_TABLES_NORMAL; } +#line 550 "sql.y" +{ yymsp[0].minor.yy769 = SHOW_KIND_TABLES_NORMAL; } +#line 7133 "sql.c" break; case 313: /* table_kind ::= CHILD */ -{ yymsp[0].minor.yy1029 = SHOW_KIND_TABLES_CHILD; } +#line 551 "sql.y" +{ yymsp[0].minor.yy769 = SHOW_KIND_TABLES_CHILD; } +#line 7138 "sql.c" break; case 314: /* db_name_cond_opt ::= */ case 319: /* from_db_opt ::= */ yytestcase(yyruleno==319); -{ yymsp[1].minor.yy720 = createDefaultDatabaseCondValue(pCxt); } +#line 553 "sql.y" +{ yymsp[1].minor.yy40 = createDefaultDatabaseCondValue(pCxt); } +#line 7144 "sql.c" break; case 315: /* db_name_cond_opt ::= db_name NK_DOT */ -{ yylhsminor.yy720 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy1045); } - yymsp[-1].minor.yy720 = yylhsminor.yy720; +#line 554 "sql.y" +{ yylhsminor.yy40 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy929); } +#line 7149 "sql.c" + yymsp[-1].minor.yy40 = yylhsminor.yy40; break; case 317: /* like_pattern_opt ::= LIKE NK_STRING */ -{ yymsp[-1].minor.yy720 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +#line 557 "sql.y" +{ yymsp[-1].minor.yy40 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +#line 7155 "sql.c" break; case 318: /* table_name_cond ::= table_name */ -{ yylhsminor.yy720 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy1045); } - yymsp[0].minor.yy720 = yylhsminor.yy720; +#line 559 "sql.y" +{ yylhsminor.yy40 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy929); } +#line 7160 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; case 320: /* from_db_opt ::= FROM db_name */ -{ yymsp[-1].minor.yy720 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy1045); } +#line 562 "sql.y" +{ yymsp[-1].minor.yy40 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy929); } +#line 7166 "sql.c" break; case 324: /* tag_item ::= TBNAME */ -{ yylhsminor.yy720 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } - yymsp[0].minor.yy720 = yylhsminor.yy720; +#line 570 "sql.y" +{ yylhsminor.yy40 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } +#line 7171 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; case 327: /* tag_item ::= column_name column_alias */ -{ yylhsminor.yy720 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy1045), &yymsp[0].minor.yy1045); } - yymsp[-1].minor.yy720 = yylhsminor.yy720; +#line 573 "sql.y" +{ yylhsminor.yy40 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy929), &yymsp[0].minor.yy929); } +#line 7177 "sql.c" + yymsp[-1].minor.yy40 = yylhsminor.yy40; break; case 328: /* tag_item ::= column_name AS column_alias */ -{ yylhsminor.yy720 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy1045), &yymsp[0].minor.yy1045); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 574 "sql.y" +{ yylhsminor.yy40 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy929), &yymsp[0].minor.yy929); } +#line 7183 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; case 329: /* db_kind_opt ::= */ -{ yymsp[1].minor.yy1029 = SHOW_KIND_ALL; } +#line 578 "sql.y" +{ yymsp[1].minor.yy769 = SHOW_KIND_ALL; } +#line 7189 "sql.c" break; case 330: /* db_kind_opt ::= USER */ -{ yymsp[0].minor.yy1029 = SHOW_KIND_DATABASES_USER; } +#line 579 "sql.y" +{ yymsp[0].minor.yy769 = SHOW_KIND_DATABASES_USER; } +#line 7194 "sql.c" break; case 331: /* db_kind_opt ::= SYSTEM */ -{ yymsp[0].minor.yy1029 = SHOW_KIND_DATABASES_SYSTEM; } +#line 580 "sql.y" +{ yymsp[0].minor.yy769 = SHOW_KIND_DATABASES_SYSTEM; } +#line 7199 "sql.c" break; - case 332: /* cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy833, yymsp[-3].minor.yy720, yymsp[-1].minor.yy720, NULL, yymsp[0].minor.yy720); } + case 332: /* cmd ::= CREATE TSMA not_exists_opt tsma_name ON full_table_name tsma_func_list INTERVAL NK_LP duration_literal NK_RP */ +#line 586 "sql.y" +{ pCxt->pRootNode = createCreateTSMAStmt(pCxt, yymsp[-8].minor.yy1049, &yymsp[-7].minor.yy929, yymsp[-4].minor.yy40, yymsp[-5].minor.yy40, releaseRawExprNode(pCxt, yymsp[-1].minor.yy40)); } +#line 7204 "sql.c" break; - case 333: /* cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy833, yymsp[-5].minor.yy720, yymsp[-3].minor.yy720, yymsp[-1].minor.yy984, NULL); } + case 333: /* cmd ::= CREATE RECURSIVE TSMA not_exists_opt tsma_name ON full_table_name INTERVAL NK_LP duration_literal NK_RP */ +#line 588 "sql.y" +{ pCxt->pRootNode = createCreateTSMAStmt(pCxt, yymsp[-7].minor.yy1049, &yymsp[-6].minor.yy929, NULL, yymsp[-4].minor.yy40, releaseRawExprNode(pCxt, yymsp[-1].minor.yy40)); } +#line 7209 "sql.c" break; - case 334: /* cmd ::= DROP INDEX exists_opt full_index_name */ -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy833, yymsp[0].minor.yy720); } + case 334: /* cmd ::= DROP TSMA exists_opt full_tsma_name */ +#line 589 "sql.y" +{ pCxt->pRootNode = createDropTSMAStmt(pCxt, yymsp[-1].minor.yy1049, yymsp[0].minor.yy40); } +#line 7214 "sql.c" break; - case 335: /* full_index_name ::= index_name */ -{ yylhsminor.yy720 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy1045); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 335: /* cmd ::= SHOW db_name_cond_opt TSMAS */ +#line 590 "sql.y" +{ pCxt->pRootNode = createShowTSMASStmt(pCxt, yymsp[-1].minor.yy40); } +#line 7219 "sql.c" break; - case 336: /* full_index_name ::= db_name NK_DOT index_name */ -{ yylhsminor.yy720 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy1045, &yymsp[0].minor.yy1045); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 338: /* tsma_func_list ::= FUNCTION NK_LP func_list NK_RP */ +#line 597 "sql.y" +{ yymsp[-3].minor.yy40 = createTSMAOptions(pCxt, yymsp[-1].minor.yy24); } +#line 7224 "sql.c" break; - case 337: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-9].minor.yy720 = createIndexOption(pCxt, yymsp[-7].minor.yy984, releaseRawExprNode(pCxt, yymsp[-3].minor.yy720), NULL, yymsp[-1].minor.yy720, yymsp[0].minor.yy720); } + case 339: /* cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ +#line 601 "sql.y" +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy1049, yymsp[-3].minor.yy40, yymsp[-1].minor.yy40, NULL, yymsp[0].minor.yy40); } +#line 7229 "sql.c" break; - case 338: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ -{ yymsp[-11].minor.yy720 = createIndexOption(pCxt, yymsp[-9].minor.yy984, releaseRawExprNode(pCxt, yymsp[-5].minor.yy720), releaseRawExprNode(pCxt, yymsp[-3].minor.yy720), yymsp[-1].minor.yy720, yymsp[0].minor.yy720); } + case 340: /* cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ +#line 603 "sql.y" +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy1049, yymsp[-5].minor.yy40, yymsp[-3].minor.yy40, yymsp[-1].minor.yy24, NULL); } +#line 7234 "sql.c" break; - case 341: /* func ::= sma_func_name NK_LP expression_list NK_RP */ -{ yylhsminor.yy720 = createFunctionNode(pCxt, &yymsp[-3].minor.yy1045, yymsp[-1].minor.yy984); } - yymsp[-3].minor.yy720 = yylhsminor.yy720; + case 341: /* cmd ::= DROP INDEX exists_opt full_index_name */ +#line 604 "sql.y" +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy1049, yymsp[0].minor.yy40); } +#line 7239 "sql.c" break; - case 342: /* sma_func_name ::= function_name */ - case 613: /* alias_opt ::= table_alias */ yytestcase(yyruleno==613); -{ yylhsminor.yy1045 = yymsp[0].minor.yy1045; } - yymsp[0].minor.yy1045 = yylhsminor.yy1045; + case 342: /* full_index_name ::= index_name */ +#line 606 "sql.y" +{ yylhsminor.yy40 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy929); } +#line 7244 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 347: /* sma_stream_opt ::= */ - case 396: /* stream_options ::= */ yytestcase(yyruleno==396); -{ yymsp[1].minor.yy720 = createStreamOptions(pCxt); } + case 343: /* full_index_name ::= db_name NK_DOT index_name */ +#line 607 "sql.y" +{ yylhsminor.yy40 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy929); } +#line 7250 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 348: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy720)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy720); yylhsminor.yy720 = yymsp[-2].minor.yy720; } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 344: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ +#line 610 "sql.y" +{ yymsp[-9].minor.yy40 = createIndexOption(pCxt, yymsp[-7].minor.yy24, releaseRawExprNode(pCxt, yymsp[-3].minor.yy40), NULL, yymsp[-1].minor.yy40, yymsp[0].minor.yy40); } +#line 7256 "sql.c" break; - case 349: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy720)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy720); yylhsminor.yy720 = yymsp[-2].minor.yy720; } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 345: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_COMMA duration_literal NK_RP sliding_opt sma_stream_opt */ +#line 613 "sql.y" +{ yymsp[-11].minor.yy40 = createIndexOption(pCxt, yymsp[-9].minor.yy24, releaseRawExprNode(pCxt, yymsp[-5].minor.yy40), releaseRawExprNode(pCxt, yymsp[-3].minor.yy40), yymsp[-1].minor.yy40, yymsp[0].minor.yy40); } +#line 7261 "sql.c" break; - case 350: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ -{ ((SStreamOptions*)yymsp[-2].minor.yy720)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy720); yylhsminor.yy720 = yymsp[-2].minor.yy720; } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 348: /* func ::= sma_func_name NK_LP expression_list NK_RP */ +#line 620 "sql.y" +{ yylhsminor.yy40 = createFunctionNode(pCxt, &yymsp[-3].minor.yy929, yymsp[-1].minor.yy24); } +#line 7266 "sql.c" + yymsp[-3].minor.yy40 = yylhsminor.yy40; break; - case 351: /* with_meta ::= AS */ -{ yymsp[0].minor.yy488 = 0; } + case 349: /* sma_func_name ::= function_name */ + case 621: /* alias_opt ::= table_alias */ yytestcase(yyruleno==621); +#line 624 "sql.y" +{ yylhsminor.yy929 = yymsp[0].minor.yy929; } +#line 7273 "sql.c" + yymsp[0].minor.yy929 = yylhsminor.yy929; break; - case 352: /* with_meta ::= WITH META AS */ -{ yymsp[-2].minor.yy488 = 1; } + case 354: /* sma_stream_opt ::= */ + case 403: /* stream_options ::= */ yytestcase(yyruleno==403); +#line 630 "sql.y" +{ yymsp[1].minor.yy40 = createStreamOptions(pCxt); } +#line 7280 "sql.c" break; - case 353: /* with_meta ::= ONLY META AS */ -{ yymsp[-2].minor.yy488 = 2; } + case 355: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ +#line 631 "sql.y" +{ ((SStreamOptions*)yymsp[-2].minor.yy40)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy40); yylhsminor.yy40 = yymsp[-2].minor.yy40; } +#line 7285 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 354: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy833, &yymsp[-2].minor.yy1045, yymsp[0].minor.yy720); } + case 356: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ +#line 632 "sql.y" +{ ((SStreamOptions*)yymsp[-2].minor.yy40)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy40); yylhsminor.yy40 = yymsp[-2].minor.yy40; } +#line 7291 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 355: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy833, &yymsp[-3].minor.yy1045, &yymsp[0].minor.yy1045, yymsp[-2].minor.yy488); } + case 357: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ +#line 633 "sql.y" +{ ((SStreamOptions*)yymsp[-2].minor.yy40)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy40); yylhsminor.yy40 = yymsp[-2].minor.yy40; } +#line 7297 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 356: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-5].minor.yy833, &yymsp[-4].minor.yy1045, yymsp[-1].minor.yy720, yymsp[-3].minor.yy488, yymsp[0].minor.yy720); } + case 358: /* with_meta ::= AS */ +#line 638 "sql.y" +{ yymsp[0].minor.yy516 = 0; } +#line 7303 "sql.c" break; - case 357: /* cmd ::= DROP TOPIC exists_opt topic_name */ -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy833, &yymsp[0].minor.yy1045); } + case 359: /* with_meta ::= WITH META AS */ +#line 639 "sql.y" +{ yymsp[-2].minor.yy516 = 1; } +#line 7308 "sql.c" break; - case 358: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy833, &yymsp[-2].minor.yy1045, &yymsp[0].minor.yy1045); } + case 360: /* with_meta ::= ONLY META AS */ +#line 640 "sql.y" +{ yymsp[-2].minor.yy516 = 2; } +#line 7313 "sql.c" break; - case 359: /* cmd ::= DESC full_table_name */ - case 360: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==360); -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy720); } + case 361: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ +#line 642 "sql.y" +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy1049, &yymsp[-2].minor.yy929, yymsp[0].minor.yy40); } +#line 7318 "sql.c" break; - case 361: /* cmd ::= RESET QUERY CACHE */ + case 362: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ +#line 644 "sql.y" +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy1049, &yymsp[-3].minor.yy929, &yymsp[0].minor.yy929, yymsp[-2].minor.yy516); } +#line 7323 "sql.c" + break; + case 363: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ +#line 646 "sql.y" +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-5].minor.yy1049, &yymsp[-4].minor.yy929, yymsp[-1].minor.yy40, yymsp[-3].minor.yy516, yymsp[0].minor.yy40); } +#line 7328 "sql.c" + break; + case 364: /* cmd ::= DROP TOPIC exists_opt topic_name */ +#line 648 "sql.y" +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy1049, &yymsp[0].minor.yy929); } +#line 7333 "sql.c" + break; + case 365: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ +#line 649 "sql.y" +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy1049, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy929); } +#line 7338 "sql.c" + break; + case 366: /* cmd ::= DESC full_table_name */ + case 367: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==367); +#line 652 "sql.y" +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy40); } +#line 7344 "sql.c" + break; + case 368: /* cmd ::= RESET QUERY CACHE */ +#line 656 "sql.y" { pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } +#line 7349 "sql.c" break; - case 362: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - case 363: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==363); -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy833, yymsp[-1].minor.yy720, yymsp[0].minor.yy720); } + case 369: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + case 370: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==370); +#line 659 "sql.y" +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy1049, yymsp[-1].minor.yy40, yymsp[0].minor.yy40); } +#line 7355 "sql.c" break; - case 366: /* explain_options ::= */ -{ yymsp[1].minor.yy720 = createDefaultExplainOptions(pCxt); } + case 373: /* explain_options ::= */ +#line 667 "sql.y" +{ yymsp[1].minor.yy40 = createDefaultExplainOptions(pCxt); } +#line 7360 "sql.c" break; - case 367: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -{ yylhsminor.yy720 = setExplainVerbose(pCxt, yymsp[-2].minor.yy720, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 374: /* explain_options ::= explain_options VERBOSE NK_BOOL */ +#line 668 "sql.y" +{ yylhsminor.yy40 = setExplainVerbose(pCxt, yymsp[-2].minor.yy40, &yymsp[0].minor.yy0); } +#line 7365 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 368: /* explain_options ::= explain_options RATIO NK_FLOAT */ -{ yylhsminor.yy720 = setExplainRatio(pCxt, yymsp[-2].minor.yy720, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 375: /* explain_options ::= explain_options RATIO NK_FLOAT */ +#line 669 "sql.y" +{ yylhsminor.yy40 = setExplainRatio(pCxt, yymsp[-2].minor.yy40, &yymsp[0].minor.yy0); } +#line 7371 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 369: /* cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ -{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy833, yymsp[-9].minor.yy833, &yymsp[-6].minor.yy1045, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy232, yymsp[-1].minor.yy488, &yymsp[0].minor.yy1045, yymsp[-10].minor.yy833); } + case 376: /* cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ +#line 674 "sql.y" +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy1049, yymsp[-9].minor.yy1049, &yymsp[-6].minor.yy929, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy592, yymsp[-1].minor.yy516, &yymsp[0].minor.yy929, yymsp[-10].minor.yy1049); } +#line 7377 "sql.c" break; - case 370: /* cmd ::= DROP FUNCTION exists_opt function_name */ -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy833, &yymsp[0].minor.yy1045); } + case 377: /* cmd ::= DROP FUNCTION exists_opt function_name */ +#line 675 "sql.y" +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy1049, &yymsp[0].minor.yy929); } +#line 7382 "sql.c" break; - case 375: /* language_opt ::= */ - case 418: /* on_vgroup_id ::= */ yytestcase(yyruleno==418); -{ yymsp[1].minor.yy1045 = nil_token; } + case 382: /* language_opt ::= */ + case 425: /* on_vgroup_id ::= */ yytestcase(yyruleno==425); +#line 689 "sql.y" +{ yymsp[1].minor.yy929 = nil_token; } +#line 7388 "sql.c" break; - case 376: /* language_opt ::= LANGUAGE NK_STRING */ - case 419: /* on_vgroup_id ::= ON NK_INTEGER */ yytestcase(yyruleno==419); -{ yymsp[-1].minor.yy1045 = yymsp[0].minor.yy0; } + case 383: /* language_opt ::= LANGUAGE NK_STRING */ + case 426: /* on_vgroup_id ::= ON NK_INTEGER */ yytestcase(yyruleno==426); +#line 690 "sql.y" +{ yymsp[-1].minor.yy929 = yymsp[0].minor.yy0; } +#line 7394 "sql.c" break; - case 379: /* cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ -{ pCxt->pRootNode = createCreateViewStmt(pCxt, yymsp[-4].minor.yy833, yymsp[-2].minor.yy720, &yymsp[-1].minor.yy0, yymsp[0].minor.yy720); } + case 386: /* cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ +#line 699 "sql.y" +{ pCxt->pRootNode = createCreateViewStmt(pCxt, yymsp[-4].minor.yy1049, yymsp[-2].minor.yy40, &yymsp[-1].minor.yy0, yymsp[0].minor.yy40); } +#line 7399 "sql.c" break; - case 380: /* cmd ::= DROP VIEW exists_opt full_view_name */ -{ pCxt->pRootNode = createDropViewStmt(pCxt, yymsp[-1].minor.yy833, yymsp[0].minor.yy720); } + case 387: /* cmd ::= DROP VIEW exists_opt full_view_name */ +#line 700 "sql.y" +{ pCxt->pRootNode = createDropViewStmt(pCxt, yymsp[-1].minor.yy1049, yymsp[0].minor.yy40); } +#line 7404 "sql.c" break; - case 381: /* full_view_name ::= view_name */ -{ yylhsminor.yy720 = createViewNode(pCxt, NULL, &yymsp[0].minor.yy1045); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 388: /* full_view_name ::= view_name */ +#line 702 "sql.y" +{ yylhsminor.yy40 = createViewNode(pCxt, NULL, &yymsp[0].minor.yy929); } +#line 7409 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 382: /* full_view_name ::= db_name NK_DOT view_name */ -{ yylhsminor.yy720 = createViewNode(pCxt, &yymsp[-2].minor.yy1045, &yymsp[0].minor.yy1045); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 389: /* full_view_name ::= db_name NK_DOT view_name */ +#line 703 "sql.y" +{ yylhsminor.yy40 = createViewNode(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy929); } +#line 7415 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 383: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-9].minor.yy833, &yymsp[-8].minor.yy1045, yymsp[-5].minor.yy720, yymsp[-7].minor.yy720, yymsp[-3].minor.yy984, yymsp[-2].minor.yy720, yymsp[0].minor.yy720, yymsp[-4].minor.yy984); } + case 390: /* cmd ::= CREATE STREAM not_exists_opt stream_name stream_options INTO full_table_name col_list_opt tag_def_or_ref_opt subtable_opt AS query_or_subquery */ +#line 708 "sql.y" +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-9].minor.yy1049, &yymsp[-8].minor.yy929, yymsp[-5].minor.yy40, yymsp[-7].minor.yy40, yymsp[-3].minor.yy24, yymsp[-2].minor.yy40, yymsp[0].minor.yy40, yymsp[-4].minor.yy24); } +#line 7421 "sql.c" break; - case 384: /* cmd ::= DROP STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy833, &yymsp[0].minor.yy1045); } + case 391: /* cmd ::= DROP STREAM exists_opt stream_name */ +#line 709 "sql.y" +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy1049, &yymsp[0].minor.yy929); } +#line 7426 "sql.c" break; - case 385: /* cmd ::= PAUSE STREAM exists_opt stream_name */ -{ pCxt->pRootNode = createPauseStreamStmt(pCxt, yymsp[-1].minor.yy833, &yymsp[0].minor.yy1045); } + case 392: /* cmd ::= PAUSE STREAM exists_opt stream_name */ +#line 710 "sql.y" +{ pCxt->pRootNode = createPauseStreamStmt(pCxt, yymsp[-1].minor.yy1049, &yymsp[0].minor.yy929); } +#line 7431 "sql.c" break; - case 386: /* cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ -{ pCxt->pRootNode = createResumeStreamStmt(pCxt, yymsp[-2].minor.yy833, yymsp[-1].minor.yy833, &yymsp[0].minor.yy1045); } + case 393: /* cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ +#line 711 "sql.y" +{ pCxt->pRootNode = createResumeStreamStmt(pCxt, yymsp[-2].minor.yy1049, yymsp[-1].minor.yy1049, &yymsp[0].minor.yy929); } +#line 7436 "sql.c" break; - case 391: /* column_stream_def ::= column_name */ -{ yylhsminor.yy720 = createColumnDefNode(pCxt, &yymsp[0].minor.yy1045, createDataType(TSDB_DATA_TYPE_NULL), NULL, false); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 398: /* column_stream_def ::= column_name */ +#line 724 "sql.y" +{ yylhsminor.yy40 = createColumnDefNode(pCxt, &yymsp[0].minor.yy929, createDataType(TSDB_DATA_TYPE_NULL), NULL, false); } +#line 7441 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 392: /* column_stream_def ::= column_name PRIMARY KEY */ -{ yylhsminor.yy720 = createColumnDefNode(pCxt, &yymsp[-2].minor.yy1045, createDataType(TSDB_DATA_TYPE_NULL), NULL, true); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 399: /* column_stream_def ::= column_name PRIMARY KEY */ +#line 725 "sql.y" +{ yylhsminor.yy40 = createColumnDefNode(pCxt, &yymsp[-2].minor.yy929, createDataType(TSDB_DATA_TYPE_NULL), NULL, true); } +#line 7447 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 397: /* stream_options ::= stream_options TRIGGER AT_ONCE */ - case 398: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==398); -{ yylhsminor.yy720 = setStreamOptions(pCxt, yymsp[-2].minor.yy720, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 404: /* stream_options ::= stream_options TRIGGER AT_ONCE */ + case 405: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==405); +#line 735 "sql.y" +{ yylhsminor.yy40 = setStreamOptions(pCxt, yymsp[-2].minor.yy40, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } +#line 7454 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 399: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -{ yylhsminor.yy720 = setStreamOptions(pCxt, yymsp[-3].minor.yy720, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy720)); } - yymsp[-3].minor.yy720 = yylhsminor.yy720; + case 406: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ +#line 737 "sql.y" +{ yylhsminor.yy40 = setStreamOptions(pCxt, yymsp[-3].minor.yy40, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy40)); } +#line 7460 "sql.c" + yymsp[-3].minor.yy40 = yylhsminor.yy40; break; - case 400: /* stream_options ::= stream_options WATERMARK duration_literal */ -{ yylhsminor.yy720 = setStreamOptions(pCxt, yymsp[-2].minor.yy720, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy720)); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 407: /* stream_options ::= stream_options WATERMARK duration_literal */ +#line 738 "sql.y" +{ yylhsminor.yy40 = setStreamOptions(pCxt, yymsp[-2].minor.yy40, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy40)); } +#line 7466 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 401: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ -{ yylhsminor.yy720 = setStreamOptions(pCxt, yymsp[-3].minor.yy720, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-3].minor.yy720 = yylhsminor.yy720; + case 408: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ +#line 739 "sql.y" +{ yylhsminor.yy40 = setStreamOptions(pCxt, yymsp[-3].minor.yy40, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } +#line 7472 "sql.c" + yymsp[-3].minor.yy40 = yylhsminor.yy40; break; - case 402: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ -{ yylhsminor.yy720 = setStreamOptions(pCxt, yymsp[-2].minor.yy720, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 409: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ +#line 740 "sql.y" +{ yylhsminor.yy40 = setStreamOptions(pCxt, yymsp[-2].minor.yy40, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } +#line 7478 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 403: /* stream_options ::= stream_options DELETE_MARK duration_literal */ -{ yylhsminor.yy720 = setStreamOptions(pCxt, yymsp[-2].minor.yy720, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy720)); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 410: /* stream_options ::= stream_options DELETE_MARK duration_literal */ +#line 741 "sql.y" +{ yylhsminor.yy40 = setStreamOptions(pCxt, yymsp[-2].minor.yy40, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy40)); } +#line 7484 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 404: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ -{ yylhsminor.yy720 = setStreamOptions(pCxt, yymsp[-3].minor.yy720, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } - yymsp[-3].minor.yy720 = yylhsminor.yy720; + case 411: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ +#line 742 "sql.y" +{ yylhsminor.yy40 = setStreamOptions(pCxt, yymsp[-3].minor.yy40, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } +#line 7490 "sql.c" + yymsp[-3].minor.yy40 = yylhsminor.yy40; break; - case 406: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - case 670: /* sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ yytestcase(yyruleno==670); - case 694: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==694); -{ yymsp[-3].minor.yy720 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy720); } + case 413: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + case 678: /* sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ yytestcase(yyruleno==678); + case 702: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==702); +#line 745 "sql.y" +{ yymsp[-3].minor.yy40 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy40); } +#line 7498 "sql.c" break; - case 409: /* cmd ::= KILL CONNECTION NK_INTEGER */ + case 416: /* cmd ::= KILL CONNECTION NK_INTEGER */ +#line 753 "sql.y" { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } +#line 7503 "sql.c" break; - case 410: /* cmd ::= KILL QUERY NK_STRING */ + case 417: /* cmd ::= KILL QUERY NK_STRING */ +#line 754 "sql.y" { pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } +#line 7508 "sql.c" break; - case 411: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 418: /* cmd ::= KILL TRANSACTION NK_INTEGER */ +#line 755 "sql.y" { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } +#line 7513 "sql.c" break; - case 412: /* cmd ::= KILL COMPACT NK_INTEGER */ + case 419: /* cmd ::= KILL COMPACT NK_INTEGER */ +#line 756 "sql.y" { pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_COMPACT_STMT, &yymsp[0].minor.yy0); } +#line 7518 "sql.c" break; - case 413: /* cmd ::= BALANCE VGROUP */ + case 420: /* cmd ::= BALANCE VGROUP */ +#line 759 "sql.y" { pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } +#line 7523 "sql.c" break; - case 414: /* cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ -{ pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &yymsp[0].minor.yy1045); } + case 421: /* cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ +#line 760 "sql.y" +{ pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &yymsp[0].minor.yy929); } +#line 7528 "sql.c" break; - case 415: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + case 422: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ +#line 761 "sql.y" { pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } +#line 7533 "sql.c" break; - case 416: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy984); } + case 423: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +#line 762 "sql.y" +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy24); } +#line 7538 "sql.c" break; - case 417: /* cmd ::= SPLIT VGROUP NK_INTEGER */ + case 424: /* cmd ::= SPLIT VGROUP NK_INTEGER */ +#line 763 "sql.y" { pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } +#line 7543 "sql.c" break; - case 420: /* dnode_list ::= DNODE NK_INTEGER */ -{ yymsp[-1].minor.yy984 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } + case 427: /* dnode_list ::= DNODE NK_INTEGER */ +#line 772 "sql.y" +{ yymsp[-1].minor.yy24 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +#line 7548 "sql.c" break; - case 422: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy720, yymsp[0].minor.yy720); } + case 429: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +#line 779 "sql.y" +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy40, yymsp[0].minor.yy40); } +#line 7553 "sql.c" break; - case 425: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ -{ yymsp[-6].minor.yy720 = createInsertStmt(pCxt, yymsp[-4].minor.yy720, yymsp[-2].minor.yy984, yymsp[0].minor.yy720); } + case 432: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ +#line 788 "sql.y" +{ yymsp[-6].minor.yy40 = createInsertStmt(pCxt, yymsp[-4].minor.yy40, yymsp[-2].minor.yy24, yymsp[0].minor.yy40); } +#line 7558 "sql.c" break; - case 426: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ -{ yymsp[-3].minor.yy720 = createInsertStmt(pCxt, yymsp[-1].minor.yy720, NULL, yymsp[0].minor.yy720); } + case 433: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ +#line 789 "sql.y" +{ yymsp[-3].minor.yy40 = createInsertStmt(pCxt, yymsp[-1].minor.yy40, NULL, yymsp[0].minor.yy40); } +#line 7563 "sql.c" break; - case 427: /* tags_literal ::= NK_INTEGER */ - case 439: /* tags_literal ::= NK_BIN */ yytestcase(yyruleno==439); - case 448: /* tags_literal ::= NK_HEX */ yytestcase(yyruleno==448); -{ yylhsminor.yy720 = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 434: /* tags_literal ::= NK_INTEGER */ + case 446: /* tags_literal ::= NK_BIN */ yytestcase(yyruleno==446); + case 455: /* tags_literal ::= NK_HEX */ yytestcase(yyruleno==455); +#line 792 "sql.y" +{ yylhsminor.yy40 = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0, NULL); } +#line 7570 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 428: /* tags_literal ::= NK_INTEGER NK_PLUS duration_literal */ - case 429: /* tags_literal ::= NK_INTEGER NK_MINUS duration_literal */ yytestcase(yyruleno==429); - case 440: /* tags_literal ::= NK_BIN NK_PLUS duration_literal */ yytestcase(yyruleno==440); - case 441: /* tags_literal ::= NK_BIN NK_MINUS duration_literal */ yytestcase(yyruleno==441); - case 449: /* tags_literal ::= NK_HEX NK_PLUS duration_literal */ yytestcase(yyruleno==449); - case 450: /* tags_literal ::= NK_HEX NK_MINUS duration_literal */ yytestcase(yyruleno==450); - case 458: /* tags_literal ::= NK_STRING NK_PLUS duration_literal */ yytestcase(yyruleno==458); - case 459: /* tags_literal ::= NK_STRING NK_MINUS duration_literal */ yytestcase(yyruleno==459); + case 435: /* tags_literal ::= NK_INTEGER NK_PLUS duration_literal */ + case 436: /* tags_literal ::= NK_INTEGER NK_MINUS duration_literal */ yytestcase(yyruleno==436); + case 447: /* tags_literal ::= NK_BIN NK_PLUS duration_literal */ yytestcase(yyruleno==447); + case 448: /* tags_literal ::= NK_BIN NK_MINUS duration_literal */ yytestcase(yyruleno==448); + case 456: /* tags_literal ::= NK_HEX NK_PLUS duration_literal */ yytestcase(yyruleno==456); + case 457: /* tags_literal ::= NK_HEX NK_MINUS duration_literal */ yytestcase(yyruleno==457); + case 465: /* tags_literal ::= NK_STRING NK_PLUS duration_literal */ yytestcase(yyruleno==465); + case 466: /* tags_literal ::= NK_STRING NK_MINUS duration_literal */ yytestcase(yyruleno==466); +#line 793 "sql.y" { SToken l = yymsp[-2].minor.yy0; - SToken r = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy720); + SToken r = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy40); l.n = (r.z + r.n) - l.z; - yylhsminor.yy720 = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, yymsp[0].minor.yy720); + yylhsminor.yy40 = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, yymsp[0].minor.yy40); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 7588 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 430: /* tags_literal ::= NK_PLUS NK_INTEGER */ - case 433: /* tags_literal ::= NK_MINUS NK_INTEGER */ yytestcase(yyruleno==433); - case 442: /* tags_literal ::= NK_PLUS NK_BIN */ yytestcase(yyruleno==442); - case 445: /* tags_literal ::= NK_MINUS NK_BIN */ yytestcase(yyruleno==445); - case 451: /* tags_literal ::= NK_PLUS NK_HEX */ yytestcase(yyruleno==451); - case 454: /* tags_literal ::= NK_MINUS NK_HEX */ yytestcase(yyruleno==454); + case 437: /* tags_literal ::= NK_PLUS NK_INTEGER */ + case 440: /* tags_literal ::= NK_MINUS NK_INTEGER */ yytestcase(yyruleno==440); + case 449: /* tags_literal ::= NK_PLUS NK_BIN */ yytestcase(yyruleno==449); + case 452: /* tags_literal ::= NK_MINUS NK_BIN */ yytestcase(yyruleno==452); + case 458: /* tags_literal ::= NK_PLUS NK_HEX */ yytestcase(yyruleno==458); + case 461: /* tags_literal ::= NK_MINUS NK_HEX */ yytestcase(yyruleno==461); +#line 805 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy720 = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL); + yylhsminor.yy40 = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL); } - yymsp[-1].minor.yy720 = yylhsminor.yy720; +#line 7603 "sql.c" + yymsp[-1].minor.yy40 = yylhsminor.yy40; break; - case 431: /* tags_literal ::= NK_PLUS NK_INTEGER NK_PLUS duration_literal */ - case 432: /* tags_literal ::= NK_PLUS NK_INTEGER NK_MINUS duration_literal */ yytestcase(yyruleno==432); - case 434: /* tags_literal ::= NK_MINUS NK_INTEGER NK_PLUS duration_literal */ yytestcase(yyruleno==434); - case 435: /* tags_literal ::= NK_MINUS NK_INTEGER NK_MINUS duration_literal */ yytestcase(yyruleno==435); - case 443: /* tags_literal ::= NK_PLUS NK_BIN NK_PLUS duration_literal */ yytestcase(yyruleno==443); - case 444: /* tags_literal ::= NK_PLUS NK_BIN NK_MINUS duration_literal */ yytestcase(yyruleno==444); - case 446: /* tags_literal ::= NK_MINUS NK_BIN NK_PLUS duration_literal */ yytestcase(yyruleno==446); - case 447: /* tags_literal ::= NK_MINUS NK_BIN NK_MINUS duration_literal */ yytestcase(yyruleno==447); - case 452: /* tags_literal ::= NK_PLUS NK_HEX NK_PLUS duration_literal */ yytestcase(yyruleno==452); - case 453: /* tags_literal ::= NK_PLUS NK_HEX NK_MINUS duration_literal */ yytestcase(yyruleno==453); - case 455: /* tags_literal ::= NK_MINUS NK_HEX NK_PLUS duration_literal */ yytestcase(yyruleno==455); - case 456: /* tags_literal ::= NK_MINUS NK_HEX NK_MINUS duration_literal */ yytestcase(yyruleno==456); + case 438: /* tags_literal ::= NK_PLUS NK_INTEGER NK_PLUS duration_literal */ + case 439: /* tags_literal ::= NK_PLUS NK_INTEGER NK_MINUS duration_literal */ yytestcase(yyruleno==439); + case 441: /* tags_literal ::= NK_MINUS NK_INTEGER NK_PLUS duration_literal */ yytestcase(yyruleno==441); + case 442: /* tags_literal ::= NK_MINUS NK_INTEGER NK_MINUS duration_literal */ yytestcase(yyruleno==442); + case 450: /* tags_literal ::= NK_PLUS NK_BIN NK_PLUS duration_literal */ yytestcase(yyruleno==450); + case 451: /* tags_literal ::= NK_PLUS NK_BIN NK_MINUS duration_literal */ yytestcase(yyruleno==451); + case 453: /* tags_literal ::= NK_MINUS NK_BIN NK_PLUS duration_literal */ yytestcase(yyruleno==453); + case 454: /* tags_literal ::= NK_MINUS NK_BIN NK_MINUS duration_literal */ yytestcase(yyruleno==454); + case 459: /* tags_literal ::= NK_PLUS NK_HEX NK_PLUS duration_literal */ yytestcase(yyruleno==459); + case 460: /* tags_literal ::= NK_PLUS NK_HEX NK_MINUS duration_literal */ yytestcase(yyruleno==460); + case 462: /* tags_literal ::= NK_MINUS NK_HEX NK_PLUS duration_literal */ yytestcase(yyruleno==462); + case 463: /* tags_literal ::= NK_MINUS NK_HEX NK_MINUS duration_literal */ yytestcase(yyruleno==463); +#line 810 "sql.y" { SToken l = yymsp[-3].minor.yy0; - SToken r = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy720); + SToken r = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy40); l.n = (r.z + r.n) - l.z; - yylhsminor.yy720 = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, yymsp[0].minor.yy720); + yylhsminor.yy40 = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, yymsp[0].minor.yy40); } - yymsp[-3].minor.yy720 = yylhsminor.yy720; +#line 7625 "sql.c" + yymsp[-3].minor.yy40 = yylhsminor.yy40; break; - case 436: /* tags_literal ::= NK_FLOAT */ -{ yylhsminor.yy720 = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 443: /* tags_literal ::= NK_FLOAT */ +#line 839 "sql.y" +{ yylhsminor.yy40 = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0, NULL); } +#line 7631 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 437: /* tags_literal ::= NK_PLUS NK_FLOAT */ - case 438: /* tags_literal ::= NK_MINUS NK_FLOAT */ yytestcase(yyruleno==438); + case 444: /* tags_literal ::= NK_PLUS NK_FLOAT */ + case 445: /* tags_literal ::= NK_MINUS NK_FLOAT */ yytestcase(yyruleno==445); +#line 840 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy720 = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t, NULL); + yylhsminor.yy40 = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t, NULL); } - yymsp[-1].minor.yy720 = yylhsminor.yy720; +#line 7642 "sql.c" + yymsp[-1].minor.yy40 = yylhsminor.yy40; break; - case 457: /* tags_literal ::= NK_STRING */ -{ yylhsminor.yy720 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 464: /* tags_literal ::= NK_STRING */ +#line 946 "sql.y" +{ yylhsminor.yy40 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0, NULL); } +#line 7648 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 460: /* tags_literal ::= NK_BOOL */ -{ yylhsminor.yy720 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 467: /* tags_literal ::= NK_BOOL */ +#line 959 "sql.y" +{ yylhsminor.yy40 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0, NULL); } +#line 7654 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 461: /* tags_literal ::= NULL */ -{ yylhsminor.yy720 = createRawValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0, NULL); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 468: /* tags_literal ::= NULL */ +#line 960 "sql.y" +{ yylhsminor.yy40 = createRawValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0, NULL); } +#line 7660 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 462: /* tags_literal ::= literal_func */ -{ yylhsminor.yy720 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, NULL, yymsp[0].minor.yy720); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 469: /* tags_literal ::= literal_func */ +#line 962 "sql.y" +{ yylhsminor.yy40 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, NULL, yymsp[0].minor.yy40); } +#line 7666 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 463: /* tags_literal ::= literal_func NK_PLUS duration_literal */ - case 464: /* tags_literal ::= literal_func NK_MINUS duration_literal */ yytestcase(yyruleno==464); + case 470: /* tags_literal ::= literal_func NK_PLUS duration_literal */ + case 471: /* tags_literal ::= literal_func NK_MINUS duration_literal */ yytestcase(yyruleno==471); +#line 963 "sql.y" { - SToken l = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy720); - SToken r = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy720); + SToken l = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy40); + SToken r = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy40); l.n = (r.z + r.n) - l.z; - yylhsminor.yy720 = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, yymsp[-2].minor.yy720, yymsp[0].minor.yy720); + yylhsminor.yy40 = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, yymsp[-2].minor.yy40, yymsp[0].minor.yy40); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 7678 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 467: /* literal ::= NK_INTEGER */ -{ yylhsminor.yy720 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 474: /* literal ::= NK_INTEGER */ +#line 982 "sql.y" +{ yylhsminor.yy40 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } +#line 7684 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 468: /* literal ::= NK_FLOAT */ -{ yylhsminor.yy720 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 475: /* literal ::= NK_FLOAT */ +#line 983 "sql.y" +{ yylhsminor.yy40 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } +#line 7690 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 469: /* literal ::= NK_STRING */ -{ yylhsminor.yy720 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 476: /* literal ::= NK_STRING */ +#line 984 "sql.y" +{ yylhsminor.yy40 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } +#line 7696 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 470: /* literal ::= NK_BOOL */ -{ yylhsminor.yy720 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 477: /* literal ::= NK_BOOL */ +#line 985 "sql.y" +{ yylhsminor.yy40 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } +#line 7702 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 471: /* literal ::= TIMESTAMP NK_STRING */ -{ yylhsminor.yy720 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } - yymsp[-1].minor.yy720 = yylhsminor.yy720; + case 478: /* literal ::= TIMESTAMP NK_STRING */ +#line 986 "sql.y" +{ yylhsminor.yy40 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } +#line 7708 "sql.c" + yymsp[-1].minor.yy40 = yylhsminor.yy40; break; - case 472: /* literal ::= duration_literal */ - case 482: /* signed_literal ::= signed */ yytestcase(yyruleno==482); - case 505: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==505); - case 506: /* expression ::= literal */ yytestcase(yyruleno==506); - case 508: /* expression ::= column_reference */ yytestcase(yyruleno==508); - case 509: /* expression ::= function_expression */ yytestcase(yyruleno==509); - case 510: /* expression ::= case_when_expression */ yytestcase(yyruleno==510); - case 544: /* function_expression ::= literal_func */ yytestcase(yyruleno==544); - case 594: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==594); - case 598: /* boolean_primary ::= predicate */ yytestcase(yyruleno==598); - case 600: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==600); - case 601: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==601); - case 604: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==604); - case 606: /* table_reference ::= table_primary */ yytestcase(yyruleno==606); - case 607: /* table_reference ::= joined_table */ yytestcase(yyruleno==607); - case 611: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==611); - case 696: /* query_simple ::= query_specification */ yytestcase(yyruleno==696); - case 697: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==697); - case 700: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==700); - case 702: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==702); -{ yylhsminor.yy720 = yymsp[0].minor.yy720; } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 479: /* literal ::= duration_literal */ + case 489: /* signed_literal ::= signed */ yytestcase(yyruleno==489); + case 513: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==513); + case 514: /* expression ::= literal */ yytestcase(yyruleno==514); + case 516: /* expression ::= column_reference */ yytestcase(yyruleno==516); + case 517: /* expression ::= function_expression */ yytestcase(yyruleno==517); + case 518: /* expression ::= case_when_expression */ yytestcase(yyruleno==518); + case 552: /* function_expression ::= literal_func */ yytestcase(yyruleno==552); + case 602: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==602); + case 606: /* boolean_primary ::= predicate */ yytestcase(yyruleno==606); + case 608: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==608); + case 609: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==609); + case 612: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==612); + case 614: /* table_reference ::= table_primary */ yytestcase(yyruleno==614); + case 615: /* table_reference ::= joined_table */ yytestcase(yyruleno==615); + case 619: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==619); + case 704: /* query_simple ::= query_specification */ yytestcase(yyruleno==704); + case 705: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==705); + case 708: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==708); + case 710: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==710); +#line 987 "sql.y" +{ yylhsminor.yy40 = yymsp[0].minor.yy40; } +#line 7733 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 473: /* literal ::= NULL */ -{ yylhsminor.yy720 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 480: /* literal ::= NULL */ +#line 988 "sql.y" +{ yylhsminor.yy40 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } +#line 7739 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 474: /* literal ::= NK_QUESTION */ -{ yylhsminor.yy720 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 481: /* literal ::= NK_QUESTION */ +#line 989 "sql.y" +{ yylhsminor.yy40 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 7745 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 475: /* duration_literal ::= NK_VARIABLE */ - case 671: /* interval_sliding_duration_literal ::= NK_VARIABLE */ yytestcase(yyruleno==671); - case 672: /* interval_sliding_duration_literal ::= NK_STRING */ yytestcase(yyruleno==672); - case 673: /* interval_sliding_duration_literal ::= NK_INTEGER */ yytestcase(yyruleno==673); -{ yylhsminor.yy720 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 482: /* duration_literal ::= NK_VARIABLE */ + case 679: /* interval_sliding_duration_literal ::= NK_VARIABLE */ yytestcase(yyruleno==679); + case 680: /* interval_sliding_duration_literal ::= NK_STRING */ yytestcase(yyruleno==680); + case 681: /* interval_sliding_duration_literal ::= NK_INTEGER */ yytestcase(yyruleno==681); +#line 991 "sql.y" +{ yylhsminor.yy40 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 7754 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 476: /* signed ::= NK_INTEGER */ -{ yylhsminor.yy720 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 483: /* signed ::= NK_INTEGER */ +#line 993 "sql.y" +{ yylhsminor.yy40 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } +#line 7760 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 477: /* signed ::= NK_PLUS NK_INTEGER */ -{ yymsp[-1].minor.yy720 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } + case 484: /* signed ::= NK_PLUS NK_INTEGER */ +#line 994 "sql.y" +{ yymsp[-1].minor.yy40 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } +#line 7766 "sql.c" break; - case 478: /* signed ::= NK_MINUS NK_INTEGER */ + case 485: /* signed ::= NK_MINUS NK_INTEGER */ +#line 995 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy720 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + yylhsminor.yy40 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } - yymsp[-1].minor.yy720 = yylhsminor.yy720; +#line 7775 "sql.c" + yymsp[-1].minor.yy40 = yylhsminor.yy40; break; - case 479: /* signed ::= NK_FLOAT */ -{ yylhsminor.yy720 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 486: /* signed ::= NK_FLOAT */ +#line 1000 "sql.y" +{ yylhsminor.yy40 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } +#line 7781 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 480: /* signed ::= NK_PLUS NK_FLOAT */ -{ yymsp[-1].minor.yy720 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } + case 487: /* signed ::= NK_PLUS NK_FLOAT */ +#line 1001 "sql.y" +{ yymsp[-1].minor.yy40 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } +#line 7787 "sql.c" break; - case 481: /* signed ::= NK_MINUS NK_FLOAT */ + case 488: /* signed ::= NK_MINUS NK_FLOAT */ +#line 1002 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy720 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy40 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } - yymsp[-1].minor.yy720 = yylhsminor.yy720; +#line 7796 "sql.c" + yymsp[-1].minor.yy40 = yylhsminor.yy40; break; - case 483: /* signed_literal ::= NK_STRING */ -{ yylhsminor.yy720 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 490: /* signed_literal ::= NK_STRING */ +#line 1009 "sql.y" +{ yylhsminor.yy40 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +#line 7802 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 484: /* signed_literal ::= NK_BOOL */ -{ yylhsminor.yy720 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 491: /* signed_literal ::= NK_BOOL */ +#line 1010 "sql.y" +{ yylhsminor.yy40 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } +#line 7808 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 485: /* signed_literal ::= TIMESTAMP NK_STRING */ -{ yymsp[-1].minor.yy720 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } + case 492: /* signed_literal ::= TIMESTAMP NK_STRING */ +#line 1011 "sql.y" +{ yymsp[-1].minor.yy40 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +#line 7814 "sql.c" break; - case 486: /* signed_literal ::= duration_literal */ - case 488: /* signed_literal ::= literal_func */ yytestcase(yyruleno==488); - case 565: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==565); - case 648: /* select_item ::= common_expression */ yytestcase(yyruleno==648); - case 658: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==658); - case 701: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==701); - case 703: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==703); - case 716: /* search_condition ::= common_expression */ yytestcase(yyruleno==716); -{ yylhsminor.yy720 = releaseRawExprNode(pCxt, yymsp[0].minor.yy720); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 493: /* signed_literal ::= duration_literal */ + case 495: /* signed_literal ::= literal_func */ yytestcase(yyruleno==495); + case 573: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==573); + case 656: /* select_item ::= common_expression */ yytestcase(yyruleno==656); + case 666: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==666); + case 709: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==709); + case 711: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==711); + case 724: /* search_condition ::= common_expression */ yytestcase(yyruleno==724); +#line 1012 "sql.y" +{ yylhsminor.yy40 = releaseRawExprNode(pCxt, yymsp[0].minor.yy40); } +#line 7826 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 487: /* signed_literal ::= NULL */ -{ yylhsminor.yy720 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 494: /* signed_literal ::= NULL */ +#line 1013 "sql.y" +{ yylhsminor.yy40 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } +#line 7832 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 489: /* signed_literal ::= NK_QUESTION */ -{ yylhsminor.yy720 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 496: /* signed_literal ::= NK_QUESTION */ +#line 1015 "sql.y" +{ yylhsminor.yy40 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } +#line 7838 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 507: /* expression ::= pseudo_column */ -{ yylhsminor.yy720 = yymsp[0].minor.yy720; setRawExprNodeIsPseudoColumn(pCxt, yylhsminor.yy720, true); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 515: /* expression ::= pseudo_column */ +#line 1081 "sql.y" +{ yylhsminor.yy40 = yymsp[0].minor.yy40; setRawExprNodeIsPseudoColumn(pCxt, yylhsminor.yy40, true); } +#line 7844 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 511: /* expression ::= NK_LP expression NK_RP */ - case 599: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==599); - case 715: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==715); -{ yylhsminor.yy720 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy720)); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 519: /* expression ::= NK_LP expression NK_RP */ + case 607: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==607); + case 723: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==723); +#line 1085 "sql.y" +{ yylhsminor.yy40 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy40)); } +#line 7852 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 512: /* expression ::= NK_PLUS expr_or_subquery */ + case 520: /* expression ::= NK_PLUS expr_or_subquery */ +#line 1086 "sql.y" { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy720); - yylhsminor.yy720 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy720)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy40); + yylhsminor.yy40 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy40)); } - yymsp[-1].minor.yy720 = yylhsminor.yy720; +#line 7861 "sql.c" + yymsp[-1].minor.yy40 = yylhsminor.yy40; break; - case 513: /* expression ::= NK_MINUS expr_or_subquery */ + case 521: /* expression ::= NK_MINUS expr_or_subquery */ +#line 1090 "sql.y" { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy720); - yylhsminor.yy720 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy720), NULL)); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy40); + yylhsminor.yy40 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy40), NULL)); } - yymsp[-1].minor.yy720 = yylhsminor.yy720; +#line 7870 "sql.c" + yymsp[-1].minor.yy40 = yylhsminor.yy40; break; - case 514: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + case 522: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ +#line 1094 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy720); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy720); - yylhsminor.yy720 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy720), releaseRawExprNode(pCxt, yymsp[0].minor.yy720))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy40); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy40); + yylhsminor.yy40 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy40), releaseRawExprNode(pCxt, yymsp[0].minor.yy40))); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 7880 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 515: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + case 523: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ +#line 1099 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy720); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy720); - yylhsminor.yy720 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy720), releaseRawExprNode(pCxt, yymsp[0].minor.yy720))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy40); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy40); + yylhsminor.yy40 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy40), releaseRawExprNode(pCxt, yymsp[0].minor.yy40))); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 7890 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 516: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + case 524: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ +#line 1104 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy720); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy720); - yylhsminor.yy720 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy720), releaseRawExprNode(pCxt, yymsp[0].minor.yy720))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy40); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy40); + yylhsminor.yy40 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy40), releaseRawExprNode(pCxt, yymsp[0].minor.yy40))); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 7900 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 517: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + case 525: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ +#line 1109 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy720); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy720); - yylhsminor.yy720 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy720), releaseRawExprNode(pCxt, yymsp[0].minor.yy720))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy40); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy40); + yylhsminor.yy40 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy40), releaseRawExprNode(pCxt, yymsp[0].minor.yy40))); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 7910 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 518: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ + case 526: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ +#line 1114 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy720); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy720); - yylhsminor.yy720 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy720), releaseRawExprNode(pCxt, yymsp[0].minor.yy720))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy40); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy40); + yylhsminor.yy40 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy40), releaseRawExprNode(pCxt, yymsp[0].minor.yy40))); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 7920 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 519: /* expression ::= column_reference NK_ARROW NK_STRING */ + case 527: /* expression ::= column_reference NK_ARROW NK_STRING */ +#line 1119 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy720); - yylhsminor.yy720 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy720), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy40); + yylhsminor.yy40 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy40), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 7929 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 520: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + case 528: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ +#line 1123 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy720); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy720); - yylhsminor.yy720 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy720), releaseRawExprNode(pCxt, yymsp[0].minor.yy720))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy40); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy40); + yylhsminor.yy40 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy40), releaseRawExprNode(pCxt, yymsp[0].minor.yy40))); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 7939 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 521: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + case 529: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ +#line 1128 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy720); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy720); - yylhsminor.yy720 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy720), releaseRawExprNode(pCxt, yymsp[0].minor.yy720))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy40); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy40); + yylhsminor.yy40 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy40), releaseRawExprNode(pCxt, yymsp[0].minor.yy40))); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 7949 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 524: /* column_reference ::= column_name */ -{ yylhsminor.yy720 = createRawExprNode(pCxt, &yymsp[0].minor.yy1045, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy1045)); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 532: /* column_reference ::= column_name */ +#line 1139 "sql.y" +{ yylhsminor.yy40 = createRawExprNode(pCxt, &yymsp[0].minor.yy929, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy929)); } +#line 7955 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 525: /* column_reference ::= table_name NK_DOT column_name */ -{ yylhsminor.yy720 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy1045, &yymsp[0].minor.yy1045, createColumnNode(pCxt, &yymsp[-2].minor.yy1045, &yymsp[0].minor.yy1045)); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 533: /* column_reference ::= table_name NK_DOT column_name */ +#line 1140 "sql.y" +{ yylhsminor.yy40 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy929, createColumnNode(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy929)); } +#line 7961 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 526: /* column_reference ::= NK_ALIAS */ -{ yylhsminor.yy720 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 534: /* column_reference ::= NK_ALIAS */ +#line 1141 "sql.y" +{ yylhsminor.yy40 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } +#line 7967 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 527: /* column_reference ::= table_name NK_DOT NK_ALIAS */ -{ yylhsminor.yy720 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy1045, &yymsp[0].minor.yy0, createColumnNode(pCxt, &yymsp[-2].minor.yy1045, &yymsp[0].minor.yy0)); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 535: /* column_reference ::= table_name NK_DOT NK_ALIAS */ +#line 1142 "sql.y" +{ yylhsminor.yy40 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy0, createColumnNode(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy0)); } +#line 7973 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 528: /* pseudo_column ::= ROWTS */ - case 529: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==529); - case 531: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==531); - case 532: /* pseudo_column ::= QEND */ yytestcase(yyruleno==532); - case 533: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==533); - case 534: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==534); - case 535: /* pseudo_column ::= WEND */ yytestcase(yyruleno==535); - case 536: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==536); - case 537: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==537); - case 538: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==538); - case 539: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==539); - case 546: /* literal_func ::= NOW */ yytestcase(yyruleno==546); - case 547: /* literal_func ::= TODAY */ yytestcase(yyruleno==547); -{ yylhsminor.yy720 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 536: /* pseudo_column ::= ROWTS */ + case 537: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==537); + case 539: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==539); + case 540: /* pseudo_column ::= QEND */ yytestcase(yyruleno==540); + case 541: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==541); + case 542: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==542); + case 543: /* pseudo_column ::= WEND */ yytestcase(yyruleno==543); + case 544: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==544); + case 545: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==545); + case 546: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==546); + case 547: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==547); + case 554: /* literal_func ::= NOW */ yytestcase(yyruleno==554); + case 555: /* literal_func ::= TODAY */ yytestcase(yyruleno==555); +#line 1144 "sql.y" +{ yylhsminor.yy40 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } +#line 7991 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 530: /* pseudo_column ::= table_name NK_DOT TBNAME */ -{ yylhsminor.yy720 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy1045, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy1045)))); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 538: /* pseudo_column ::= table_name NK_DOT TBNAME */ +#line 1146 "sql.y" +{ yylhsminor.yy40 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy929)))); } +#line 7997 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 540: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 541: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==541); -{ yylhsminor.yy720 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy1045, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy1045, yymsp[-1].minor.yy984)); } - yymsp[-3].minor.yy720 = yylhsminor.yy720; + case 548: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 549: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==549); +#line 1157 "sql.y" +{ yylhsminor.yy40 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy929, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy929, yymsp[-1].minor.yy24)); } +#line 8004 "sql.c" + yymsp[-3].minor.yy40 = yylhsminor.yy40; break; - case 542: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - case 543: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name_default_len NK_RP */ yytestcase(yyruleno==543); -{ yylhsminor.yy720 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy720), yymsp[-1].minor.yy232)); } - yymsp[-5].minor.yy720 = yylhsminor.yy720; + case 550: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + case 551: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name_default_len NK_RP */ yytestcase(yyruleno==551); +#line 1160 "sql.y" +{ yylhsminor.yy40 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy40), yymsp[-1].minor.yy592)); } +#line 8011 "sql.c" + yymsp[-5].minor.yy40 = yylhsminor.yy40; break; - case 545: /* literal_func ::= noarg_func NK_LP NK_RP */ -{ yylhsminor.yy720 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy1045, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy1045, NULL)); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 553: /* literal_func ::= noarg_func NK_LP NK_RP */ +#line 1166 "sql.y" +{ yylhsminor.yy40 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy929, NULL)); } +#line 8017 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 561: /* star_func_para_list ::= NK_STAR */ -{ yylhsminor.yy984 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy984 = yylhsminor.yy984; + case 569: /* star_func_para_list ::= NK_STAR */ +#line 1191 "sql.y" +{ yylhsminor.yy24 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } +#line 8023 "sql.c" + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 566: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 651: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==651); -{ yylhsminor.yy720 = createColumnNode(pCxt, &yymsp[-2].minor.yy1045, &yymsp[0].minor.yy0); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 574: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 659: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==659); +#line 1200 "sql.y" +{ yylhsminor.yy40 = createColumnNode(pCxt, &yymsp[-2].minor.yy929, &yymsp[0].minor.yy0); } +#line 8030 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 567: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ -{ yylhsminor.yy720 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy984, yymsp[-1].minor.yy720)); } - yymsp[-3].minor.yy720 = yylhsminor.yy720; + case 575: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ +#line 1203 "sql.y" +{ yylhsminor.yy40 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy24, yymsp[-1].minor.yy40)); } +#line 8036 "sql.c" + yymsp[-3].minor.yy40 = yylhsminor.yy40; break; - case 568: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ -{ yylhsminor.yy720 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy720), yymsp[-2].minor.yy984, yymsp[-1].minor.yy720)); } - yymsp[-4].minor.yy720 = yylhsminor.yy720; + case 576: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ +#line 1205 "sql.y" +{ yylhsminor.yy40 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy40), yymsp[-2].minor.yy24, yymsp[-1].minor.yy40)); } +#line 8042 "sql.c" + yymsp[-4].minor.yy40 = yylhsminor.yy40; break; - case 571: /* when_then_expr ::= WHEN common_expression THEN common_expression */ -{ yymsp[-3].minor.yy720 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy720), releaseRawExprNode(pCxt, yymsp[0].minor.yy720)); } + case 579: /* when_then_expr ::= WHEN common_expression THEN common_expression */ +#line 1212 "sql.y" +{ yymsp[-3].minor.yy40 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy40), releaseRawExprNode(pCxt, yymsp[0].minor.yy40)); } +#line 8048 "sql.c" break; - case 573: /* case_when_else_opt ::= ELSE common_expression */ -{ yymsp[-1].minor.yy720 = releaseRawExprNode(pCxt, yymsp[0].minor.yy720); } + case 581: /* case_when_else_opt ::= ELSE common_expression */ +#line 1215 "sql.y" +{ yymsp[-1].minor.yy40 = releaseRawExprNode(pCxt, yymsp[0].minor.yy40); } +#line 8053 "sql.c" break; - case 574: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ - case 579: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==579); + case 582: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ + case 587: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==587); +#line 1218 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy720); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy720); - yylhsminor.yy720 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy1024, releaseRawExprNode(pCxt, yymsp[-2].minor.yy720), releaseRawExprNode(pCxt, yymsp[0].minor.yy720))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy40); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy40); + yylhsminor.yy40 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy700, releaseRawExprNode(pCxt, yymsp[-2].minor.yy40), releaseRawExprNode(pCxt, yymsp[0].minor.yy40))); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 8063 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 575: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + case 583: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ +#line 1225 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy720); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy720); - yylhsminor.yy720 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy720), releaseRawExprNode(pCxt, yymsp[-2].minor.yy720), releaseRawExprNode(pCxt, yymsp[0].minor.yy720))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy40); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy40); + yylhsminor.yy40 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy40), releaseRawExprNode(pCxt, yymsp[-2].minor.yy40), releaseRawExprNode(pCxt, yymsp[0].minor.yy40))); } - yymsp[-4].minor.yy720 = yylhsminor.yy720; +#line 8073 "sql.c" + yymsp[-4].minor.yy40 = yylhsminor.yy40; break; - case 576: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + case 584: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ +#line 1231 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy720); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy720); - yylhsminor.yy720 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy720), releaseRawExprNode(pCxt, yymsp[-2].minor.yy720), releaseRawExprNode(pCxt, yymsp[0].minor.yy720))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy40); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy40); + yylhsminor.yy40 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy40), releaseRawExprNode(pCxt, yymsp[-2].minor.yy40), releaseRawExprNode(pCxt, yymsp[0].minor.yy40))); } - yymsp[-5].minor.yy720 = yylhsminor.yy720; +#line 8083 "sql.c" + yymsp[-5].minor.yy40 = yylhsminor.yy40; break; - case 577: /* predicate ::= expr_or_subquery IS NULL */ + case 585: /* predicate ::= expr_or_subquery IS NULL */ +#line 1236 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy720); - yylhsminor.yy720 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy720), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy40); + yylhsminor.yy40 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy40), NULL)); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 8092 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 578: /* predicate ::= expr_or_subquery IS NOT NULL */ + case 586: /* predicate ::= expr_or_subquery IS NOT NULL */ +#line 1240 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy720); - yylhsminor.yy720 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy720), NULL)); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy40); + yylhsminor.yy40 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy40), NULL)); } - yymsp[-3].minor.yy720 = yylhsminor.yy720; +#line 8101 "sql.c" + yymsp[-3].minor.yy40 = yylhsminor.yy40; break; - case 580: /* compare_op ::= NK_LT */ -{ yymsp[0].minor.yy1024 = OP_TYPE_LOWER_THAN; } + case 588: /* compare_op ::= NK_LT */ +#line 1252 "sql.y" +{ yymsp[0].minor.yy700 = OP_TYPE_LOWER_THAN; } +#line 8107 "sql.c" break; - case 581: /* compare_op ::= NK_GT */ -{ yymsp[0].minor.yy1024 = OP_TYPE_GREATER_THAN; } + case 589: /* compare_op ::= NK_GT */ +#line 1253 "sql.y" +{ yymsp[0].minor.yy700 = OP_TYPE_GREATER_THAN; } +#line 8112 "sql.c" break; - case 582: /* compare_op ::= NK_LE */ -{ yymsp[0].minor.yy1024 = OP_TYPE_LOWER_EQUAL; } + case 590: /* compare_op ::= NK_LE */ +#line 1254 "sql.y" +{ yymsp[0].minor.yy700 = OP_TYPE_LOWER_EQUAL; } +#line 8117 "sql.c" break; - case 583: /* compare_op ::= NK_GE */ -{ yymsp[0].minor.yy1024 = OP_TYPE_GREATER_EQUAL; } + case 591: /* compare_op ::= NK_GE */ +#line 1255 "sql.y" +{ yymsp[0].minor.yy700 = OP_TYPE_GREATER_EQUAL; } +#line 8122 "sql.c" break; - case 584: /* compare_op ::= NK_NE */ -{ yymsp[0].minor.yy1024 = OP_TYPE_NOT_EQUAL; } + case 592: /* compare_op ::= NK_NE */ +#line 1256 "sql.y" +{ yymsp[0].minor.yy700 = OP_TYPE_NOT_EQUAL; } +#line 8127 "sql.c" break; - case 585: /* compare_op ::= NK_EQ */ -{ yymsp[0].minor.yy1024 = OP_TYPE_EQUAL; } + case 593: /* compare_op ::= NK_EQ */ +#line 1257 "sql.y" +{ yymsp[0].minor.yy700 = OP_TYPE_EQUAL; } +#line 8132 "sql.c" break; - case 586: /* compare_op ::= LIKE */ -{ yymsp[0].minor.yy1024 = OP_TYPE_LIKE; } + case 594: /* compare_op ::= LIKE */ +#line 1258 "sql.y" +{ yymsp[0].minor.yy700 = OP_TYPE_LIKE; } +#line 8137 "sql.c" break; - case 587: /* compare_op ::= NOT LIKE */ -{ yymsp[-1].minor.yy1024 = OP_TYPE_NOT_LIKE; } + case 595: /* compare_op ::= NOT LIKE */ +#line 1259 "sql.y" +{ yymsp[-1].minor.yy700 = OP_TYPE_NOT_LIKE; } +#line 8142 "sql.c" break; - case 588: /* compare_op ::= MATCH */ -{ yymsp[0].minor.yy1024 = OP_TYPE_MATCH; } + case 596: /* compare_op ::= MATCH */ +#line 1260 "sql.y" +{ yymsp[0].minor.yy700 = OP_TYPE_MATCH; } +#line 8147 "sql.c" break; - case 589: /* compare_op ::= NMATCH */ -{ yymsp[0].minor.yy1024 = OP_TYPE_NMATCH; } + case 597: /* compare_op ::= NMATCH */ +#line 1261 "sql.y" +{ yymsp[0].minor.yy700 = OP_TYPE_NMATCH; } +#line 8152 "sql.c" break; - case 590: /* compare_op ::= CONTAINS */ -{ yymsp[0].minor.yy1024 = OP_TYPE_JSON_CONTAINS; } + case 598: /* compare_op ::= CONTAINS */ +#line 1262 "sql.y" +{ yymsp[0].minor.yy700 = OP_TYPE_JSON_CONTAINS; } +#line 8157 "sql.c" break; - case 591: /* in_op ::= IN */ -{ yymsp[0].minor.yy1024 = OP_TYPE_IN; } + case 599: /* in_op ::= IN */ +#line 1266 "sql.y" +{ yymsp[0].minor.yy700 = OP_TYPE_IN; } +#line 8162 "sql.c" break; - case 592: /* in_op ::= NOT IN */ -{ yymsp[-1].minor.yy1024 = OP_TYPE_NOT_IN; } + case 600: /* in_op ::= NOT IN */ +#line 1267 "sql.y" +{ yymsp[-1].minor.yy700 = OP_TYPE_NOT_IN; } +#line 8167 "sql.c" break; - case 593: /* in_predicate_value ::= NK_LP literal_list NK_RP */ -{ yylhsminor.yy720 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy984)); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 601: /* in_predicate_value ::= NK_LP literal_list NK_RP */ +#line 1269 "sql.y" +{ yylhsminor.yy40 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy24)); } +#line 8172 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 595: /* boolean_value_expression ::= NOT boolean_primary */ + case 603: /* boolean_value_expression ::= NOT boolean_primary */ +#line 1273 "sql.y" { - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy720); - yylhsminor.yy720 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy720), NULL)); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy40); + yylhsminor.yy40 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy40), NULL)); } - yymsp[-1].minor.yy720 = yylhsminor.yy720; +#line 8181 "sql.c" + yymsp[-1].minor.yy40 = yylhsminor.yy40; break; - case 596: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + case 604: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ +#line 1278 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy720); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy720); - yylhsminor.yy720 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy720), releaseRawExprNode(pCxt, yymsp[0].minor.yy720))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy40); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy40); + yylhsminor.yy40 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy40), releaseRawExprNode(pCxt, yymsp[0].minor.yy40))); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 8191 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 597: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + case 605: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ +#line 1284 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy720); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy720); - yylhsminor.yy720 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy720), releaseRawExprNode(pCxt, yymsp[0].minor.yy720))); + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy40); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy40); + yylhsminor.yy40 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy40), releaseRawExprNode(pCxt, yymsp[0].minor.yy40))); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; +#line 8201 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 605: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -{ yylhsminor.yy720 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, JOIN_STYPE_NONE, yymsp[-2].minor.yy720, yymsp[0].minor.yy720, NULL); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 613: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +#line 1302 "sql.y" +{ yylhsminor.yy40 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, JOIN_STYPE_NONE, yymsp[-2].minor.yy40, yymsp[0].minor.yy40, NULL); } +#line 8207 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 608: /* table_primary ::= table_name alias_opt */ -{ yylhsminor.yy720 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy1045, &yymsp[0].minor.yy1045); } - yymsp[-1].minor.yy720 = yylhsminor.yy720; + case 616: /* table_primary ::= table_name alias_opt */ +#line 1308 "sql.y" +{ yylhsminor.yy40 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy929, &yymsp[0].minor.yy929); } +#line 8213 "sql.c" + yymsp[-1].minor.yy40 = yylhsminor.yy40; break; - case 609: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -{ yylhsminor.yy720 = createRealTableNode(pCxt, &yymsp[-3].minor.yy1045, &yymsp[-1].minor.yy1045, &yymsp[0].minor.yy1045); } - yymsp[-3].minor.yy720 = yylhsminor.yy720; + case 617: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +#line 1309 "sql.y" +{ yylhsminor.yy40 = createRealTableNode(pCxt, &yymsp[-3].minor.yy929, &yymsp[-1].minor.yy929, &yymsp[0].minor.yy929); } +#line 8219 "sql.c" + yymsp[-3].minor.yy40 = yylhsminor.yy40; break; - case 610: /* table_primary ::= subquery alias_opt */ -{ yylhsminor.yy720 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy720), &yymsp[0].minor.yy1045); } - yymsp[-1].minor.yy720 = yylhsminor.yy720; + case 618: /* table_primary ::= subquery alias_opt */ +#line 1310 "sql.y" +{ yylhsminor.yy40 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy40), &yymsp[0].minor.yy929); } +#line 8225 "sql.c" + yymsp[-1].minor.yy40 = yylhsminor.yy40; break; - case 612: /* alias_opt ::= */ -{ yymsp[1].minor.yy1045 = nil_token; } + case 620: /* alias_opt ::= */ +#line 1315 "sql.y" +{ yymsp[1].minor.yy929 = nil_token; } +#line 8231 "sql.c" break; - case 614: /* alias_opt ::= AS table_alias */ -{ yymsp[-1].minor.yy1045 = yymsp[0].minor.yy1045; } + case 622: /* alias_opt ::= AS table_alias */ +#line 1317 "sql.y" +{ yymsp[-1].minor.yy929 = yymsp[0].minor.yy929; } +#line 8236 "sql.c" break; - case 615: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 616: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==616); -{ yymsp[-2].minor.yy720 = yymsp[-1].minor.yy720; } + case 623: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 624: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==624); +#line 1319 "sql.y" +{ yymsp[-2].minor.yy40 = yymsp[-1].minor.yy40; } +#line 8242 "sql.c" break; - case 617: /* joined_table ::= table_reference join_type join_subtype JOIN table_reference join_on_clause_opt window_offset_clause_opt jlimit_clause_opt */ + case 625: /* joined_table ::= table_reference join_type join_subtype JOIN table_reference join_on_clause_opt window_offset_clause_opt jlimit_clause_opt */ +#line 1325 "sql.y" { - yylhsminor.yy720 = createJoinTableNode(pCxt, yymsp[-6].minor.yy548, yymsp[-5].minor.yy506, yymsp[-7].minor.yy720, yymsp[-3].minor.yy720, yymsp[-2].minor.yy720); - yylhsminor.yy720 = addWindowOffsetClause(pCxt, yylhsminor.yy720, yymsp[-1].minor.yy720); - yylhsminor.yy720 = addJLimitClause(pCxt, yylhsminor.yy720, yymsp[0].minor.yy720); + yylhsminor.yy40 = createJoinTableNode(pCxt, yymsp[-6].minor.yy596, yymsp[-5].minor.yy630, yymsp[-7].minor.yy40, yymsp[-3].minor.yy40, yymsp[-2].minor.yy40); + yylhsminor.yy40 = addWindowOffsetClause(pCxt, yylhsminor.yy40, yymsp[-1].minor.yy40); + yylhsminor.yy40 = addJLimitClause(pCxt, yylhsminor.yy40, yymsp[0].minor.yy40); } - yymsp[-7].minor.yy720 = yylhsminor.yy720; +#line 8251 "sql.c" + yymsp[-7].minor.yy40 = yylhsminor.yy40; break; - case 618: /* join_type ::= */ -{ yymsp[1].minor.yy548 = JOIN_TYPE_INNER; } + case 626: /* join_type ::= */ +#line 1333 "sql.y" +{ yymsp[1].minor.yy596 = JOIN_TYPE_INNER; } +#line 8257 "sql.c" break; - case 619: /* join_type ::= INNER */ -{ yymsp[0].minor.yy548 = JOIN_TYPE_INNER; } + case 627: /* join_type ::= INNER */ +#line 1334 "sql.y" +{ yymsp[0].minor.yy596 = JOIN_TYPE_INNER; } +#line 8262 "sql.c" break; - case 620: /* join_type ::= LEFT */ -{ yymsp[0].minor.yy548 = JOIN_TYPE_LEFT; } + case 628: /* join_type ::= LEFT */ +#line 1335 "sql.y" +{ yymsp[0].minor.yy596 = JOIN_TYPE_LEFT; } +#line 8267 "sql.c" break; - case 621: /* join_type ::= RIGHT */ -{ yymsp[0].minor.yy548 = JOIN_TYPE_RIGHT; } + case 629: /* join_type ::= RIGHT */ +#line 1336 "sql.y" +{ yymsp[0].minor.yy596 = JOIN_TYPE_RIGHT; } +#line 8272 "sql.c" break; - case 622: /* join_type ::= FULL */ -{ yymsp[0].minor.yy548 = JOIN_TYPE_FULL; } + case 630: /* join_type ::= FULL */ +#line 1337 "sql.y" +{ yymsp[0].minor.yy596 = JOIN_TYPE_FULL; } +#line 8277 "sql.c" break; - case 623: /* join_subtype ::= */ -{ yymsp[1].minor.yy506 = JOIN_STYPE_NONE; } + case 631: /* join_subtype ::= */ +#line 1341 "sql.y" +{ yymsp[1].minor.yy630 = JOIN_STYPE_NONE; } +#line 8282 "sql.c" break; - case 624: /* join_subtype ::= OUTER */ -{ yymsp[0].minor.yy506 = JOIN_STYPE_OUTER; } + case 632: /* join_subtype ::= OUTER */ +#line 1342 "sql.y" +{ yymsp[0].minor.yy630 = JOIN_STYPE_OUTER; } +#line 8287 "sql.c" break; - case 625: /* join_subtype ::= SEMI */ -{ yymsp[0].minor.yy506 = JOIN_STYPE_SEMI; } + case 633: /* join_subtype ::= SEMI */ +#line 1343 "sql.y" +{ yymsp[0].minor.yy630 = JOIN_STYPE_SEMI; } +#line 8292 "sql.c" break; - case 626: /* join_subtype ::= ANTI */ -{ yymsp[0].minor.yy506 = JOIN_STYPE_ANTI; } + case 634: /* join_subtype ::= ANTI */ +#line 1344 "sql.y" +{ yymsp[0].minor.yy630 = JOIN_STYPE_ANTI; } +#line 8297 "sql.c" break; - case 627: /* join_subtype ::= ASOF */ -{ yymsp[0].minor.yy506 = JOIN_STYPE_ASOF; } + case 635: /* join_subtype ::= ASOF */ +#line 1345 "sql.y" +{ yymsp[0].minor.yy630 = JOIN_STYPE_ASOF; } +#line 8302 "sql.c" break; - case 628: /* join_subtype ::= WINDOW */ -{ yymsp[0].minor.yy506 = JOIN_STYPE_WIN; } + case 636: /* join_subtype ::= WINDOW */ +#line 1346 "sql.y" +{ yymsp[0].minor.yy630 = JOIN_STYPE_WIN; } +#line 8307 "sql.c" break; - case 632: /* window_offset_clause_opt ::= WINDOW_OFFSET NK_LP window_offset_literal NK_COMMA window_offset_literal NK_RP */ -{ yymsp[-5].minor.yy720 = createWindowOffsetNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy720), releaseRawExprNode(pCxt, yymsp[-1].minor.yy720)); } + case 640: /* window_offset_clause_opt ::= WINDOW_OFFSET NK_LP window_offset_literal NK_COMMA window_offset_literal NK_RP */ +#line 1353 "sql.y" +{ yymsp[-5].minor.yy40 = createWindowOffsetNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy40), releaseRawExprNode(pCxt, yymsp[-1].minor.yy40)); } +#line 8312 "sql.c" break; - case 633: /* window_offset_literal ::= NK_VARIABLE */ -{ yylhsminor.yy720 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createTimeOffsetValueNode(pCxt, &yymsp[0].minor.yy0)); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 641: /* window_offset_literal ::= NK_VARIABLE */ +#line 1355 "sql.y" +{ yylhsminor.yy40 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createTimeOffsetValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 8317 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 634: /* window_offset_literal ::= NK_MINUS NK_VARIABLE */ + case 642: /* window_offset_literal ::= NK_MINUS NK_VARIABLE */ +#line 1356 "sql.y" { SToken t = yymsp[-1].minor.yy0; t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; - yylhsminor.yy720 = createRawExprNode(pCxt, &t, createTimeOffsetValueNode(pCxt, &t)); + yylhsminor.yy40 = createRawExprNode(pCxt, &t, createTimeOffsetValueNode(pCxt, &t)); } - yymsp[-1].minor.yy720 = yylhsminor.yy720; +#line 8327 "sql.c" + yymsp[-1].minor.yy40 = yylhsminor.yy40; break; - case 636: /* jlimit_clause_opt ::= JLIMIT NK_INTEGER */ - case 707: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ yytestcase(yyruleno==707); - case 711: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==711); -{ yymsp[-1].minor.yy720 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } + case 644: /* jlimit_clause_opt ::= JLIMIT NK_INTEGER */ + case 715: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ yytestcase(yyruleno==715); + case 719: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==719); +#line 1363 "sql.y" +{ yymsp[-1].minor.yy40 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } +#line 8335 "sql.c" break; - case 637: /* query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ + case 645: /* query_specification ::= SELECT hint_list set_quantifier_opt tag_mode_opt select_list from_clause_opt where_clause_opt partition_by_clause_opt range_opt every_opt fill_opt twindow_clause_opt group_by_clause_opt having_clause_opt */ +#line 1369 "sql.y" { - yymsp[-13].minor.yy720 = createSelectStmt(pCxt, yymsp[-11].minor.yy833, yymsp[-9].minor.yy984, yymsp[-8].minor.yy720, yymsp[-12].minor.yy984); - yymsp[-13].minor.yy720 = setSelectStmtTagMode(pCxt, yymsp[-13].minor.yy720, yymsp[-10].minor.yy833); - yymsp[-13].minor.yy720 = addWhereClause(pCxt, yymsp[-13].minor.yy720, yymsp[-7].minor.yy720); - yymsp[-13].minor.yy720 = addPartitionByClause(pCxt, yymsp[-13].minor.yy720, yymsp[-6].minor.yy984); - yymsp[-13].minor.yy720 = addWindowClauseClause(pCxt, yymsp[-13].minor.yy720, yymsp[-2].minor.yy720); - yymsp[-13].minor.yy720 = addGroupByClause(pCxt, yymsp[-13].minor.yy720, yymsp[-1].minor.yy984); - yymsp[-13].minor.yy720 = addHavingClause(pCxt, yymsp[-13].minor.yy720, yymsp[0].minor.yy720); - yymsp[-13].minor.yy720 = addRangeClause(pCxt, yymsp[-13].minor.yy720, yymsp[-5].minor.yy720); - yymsp[-13].minor.yy720 = addEveryClause(pCxt, yymsp[-13].minor.yy720, yymsp[-4].minor.yy720); - yymsp[-13].minor.yy720 = addFillClause(pCxt, yymsp[-13].minor.yy720, yymsp[-3].minor.yy720); + yymsp[-13].minor.yy40 = createSelectStmt(pCxt, yymsp[-11].minor.yy1049, yymsp[-9].minor.yy24, yymsp[-8].minor.yy40, yymsp[-12].minor.yy24); + yymsp[-13].minor.yy40 = setSelectStmtTagMode(pCxt, yymsp[-13].minor.yy40, yymsp[-10].minor.yy1049); + yymsp[-13].minor.yy40 = addWhereClause(pCxt, yymsp[-13].minor.yy40, yymsp[-7].minor.yy40); + yymsp[-13].minor.yy40 = addPartitionByClause(pCxt, yymsp[-13].minor.yy40, yymsp[-6].minor.yy24); + yymsp[-13].minor.yy40 = addWindowClauseClause(pCxt, yymsp[-13].minor.yy40, yymsp[-2].minor.yy40); + yymsp[-13].minor.yy40 = addGroupByClause(pCxt, yymsp[-13].minor.yy40, yymsp[-1].minor.yy24); + yymsp[-13].minor.yy40 = addHavingClause(pCxt, yymsp[-13].minor.yy40, yymsp[0].minor.yy40); + yymsp[-13].minor.yy40 = addRangeClause(pCxt, yymsp[-13].minor.yy40, yymsp[-5].minor.yy40); + yymsp[-13].minor.yy40 = addEveryClause(pCxt, yymsp[-13].minor.yy40, yymsp[-4].minor.yy40); + yymsp[-13].minor.yy40 = addFillClause(pCxt, yymsp[-13].minor.yy40, yymsp[-3].minor.yy40); } +#line 8351 "sql.c" break; - case 638: /* hint_list ::= */ -{ yymsp[1].minor.yy984 = createHintNodeList(pCxt, NULL); } + case 646: /* hint_list ::= */ +#line 1384 "sql.y" +{ yymsp[1].minor.yy24 = createHintNodeList(pCxt, NULL); } +#line 8356 "sql.c" break; - case 639: /* hint_list ::= NK_HINT */ -{ yylhsminor.yy984 = createHintNodeList(pCxt, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy984 = yylhsminor.yy984; + case 647: /* hint_list ::= NK_HINT */ +#line 1385 "sql.y" +{ yylhsminor.yy24 = createHintNodeList(pCxt, &yymsp[0].minor.yy0); } +#line 8361 "sql.c" + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 644: /* set_quantifier_opt ::= ALL */ -{ yymsp[0].minor.yy833 = false; } + case 652: /* set_quantifier_opt ::= ALL */ +#line 1396 "sql.y" +{ yymsp[0].minor.yy1049 = false; } +#line 8367 "sql.c" break; - case 647: /* select_item ::= NK_STAR */ -{ yylhsminor.yy720 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } - yymsp[0].minor.yy720 = yylhsminor.yy720; + case 655: /* select_item ::= NK_STAR */ +#line 1403 "sql.y" +{ yylhsminor.yy40 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } +#line 8372 "sql.c" + yymsp[0].minor.yy40 = yylhsminor.yy40; break; - case 649: /* select_item ::= common_expression column_alias */ - case 659: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==659); -{ yylhsminor.yy720 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy720), &yymsp[0].minor.yy1045); } - yymsp[-1].minor.yy720 = yylhsminor.yy720; + case 657: /* select_item ::= common_expression column_alias */ + case 667: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==667); +#line 1405 "sql.y" +{ yylhsminor.yy40 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy40), &yymsp[0].minor.yy929); } +#line 8379 "sql.c" + yymsp[-1].minor.yy40 = yylhsminor.yy40; break; - case 650: /* select_item ::= common_expression AS column_alias */ - case 660: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==660); -{ yylhsminor.yy720 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy720), &yymsp[0].minor.yy1045); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 658: /* select_item ::= common_expression AS column_alias */ + case 668: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==668); +#line 1406 "sql.y" +{ yylhsminor.yy40 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy40), &yymsp[0].minor.yy929); } +#line 8386 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 655: /* partition_by_clause_opt ::= PARTITION BY partition_list */ - case 685: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==685); - case 705: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==705); -{ yymsp[-2].minor.yy984 = yymsp[0].minor.yy984; } + case 663: /* partition_by_clause_opt ::= PARTITION BY partition_list */ + case 693: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==693); + case 713: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==713); +#line 1415 "sql.y" +{ yymsp[-2].minor.yy24 = yymsp[0].minor.yy24; } +#line 8394 "sql.c" break; - case 662: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ -{ yymsp[-5].minor.yy720 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy720), releaseRawExprNode(pCxt, yymsp[-1].minor.yy720)); } + case 670: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ +#line 1428 "sql.y" +{ yymsp[-5].minor.yy40 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy40), releaseRawExprNode(pCxt, yymsp[-1].minor.yy40)); } +#line 8399 "sql.c" break; - case 663: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ -{ yymsp[-3].minor.yy720 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy720)); } + case 671: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ +#line 1429 "sql.y" +{ yymsp[-3].minor.yy40 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy40)); } +#line 8404 "sql.c" break; - case 664: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-5].minor.yy720 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy720), NULL, yymsp[-1].minor.yy720, yymsp[0].minor.yy720); } + case 672: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ +#line 1431 "sql.y" +{ yymsp[-5].minor.yy40 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy40), NULL, yymsp[-1].minor.yy40, yymsp[0].minor.yy40); } +#line 8409 "sql.c" break; - case 665: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ -{ yymsp[-7].minor.yy720 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy720), releaseRawExprNode(pCxt, yymsp[-3].minor.yy720), yymsp[-1].minor.yy720, yymsp[0].minor.yy720); } + case 673: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ +#line 1435 "sql.y" +{ yymsp[-7].minor.yy40 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy40), releaseRawExprNode(pCxt, yymsp[-3].minor.yy40), yymsp[-1].minor.yy40, yymsp[0].minor.yy40); } +#line 8414 "sql.c" break; - case 666: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ -{ yymsp[-6].minor.yy720 = createEventWindowNode(pCxt, yymsp[-3].minor.yy720, yymsp[0].minor.yy720); } + case 674: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ +#line 1437 "sql.y" +{ yymsp[-6].minor.yy40 = createEventWindowNode(pCxt, yymsp[-3].minor.yy40, yymsp[0].minor.yy40); } +#line 8419 "sql.c" break; - case 667: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ -{ yymsp[-3].minor.yy720 = createCountWindowNode(pCxt, &yymsp[-1].minor.yy0, &yymsp[-1].minor.yy0); } + case 675: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ +#line 1439 "sql.y" +{ yymsp[-3].minor.yy40 = createCountWindowNode(pCxt, &yymsp[-1].minor.yy0, &yymsp[-1].minor.yy0); } +#line 8424 "sql.c" break; - case 668: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -{ yymsp[-5].minor.yy720 = createCountWindowNode(pCxt, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0); } + case 676: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +#line 1441 "sql.y" +{ yymsp[-5].minor.yy40 = createCountWindowNode(pCxt, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0); } +#line 8429 "sql.c" break; - case 675: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -{ yymsp[-3].minor.yy720 = createFillNode(pCxt, yymsp[-1].minor.yy318, NULL); } + case 683: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +#line 1451 "sql.y" +{ yymsp[-3].minor.yy40 = createFillNode(pCxt, yymsp[-1].minor.yy998, NULL); } +#line 8434 "sql.c" break; - case 676: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ -{ yymsp[-5].minor.yy720 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy984)); } + case 684: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ +#line 1452 "sql.y" +{ yymsp[-5].minor.yy40 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy24)); } +#line 8439 "sql.c" break; - case 677: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ -{ yymsp[-5].minor.yy720 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy984)); } + case 685: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ +#line 1453 "sql.y" +{ yymsp[-5].minor.yy40 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy24)); } +#line 8444 "sql.c" break; - case 678: /* fill_mode ::= NONE */ -{ yymsp[0].minor.yy318 = FILL_MODE_NONE; } + case 686: /* fill_mode ::= NONE */ +#line 1457 "sql.y" +{ yymsp[0].minor.yy998 = FILL_MODE_NONE; } +#line 8449 "sql.c" break; - case 679: /* fill_mode ::= PREV */ -{ yymsp[0].minor.yy318 = FILL_MODE_PREV; } + case 687: /* fill_mode ::= PREV */ +#line 1458 "sql.y" +{ yymsp[0].minor.yy998 = FILL_MODE_PREV; } +#line 8454 "sql.c" break; - case 680: /* fill_mode ::= NULL */ -{ yymsp[0].minor.yy318 = FILL_MODE_NULL; } + case 688: /* fill_mode ::= NULL */ +#line 1459 "sql.y" +{ yymsp[0].minor.yy998 = FILL_MODE_NULL; } +#line 8459 "sql.c" break; - case 681: /* fill_mode ::= NULL_F */ -{ yymsp[0].minor.yy318 = FILL_MODE_NULL_F; } + case 689: /* fill_mode ::= NULL_F */ +#line 1460 "sql.y" +{ yymsp[0].minor.yy998 = FILL_MODE_NULL_F; } +#line 8464 "sql.c" break; - case 682: /* fill_mode ::= LINEAR */ -{ yymsp[0].minor.yy318 = FILL_MODE_LINEAR; } + case 690: /* fill_mode ::= LINEAR */ +#line 1461 "sql.y" +{ yymsp[0].minor.yy998 = FILL_MODE_LINEAR; } +#line 8469 "sql.c" break; - case 683: /* fill_mode ::= NEXT */ -{ yymsp[0].minor.yy318 = FILL_MODE_NEXT; } + case 691: /* fill_mode ::= NEXT */ +#line 1462 "sql.y" +{ yymsp[0].minor.yy998 = FILL_MODE_NEXT; } +#line 8474 "sql.c" break; - case 686: /* group_by_list ::= expr_or_subquery */ -{ yylhsminor.yy984 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy720))); } - yymsp[0].minor.yy984 = yylhsminor.yy984; + case 694: /* group_by_list ::= expr_or_subquery */ +#line 1471 "sql.y" +{ yylhsminor.yy24 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy40))); } +#line 8479 "sql.c" + yymsp[0].minor.yy24 = yylhsminor.yy24; break; - case 687: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ -{ yylhsminor.yy984 = addNodeToList(pCxt, yymsp[-2].minor.yy984, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy720))); } - yymsp[-2].minor.yy984 = yylhsminor.yy984; + case 695: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ +#line 1472 "sql.y" +{ yylhsminor.yy24 = addNodeToList(pCxt, yymsp[-2].minor.yy24, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy40))); } +#line 8485 "sql.c" + yymsp[-2].minor.yy24 = yylhsminor.yy24; break; - case 691: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ -{ yymsp[-5].minor.yy720 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy720), releaseRawExprNode(pCxt, yymsp[-1].minor.yy720)); } + case 699: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ +#line 1479 "sql.y" +{ yymsp[-5].minor.yy40 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy40), releaseRawExprNode(pCxt, yymsp[-1].minor.yy40)); } +#line 8491 "sql.c" break; - case 692: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ -{ yymsp[-3].minor.yy720 = createInterpTimePoint(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy720)); } + case 700: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ +#line 1481 "sql.y" +{ yymsp[-3].minor.yy40 = createInterpTimePoint(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy40)); } +#line 8496 "sql.c" break; - case 695: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + case 703: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ +#line 1488 "sql.y" { - yylhsminor.yy720 = addOrderByClause(pCxt, yymsp[-3].minor.yy720, yymsp[-2].minor.yy984); - yylhsminor.yy720 = addSlimitClause(pCxt, yylhsminor.yy720, yymsp[-1].minor.yy720); - yylhsminor.yy720 = addLimitClause(pCxt, yylhsminor.yy720, yymsp[0].minor.yy720); + yylhsminor.yy40 = addOrderByClause(pCxt, yymsp[-3].minor.yy40, yymsp[-2].minor.yy24); + yylhsminor.yy40 = addSlimitClause(pCxt, yylhsminor.yy40, yymsp[-1].minor.yy40); + yylhsminor.yy40 = addLimitClause(pCxt, yylhsminor.yy40, yymsp[0].minor.yy40); } - yymsp[-3].minor.yy720 = yylhsminor.yy720; +#line 8505 "sql.c" + yymsp[-3].minor.yy40 = yylhsminor.yy40; break; - case 698: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ -{ yylhsminor.yy720 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy720, yymsp[0].minor.yy720); } - yymsp[-3].minor.yy720 = yylhsminor.yy720; + case 706: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ +#line 1498 "sql.y" +{ yylhsminor.yy40 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy40, yymsp[0].minor.yy40); } +#line 8511 "sql.c" + yymsp[-3].minor.yy40 = yylhsminor.yy40; break; - case 699: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ -{ yylhsminor.yy720 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy720, yymsp[0].minor.yy720); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 707: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ +#line 1500 "sql.y" +{ yylhsminor.yy40 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy40, yymsp[0].minor.yy40); } +#line 8517 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 708: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 712: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==712); -{ yymsp[-3].minor.yy720 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 716: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 720: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==720); +#line 1515 "sql.y" +{ yymsp[-3].minor.yy40 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } +#line 8524 "sql.c" break; - case 709: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 713: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==713); -{ yymsp[-3].minor.yy720 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } + case 717: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 721: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==721); +#line 1516 "sql.y" +{ yymsp[-3].minor.yy40 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } +#line 8530 "sql.c" break; - case 714: /* subquery ::= NK_LP query_expression NK_RP */ -{ yylhsminor.yy720 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy720); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 722: /* subquery ::= NK_LP query_expression NK_RP */ +#line 1524 "sql.y" +{ yylhsminor.yy40 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy40); } +#line 8535 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 719: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ -{ yylhsminor.yy720 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy720), yymsp[-1].minor.yy670, yymsp[0].minor.yy545); } - yymsp[-2].minor.yy720 = yylhsminor.yy720; + case 727: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ +#line 1538 "sql.y" +{ yylhsminor.yy40 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy40), yymsp[-1].minor.yy258, yymsp[0].minor.yy585); } +#line 8541 "sql.c" + yymsp[-2].minor.yy40 = yylhsminor.yy40; break; - case 720: /* ordering_specification_opt ::= */ -{ yymsp[1].minor.yy670 = ORDER_ASC; } + case 728: /* ordering_specification_opt ::= */ +#line 1542 "sql.y" +{ yymsp[1].minor.yy258 = ORDER_ASC; } +#line 8547 "sql.c" break; - case 721: /* ordering_specification_opt ::= ASC */ -{ yymsp[0].minor.yy670 = ORDER_ASC; } + case 729: /* ordering_specification_opt ::= ASC */ +#line 1543 "sql.y" +{ yymsp[0].minor.yy258 = ORDER_ASC; } +#line 8552 "sql.c" break; - case 722: /* ordering_specification_opt ::= DESC */ -{ yymsp[0].minor.yy670 = ORDER_DESC; } + case 730: /* ordering_specification_opt ::= DESC */ +#line 1544 "sql.y" +{ yymsp[0].minor.yy258 = ORDER_DESC; } +#line 8557 "sql.c" break; - case 723: /* null_ordering_opt ::= */ -{ yymsp[1].minor.yy545 = NULL_ORDER_DEFAULT; } + case 731: /* null_ordering_opt ::= */ +#line 1548 "sql.y" +{ yymsp[1].minor.yy585 = NULL_ORDER_DEFAULT; } +#line 8562 "sql.c" break; - case 724: /* null_ordering_opt ::= NULLS FIRST */ -{ yymsp[-1].minor.yy545 = NULL_ORDER_FIRST; } + case 732: /* null_ordering_opt ::= NULLS FIRST */ +#line 1549 "sql.y" +{ yymsp[-1].minor.yy585 = NULL_ORDER_FIRST; } +#line 8567 "sql.c" break; - case 725: /* null_ordering_opt ::= NULLS LAST */ -{ yymsp[-1].minor.yy545 = NULL_ORDER_LAST; } + case 733: /* null_ordering_opt ::= NULLS LAST */ +#line 1550 "sql.y" +{ yymsp[-1].minor.yy585 = NULL_ORDER_LAST; } +#line 8572 "sql.c" break; default: break; @@ -7169,6 +8631,7 @@ static void yy_syntax_error( ParseCTX_FETCH #define TOKEN yyminor /************ Begin %syntax_error code ****************************************/ +#line 29 "sql.y" if (TSDB_CODE_SUCCESS == pCxt->errCode) { if(TOKEN.z) { @@ -7179,6 +8642,7 @@ static void yy_syntax_error( } else if (TSDB_CODE_PAR_DB_NOT_SPECIFIED == pCxt->errCode && TK_NK_FLOAT == TOKEN.type) { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_SYNTAX_ERROR, TOKEN.z); } +#line 8645 "sql.c" /************ End %syntax_error code ******************************************/ ParseARG_STORE /* Suppress warning about unused %extra_argument variable */ ParseCTX_STORE diff --git a/source/libs/parser/test/mockCatalogService.cpp b/source/libs/parser/test/mockCatalogService.cpp index 1cff7ac87a..c0348ab43b 100644 --- a/source/libs/parser/test/mockCatalogService.cpp +++ b/source/libs/parser/test/mockCatalogService.cpp @@ -756,6 +756,7 @@ void MockCatalogService::destoryCatalogReq(SCatalogReq* pReq) { taosArrayDestroy(pReq->pTableIndex); taosArrayDestroy(pReq->pTableCfg); taosArrayDestroyEx(pReq->pView, destoryTablesReq); + taosArrayDestroyEx(pReq->pTableTSMAs, destoryTablesReq); delete pReq; } diff --git a/source/libs/planner/src/planLogicCreater.c b/source/libs/planner/src/planLogicCreater.c index f618bece13..cceabcbf50 100644 --- a/source/libs/planner/src/planLogicCreater.c +++ b/source/libs/planner/src/planLogicCreater.c @@ -364,6 +364,9 @@ static int32_t makeScanLogicNode(SLogicPlanContext* pCxt, SRealTableNode* pRealT TSWAP(pScan->pVgroupList, pRealTable->pVgroupList); TSWAP(pScan->pSmaIndexes, pRealTable->pSmaIndexes); + TSWAP(pScan->pTsmas, pRealTable->pTsmas); + TSWAP(pScan->pTsmaTargetTbVgInfo, pRealTable->tsmaTargetTbVgInfo); + TSWAP(pScan->pTsmaTargetTbInfo, pRealTable->tsmaTargetTbInfo); pScan->tableId = pRealTable->pMeta->uid; pScan->stableId = pRealTable->pMeta->suid; pScan->tableType = pRealTable->pMeta->tableType; diff --git a/source/libs/planner/src/planOptimizer.c b/source/libs/planner/src/planOptimizer.c index 71bf89531a..ae37334762 100644 --- a/source/libs/planner/src/planOptimizer.c +++ b/source/libs/planner/src/planOptimizer.c @@ -818,7 +818,7 @@ static bool pdcJoinIsPrimEqualCond(SJoinLogicNode* pJoin, SNode* pCond) { tSimpleHashCleanup(pLeftTables); tSimpleHashCleanup(pRightTables); - + return res; } @@ -1186,14 +1186,14 @@ static int32_t pdcJoinAddPreFilterColsToTarget(SOptimizeContext* pCxt, SJoinLogi if (TSDB_CODE_SUCCESS == code) { code = createColumnByRewriteExprs(pCondCols, &pTargets); } - + nodesDestroyList(pCondCols); - + if (TSDB_CODE_SUCCESS == code) { SNode* pNode = NULL; FOREACH(pNode, pTargets) { SNode* pTmp = NULL; - bool found = false; + bool found = false; FOREACH(pTmp, pJoin->node.pTargets) { if (nodesEqualNode(pTmp, pNode)) { found = true; @@ -1204,7 +1204,7 @@ static int32_t pdcJoinAddPreFilterColsToTarget(SOptimizeContext* pCxt, SJoinLogi nodesListStrictAppend(pJoin->node.pTargets, nodesCloneNode(pNode)); } } - } + } nodesDestroyList(pTargets); @@ -2917,8 +2917,7 @@ static int32_t partTagsOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub scanPathOptSetGroupOrderScan(pScan); pParent->hasGroupKeyOptimized = true; } - if (pNode->pParent->pSlimit) - pScan->groupOrderScan = true; + if (pNode->pParent->pSlimit) pScan->groupOrderScan = true; NODES_CLEAR_LIST(pNode->pChildren); nodesDestroyNode((SNode*)pNode); @@ -3395,7 +3394,7 @@ static SNode* rewriteUniqueOptCreateFirstFunc(SFunctionNode* pSelectValue, SNode strcpy(pFunc->node.aliasName, pSelectValue->node.aliasName); } else { int64_t pointer = (int64_t)pFunc; - char name[TSDB_FUNC_NAME_LEN + TSDB_POINTER_PRINT_BYTES + TSDB_NAME_DELIMITER_LEN + 1] = {0}; + char name[TSDB_FUNC_NAME_LEN + TSDB_POINTER_PRINT_BYTES + TSDB_NAME_DELIMITER_LEN + 1] = {0}; int32_t len = snprintf(name, sizeof(name) - 1, "%s.%" PRId64 "", pFunc->functionName, pointer); taosCreateMD5Hash(name, len); strncpy(pFunc->node.aliasName, name, TSDB_COL_NAME_LEN - 1); @@ -3603,8 +3602,8 @@ static bool hasSuitableCache(int8_t cacheLastMode, bool hasLastRow, bool hasLast /// @param lastColId only used when lastColNum equals 1, the col id of the only one last col /// @param selectNonPKColNum num of normal cols /// @param selectNonPKColId only used when selectNonPKColNum equals 1, the col id of the only one select col -static bool lastRowScanOptCheckColNum(int32_t lastColNum, col_id_t lastColId, - int32_t selectNonPKColNum, col_id_t selectNonPKColId) { +static bool lastRowScanOptCheckColNum(int32_t lastColNum, col_id_t lastColId, int32_t selectNonPKColNum, + col_id_t selectNonPKColId) { // multi select non pk col + last func: select c1, c2, last(c1) if (selectNonPKColNum > 1 && lastColNum > 0) return false; @@ -3678,8 +3677,7 @@ static bool lastRowScanOptCheckFuncList(SLogicNode* pNode, int8_t cacheLastModel } else if (lastColNum > 0) { return false; } - if (!lastRowScanOptCheckColNum(lastColNum, lastColId, selectNonPKColNum, selectNonPKColId)) - return false; + if (!lastRowScanOptCheckColNum(lastColNum, lastColId, selectNonPKColNum, selectNonPKColId)) return false; } else if (FUNCTION_TYPE_GROUP_KEY == pAggFunc->funcType) { if (!lastRowScanOptLastParaIsTag(nodesListGetNode(pAggFunc->pParameterList, 0))) { return false; @@ -3720,7 +3718,7 @@ static bool lastRowScanOptMayBeOptimized(SLogicNode* pNode) { if (!lastRowScanOptCheckLastCache(pAgg, pScan)) { return false; } - + bool hasOtherFunc = false; if (!lastRowScanOptCheckFuncList(pNode, pScan->cacheLastMode, &hasOtherFunc)) { return false; @@ -3947,7 +3945,7 @@ static int32_t lastRowScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogic } else { pNode = nodesListGetNode(pFunc->pParameterList, 0); nodesListMakeAppend(&cxt.pOtherCols, pNode); - + if (FUNCTION_TYPE_SELECT_VALUE == funcType) { if (nodeType(pNode) == QUERY_NODE_COLUMN) { SColumnNode* pCol = (SColumnNode*)pNode; @@ -3973,7 +3971,8 @@ static int32_t lastRowScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogic sprintf(pPKTsCol->colName, "#sel_val.%p", pPKTsCol); nodesListAppend(pScan->node.pTargets, nodesCloneNode((SNode*)pPKTsCol)); } - if (pNonPKCol && cxt.pLastCols->length == 1 && nodesEqualNode((SNode*)pNonPKCol, nodesListGetNode(cxt.pLastCols, 0))) { + if (pNonPKCol && cxt.pLastCols->length == 1 && + nodesEqualNode((SNode*)pNonPKCol, nodesListGetNode(cxt.pLastCols, 0))) { // when select last(c1), c1 from ..., we add c1 to targets sprintf(pNonPKCol->colName, "#sel_val.%p", pNonPKCol); nodesListAppend(pScan->node.pTargets, nodesCloneNode((SNode*)pNonPKCol)); @@ -3990,7 +3989,6 @@ static int32_t lastRowScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogic return TSDB_CODE_SUCCESS; } - static bool splitCacheLastFuncOptMayBeOptimized(SLogicNode* pNode) { if (QUERY_NODE_LOGIC_PLAN_AGG != nodeType(pNode) || 1 != LIST_LENGTH(pNode->pChildren) || QUERY_NODE_LOGIC_PLAN_SCAN != nodeType(nodesListGetNode(pNode->pChildren, 0))) { @@ -4015,7 +4013,8 @@ static bool splitCacheLastFuncOptMayBeOptimized(SLogicNode* pNode) { return true; } -static int32_t splitCacheLastFuncOptCreateAggLogicNode(SAggLogicNode** pNewAgg, SAggLogicNode* pAgg, SNodeList* pFunc, SNodeList* pTargets) { +static int32_t splitCacheLastFuncOptCreateAggLogicNode(SAggLogicNode** pNewAgg, SAggLogicNode* pAgg, SNodeList* pFunc, + SNodeList* pTargets) { SAggLogicNode* pNew = (SAggLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_AGG); if (NULL == pNew) { nodesDestroyList(pFunc); @@ -4051,10 +4050,10 @@ static int32_t splitCacheLastFuncOptCreateAggLogicNode(SAggLogicNode** pNewAgg, pNew->node.pChildren = nodesCloneList(pAgg->node.pChildren); int32_t code = 0; - SNode* pNode = nodesListGetNode(pNew->node.pChildren, 0); + SNode* pNode = nodesListGetNode(pNew->node.pChildren, 0); if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode)) { SScanLogicNode* pScan = (SScanLogicNode*)pNode; - SNodeList* pOldScanCols = NULL; + SNodeList* pOldScanCols = NULL; TSWAP(pScan->pScanCols, pOldScanCols); nodesDestroyList(pScan->pScanPseudoCols); pScan->pScanPseudoCols = NULL; @@ -4110,7 +4109,8 @@ static int32_t splitCacheLastFuncOptModifyAggLogicNode(SAggLogicNode* pAgg) { return TSDB_CODE_SUCCESS; } -static int32_t splitCacheLastFuncOptCreateMergeLogicNode(SMergeLogicNode** pNew, SAggLogicNode* pAgg1, SAggLogicNode* pAgg2) { +static int32_t splitCacheLastFuncOptCreateMergeLogicNode(SMergeLogicNode** pNew, SAggLogicNode* pAgg1, + SAggLogicNode* pAgg2) { SMergeLogicNode* pMerge = (SMergeLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_MERGE); if (NULL == pMerge) { return TSDB_CODE_OUT_OF_MEMORY; @@ -4127,17 +4127,13 @@ static int32_t splitCacheLastFuncOptCreateMergeLogicNode(SMergeLogicNode** pNew, nodesDestroyNode(pNewAgg2); return TSDB_CODE_OUT_OF_MEMORY; } - + ((SAggLogicNode*)pNewAgg1)->node.pParent = (SLogicNode*)pMerge; ((SAggLogicNode*)pNewAgg2)->node.pParent = (SLogicNode*)pMerge; SNode* pNode = NULL; - FOREACH(pNode, ((SAggLogicNode*)pNewAgg1)->node.pChildren) { - ((SLogicNode*)pNode)->pParent = (SLogicNode*)pNewAgg1; - } - FOREACH(pNode, ((SAggLogicNode*)pNewAgg2)->node.pChildren) { - ((SLogicNode*)pNode)->pParent = (SLogicNode*)pNewAgg2; - } + FOREACH(pNode, ((SAggLogicNode*)pNewAgg1)->node.pChildren) { ((SLogicNode*)pNode)->pParent = (SLogicNode*)pNewAgg1; } + FOREACH(pNode, ((SAggLogicNode*)pNewAgg2)->node.pChildren) { ((SLogicNode*)pNode)->pParent = (SLogicNode*)pNewAgg2; } int32_t code = nodesListMakeStrictAppendList(&pMerge->node.pTargets, nodesCloneList(pAgg1->node.pTargets)); if (TSDB_CODE_SUCCESS == code) { @@ -4157,7 +4153,7 @@ static int32_t splitCacheLastFuncOptCreateMergeLogicNode(SMergeLogicNode** pNew, } else { *pNew = pMerge; } - + return code; } @@ -4203,8 +4199,8 @@ static int32_t splitCacheLastFuncOptimize(SOptimizeContext* pCxt, SLogicSubplan* { WHERE_EACH(pNode, pAgg->node.pTargets) { SColumnNode* pCol = (SColumnNode*)pNode; - SNode* pFuncNode = NULL; - bool found = false; + SNode* pFuncNode = NULL; + bool found = false; FOREACH(pFuncNode, pAggFuncList) { SFunctionNode* pFunc = (SFunctionNode*)pFuncNode; if (0 == strcmp(pFunc->node.aliasName, pCol->colName)) { @@ -4217,7 +4213,7 @@ static int32_t splitCacheLastFuncOptimize(SOptimizeContext* pCxt, SLogicSubplan* ERASE_NODE(pAgg->node.pTargets); continue; } - WHERE_NEXT; + WHERE_NEXT; } } @@ -4228,8 +4224,8 @@ static int32_t splitCacheLastFuncOptimize(SOptimizeContext* pCxt, SLogicSubplan* } SMergeLogicNode* pMerge = NULL; - SAggLogicNode* pNewAgg = NULL; - int32_t code = splitCacheLastFuncOptCreateAggLogicNode(&pNewAgg, pAgg, pAggFuncList, pTargets); + SAggLogicNode* pNewAgg = NULL; + int32_t code = splitCacheLastFuncOptCreateAggLogicNode(&pNewAgg, pAgg, pAggFuncList, pTargets); if (TSDB_CODE_SUCCESS == code) { code = splitCacheLastFuncOptModifyAggLogicNode(pAgg); } @@ -4240,19 +4236,17 @@ static int32_t splitCacheLastFuncOptimize(SOptimizeContext* pCxt, SLogicSubplan* code = replaceLogicNode(pLogicSubplan, (SLogicNode*)pAgg, (SLogicNode*)pMerge); } - nodesDestroyNode((SNode *)pAgg); - nodesDestroyNode((SNode *)pNewAgg); + nodesDestroyNode((SNode*)pAgg); + nodesDestroyNode((SNode*)pNewAgg); if (TSDB_CODE_SUCCESS != code) { - nodesDestroyNode((SNode *)pMerge); + nodesDestroyNode((SNode*)pMerge); } - + pCxt->optimized = true; return code; } - - // merge projects static bool mergeProjectsMayBeOptimized(SLogicNode* pNode) { if (QUERY_NODE_LOGIC_PLAN_PROJECT != nodeType(pNode) || 1 != LIST_LENGTH(pNode->pChildren)) { @@ -4405,7 +4399,7 @@ static int32_t tagScanOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubp } pScanNode->onlyMetaCtbIdx = false; - + pCxt->optimized = true; return TSDB_CODE_SUCCESS; } @@ -4449,8 +4443,8 @@ static bool pushDownLimitTo(SLogicNode* pNodeWithLimit, SLogicNode* pNodeLimitPu // The scan below will do scanning with group order return cloneLimit(pNodeWithLimit, pNodeLimitPushTo, CLONE_SLIMIT); } - // else if not part by tag and tbname, the partition node below indicates that results are sorted, the agg node can - // be pipelined. + // else if not part by tag and tbname, the partition node below indicates that results are sorted, the agg node + // can be pipelined. if (nodeType(pNodeWithLimit) == QUERY_NODE_LOGIC_PLAN_PROJECT && LIST_LENGTH(pNodeLimitPushTo->pChildren) == 1) { SLogicNode* pChild = (SLogicNode*)nodesListGetNode(pNodeLimitPushTo->pChildren, 0); if (nodeType(pChild) == QUERY_NODE_LOGIC_PLAN_PARTITION) { @@ -5121,19 +5115,16 @@ static bool stbJoinOptShouldBeOptimized(SLogicNode* pNode) { return true; } - int32_t stbJoinOptAddFuncToScanNode(char* funcName, SScanLogicNode* pScan) { SFunctionNode* pUidFunc = createFunction(funcName, NULL); - snprintf(pUidFunc->node.aliasName, sizeof(pUidFunc->node.aliasName), "%s.%p", - pUidFunc->functionName, pUidFunc); - int32_t code = nodesListStrictAppend(pScan->pScanPseudoCols, (SNode *)pUidFunc); + snprintf(pUidFunc->node.aliasName, sizeof(pUidFunc->node.aliasName), "%s.%p", pUidFunc->functionName, pUidFunc); + int32_t code = nodesListStrictAppend(pScan->pScanPseudoCols, (SNode*)pUidFunc); if (TSDB_CODE_SUCCESS == code) { code = createColumnByRewriteExpr((SNode*)pUidFunc, &pScan->node.pTargets); } return code; } - int32_t stbJoinOptRewriteToTagScan(SLogicNode* pJoin, SNode* pNode) { SScanLogicNode* pScan = (SScanLogicNode*)pNode; SJoinLogicNode* pJoinNode = (SJoinLogicNode*)pJoin; @@ -5146,14 +5137,14 @@ int32_t stbJoinOptRewriteToTagScan(SLogicNode* pJoin, SNode* pNode) { pScan->onlyMetaCtbIdx = true; SNodeList* pTags = nodesMakeList(); - int32_t code = nodesCollectColumnsFromNode(pJoinNode->pTagEqCond, NULL, COLLECT_COL_TYPE_TAG, &pTags); + int32_t code = nodesCollectColumnsFromNode(pJoinNode->pTagEqCond, NULL, COLLECT_COL_TYPE_TAG, &pTags); if (TSDB_CODE_SUCCESS == code) { code = nodesCollectColumnsFromNode(pJoinNode->pTagOnCond, NULL, COLLECT_COL_TYPE_TAG, &pTags); } if (TSDB_CODE_SUCCESS == code) { SNode* pTarget = NULL; SNode* pTag = NULL; - bool found = false; + bool found = false; WHERE_EACH(pTarget, pScan->node.pTargets) { found = false; SColumnNode* pTargetCol = (SColumnNode*)pTarget; @@ -5170,7 +5161,7 @@ int32_t stbJoinOptRewriteToTagScan(SLogicNode* pJoin, SNode* pNode) { WHERE_NEXT; } } - } + } if (TSDB_CODE_SUCCESS == code) { code = stbJoinOptAddFuncToScanNode("_tbuid", pScan); } @@ -5181,7 +5172,7 @@ int32_t stbJoinOptRewriteToTagScan(SLogicNode* pJoin, SNode* pNode) { if (code) { nodesDestroyList(pTags); } - + return code; } @@ -5192,7 +5183,7 @@ static int32_t stbJoinOptCreateTagScanNode(SLogicNode* pJoin, SNodeList** ppList } int32_t code = TSDB_CODE_SUCCESS; - SNode* pNode = NULL; + SNode* pNode = NULL; FOREACH(pNode, pList) { code = stbJoinOptRewriteToTagScan(pJoin, pNode); if (code) { @@ -5234,9 +5225,10 @@ static int32_t stbJoinOptCreateTagHashJoinNode(SLogicNode* pOrig, SNodeList* pCh SNode* pNode = NULL; FOREACH(pNode, pChildren) { SScanLogicNode* pScan = (SScanLogicNode*)pNode; - SNode* pCol = NULL; + SNode* pCol = NULL; FOREACH(pCol, pScan->pScanPseudoCols) { - if (QUERY_NODE_FUNCTION == nodeType(pCol) && (((SFunctionNode*)pCol)->funcType == FUNCTION_TYPE_TBUID || ((SFunctionNode*)pCol)->funcType == FUNCTION_TYPE_VGID)) { + if (QUERY_NODE_FUNCTION == nodeType(pCol) && (((SFunctionNode*)pCol)->funcType == FUNCTION_TYPE_TBUID || + ((SFunctionNode*)pCol)->funcType == FUNCTION_TYPE_VGID)) { code = createColumnByRewriteExpr(pCol, &pJoin->node.pTargets); if (code) { break; @@ -5279,7 +5271,7 @@ static int32_t stbJoinOptCreateTableScanNodes(SLogicNode* pJoin, SNodeList** ppL int32_t code = TSDB_CODE_SUCCESS; int32_t i = 0; - SNode* pNode = NULL; + SNode* pNode = NULL; FOREACH(pNode, pList) { SScanLogicNode* pScan = (SScanLogicNode*)pNode; //code = stbJoinOptAddFuncToScanNode("_tbuid", pScan); @@ -5294,7 +5286,7 @@ static int32_t stbJoinOptCreateTableScanNodes(SLogicNode* pJoin, SNodeList** ppL pScan->node.dynamicOp = true; *(srcScan + i++) = pScan->pVgroupList->numOfVgroups <= 1; - + pScan->scanType = SCAN_TYPE_TABLE; } @@ -5304,13 +5296,13 @@ static int32_t stbJoinOptCreateTableScanNodes(SLogicNode* pJoin, SNodeList** ppL } static int32_t stbJoinOptCreateGroupCacheNode(SLogicNode* pRoot, SNodeList* pChildren, SLogicNode** ppLogic) { - int32_t code = TSDB_CODE_SUCCESS; + int32_t code = TSDB_CODE_SUCCESS; SGroupCacheLogicNode* pGrpCache = (SGroupCacheLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_GROUP_CACHE); if (NULL == pGrpCache) { return TSDB_CODE_OUT_OF_MEMORY; } - - //pGrpCache->node.dynamicOp = true; + + // pGrpCache->node.dynamicOp = true; pGrpCache->grpColsMayBeNull = false; pGrpCache->grpByUid = true; pGrpCache->batchFetch = getBatchScanOptionFromHint(pRoot->pHint); @@ -5325,9 +5317,10 @@ static int32_t stbJoinOptCreateGroupCacheNode(SLogicNode* pRoot, SNodeList* pChi } SScanLogicNode* pScan = (SScanLogicNode*)nodesListGetNode(pChildren, 0); - SNode* pCol = NULL; + SNode* pCol = NULL; FOREACH(pCol, pScan->pScanPseudoCols) { - if (QUERY_NODE_FUNCTION == nodeType(pCol) && (((SFunctionNode*)pCol)->funcType == FUNCTION_TYPE_TBUID || ((SFunctionNode*)pCol)->funcType == FUNCTION_TYPE_VGID)) { + if (QUERY_NODE_FUNCTION == nodeType(pCol) && (((SFunctionNode*)pCol)->funcType == FUNCTION_TYPE_TBUID || + ((SFunctionNode*)pCol)->funcType == FUNCTION_TYPE_VGID)) { code = createColumnByRewriteExpr(pCol, &pGrpCache->pGroupCols); if (code) { break; @@ -5335,7 +5328,7 @@ static int32_t stbJoinOptCreateGroupCacheNode(SLogicNode* pRoot, SNodeList* pChi } } - bool hasCond = false; + bool hasCond = false; SNode* pNode = NULL; FOREACH(pNode, pChildren) { SScanLogicNode* pScan = (SScanLogicNode*)pNode; @@ -5345,7 +5338,7 @@ static int32_t stbJoinOptCreateGroupCacheNode(SLogicNode* pRoot, SNodeList* pChi pScan->node.pParent = (SLogicNode*)pGrpCache; } pGrpCache->globalGrp = false; - + if (TSDB_CODE_SUCCESS == code) { *ppLogic = (SLogicNode*)pGrpCache; } else { @@ -5397,16 +5390,14 @@ static int32_t stbJoinOptCreateMergeJoinNode(SLogicNode* pOrig, SLogicNode* pChi } pJoin->joinAlgo = JOIN_ALGO_MERGE; - //pJoin->node.dynamicOp = true; + // pJoin->node.dynamicOp = true; stbJoinOptRemoveTagEqCond(pJoin); NODES_DESTORY_NODE(pJoin->pTagEqCond); - + SNode* pNode = NULL; - FOREACH(pNode, pJoin->node.pChildren) { - ERASE_NODE(pJoin->node.pChildren); - } - int32_t code = nodesListStrictAppend(pJoin->node.pChildren, (SNode *)pChild); + FOREACH(pNode, pJoin->node.pChildren) { ERASE_NODE(pJoin->node.pChildren); } + int32_t code = nodesListStrictAppend(pJoin->node.pChildren, (SNode*)pChild); if (TSDB_CODE_SUCCESS == code) { pChild->pParent = (SLogicNode*)pJoin; *ppLogic = (SLogicNode*)pJoin; @@ -5418,8 +5409,9 @@ static int32_t stbJoinOptCreateMergeJoinNode(SLogicNode* pOrig, SLogicNode* pChi return code; } -static int32_t stbJoinOptCreateDynQueryCtrlNode(SLogicNode* pRoot, SLogicNode* pPrev, SLogicNode* pPost, bool* srcScan, SLogicNode** ppDynNode) { - int32_t code = TSDB_CODE_SUCCESS; +static int32_t stbJoinOptCreateDynQueryCtrlNode(SLogicNode* pRoot, SLogicNode* pPrev, SLogicNode* pPost, bool* srcScan, + SLogicNode** ppDynNode) { + int32_t code = TSDB_CODE_SUCCESS; SDynQueryCtrlLogicNode* pDynCtrl = (SDynQueryCtrlLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_DYN_QUERY_CTRL); if (NULL == pDynCtrl) { return TSDB_CODE_OUT_OF_MEMORY; @@ -5428,22 +5420,22 @@ static int32_t stbJoinOptCreateDynQueryCtrlNode(SLogicNode* pRoot, SLogicNode* p pDynCtrl->qType = DYN_QTYPE_STB_HASH; pDynCtrl->stbJoin.batchFetch = getBatchScanOptionFromHint(pRoot->pHint); memcpy(pDynCtrl->stbJoin.srcScan, srcScan, sizeof(pDynCtrl->stbJoin.srcScan)); - - if (TSDB_CODE_SUCCESS == code) { + + if (TSDB_CODE_SUCCESS == code) { pDynCtrl->node.pChildren = nodesMakeList(); if (NULL == pDynCtrl->node.pChildren) { code = TSDB_CODE_OUT_OF_MEMORY; } } - if (TSDB_CODE_SUCCESS == code) { + if (TSDB_CODE_SUCCESS == code) { pDynCtrl->stbJoin.pVgList = nodesMakeList(); if (NULL == pDynCtrl->stbJoin.pVgList) { code = TSDB_CODE_OUT_OF_MEMORY; } } - if (TSDB_CODE_SUCCESS == code) { + if (TSDB_CODE_SUCCESS == code) { pDynCtrl->stbJoin.pUidList = nodesMakeList(); if (NULL == pDynCtrl->stbJoin.pUidList) { code = TSDB_CODE_OUT_OF_MEMORY; @@ -5472,7 +5464,7 @@ static int32_t stbJoinOptCreateDynQueryCtrlNode(SLogicNode* pRoot, SLogicNode* p if (TSDB_CODE_SUCCESS == code) { pPrev->pParent = (SLogicNode*)pDynCtrl; pPost->pParent = (SLogicNode*)pDynCtrl; - + *ppDynNode = (SLogicNode*)pDynCtrl; } else { nodesDestroyNode((SNode*)pDynCtrl); @@ -5488,9 +5480,9 @@ static int32_t stbJoinOptRewriteStableJoin(SOptimizeContext* pCxt, SLogicNode* p SLogicNode* pGrpCacheNode = NULL; SLogicNode* pHJoinNode = NULL; SLogicNode* pMJoinNode = NULL; - SLogicNode* pDynNode = NULL; + SLogicNode* pDynNode = NULL; bool srcScan[2] = {0}; - + int32_t code = stbJoinOptCreateTagScanNode(pJoin, &pTagScanNodes); if (TSDB_CODE_SUCCESS == code) { code = stbJoinOptCreateTagHashJoinNode(pJoin, pTagScanNodes, &pHJoinNode); @@ -5642,8 +5634,8 @@ static bool partColOptShouldBeOptimized(SLogicNode* pNode) { } static SSortLogicNode* partColOptCreateSort(SPartitionLogicNode* pPartition) { - SNode* node; - int32_t code = TSDB_CODE_SUCCESS; + SNode* node; + int32_t code = TSDB_CODE_SUCCESS; SSortLogicNode* pSort = (SSortLogicNode*)nodesMakeNode(QUERY_NODE_LOGIC_PLAN_SORT); if (pSort) { bool alreadyPartByPKTs = false; @@ -5703,7 +5695,6 @@ static int32_t partitionColsOpt(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub if (NULL == pNode) return TSDB_CODE_SUCCESS; SLogicNode* pRootNode = getLogicNodeRootNode((SLogicNode*)pNode); - if (pRootNode->pHint && getSortForGroupOptHint(pRootNode->pHint)) { // replace with sort node SSortLogicNode* pSort = partColOptCreateSort(pNode); @@ -5767,6 +5758,808 @@ static int32_t partitionColsOpt(SOptimizeContext* pCxt, SLogicSubplan* pLogicSub return code; } +static bool tsmaOptMayBeOptimized(SLogicNode* pNode) { + if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pNode)) { + SNode* pTmpNode; + SNodeList* pFuncs = NULL; + SScanLogicNode* pScan = (SScanLogicNode*)pNode; + SLogicNode* pParent = pScan->node.pParent; + SNode* pConds = pScan->node.pConditions; + + if (pScan->scanType != SCAN_TYPE_TABLE || !pParent || pConds) return false; + if (!pScan->pTsmas || pScan->pTsmas->size <= 0) { + return false; + } + + switch (nodeType(pParent)) { + case QUERY_NODE_LOGIC_PLAN_WINDOW: { + SWindowLogicNode* pWindow = (SWindowLogicNode*)pParent; + // only time window interval supported + if (pWindow->winType != WINDOW_TYPE_INTERVAL) return false; + pFuncs = pWindow->pFuncs; + } break; + case QUERY_NODE_LOGIC_PLAN_AGG: { + SAggLogicNode* pAgg = (SAggLogicNode*)pParent; + // group/partition by normal cols not supported + if (pAgg->pGroupKeys) return false; + pFuncs = pAgg->pAggFuncs; + } break; + default: + return false; + } + + assert(pFuncs); + FOREACH(pTmpNode, pFuncs) { + SFunctionNode* pFunc = (SFunctionNode*)pTmpNode; + if (!fmIsTSMASupportedFunc(pFunc->funcId) && !fmIsPseudoColumnFunc(pFunc->funcId) && + !fmIsGroupKeyFunc(pFunc->funcId)) { + return false; + } + } + + return true; + } + return false; +} + +typedef struct STSMAOptUsefulTsma { + const STableTSMAInfo* pTsma; // NULL if no tsma available, which will use original data for calculation + STimeWindow scanRange; // scan time range for this tsma + SArray* pTsmaScanCols; // SArray index of tsmaFuncs array + char targetTbName[TSDB_TABLE_NAME_LEN]; // the scanning table name, used only when pTsma is not NULL + uint64_t targetTbUid; // the scanning table uid, used only when pTsma is not NULL +} STSMAOptUsefulTsma; + +typedef struct STSMAOptCtx { + // input + SScanLogicNode* pScan; + SLogicNode* pParent; // parent of Table Scan, Agg or Interval + const SNodeList* pAggFuncs; + const STimeWindow* pTimeRange; + const SArray* pTsmas; + SInterval* queryInterval; // not null with window logic node + int8_t precision; + + // output + SArray* pUsefulTsmas; // SArray, sorted by tsma interval from long to short + SArray* pUsedTsmas; + SLogicSubplan* generatedSubPlans[2]; + SNodeList** ppParentTsmaSubplans; +} STSMAOptCtx; + +static int32_t fillTSMAOptCtx(STSMAOptCtx* pTsmaOptCtx, SScanLogicNode* pScan) { + int32_t code = 0; + pTsmaOptCtx->pScan = pScan; + pTsmaOptCtx->pParent = pScan->node.pParent; + pTsmaOptCtx->pTsmas = pScan->pTsmas; + pTsmaOptCtx->pTimeRange = &pScan->scanRange; + pTsmaOptCtx->precision = pScan->node.precision; + + if (nodeType(pTsmaOptCtx->pParent) == QUERY_NODE_LOGIC_PLAN_WINDOW) { + pTsmaOptCtx->queryInterval = taosMemoryCalloc(1, sizeof(SInterval)); + if (!pTsmaOptCtx->queryInterval) return TSDB_CODE_OUT_OF_MEMORY; + + SWindowLogicNode* pWindow = (SWindowLogicNode*)pTsmaOptCtx->pParent; + pTsmaOptCtx->queryInterval->interval = pWindow->interval; + pTsmaOptCtx->queryInterval->intervalUnit = pWindow->intervalUnit; + pTsmaOptCtx->queryInterval->offset = pWindow->offset; + pTsmaOptCtx->queryInterval->offsetUnit = pWindow->intervalUnit; + pTsmaOptCtx->queryInterval->sliding = pWindow->sliding; + pTsmaOptCtx->queryInterval->slidingUnit = pWindow->slidingUnit; + pTsmaOptCtx->queryInterval->precision = pWindow->node.precision; + pTsmaOptCtx->queryInterval->tz = tsTimezone; + pTsmaOptCtx->pAggFuncs = pWindow->pFuncs; + pTsmaOptCtx->ppParentTsmaSubplans = &pWindow->pTsmaSubplans; + } else { + ASSERT(nodeType(pTsmaOptCtx->pParent) == QUERY_NODE_LOGIC_PLAN_AGG); + SAggLogicNode* pAgg = (SAggLogicNode*)pTsmaOptCtx->pParent; + pTsmaOptCtx->pAggFuncs = pAgg->pAggFuncs; + pTsmaOptCtx->ppParentTsmaSubplans = &pAgg->pTsmaSubplans; + } + pTsmaOptCtx->pUsefulTsmas = taosArrayInit(pScan->pTsmas->size, sizeof(STSMAOptUsefulTsma)); + pTsmaOptCtx->pUsedTsmas = taosArrayInit(3, sizeof(STSMAOptUsefulTsma)); + if (!pTsmaOptCtx->pUsefulTsmas || !pTsmaOptCtx->pUsedTsmas) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + return code; +} + +static void tsmaOptFreeUsefulTsma(void* p) { + STSMAOptUsefulTsma* pTsma = p; + taosArrayDestroy(pTsma->pTsmaScanCols); +} + +static void clearTSMAOptCtx(STSMAOptCtx* pTsmaOptCtx) { + taosArrayDestroyEx(pTsmaOptCtx->pUsefulTsmas, tsmaOptFreeUsefulTsma); + taosArrayDestroy(pTsmaOptCtx->pUsedTsmas); + taosMemoryFreeClear(pTsmaOptCtx->queryInterval); +} + +static bool tsmaOptCheckValidInterval(int64_t tsmaInterval, int8_t tsmaIntevalUnit, const STSMAOptCtx* pTsmaOptCtx) { + if (!pTsmaOptCtx->queryInterval) return true; + + bool validInterval = pTsmaOptCtx->queryInterval->interval % tsmaInterval == 0; + bool validSliding = pTsmaOptCtx->queryInterval->sliding % tsmaInterval == 0; + bool validOffset = pTsmaOptCtx->queryInterval->offset % tsmaInterval == 0; + return validInterval && validSliding && validOffset; +} + +static bool tsmaOptCheckValidFuncs(const SArray* pTsmaFuncs, const SNodeList* pQueryFuncs, SArray* pTsmaScanCols) { + SNode* pNode; + bool failed = false, found = false; + + taosArrayClear(pTsmaScanCols); + FOREACH(pNode, pQueryFuncs) { + SFunctionNode* pQueryFunc = (SFunctionNode*)pNode; + if (fmIsPseudoColumnFunc(pQueryFunc->funcId) || fmIsGroupKeyFunc(pQueryFunc->funcId)) continue; + if (nodeType(pQueryFunc->pParameterList->pHead->pNode) != QUERY_NODE_COLUMN) { + failed = true; + break; + } + int32_t queryColId = ((SColumnNode*)pQueryFunc->pParameterList->pHead->pNode)->colId; + found = false; + int32_t notMyStateFuncId = -1; + // iterate funcs + for (int32_t i = 0; i < pTsmaFuncs->size; i++) { + STableTSMAFuncInfo* pTsmaFuncInfo = taosArrayGet(pTsmaFuncs, i); + if (pTsmaFuncInfo->funcId == notMyStateFuncId) continue; + + if (!fmIsMyStateFunc(pQueryFunc->funcId, pTsmaFuncInfo->funcId)) { + notMyStateFuncId = pTsmaFuncInfo->funcId; + continue; + } + + if (queryColId != pTsmaFuncInfo->colId) { + continue; + } + found = true; + taosArrayPush(pTsmaScanCols, &i); + break; + } + if (failed || !found) { + break; + } + } + return found; +} + +typedef struct STsmaOptTagCheckCtx { + const STableTSMAInfo* pTsma; + bool ok; +} STsmaOptTagCheckCtx; + +static EDealRes tsmaOptTagCheck(SNode* pNode, void* pContext) { + bool found = false; + if (nodeType(pNode) == QUERY_NODE_COLUMN) { + SColumnNode* pCol = (SColumnNode*)pNode; + if (pCol->colType == COLUMN_TYPE_TAG) { + STsmaOptTagCheckCtx* pCtx = pContext; + for (int32_t i = 0; i < pCtx->pTsma->pTags->size; ++i) { + SSchema* pSchema = taosArrayGet(pCtx->pTsma->pTags, i); + if (pSchema->colId == pCol->colId) { + found = true; + } + } + if (!found) { + pCtx->ok = false; + return DEAL_RES_END; + } + } + } + return DEAL_RES_CONTINUE; +} + +static bool tsmaOptCheckTags(STSMAOptCtx* pCtx, const STableTSMAInfo* pTsma) { + const SScanLogicNode* pScan = pCtx->pScan; + STsmaOptTagCheckCtx ctx = {.pTsma = pTsma, .ok = true}; + nodesWalkExpr(pScan->pTagCond, tsmaOptTagCheck, &ctx); + if (!ctx.ok) return false; + nodesWalkExprs(pScan->pScanPseudoCols, tsmaOptTagCheck, &ctx); + if (!ctx.ok) return false; + nodesWalkExprs(pScan->pGroupTags, tsmaOptTagCheck, &ctx); + return ctx.ok; +} + +static int32_t tsmaOptFilterTsmas(STSMAOptCtx* pTsmaOptCtx) { + STSMAOptUsefulTsma usefulTsma = {.pTsma = NULL, .scanRange = {.skey = TSKEY_MIN, .ekey = TSKEY_MAX}}; + SArray* pTsmaScanCols = NULL; + + for (int32_t i = 0; i < pTsmaOptCtx->pTsmas->size; ++i) { + if (!pTsmaScanCols) { + pTsmaScanCols = taosArrayInit(pTsmaOptCtx->pAggFuncs->length, sizeof(int32_t)); + if (!pTsmaScanCols) return TSDB_CODE_OUT_OF_MEMORY; + } + if (pTsmaOptCtx->pScan->tableType == TSDB_CHILD_TABLE || pTsmaOptCtx->pScan->tableType == TSDB_NORMAL_TABLE) { + const STsmaTargetTbInfo* ptbInfo = taosArrayGet(pTsmaOptCtx->pScan->pTsmaTargetTbInfo, i); + if (ptbInfo->uid == 0) continue; // tsma res table meta not found, skip this tsma, this is possible when there is no data in this ctb + } + + STableTSMAInfo* pTsma = taosArrayGetP(pTsmaOptCtx->pTsmas, i); + if (!pTsma->fillHistoryFinished || tsMaxTsmaCalcDelay * 1000 < (pTsma->rspTs - pTsma->reqTs) + pTsma->delayDuration) { + continue; + } + // filter with interval + if (!tsmaOptCheckValidInterval(pTsma->interval, pTsma->unit, pTsmaOptCtx)) { + continue; + } + // filter with funcs, note that tsma funcs has been sorted by funcId and ColId + if (!tsmaOptCheckValidFuncs(pTsma->pFuncs, pTsmaOptCtx->pAggFuncs, pTsmaScanCols)) { + continue; + } + + if (!tsmaOptCheckTags(pTsmaOptCtx, pTsma)) continue; + usefulTsma.pTsma = pTsma; + usefulTsma.pTsmaScanCols = pTsmaScanCols; + pTsmaScanCols = NULL; + taosArrayPush(pTsmaOptCtx->pUsefulTsmas, &usefulTsma); + } + if (pTsmaScanCols) taosArrayDestroy(pTsmaScanCols); + return TSDB_CODE_SUCCESS; +} + +static int32_t tsmaInfoCompWithIntervalDesc(const void* pLeft, const void* pRight) { + const STSMAOptUsefulTsma *p = pLeft, *q = pRight; + int64_t pInterval = p->pTsma->interval, qInterval = q->pTsma->interval; + int32_t code = getDuration(pInterval, p->pTsma->unit, &pInterval, TSDB_TIME_PRECISION_MILLI); + ASSERT(code == TSDB_CODE_SUCCESS); + code = getDuration(qInterval, q->pTsma->unit, &qInterval, TSDB_TIME_PRECISION_MILLI); + ASSERT(code == TSDB_CODE_SUCCESS); + if (pInterval > qInterval) return -1; + if (pInterval < qInterval) return 1; + return 0; +} + +static const STSMAOptUsefulTsma* tsmaOptFindUsefulTsma(const SArray* pUsefulTsmas, int32_t startIdx, + int64_t alignInterval, int64_t alignInterval2, + int8_t precision) { + int64_t tsmaInterval; + for (int32_t i = startIdx; i < pUsefulTsmas->size; ++i) { + const STSMAOptUsefulTsma* pUsefulTsma = taosArrayGet(pUsefulTsmas, i); + getDuration(pUsefulTsma->pTsma->interval, pUsefulTsma->pTsma->unit, &tsmaInterval, precision); + if (alignInterval % tsmaInterval == 0 && alignInterval2 % tsmaInterval == 0) { + return pUsefulTsma; + } + } + return NULL; +} + +static void tsmaOptInitIntervalFromTsma(SInterval* pInterval, const STableTSMAInfo* pTsma, int8_t precision) { + pInterval->interval = pTsma->interval; + pInterval->intervalUnit = pTsma->unit; + pInterval->sliding = pTsma->interval; + pInterval->slidingUnit = pTsma->unit; + pInterval->offset = 0; + pInterval->offsetUnit = pTsma->unit; + pInterval->precision = precision; +} + +static void tsmaOptSplitWindows(STSMAOptCtx* pTsmaOptCtx, const STimeWindow* pScanRange) { + bool needTailWindow = false; + bool isSkeyAlignedWithTsma = true, isEkeyAlignedWithTsma = true; + int64_t winSkey = TSKEY_MIN, winEkey = TSKEY_MAX; + int64_t startOfSkeyFirstWin = pScanRange->skey, endOfSkeyFirstWin; + int64_t startOfEkeyFirstWin = pScanRange->ekey, endOfEkeyFirstWin; + int64_t tsmaInterval; + SInterval interval; + STimeWindow scanRange = *pScanRange; + const SInterval* pInterval = pTsmaOptCtx->queryInterval; + const STSMAOptUsefulTsma* pUsefulTsma = taosArrayGet(pTsmaOptCtx->pUsefulTsmas, 0); + const STableTSMAInfo* pTsma = pUsefulTsma->pTsma; + + if (pScanRange->ekey <= pScanRange->skey) return; + + if (!pInterval) { + tsmaOptInitIntervalFromTsma(&interval, pTsma, pTsmaOptCtx->precision); + pInterval = &interval; + } + + tsmaInterval = pTsma->interval; + + // check for head windows + if (pScanRange->skey != TSKEY_MIN) { + startOfSkeyFirstWin = taosTimeTruncate(pScanRange->skey, pInterval); + endOfSkeyFirstWin = + taosTimeAdd(startOfSkeyFirstWin, pInterval->interval, pInterval->intervalUnit, pTsmaOptCtx->precision); + isSkeyAlignedWithTsma = ((pScanRange->skey - startOfSkeyFirstWin) % tsmaInterval == 0); + } else { + endOfSkeyFirstWin = TSKEY_MIN; + } + + // check for tail windows + if (pScanRange->ekey != TSKEY_MAX) { + startOfEkeyFirstWin = taosTimeTruncate(pScanRange->ekey, pInterval); + endOfEkeyFirstWin = + taosTimeAdd(startOfEkeyFirstWin, pInterval->interval, pInterval->intervalUnit, pTsmaOptCtx->precision); + isEkeyAlignedWithTsma = ((pScanRange->ekey + 1 - startOfEkeyFirstWin) % tsmaInterval == 0); + if (startOfEkeyFirstWin > startOfSkeyFirstWin) { + needTailWindow = true; + } + } + + // add head tsma if possible + if (!isSkeyAlignedWithTsma) { + scanRange.ekey = TMIN( + scanRange.ekey, + taosTimeAdd(startOfSkeyFirstWin, pInterval->interval * 1, pInterval->intervalUnit, pTsmaOptCtx->precision) - 1); + const STSMAOptUsefulTsma* pTsmaFound = + tsmaOptFindUsefulTsma(pTsmaOptCtx->pUsefulTsmas, 1, scanRange.skey - startOfSkeyFirstWin, + (scanRange.ekey + 1 - startOfSkeyFirstWin), pTsmaOptCtx->precision); + STSMAOptUsefulTsma usefulTsma = {.pTsma = pTsmaFound ? pTsmaFound->pTsma : NULL, + .scanRange = scanRange, + .pTsmaScanCols = pTsmaFound ? pTsmaFound->pTsmaScanCols : NULL}; + taosArrayPush(pTsmaOptCtx->pUsedTsmas, &usefulTsma); + } + + // the main tsma + if (endOfSkeyFirstWin < startOfEkeyFirstWin || (endOfSkeyFirstWin == startOfEkeyFirstWin && (isSkeyAlignedWithTsma || isEkeyAlignedWithTsma))) { + scanRange.ekey = + TMIN(pScanRange->ekey, isEkeyAlignedWithTsma ? pScanRange->ekey : startOfEkeyFirstWin - 1); + if (!isSkeyAlignedWithTsma) { + scanRange.skey = endOfSkeyFirstWin; + } + STSMAOptUsefulTsma usefulTsma = { + .pTsma = pTsma, .scanRange = scanRange, .pTsmaScanCols = pUsefulTsma->pTsmaScanCols}; + taosArrayPush(pTsmaOptCtx->pUsedTsmas, &usefulTsma); + } + + // add tail tsma if possible + if (!isEkeyAlignedWithTsma && needTailWindow) { + scanRange.skey = startOfEkeyFirstWin; + scanRange.ekey = pScanRange->ekey; + const STSMAOptUsefulTsma* pTsmaFound = + tsmaOptFindUsefulTsma(pTsmaOptCtx->pUsefulTsmas, 1, scanRange.skey - startOfEkeyFirstWin, + scanRange.ekey + 1 - startOfEkeyFirstWin, pTsmaOptCtx->precision); + STSMAOptUsefulTsma usefulTsma = {.pTsma = pTsmaFound ? pTsmaFound->pTsma : NULL, + .scanRange = scanRange, + .pTsmaScanCols = pTsmaFound ? pTsmaFound->pTsmaScanCols : NULL}; + taosArrayPush(pTsmaOptCtx->pUsedTsmas, &usefulTsma); + } +} + +SNodeList* tsmaOptCreateTsmaScanCols(const STSMAOptUsefulTsma* pTsma, const SNodeList* pAggFuncs) { + ASSERT(pTsma->pTsma); + ASSERT(pTsma->pTsmaScanCols); + int32_t code; + SNode* pNode; + SNodeList* pScanCols = NULL; + + int32_t i = 0; + + FOREACH(pNode, pAggFuncs) { + SFunctionNode* pFunc = (SFunctionNode*)pNode; + if (fmIsPseudoColumnFunc(pFunc->funcId) || fmIsGroupKeyFunc(pFunc->funcId)) { + continue; + } + const int32_t* idx = taosArrayGet(pTsma->pTsmaScanCols, i); + SColumnNode* pCol = (SColumnNode*)nodesMakeNode(QUERY_NODE_COLUMN); + if (pCol) { + pCol->colId = *idx + 2; + pCol->tableType = TSDB_SUPER_TABLE; + pCol->tableId = pTsma->targetTbUid; + pCol->colType = COLUMN_TYPE_COLUMN; + strcpy(pCol->tableName, pTsma->targetTbName); + strcpy(pCol->dbName, pTsma->pTsma->targetDbFName); + strcpy(pCol->colName, pFunc->node.aliasName); + strcpy(pCol->node.aliasName, pFunc->node.aliasName); + pCol->node.resType.type = TSDB_DATA_TYPE_BINARY; + code = nodesListMakeStrictAppend(&pScanCols, (SNode*)pCol); + } else { + code = TSDB_CODE_OUT_OF_MEMORY; + } + if (code) break; + ++i; + } + + if (code) { + nodesDestroyList(pScanCols); + pScanCols = NULL; + } + return pScanCols; +} + +static int32_t tsmaOptRewriteTag(const STSMAOptCtx* pTsmaOptCtx, const STSMAOptUsefulTsma* pTsma, + SColumnNode* pTagCol) { + bool found = false; + if (pTagCol->colType != COLUMN_TYPE_TAG) return 0; + for (int32_t i = 0; i < pTsma->pTsma->pTags->size; ++i) { + const SSchema* pSchema = taosArrayGet(pTsma->pTsma->pTags, i); + if (strcmp(pTagCol->colName, pSchema->name) == 0) { + strcpy(pTagCol->tableName, pTsma->targetTbName); + strcpy(pTagCol->tableAlias, pTsma->targetTbName); + pTagCol->tableId = pTsma->targetTbUid; + pTagCol->tableType = TSDB_SUPER_TABLE; + pTagCol->colId = pSchema->colId; + found = true; + break; + } + } + ASSERT(found); + return 0; +} + +static int32_t tsmaOptRewriteTbname(const STSMAOptCtx* pTsmaOptCtx, SNode** pTbNameNode, + const STSMAOptUsefulTsma* pTsma) { + int32_t code = 0; + SExprNode* pRewrittenFunc = (SExprNode*)nodesMakeNode(pTsma ? QUERY_NODE_COLUMN : QUERY_NODE_FUNCTION); + SValueNode* pValue = NULL; + if (!pRewrittenFunc) code = TSDB_CODE_OUT_OF_MEMORY; + if (code == TSDB_CODE_SUCCESS) { + pRewrittenFunc->resType = ((SExprNode*)(*pTbNameNode))->resType; + } + + if (pTsma && code == TSDB_CODE_SUCCESS) { + nodesDestroyNode(*pTbNameNode); + SColumnNode* pCol = (SColumnNode*)pRewrittenFunc; + const SSchema* pSchema = taosArrayGet(pTsma->pTsma->pTags, pTsma->pTsma->pTags->size - 1); + strcpy(pCol->tableName, pTsma->targetTbName); + strcpy(pCol->tableAlias, pTsma->targetTbName); + pCol->tableId = pTsma->targetTbUid; + pCol->tableType = TSDB_SUPER_TABLE; + pCol->colId = pSchema->colId; + pCol->colType = COLUMN_TYPE_TAG; + } else if (code == TSDB_CODE_SUCCESS) { + // if no tsma, we replace func tbname with concat('', tbname) + SFunctionNode* pFunc = (SFunctionNode*)pRewrittenFunc; + pFunc->funcId = fmGetFuncId("concat"); + snprintf(pFunc->functionName, TSDB_FUNC_NAME_LEN, "concat"); + pValue = (SValueNode*)nodesMakeNode(QUERY_NODE_VALUE); + if (!pValue) code = TSDB_CODE_OUT_OF_MEMORY; + + if (code == TSDB_CODE_SUCCESS) { + pValue->translate = true; + pValue->node.resType = ((SExprNode*)(*pTbNameNode))->resType; + pValue->literal = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN + 1); + pValue->datum.p = taosMemoryCalloc(1, TSDB_TABLE_FNAME_LEN + 1 + VARSTR_HEADER_SIZE); + if (!pValue->literal || !pValue->datum.p) code = TSDB_CODE_OUT_OF_MEMORY; + } + + if (code == TSDB_CODE_SUCCESS) { + code = nodesListMakeStrictAppend(&pFunc->pParameterList, (SNode*)pValue); + pValue = NULL; + } + if (code == TSDB_CODE_SUCCESS) { + code = nodesListStrictAppend(pFunc->pParameterList, *pTbNameNode); + } + } + + if (code == TSDB_CODE_SUCCESS) { + *pTbNameNode = (SNode*)pRewrittenFunc; + } else { + nodesDestroyNode((SNode*)pRewrittenFunc); + if (pValue) nodesDestroyNode((SNode*)pValue); + } + + return code; +} + +struct TsmaOptRewriteCtx { + const STSMAOptCtx* pTsmaOptCtx; + const STSMAOptUsefulTsma* pTsma; + bool rewriteTag; + bool rewriteTbname; + int32_t code; +}; + +EDealRes tsmaOptNodeRewriter(SNode** ppNode, void* ctx) { + SNode* pNode = *ppNode; + int32_t code = 0; + struct TsmaOptRewriteCtx* pCtx = ctx; + if (pCtx->rewriteTag && nodeType(pNode) == QUERY_NODE_COLUMN && ((SColumnNode*)pNode)->colType == COLUMN_TYPE_TAG) { + code = tsmaOptRewriteTag(pCtx->pTsmaOptCtx, pCtx->pTsma, (SColumnNode*)pNode); + } else if (pCtx->rewriteTbname && + ((nodeType(pNode) == QUERY_NODE_FUNCTION && ((SFunctionNode*)pNode)->funcType == FUNCTION_TYPE_TBNAME) || + (nodeType(pNode) == QUERY_NODE_COLUMN && ((SColumnNode*)pNode)->colType == COLUMN_TYPE_TBNAME))) { + code = tsmaOptRewriteTbname(pCtx->pTsmaOptCtx, ppNode, pCtx->pTsma); + if (code == TSDB_CODE_SUCCESS) return DEAL_RES_IGNORE_CHILD; + } + if (code) { + pCtx->code = code; + return DEAL_RES_ERROR; + } + return DEAL_RES_CONTINUE; +} + +static int32_t tsmaOptRewriteNode(SNode** pNode, STSMAOptCtx* pCtx, const STSMAOptUsefulTsma* pTsma, bool rewriteTbName, bool rewriteTag) { + struct TsmaOptRewriteCtx ctx = { + .pTsmaOptCtx = pCtx, .pTsma = pTsma, .rewriteTag = rewriteTag, .rewriteTbname = rewriteTbName, .code = 0}; + SNode* pOut = *pNode; + nodesRewriteExpr(&pOut, tsmaOptNodeRewriter, &ctx); + if (ctx.code == TSDB_CODE_SUCCESS) *pNode = pOut; + return ctx.code; +} + +static int32_t tsmaOptRewriteNodeList(SNodeList* pNodes, STSMAOptCtx* pCtx, const STSMAOptUsefulTsma* pTsma, + bool rewriteTbName, bool rewriteTag) { + int32_t code = 0; + SNode* pNode; + FOREACH(pNode, pNodes) { + SNode* pOut = pNode; + code = tsmaOptRewriteNode(&pOut, pCtx, pTsma, rewriteTbName, rewriteTag); + if (TSDB_CODE_SUCCESS != code) break; + REPLACE_NODE(pOut); + } + return code; +} + +static int32_t tsmaOptRewriteScan(STSMAOptCtx* pTsmaOptCtx, SScanLogicNode* pNewScan, const STSMAOptUsefulTsma* pTsma) { + SNode* pNode; + int32_t code = 0; + + pNewScan->scanRange.skey = pTsma->scanRange.skey; + pNewScan->scanRange.ekey = pTsma->scanRange.ekey; + + if (pTsma->pTsma) { + // PK col + SColumnNode* pPkTsCol = NULL; + FOREACH(pNode, pNewScan->pScanCols) { + SColumnNode* pCol = (SColumnNode*)pNode; + ASSERT(pTsma->pTsmaScanCols); + if (pCol->colId == PRIMARYKEY_TIMESTAMP_COL_ID) { + pPkTsCol = (SColumnNode*)nodesCloneNode((SNode*)pCol); + if (!pPkTsCol) { + code = TSDB_CODE_OUT_OF_MEMORY; + } + break; + } + } + if (code == TSDB_CODE_SUCCESS) { + nodesDestroyList(pNewScan->pScanCols); + // normal cols + pNewScan->pScanCols = tsmaOptCreateTsmaScanCols(pTsma, pTsmaOptCtx->pAggFuncs); + if (!pNewScan->pScanCols) code = TSDB_CODE_OUT_OF_MEMORY; + } + if (code == TSDB_CODE_SUCCESS && pPkTsCol) { + tstrncpy(pPkTsCol->tableName, pTsma->targetTbName, TSDB_TABLE_NAME_LEN); + tstrncpy(pPkTsCol->tableAlias, pTsma->targetTbName, TSDB_TABLE_NAME_LEN); + pPkTsCol->tableId = pTsma->targetTbUid; + nodesListMakeStrictAppend(&pNewScan->pScanCols, nodesCloneNode((SNode*)pPkTsCol)); + } + if (code == TSDB_CODE_SUCCESS) { + pNewScan->stableId = pTsma->pTsma->destTbUid; + pNewScan->tableId = pTsma->targetTbUid; + strcpy(pNewScan->tableName.tname, pTsma->targetTbName); + } + if (code == TSDB_CODE_SUCCESS) { + code = tsmaOptRewriteNodeList(pNewScan->pScanPseudoCols, pTsmaOptCtx, pTsma, true, true); + } + if (code == TSDB_CODE_SUCCESS) { + code = tsmaOptRewriteNode(&pNewScan->pTagCond, pTsmaOptCtx, pTsma, true, true); + } + if (code == TSDB_CODE_SUCCESS) { + code = tsmaOptRewriteNodeList(pNewScan->pGroupTags, pTsmaOptCtx, pTsma, true, true); + } + if (pTsmaOptCtx->pScan->pTsmaTargetTbVgInfo && pTsmaOptCtx->pScan->pTsmaTargetTbVgInfo->size > 0) { + for (int32_t i = 0; i < taosArrayGetSize(pTsmaOptCtx->pScan->pTsmas); ++i) { + STableTSMAInfo* pTsmaInfo = taosArrayGetP(pTsmaOptCtx->pScan->pTsmas, i); + if (pTsmaInfo == pTsma->pTsma) { + const SVgroupsInfo* pVgpsInfo = taosArrayGetP(pTsmaOptCtx->pScan->pTsmaTargetTbVgInfo, i); + taosMemoryFreeClear(pNewScan->pVgroupList); + int32_t len = sizeof(int32_t) + sizeof(SVgroupInfo) * pVgpsInfo->numOfVgroups; + pNewScan->pVgroupList = taosMemoryCalloc(1, len); + memcpy(pNewScan->pVgroupList, pVgpsInfo, len); + break; + } + } + } + } else { + FOREACH(pNode, pNewScan->pGroupTags) { + // rewrite tbname recursively + struct TsmaOptRewriteCtx ctx = { + .pTsmaOptCtx = pTsmaOptCtx, .pTsma = NULL, .rewriteTag = false, .rewriteTbname = true, .code = 0}; + nodesRewriteExpr(&pNode, tsmaOptNodeRewriter, &ctx); + if (ctx.code) { + code = ctx.code; + } else { + REPLACE_NODE(pNode); + } + } + } + return code; +} + +static int32_t tsmaOptCreateWStart(int8_t precision, SFunctionNode** pWStartOut) { + SFunctionNode* pWStart = (SFunctionNode*)nodesMakeNode(QUERY_NODE_FUNCTION); + if (NULL == pWStart) { + return TSDB_CODE_OUT_OF_MEMORY; + } + strcpy(pWStart->functionName, "_wstart"); + int64_t pointer = (int64_t)pWStart; + char name[TSDB_COL_NAME_LEN + TSDB_POINTER_PRINT_BYTES + TSDB_NAME_DELIMITER_LEN + 1] = {0}; + int32_t len = snprintf(name, sizeof(name) - 1, "%s.%" PRId64 "", pWStart->functionName, pointer); + taosCreateMD5Hash(name, len); + strncpy(pWStart->node.aliasName, name, TSDB_COL_NAME_LEN - 1); + pWStart->node.resType.precision = precision; + + int32_t code = fmGetFuncInfo(pWStart, NULL, 0); + if (code) { + nodesDestroyNode((SNode*)pWStart); + } else { + *pWStartOut = pWStart; + } + return code; +} + +static int32_t tsmaOptRewriteParent(STSMAOptCtx* pTsmaOptCtx, SLogicNode* pParent, SScanLogicNode* pScan, + const STSMAOptUsefulTsma* pTsma) { + int32_t code = 0; + SColumnNode* pColNode; + SWindowLogicNode* pWindow = NULL; + SAggLogicNode* pAgg; + SNodeList* pAggFuncs; + SListCell* pScanListCell; + SNode* pAggFuncNode; + SNodeList* pAggStateFuncs = NULL; + bool isFirstMergeNode = pTsmaOptCtx->pScan == pScan; + SFunctionNode * pPartial = NULL, *pMerge = NULL; + + if (nodeType(pParent) == QUERY_NODE_LOGIC_PLAN_WINDOW) { + pWindow = (SWindowLogicNode*)pParent; + pAggFuncs = pWindow->pFuncs; + } else { + pAgg = (SAggLogicNode*)pParent; + pAggFuncs = pAgg->pAggFuncs; + } + pScanListCell = pScan->pScanCols->pHead; + + FOREACH(pAggFuncNode, pAggFuncs) { + SFunctionNode* pAggFunc = (SFunctionNode*)pAggFuncNode; + if (fmIsGroupKeyFunc(pAggFunc->funcId)) { + struct TsmaOptRewriteCtx ctx = { + .pTsmaOptCtx = pTsmaOptCtx, .pTsma = pTsma, .rewriteTag = true, .rewriteTbname = true, .code = 0}; + nodesRewriteExpr(&pAggFuncNode, tsmaOptNodeRewriter, &ctx); + if (ctx.code) { + code = ctx.code; + } else { + REPLACE_NODE(pAggFuncNode); + } + continue; + } else if (fmIsPseudoColumnFunc(pAggFunc->funcId)) { + continue; + } + code = fmGetDistMethod(pAggFunc, &pPartial, NULL, &pMerge); + if (code) break; + + pColNode = (SColumnNode*)pScanListCell->pNode; + pScanListCell = pScanListCell->pNext; + pColNode->node.resType = pPartial->node.resType; + // currently we assume that the first parameter must be the scan column + nodesListErase(pMerge->pParameterList, pMerge->pParameterList->pHead); + nodesListPushFront(pMerge->pParameterList, nodesCloneNode((SNode*)pColNode)); + + nodesDestroyNode((SNode*)pPartial); + REPLACE_NODE(pMerge); + } + + if (code == TSDB_CODE_SUCCESS && pWindow) { + SColumnNode* pCol = (SColumnNode*)pScan->pScanCols->pTail->pNode; + assert(pCol->colId == PRIMARYKEY_TIMESTAMP_COL_ID); + nodesDestroyNode(pWindow->pTspk); + pWindow->pTspk = nodesCloneNode((SNode*)pCol); + } + + if (code == TSDB_CODE_SUCCESS) { + nodesDestroyList(pScan->node.pTargets); + code = createColumnByRewriteExprs(pScan->pScanCols, &pScan->node.pTargets); + } + if (code == TSDB_CODE_SUCCESS) { + code = createColumnByRewriteExprs(pScan->pScanPseudoCols, &pScan->node.pTargets); + } + + return code; +} + +static int32_t tsmaOptGeneratePlan(STSMAOptCtx* pTsmaOptCtx) { + int32_t code = 0; + const STSMAOptUsefulTsma* pTsma = NULL; + SNodeList* pAggFuncs = NULL; + bool hasSubPlan = false; + + for (int32_t i = 0; i < pTsmaOptCtx->pUsedTsmas->size; ++i) { + STSMAOptUsefulTsma* pTsma = taosArrayGet(pTsmaOptCtx->pUsedTsmas, i); + if (!pTsma->pTsma) continue; + if (pTsmaOptCtx->pScan->tableType == TSDB_CHILD_TABLE || pTsmaOptCtx->pScan->tableType == TSDB_NORMAL_TABLE) { + for (int32_t j = 0; j < pTsmaOptCtx->pScan->pTsmas->size; ++j) { + if (taosArrayGetP(pTsmaOptCtx->pScan->pTsmas, j) == pTsma->pTsma) { + const STsmaTargetTbInfo* ptbInfo = taosArrayGet(pTsmaOptCtx->pScan->pTsmaTargetTbInfo, j); + ASSERT(ptbInfo->uid != 0); + strcpy(pTsma->targetTbName, ptbInfo->tableName); + pTsma->targetTbUid = ptbInfo->uid; + } + } + } else { + strcpy(pTsma->targetTbName, pTsma->pTsma->targetTb); + pTsma->targetTbUid = pTsma->pTsma->destTbUid; + } + } + + for (int32_t i = 1; i < pTsmaOptCtx->pUsedTsmas->size && code == TSDB_CODE_SUCCESS; ++i) { + pTsma = taosArrayGet(pTsmaOptCtx->pUsedTsmas, i); + SLogicSubplan* pSubplan = (SLogicSubplan*)nodesMakeNode(QUERY_NODE_LOGIC_SUBPLAN); + if (!pSubplan) { + code = TSDB_CODE_OUT_OF_MEMORY; + break; + } + pSubplan->subplanType = SUBPLAN_TYPE_SCAN; + pTsmaOptCtx->generatedSubPlans[i - 1] = pSubplan; + hasSubPlan = true; + SLogicNode* pParent = (SLogicNode*)nodesCloneNode((SNode*)pTsmaOptCtx->pParent); + if (!pParent) { + code = TSDB_CODE_OUT_OF_MEMORY; + break; + } + pSubplan->pNode = pParent; + pParent->pParent = NULL; + pParent->groupAction = GROUP_ACTION_KEEP; + SScanLogicNode* pScan = (SScanLogicNode*)pParent->pChildren->pHead->pNode; + code = tsmaOptRewriteScan(pTsmaOptCtx, pScan, pTsma); + if (code == TSDB_CODE_SUCCESS && pTsma->pTsma) { + code = tsmaOptRewriteParent(pTsmaOptCtx, pParent, pScan, pTsma); + } + } + + if (code == TSDB_CODE_SUCCESS) { + pTsma = taosArrayGet(pTsmaOptCtx->pUsedTsmas, 0); + pTsmaOptCtx->pScan->needSplit = hasSubPlan; + code = tsmaOptRewriteScan(pTsmaOptCtx, pTsmaOptCtx->pScan, pTsma); + if (code == TSDB_CODE_SUCCESS && pTsma->pTsma) { + code = tsmaOptRewriteParent(pTsmaOptCtx, pTsmaOptCtx->pParent, pTsmaOptCtx->pScan, pTsma); + } + } + + return code; +} + +static bool tsmaOptIsUsingTsmas(STSMAOptCtx* pCtx) { + if (pCtx->pUsedTsmas->size == 0) { + return false; + } + for (int32_t i = 0; i < pCtx->pUsedTsmas->size; ++i) { + const STSMAOptUsefulTsma*pTsma = taosArrayGet(pCtx->pUsedTsmas, i); + if (pTsma->pTsma) return true; + } + return false; +} + +static int32_t tsmaOptimize(SOptimizeContext* pCxt, SLogicSubplan* pLogicSubplan) { + int32_t code = 0; + STSMAOptCtx tsmaOptCtx = {0}; + SScanLogicNode* pScan = (SScanLogicNode*)optFindPossibleNode(pLogicSubplan->pNode, tsmaOptMayBeOptimized); + if (!pScan) return code; + + SLogicNode* pRootNode = getLogicNodeRootNode((SLogicNode*)pScan); + if (getOptHint(pRootNode->pHint, HINT_SKIP_TSMA)) return code; + + code = fillTSMAOptCtx(&tsmaOptCtx, pScan); + if (code == TSDB_CODE_SUCCESS) { + // 1. extract useful tsmas + code = tsmaOptFilterTsmas(&tsmaOptCtx); + + if (code == TSDB_CODE_SUCCESS && tsmaOptCtx.pUsefulTsmas->size > 0) { + // 2. sort useful tsmas with interval + taosArraySort(tsmaOptCtx.pUsefulTsmas, tsmaInfoCompWithIntervalDesc); + // 3. split windows + tsmaOptSplitWindows(&tsmaOptCtx, tsmaOptCtx.pTimeRange); + if (tsmaOptIsUsingTsmas(&tsmaOptCtx)) { + // 4. create logic plan + code = tsmaOptGeneratePlan(&tsmaOptCtx); + + if (TSDB_CODE_SUCCESS == code) { + for (int32_t i = 0; i < 2; i++) { + SLogicSubplan* pSubplan = tsmaOptCtx.generatedSubPlans[i]; + if (!pSubplan) continue; + pSubplan->subplanType = SUBPLAN_TYPE_SCAN; + nodesListMakeAppend(tsmaOptCtx.ppParentTsmaSubplans, (SNode*)pSubplan); + } + pCxt->optimized = true; + } + } + } + } + pScan->pTsmas = NULL; + clearTSMAOptCtx(&tsmaOptCtx); + return code; +} + // clang-format off static const SOptimizeRule optimizeRuleSet[] = { {.pName = "ScanPath", .optimizeFunc = scanPathOptimize}, @@ -5791,6 +6584,7 @@ static const SOptimizeRule optimizeRuleSet[] = { {.pName = "EliminateProject", .optimizeFunc = eliminateProjOptimize}, {.pName = "EliminateSetOperator", .optimizeFunc = eliminateSetOpOptimize}, {.pName = "PartitionCols", .optimizeFunc = partitionColsOpt}, + {.pName = "Tsma", .optimizeFunc = tsmaOptimize}, }; // clang-format on diff --git a/source/libs/planner/src/planPhysiCreater.c b/source/libs/planner/src/planPhysiCreater.c index 8a40060caa..e7e0be6d57 100644 --- a/source/libs/planner/src/planPhysiCreater.c +++ b/source/libs/planner/src/planPhysiCreater.c @@ -1556,6 +1556,17 @@ static int32_t rewritePrecalcExpr(SPhysiPlanContext* pCxt, SNode* pNode, SNodeLi return code; } +static EDealRes hasCountLikeFunc(SNode* pNode, void* res) { + if (QUERY_NODE_FUNCTION == nodeType(pNode)) { + SFunctionNode* pFunc = (SFunctionNode*)pNode; + if (fmIsCountLikeFunc(pFunc->funcId) || (pFunc->hasOriginalFunc && fmIsCountLikeFunc(pFunc->originalFuncId))) { + *(bool*)res = true; + return DEAL_RES_END; + } + } + return DEAL_RES_CONTINUE; +} + static int32_t createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, SAggLogicNode* pAggLogicNode, SPhysiNode** pPhyNode, SSubplan* pSubPlan) { SAggPhysiNode* pAgg = @@ -1579,6 +1590,7 @@ static int32_t createAggPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren, if (TSDB_CODE_SUCCESS == code) { code = rewritePrecalcExprs(pCxt, pAggLogicNode->pAggFuncs, &pPrecalcExprs, &pAggFuncs); } + nodesWalkExprs(pAggFuncs, hasCountLikeFunc, &pAgg->hasCountLikeFunc); SDataBlockDescNode* pChildTupe = (((SPhysiNode*)nodesListGetNode(pChildren, 0))->pOutputDataBlockDesc); // push down expression to pOutputDataBlockDesc of child node @@ -2282,13 +2294,13 @@ static int32_t createFillPhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildren return code; } -static int32_t createExchangePhysiNodeByMerge(SMergePhysiNode* pMerge) { +static int32_t createExchangePhysiNodeByMerge(SMergePhysiNode* pMerge, int32_t idx) { SExchangePhysiNode* pExchange = (SExchangePhysiNode*)nodesMakeNode(QUERY_NODE_PHYSICAL_PLAN_EXCHANGE); if (NULL == pExchange) { return TSDB_CODE_OUT_OF_MEMORY; } - pExchange->srcStartGroupId = pMerge->srcGroupId; - pExchange->srcEndGroupId = pMerge->srcGroupId; + pExchange->srcStartGroupId = pMerge->srcGroupId + idx; + pExchange->srcEndGroupId = pMerge->srcGroupId + idx; pExchange->singleChannel = true; pExchange->node.pParent = (SPhysiNode*)pMerge; pExchange->node.pOutputDataBlockDesc = (SDataBlockDescNode*)nodesCloneNode((SNode*)pMerge->node.pOutputDataBlockDesc); @@ -2319,6 +2331,7 @@ static int32_t createMergePhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildre pMerge->numOfChannels = pMergeLogicNode->numOfChannels; pMerge->srcGroupId = pMergeLogicNode->srcGroupId; + pMerge->srcEndGroupId = pMergeLogicNode->srcEndGroupId; pMerge->groupSort = pMergeLogicNode->groupSort; pMerge->ignoreGroupId = pMergeLogicNode->ignoreGroupId; pMerge->inputWithGroupId = pMergeLogicNode->inputWithGroupId; @@ -2327,11 +2340,14 @@ static int32_t createMergePhysiNode(SPhysiPlanContext* pCxt, SNodeList* pChildre code = addDataBlockSlots(pCxt, pMergeLogicNode->pInputs, pMerge->node.pOutputDataBlockDesc); if (TSDB_CODE_SUCCESS == code) { - for (int32_t i = 0; i < pMerge->numOfChannels; ++i) { - code = createExchangePhysiNodeByMerge(pMerge); - if (TSDB_CODE_SUCCESS != code) { - break; + for (int32_t j = 0; j < pMergeLogicNode->numOfSubplans; ++j) { + for (int32_t i = 0; i < pMerge->numOfChannels; ++i) { + code = createExchangePhysiNodeByMerge(pMerge, j); + if (TSDB_CODE_SUCCESS != code) { + break; + } } + if (code) break; } } diff --git a/source/libs/planner/src/planSpliter.c b/source/libs/planner/src/planSpliter.c index 010002d77a..ac1035e7c8 100644 --- a/source/libs/planner/src/planSpliter.c +++ b/source/libs/planner/src/planSpliter.c @@ -39,6 +39,11 @@ typedef struct SSplitRule { FSplit splitFunc; } SSplitRule; +typedef struct SFindSplitNodeCtx { + const SSplitContext* pSplitCtx; + const SLogicSubplan* pSubplan; +} SFindSplitNodeCtx; + typedef bool (*FSplFindSplitNode)(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode, void* pInfo); static int32_t stbSplCreateMergeKeys(SNodeList* pSortKeys, SNodeList* pTargets, SNodeList** pOutput); @@ -150,7 +155,8 @@ static bool splIsChildSubplan(SLogicNode* pLogicNode, int32_t groupId) { } if (QUERY_NODE_LOGIC_PLAN_MERGE == nodeType(pLogicNode)) { - return ((SMergeLogicNode*)pLogicNode)->srcGroupId == groupId; + return ((SMergeLogicNode*)pLogicNode)->srcGroupId <= groupId && + ((SMergeLogicNode*)pLogicNode)->srcEndGroupId >= groupId; } SNode* pChild; @@ -232,7 +238,7 @@ static bool stbSplHasGatherExecFunc(const SNodeList* pFuncs) { } static bool stbSplIsMultiTbScan(bool streamQuery, SScanLogicNode* pScan) { - return (NULL != pScan->pVgroupList && pScan->pVgroupList->numOfVgroups > 1); + return (NULL != pScan->pVgroupList && pScan->pVgroupList->numOfVgroups > 1) || pScan->needSplit; } static bool stbSplHasMultiTbScan(bool streamQuery, SLogicNode* pNode) { @@ -249,6 +255,13 @@ static bool stbSplHasMultiTbScan(bool streamQuery, SLogicNode* pNode) { if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pChild) && stbSplIsMultiTbScan(streamQuery, (SScanLogicNode*)pChild)) { return true; } + + if (QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pChild)) { + if (QUERY_NODE_LOGIC_PLAN_AGG == nodeType(pNode) || (QUERY_NODE_LOGIC_PLAN_WINDOW == nodeType(pNode) && + ((SWindowLogicNode*)pNode)->winType == WINDOW_TYPE_INTERVAL)) { + return ((SScanLogicNode*)pChild)->needSplit; + } + } return false; } @@ -312,7 +325,8 @@ static bool stbSplIsTableCountQuery(SLogicNode* pNode) { return QUERY_NODE_LOGIC_PLAN_SCAN == nodeType(pChild) && SCAN_TYPE_TABLE_COUNT == ((SScanLogicNode*)pChild)->scanType; } -static bool stbSplNeedSplit(bool streamQuery, SLogicNode* pNode) { +static bool stbSplNeedSplit(SFindSplitNodeCtx* pCtx, SLogicNode* pNode) { + bool streamQuery = pCtx->pSplitCtx->pPlanCxt->streamQuery; switch (nodeType(pNode)) { case QUERY_NODE_LOGIC_PLAN_SCAN: return streamQuery ? false : stbSplIsMultiTbScan(streamQuery, (SScanLogicNode*)pNode); @@ -323,7 +337,7 @@ static bool stbSplNeedSplit(bool streamQuery, SLogicNode* pNode) { case QUERY_NODE_LOGIC_PLAN_AGG: return (!stbSplHasGatherExecFunc(((SAggLogicNode*)pNode)->pAggFuncs) || isPartTableAgg((SAggLogicNode*)pNode)) && - stbSplHasMultiTbScan(streamQuery, pNode) && !stbSplIsTableCountQuery(pNode); + (stbSplHasMultiTbScan(streamQuery, pNode) && !stbSplIsTableCountQuery(pNode)); case QUERY_NODE_LOGIC_PLAN_WINDOW: return stbSplNeedSplitWindow(streamQuery, pNode); case QUERY_NODE_LOGIC_PLAN_SORT: @@ -336,7 +350,8 @@ static bool stbSplNeedSplit(bool streamQuery, SLogicNode* pNode) { static bool stbSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SLogicNode* pNode, SStableSplitInfo* pInfo) { - if (stbSplNeedSplit(pCxt->pPlanCxt->streamQuery, pNode)) { + SFindSplitNodeCtx ctx = {.pSplitCtx = pCxt, .pSubplan = pSubplan}; + if (stbSplNeedSplit(&ctx, pNode)) { pInfo->pSplitNode = pNode; pInfo->pSubplan = pSubplan; return true; @@ -641,9 +656,11 @@ static int32_t stbSplCreateMergeNode(SSplitContext* pCxt, SLogicSubplan* pSubpla pMerge->needSort = needSort; pMerge->numOfChannels = stbSplGetNumOfVgroups(pPartChild); pMerge->srcGroupId = pCxt->groupId; + pMerge->srcEndGroupId = pCxt->groupId; pMerge->node.precision = pPartChild->precision; pMerge->pMergeKeys = pMergeKeys; pMerge->groupSort = groupSort; + pMerge->numOfSubplans = 1; int32_t code = TSDB_CODE_SUCCESS; pMerge->pInputs = nodesCloneList(pPartChild->pTargets); @@ -725,9 +742,36 @@ static int32_t stbSplSplitIntervalForBatch(SSplitContext* pCxt, SStableSplitInfo nodesDestroyList(pMergeKeys); } } + SLogicSubplan* pSplitSubPlan = NULL; if (TSDB_CODE_SUCCESS == code) { - code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, - (SNode*)splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT)); + pSplitSubPlan = splCreateScanSubplan(pCxt, pPartWindow, SPLIT_FLAG_STABLE_SPLIT); + if (!pSplitSubPlan) code = TSDB_CODE_OUT_OF_MEMORY; + } + if (code == TSDB_CODE_SUCCESS) { + SNode* pNode; + SMergeLogicNode* pMerge = (SMergeLogicNode*)pInfo->pSplitNode->pChildren->pHead->pNode; + SWindowLogicNode* pWindow = (SWindowLogicNode*)pInfo->pSplitNode; + if (LIST_LENGTH(pWindow->pTsmaSubplans) > 0) { + FOREACH(pNode, pWindow->pTsmaSubplans) { + ++(pCxt->groupId); + SLogicSubplan* pSubplan = (SLogicSubplan*)pNode; + pSubplan->id.groupId = pCxt->groupId; + pSubplan->id.queryId = pCxt->queryId; + pSubplan->splitFlag = SPLIT_FLAG_STABLE_SPLIT; + splSetSubplanVgroups(pSubplan, pSubplan->pNode); + code = stbSplCreatePartWindowNode((SWindowLogicNode*)pSubplan->pNode, &pPartWindow); + if (TSDB_CODE_SUCCESS == code) { + nodesDestroyNode((SNode*)pSubplan->pNode); + pSubplan->pNode = pPartWindow; + } + } + code = nodesListMakeStrictAppendList(&pInfo->pSubplan->pChildren, pWindow->pTsmaSubplans); + pMerge->numOfSubplans = LIST_LENGTH(pInfo->pSubplan->pChildren) + 1; + } + pMerge->srcEndGroupId = pCxt->groupId; + } + if (code == TSDB_CODE_SUCCESS) { + code = nodesListMakePushFront(&pInfo->pSubplan->pChildren, (SNode*)pSplitSubPlan); } pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; ++(pCxt->groupId); @@ -942,7 +986,8 @@ static int32_t stbSplSplitWindowForPartTable(SSplitContext* pCxt, SStableSplitIn } static int32_t stbSplSplitWindowNode(SSplitContext* pCxt, SStableSplitInfo* pInfo) { - if (isPartTableWinodw((SWindowLogicNode*)pInfo->pSplitNode)) { + if (isPartTableWinodw((SWindowLogicNode*)pInfo->pSplitNode) && + (LIST_LENGTH(((SWindowLogicNode*)pInfo->pSplitNode)->pTsmaSubplans) == 0)) { return stbSplSplitWindowForPartTable(pCxt, pInfo); } else { return stbSplSplitWindowForCrossTable(pCxt, pInfo); @@ -1096,29 +1141,99 @@ static int32_t stbSplAggNodeCreateMerge(SSplitContext* pCtx, SStableSplitInfo* p return code; } +static int32_t stbSplSplitAggNodeForCrossTableMulSubplan(SSplitContext* pCxt, SStableSplitInfo* pInfo) { + SLogicNode* pPartAgg = NULL; + bool hasExchange = false; + SMergeLogicNode* pMergeNode = NULL; + SLogicSubplan* pFirstScanSubplan = NULL; + int32_t code = stbSplCreatePartAggNode((SAggLogicNode*)pInfo->pSplitNode, &pPartAgg); + + if (TSDB_CODE_SUCCESS == code) { + if (pInfo->pSplitNode->forceCreateNonBlockingOptr) { + code = stbSplAggNodeCreateMerge(pCxt, pInfo, pPartAgg); + } else { + hasExchange = true; + code = stbSplCreateMergeNode(pCxt, NULL, pInfo->pSplitNode, NULL, pPartAgg, false, false); + } + pMergeNode = + (SMergeLogicNode*)nodesListGetNode(pInfo->pSplitNode->pChildren, LIST_LENGTH(pInfo->pSplitNode->pChildren) - 1); + } else { + nodesDestroyNode((SNode*)pPartAgg); + } + + if (code == TSDB_CODE_SUCCESS) { + pFirstScanSubplan = splCreateScanSubplan(pCxt, pPartAgg, SPLIT_FLAG_STABLE_SPLIT); + if (!pFirstScanSubplan) code = TSDB_CODE_OUT_OF_MEMORY; + } + + if (code == TSDB_CODE_SUCCESS) { + SNode* pNode; + SAggLogicNode* pAgg = (SAggLogicNode*)pInfo->pSplitNode; + if (LIST_LENGTH(pAgg->pTsmaSubplans) > 0) { + FOREACH(pNode, pAgg->pTsmaSubplans) { + ++(pCxt->groupId); + SLogicSubplan* pSubplan = (SLogicSubplan*)pNode; + pSubplan->id.groupId = pCxt->groupId; + pSubplan->id.queryId = pCxt->queryId; + pSubplan->splitFlag = SPLIT_FLAG_STABLE_SPLIT; + splSetSubplanVgroups(pSubplan, pSubplan->pNode); + code = stbSplCreatePartAggNode((SAggLogicNode*)pSubplan->pNode, &pPartAgg); + if (code) break; + nodesDestroyNode((SNode*)pSubplan->pNode); + pSubplan->pNode = pPartAgg; + } + code = nodesListMakeStrictAppendList(&pInfo->pSubplan->pChildren, pAgg->pTsmaSubplans); + pMergeNode->numOfSubplans = LIST_LENGTH(pInfo->pSubplan->pChildren) + 1; + } + pMergeNode->srcEndGroupId = pCxt->groupId; + } + + if (code == TSDB_CODE_SUCCESS) { + code = nodesListMakeAppend(&pInfo->pSubplan->pChildren, (SNode*)pFirstScanSubplan); + } + + if (code && pFirstScanSubplan) { + nodesDestroyNode((SNode*)pFirstScanSubplan); + } + + pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; + ++(pCxt->groupId); + return code; +} + static int32_t stbSplSplitAggNodeForCrossTable(SSplitContext* pCxt, SStableSplitInfo* pInfo) { SLogicNode* pPartAgg = NULL; int32_t code = stbSplCreatePartAggNode((SAggLogicNode*)pInfo->pSplitNode, &pPartAgg); - if (TSDB_CODE_SUCCESS == code) { // if slimit was pushed down to agg, agg will be pipelined mode, add sort merge before parent agg if (pInfo->pSplitNode->forceCreateNonBlockingOptr) code = stbSplAggNodeCreateMerge(pCxt, pInfo, pPartAgg); - else + else { code = stbSplCreateExchangeNode(pCxt, pInfo->pSplitNode, pPartAgg); + } } else { nodesDestroyNode((SNode*)pPartAgg); } + + SLogicSubplan* pScanSubplan = NULL; if (TSDB_CODE_SUCCESS == code) { - code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, - (SNode*)splCreateScanSubplan(pCxt, pPartAgg, SPLIT_FLAG_STABLE_SPLIT)); + pScanSubplan = splCreateScanSubplan(pCxt, pPartAgg, SPLIT_FLAG_STABLE_SPLIT); + if (!pScanSubplan) code = TSDB_CODE_OUT_OF_MEMORY; } + + if (code == TSDB_CODE_SUCCESS) { + code = nodesListMakeStrictAppend(&pInfo->pSubplan->pChildren, (SNode*)pScanSubplan); + } + pInfo->pSubplan->subplanType = SUBPLAN_TYPE_MERGE; ++(pCxt->groupId); return code; } static int32_t stbSplSplitAggNode(SSplitContext* pCxt, SStableSplitInfo* pInfo) { + if (LIST_LENGTH(((SAggLogicNode*)pInfo->pSplitNode)->pTsmaSubplans) > 0) { + return stbSplSplitAggNodeForCrossTableMulSubplan(pCxt, pInfo); + } if (isPartTableAgg((SAggLogicNode*)pInfo->pSplitNode)) { return stbSplSplitAggNodeForPartTable(pCxt, pInfo); } @@ -1712,6 +1827,7 @@ static bool unDistSplFindSplitNode(SSplitContext* pCxt, SLogicSubplan* pSubplan, SUnionDistinctSplitInfo* pInfo) { if (QUERY_NODE_LOGIC_PLAN_AGG == nodeType(pNode) && LIST_LENGTH(pNode->pChildren) > 1) { pInfo->pAgg = (SAggLogicNode*)pNode; + if (!pInfo->pAgg->pGroupKeys) return false; pInfo->pSubplan = pSubplan; return true; } diff --git a/source/libs/planner/src/planner.c b/source/libs/planner/src/planner.c index a4a33b30fd..78ae541166 100644 --- a/source/libs/planner/src/planner.c +++ b/source/libs/planner/src/planner.c @@ -79,7 +79,7 @@ static int32_t setSubplanExecutionNode(SPhysiNode* pNode, int32_t groupId, SDown } } else if (QUERY_NODE_PHYSICAL_PLAN_MERGE == nodeType(pNode)) { SMergePhysiNode* pMerge = (SMergePhysiNode*)pNode; - if (pMerge->srcGroupId == groupId) { + if (pMerge->srcGroupId <= groupId && pMerge->srcEndGroupId >= groupId) { SExchangePhysiNode* pExchange = (SExchangePhysiNode*)nodesListGetNode(pMerge->node.pChildren, pMerge->numOfChannels - 1); if (1 == pMerge->numOfChannels) { diff --git a/source/libs/qcom/src/querymsg.c b/source/libs/qcom/src/querymsg.c index 7948bbbceb..04cef3e644 100644 --- a/source/libs/qcom/src/querymsg.c +++ b/source/libs/qcom/src/querymsg.c @@ -304,6 +304,58 @@ int32_t queryBuildGetViewMetaMsg(void *input, char **msg, int32_t msgSize, int32 return TSDB_CODE_SUCCESS; } +int32_t queryBuildGetTableTSMAMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, + void *(*mallcFp)(int64_t)) { + if (NULL == msg || NULL == msgLen) { + return TSDB_CODE_TSC_INVALID_INPUT; + } + + STableTSMAInfoReq req = {0}; + strncpy(req.name, input, sizeof(req.name) - 1); + + int32_t bufLen = tSerializeTableTSMAInfoReq(NULL, 0, &req); + void * pBuf = (*mallcFp)(bufLen); + tSerializeTableTSMAInfoReq(pBuf, bufLen, &req); + + *msg = pBuf; + *msgLen = bufLen; + return TSDB_CODE_SUCCESS; +} + +int32_t queryBuildGetTSMAMsg(void *input, char **msg, int32_t msgSize, int32_t *msgLen, + void *(*mallcFp)(int64_t)) { + if (NULL == msg || NULL == msgLen) { + return TSDB_CODE_TSC_INVALID_INPUT; + } + + STableTSMAInfoReq req = {0}; + req.fetchingWithTsmaName = true; + strncpy(req.name, input, sizeof(req.name) - 1); + + int32_t bufLen = tSerializeTableTSMAInfoReq(NULL, 0, &req); + void * pBuf = (*mallcFp)(bufLen); + tSerializeTableTSMAInfoReq(pBuf, bufLen, &req); + + *msg = pBuf; + *msgLen = bufLen; + return TSDB_CODE_SUCCESS; +} + +int32_t queryBuildGetStreamProgressMsg(void* input, char** msg, int32_t msgSize, int32_t *msgLen, void*(*mallcFp)(int64_t)) { + if (!msg || !msgLen) { + return TSDB_CODE_TSC_INVALID_INPUT; + } + + int32_t len = tSerializeStreamProgressReq(NULL, 0, input); + void* pBuf = (*mallcFp)(len); + + tSerializeStreamProgressReq(pBuf, len, input); + + *msg = pBuf; + *msgLen = len; + return TSDB_CODE_SUCCESS; +} + int32_t queryProcessUseDBRsp(void *output, char *msg, int32_t msgSize) { SUseDbOutput *pOut = output; SUseDbRsp usedbRsp = {0}; @@ -683,6 +735,31 @@ int32_t queryProcessGetViewMetaRsp(void *output, char *msg, int32_t msgSize) { return TSDB_CODE_SUCCESS; } +int32_t queryProcessGetTbTSMARsp(void* output, char* msg, int32_t msgSize) { + if (NULL == output || NULL == msg || msgSize <= 0) { + return TSDB_CODE_TSC_INVALID_INPUT; + } + + if (tDeserializeTableTSMAInfoRsp(msg, msgSize, output) != 0) { + qError("tDeserializeSViewMetaRsp failed, msgSize:%d", msgSize); + return TSDB_CODE_INVALID_MSG; + } + + return TSDB_CODE_SUCCESS; +} + +int32_t queryProcessStreamProgressRsp(void* output, char* msg, int32_t msgSize) { + if (!output || !msg || msgSize <= 0) { + return TSDB_CODE_TSC_INVALID_INPUT; + } + + if (tDeserializeSStreamProgressRsp(msg, msgSize, output) != 0) { + qError("tDeserializeStreamProgressRsp failed, msgSize: %d", msgSize); + return TSDB_CODE_INVALID_MSG; + } + return TSDB_CODE_SUCCESS; +} + void initQueryModuleMsgHandle() { queryBuildMsg[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryBuildTableMetaReqMsg; @@ -699,6 +776,9 @@ void initQueryModuleMsgHandle() { queryBuildMsg[TMSG_INDEX(TDMT_MND_TABLE_CFG)] = queryBuildGetTbCfgMsg; queryBuildMsg[TMSG_INDEX(TDMT_MND_SERVER_VERSION)] = queryBuildGetSerVerMsg; queryBuildMsg[TMSG_INDEX(TDMT_MND_VIEW_META)] = queryBuildGetViewMetaMsg; + queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_TABLE_TSMA)] = queryBuildGetTableTSMAMsg; + queryBuildMsg[TMSG_INDEX(TDMT_MND_GET_TSMA)] = queryBuildGetTSMAMsg; + queryBuildMsg[TMSG_INDEX(TDMT_VND_GET_STREAM_PROGRESS)] = queryBuildGetStreamProgressMsg; queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_TABLE_META)] = queryProcessTableMetaRsp; queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_TABLE_META)] = queryProcessTableMetaRsp; @@ -714,6 +794,9 @@ void initQueryModuleMsgHandle() { queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_TABLE_CFG)] = queryProcessGetTbCfgRsp; queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_SERVER_VERSION)] = queryProcessGetSerVerRsp; queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_VIEW_META)] = queryProcessGetViewMetaRsp; + queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_TABLE_TSMA)] = queryProcessGetTbTSMARsp; + queryProcessMsgRsp[TMSG_INDEX(TDMT_MND_GET_TSMA)] = queryProcessGetTbTSMARsp; + queryProcessMsgRsp[TMSG_INDEX(TDMT_VND_GET_STREAM_PROGRESS)] = queryProcessStreamProgressRsp; } #pragma GCC diagnostic pop diff --git a/source/libs/scalar/src/sclfunc.c b/source/libs/scalar/src/sclfunc.c index e732d1c587..da26d7e3b9 100644 --- a/source/libs/scalar/src/sclfunc.c +++ b/source/libs/scalar/src/sclfunc.c @@ -697,6 +697,36 @@ int32_t substrFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOu return TSDB_CODE_SUCCESS; } +int32_t md5Function(SScalarParam* pInput, int32_t inputNum, SScalarParam* pOutput) { + SColumnInfoData *pInputData = pInput->columnData; + SColumnInfoData *pOutputData = pOutput->columnData; + int32_t bufLen = TMAX(MD5_OUTPUT_LEN + VARSTR_HEADER_SIZE + 1, pInputData->info.bytes); + char* pOutputBuf = taosMemoryMalloc(bufLen); + if (!pOutputBuf) { + qError("md5 function alloc memory failed"); + return TSDB_CODE_OUT_OF_MEMORY; + } + for (int32_t i = 0; i < pInput->numOfRows; ++i) { + if (colDataIsNull_s(pInputData, i)) { + colDataSetNULL(pOutputData, i); + continue; + } + char *input = colDataGetData(pInput[0].columnData, i); + if (bufLen < varDataLen(input) + VARSTR_HEADER_SIZE) { + bufLen = varDataLen(input) + VARSTR_HEADER_SIZE; + pOutputBuf = taosMemoryRealloc(pOutputBuf, bufLen); + } + char *output = pOutputBuf; + memcpy(varDataVal(output), varDataVal(input), varDataLen(input)); + int32_t len = taosCreateMD5Hash(varDataVal(output), varDataLen(input)); + varDataSetLen(output, len); + colDataSetVal(pOutputData, i, output, false); + } + pOutput->numOfRows = pInput->numOfRows; + taosMemoryFree(pOutputBuf); + return TSDB_CODE_SUCCESS; +} + /** Conversion functions **/ int32_t castFunction(SScalarParam *pInput, int32_t inputNum, SScalarParam *pOutput) { int16_t inputType = GET_PARAM_TYPE(&pInput[0]); diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 2e9499b77d..a60fed59bf 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -322,9 +322,12 @@ TAOS_DEFINE_ERROR(TSDB_CODE_MND_TOO_MANY_STREAMS, "Too many streams") TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_TARGET_TABLE, "Cannot write the same stable as other stream") // mnode-sma -TAOS_DEFINE_ERROR(TSDB_CODE_MND_SMA_ALREADY_EXIST, "index already exists in db") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_SMA_NOT_EXIST, "index not exist") -TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_SMA_OPTION, "Invalid sma index option") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_SMA_ALREADY_EXIST, "SMA already exists") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_SMA_NOT_EXIST, "sma not exist") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_SMA_OPTION, "Invalid sma option") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_INVALID_DROP_TSMA, "Invalid drop base tsma, drop recursive tsma first") +TAOS_DEFINE_ERROR(TSDB_CODE_MND_MAX_TSMA_NUM_EXCEEDED, "Max tsma num exceeded") + // mnode-view TAOS_DEFINE_ERROR(TSDB_CODE_MND_VIEW_ALREADY_EXIST, "view already exists in db") @@ -686,6 +689,12 @@ TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_ENV, "Invalid tsma env") TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_STAT, "Invalid tsma state") TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_PTR, "Invalid tsma pointer") TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_PARA, "Invalid tsma parameters") +TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_TB, "Invalid table to create tsma, only stable or normal table allowed") +TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_INTERVAL, "Invalid tsma interval, 1ms ~ 1h is allowed") +TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_INVALID_FUNC_PARAM, "Invalid tsma func param, only one non-tag column allowed") +TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_UNSUPPORTED_FUNC, "Tsma func not supported") +TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_MUST_BE_DROPPED, "Tsma must be dropped first") +TAOS_DEFINE_ERROR(TSDB_CODE_TSMA_NAME_TOO_LONG, "Tsma name too long") //rsma TAOS_DEFINE_ERROR(TSDB_CODE_RSMA_INVALID_ENV, "Invalid rsma env") diff --git a/tests/army/frame/server/dnode.py b/tests/army/frame/server/dnode.py index 6331939636..fdb48e480d 100644 --- a/tests/army/frame/server/dnode.py +++ b/tests/army/frame/server/dnode.py @@ -47,20 +47,20 @@ class TDDnode: "locale": "en_US.UTF-8", "charset": "UTF-8", "asyncLog": "0", - "mDebugFlag": "143", - "dDebugFlag": "143", - "vDebugFlag": "143", - "tqDebugFlag": "143", - "cDebugFlag": "143", - "stDebugFlag": "143", - "smaDebugFlag": "143", - "jniDebugFlag": "143", - "qDebugFlag": "143", - "rpcDebugFlag": "143", + "mDebugFlag": "135", + "dDebugFlag": "131", + "vDebugFlag": "131", + "tqDebugFlag": "135", + "cDebugFlag": "135", + "stDebugFlag": "135", + "smaDebugFlag": "135", + "jniDebugFlag": "131", + "qDebugFlag": "131", + "rpcDebugFlag": "135", "tmrDebugFlag": "131", - "uDebugFlag": "135", - "sDebugFlag": "135", - "wDebugFlag": "135", + "uDebugFlag": "131", + "sDebugFlag": "131", + "wDebugFlag": "131", "numOfLogLines": "100000000", "statusInterval": "1", "enableQueryHb": "1", diff --git a/tests/develop-test/2-query/table_count_scan.py b/tests/develop-test/2-query/table_count_scan.py index 60899bc1c8..655499249a 100644 --- a/tests/develop-test/2-query/table_count_scan.py +++ b/tests/develop-test/2-query/table_count_scan.py @@ -65,7 +65,7 @@ class TDTestCase: tdSql.query('select count(*),db_name, stable_name from information_schema.ins_tables group by db_name, stable_name;') tdSql.checkRows(3) - tdSql.checkData(0, 0, 30) + tdSql.checkData(0, 0, 31) tdSql.checkData(0, 1, 'information_schema') tdSql.checkData(0, 2, None) tdSql.checkData(1, 0, 3) @@ -77,7 +77,7 @@ class TDTestCase: tdSql.query('select count(1) v,db_name, stable_name from information_schema.ins_tables group by db_name, stable_name order by v desc;') tdSql.checkRows(3) - tdSql.checkData(0, 0, 30) + tdSql.checkData(0, 0, 31) tdSql.checkData(0, 1, 'information_schema') tdSql.checkData(0, 2, None) tdSql.checkData(1, 0, 5) @@ -93,7 +93,7 @@ class TDTestCase: tdSql.checkData(1, 1, 'performance_schema') tdSql.checkData(0, 0, 3) tdSql.checkData(0, 1, 'tbl_count') - tdSql.checkData(2, 0, 30) + tdSql.checkData(2, 0, 31) tdSql.checkData(2, 1, 'information_schema') tdSql.query("select count(*) from information_schema.ins_tables where db_name='tbl_count'") @@ -106,7 +106,7 @@ class TDTestCase: tdSql.query('select count(*) from information_schema.ins_tables') tdSql.checkRows(1) - tdSql.checkData(0, 0, 38) + tdSql.checkData(0, 0, 39) tdSql.execute('create table stba (ts timestamp, c1 bool, c2 tinyint, c3 smallint, c4 int, c5 bigint, c6 float, c7 double, c8 binary(10), c9 nchar(10), c10 tinyint unsigned, c11 smallint unsigned, c12 int unsigned, c13 bigint unsigned) TAGS(t1 int, t2 binary(10), t3 double);') @@ -189,7 +189,7 @@ class TDTestCase: tdSql.checkData(2, 0, 5) tdSql.checkData(2, 1, 'performance_schema') tdSql.checkData(2, 2, None) - tdSql.checkData(3, 0, 30) + tdSql.checkData(3, 0, 31) tdSql.checkData(3, 1, 'information_schema') tdSql.checkData(3, 2, None) @@ -204,7 +204,7 @@ class TDTestCase: tdSql.checkData(2, 0, 5) tdSql.checkData(2, 1, 'performance_schema') tdSql.checkData(2, 2, None) - tdSql.checkData(3, 0, 30) + tdSql.checkData(3, 0, 31) tdSql.checkData(3, 1, 'information_schema') tdSql.checkData(3, 2, None) @@ -215,7 +215,7 @@ class TDTestCase: tdSql.checkData(0, 1, 'tbl_count') tdSql.checkData(1, 0, 5) tdSql.checkData(1, 1, 'performance_schema') - tdSql.checkData(2, 0, 30) + tdSql.checkData(2, 0, 31) tdSql.checkData(2, 1, 'information_schema') tdSql.query("select count(*) from information_schema.ins_tables where db_name='tbl_count'") @@ -228,7 +228,7 @@ class TDTestCase: tdSql.query('select count(*) from information_schema.ins_tables') tdSql.checkRows(1) - tdSql.checkData(0, 0, 39) + tdSql.checkData(0, 0, 40) tdSql.execute('drop database tbl_count') diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 14d9db273b..9ee365647b 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -113,6 +113,11 @@ ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/tbname.py -Q 2 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/tbname.py -Q 3 ,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/tbname.py -Q 4 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/tsma.py +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/tsma.py -R +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/tsma.py -Q 2 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/tsma.py -Q 3 +,,y,system-test,./pytest.sh python3 ./test.py -f 2-query/tsma.py -Q 4 ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqShow.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/tmqDropStb.py ,,y,system-test,./pytest.sh python3 ./test.py -f 7-tmq/subscribeStb0.py diff --git a/tests/pytest/util/common.py b/tests/pytest/util/common.py index 61cb770a10..df50e8031c 100644 --- a/tests/pytest/util/common.py +++ b/tests/pytest/util/common.py @@ -1862,6 +1862,55 @@ class TDCom: time.sleep(1) return tbname + def update_json_file_replica(self, json_file_path, new_replica_value, output_file_path=None): + """ + Read a JSON file, update the 'replica' value, and write the result back to a file. + + Parameters: + json_file_path (str): The path to the original JSON file. + new_replica_value (int): The new 'replica' value to be set. + output_file_path (str, optional): The path to the output file where the updated JSON will be saved. + If not provided, the original file will be overwritten. + + Returns: + None + """ + try: + # Read the JSON file and load its content into a Python dictionary + with open(json_file_path, 'r', encoding='utf-8') as file: + data = json.load(file) + + # Iterate over each item in the 'databases' list to find 'dbinfo' and update 'replica' + for db in data['databases']: + if 'dbinfo' in db: + db['dbinfo']['replica'] = new_replica_value + + # Convert the updated dictionary back into a JSON string with indentation for readability + updated_json_str = json.dumps(data, indent=4, ensure_ascii=False) + + # Write the updated JSON string to a file + if output_file_path: + # If an output file path is provided, write to the new file + with open(output_file_path, 'w', encoding='utf-8') as output_file: + output_file.write(updated_json_str) + else: + # Otherwise, overwrite the original file with the updated content + with open(json_file_path, 'w', encoding='utf-8') as file: + file.write(updated_json_str) + + except json.JSONDecodeError as e: + # Handle JSON decoding error (e.g., if the file is not valid JSON) + print(f"JSON decode error: {e}") + except FileNotFoundError: + # Handle the case where the JSON file is not found at the given path + print(f"File not found: {json_file_path}") + except KeyError as e: + # Handle missing key error (e.g., if 'databases' or 'dbinfo' is not present) + print(f"Key error: {e}") + except Exception as e: + # Handle any other exceptions that may occur + print(f"An error occurred: {e}") + def is_json(msg): if isinstance(msg, str): try: @@ -1896,4 +1945,7 @@ def dict2toml(in_dict: dict, file:str): with open(file, 'w') as f: toml.dump(in_dict, f) + + + tdCom = TDCom() diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index 789e5866ee..2d3275d95e 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -130,21 +130,20 @@ class TDDnode: "locale": "en_US.UTF-8", "charset": "UTF-8", "asyncLog": "0", - "DebugFlag": "131", - "mDebugFlag": "143", - "dDebugFlag": "143", - "vDebugFlag": "143", - "tqDebugFlag": "143", - "cDebugFlag": "143", - "stDebugFlag": "143", - "smaDebugFlag": "143", - "jniDebugFlag": "143", - "qDebugFlag": "143", - "rpcDebugFlag": "143", + "mDebugFlag": "135", + "dDebugFlag": "131", + "vDebugFlag": "131", + "tqDebugFlag": "135", + "cDebugFlag": "135", + "stDebugFlag": "135", + "smaDebugFlag": "135", + "jniDebugFlag": "131", + "qDebugFlag": "131", + "rpcDebugFlag": "135", "tmrDebugFlag": "131", - "uDebugFlag": "135", - "sDebugFlag": "135", - "wDebugFlag": "135", + "uDebugFlag": "131", + "sDebugFlag": "131", + "wDebugFlag": "131", "numOfLogLines": "100000000", "statusInterval": "1", "enableQueryHb": "1", diff --git a/tests/pytest/util/sql.py b/tests/pytest/util/sql.py index d1ffaaca92..b46326bb3c 100644 --- a/tests/pytest/util/sql.py +++ b/tests/pytest/util/sql.py @@ -22,7 +22,8 @@ import shutil import pandas as pd from util.log import * from util.constant import * - +import ctypes +import random # from datetime import timezone import time @@ -78,7 +79,7 @@ class TDSql: self.cursor.execute(s) time.sleep(2) - def execute(self, sql, queryTimes=30, show=False): + def execute(self, sql, queryTimes=20, show=False): self.sql = sql if show: tdLog.info(sql) @@ -118,7 +119,6 @@ class TDSql: def error(self, sql, expectedErrno = None, expectErrInfo = None, fullMatched = True, show = False): caller = inspect.getframeinfo(inspect.stack()[1][0]) expectErrNotOccured = True - if show: tdLog.info("sql:%s" % (sql)) @@ -140,7 +140,8 @@ class TDSql: if fullMatched: if expectedErrno != None: - if expectedErrno == self.errno: + expectedErrno_rest = expectedErrno & 0x0000ffff + if expectedErrno == self.errno or expectedErrno_rest == self.errno: tdLog.info("sql:%s, expected errno %s occured" % (sql, expectedErrno)) else: tdLog.exit("%s(%d) failed: sql:%s, errno '%s' occured, but not expected errno '%s'" % (caller.filename, caller.lineno, sql, self.errno, expectedErrno)) @@ -152,7 +153,8 @@ class TDSql: tdLog.exit("%s(%d) failed: sql:%s, ErrInfo '%s' occured, but not expected ErrInfo '%s'" % (caller.filename, caller.lineno, sql, self.error_info, expectErrInfo)) else: if expectedErrno != None: - if expectedErrno in self.errno: + expectedErrno_rest = expectedErrno & 0x0000ffff + if expectedErrno in self.errno or expectedErrno_rest in self.errno: tdLog.info("sql:%s, expected errno %s occured" % (sql, expectedErrno)) else: tdLog.exit("%s(%d) failed: sql:%s, errno '%s' occured, but not expected errno '%s'" % (caller.filename, caller.lineno, sql, self.errno, expectedErrno)) @@ -743,5 +745,59 @@ class TDSql: os.makedirs( dir, 755 ) tdLog.info("dir: %s is created" %dir) pass + + + + def get_db_vgroups(self, db_name:str = "test") -> list: + db_vgroups_list = [] + tdSql.query(f"show {db_name}.vgroups") + for result in tdSql.queryResult: + db_vgroups_list.append(result[0]) + vgroup_nums = len(db_vgroups_list) + tdLog.debug(f"{db_name} has {vgroup_nums} vgroups :{db_vgroups_list}") + tdSql.query("select * from information_schema.ins_vnodes") + return db_vgroups_list + + def get_cluseter_dnodes(self) -> list: + cluset_dnodes_list = [] + tdSql.query("show dnodes") + for result in tdSql.queryResult: + cluset_dnodes_list.append(result[0]) + self.clust_dnode_nums = len(cluset_dnodes_list) + tdLog.debug(f"cluster has {len(cluset_dnodes_list)} dnodes :{cluset_dnodes_list}") + return cluset_dnodes_list + + def redistribute_one_vgroup(self, db_name:str = "test", replica:int = 1, vgroup_id:int = 1, useful_trans_dnodes_list:list = [] ): + # redisutribute vgroup {vgroup_id} dnode {dnode_id} + if replica == 1: + dnode_id = random.choice(useful_trans_dnodes_list) + redistribute_sql = f"redistribute vgroup {vgroup_id} dnode {dnode_id}" + elif replica ==3: + selected_dnodes = random.sample(useful_trans_dnodes_list, replica) + redistribute_sql_parts = [f"dnode {dnode}" for dnode in selected_dnodes] + redistribute_sql = f"redistribute vgroup {vgroup_id} " + " ".join(redistribute_sql_parts) + else: + raise ValueError(f"Replica count must be 1 or 3,but got {replica}") + tdLog.debug(f"redistributeSql:{redistribute_sql}") + tdSql.query(redistribute_sql) + tdLog.debug("redistributeSql ok") + + def redistribute_db_all_vgroups(self, db_name:str = "test", replica:int = 1): + db_vgroups_list = self.get_db_vgroups(db_name) + cluset_dnodes_list = self.get_cluseter_dnodes() + useful_trans_dnodes_list = cluset_dnodes_list.copy() + tdSql.query("select * from information_schema.ins_vnodes") + #result: dnode_id|vgroup_id|db_name|status|role_time|start_time|restored| + + for vnode_group_id in db_vgroups_list: + print(tdSql.queryResult) + for result in tdSql.queryResult: + if result[2] == db_name and result[1] == vnode_group_id: + tdLog.debug(f"dbname: {db_name}, vgroup :{vnode_group_id}, dnode is {result[0]}") + print(useful_trans_dnodes_list) + useful_trans_dnodes_list.remove(result[0]) + tdLog.debug(f"vgroup :{vnode_group_id},redis_dnode list:{useful_trans_dnodes_list}") + self.redistribute_one_vgroup(db_name, replica, vnode_group_id, useful_trans_dnodes_list) + useful_trans_dnodes_list = cluset_dnodes_list.copy() tdSql = TDSql() diff --git a/tests/script/sh/deploy.bat b/tests/script/sh/deploy.bat index fd76b30078..dbabe3067b 100644 --- a/tests/script/sh/deploy.bat +++ b/tests/script/sh/deploy.bat @@ -67,19 +67,19 @@ echo supportVnodes 128 >> %TAOS_CFG% echo dataDir %DATA_DIR% >> %TAOS_CFG% echo logDir %LOG_DIR% >> %TAOS_CFG% echo debugFlag 0 >> %TAOS_CFG% -echo mDebugFlag 143 >> %TAOS_CFG% -echo dDebugFlag 143 >> %TAOS_CFG% -echo vDebugFlag 143 >> %TAOS_CFG% -echo tqDebugFlag 143 >> %TAOS_CFG% -echo tsdbDebugFlag 143 >> %TAOS_CFG% -echo cDebugFlag 143 >> %TAOS_CFG% -echo jniDebugFlag 143 >> %TAOS_CFG% -echo qDebugFlag 143 >> %TAOS_CFG% -echo rpcDebugFlag 143 >> %TAOS_CFG% +echo mDebugFlag 135 >> %TAOS_CFG% +echo dDebugFlag 131 >> %TAOS_CFG% +echo vDebugFlag 131 >> %TAOS_CFG% +echo tqDebugFlag 135 >> %TAOS_CFG% +echo tsdbDebugFlag 135 >> %TAOS_CFG% +echo cDebugFlag 135 >> %TAOS_CFG% +echo jniDebugFlag 131 >> %TAOS_CFG% +echo qDebugFlag 131 >> %TAOS_CFG% +echo rpcDebugFlag 135 >> %TAOS_CFG% echo tmrDebugFlag 131 >> %TAOS_CFG% -echo uDebugFlag 143 >> %TAOS_CFG% -echo sDebugFlag 143 >> %TAOS_CFG% -echo wDebugFlag 143 >> %TAOS_CFG% +echo uDebugFlag 131 >> %TAOS_CFG% +echo sDebugFlag 131 >> %TAOS_CFG% +echo wDebugFlag 131 >> %TAOS_CFG% echo numOfLogLines 20000000 >> %TAOS_CFG% echo statusInterval 1 >> %TAOS_CFG% echo asyncLog 0 >> %TAOS_CFG% diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index c6bd78336c..76d890b26a 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -117,27 +117,26 @@ echo "supportVnodes 1024" >> $TAOS_CFG echo "statusInterval 1" >> $TAOS_CFG echo "dataDir $DATA_DIR" >> $TAOS_CFG echo "logDir $LOG_DIR" >> $TAOS_CFG -echo "debugFlag 135" >> $TAOS_CFG echo "tmrDebugFlag 131" >> $TAOS_CFG -echo "uDebugFlag 143" >> $TAOS_CFG -echo "rpcDebugFlag 143" >> $TAOS_CFG -echo "jniDebugFlag 143" >> $TAOS_CFG -echo "qDebugFlag 143" >> $TAOS_CFG -echo "cDebugFlag 143" >> $TAOS_CFG -echo "dDebugFlag 143" >> $TAOS_CFG -echo "vDebugFlag 143" >> $TAOS_CFG -echo "mDebugFlag 143" >> $TAOS_CFG -echo "wDebugFlag 143" >> $TAOS_CFG -echo "sDebugFlag 143" >> $TAOS_CFG -echo "tsdbDebugFlag 143" >> $TAOS_CFG -echo "tdbDebugFlag 143" >> $TAOS_CFG -echo "tqDebugFlag 143" >> $TAOS_CFG -echo "fsDebugFlag 143" >> $TAOS_CFG -echo "idxDebugFlag 143" >> $TAOS_CFG -echo "udfDebugFlag 143" >> $TAOS_CFG -echo "smaDebugFlag 143" >> $TAOS_CFG -echo "metaDebugFlag 143" >> $TAOS_CFG -echo "stDebugFlag 143" >> $TAOS_CFG +echo "uDebugFlag 131" >> $TAOS_CFG +echo "rpcDebugFlag 135" >> $TAOS_CFG +echo "jniDebugFlag 131" >> $TAOS_CFG +echo "qDebugFlag 131" >> $TAOS_CFG +echo "cDebugFlag 135" >> $TAOS_CFG +echo "dDebugFlag 131" >> $TAOS_CFG +echo "vDebugFlag 131" >> $TAOS_CFG +echo "mDebugFlag 135" >> $TAOS_CFG +echo "wDebugFlag 131" >> $TAOS_CFG +echo "sDebugFlag 131" >> $TAOS_CFG +echo "tsdbDebugFlag 135" >> $TAOS_CFG +echo "tdbDebugFlag 135" >> $TAOS_CFG +echo "tqDebugFlag 135" >> $TAOS_CFG +echo "fsDebugFlag 135" >> $TAOS_CFG +echo "idxDebugFlag 135" >> $TAOS_CFG +echo "udfDebugFlag 135" >> $TAOS_CFG +echo "smaDebugFlag 135" >> $TAOS_CFG +echo "metaDebugFlag 135" >> $TAOS_CFG +echo "stDebugFlag 135" >> $TAOS_CFG echo "numOfLogLines 20000000" >> $TAOS_CFG echo "asyncLog 0" >> $TAOS_CFG echo "locale en_US.UTF-8" >> $TAOS_CFG diff --git a/tests/script/tsim/query/sys_tbname.sim b/tests/script/tsim/query/sys_tbname.sim index 65f96ebc66..11b4482f10 100644 --- a/tests/script/tsim/query/sys_tbname.sim +++ b/tests/script/tsim/query/sys_tbname.sim @@ -58,7 +58,7 @@ endi sql select tbname from information_schema.ins_tables; print $rows $data00 -if $rows != 39 then +if $rows != 40 then return -1 endi if $data00 != @ins_tables@ then diff --git a/tests/script/tsim/query/tableCount.sim b/tests/script/tsim/query/tableCount.sim index b8ffc3a41d..4c9c8ce240 100644 --- a/tests/script/tsim/query/tableCount.sim +++ b/tests/script/tsim/query/tableCount.sim @@ -53,7 +53,7 @@ sql select stable_name,count(table_name) from information_schema.ins_tables grou if $rows != 3 then return -1 endi -if $data01 != 36 then +if $data01 != 37 then return -1 endi if $data11 != 10 then @@ -72,7 +72,7 @@ endi if $data11 != 5 then return -1 endi -if $data21 != 30 then +if $data21 != 31 then return -1 endi if $data31 != 5 then @@ -97,7 +97,7 @@ endi if $data42 != 3 then return -1 endi -if $data52 != 30 then +if $data52 != 31 then return -1 endi if $data62 != 5 then diff --git a/tests/script/tsim/sma/drop_sma.sim b/tests/script/tsim/sma/drop_sma.sim index fcf48f2b36..7121f402fa 100644 --- a/tests/script/tsim/sma/drop_sma.sim +++ b/tests/script/tsim/sma/drop_sma.sim @@ -79,7 +79,7 @@ else endi - +sql drop index sma_index_name1 print --> drop stb sql drop table stb; @@ -120,6 +120,7 @@ else endi endi +sql drop index sma_index_name1 print --> drop stb sql drop table stb; diff --git a/tests/script/tsim/tagindex/sma_and_tag_index.sim b/tests/script/tsim/tagindex/sma_and_tag_index.sim index e7e4682810..77cc9f53f9 100644 --- a/tests/script/tsim/tagindex/sma_and_tag_index.sim +++ b/tests/script/tsim/tagindex/sma_and_tag_index.sim @@ -88,7 +88,13 @@ if $rows != 7 then return -1 endi - +$i = 0 +$smaPre = sma3 +while $i < 5 + $sma = $smaPre . $i + $i = $i + 1 + sql drop index $sma +endw sql drop stable $mtPrefix sql select * from information_schema.ins_indexes @@ -163,4 +169,4 @@ endi -system sh/exec.sh -n dnode1 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/tests/system-test/0-others/compatibility.py b/tests/system-test/0-others/compatibility.py index 8163177a3b..4c2fe652b8 100644 --- a/tests/system-test/0-others/compatibility.py +++ b/tests/system-test/0-others/compatibility.py @@ -84,7 +84,7 @@ class TDTestCase: return cfgPath - def installTaosd(self,bPath,cPath): + def installTaosd(self, bPath, cPath, package_type="community"): # os.system(f"rmtaos && mkdir -p {self.getBuildPath()}/build/lib/temp && mv {self.getBuildPath()}/build/lib/libtaos.so* {self.getBuildPath()}/build/lib/temp/ ") # os.system(f" mv {bPath}/build {bPath}/build_bak ") # os.system(f"mv {self.getBuildPath()}/build/lib/libtaos.so {self.getBuildPath()}/build/lib/libtaos.so_bak ") @@ -92,10 +92,15 @@ class TDTestCase: packagePath = "/usr/local/src/" dataPath = cPath + "/../data/" + packageType = "server" + if package_type == "community" : + packageType = "server" + elif package_type == "enterprise": + packageType = "enterprise" if platform.system() == "Linux" and platform.machine() == "aarch64": - packageName = "TDengine-server-"+ BASEVERSION + "-Linux-arm64.tar.gz" + packageName = "TDengine-"+ packageType + "-" + BASEVERSION + "-Linux-arm64.tar.gz" else: - packageName = "TDengine-server-"+ BASEVERSION + "-Linux-x64.tar.gz" + packageName = "TDengine-"+ packageType + "-" + BASEVERSION + "-Linux-x64.tar.gz" packageTPath = packageName.split("-Linux-")[0] my_file = Path(f"{packagePath}/{packageName}") if not my_file.exists(): @@ -160,7 +165,8 @@ class TDTestCase: cPath = self.getCfgPath() dbname = "test" stb = f"{dbname}.meters" - self.installTaosd(bPath,cPath) + package_type = "community" + self.installTaosd(bPath,cPath,package_type) # os.system(f"echo 'debugFlag 143' >> {cPath}/taos.cfg ") tableNumbers=100 recordNumbers1=100 diff --git a/tests/system-test/0-others/information_schema.py b/tests/system-test/0-others/information_schema.py index ffdd9d191d..c9802fa80d 100644 --- a/tests/system-test/0-others/information_schema.py +++ b/tests/system-test/0-others/information_schema.py @@ -47,7 +47,7 @@ class TDTestCase: 'col12': f'binary({self.binary_length})', 'col13': f'nchar({self.nchar_length})' } - self.tbnum = 20 + self.tbnum = 21 self.rowNum = 10 self.tag_dict = { 't0':'int', @@ -61,7 +61,7 @@ class TDTestCase: self.ins_list = ['ins_dnodes','ins_mnodes','ins_qnodes','ins_snodes','ins_cluster','ins_databases','ins_functions',\ 'ins_indexes','ins_stables','ins_tables','ins_tags','ins_columns','ins_users','ins_grants','ins_vgroups','ins_configs','ins_dnode_variables',\ 'ins_topics','ins_subscriptions','ins_streams','ins_stream_tasks','ins_vnodes','ins_user_privileges','ins_views', - 'ins_compacts', 'ins_compact_details', 'ins_grants_full','ins_grants_logs', 'ins_machines', 'ins_arbgroups'] + 'ins_compacts', 'ins_compact_details', 'ins_grants_full','ins_grants_logs', 'ins_machines', 'ins_arbgroups', 'ins_tsmas'] self.perf_list = ['perf_connections','perf_queries','perf_consumers','perf_trans','perf_apps'] def insert_data(self,column_dict,tbname,row_num): insert_sql = self.setsql.set_insertsql(column_dict,tbname,self.binary_str,self.nchar_str) @@ -221,7 +221,7 @@ class TDTestCase: tdSql.checkEqual(20470,len(tdSql.queryResult)) tdSql.query("select * from information_schema.ins_columns where db_name ='information_schema'") - tdSql.checkEqual(True, len(tdSql.queryResult) in range(226, 241)) + tdSql.checkEqual(True, len(tdSql.queryResult) in range(226, 250)) tdSql.query("select * from information_schema.ins_columns where db_name ='performance_schema'") tdSql.checkEqual(54, len(tdSql.queryResult)) diff --git a/tests/system-test/0-others/udf_create.py b/tests/system-test/0-others/udf_create.py index ee1a0ef5b3..6071561035 100644 --- a/tests/system-test/0-others/udf_create.py +++ b/tests/system-test/0-others/udf_create.py @@ -197,7 +197,9 @@ class TDTestCase: tdLog.info("create two udf functions success ") def basic_udf_query(self): - + # create tsma of udf + tdSql.error("create tsma tsma_udf on db.tb function(udf1(num1)) interval(10m);") # DB error: Not buildin function (0.001656s) + tdSql.error("create tsma tsma_udf on db.stb1 function(udf1(c1)) interval(10m);") # DB error: Not buildin function (0.001656s) # scalar functions # udf1_dup diff --git a/tests/system-test/1-insert/table_param_ttl.py b/tests/system-test/1-insert/table_param_ttl.py index f36a49a1d7..371be76b55 100644 --- a/tests/system-test/1-insert/table_param_ttl.py +++ b/tests/system-test/1-insert/table_param_ttl.py @@ -28,6 +28,20 @@ class TDTestCase: self.ttl_param = 1 self.default_ttl = 100 self.modify_ttl = 1 + + def wait_query(self, sql: str, expected_row_num: int, timeout_in_seconds: float): + timeout = timeout_in_seconds + tdSql.query(sql) + while timeout > 0 and tdSql.getRows() != expected_row_num: + tdLog.debug(f'start to wait query: {sql} to return {expected_row_num}, got: {tdSql.getRows()}, remain: {timeout_in_seconds - timeout}') + time.sleep(1) + timeout = timeout - 1 + tdSql.query(sql) + if timeout <= 0: + tdLog.exit(f'failed to wait query: {sql} to return {expected_row_num} rows timeout: {timeout_in_seconds}s') + else: + tdLog.debug(f'wait query succeed: {sql} to return {expected_row_num}, got: {tdSql.getRows()}') + def ttl_check_ntb(self): tdSql.prepare() @@ -36,17 +50,15 @@ class TDTestCase: tdSql.query(f'show db.tables') tdSql.checkRows(self.tbnum) tdSql.execute(f'flush database db') - sleep(self.updatecfgDict['ttlUnit']*self.ttl_param+self.updatecfgDict['ttlPushInterval'] + 1) - tdSql.query(f'show db.tables') - tdSql.checkRows(0) + timeout = self.updatecfgDict['ttlUnit']*self.ttl_param+self.updatecfgDict['ttlPushInterval'] + self.wait_query('show db.tables', 0, timeout + 5) for i in range(self.tbnum): tdSql.execute(f'create table db.{self.ntbname}_{i} (ts timestamp,c0 int) ttl {self.default_ttl}') for i in range(int(self.tbnum/2)): tdSql.execute(f'alter table db.{self.ntbname}_{i} ttl {self.modify_ttl}') tdSql.execute(f'flush database db') - sleep(self.updatecfgDict['ttlUnit']*self.modify_ttl+self.updatecfgDict['ttlPushInterval'] + 1) - tdSql.query(f'show db.tables') - tdSql.checkRows(self.tbnum - int(self.tbnum/2)) + timeout = self.updatecfgDict['ttlUnit']*self.modify_ttl+self.updatecfgDict['ttlPushInterval'] + self.wait_query('show db.tables', self.tbnum - int(self.tbnum / 2), timeout + 10) tdSql.execute('drop database db') def ttl_check_ctb(self): tdSql.prepare() @@ -57,9 +69,8 @@ class TDTestCase: tdSql.query(f'show db.tables') tdSql.checkRows(self.tbnum) tdSql.execute(f'flush database db') - sleep(self.updatecfgDict['ttlUnit']*self.ttl_param+self.updatecfgDict['ttlPushInterval'] + 1) - tdSql.query(f'show db.tables') - tdSql.checkRows(0) + timeout = self.updatecfgDict['ttlUnit']*self.ttl_param+self.updatecfgDict['ttlPushInterval']; + self.wait_query('show db.tables', 0, timeout + 5) for i in range(self.tbnum): tdSql.execute(f'create table db.{self.stbname}_{i} using db.{self.stbname} tags({i}) ttl {self.default_ttl}') tdSql.query(f'show db.tables') @@ -67,9 +78,8 @@ class TDTestCase: for i in range(int(self.tbnum/2)): tdSql.execute(f'alter table db.{self.stbname}_{i} ttl {self.modify_ttl}') tdSql.execute(f'flush database db') - sleep(self.updatecfgDict['ttlUnit']*self.modify_ttl+self.updatecfgDict['ttlPushInterval'] + 1) - tdSql.query(f'show db.tables') - tdSql.checkRows(self.tbnum - int(self.tbnum/2)) + timeout = self.updatecfgDict['ttlUnit']*self.modify_ttl+self.updatecfgDict['ttlPushInterval']; + self.wait_query('show db.tables', self.tbnum - int(self.tbnum / 2), timeout + 5) tdSql.execute('drop database db') def ttl_check_insert(self): @@ -80,9 +90,8 @@ class TDTestCase: tdSql.query(f'show db.tables') tdSql.checkRows(self.tbnum) tdSql.execute(f'flush database db') - sleep(self.updatecfgDict['ttlUnit']*self.ttl_param+self.updatecfgDict['ttlPushInterval'] + 1) - tdSql.query(f'show db.tables') - tdSql.checkRows(0) + timeout = self.updatecfgDict['ttlUnit']*self.ttl_param+self.updatecfgDict['ttlPushInterval']; + self.wait_query('show db.tables', 0, timeout + 5) tdSql.execute('drop database db') def run(self): self.ttl_check_ntb() diff --git a/tests/system-test/2-query/agg_group_NotReturnValue.py b/tests/system-test/2-query/agg_group_NotReturnValue.py index d25395cbbd..73a8fe04c3 100755 --- a/tests/system-test/2-query/agg_group_NotReturnValue.py +++ b/tests/system-test/2-query/agg_group_NotReturnValue.py @@ -1584,6 +1584,7 @@ class TDTestCase(TDTestCase): self.dropandcreateDB_random("nested", 1) self.modify_tables() + tdSql.execute('alter local "countAlwaysReturnValue" "0"') for i in range(2): self.tag_count_all() diff --git a/tests/system-test/2-query/compa4096_tsma.json b/tests/system-test/2-query/compa4096_tsma.json new file mode 100644 index 0000000000..66d98ceebe --- /dev/null +++ b/tests/system-test/2-query/compa4096_tsma.json @@ -0,0 +1,66 @@ +{ + "filetype": "insert", + "cfgdir": "/etc/taos", + "host": "localhost", + "port": 6030, + "rest_port": 6041, + "user": "root", + "password": "taosdata", + "thread_count": 100, + "create_table_thread_count": 24, + "result_file": "taosBenchmark_result.log", + "confirm_parameter_prompt": "no", + "insert_interval": 0, + "num_of_records_per_req": 1000000, + "max_sql_len": 1024000, + "databases": [ + { + "dbinfo": { + "name": "db4096", + "drop": "yes", + "replica": 1, + "duration": 10, + "precision": "ms", + "keep": 3650, + "comp": 2, + "vgroups": 2, + "buffer": 1000 + }, + "super_tables": [ + { + "name": "stb0", + "child_table_exists": "no", + "childtable_count":2, + "childtable_prefix": "ctb0", + "escape_character": "no", + "auto_create_table": "no", + "batch_create_tbl_num": 500, + "data_source": "rand", + "insert_mode": "taosc", + "rollup": null, + "interlace_rows": 0, + "line_protocol": null, + "tcp_transfer": "no", + "insert_rows": 10, + "childtable_limit": 0, + "childtable_offset": 0, + "rows_per_tbl": 0, + "max_sql_len": 1048576, + "disorder_ratio": 0, + "disorder_range": 1000, + "timestamp_step": 1000, + "start_timestamp": "2022-10-22 17:20:36", + "sample_format": "csv", + "sample_file": "./sample.csv", + "tags_file": "", + "columns": [{ "type": "INT","count": 4093}], + "tags": [{"type": "TINYINT", "count": 1},{"type": "NCHAR","count": 1}] + } + ] + } + ], + "prepare_rand": 10000, + "chinese": "no", + "streams": false, + "test_log": "/root/testlog/" +} diff --git a/tests/system-test/2-query/countAlwaysReturnValue.py b/tests/system-test/2-query/countAlwaysReturnValue.py index f22fa3e01e..bced89456e 100644 --- a/tests/system-test/2-query/countAlwaysReturnValue.py +++ b/tests/system-test/2-query/countAlwaysReturnValue.py @@ -168,6 +168,7 @@ class TDTestCase: tdLog.printNoPrefix("==========step1:prepare data ==============") self.prepare_data() + tdSql.execute('alter local "countAlwaysReturnValue" "0"') tdLog.printNoPrefix("==========step2:test results ==============") diff --git a/tests/system-test/2-query/db.py b/tests/system-test/2-query/db.py index 07514a0950..cfe224acb0 100644 --- a/tests/system-test/2-query/db.py +++ b/tests/system-test/2-query/db.py @@ -52,7 +52,7 @@ class TDTestCase: tdSql.checkRows(1) tdSql.checkData(0, 0, i + 1) tdSql.checkData(0, 1, 'debugFlag') - tdSql.checkData(0, 2, 131) + tdSql.checkData(0, 2, 0) tdSql.query("show dnode 1 variables like '%debugFlag'") tdSql.checkRows(23) diff --git a/tests/system-test/2-query/tsma.py b/tests/system-test/2-query/tsma.py new file mode 100644 index 0000000000..606faf6312 --- /dev/null +++ b/tests/system-test/2-query/tsma.py @@ -0,0 +1,1601 @@ +from random import randrange +import time +import threading +import secrets +from util.log import * +from util.sql import * +from util.cases import * +from util.dnodes import * +from util.common import * +# from tmqCommon import * + +ROUND = 1000 + +class TSMA: + def __init__(self): + self.tsma_name = '' + self.db_name = '' + self.original_table_name = '' + self.funcs = [] + self.cols = [] + self.interval: str = '' + + +class UsedTsma: + TS_MIN = '-9223372036854775808' + TS_MAX = '9223372036854775806' + TSMA_RES_STB_POSTFIX = '_tsma_res_stb_' + + def __init__(self) -> None: + self.name = '' # tsma name or table name + self.time_range_start: float = float(UsedTsma.TS_MIN) + self.time_range_end: float = float(UsedTsma.TS_MAX) + self.is_tsma_ = False + + def __eq__(self, __value: object) -> bool: + if isinstance(__value, self.__class__): + return self.name == __value.name \ + and self.time_range_start == __value.time_range_start \ + and self.time_range_end == __value.time_range_end \ + and self.is_tsma_ == __value.is_tsma_ + else: + return False + + def __ne__(self, __value: object) -> bool: + return not self.__eq__(__value) + + def __str__(self) -> str: + return "%s: from %s to %s is_tsma: %d" % (self.name, self.time_range_start, self.time_range_end, self.is_tsma_) + + def __repr__(self) -> str: + return self.__str__() + + def setIsTsma(self): + self.is_tsma_ = self.name.endswith(self.TSMA_RES_STB_POSTFIX) + if not self.is_tsma_: + self.is_tsma_ = len(self.name) == 32 # for tsma output child table + +class TSMAQueryContext: + def __init__(self) -> None: + self.sql = '' + self.used_tsmas: List[UsedTsma] = [] + self.ignore_tsma_check_ = False + self.ignore_res_order_ = False + + def __eq__(self, __value) -> bool: + if isinstance(__value, self.__class__): + if self.ignore_tsma_check_ or __value.ignore_tsma_check_: + return True + if len(self.used_tsmas) != len(__value.used_tsmas): + return False + for used_tsma1, used_tsma2 in zip(self.used_tsmas, __value.used_tsmas): + if not used_tsma1 == used_tsma2: + return False + return True + else: + return False + + def __ne__(self, __value: object) -> bool: + return self.__eq__(__value) + + def __str__(self) -> str: + return str(self.used_tsmas) + + def has_tsma(self) -> bool: + for tsma in self.used_tsmas: + if tsma.is_tsma_: + return True + return False + + +class TSMAQCBuilder: + def __init__(self) -> None: + self.qc_: TSMAQueryContext = TSMAQueryContext() + + def get_qc(self) -> TSMAQueryContext: + return self.qc_ + + def with_sql(self, sql: str): + self.qc_.sql = sql + return self + + def to_timestamp(self, ts: str) -> float: + if ts == UsedTsma.TS_MAX or ts == UsedTsma.TS_MIN: + return float(ts) + tdSql.query( + "select to_timestamp('%s', 'yyyy-mm-dd hh24-mi-ss.ms')" % (ts)) + res = tdSql.queryResult[0][0] + return res.timestamp() * 1000 + + def md5(self, buf: str) -> str: + tdSql.query(f'select md5("{buf}")') + res = tdSql.queryResult[0][0] + return res + + def should_query_with_table(self, tb_name: str, ts_begin: str = UsedTsma.TS_MIN, ts_end: str = UsedTsma.TS_MAX) -> 'TSMAQCBuilder': + used_tsma: UsedTsma = UsedTsma() + used_tsma.name = tb_name + used_tsma.time_range_start = self.to_timestamp(ts_begin) + used_tsma.time_range_end = self.to_timestamp(ts_end) + used_tsma.is_tsma_ = False + self.qc_.used_tsmas.append(used_tsma) + return self + + def should_query_with_tsma_ctb(self, db_name: str, tsma_name: str, ctb_name: str, ts_begin: str = UsedTsma.TS_MIN, ts_end: str = UsedTsma.TS_MAX) -> 'TSMAQCBuilder': + used_tsma: UsedTsma = UsedTsma() + name = f'1.{db_name}.{tsma_name}_{ctb_name}' + used_tsma.name = self.md5(name) + used_tsma.time_range_start = self.to_timestamp(ts_begin) + used_tsma.time_range_end = self.to_timestamp(ts_end) + used_tsma.is_tsma_ = True + self.qc_.used_tsmas.append(used_tsma) + return self + + def ignore_query_table(self): + self.qc_.ignore_tsma_check_ = True + return self + + def ignore_res_order(self, ignore: bool): + self.qc_.ignore_res_order_ = ignore + return self + + def should_query_with_tsma(self, tsma_name: str, ts_begin: str = UsedTsma.TS_MIN, ts_end: str = UsedTsma.TS_MAX, child_tb: bool = False) -> 'TSMAQCBuilder': + used_tsma: UsedTsma = UsedTsma() + if child_tb: + used_tsma.name = tsma_name + else: + used_tsma.name = tsma_name + UsedTsma.TSMA_RES_STB_POSTFIX + used_tsma.time_range_start = self.to_timestamp(ts_begin) + used_tsma.time_range_end = self.to_timestamp(ts_end) + used_tsma.is_tsma_ = True + self.qc_.used_tsmas.append(used_tsma) + return self + + +class TSMATester: + def __init__(self, tdSql: TDSql) -> None: + self.tsmas = [] + self.tdSql: TDSql = tdSql + + def explain_sql(self, sql: str): + tdSql.execute("alter local 'querySmaOptimize' '1'") + sql = "explain verbose true " + sql + tdSql.query(sql, queryTimes=1) + res = self.tdSql.queryResult + if self.tdSql.queryResult is None: + raise + return res + + def get_tsma_query_ctx(self, sql: str): + explain_res = self.explain_sql(sql) + query_ctx: TSMAQueryContext = TSMAQueryContext() + query_ctx.sql = sql + query_ctx.used_tsmas = [] + used_tsma: UsedTsma = UsedTsma() + for row in explain_res: + row = str(row) + if len(used_tsma.name) == 0: + idx = row.find("Table Scan on ") + if idx >= 0: + words = row[idx:].split(' ') + used_tsma.name = words[3] + used_tsma.setIsTsma() + else: + idx = row.find('Time Range:') + if idx >= 0: + row = row[idx:].split('[')[1] + row = row.split(']')[0] + words = row.split(',') + used_tsma.time_range_start = float(words[0].strip()) + used_tsma.time_range_end = float(words[1].strip()) + query_ctx.used_tsmas.append(used_tsma) + used_tsma = UsedTsma() + + deduplicated_tsmas: list[UsedTsma] = [] + if len(query_ctx.used_tsmas) > 0: + deduplicated_tsmas.append(query_ctx.used_tsmas[0]) + for tsma in query_ctx.used_tsmas: + if tsma == deduplicated_tsmas[-1]: + continue + else: + deduplicated_tsmas.append(tsma) + query_ctx.used_tsmas = deduplicated_tsmas + + return query_ctx + + def check_explain(self, sql: str, expect: TSMAQueryContext) -> TSMAQueryContext: + query_ctx = self.get_tsma_query_ctx(sql) + if not query_ctx == expect: + tdLog.exit('check explain failed for sql: %s \nexpect: %s \nactual: %s' % ( + sql, str(expect), str(query_ctx))) + elif expect.has_tsma(): + tdLog.debug('check explain succeed for sql: %s \ntsma: %s' % + (sql, str(expect.used_tsmas))) + has_tsma = False + for tsma in query_ctx.used_tsmas: + has_tsma = has_tsma or tsma.is_tsma_ + if not has_tsma and len(query_ctx.used_tsmas) > 1: + tdLog.exit( + f'explain err for sql: {sql}, has multi non tsmas, {query_ctx.used_tsmas}') + return query_ctx + + def check_result(self, sql: str, skip_order: bool = False): + tdSql.execute("alter local 'querySmaOptimize' '1'") + tsma_res = tdSql.getResult(sql) + + tdSql.execute("alter local 'querySmaOptimize' '0'") + no_tsma_res = tdSql.getResult(sql) + + if no_tsma_res is None or tsma_res is None: + if no_tsma_res != tsma_res: + tdLog.exit("comparing tsma res for: %s got different rows of result: without tsma: %s, with tsma: %s" % ( + sql, str(no_tsma_res), str(tsma_res))) + else: + return + + if len(no_tsma_res) != len(tsma_res): + tdLog.exit("comparing tsma res for: %s got different rows of result: \nwithout tsma: %s\nwith tsma: %s" % ( + sql, str(no_tsma_res), str(tsma_res))) + if skip_order: + try: + no_tsma_res.sort( + key=lambda x: [v is None for v in x] + list(x)) + tsma_res.sort(key=lambda x: [v is None for v in x] + list(x)) + except Exception as e: + tdLog.exit("comparing tsma res for: %s got different data: \nno tsma res: %s \n tsma res: %s err: %s" % ( + sql, str(no_tsma_res), str(tsma_res), str(e))) + + for row_no_tsma, row_tsma in zip(no_tsma_res, tsma_res): + if row_no_tsma != row_tsma: + tdLog.exit("comparing tsma res for: %s got different row data: no tsma row: %s, tsma row: %s \nno tsma res: %s \n tsma res: %s" % ( + sql, str(row_no_tsma), str(row_tsma), str(no_tsma_res), str(tsma_res))) + tdLog.info('result check succeed for sql: %s. \n tsma-res: %s. \nno_tsma-res: %s' % + (sql, str(tsma_res), str(no_tsma_res))) + + def check_sql(self, sql: str, expect: TSMAQueryContext): + tdLog.debug(f"start to check sql: {sql}") + actual_ctx = self.check_explain(sql, expect=expect) + tdLog.debug(f"ctx: {actual_ctx}") + if actual_ctx.has_tsma(): + self.check_result(sql, expect.ignore_res_order_) + + def check_sqls(self, sqls, expects): + for sql, query_ctx in zip(sqls, expects): + self.check_sql(sql, query_ctx) + + +class TSMATesterSQLGeneratorOptions: + def __init__(self) -> None: + self.ts_min: int = 1537146000000 - 1000 * 60 * 60 + self.ts_max: int = 1537150999000 + 1000 * 60 * 60 + self.times: int = 100 + self.pk_col: str = 'ts' + self.column_prefix: str = 'c' + self.column_num: int = 9 # c1 - c10 + self.tags_prefix: str = 't' + self.tag_num: int = 6 # t1 - t6 + self.str_tag_idx: List = [2, 3] + self.child_table_name_prefix: str = 't' + self.child_table_num: int = 10 # t0 - t9 + self.interval: bool = False + # 70% generating a partition by, 30% no partition by, same as group by + self.partition_by: bool = False + self.group_by: bool = False + # generating no ts range condition is also possible + self.where_ts_range: bool = False + self.where_tbname_func: bool = False + self.where_tag_func: bool = False + self.where_col_func: bool = False + self.slimit_max = 10 + self.limit_max = 10 + self.norm_tb = False + + +class TSMATesterSQLGeneratorRes: + def __init__(self): + self.has_where_ts_range: bool = False + self.has_interval: bool = False + self.partition_by: bool = False + self.group_by: bool = False + self.has_slimit: bool = False + self.has_limit: bool = False + self.has_user_order_by: bool = False + + def can_ignore_res_order(self): + return not (self.has_limit and self.has_slimit) + + +class TSMATestSQLGenerator: + def __init__(self, opts: TSMATesterSQLGeneratorOptions = TSMATesterSQLGeneratorOptions()): + self.db_name_: str = '' + self.tb_name_: str = '' + self.ts_scan_range_: List[float] = [ + float(UsedTsma.TS_MIN), float(UsedTsma.TS_MAX)] + self.agg_funcs_: List[str] = [] + self.tsmas_: List[TSMA] = [] # currently created tsmas + self.opts_: TSMATesterSQLGeneratorOptions = opts + self.res_: TSMATesterSQLGeneratorRes = TSMATesterSQLGeneratorRes() + + self.select_list_: List[str] = [] + self.where_list_: List[str] = [] + self.group_or_partition_by_list: List[str] = [] + self.interval: str = '' + + def get_depth_one_str_funcs(self, name: str) -> List[str]: + concat1 = f'CONCAT({name}, "_concat")' + concat2 = f'CONCAT({name}, {name})' + concat3 = f'CONCAT({name}, {name}, {name})' + start = random.randint(1, 3) + len = random.randint(0, 3) + substr = f'SUBSTR({name}, {start}, {len})' + lower = f'LOWER({name})' + ltrim = f'LTRIM({name})' + return [concat1, concat2, concat3, substr, substr, lower, lower, ltrim, name] + + def generate_depthed_str_func(self, name: str, depth: int) -> str: + if depth == 1: + return random.choice(self.get_depth_one_str_funcs(name)) + name = self.generate_depthed_str_func(name, depth - 1) + return random.choice(self.get_depth_one_str_funcs(name)) + + def generate_str_func(self, column_name: str, depth: int = 0) -> str: + if depth == 0: + depth = random.randint(1, 3) + + ret = self.generate_depthed_str_func(column_name, depth) + tdLog.debug(f'generating str func: {ret}') + return ret + + def get_random_type(self, funcs): + rand: int = randrange(1, len(funcs)) + return funcs[rand-1]() + + def generate_select_list(self, user_select_list: str, partition_by_list: str): + res = user_select_list + if self.res_.has_interval and random.random() < 0.8: + res = res + ',_wstart, _wend' + if self.res_.partition_by or self.res_.group_by and random.random() < 0.8: + res = res + f',{partition_by_list}' + return res + + def generate_order_by(self, user_order_by: str, partition_by_list: str): + auto_order_by = 'ORDER BY' + has_limit = self.res_.has_limit or self.res_.has_slimit + if has_limit and (self.res_.group_by or self.res_.partition_by): + auto_order_by = f'{auto_order_by} {partition_by_list},' + if has_limit and self.res_.has_interval: + auto_order_by = f'{auto_order_by} _wstart, _wend,' + if len(user_order_by) > 0: + self.res_.has_user_order_by = True + auto_order_by = f'{auto_order_by} {user_order_by},' + if auto_order_by == 'ORDER BY': + return '' + else: + return auto_order_by[:-1] + + def generate_one(self, select_list: str, possible_tbs: List, order_by_list: str, interval_list: List[str] = []) -> str: + tb = random.choice(possible_tbs) + where = self.generate_where() + interval = self.generate_interval(interval_list) + (partition_by, partition_by_list) = self.generate_partition_by() + limit = self.generate_limit() + auto_select_list = self.generate_select_list( + select_list, partition_by_list) + order_by = self.generate_order_by(order_by_list, partition_by_list) + sql = f"SELECT {auto_select_list} FROM {tb} {where} {partition_by} {partition_by_list} {interval} {order_by} {limit}" + tdLog.debug(sql) + return sql + + def can_ignore_res_order(self): + return self.res_.can_ignore_res_order() + + def generate_where(self) -> str: + v = random.random() + where = '' + if not self.opts_.norm_tb: + if v < 0.2: + where = f'{self.generate_tbname_where()}' + elif v < 0.5: + where = f'{self.generate_tag_where()}' + elif v < 0.7: + op = random.choice(['AND', 'OR']) + where = f'{self.generate_tbname_where()} {op} {self.generate_tag_where()}' + ts_where = self.generate_ts_where_range() + if len(ts_where) > 0 or len(where) > 0: + op = '' + if len(where) > 0 and len(ts_where) > 0: + op = random.choice(['AND', 'AND', 'AND', 'AND', 'OR']) + return f'WHERE {ts_where} {op} {where}' + return '' + + def generate_str_equal_operator(self, column_name: str, opts: List) -> str: + opt = random.choice(opts) + return f'{column_name} = "{opt}"' + + # TODO support it + def generate_str_in_operator(self, column_name: str, opts: List) -> str: + opt = random.choice(opts) + IN = f'"{",".join(opts)}"' + return f'{column_name} in ({IN})' + + def generate_str_like_operator(self, column_name: str, opts: List) -> str: + opt = random.choice(opts) + return f'{column_name} like "{opt}"' + + def generate_tbname_where(self) -> str: + tbs = [] + for idx in range(1, self.opts_.tag_num + 1): + tbs.append(f'{self.opts_.child_table_name_prefix}{idx}') + + if random.random() < 0.5: + return self.generate_str_equal_operator('tbname', tbs) + else: + return self.generate_str_like_operator('tbname', ['t%', '%2']) + + def generate_tag_where(self) -> str: + idx = random.randrange(1, self.opts_.tag_num + 1) + if random.random() < 0.5 and idx in self.opts_.str_tag_idx: + if random.random() < 0.5: + return self.generate_str_equal_operator(f'{self.opts_.tags_prefix}{idx}', [f'tb{random.randint(1,100)}']) + else: + return self.generate_str_like_operator(f'{self.opts_.tags_prefix}{idx}', ['%1', 'tb%', 'tb1%', '%1%']) + else: + operator = random.choice(['>', '>=', '<', '<=', '=', '!=']) + val = random.randint(1, 100) + return f'{self.opts_.tags_prefix}{idx} {operator} {val}' + + def generate_timestamp(self, min: float = -1, max: float = 0) -> int: + milliseconds_aligned: float = random.randint(int(min), int(max)) + seconds_aligned = int(milliseconds_aligned / 1000) * 1000 + if seconds_aligned < min: + seconds_aligned = int(min) + minutes_aligned = int(milliseconds_aligned / 1000 / 60) * 1000 * 60 + if minutes_aligned < min: + minutes_aligned = int(min) + hour_aligned = int(milliseconds_aligned / 1000 / + 60 / 60) * 1000 * 60 * 60 + if hour_aligned < min: + hour_aligned = int(min) + + return random.choice([milliseconds_aligned, seconds_aligned, seconds_aligned, minutes_aligned, minutes_aligned, hour_aligned, hour_aligned]) + + def generate_ts_where_range(self): + if not self.opts_.where_ts_range: + return '' + left_operators = ['>', '>=', ''] + right_operators = ['<', '<=', ''] + left_operator = left_operators[random.randrange(0, 3)] + right_operator = right_operators[random.randrange(0, 3)] + a = '' + left_value = None + if left_operator: + left_value = self.generate_timestamp( + self.opts_.ts_min, self.opts_.ts_max) + a += f'{self.opts_.pk_col} {left_operator} {left_value}' + if right_operator: + if left_value: + start = left_value + else: + start = self.opts_.ts_min + right_value = self.generate_timestamp(start, self.opts_.ts_max) + if left_operator: + a += ' AND ' + a += f'{self.opts_.pk_col} {right_operator} {right_value}' + # tdLog.debug(f'{self.opts_.pk_col} range with: {a}') + if len(a) > 0: + self.res_.has_where_ts_range = True + return a + + def generate_limit(self) -> str: + ret = '' + can_have_slimit = self.res_.partition_by or self.res_.group_by + if can_have_slimit: + if random.random() < 0.4: + ret = f'SLIMIT {random.randint(0, self.opts_.slimit_max)}' + self.res_.has_slimit = True + if random.random() < 0.4: + self.res_.has_limit = True + ret = ret + f' LIMIT {random.randint(0, self.opts_.limit_max)}' + return ret + + ## if offset is True, offset cannot be the same as interval + def generate_random_offset_sliding(self, interval: str, offset: bool = False) -> str: + unit = interval[-1] + hasUnit = unit.isalpha() + if not hasUnit: + start = 1 + if offset: + start = 2 + ret: int = int(int(interval) / random.randint(start, 5)) + return str(ret) + return '' + + # add sliding offset + def generate_interval(self, intervals: List[str]) -> str: + if not self.opts_.interval: + return '' + if random.random() < 0.4: # no interval + return '' + value = random.choice(intervals) + self.res_.has_interval = True + has_offset = False + offset = '' + has_sliding = False + sliding = '' + num: int = int(value[:-1]) + unit = value[-1] + if has_offset and num > 1: + offset = f', {self.generate_random_offset_sliding(value, True)}' + if has_sliding: + sliding = f'sliding({self.generate_random_offset_sliding(value)})' + return f'INTERVAL({value} {offset}) {sliding}' + + def generate_tag_list(self): + used_tag_num = random.randrange(1, self.opts_.tag_num + 1) + ret = '' + for _ in range(used_tag_num): + tag_idx = random.randint(1, self.opts_.tag_num) + tag_name = self.opts_.tags_prefix + f'{tag_idx}' + if random.random() < 0.5 and tag_idx in self.opts_.str_tag_idx: + tag_func = self.generate_str_func(tag_name, 2) + else: + tag_func = tag_name + ret = ret + f'{tag_func},' + return ret[:-1] + + def generate_tbname_tag_list(self): + tag_num = random.randrange(1, self.opts_.tag_num) + ret = '' + tbname_idx = random.randint(0, tag_num + 1) + for i in range(tag_num + 1): + if i == tbname_idx: + ret = ret + 'tbname,' + else: + tag_idx = random.randint(1, self.opts_.tag_num) + ret = ret + self.opts_.tags_prefix + f'{tag_idx},' + return ret[:-1] + + def generate_partition_by(self): + if not self.opts_.partition_by and not self.opts_.group_by: + return ('', '') + # no partition or group + if random.random() < 0.3: + return ('', '') + ret = '' + rand = random.random() + if rand < 0.4: + if random.random() < 0.5: + ret = self.generate_str_func('tbname', 3) + else: + ret = 'tbname' + elif rand < 0.8: + ret = self.generate_tag_list() + else: + # tbname and tag + ret = self.generate_tbname_tag_list() + # tdLog.debug(f'partition by: {ret}') + if self.res_.has_interval or random.random() < 0.5: + self.res_.partition_by = True + return (str('PARTITION BY'), f'{ret}') + else: + self.res_.group_by = True + return (str('GROUP BY'), f'{ret}') + + def generate_where_tbname(self) -> str: + return self.generate_str_func('tbname') + + def generate_where_tag(self) -> str: + # tag_idx = random.randint(1, self.opts_.tag_num) + # tag = self.opts_.tags_prefix + str(tag_idx) + return self.generate_str_func('t3') + + def generate_where_conditions(self) -> str: + + pass + + # generate func in tsmas(select list) + def _generate_agg_func_for_select(self) -> str: + pass + + # order by, limit, having, subquery... + + +class TDTestCase: + updatecfgDict = {'asynclog': 0, 'ttlUnit': 1, 'ttlPushInterval': 5, 'ratioOfVnodeStreamThrea': 4, 'maxTsmaNum': 8} + + def __init__(self): + self.vgroups = 4 + self.ctbNum = 10 + self.rowsPerTbl = 10000 + self.duraion = '1h' + + def init(self, conn, logSql, replicaVar=1): + self.replicaVar = int(replicaVar) + tdLog.debug(f"start to excute {__file__}") + tdSql.init(conn.cursor(), False) + self.tsma_tester: TSMATester = TSMATester(tdSql) + self.tsma_sql_generator: TSMATestSQLGenerator = TSMATestSQLGenerator() + + def create_database(self, tsql, dbName, dropFlag=1, vgroups=2, replica=1, duration: str = '1d'): + if dropFlag == 1: + tsql.execute("drop database if exists %s" % (dbName)) + + tsql.execute("create database if not exists %s vgroups %d replica %d duration %s" % ( + dbName, vgroups, replica, duration)) + tdLog.debug("complete to create database %s" % (dbName)) + return + + def create_stable(self, tsql, paraDict): + colString = tdCom.gen_column_type_str( + colname_prefix=paraDict["colPrefix"], column_elm_list=paraDict["colSchema"]) + tagString = tdCom.gen_tag_type_str( + tagname_prefix=paraDict["tagPrefix"], tag_elm_list=paraDict["tagSchema"]) + sqlString = f"create table if not exists %s.%s (%s) tags (%s)" % ( + paraDict["dbName"], paraDict["stbName"], colString, tagString) + tdLog.debug("%s" % (sqlString)) + tsql.execute(sqlString) + return + + def create_ctable(self, tsql=None, dbName='dbx', stbName='stb', ctbPrefix='ctb', ctbNum=1, ctbStartIdx=0): + for i in range(ctbNum): + sqlString = "create table %s.%s%d using %s.%s tags(%d, 'tb%d', 'tb%d', %d, %d, %d)" % (dbName, ctbPrefix, i+ctbStartIdx, dbName, stbName, (i+ctbStartIdx) % 5, i+ctbStartIdx + random.randint( + 1, 100), i+ctbStartIdx + random.randint(1, 100), i+ctbStartIdx + random.randint(1, 100), i+ctbStartIdx + random.randint(1, 100), i+ctbStartIdx + random.randint(1, 100)) + tsql.execute(sqlString) + + tdLog.debug("complete to create %d child tables by %s.%s" % + (ctbNum, dbName, stbName)) + return + + def init_normal_tb(self, tsql, db_name: str, tb_name: str, rows: int, start_ts: int, ts_step: int): + sql = 'CREATE TABLE %s.%s (ts timestamp, c1 INT, c2 INT, c3 INT, c4 double, c5 VARCHAR(255))' % ( + db_name, tb_name) + tsql.execute(sql) + sql = 'INSERT INTO %s.%s values' % (db_name, tb_name) + for j in range(rows): + sql += f'(%d, %d,%d,%d,{random.random()},"varchar_%d"),' % (start_ts + j * ts_step + randrange(500), j % + 10 + randrange(200), j % 10, j % 10, j % 10 + randrange(100)) + tsql.execute(sql) + + def insert_data(self, tsql, dbName, ctbPrefix, ctbNum, rowsPerTbl, batchNum, startTs, tsStep): + tdLog.debug("start to insert data ............") + tsql.execute("use %s" % dbName) + pre_insert = "insert into " + sql = pre_insert + + for i in range(ctbNum): + rowsBatched = 0 + sql += " %s.%s%d values " % (dbName, ctbPrefix, i) + for j in range(rowsPerTbl): + if (i < ctbNum/2): + sql += "(%d, %d, %d, %d,%d,%d,%d,true,'binary%d', 'nchar%d') " % (startTs + j*tsStep + randrange( + 500), j % 10 + randrange(100), j % 10 + randrange(200), j % 10, j % 10, j % 10, j % 10, j % 10, j % 10) + else: + sql += "(%d, %d, NULL, %d,NULL,%d,%d,true,'binary%d', 'nchar%d') " % ( + startTs + j*tsStep + randrange(500), j % 10, j % 10, j % 10, j % 10, j % 10, j % 10) + rowsBatched += 1 + if ((rowsBatched == batchNum) or (j == rowsPerTbl - 1)): + tsql.execute(sql) + rowsBatched = 0 + if j < rowsPerTbl - 1: + sql = "insert into %s.%s%d values " % (dbName, ctbPrefix, i) + else: + sql = "insert into " + if sql != pre_insert: + tsql.execute(sql) + tdLog.debug("insert data ............ [OK]") + return + + def init_data(self, ctb_num: int = 10, rows_per_ctb: int = 10000, start_ts: int = 1537146000000, ts_step: int = 500): + tdLog.printNoPrefix( + "======== prepare test env include database, stable, ctables, and insert data: ") + paraDict = {'dbName': 'test', + 'dropFlag': 1, + 'vgroups': 2, + 'stbName': 'meters', + 'colPrefix': 'c', + 'tagPrefix': 't', + 'colSchema': [{'type': 'INT', 'count': 1}, {'type': 'BIGINT', 'count': 1}, {'type': 'FLOAT', 'count': 1}, {'type': 'DOUBLE', 'count': 1}, {'type': 'smallint', 'count': 1}, {'type': 'tinyint', 'count': 1}, {'type': 'bool', 'count': 1}, {'type': 'binary', 'len': 10, 'count': 1}, {'type': 'nchar', 'len': 10, 'count': 1}], + 'tagSchema': [{'type': 'INT', 'count': 1}, {'type': 'nchar', 'len': 20, 'count': 1}, {'type': 'binary', 'len': 20, 'count': 1}, {'type': 'BIGINT', 'count': 1}, {'type': 'smallint', 'count': 1}, {'type': 'DOUBLE', 'count': 1}], + 'ctbPrefix': 't', + 'ctbStartIdx': 0, + 'ctbNum': ctb_num, + 'rowsPerTbl': rows_per_ctb, + 'batchNum': 3000, + 'startTs': start_ts, + 'tsStep': ts_step} + + paraDict['vgroups'] = self.vgroups + paraDict['ctbNum'] = self.ctbNum + paraDict['rowsPerTbl'] = self.rowsPerTbl + + tdLog.info("create database") + self.create_database(tsql=tdSql, dbName=paraDict["dbName"], dropFlag=paraDict["dropFlag"], + vgroups=paraDict["vgroups"], replica=self.replicaVar, duration=self.duraion) + + tdLog.info("create stb") + self.create_stable(tsql=tdSql, paraDict=paraDict) + + tdLog.info("create child tables") + self.create_ctable(tsql=tdSql, dbName=paraDict["dbName"], + stbName=paraDict["stbName"], ctbPrefix=paraDict["ctbPrefix"], + ctbNum=paraDict["ctbNum"], ctbStartIdx=paraDict["ctbStartIdx"]) + self.insert_data(tsql=tdSql, dbName=paraDict["dbName"], + ctbPrefix=paraDict["ctbPrefix"], ctbNum=paraDict["ctbNum"], + rowsPerTbl=paraDict["rowsPerTbl"], batchNum=paraDict["batchNum"], + startTs=paraDict["startTs"], tsStep=paraDict["tsStep"]) + self.init_normal_tb(tdSql, paraDict['dbName'], 'norm_tb', + paraDict['rowsPerTbl'], paraDict['startTs'], paraDict['tsStep']) + + def wait_for_tsma_calculation(self, func_list: list, db: str, tb: str, interval: str, tsma_name: str, timeout_seconds: int =600): + start_time = time.time() + while True: + current_time = time.time() + if current_time - start_time > timeout_seconds: + error_message = f"Timeout occurred while waiting for TSMA calculation to complete." + tdLog.exit(error_message) + sql = 'select %s from %s.%s interval(%s)' % ( + ', '.join(func_list), db, tb, interval) + tdLog.debug( + f'waiting for tsma {db}.{tsma_name} to be useful with sql {sql}') + ctx: TSMAQueryContext = self.tsma_tester.get_tsma_query_ctx(sql) + if ctx.has_tsma(): + if ctx.used_tsmas[0].name == tsma_name + UsedTsma.TSMA_RES_STB_POSTFIX: + break + elif len(ctx.used_tsmas[0].name) == 32: + name = f'1.{db}.{tsma_name}_{tb}' + if ctx.used_tsmas[0].name == TSMAQCBuilder().md5(name): + break + else: + time.sleep(1) + else: + time.sleep(1) + else: + time.sleep(1) + time.sleep(1) + + def create_tsma(self, tsma_name: str, db: str, tb: str, func_list: list, interval: str, check_tsma_calculation : str=True): + tdSql.execute('use %s' % db) + sql = "CREATE TSMA %s ON %s.%s FUNCTION(%s) INTERVAL(%s)" % ( + tsma_name, db, tb, ','.join(func_list), interval) + tdSql.execute(sql, queryTimes=1) + if check_tsma_calculation == True: + self.wait_for_tsma_calculation(func_list, db, tb, interval, tsma_name) + + def create_error_tsma(self, tsma_name: str, db: str, tb: str, func_list: list, interval: str, expectedErrno: int): + tdSql.execute('use %s' % db) + sql = "CREATE TSMA %s ON %s.%s FUNCTION(%s) INTERVAL(%s)" % ( + tsma_name, db, tb, ','.join(func_list), interval) + tdSql.error(sql, expectedErrno) + + def create_recursive_tsma(self, base_tsma_name: str, new_tsma_name: str, db: str, interval: str, tb_name: str, func_list: List[str] = ['avg(c1)']): + tdSql.execute('use %s' % db, queryTimes=1) + sql = 'CREATE RECURSIVE TSMA %s ON %s.%s INTERVAL(%s)' % ( + new_tsma_name, db, base_tsma_name, interval) + tdSql.execute(sql, queryTimes=1) + self.wait_for_tsma_calculation( + func_list, db, tb_name, interval, new_tsma_name) + + def drop_tsma(self, tsma_name: str, db: str): + sql = 'DROP TSMA %s.%s' % (db, tsma_name) + tdSql.execute(sql, queryTimes=1) + + def check_explain_res_has_row(self, plan_str_expect: str, explain_output): + plan_found = False + for row in explain_output: + if str(row).find(plan_str_expect) >= 0: + tdLog.debug("plan: [%s] found in: [%s]" % + (plan_str_expect, str(row))) + plan_found = True + break + if not plan_found: + tdLog.exit("plan: %s not found in res: [%s]" % ( + plan_str_expect, str(explain_output))) + + def check(self, ctxs: List): + for ctx in ctxs: + self.tsma_tester.check_sql(ctx.sql, ctx) + + def test_query_with_tsma(self): + self.create_tsma('tsma1', 'test', 'meters', ['avg(c1)', 'avg(c2)'], '5m') + self.create_tsma('tsma2', 'test', 'meters', ['avg(c1)', 'avg(c2)'], '30m') + self.create_tsma('tsma5', 'test', 'norm_tb', ['avg(c1)', 'avg(c2)'], '10m') + + self.test_query_with_tsma_interval() + self.test_query_with_tsma_agg() + self.test_recursive_tsma() + self.test_query_interval_sliding() + self.test_union() + self.test_query_child_table() + self.test_skip_tsma_hint() + self.test_long_tsma_name() + self.test_long_ctb_name() + self.test_add_tag_col() + self.test_modify_col_name_value() + self.test_alter_tag_val() + self.test_ins_tsma() + + def test_ins_tsma(self): + tdSql.execute('use performance_schema') + tdSql.query('show performance_schema.tsmas') + tdSql.checkRows(0) + tdSql.execute('use test') + tdSql.query('show test.tsmas') + tdSql.checkRows(3) + tdSql.query('select * from information_schema.ins_tsmas') + tdSql.checkRows(3) + tdSql.execute('create database dd') + tdSql.execute('use dd') + tdSql.execute('create table dd.norm_tb (ts timestamp, c1 int)') + tdSql.execute('insert into dd.norm_tb values(now, 1)') + self.create_tsma('tsma_norm_tb_dd', 'dd', 'norm_tb', ['avg(c1)', 'sum(c1)', 'min(c1)'], '10m') + tdSql.query('show dd.tsmas') + tdSql.checkRows(1) + tdSql.query('select * from information_schema.ins_tsmas') + tdSql.checkRows(4) + tdSql.query('show test.tsmas') + tdSql.checkRows(3) + tdSql.execute('use test') + tdSql.query('show dd.tsmas') + tdSql.checkRows(1) + tdSql.execute('drop database dd') + tdSql.query('select * from information_schema.ins_tsmas') + tdSql.checkRows(3) + tdSql.execute('use test') + + def test_alter_tag_val(self): + sql = 'alter table test.t1 set tag t1 = 999' + tdSql.error(sql, -2147471088) + + def test_query_interval_sliding(self): + pass + + def test_union(self): + ctxs = [] + sql = 'select avg(c1) from test.meters union select avg(c1) from test.norm_tb' + ctx = TSMAQCBuilder().with_sql(sql).should_query_with_tsma('tsma2').should_query_with_tsma_ctb('test', 'tsma5', 'norm_tb').get_qc() + ctxs.append(ctx) + sql = 'select avg(c1), avg(c2) from test.meters where ts between "2018-09-17 09:00:00.000" and "2018-09-17 10:00:00.000" union select avg(c1), avg(c2) from test.meters where ts between "2018-09-17 09:00:00.200" and "2018-09-17 10:23:19.800"' + ctxs.append(TSMAQCBuilder().with_sql(sql) + .should_query_with_tsma('tsma2', '2018-09-17 09:00:00', '2018-09-17 09:59:59:999') + .should_query_with_table("meters", '2018-09-17 10:00:00', '2018-09-17 10:00:00') + .should_query_with_table('meters', '2018-09-17 09:00:00.200', '2018-09-17 09:29:59:999') + .should_query_with_tsma('tsma2', '2018-09-17 09:30:00', '2018-09-17 09:59:59.999') + .should_query_with_table('meters', '2018-09-17 10:00:00.000', '2018-09-17 10:23:19.800').get_qc()) + self.check(ctxs) + + tdSql.execute('create database db2') + tdSql.execute('use db2') + tdSql.execute('create table db2.norm_tb(ts timestamp, c2 int)') + tdSql.execute('insert into db2.norm_tb values(now, 1)') + tdSql.execute('insert into db2.norm_tb values(now, 2)') + self.create_tsma('tsma_db2_norm_t', 'db2', 'norm_tb', ['avg(c2)', 'last(ts)'], '10m') + sql = 'select avg(c1) as avg_c1 from test.meters union select avg(c2) from db2.norm_tb order by avg_c1' + self.check([TSMAQCBuilder().with_sql(sql).should_query_with_tsma('tsma2').should_query_with_tsma_ctb('db2', 'tsma_db2_norm_t', 'norm_tb').get_qc()]) + tdSql.execute('drop database db2') + tdSql.execute('use test') + + def test_modify_col_name_value(self): + tdSql.error('alter table test.norm_tb rename column c1 c1_new', -2147471088) ## tsma must be dropped + + ## modify tag name + tdSql.error('alter stable test.meters rename tag t1 t1_new;', -2147482637) ## stream must be dropped + + def test_add_tag_col(self): + ## query with newly add tag will skip all tsmas not have this tag + tdSql.execute('alter table test.meters add tag tag_new int', queryTimes=1) + sql = 'select avg(c1) from test.meters partition by tag_new' + self.check([TSMAQCBuilder().with_sql(sql).should_query_with_table('meters').get_qc()]) + sql = 'select avg(c1) from test.meters partition by abs(tag_new)' + self.check([TSMAQCBuilder().with_sql(sql).should_query_with_table('meters').get_qc()]) + sql = 'select avg(c1) from test.meters where abs(tag_new) > 100' + self.check([TSMAQCBuilder().with_sql(sql).should_query_with_table('meters').get_qc()]) + + tdSql.execute('alter table test.meters drop tag tag_new', queryTimes=1) + + def generate_random_string(self, length): + letters_and_digits = string.ascii_lowercase + result_str = ''.join(random.choice(letters_and_digits) for i in range(length)) + return result_str + + def test_long_tsma_name(self): + name = self.generate_random_string(178) + tsma_func_list = ['avg(c2)', 'avg(c3)', 'min(c4)', 'max(c3)', 'sum(c2)', 'count(ts)', 'count(c2)', 'first(c5)', 'last(c5)', 'spread(c2)', 'stddev(c3)', 'hyperloglog(c5)', 'last(ts)'] + self.create_tsma(name, 'test', 'meters', tsma_func_list, '55m') + sql = 'select last(c5), spread(c2) from test.meters interval(55m)' + ctx = TSMAQCBuilder().with_sql(sql).should_query_with_tsma(name).get_qc() + self.check([ctx]) + tdSql.execute(f'drop tsma test.{name}') + + name = self.generate_random_string(180) + tdSql.error(f'create tsma {name} on test.meters function({",".join(tsma_func_list)}) interval(1h)', -2147471087) + + name = self.generate_random_string(179) + tdSql.error(f'create tsma {name} on test.meters function({",".join(tsma_func_list)}) interval(1h)', -2147471087) + + name = self.generate_random_string(178) + self.create_recursive_tsma('tsma1', name, 'test', '60m', 'meters', ['avg(c1)','avg(c2)']) + sql = 'select avg(c1) from test.meters interval(60m)' + self.check([TSMAQCBuilder().with_sql(sql).should_query_with_tsma(name).get_qc()]) + + tdSql.execute(f'drop tsma test.{name}') + + def test_long_ctb_name(self): + tb_name = self.generate_random_string(192) + tsma_name = self.generate_random_string(178) + tdSql.execute('create database db2') + tdSql.execute('use db2') + db_name = 'db2' + tdSql.execute(f'create table {db_name}.{tb_name}(ts timestamp, c2 int)') + tdSql.execute(f'insert into {db_name}.{tb_name} values(now, 1)') + tdSql.execute(f'insert into {db_name}.{tb_name} values(now, 2)') + self.create_tsma(tsma_name, 'db2', tb_name, ['avg(c2)', 'last(ts)'], '10m') + sql = f'select avg(c2), last(ts) from {db_name}.{tb_name}' + self.check([TSMAQCBuilder().with_sql(sql).should_query_with_tsma_ctb('db2', tsma_name, tb_name).get_qc()]) + tdSql.execute('drop database db2') + tdSql.execute('use test') + + def test_skip_tsma_hint(self): + ctxs = [] + sql = 'select /*+ skip_tsma()*/avg(c1), avg(c2) from test.meters interval(5m)' + ctxs.append(TSMAQCBuilder().with_sql(sql).should_query_with_table('meters').get_qc()) + + sql = 'select avg(c1), avg(c2) from test.meters interval(5m)' + ctxs.append(TSMAQCBuilder().with_sql(sql).should_query_with_tsma('tsma1').get_qc()) + self.check(ctxs) + + def test_query_child_table(self): + sql = 'select avg(c1) from test.t1' + ctx = TSMAQCBuilder().with_sql(sql).should_query_with_tsma_ctb('test', 'tsma2', 't1', UsedTsma.TS_MIN, UsedTsma.TS_MAX).get_qc() + self.tsma_tester.check_sql(sql, ctx) + sql = 'select avg(c1) from test.t3' + ctx = TSMAQCBuilder().with_sql(sql).should_query_with_tsma_ctb('test', 'tsma2', 't3').get_qc() + self.tsma_tester.check_sql(sql, ctx) + + def test_recursive_tsma(self): + tdSql.execute('drop tsma test.tsma2') + tsma_func_list = ['last(ts)', 'avg(c2)', 'avg(c3)', 'min(c4)', 'max(c3)', 'sum(c2)', 'count(ts)', 'count(c2)', 'first(c5)', 'last(c5)', 'spread(c2)', 'stddev(c3)', 'hyperloglog(c5)'] + select_func_list: List[str] = tsma_func_list.copy() + select_func_list.append('count(*)') + self.create_tsma('tsma3', 'test', 'meters', tsma_func_list, '5m') + self.create_recursive_tsma( + 'tsma3', 'tsma4', 'test', '20m', 'meters', tsma_func_list) + # now we have 5m, 10m, 30m, 1h 4 tsmas + sql = 'select avg(c2), "recursive test.tsma4" from test.meters' + ctx = TSMAQCBuilder().with_sql(sql).should_query_with_tsma( + 'tsma4', UsedTsma.TS_MIN, UsedTsma.TS_MAX).get_qc() + #time.sleep(999999) + self.tsma_tester.check_sql(sql, ctx) + self.check(self.test_query_tsma_all(select_func_list)) + self.create_recursive_tsma( + 'tsma4', 'tsma6', 'test', '1h', 'meters', tsma_func_list) + ctx = TSMAQCBuilder().with_sql(sql).should_query_with_tsma( + 'tsma6', UsedTsma.TS_MIN, UsedTsma.TS_MAX).get_qc() + self.tsma_tester.check_sql(sql, ctx) + + self.check(self.test_query_tsma_all(select_func_list)) + + tdSql.error('drop tsma test.tsma3', -2147482491) + tdSql.error('drop tsma test.tsma4', -2147482491) + tdSql.execute('drop tsma test.tsma6') + tdSql.execute('drop tsma test.tsma4') + tdSql.execute('drop tsma test.tsma3') + self.create_tsma('tsma2', 'test', 'meters', ['avg(c1)', 'avg(c2)'], '30m') + + # test query with dropped tsma tsma4 and tsma6 + sql = 'select avg(c2), "test.tsma2" from test.meters' + ctx = TSMAQCBuilder().with_sql(sql).should_query_with_tsma( + 'tsma2', UsedTsma.TS_MIN, UsedTsma.TS_MAX).get_qc() + self.check([ctx]) + + # test recrusive tsma on norm_tb + tsma_name = 'tsma_recursive_on_norm_tb' + self.create_recursive_tsma('tsma5', tsma_name, 'test', '20m', 'norm_tb', ['avg(c1)', 'avg(c2)']) + sql = 'select avg(c1), avg(c2), tbname from test.norm_tb partition by tbname interval(20m)' + self.check([TSMAQCBuilder().with_sql(sql).should_query_with_tsma_ctb('test', tsma_name, 'norm_tb').get_qc()]) + tdSql.execute(f'drop tsma test.{tsma_name}') + + def test_query_with_tsma_interval(self): + self.check(self.test_query_with_tsma_interval_possibly_partition()) + self.check(self.test_query_with_tsma_interval_partition_by_col()) + + def test_query_tsma_all(self, func_list: List = ['avg(c1)', 'avg(c2)']) -> List: + ctxs = [] + interval_list = ['1s', '5s', '59s', '60s', '1m', '120s', '10m', '20m', + '30m', '1h', '90m', '2h', '8h', '1d'] + opts: TSMATesterSQLGeneratorOptions = TSMATesterSQLGeneratorOptions() + opts.interval = True + opts.where_ts_range = True + for _ in range(1, ROUND): + opts.partition_by = True + opts.group_by = True + opts.norm_tb = False + sql_generator = TSMATestSQLGenerator(opts) + sql = sql_generator.generate_one( + ','.join(func_list), ['test.meters', 'test.meters', 'test.t1', 'test.t9'], '', interval_list) + ctxs.append(TSMAQCBuilder().with_sql(sql).ignore_query_table( + ).ignore_res_order(sql_generator.can_ignore_res_order()).get_qc()) + + if random.random() > 0.7: + continue + opts.partition_by = False + opts.group_by = False + opts.norm_tb = True + sql_generator = TSMATestSQLGenerator(opts) + sql = sql_generator.generate_one( + ','.join(func_list), ['test.norm_tb', 'test.t5'], '', interval_list) + ctxs.append(TSMAQCBuilder().with_sql(sql).ignore_query_table( + ).ignore_res_order(sql_generator.can_ignore_res_order()).get_qc()) + return ctxs + + def test_query_with_tsma_interval_possibly_partition(self,db_name: str = 'test'): + ctxs: List[TSMAQueryContext] = [] + sql = f'select avg(c1), avg(c2) from {db_name}.meters interval(5m)' + ctxs.append(TSMAQCBuilder().with_sql(sql) + .should_query_with_tsma('tsma1', UsedTsma.TS_MIN, UsedTsma.TS_MAX).get_qc()) + + sql = f'select avg(c1), avg(c2) from {db_name}.meters interval(10m)' + ctxs.append(TSMAQCBuilder().with_sql(sql) + .should_query_with_tsma('tsma1', UsedTsma.TS_MIN, UsedTsma.TS_MAX).get_qc()) + sql = f'select avg(c1), avg(c2) from {db_name}.meters interval(30m)' + ctxs.append(TSMAQCBuilder().with_sql(sql) + .should_query_with_tsma('tsma2', UsedTsma.TS_MIN, UsedTsma.TS_MAX).get_qc()) + sql = f'select avg(c1), avg(c2) from {db_name}.meters interval(60m)' + ctxs.append(TSMAQCBuilder().with_sql(sql) + .should_query_with_tsma('tsma2', UsedTsma.TS_MIN, UsedTsma.TS_MAX).get_qc()) + sql = f'select avg(c1), avg(c2) from {db_name}.meters interval(60m, 30m) SLIDING(30m)' + ctxs.append(TSMAQCBuilder().with_sql(sql) + .should_query_with_tsma('tsma2', UsedTsma.TS_MIN, UsedTsma.TS_MAX).get_qc()) + sql = f'select avg(c1), avg(c2) from {db_name}.meters interval(60m, 25m) SLIDING(25m)' + ctxs.append(TSMAQCBuilder().with_sql(sql) + .should_query_with_tsma('tsma1', UsedTsma.TS_MIN, UsedTsma.TS_MAX).get_qc()) + + sql = f"select avg(c1), avg(c2) from {db_name}.meters where ts >= '2018-09-17 09:00:00.009' and ts < '2018-09-17 10:23:19.665' interval(30m)" + ctxs.append(TSMAQCBuilder().with_sql(sql) + .should_query_with_table('meters', '2018-09-17 09:00:00.009', '2018-09-17 09:29:59.999') + .should_query_with_tsma('tsma2', '2018-09-17 09:30:00', '2018-09-17 09:59:59.999') + .should_query_with_table('meters', '2018-09-17 10:00:00.000', '2018-09-17 10:23:19.664').get_qc()) + + sql = f"select avg(c1), avg(c2) from {db_name}.meters where ts >= '2018-09-17 09:00:00.009' and ts < '2018-09-17 10:23:19.665' interval(30m, 25m) SLIDING(10m)" + ctxs.append(TSMAQCBuilder().with_sql(sql) + .should_query_with_table('meters', '2018-09-17 09:00:00.009', '2018-09-17 09:04:59.999') + .should_query_with_tsma('tsma1', '2018-09-17 09:05:00', '2018-09-17 09:54:59.999') + .should_query_with_table('meters', '2018-09-17 09:55:00.000', '2018-09-17 10:23:19.664').get_qc()) + + sql = f"SELECT avg(c1), avg(c2),_wstart, _wend,t3,t4,t5,t2 FROM {db_name}.meters WHERE ts >= '2018-09-17 8:00:00' AND ts < '2018-09-17 09:03:18.334' PARTITION BY t3,t4,t5,t2 INTERVAL(1d);" + ctxs.append(TSMAQCBuilder().with_sql(sql) + .should_query_with_table('meters', '2018-09-17 8:00:00', '2018-09-17 09:03:18.333').get_qc()) + ctxs.extend(self.test_query_tsma_all()) + return ctxs + + def test_query_with_tsma_interval_partition_by_col(self): + return [] + + def test_query_with_tsma_agg(self): + self.check(self.test_query_with_tsma_agg_no_group_by()) + self.check(self.test_query_with_tsma_agg_group_by_tbname()) + self.check(self.test_query_with_tsma_with_having()) + + def test_query_with_tsma_agg_no_group_by(self, db_name: str = 'test'): + ctxs: List[TSMAQueryContext] = [] + sql = f'select avg(c1), avg(c2) from {db_name}.meters' + ctxs.append(TSMAQCBuilder().with_sql( + sql).should_query_with_tsma('tsma2').get_qc()) + + sql = f'select avg(c1), avg(c2) from {db_name}.meters where ts between "2018-09-17 09:00:00.000" and "2018-09-17 10:00:00.000"' + ctxs.append(TSMAQCBuilder().with_sql(sql) + .should_query_with_tsma('tsma2', '2018-09-17 09:00:00', '2018-09-17 09:59:59:999') + .should_query_with_table("meters", '2018-09-17 10:00:00', '2018-09-17 10:00:00').get_qc()) + + sql = f'select avg(c1), avg(c2) from {db_name}.meters where ts between "2018-09-17 09:00:00.200" and "2018-09-17 10:23:19.800"' + ctxs.append(TSMAQCBuilder().with_sql(sql) + .should_query_with_table('meters', '2018-09-17 09:00:00.200', '2018-09-17 09:29:59:999') + .should_query_with_tsma('tsma2', '2018-09-17 09:30:00', '2018-09-17 09:59:59.999') + .should_query_with_table('meters', '2018-09-17 10:00:00.000', '2018-09-17 10:23:19.800').get_qc()) + + sql = f'select avg(c1) + avg(c2), avg(c2) from {db_name}.meters where ts between "2018-09-17 09:00:00.200" and "2018-09-17 10:23:19.800"' + ctxs.append(TSMAQCBuilder().with_sql(sql) + .should_query_with_table('meters', '2018-09-17 09:00:00.200', '2018-09-17 09:29:59:999') + .should_query_with_tsma('tsma2', '2018-09-17 09:30:00', '2018-09-17 09:59:59.999') + .should_query_with_table('meters', '2018-09-17 10:00:00.000', '2018-09-17 10:23:19.800').get_qc()) + + sql = f'select avg(c1) + avg(c2), avg(c2) + 1 from {db_name}.meters where ts between "2018-09-17 09:00:00.200" and "2018-09-17 10:23:19.800"' + ctxs.append(TSMAQCBuilder().with_sql(sql) + .should_query_with_table('meters', '2018-09-17 09:00:00.200', '2018-09-17 09:29:59:999') + .should_query_with_tsma('tsma2', '2018-09-17 09:30:00', '2018-09-17 09:59:59.999') + .should_query_with_table('meters', '2018-09-17 10:00:00.000', '2018-09-17 10:23:19.800').get_qc()) + + sql = f"select avg(c1) + 1, avg(c2) from {db_name}.meters where ts >= '2018-09-17 9:30:00.118' and ts < '2018-09-17 10:50:00'" + ctxs.append(TSMAQCBuilder().with_sql(sql) + .should_query_with_table('meters', '2018-09-17 9:30:00.118', '2018-09-17 9:59:59.999') + .should_query_with_tsma('tsma2', '2018-09-17 10:00:00', '2018-09-17 10:29:59.999') + .should_query_with_tsma('tsma1', '2018-09-17 10:30:00.000', '2018-09-17 10:49:59.999').get_qc()) + + sql = f"select avg(c1), avg(c2) from {db_name}.meters where ts >= '2018-09-17 9:00:00' and ts < '2018-09-17 9:45:00' limit 2" + ctxs.append(TSMAQCBuilder().with_sql(sql) + .should_query_with_tsma('tsma2', '2018-09-17 9:00:00', '2018-09-17 9:29:59.999') + .should_query_with_tsma('tsma1', '2018-09-17 9:30:00', '2018-09-17 9:44:59.999').get_qc()) + + sql = f'select avg(c1) + avg(c2) from {db_name}.meters where tbname like "%t1%"' + ctxs.append(TSMAQCBuilder().with_sql( + sql).should_query_with_tsma('tsma2').get_qc()) + + sql = f'select avg(c1), avg(c2) from {db_name}.meters where c1 is not NULL' + ctxs.append(TSMAQCBuilder().with_sql( + sql).should_query_with_table('meters').get_qc()) + + sql = f'select avg(c1), avg(c2), spread(c4) from {db_name}.meters' + ctxs.append(TSMAQCBuilder().with_sql( + sql).should_query_with_table('meters').get_qc()) + + sql = f'select avg(c1), avg(c2) from {db_name}.meters where tbname = \'t1\'' + ctxs.append(TSMAQCBuilder().with_sql( + sql).should_query_with_tsma('tsma2').get_qc()) + + sql = f'select avg(c1), avg(c2) from {db_name}.meters where tbname = \'t1\' or tbname = \'t2\'' + ctxs.append(TSMAQCBuilder().with_sql( + sql).should_query_with_tsma('tsma2').get_qc()) + + sql = f'''select avg(c1), avg(c2) from {db_name}.meters where tbname = 't1' and c1 is not NULL''' + ctxs.append(TSMAQCBuilder().with_sql( + sql).should_query_with_table('meters').get_qc()) + + sql = f'select avg(c1+c2) from {db_name}.meters' + ctxs.append(TSMAQCBuilder().with_sql( + sql).should_query_with_table('meters').get_qc()) + + sql = f'select avg(c1), avg(c2) from {db_name}.meters where ts >= "2018-09-17 9:25:00" and ts < "2018-09-17 10:00:00" limit 6' + ctxs.append(TSMAQCBuilder().with_sql(sql).should_query_with_tsma('tsma1', '2018-09-17 9:25:00', '2018-09-17 9:29:59.999') + .should_query_with_tsma('tsma2', '2018-09-17 9:30:00', '2018-09-17 9:59:59.999').get_qc()) + + return ctxs + + def test_query_with_tsma_agg_group_by_tbname(self, db_name: str = 'test'): + ctxs: List[TSMAQueryContext] = [] + sql = f'select avg(c1) as a, avg(c2) as b, tbname from {db_name}.meters group by tbname order by tbname, a, b' + ctxs.append(TSMAQCBuilder().with_sql( + sql).should_query_with_tsma('tsma2').get_qc()) + + sql = f'select avg(c1) as a, avg(c2) + 1 as b, tbname from {db_name}.meters where c1 > 10 group by tbname order by tbname, a, b' + ctxs.append(TSMAQCBuilder().with_sql( + sql).should_query_with_table('meters').get_qc()) + + sql = f'select avg(c1) + avg(c2) as a, avg(c2) + 1 as b, tbname from {db_name}.meters where ts between "2018-09-17 09:00:00.200" and "2018-09-17 10:23:19.800" group by tbname order by tbname, a, b' + ctxs.append(TSMAQCBuilder().with_sql(sql) + .should_query_with_table('meters', '2018-09-17 09:00:00.200', '2018-09-17 09:29:59:999') + .should_query_with_tsma('tsma2', '2018-09-17 09:30:00', '2018-09-17 09:59:59.999') + .should_query_with_table('meters', '2018-09-17 10:00:00.000', '2018-09-17 10:23:19.800').get_qc()) + + sql = f'select avg(c1) + avg(c2) + 3 as a, substr(tbname, 1) as c from {db_name}.meters group by substr(tbname, 1) order by c, a' + ctxs.append(TSMAQCBuilder().with_sql( + sql).should_query_with_tsma('tsma2').get_qc()) + + sql = f'select avg(c1) + avg(c2) as a, avg(c2) + 1 as b, substr(tbname, 1, 1) as c from {db_name}.meters where ts between "2018-09-17 09:00:00.200" and "2018-09-17 10:23:19.800" group by substr(tbname, 1, 1) order by c, a, b' + ctxs.append(TSMAQCBuilder().with_sql(sql) + .should_query_with_table('meters', '2018-09-17 09:00:00.200', '2018-09-17 09:29:59:999') + .should_query_with_tsma('tsma2', '2018-09-17 09:30:00', '2018-09-17 09:59:59.999') + .should_query_with_table('meters', '2018-09-17 10:00:00.000', '2018-09-17 10:23:19.800').get_qc()) + + sql = f'select avg(c1), tbname from {db_name}.meters group by tbname having avg(c1) > 0 order by tbname' + ctxs.append(TSMAQCBuilder().with_sql( + sql).should_query_with_tsma('tsma2').get_qc()) + sql = f'select avg(c1), tbname from {db_name}.meters group by tbname having avg(c1) > 0 and tbname = "t1"' + ctxs.append(TSMAQCBuilder().with_sql( + sql).should_query_with_tsma('tsma2').get_qc()) + + sql = f'select avg(c1), tbname from {db_name}.meters group by tbname having avg(c1) > 0 and tbname = "t1" order by tbname' + ctxs.append(TSMAQCBuilder().with_sql( + sql).should_query_with_tsma('tsma2').get_qc()) + + sql = f'select avg(c1) + 1, tbname from {db_name}.meters group by tbname having avg(c1) > 0 and tbname = "t1" order by tbname' + ctxs.append(TSMAQCBuilder().with_sql( + sql).should_query_with_tsma('tsma2').get_qc()) + sql = f'select avg(c1) + 1, tbname from {db_name}.meters group by tbname having avg(c1) > 0 and tbname like "t%" order by tbname' + ctxs.append(TSMAQCBuilder().with_sql( + sql).should_query_with_tsma('tsma2').get_qc()) + + return ctxs + + def test_query_with_tsma_with_having(self): + return [] + + def test_ddl(self): + self.test_create_tsma() + self.test_drop_tsma() + self.test_tb_ddl_with_created_tsma() + + + def run(self): + self.init_data() + self.test_ddl() + self.test_query_with_tsma() + # bug to fix + # self.test_flush_query() + + #cluster test + cluster_dnode_list = tdSql.get_cluseter_dnodes() + clust_dnode_nums = len(cluster_dnode_list) + if clust_dnode_nums > 1: + self.test_redistribute_vgroups() + + def test_create_tsma(self): + function_name = sys._getframe().f_code.co_name + tdLog.debug(f'-----{function_name}------') + self.test_create_tsma_on_stable() + self.test_create_tsma_on_norm_table() + self.test_create_tsma_on_child_table() + self.test_create_recursive_tsma() + self.test_create_tsma_maxlist_function() + self.test_create_diffrent_tsma_name() + self.test_create_illegal_tsma_sql() + # self.test_drop_stable() ## drop stable and recreate a stable + # self.test_drop_ctable() + self.test_drop_db() + + def wait_query(self, sql: str, expected_row_num: int, timeout_in_seconds: float): + timeout = timeout_in_seconds + tdSql.query(sql) + while timeout > 0 and tdSql.getRows() != expected_row_num: + tdLog.debug(f'start to wait query: {sql} to return {expected_row_num}, got: {tdSql.getRows()}, remain: {timeout_in_seconds - timeout}') + time.sleep(1) + timeout = timeout - 1 + tdSql.query(sql) + if timeout <= 0: + tdLog.exit(f'failed to wait query: {sql} to return {expected_row_num} rows timeout: {timeout_in_seconds}s') + else: + tdLog.debug(f'wait query succeed: {sql} to return {expected_row_num}, got: {tdSql.getRows()}') + + def test_drop_tsma(self): + function_name = sys._getframe().f_code.co_name + tdLog.debug(f'-----{function_name}------') + self.create_tsma('tsma1', 'test', 'meters', [ + 'avg(c1)', 'avg(c2)'], '5m') + self.create_recursive_tsma('tsma1', 'tsma2', 'test', '15m', 'meters') + + # drop recursive tsma first + tdSql.error('drop tsma test.tsma1', -2147482491) + tdSql.execute('drop tsma test.tsma2', queryTimes=1) + tdSql.execute('drop tsma test.tsma1', queryTimes=1) + self.wait_query('show transactions', 0, 10) + tdSql.execute('drop database test', queryTimes=1) + + self.init_data() + + def test_drop_db(self): + function_name = sys._getframe().f_code.co_name + tdLog.debug(f'-----{function_name}------') + tdSql.execute('create database nsdb precision "ns"', queryTimes=1) + tdSql.execute('use nsdb', queryTimes=1) + tdSql.execute( + 'create table nsdb.meters(ts timestamp, c1 int, c2 int) tags(t1 int, t2 int)', queryTimes=1) + # TODO insert data + self.create_tsma('tsma1', 'nsdb', 'meters', [ + 'avg(c1)', 'avg(c2)'], '5m') + self.create_recursive_tsma('tsma1', 'tsma2', 'nsdb', '10m', 'meters') + tdSql.query('select avg(c1) from nsdb.meters', queryTimes=1) + tdSql.execute('drop database nsdb') + + def test_tb_ddl_with_created_tsma(self): + function_name = sys._getframe().f_code.co_name + tdLog.debug(f'-----{function_name}------') + tdSql.execute('create database nsdb precision "ns"', queryTimes=1) + tdSql.execute('use nsdb', queryTimes=1) + tdSql.execute( + 'create table nsdb.meters(ts timestamp, c1 int, c2 int) tags(t1 int, t2 int)', queryTimes=1) + self.create_tsma('tsma1', 'nsdb', 'meters', ['avg(c1)', 'avg(c2)'], '5m') + # drop column, drop tag + tdSql.error('alter table nsdb.meters drop column c1', -2147482637) + tdSql.error('alter table nsdb.meters drop tag t1', -2147482637) + tdSql.error('alter table nsdb.meters drop tag t2', - + 2147482637) # Stream must be dropped first + tdSql.execute('drop tsma nsdb.tsma1', queryTimes=1) + + # add tag + tdSql.execute('alter table nsdb.meters add tag t3 int', queryTimes=1) + # Invalid tsma func param, only one non-tag column allowed + tdSql.error( + 'create tsma tsma1 on nsdb.meters function(avg(c1), avg(c2), avg(t3)) interval(5m)', -2147471096) + + tdSql.execute('alter table nsdb.meters drop tag t3', queryTimes=1) + self.wait_query('show transactions', 0, 10) + tdSql.execute('drop database nsdb') + + # drop norm table + self.create_tsma('tsma_norm_tb', 'test', 'norm_tb', ['avg(c1)', 'avg(c2)'], '5m') + tdSql.error('drop table test.norm_tb', -2147471088) + + # drop no tsma table + tdSql.execute('drop table test.t2, test.t1') + + # test ttl drop table + self.create_tsma('tsma1', 'test', 'meters', ['avg(c1)', 'avg(c2)'], '5m') + tdSql.execute('alter table test.t0 ttl 2', queryTimes=1) + tdSql.execute('flush database test') + self.wait_query('show test.tables like "%t0"', 0, 10) + + # test drop multi tables + tdSql.execute('drop table test.t3, test.t4') + self.wait_query('show test.tables like "%t3"', 0, 1) + self.wait_query('show test.tables like "%t4"', 0, 1) + + tdSql.query('show test.tables like "%tsma%"') + tdSql.checkRows(0) + + # test drop stream + tdSql.error('drop stream tsma1', -2147471088) ## TSMA must be dropped first + + self.wait_query('show transactions', 0, 10) + tdSql.execute('drop database test', queryTimes=1) + self.init_data() + + def test_create_tsma_on_stable(self): + function_name = sys._getframe().f_code.co_name + tdLog.debug(f'-----{function_name}------') + tdSql.execute('create database nsdb precision "ns"', queryTimes=1) + tdSql.execute('use nsdb', queryTimes=1) + tdSql.execute( + 'create table nsdb.meters(ts timestamp, c1 int, c2 int, c3 varchar(255)) tags(t1 int, t2 int)', queryTimes=1) + self.create_tsma('tsma1', 'nsdb', 'meters', ['avg(c1)', 'avg(c2)'], '5m') + # Invalid tsma interval, 1ms ~ 1h is allowed + tdSql.error( + 'create tsma tsma2 on nsdb.meters function(avg(c1), avg(c2)) interval(2h)', -2147471097) + tdSql.error( + 'create tsma tsma2 on nsdb.meters function(avg(c1), avg(c2)) interval(3601s)', -2147471097) + tdSql.error( + 'create tsma tsma2 on nsdb.meters function(avg(c1), avg(c2)) interval(3600001a)', -2147471097) + tdSql.error( + 'create tsma tsma2 on nsdb.meters function(avg(c1), avg(c2)) interval(3600001000u)', -2147471097) + tdSql.error( + 'create tsma tsma2 on nsdb.meters function(avg(c1), avg(c2)) interval(999999b)', -2147471097) + tdSql.error( + 'create tsma tsma2 on nsdb.meters function(avg(c1), avg(c2)) interval(999u)', -2147471097) + # invalid tsma func param + tdSql.error( + 'create tsma tsma2 on nsdb.meters function(avg(c1, c2), avg(c2)) interval(10m)', -2147471096) + # invalid param data type + tdSql.error( + 'create tsma tsma2 on nsdb.meters function(avg(ts), avg(c2)) interval(10m)', -2147473406) + tdSql.error( + 'create tsma tsma2 on nsdb.meters function(avg(c3), avg(c2)) interval(10m)', -2147473406) + # invalid tsma func param + tdSql.error( + 'create tsma tsma2 on nsdb.meters function(avg(c1+1), avg(c2)) interval(10m)', -2147471096) + # invalid tsma func param + tdSql.error( + 'create tsma tsma2 on nsdb.meters function(avg(c1*c2), avg(c2)) interval(10m)', -2147471096) + + # sma already exists in different db + # SMA already exists in db # Stream already exists + tdSql.error( + 'create tsma tsma1 on test.meters function(avg(c1), avg(c2)) interval(10m)', -2147482496) + + + # Invalid tsma interval, error format,including sliding and interval_offset + tdSql.error( + 'create tsma tsma_error_interval on nsdb.meters function(count(c2)) interval(10)') #syntax error + tdSql.error( + 'create tsma tsma_error_interval on nsdb.meters function(count(c2)) interval("10m")') + tdSql.error( + 'create tsma tsma_error_interval on nsdb.meters function(count(c2)) interval(10,10m)') + tdSql.error( + 'create tsma tsma_error_interval on nsdb.meters function(count(c2)) interval(10s,10m)') + tdSql.error( + 'create tsma tsma_error_interval on nsdb.meters function(count(c2)) interval(10s) sliding(1m)') + + # max tsma num 8 + self.create_tsma('tsma2', 'nsdb', 'meters', ['avg(c1)', 'avg(c2)'], '10s') + self.create_tsma('tsma_test3', 'test', 'meters', ['avg(c1)', 'avg(c2)'], '100s') + self.create_tsma('tsma4', 'nsdb', 'meters', ['avg(c1)', 'avg(c2)'], '101s') + self.create_tsma('tsma5', 'nsdb', 'meters', ['avg(c1)', 'count(ts)'], '102s') + self.create_tsma('tsma6', 'nsdb', 'meters', ['avg(c1)', 'avg(c2)'], '103s') + self.create_tsma('tsma7', 'nsdb', 'meters', ['avg(c1)', 'count(c2)'], '104s') + self.create_tsma('tsma8', 'test', 'meters', ['avg(c1)', 'sum(c2)'], '105s') + tdSql.error('create tsma tsma9 on nsdb.meters function(count(ts), count(c1), sum(c2)) interval(99s)', -2147482490) + tdSql.error('create recursive tsma tsma9 on test.tsma8 interval(210s)', -2147482490) + + # modify maxTsmaNum para + tdSql.error('alter dnode 1 "maxTsmaNum" "13";') + tdSql.error('alter dnode 1 "maxTsmaNum" "-1";') + + # tdSql.error('alter dnode 1 "maxTsmaNum" "abc";') + # tdSql.error('alter dnode 1 "maxTsmaNum" "1.2";') + + tdSql.execute("alter dnode 1 'maxTsmaNum' '0';", queryTimes=1) + tdSql.error('create tsma tsma9 on nsdb.meters function(count(ts), count(c1), sum(c2)) interval(99s)', -2147482490) + tdSql.execute("alter dnode 1 'maxTsmaNum' '12';", queryTimes=1) + tdSql.execute('create tsma tsma9 on nsdb.meters function(count(ts), count(c1), sum(c2)) interval(109s)') + tdSql.execute('create tsma tsma10 on nsdb.meters function(count(ts), count(c1), sum(c2)) interval(110s)') + tdSql.execute('create tsma tsma11 on nsdb.meters function(count(ts), count(c1), sum(c2)) interval(111s)') + tdSql.execute('create tsma tsma12 on nsdb.meters function(count(ts), count(c1), sum(c2)) interval(112s)') + tdSql.query("show nsdb.tsmas", queryTimes=1) + print(tdSql.queryResult) + tdSql.query("show test.tsmas", queryTimes=1) + print(tdSql.queryResult) + tdSql.error('create tsma tsma13 on nsdb.meters function(count(ts), count(c1), sum(c2)) interval(113s)', -2147482490) + + + # drop tsma + tdSql.execute('drop tsma nsdb.tsma1', queryTimes=1) + tdSql.execute('use test', queryTimes=1) + tdSql.execute( + 'create tsma tsma1 on nsdb.meters function(avg(c1), avg(c2)) interval(10m)', queryTimes=1) + self.wait_for_tsma_calculation( + ['avg(c1)', 'avg(c2)'], 'nsdb', 'meters', '10m', 'tsma1') + tdSql.execute('drop tsma nsdb.tsma1', queryTimes=1) + + tdSql.error( + 'create tsma tsma1 on test.meters function(avg(c1), avg(c2)) interval(2h)', -2147471097) + self.wait_query('show transactions', 0, 10) + tdSql.execute('drop database nsdb') + + def test_create_tsma_on_norm_table(self): + function_name = sys._getframe().f_code.co_name + tdLog.debug(f'-----{function_name}------') + + def test_create_tsma_on_child_table(self): + function_name = sys._getframe().f_code.co_name + tdLog.debug(f'-----{function_name}------') + # Invalid table to create tsma, only stable or normal table allowed + tdSql.error( + 'create tsma tsma1 on test.t1 function(avg(c1), avg(c2)) interval(1m)', -2147471098) + + def test_create_recursive_tsma(self): + function_name = sys._getframe().f_code.co_name + tdLog.debug(f'-----{function_name}------') + tdSql.execute('use test') + self.create_tsma('tsma1', 'test', 'meters', [ + 'avg(c1)', 'avg(c2)'], '5m') + sql = 'create recursive tsma tsma2 on test.tsma1 function(avg(c1)) interval(1m)' + tdSql.error(sql, -2147473920) # syntax error + + sql = 'create recursive tsma tsma2 on test.tsma1 interval(1m)' + tdSql.error(sql, -2147471099) # invalid tsma parameter + + sql = 'create recursive tsma tsma2 on test.tsma1 interval(7m)' + tdSql.error(sql, -2147471099) # invalid tsma parameter + + sql = 'create recursive tsma tsma2 on test.tsma1 interval(11m)' + tdSql.error(sql, -2147471099) # invalid tsma parameter + + self.create_recursive_tsma('tsma1', 'tsma2', 'test', '20m', 'meters') + + sql = 'create recursive tsma tsma3 on test.tsma2 interval(30m)' + tdSql.error(sql, -2147471099) # invalid tsma parameter + + self.create_recursive_tsma('tsma2', 'tsma3', 'test', '40m', 'meters') + + tdSql.execute('drop tsma test.tsma3', queryTimes=1) + tdSql.execute('drop tsma test.tsma2', queryTimes=1) + tdSql.execute('drop tsma test.tsma1', queryTimes=1) + + def test_create_tsma_maxlist_function(self): + function_name = sys._getframe().f_code.co_name + tdLog.debug(f'-----{function_name}------') + json_file = "2-query/compa4096_tsma.json" + tdCom.update_json_file_replica(json_file, self.replicaVar) + os.system(f"taosBenchmark -f {json_file} -y ") + # max number of list is 4093: 4096 - 3 - 2(原始表tag个数) - 1(tbname) + tdSql.execute('use db4096') + + self.create_tsma('tsma_4050', 'db4096', 'stb0', self.generate_tsma_function_list_columns(4050), '5m',check_tsma_calculation=False) + + self.create_tsma('tsma_4090', 'db4096', 'stb0', self.generate_tsma_function_list_columns(4090), '6m',check_tsma_calculation=False) + + self.create_error_tsma('tsma_4091', 'db4096', 'stb0', self.generate_tsma_function_list_columns(4091), '5m', -2147473856) #Too many columns + + self.drop_tsma('tsma_4050', 'db4096') + self.drop_tsma('tsma_4090', 'db4096') + + def generate_tsma_function_list_columns(self,max_column: int =4093): + columns = [] + self.tsma_support_func = ["max", "min", "count", "sum"] + num_items = len(self.tsma_support_func) + for i in range(max_column): + random_index = secrets.randbelow(num_items) + tsma_column_element = self.tsma_support_func[random_index] + '(c' + str(i) + ')' + columns.append(tsma_column_element) + return columns + + def test_create_diffrent_tsma_name(self): + function_name = sys._getframe().f_code.co_name + tdLog.debug(f'-----{function_name}------') + tdSql.execute('use test') + + self.create_tsma('tsma_repeat', 'test', 'meters', ['avg(c1)', 'avg(c2)'], '5m') + tdSql.error('create tsma tsma_repeat on test.meters function(avg(c1), avg(c2)) interval(10m)', -2147482496) # DB error: SMA already exists in db + + # same name with dbname, stable and child table + self.test_create_and_drop_tsma('meters', 'test', 'meters', ['count(c1)', 'avg(c2)'], '5m') + self.test_create_and_drop_tsma('t1', 'test', 'meters', ['count(c1)', 'avg(c2)'], '5m') + self.test_create_and_drop_tsma('test', 'test', 'meters', ['count(c1)', 'avg(c2)'], '5m') + + # tsma name is key word + tdSql.error("CREATE TSMA tsma ON test.meters FUNCTION(avg(c1)) INTERVAL(5m); ", -2147473920) # syntax error near + tdSql.error("CREATE TSMA bool ON test.meters FUNCTION(avg(c1)) INTERVAL(5m); ", -2147473920) + + # tsma name is illegal + tdSql.error("CREATE TSMA 129_tsma ON test.meters FUNCTION(count(c1)) INTERVAL(5m); ", -2147473920) + tdSql.error("CREATE TSMA T*\-sma129_ ON test.meters FUNCTION(count(c1)) INTERVAL(5m); ", -2147473920) + tdSql.error("CREATE TSMA Tsma_repeat ON test.meters FUNCTION(count(c1)) INTERVAL(5m); ", -2147482496) + + # tsma name include escape character + + tdSql.execute("CREATE TSMA `129_tsma` ON test.meters FUNCTION(count(c3)) INTERVAL(5m); ") + tdSql.execute("CREATE TSMA `129_Tsma` ON test.meters FUNCTION(count(c3)) INTERVAL(5m); ") + tdSql.execute("CREATE TSMA `129_T*\-sma` ON test.meters FUNCTION(count(c3)) INTERVAL(5m); ") + tdSql.execute("drop tsma test.`129_tsma`") + tdSql.execute("drop tsma test.`129_Tsma`") + tdSql.execute("drop tsma test.`129_T*\-sma`") + + self.drop_tsma('tsma_repeat', 'test') + + + def test_create_and_drop_tsma(self, tsma_name: str, db_name: str = 'test', table_name: str = 'meters', func_list: List = ['avg(c1)', 'avg(c2)'], interval: str = '5m'): + function_name = sys._getframe().f_code.co_name + tdLog.debug(f'-----{function_name}------') + tdSql.execute('use test') + self.create_tsma(tsma_name, db_name, table_name , func_list, interval) + self.drop_tsma(tsma_name, db_name) + + def test_create_illegal_tsma_sql(self): + function_name = sys._getframe().f_code.co_name + tdLog.debug(f'-----{function_name}------') + tdSql.execute('use test') + + # DB error: Table does not exist + tdSql.error('create tsma tsma_illegal on test.meterss function(count(c5), avg(c2)) interval(5m)',-2147473917) + + # syntax error near + tdSql.error('create tsma tsma_illegal on test.meters function() interval(5m)',-2147473920) + tdSql.error('create tsma tsma_illegal on test.meters function("count(c5)") interval(5m)',-2147473920) + tdSql.error('create tsma tsma_illegal on test.meters function(count(c5)+1) interval(5m)',-2147473920) + tdSql.error('create tsma tsma_illegal on test.meters function(avg(c1)+avg(c2)) interval(5m)',-2147473920) + + # Invalid tsma func param, only one column allowed + tdSql.error('create tsma tsma_illegal on test.meters function(count(1)) interval(5m)',-2147471096) + tdSql.error('create tsma tsma_illegal on test.meters function(count(c1,c2)) interval(5m)',-2147471096) + tdSql.error('create tsma tsma_illegal on test.meters function(count(_wstart)) interval(5m)',-2147471096) + tdSql.error('create tsma tsma_illegal on test.meters function(count(_wend)) interval(5m)',-2147471096) + tdSql.error('create tsma tsma_illegal on test.meters function(count(_wduration)) interval(5m)',-2147471096) + + # Tsma func not supported + # TODO add all of funcs not supported + tdSql.error('create tsma tsma_illegal on test.meters function(abs(c1)) interval(5m)',-2147471095) + tdSql.error('create tsma tsma_illegal on test.meters function(last_row(c1)) interval(5m)',-2147471095) + + # mixed tsma func not supported + tdSql.error('create tsma tsma_illegal on test.meters function(last(c1),last_row(c1)) interval(5m)',-2147471095) + + # Invalid function para type + tdSql.error('create tsma tsma_illegal on test.meters function(avg(c8)) interval(5m)',-2147473406) + + def test_flush_query(self): + tdSql.execute('insert into test.norm_tb (ts,c1_new,c2) values (now,1,2)(now+1s,2,3)(now+2s,2,3)(now+3s,2,3) (now+4s,1,2)(now+5s,2,3)(now+6s,2,3)(now+7s,2,3); select /*+ skip_tsma()*/ avg(c1_new),avg(c2) from test.norm_tb interval(10m);select avg(c1_new),avg(c2) from test.norm_tb interval(10m);select * from information_schema.ins_stream_tasks;', queryTimes=1) + tdSql.execute('flush database test', queryTimes=1) + tdSql.query('select count(*) from test.meters', queryTimes=1) + tdSql.checkData(0,0,100000) + tdSql.query('select count(*) from test.norm_tb', queryTimes=1) + tdSql.checkData(0,0,10008) + tdSql.execute('flush database test', queryTimes=1) + tdSql.query('select count(*) from test.meters', queryTimes=1) + tdSql.checkData(0,0,100000) + tdSql.query('select count(*) from test.norm_tb', queryTimes=1) + tdSql.checkData(0,0,10008) + + def test_redistribute_vgroups(self): + tdSql.redistribute_db_all_vgroups('test', self.replicaVar) + tdSql.redistribute_db_all_vgroups('db4096', self.replicaVar) + + # def test_replica_dnode(self): + + # def test_split_dnode(self): + + + def stop(self): + tdSql.close() + tdLog.success(f"{__file__} successfully executed") + + +event = threading.Event() + +tdCases.addLinux(__file__, TDTestCase()) +tdCases.addWindows(__file__, TDTestCase())