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 0e1525f252..0968c59399 100644 --- a/include/common/tcommon.h +++ b/include/common/tcommon.h @@ -412,6 +412,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 927f1c0c89..f7db44fea1 100644 --- a/include/common/tmsg.h +++ b/include/common/tmsg.h @@ -111,6 +111,7 @@ enum { HEARTBEAT_KEY_TMQ, HEARTBEAT_KEY_DYN_VIEW, HEARTBEAT_KEY_VIEWINFO, + HEARTBEAT_KEY_TSMA, }; typedef enum _mgmt_table { @@ -146,6 +147,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, @@ -250,6 +252,7 @@ typedef enum ENodeType { QUERY_NODE_WINDOW_OFFSET, QUERY_NODE_COUNT_WINDOW, QUERY_NODE_COLUMN_OPTIONS, + QUERY_NODE_TSMA_OPTIONS, // Statement nodes are used in parser and planner module. QUERY_NODE_SET_OPERATOR = 100, @@ -371,6 +374,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, @@ -443,9 +450,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 { @@ -1475,8 +1482,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 { @@ -2675,6 +2688,7 @@ typedef struct { SArray* pVgroupVerList; // 3.3.0.0 SArray* pCols; // array of SField + int64_t smaId; } SCMCreateStreamReq; typedef struct { @@ -3642,6 +3656,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); @@ -4265,6 +4283,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); void setDefaultOptionsForField(SFieldWithOptions* field); void setFieldWithOptions(SFieldWithOptions* fieldWithOptions, SField* field); 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 ed02e1ed5d..23c0358a6e 100644 --- a/include/common/ttokendef.h +++ b/include/common/ttokendef.h @@ -204,187 +204,190 @@ #define TK_QTAGS 186 #define TK_AS 187 #define TK_SYSTEM 188 -#define TK_INDEX 189 -#define TK_FUNCTION 190 -#define TK_INTERVAL 191 -#define TK_COUNT 192 -#define TK_LAST_ROW 193 -#define TK_META 194 -#define TK_ONLY 195 -#define TK_TOPIC 196 -#define TK_CONSUMER 197 -#define TK_GROUP 198 -#define TK_DESC 199 -#define TK_DESCRIBE 200 -#define TK_RESET 201 -#define TK_QUERY 202 -#define TK_CACHE 203 -#define TK_EXPLAIN 204 -#define TK_ANALYZE 205 -#define TK_VERBOSE 206 -#define TK_NK_BOOL 207 -#define TK_RATIO 208 -#define TK_NK_FLOAT 209 -#define TK_OUTPUTTYPE 210 -#define TK_AGGREGATE 211 -#define TK_BUFSIZE 212 -#define TK_LANGUAGE 213 -#define TK_REPLACE 214 -#define TK_STREAM 215 -#define TK_INTO 216 -#define TK_PAUSE 217 -#define TK_RESUME 218 -#define TK_PRIMARY 219 -#define TK_KEY 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_ENCODE 367 -#define TK_COMPRESS 368 -#define TK_LEVEL 369 +#define TK_TSMA 189 +#define TK_INTERVAL 190 +#define TK_RECURSIVE 191 +#define TK_TSMAS 192 +#define TK_FUNCTION 193 +#define TK_INDEX 194 +#define TK_COUNT 195 +#define TK_LAST_ROW 196 +#define TK_META 197 +#define TK_ONLY 198 +#define TK_TOPIC 199 +#define TK_CONSUMER 200 +#define TK_GROUP 201 +#define TK_DESC 202 +#define TK_DESCRIBE 203 +#define TK_RESET 204 +#define TK_QUERY 205 +#define TK_CACHE 206 +#define TK_EXPLAIN 207 +#define TK_ANALYZE 208 +#define TK_VERBOSE 209 +#define TK_NK_BOOL 210 +#define TK_RATIO 211 +#define TK_NK_FLOAT 212 +#define TK_OUTPUTTYPE 213 +#define TK_AGGREGATE 214 +#define TK_BUFSIZE 215 +#define TK_LANGUAGE 216 +#define TK_REPLACE 217 +#define TK_STREAM 218 +#define TK_INTO 219 +#define TK_PAUSE 220 +#define TK_RESUME 221 +#define TK_PRIMARY 222 +#define TK_KEY 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_ENCODE 370 +#define TK_COMPRESS 371 +#define TK_LEVEL 372 #define TK_NK_SPACE 600 #define TK_NK_COMMENT 601 @@ -399,6 +402,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 bc9cece2ce..5cb1b45b39 100644 --- a/include/libs/nodes/cmdnodes.h +++ b/include/libs/nodes/cmdnodes.h @@ -222,11 +222,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 { @@ -600,6 +602,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 c9dda8165e..32f7cef12c 100644 --- a/include/libs/qcom/query.h +++ b/include/libs/qcom/query.h @@ -332,7 +332,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/libs/stream/tstream.h b/include/libs/stream/tstream.h index 8bced20ca3..5e647c0f9e 100644 --- a/include/libs/stream/tstream.h +++ b/include/libs/stream/tstream.h @@ -247,11 +247,11 @@ typedef enum { TASK_SCANHISTORY_CONT = 0x1, TASK_SCANHISTORY_QUIT = 0x2, TASK_SCANHISTORY_REXEC = 0x3, -} EScanHistoryRet; +} EScanHistoryCode; typedef struct { - EScanHistoryRet ret; - int32_t idleTime; + EScanHistoryCode ret; + int32_t idleTime; } SScanhistoryDataInfo; typedef struct { @@ -811,7 +811,7 @@ int32_t streamSendCheckRsp(const SStreamMeta* pMeta, const SStreamTaskCheckReq* int32_t streamProcessCheckRsp(SStreamTask* pTask, const SStreamTaskCheckRsp* pRsp); int32_t streamLaunchFillHistoryTask(SStreamTask* pTask); int32_t streamStartScanHistoryAsync(SStreamTask* pTask, int8_t igUntreated); -int32_t streamReExecScanHistoryFuture(SStreamTask* pTask, int32_t idleDuration); +int32_t streamExecScanHistoryInFuture(SStreamTask* pTask, int32_t idleDuration); bool streamHistoryTaskSetVerRangeStep2(SStreamTask* pTask, int64_t latestVer); int32_t streamQueueGetNumOfItems(const SStreamQueue* pQueue); diff --git a/include/util/taoserror.h b/include/util/taoserror.h index 7a416d960d..c13c8586f5 100644 --- a/include/util/taoserror.h +++ b/include/util/taoserror.h @@ -426,6 +426,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 @@ -827,6 +829,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 1d7954ec71..f3a85fed35 100644 --- a/source/common/src/tmsg.c +++ b/source/common/src/tmsg.c @@ -68,6 +68,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) { @@ -890,6 +892,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; @@ -940,6 +952,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; @@ -950,6 +985,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) { @@ -3656,6 +3692,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; } @@ -3736,6 +3780,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; } @@ -3785,6 +3840,10 @@ void tFreeSDbHbRsp(SDbHbRsp *pDbRsp) { tFreeSDbCfgRsp(pDbRsp->cfgRsp); taosMemoryFree(pDbRsp->cfgRsp); } + if (pDbRsp->pTsmaRsp) { + tFreeTableTSMAInfoRsp(pDbRsp->pTsmaRsp); + taosMemoryFree(pDbRsp->pTsmaRsp); + } } void tFreeSDbHbBatchRsp(SDbHbBatchRsp *pRsp) { @@ -7807,6 +7866,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; @@ -7933,6 +7993,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); @@ -8376,8 +8439,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; @@ -10050,4 +10113,443 @@ void setFieldWithOptions(SFieldWithOptions *fieldWithOptions, SField *field) { fieldWithOptions->flags = field->flags; fieldWithOptions->type = field->type; strncpy(fieldWithOptions->name, field->name, TSDB_COL_NAME_LEN); -} \ No newline at end of file +} +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 fa6cf0dbaf..ab2a63c59c 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 85b854dbe0..e7276c3e57 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); @@ -997,7 +1006,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) { @@ -2690,11 +2699,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); @@ -3385,6 +3389,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}; @@ -3851,3 +3860,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 ad4ed40dac..0624f4e71e 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)); @@ -819,23 +833,57 @@ _OVER: return terrno; } -int64_t mndStreamGenChkpId(SMnode *pMnode) { +int64_t mndStreamGenChkptId(SMnode *pMnode, bool lock) { SStreamObj *pStream = NULL; void *pIter = NULL; SSdb *pSdb = pMnode->pSdb; - int64_t maxChkpId = 0; + int64_t maxChkptId = 0; while (1) { pIter = sdbFetch(pSdb, SDB_STREAM, pIter, (void **)&pStream); if (pIter == NULL) break; - maxChkpId = TMAX(maxChkpId, pStream->checkpointId); + maxChkptId = TMAX(maxChkptId, pStream->checkpointId); mDebug("stream:%p, %s id:%" PRIx64 "checkpoint %" PRId64 "", pStream, pStream->name, pStream->uid, pStream->checkpointId); sdbRelease(pSdb, pStream); } - mDebug("generated checkpoint %" PRId64 "", maxChkpId + 1); - return maxChkpId + 1; + { // check the max checkpoint id from all vnodes. + int64_t maxCheckpointId = -1; + if (lock) { + taosThreadMutexLock(&execInfo.lock); + } + + for (int32_t i = 0; i < taosArrayGetSize(execInfo.pTaskList); ++i) { + STaskId *p = taosArrayGet(execInfo.pTaskList, i); + + STaskStatusEntry *pEntry = taosHashGet(execInfo.pTaskMap, p, sizeof(*p)); + if (pEntry == NULL) { + continue; + } + + if (pEntry->checkpointInfo.failed) { + continue; + } + + if (maxCheckpointId < pEntry->checkpointInfo.latestId) { + maxCheckpointId = pEntry->checkpointInfo.latestId; + } + } + + if (lock) { + taosThreadMutexUnlock(&execInfo.lock); + } + + if (maxCheckpointId > maxChkptId) { + mDebug("max checkpointId in mnode:%" PRId64 ", smaller than max checkpointId in vnode:%" PRId64, maxChkptId, + maxCheckpointId); + maxChkptId = maxCheckpointId; + } + } + + mDebug("generated checkpoint %" PRId64 "", maxChkptId + 1); + return maxChkptId + 1; } static int32_t mndProcessStreamCheckpointTmr(SRpcMsg *pReq) { @@ -846,7 +894,7 @@ static int32_t mndProcessStreamCheckpointTmr(SRpcMsg *pReq) { } SMStreamDoCheckpointMsg *pMsg = rpcMallocCont(sizeof(SMStreamDoCheckpointMsg)); - pMsg->checkpointId = mndStreamGenChkpId(pMnode); + pMsg->checkpointId = mndStreamGenChkptId(pMnode, true); int32_t size = sizeof(SMStreamDoCheckpointMsg); SRpcMsg rpcMsg = {.msgType = TDMT_MND_STREAM_BEGIN_CHECKPOINT, .pCont = pMsg, .contLen = size}; @@ -1182,6 +1230,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); @@ -2308,7 +2374,7 @@ int32_t mndProcessStreamReqCheckpoint(SRpcMsg *pReq) { int32_t total = taosArrayGetSize(*pReqTaskList); if (total == numOfTasks) { // all tasks has send the reqs - int64_t checkpointId = mndStreamGenChkpId(pMnode); + int64_t checkpointId = mndStreamGenChkptId(pMnode, false); mInfo("stream:0x%" PRIx64 " all tasks req checkpoint, start checkpointId:%" PRId64, req.streamId, checkpointId); if (pStream != NULL) { // TODO:handle error @@ -2345,3 +2411,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 ca8e1dc4ac..419ebd1a6c 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 30ca4c7a36..00ca0319d0 100644 --- a/source/dnode/vnode/src/tq/tq.c +++ b/source/dnode/vnode/src/tq/tq.c @@ -936,7 +936,7 @@ int32_t tqProcessTaskScanHistory(STQ* pTq, SRpcMsg* pMsg) { atomic_store_32(&pTask->status.inScanHistorySentinel, 0); if (retInfo.ret == TASK_SCANHISTORY_REXEC) { - streamReExecScanHistoryFuture(pTask, retInfo.idleTime); + streamExecScanHistoryInFuture(pTask, retInfo.idleTime); } else { SStreamTaskState* p = streamTaskGetStatus(pTask); ETaskStatus s = p->state; @@ -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 939a24a694..19be7e7ebd 100644 --- a/source/dnode/vnode/src/vnd/vnodeQuery.c +++ b/source/dnode/vnode/src/vnd/vnodeQuery.c @@ -360,6 +360,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; @@ -748,3 +751,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 af0c69b90f..d1f12fc0c0 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 f794fb7348..1c775fcce7 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); @@ -1391,6 +1405,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)) { @@ -1404,7 +1425,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); @@ -1434,6 +1455,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); @@ -1790,7 +1812,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)); @@ -1834,6 +1856,7 @@ int32_t ctgOpUpdateVgroup(SCtgCacheOperation *operation) { if (dbCache->cfgCache.cfgInfo) { dbCacheInfo.cfgVersion = dbCache->cfgCache.cfgInfo->cfgVersion; + dbCacheInfo.tsmaVersion = dbCache->tsmaVersion; } vgCache->vgInfo = dbInfo; @@ -1901,6 +1924,7 @@ int32_t ctgOpUpdateDbCfg(SCtgCacheOperation *operation) { } else { cacheInfo.vgVersion = -1; } + cacheInfo.tsmaVersion = dbCache->tsmaVersion; ctgWLockDbCfgInfo(dbCache); @@ -2083,7 +2107,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))) { @@ -2135,7 +2160,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))) { @@ -2563,6 +2589,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; @@ -2591,6 +2618,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; @@ -2991,20 +3026,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); @@ -3145,5 +3181,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 af30fbce82..77725c1dda 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) { @@ -1682,6 +1784,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; @@ -2015,6 +2121,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); } @@ -2312,5 +2420,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/projectoperator.c b/source/libs/executor/src/projectoperator.c index 7984da9b30..19828d5146 100644 --- a/source/libs/executor/src/projectoperator.c +++ b/source/libs/executor/src/projectoperator.c @@ -231,7 +231,7 @@ static int32_t doIngroupLimitOffset(SLimitInfo* pLimitInfo, uint64_t groupId, SS // set current group id pLimitInfo->currentGroupId = groupId; bool limitReached = applyLimitOffset(pLimitInfo, pBlock, pOperator->pTaskInfo); - if (pBlock->info.rows == 0) { + if (pBlock->info.rows == 0 && 0 != pLimitInfo->limit.limit) { return PROJECT_RETRIEVE_CONTINUE; } else { if (limitReached && (pLimitInfo->slimit.limit >= 0 && pLimitInfo->slimit.limit <= pLimitInfo->numOfOutputGroups)) { 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 8a2ae1bd66..de84246727 100644 --- a/source/libs/nodes/src/nodesCloneFuncs.c +++ b/source/libs/nodes/src/nodesCloneFuncs.c @@ -223,6 +223,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; } @@ -482,6 +484,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; } @@ -571,6 +574,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 56e053c94c..ec9a291f8c 100644 --- a/source/libs/nodes/src/nodesCodeFuncs.c +++ b/source/libs/nodes/src/nodesCodeFuncs.c @@ -2470,6 +2470,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; @@ -2490,6 +2491,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; } @@ -2513,6 +2517,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; } @@ -4240,6 +4247,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; @@ -4266,6 +4275,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; } @@ -4294,6 +4310,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; } @@ -7327,6 +7350,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 a781d00da7..746cdbd016 100644 --- a/source/libs/nodes/src/nodesUtilFuncs.c +++ b/source/libs/nodes/src/nodesUtilFuncs.c @@ -521,6 +521,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)); @@ -563,6 +564,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: @@ -812,6 +819,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: @@ -920,6 +929,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; @@ -1194,7 +1209,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); @@ -1281,6 +1297,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); @@ -1295,6 +1320,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: { @@ -1750,6 +1777,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) { @@ -1766,6 +1803,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; } @@ -2620,3 +2658,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 ede2d7d2a4..300329c639 100644 --- a/source/libs/parser/inc/parAst.h +++ b/source/libs/parser/inc/parAst.h @@ -286,6 +286,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 048554d968..ac14fcefdf --- a/source/libs/parser/inc/sql.y +++ b/source/libs/parser/inc/sql.y @@ -586,6 +586,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); } @@ -1060,6 +1077,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 32526fe0a0..75e48e5b4e 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) { @@ -1943,7 +1962,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) { @@ -2889,3 +2908,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 ae52c288d6..599f93602a 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 83febdaee7..d111a475e8 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); @@ -704,6 +708,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; @@ -3604,13 +3644,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) { @@ -4220,6 +4339,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; @@ -4945,7 +5067,7 @@ static int32_t checkIntervalWindow(STranslateContext* pCxt, SIntervalWindowNode* return generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_INTER_SLIDING_UNIT); } if ((pSliding->datum.i < - convertTimeFromPrecisionToUnit(tsMinSlidingTime, TSDB_TIME_PRECISION_MILLI, pSliding->unit)) || + 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); } @@ -5523,20 +5645,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; @@ -5566,16 +5687,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; @@ -7495,6 +7654,8 @@ typedef struct SSampleAstInfo { SNodeList* pPartitionByList; STableMeta* pRollupTableMeta; bool createSmaIndex; + SNodeList* pTags; + SNode* pSubTable; } SSampleAstInfo; static int32_t buildTableForSampleAst(SSampleAstInfo* pInfo, SNode** pOutput) { @@ -7516,6 +7677,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); } @@ -7525,6 +7687,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); } @@ -7534,10 +7697,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; @@ -7551,7 +7715,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); @@ -7579,7 +7747,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; @@ -7588,9 +7756,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); } @@ -7613,6 +7783,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) { @@ -7736,7 +7908,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; @@ -7843,6 +8015,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); } @@ -8285,7 +8458,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; @@ -8343,7 +8516,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); } @@ -9650,14 +9823,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); @@ -9842,7 +10015,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}; @@ -10444,6 +10618,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)) { @@ -10626,7 +11234,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; } @@ -11798,34 +12413,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; } @@ -11834,14 +12445,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: @@ -11908,6 +12520,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) { @@ -11915,24 +12530,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) { @@ -11944,6 +12599,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", @@ -11960,11 +12625,9 @@ 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]; + STag* pTag = NULL; + SToken token; + char tokenBuf[TSDB_MAX_TAGS_LEN]; const char* tagStr = pStmt->pVal->literal; NEXT_TOKEN_WITH_PREV(tagStr, token); if (TSDB_CODE_SUCCESS == code) { @@ -12104,6 +12767,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); @@ -12443,6 +13117,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 55285b6ab9..d76af7c3b4 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 @@ -211,6 +213,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"; } @@ -737,6 +741,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); @@ -809,6 +819,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) { @@ -877,6 +888,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); @@ -1144,6 +1161,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); @@ -1158,6 +1183,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)); @@ -1237,10 +1287,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); @@ -1249,6 +1301,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 4dd394e544..a417201fa4 100644 --- a/source/libs/parser/src/sql.c +++ b/source/libs/parser/src/sql.c @@ -235,187 +235,190 @@ #define TK_QTAGS 186 #define TK_AS 187 #define TK_SYSTEM 188 -#define TK_INDEX 189 -#define TK_FUNCTION 190 -#define TK_INTERVAL 191 -#define TK_COUNT 192 -#define TK_LAST_ROW 193 -#define TK_META 194 -#define TK_ONLY 195 -#define TK_TOPIC 196 -#define TK_CONSUMER 197 -#define TK_GROUP 198 -#define TK_DESC 199 -#define TK_DESCRIBE 200 -#define TK_RESET 201 -#define TK_QUERY 202 -#define TK_CACHE 203 -#define TK_EXPLAIN 204 -#define TK_ANALYZE 205 -#define TK_VERBOSE 206 -#define TK_NK_BOOL 207 -#define TK_RATIO 208 -#define TK_NK_FLOAT 209 -#define TK_OUTPUTTYPE 210 -#define TK_AGGREGATE 211 -#define TK_BUFSIZE 212 -#define TK_LANGUAGE 213 -#define TK_REPLACE 214 -#define TK_STREAM 215 -#define TK_INTO 216 -#define TK_PAUSE 217 -#define TK_RESUME 218 -#define TK_PRIMARY 219 -#define TK_KEY 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_ENCODE 367 -#define TK_COMPRESS 368 -#define TK_LEVEL 369 +#define TK_TSMA 189 +#define TK_INTERVAL 190 +#define TK_RECURSIVE 191 +#define TK_TSMAS 192 +#define TK_FUNCTION 193 +#define TK_INDEX 194 +#define TK_COUNT 195 +#define TK_LAST_ROW 196 +#define TK_META 197 +#define TK_ONLY 198 +#define TK_TOPIC 199 +#define TK_CONSUMER 200 +#define TK_GROUP 201 +#define TK_DESC 202 +#define TK_DESCRIBE 203 +#define TK_RESET 204 +#define TK_QUERY 205 +#define TK_CACHE 206 +#define TK_EXPLAIN 207 +#define TK_ANALYZE 208 +#define TK_VERBOSE 209 +#define TK_NK_BOOL 210 +#define TK_RATIO 211 +#define TK_NK_FLOAT 212 +#define TK_OUTPUTTYPE 213 +#define TK_AGGREGATE 214 +#define TK_BUFSIZE 215 +#define TK_LANGUAGE 216 +#define TK_REPLACE 217 +#define TK_STREAM 218 +#define TK_INTO 219 +#define TK_PAUSE 220 +#define TK_RESUME 221 +#define TK_PRIMARY 222 +#define TK_KEY 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_ENCODE 370 +#define TK_COMPRESS 371 +#define TK_LEVEL 372 #endif /**************** End token definitions ***************************************/ @@ -475,30 +478,30 @@ #endif /************* Begin control #defines *****************************************/ #define YYCODETYPE unsigned short int -#define YYNOCODE 545 +#define YYNOCODE 551 #define YYACTIONTYPE unsigned short int #define ParseTOKENTYPE SToken typedef union { int yyinit; ParseTOKENTYPE yy0; - EShowKind yy89; - EJoinType yy92; - EFillMode yy94; - SDataType yy154; - int8_t yy173; - EJoinSubType yy534; - SToken yy659; - SNodeList* yy694; - ENullOrder yy707; - EOrder yy708; - SNode* yy722; - int64_t yy729; - SShowTablesOption yy817; - int32_t yy830; - SAlterOption yy845; - bool yy897; - STokenPair yy967; - EOperatorType yy1070; + EOperatorType yy22; + EJoinSubType yy26; + ENullOrder yy71; + STokenPair yy73; + EOrder yy88; + SDataType yy146; + SAlterOption yy177; + EJoinType yy190; + SShowTablesOption yy347; + int32_t yy462; + SToken yy585; + SNodeList* yy616; + SNode* yy826; + EShowKind yy857; + int64_t yy891; + bool yy983; + int8_t yy999; + EFillMode yy1082; } YYMINORTYPE; #ifndef YYSTACKDEPTH #define YYSTACKDEPTH 100 @@ -514,18 +517,18 @@ typedef union { #define ParseCTX_FETCH #define ParseCTX_STORE #define YYFALLBACK 1 -#define YYNSTATE 926 -#define YYNRULE 735 -#define YYNRULE_WITH_ACTION 735 -#define YYNTOKEN 370 -#define YY_MAX_SHIFT 925 -#define YY_MIN_SHIFTREDUCE 1388 -#define YY_MAX_SHIFTREDUCE 2122 -#define YY_ERROR_ACTION 2123 -#define YY_ACCEPT_ACTION 2124 -#define YY_NO_ACTION 2125 -#define YY_MIN_REDUCE 2126 -#define YY_MAX_REDUCE 2860 +#define YYNSTATE 956 +#define YYNRULE 743 +#define YYNRULE_WITH_ACTION 743 +#define YYNTOKEN 373 +#define YY_MAX_SHIFT 955 +#define YY_MIN_SHIFTREDUCE 1422 +#define YY_MAX_SHIFTREDUCE 2164 +#define YY_ERROR_ACTION 2165 +#define YY_ACCEPT_ACTION 2166 +#define YY_NO_ACTION 2167 +#define YY_MIN_REDUCE 2168 +#define YY_MAX_REDUCE 2910 /************* End control #defines *******************************************/ #define YY_NLOOKAHEAD ((int)(sizeof(yy_lookahead)/sizeof(yy_lookahead[0]))) @@ -592,879 +595,891 @@ typedef union { ** yy_default[] Default action for each state. ** *********** Begin parsing tables **********************************************/ -#define YY_ACTTAB_COUNT (2980) +#define YY_ACTTAB_COUNT (2999) static const YYACTIONTYPE yy_action[] = { - /* 0 */ 766, 96, 880, 821, 2325, 2285, 2471, 2831, 2826, 2831, - /* 10 */ 526, 2314, 47, 45, 2039, 2826, 2636, 2826, 425, 362, - /* 20 */ 453, 456, 1861, 142, 2468, 808, 765, 212, 2320, 781, - /* 30 */ 664, 2827, 767, 2316, 2830, 1948, 2830, 1859, 2827, 2829, - /* 40 */ 2827, 2828, 755, 358, 821, 2325, 40, 39, 177, 2471, - /* 50 */ 46, 44, 43, 42, 41, 2043, 2260, 2654, 2126, 586, - /* 60 */ 584, 1886, 401, 2636, 142, 1943, 225, 2469, 808, 519, - /* 70 */ 2654, 669, 19, 2602, 518, 803, 801, 438, 2518, 1867, - /* 80 */ 702, 193, 141, 140, 139, 138, 137, 136, 135, 134, - /* 90 */ 133, 820, 47, 45, 459, 700, 1886, 698, 279, 278, - /* 100 */ 453, 2636, 1861, 820, 2654, 825, 503, 423, 922, 2451, - /* 110 */ 413, 15, 778, 151, 804, 1948, 2385, 1859, 2635, 231, - /* 120 */ 2602, 2674, 803, 732, 448, 115, 2637, 807, 2639, 2640, - /* 130 */ 802, 2826, 825, 770, 1454, 2383, 1453, 195, 820, 2728, - /* 140 */ 754, 716, 2654, 449, 2724, 1943, 176, 1950, 1951, 2832, - /* 150 */ 212, 147, 19, 1886, 2827, 767, 2328, 1977, 2602, 1867, - /* 160 */ 803, 323, 324, 213, 91, 2635, 322, 90, 2674, 1455, - /* 170 */ 77, 2775, 391, 2637, 807, 2639, 2640, 802, 800, 825, - /* 180 */ 786, 2693, 50, 2636, 626, 1921, 1931, 2014, 922, 457, - /* 190 */ 623, 15, 1949, 1952, 40, 39, 804, 175, 46, 44, - /* 200 */ 43, 42, 41, 2635, 37, 319, 2674, 1862, 2330, 1860, - /* 210 */ 183, 2637, 807, 2639, 2640, 802, 186, 825, 308, 29, - /* 220 */ 631, 2510, 1978, 88, 2654, 465, 1922, 1950, 1951, 50, - /* 230 */ 780, 181, 2736, 2737, 89, 149, 2741, 179, 507, 2138, - /* 240 */ 2602, 715, 803, 1865, 1866, 1918, 9, 1920, 1923, 1924, - /* 250 */ 1925, 1926, 1927, 1928, 1929, 1930, 799, 823, 822, 1942, - /* 260 */ 1944, 1945, 1946, 1947, 2, 1921, 1931, 509, 505, 768, - /* 270 */ 2847, 132, 1949, 1952, 131, 130, 129, 128, 127, 126, - /* 280 */ 125, 124, 123, 1887, 1543, 2635, 1919, 1862, 2674, 1860, - /* 290 */ 96, 118, 183, 2637, 807, 2639, 2640, 802, 2084, 825, - /* 300 */ 472, 2327, 2014, 2011, 2012, 2013, 36, 451, 1972, 1973, - /* 310 */ 1974, 1975, 1976, 1980, 1981, 1982, 1983, 2321, 1715, 1716, - /* 320 */ 778, 151, 637, 1865, 1866, 1918, 1545, 1920, 1923, 1924, - /* 330 */ 1925, 1926, 1927, 1928, 1929, 1930, 799, 823, 822, 1942, - /* 340 */ 1944, 1945, 1946, 1947, 2, 12, 47, 45, 2636, 439, - /* 350 */ 2518, 618, 2848, 2329, 453, 474, 1861, 176, 2378, 2380, - /* 360 */ 616, 804, 641, 612, 608, 1604, 472, 2327, 2014, 1948, - /* 370 */ 864, 1859, 862, 168, 167, 859, 858, 857, 165, 1595, - /* 380 */ 854, 853, 852, 1599, 851, 1601, 1602, 850, 847, 2654, - /* 390 */ 1610, 844, 1612, 1613, 841, 838, 835, 1830, 794, 1943, - /* 400 */ 46, 44, 43, 42, 41, 2602, 19, 803, 315, 793, - /* 410 */ 1735, 1736, 712, 1867, 771, 778, 151, 2748, 2011, 2012, - /* 420 */ 2013, 2748, 2748, 2748, 2748, 2748, 47, 45, 1953, 464, - /* 430 */ 463, 756, 429, 428, 453, 62, 1861, 1886, 716, 121, - /* 440 */ 2736, 2737, 922, 149, 2741, 15, 2385, 479, 478, 1948, - /* 450 */ 2635, 1859, 2596, 2674, 458, 1734, 1737, 115, 2637, 807, - /* 460 */ 2639, 2640, 802, 2831, 825, 2383, 1890, 153, 831, 161, - /* 470 */ 2699, 2728, 1868, 2379, 2380, 449, 2724, 580, 205, 1943, - /* 480 */ 1889, 1950, 1951, 2748, 2011, 2012, 2013, 2748, 2748, 2748, - /* 490 */ 2748, 2748, 621, 1867, 2372, 622, 2169, 40, 39, 2636, - /* 500 */ 2064, 46, 44, 43, 42, 41, 47, 45, 427, 426, - /* 510 */ 877, 666, 781, 459, 453, 2065, 1861, 718, 2510, 1921, - /* 520 */ 1931, 362, 922, 2127, 825, 48, 1949, 1952, 62, 1948, - /* 530 */ 51, 1859, 751, 668, 188, 2736, 777, 667, 143, 776, - /* 540 */ 2654, 1862, 236, 1860, 132, 2743, 2826, 131, 130, 129, - /* 550 */ 128, 127, 126, 125, 124, 123, 2602, 2063, 803, 1943, - /* 560 */ 152, 1950, 1951, 2699, 765, 212, 2036, 579, 235, 2827, - /* 570 */ 767, 2740, 2107, 1867, 778, 151, 879, 1865, 1866, 1918, - /* 580 */ 2519, 1920, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, - /* 590 */ 799, 823, 822, 1942, 1944, 1945, 1946, 1947, 2, 1921, - /* 600 */ 1931, 2635, 922, 468, 2674, 48, 1949, 1952, 115, 2637, - /* 610 */ 807, 2639, 2640, 802, 315, 825, 830, 829, 828, 1889, - /* 620 */ 195, 1862, 2728, 1860, 40, 39, 449, 2724, 46, 44, - /* 630 */ 43, 42, 41, 203, 2743, 2149, 1890, 757, 752, 745, - /* 640 */ 741, 1950, 1951, 3, 1871, 2124, 1886, 313, 2546, 2016, - /* 650 */ 2017, 2018, 2019, 2020, 2776, 53, 1918, 1865, 1866, 1918, - /* 660 */ 2739, 1920, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, - /* 670 */ 799, 823, 822, 1942, 1944, 1945, 1946, 1947, 2, 1921, - /* 680 */ 1931, 629, 713, 66, 622, 2169, 1949, 1952, 2114, 12, - /* 690 */ 62, 1891, 2602, 182, 2736, 2737, 1604, 149, 2741, 492, - /* 700 */ 1887, 1862, 247, 1860, 672, 731, 624, 315, 2177, 315, - /* 710 */ 1595, 854, 853, 852, 1599, 851, 1601, 1602, 798, 797, - /* 720 */ 2636, 1610, 796, 1612, 1613, 795, 838, 835, 1537, 485, - /* 730 */ 43, 42, 41, 804, 484, 2179, 2743, 1865, 1866, 1918, - /* 740 */ 2543, 1920, 1923, 1924, 1925, 1926, 1927, 1928, 1929, 1930, - /* 750 */ 799, 823, 822, 1942, 1944, 1945, 1946, 1947, 2, 47, - /* 760 */ 45, 2654, 2738, 1890, 399, 1437, 1884, 453, 249, 1861, - /* 770 */ 2215, 1885, 624, 569, 2177, 1829, 589, 2602, 2148, 803, - /* 780 */ 2524, 588, 1948, 732, 1859, 517, 313, 516, 40, 39, - /* 790 */ 62, 2826, 46, 44, 43, 42, 41, 549, 2595, 590, - /* 800 */ 12, 470, 10, 208, 400, 551, 2113, 467, 466, 2832, - /* 810 */ 212, 1922, 1943, 1435, 2827, 767, 529, 856, 1958, 515, - /* 820 */ 2376, 2072, 2635, 113, 1886, 2674, 1867, 1643, 1644, 115, - /* 830 */ 2637, 807, 2639, 2640, 802, 2602, 825, 1433, 1434, 284, - /* 840 */ 154, 2846, 60, 2728, 684, 683, 682, 449, 2724, 2317, - /* 850 */ 729, 674, 148, 678, 2035, 922, 424, 677, 15, 459, - /* 860 */ 2612, 1891, 676, 681, 432, 431, 1890, 537, 675, 315, - /* 870 */ 825, 1919, 430, 671, 670, 668, 821, 2325, 1861, 667, - /* 880 */ 748, 747, 2070, 2071, 2073, 2074, 2075, 2300, 2616, 2420, - /* 890 */ 821, 2325, 2083, 1859, 1950, 1951, 216, 2458, 2437, 1867, - /* 900 */ 577, 576, 575, 574, 573, 568, 567, 566, 565, 407, - /* 910 */ 55, 821, 2325, 555, 554, 553, 552, 546, 545, 544, - /* 920 */ 2147, 539, 538, 422, 193, 821, 2325, 530, 1703, 1704, - /* 930 */ 207, 523, 1921, 1931, 1722, 1867, 2618, 2620, 450, 1949, - /* 940 */ 1952, 2212, 684, 683, 682, 524, 787, 825, 2700, 674, - /* 950 */ 148, 678, 2452, 638, 1862, 677, 1860, 2385, 864, 2385, - /* 960 */ 676, 681, 432, 431, 922, 473, 675, 421, 2404, 315, - /* 970 */ 430, 671, 670, 2309, 403, 218, 2383, 2602, 2383, 40, - /* 980 */ 39, 2301, 855, 46, 44, 43, 42, 41, 1891, 1922, - /* 990 */ 1865, 1866, 1918, 792, 1920, 1923, 1924, 1925, 1926, 1927, - /* 1000 */ 1928, 1929, 1930, 799, 823, 822, 1942, 1944, 1945, 1946, - /* 1010 */ 1947, 2, 2312, 639, 2464, 897, 896, 895, 894, 482, - /* 1020 */ 2307, 893, 892, 156, 887, 886, 885, 884, 883, 882, - /* 1030 */ 881, 155, 875, 874, 873, 481, 480, 870, 869, 868, - /* 1040 */ 192, 191, 867, 477, 866, 865, 178, 2636, 2146, 1919, - /* 1050 */ 2145, 375, 789, 766, 2700, 562, 691, 1457, 1458, 561, - /* 1060 */ 804, 2826, 2783, 1862, 2199, 1860, 282, 560, 373, 75, - /* 1070 */ 281, 703, 74, 821, 2325, 660, 659, 2636, 175, 765, - /* 1080 */ 212, 2144, 402, 2055, 2827, 767, 685, 280, 2654, 2331, - /* 1090 */ 804, 1891, 2796, 543, 245, 603, 601, 598, 596, 1865, - /* 1100 */ 1866, 1886, 33, 694, 2602, 2602, 803, 2602, 40, 39, - /* 1110 */ 688, 686, 46, 44, 43, 42, 41, 277, 2654, 405, - /* 1120 */ 404, 862, 168, 167, 859, 858, 857, 165, 2143, 460, - /* 1130 */ 535, 2447, 564, 563, 2602, 760, 803, 2142, 2602, 62, - /* 1140 */ 99, 1454, 1948, 1453, 469, 410, 541, 2447, 437, 2635, - /* 1150 */ 704, 2830, 2674, 821, 2325, 2141, 115, 2637, 807, 2639, - /* 1160 */ 2640, 802, 71, 825, 1969, 70, 2140, 2612, 2846, 2137, - /* 1170 */ 2728, 290, 1943, 556, 449, 2724, 1455, 63, 283, 2635, - /* 1180 */ 571, 2447, 2674, 227, 107, 2602, 115, 2637, 807, 2639, - /* 1190 */ 2640, 802, 2299, 825, 2602, 2616, 2636, 1428, 2846, 229, - /* 1200 */ 2728, 2025, 821, 2325, 449, 2724, 2136, 35, 2555, 804, - /* 1210 */ 2318, 743, 2602, 40, 39, 368, 1435, 46, 44, 43, - /* 1220 */ 42, 41, 557, 2602, 479, 478, 2602, 85, 84, 522, - /* 1230 */ 821, 2325, 224, 234, 1875, 14, 13, 2654, 294, 1430, - /* 1240 */ 1433, 1434, 2135, 2618, 2621, 514, 512, 1948, 2430, 1868, - /* 1250 */ 558, 821, 2325, 2602, 825, 803, 680, 679, 398, 1789, - /* 1260 */ 1790, 501, 732, 2602, 498, 494, 490, 487, 515, 1555, - /* 1270 */ 2826, 640, 2636, 662, 661, 40, 39, 1943, 1979, 46, - /* 1280 */ 44, 43, 42, 41, 1554, 804, 101, 2819, 2832, 212, - /* 1290 */ 533, 1867, 475, 2827, 767, 821, 2325, 1539, 2635, 2602, - /* 1300 */ 175, 2674, 821, 2325, 773, 115, 2637, 807, 2639, 2640, - /* 1310 */ 802, 2330, 825, 2654, 1852, 2322, 1828, 2846, 315, 2728, - /* 1320 */ 791, 2134, 285, 449, 2724, 1559, 1919, 821, 2325, 2602, - /* 1330 */ 2636, 803, 862, 168, 167, 859, 858, 857, 165, 1540, - /* 1340 */ 1558, 821, 2325, 804, 2385, 2760, 1991, 293, 462, 461, - /* 1350 */ 1853, 369, 40, 39, 2362, 591, 46, 44, 43, 42, - /* 1360 */ 41, 784, 34, 785, 823, 822, 1942, 1944, 1945, 1946, - /* 1370 */ 1947, 2654, 1984, 2133, 2635, 2385, 2132, 2674, 2602, 2636, - /* 1380 */ 2131, 115, 2637, 807, 2639, 2640, 802, 2602, 825, 803, - /* 1390 */ 821, 2325, 804, 2846, 816, 2728, 821, 2325, 2385, 449, - /* 1400 */ 2724, 166, 2130, 821, 2325, 821, 2325, 821, 2325, 2636, - /* 1410 */ 327, 593, 860, 891, 889, 2376, 818, 2384, 100, 1876, - /* 1420 */ 2654, 1871, 804, 819, 706, 354, 705, 476, 2302, 2129, - /* 1430 */ 2602, 861, 2635, 2602, 2376, 2674, 2602, 2602, 803, 115, - /* 1440 */ 2637, 807, 2639, 2640, 802, 2197, 825, 2154, 917, 1763, - /* 1450 */ 2654, 2846, 144, 2728, 119, 1879, 1881, 449, 2724, 2602, - /* 1460 */ 769, 157, 2556, 673, 87, 158, 2602, 687, 803, 823, - /* 1470 */ 822, 1942, 1944, 1945, 1946, 1947, 270, 709, 1870, 268, - /* 1480 */ 54, 2635, 2188, 2623, 2674, 158, 2602, 1535, 115, 2637, - /* 1490 */ 807, 2639, 2640, 802, 739, 825, 272, 717, 274, 271, - /* 1500 */ 2703, 273, 2728, 2329, 689, 276, 449, 2724, 275, 49, - /* 1510 */ 49, 2635, 2186, 2636, 2674, 1869, 732, 782, 115, 2637, - /* 1520 */ 807, 2639, 2640, 802, 2826, 825, 804, 196, 2116, 2117, - /* 1530 */ 2701, 732, 2728, 2636, 692, 166, 449, 2724, 64, 2826, - /* 1540 */ 49, 49, 2832, 212, 1779, 2625, 804, 2827, 767, 14, - /* 1550 */ 13, 732, 321, 2636, 2654, 333, 332, 2832, 212, 2826, - /* 1560 */ 76, 2180, 2827, 767, 1787, 2261, 804, 335, 334, 163, - /* 1570 */ 2602, 732, 803, 2059, 2654, 166, 206, 2832, 212, 2826, - /* 1580 */ 337, 336, 2827, 767, 339, 338, 2789, 774, 2069, 2068, - /* 1590 */ 2602, 73, 803, 2139, 2654, 341, 340, 2832, 212, 186, - /* 1600 */ 343, 342, 2827, 767, 833, 309, 299, 164, 345, 344, - /* 1610 */ 2602, 166, 803, 915, 783, 2635, 749, 1985, 2674, 1932, - /* 1620 */ 1732, 301, 115, 2637, 807, 2639, 2640, 802, 112, 825, - /* 1630 */ 145, 325, 347, 346, 788, 2635, 2728, 109, 2674, 813, - /* 1640 */ 449, 2724, 116, 2637, 807, 2639, 2640, 802, 329, 825, - /* 1650 */ 1873, 349, 348, 779, 1586, 2635, 2728, 146, 2674, 2636, - /* 1660 */ 2727, 2724, 116, 2637, 807, 2639, 2640, 802, 1518, 825, - /* 1670 */ 367, 1491, 804, 351, 350, 163, 2728, 353, 352, 2636, - /* 1680 */ 790, 2724, 871, 1617, 872, 2254, 1625, 1872, 2655, 2253, - /* 1690 */ 1632, 2170, 804, 2456, 2636, 2779, 746, 444, 753, 440, - /* 1700 */ 2654, 265, 810, 483, 2457, 2176, 1510, 804, 1508, 1630, - /* 1710 */ 1519, 2373, 725, 1492, 311, 2780, 2602, 187, 803, 2790, - /* 1720 */ 2654, 761, 762, 306, 2286, 486, 658, 654, 650, 646, - /* 1730 */ 5, 264, 314, 491, 419, 2654, 2602, 499, 803, 500, - /* 1740 */ 1894, 511, 510, 220, 219, 513, 222, 361, 1884, 1756, - /* 1750 */ 527, 2602, 1885, 803, 169, 534, 233, 536, 540, 582, - /* 1760 */ 547, 805, 542, 559, 2674, 570, 572, 578, 116, 2637, - /* 1770 */ 807, 2639, 2640, 802, 2449, 825, 97, 581, 583, 262, - /* 1780 */ 592, 2635, 2728, 594, 2674, 595, 412, 2724, 180, 2637, - /* 1790 */ 807, 2639, 2640, 802, 238, 825, 2635, 239, 597, 2674, - /* 1800 */ 599, 600, 242, 116, 2637, 807, 2639, 2640, 802, 602, - /* 1810 */ 825, 604, 2636, 1892, 619, 620, 4, 2728, 627, 630, - /* 1820 */ 628, 250, 2725, 93, 1887, 804, 632, 2636, 1893, 253, - /* 1830 */ 633, 1895, 634, 636, 1896, 733, 2786, 665, 256, 2465, - /* 1840 */ 804, 258, 94, 95, 642, 263, 252, 663, 2636, 695, - /* 1850 */ 696, 2533, 120, 2654, 708, 261, 254, 395, 710, 98, - /* 1860 */ 2530, 804, 259, 635, 159, 363, 1888, 2315, 2654, 2602, - /* 1870 */ 267, 803, 2311, 286, 2636, 2511, 269, 171, 117, 2313, - /* 1880 */ 2308, 251, 172, 720, 2602, 173, 803, 804, 721, 2654, - /* 1890 */ 2529, 719, 291, 289, 727, 750, 8, 726, 2795, 811, - /* 1900 */ 2767, 2794, 724, 296, 759, 2602, 442, 803, 302, 300, - /* 1910 */ 736, 737, 735, 734, 2635, 2654, 185, 2674, 764, 304, - /* 1920 */ 298, 180, 2637, 807, 2639, 2640, 802, 443, 825, 2635, - /* 1930 */ 303, 2602, 2674, 803, 2747, 763, 392, 2637, 807, 2639, - /* 1940 */ 2640, 802, 305, 825, 2849, 445, 772, 775, 150, 2825, - /* 1950 */ 2635, 310, 1889, 2674, 2033, 2031, 199, 392, 2637, 807, - /* 1960 */ 2639, 2640, 802, 61, 825, 2744, 814, 809, 2636, 2787, - /* 1970 */ 307, 316, 160, 364, 365, 2479, 2635, 2478, 815, 2674, - /* 1980 */ 2477, 801, 455, 385, 2637, 807, 2639, 2640, 802, 2636, - /* 1990 */ 825, 2709, 366, 162, 2326, 106, 2594, 2593, 108, 1412, - /* 2000 */ 214, 916, 804, 2589, 1, 919, 2588, 2580, 2636, 2654, - /* 2010 */ 827, 2579, 52, 370, 2571, 2570, 2586, 356, 921, 2585, - /* 2020 */ 2577, 804, 2576, 2565, 170, 2602, 394, 803, 2564, 382, - /* 2030 */ 2654, 712, 393, 406, 758, 2583, 2582, 2574, 374, 2573, - /* 2040 */ 2562, 2561, 2559, 2558, 2377, 383, 2602, 372, 803, 2654, - /* 2050 */ 2554, 2553, 2552, 417, 2547, 82, 488, 489, 1812, 1813, - /* 2060 */ 217, 493, 2545, 495, 418, 2602, 496, 803, 452, 497, - /* 2070 */ 2635, 1811, 2544, 2674, 420, 714, 2542, 391, 2637, 807, - /* 2080 */ 2639, 2640, 802, 502, 825, 2541, 2694, 454, 506, 2539, - /* 2090 */ 504, 2635, 2540, 925, 2674, 508, 1800, 2515, 392, 2637, - /* 2100 */ 807, 2639, 2640, 802, 221, 825, 2514, 223, 1759, 360, - /* 2110 */ 2635, 83, 1758, 2674, 2492, 2491, 2490, 392, 2637, 807, - /* 2120 */ 2639, 2640, 802, 520, 825, 202, 521, 2489, 2488, 525, - /* 2130 */ 2439, 1702, 2436, 528, 913, 909, 905, 901, 2636, 357, - /* 2140 */ 2435, 2429, 531, 2426, 532, 2425, 86, 226, 2424, 2423, - /* 2150 */ 2428, 804, 2427, 228, 2422, 2636, 2421, 2419, 2418, 2417, - /* 2160 */ 230, 548, 2416, 550, 2414, 2413, 2412, 2411, 804, 2434, - /* 2170 */ 2636, 2410, 2409, 2408, 2432, 2415, 2407, 2406, 2405, 2654, - /* 2180 */ 2403, 2402, 2401, 804, 114, 2400, 2399, 330, 2398, 2397, - /* 2190 */ 2396, 232, 92, 2395, 2394, 2602, 2654, 803, 2393, 2433, - /* 2200 */ 2431, 2392, 2391, 2390, 2389, 1708, 2388, 237, 585, 587, - /* 2210 */ 2387, 2654, 2602, 2386, 803, 2219, 240, 1556, 408, 817, - /* 2220 */ 409, 2218, 2217, 2216, 1552, 241, 243, 2602, 244, 803, - /* 2230 */ 1560, 2214, 2211, 605, 607, 606, 2210, 2203, 2190, 611, - /* 2240 */ 707, 257, 609, 2674, 2165, 194, 613, 387, 2637, 807, - /* 2250 */ 2639, 2640, 802, 617, 825, 2164, 615, 2635, 610, 79, - /* 2260 */ 2674, 2636, 614, 318, 377, 2637, 807, 2639, 2640, 802, - /* 2270 */ 317, 825, 2635, 246, 804, 2674, 2622, 1436, 204, 376, - /* 2280 */ 2637, 807, 2639, 2640, 802, 2513, 825, 80, 2636, 287, - /* 2290 */ 248, 2509, 625, 2499, 2487, 255, 2486, 260, 2463, 2303, - /* 2300 */ 2213, 804, 2654, 2636, 2209, 643, 1484, 644, 645, 2207, - /* 2310 */ 647, 648, 649, 2205, 651, 652, 804, 653, 2602, 2202, - /* 2320 */ 803, 655, 656, 657, 2636, 2185, 2183, 2184, 2182, 2654, - /* 2330 */ 2161, 2305, 1637, 1636, 2304, 266, 2200, 804, 72, 1542, - /* 2340 */ 1541, 888, 1538, 1536, 2654, 2602, 1525, 803, 2198, 1534, - /* 2350 */ 2189, 1533, 1532, 1531, 1530, 890, 2187, 1527, 1526, 433, - /* 2360 */ 2602, 434, 803, 2635, 435, 2654, 2674, 2160, 436, 1524, - /* 2370 */ 378, 2637, 807, 2639, 2640, 802, 690, 825, 693, 2159, - /* 2380 */ 2158, 2602, 2636, 803, 697, 2157, 699, 2156, 701, 122, - /* 2390 */ 2635, 1794, 1796, 2674, 1793, 804, 2512, 384, 2637, 807, - /* 2400 */ 2639, 2640, 802, 28, 825, 2635, 2508, 288, 2674, 1798, - /* 2410 */ 711, 56, 388, 2637, 807, 2639, 2640, 802, 67, 825, - /* 2420 */ 1765, 57, 1767, 2654, 722, 292, 2635, 2498, 2485, 2674, - /* 2430 */ 2484, 20, 2831, 379, 2637, 807, 2639, 2640, 802, 2602, - /* 2440 */ 825, 803, 2636, 728, 1769, 1784, 723, 2086, 1744, 174, - /* 2450 */ 17, 730, 1743, 738, 30, 804, 2060, 441, 6, 7, - /* 2460 */ 744, 2636, 295, 740, 21, 22, 198, 209, 742, 32, - /* 2470 */ 2623, 2026, 297, 2067, 804, 2054, 2636, 2024, 210, 184, - /* 2480 */ 2028, 197, 31, 2654, 2635, 81, 211, 2674, 2106, 804, - /* 2490 */ 2107, 389, 2637, 807, 2639, 2640, 802, 65, 825, 2602, - /* 2500 */ 24, 803, 2654, 2101, 312, 2100, 446, 2105, 2636, 2104, - /* 2510 */ 447, 2008, 59, 2007, 189, 2483, 2462, 2654, 2602, 58, - /* 2520 */ 803, 804, 102, 103, 25, 13, 1960, 1877, 11, 1970, - /* 2530 */ 840, 1959, 190, 2602, 843, 803, 846, 23, 1935, 1911, - /* 2540 */ 2461, 18, 200, 104, 2635, 331, 1934, 2674, 849, 2654, - /* 2550 */ 38, 380, 2637, 807, 2639, 2640, 802, 16, 825, 1933, - /* 2560 */ 26, 328, 1903, 2635, 806, 2602, 2674, 803, 27, 201, - /* 2570 */ 390, 2637, 807, 2639, 2640, 802, 320, 825, 2635, 812, - /* 2580 */ 109, 2674, 826, 2062, 2122, 381, 2637, 807, 2639, 2640, - /* 2590 */ 802, 326, 825, 2636, 1937, 69, 105, 2679, 2678, 824, - /* 2600 */ 68, 2121, 2120, 832, 1618, 471, 804, 1615, 834, 2119, - /* 2610 */ 2635, 836, 1614, 2674, 2636, 837, 355, 396, 2637, 807, - /* 2620 */ 2639, 2640, 802, 839, 825, 1611, 842, 804, 845, 848, - /* 2630 */ 1605, 2636, 1603, 110, 2654, 1609, 111, 1631, 1608, 1607, - /* 2640 */ 1606, 78, 1627, 1482, 804, 863, 1521, 1520, 1517, 1514, - /* 2650 */ 2602, 1513, 803, 2636, 1512, 2654, 1511, 1550, 1509, 1507, - /* 2660 */ 1506, 1505, 876, 1549, 878, 215, 804, 1503, 1502, 1500, - /* 2670 */ 1501, 2602, 2654, 803, 1499, 1498, 1497, 1546, 1544, 1494, - /* 2680 */ 1493, 1490, 1489, 1488, 2208, 1487, 898, 899, 2602, 2206, - /* 2690 */ 803, 902, 900, 904, 2654, 2635, 2204, 903, 2674, 906, - /* 2700 */ 908, 2201, 397, 2637, 807, 2639, 2640, 802, 907, 825, - /* 2710 */ 2602, 910, 803, 912, 911, 2181, 2635, 914, 2636, 2674, - /* 2720 */ 1425, 2155, 1413, 2648, 2637, 807, 2639, 2640, 802, 359, - /* 2730 */ 825, 804, 918, 2635, 920, 923, 2674, 2636, 1863, 371, - /* 2740 */ 2647, 2637, 807, 2639, 2640, 802, 924, 825, 2125, 2125, - /* 2750 */ 804, 2125, 2125, 2125, 2125, 2635, 2125, 2636, 2674, 2654, - /* 2760 */ 2125, 2125, 2646, 2637, 807, 2639, 2640, 802, 2125, 825, - /* 2770 */ 804, 2125, 2125, 2125, 2125, 2602, 2636, 803, 2654, 2125, - /* 2780 */ 2125, 2125, 2125, 2125, 2125, 2125, 2125, 2125, 2125, 804, - /* 2790 */ 2125, 2125, 2125, 2125, 2602, 2125, 803, 2636, 2654, 2125, - /* 2800 */ 2125, 2125, 2125, 2125, 2125, 2125, 2125, 2125, 2125, 2125, - /* 2810 */ 804, 2125, 2125, 2125, 2602, 2125, 803, 2654, 2125, 2125, - /* 2820 */ 2635, 2125, 2125, 2674, 2125, 2125, 2125, 414, 2637, 807, - /* 2830 */ 2639, 2640, 802, 2602, 825, 803, 2125, 2125, 2654, 2635, - /* 2840 */ 2125, 2125, 2674, 2125, 2125, 2125, 415, 2637, 807, 2639, - /* 2850 */ 2640, 802, 2125, 825, 2602, 2125, 803, 2125, 2125, 2635, - /* 2860 */ 2125, 2125, 2674, 2636, 2125, 2125, 411, 2637, 807, 2639, - /* 2870 */ 2640, 802, 2125, 825, 2125, 2125, 804, 2125, 2635, 2125, - /* 2880 */ 2125, 2674, 2125, 2125, 2125, 416, 2637, 807, 2639, 2640, - /* 2890 */ 802, 2125, 825, 2125, 2125, 2125, 2125, 2125, 2125, 805, - /* 2900 */ 2125, 2125, 2674, 2125, 2654, 2125, 387, 2637, 807, 2639, - /* 2910 */ 2640, 802, 2125, 825, 2125, 2125, 2125, 2125, 2125, 2125, - /* 2920 */ 2602, 2125, 803, 2125, 2125, 2125, 2125, 2125, 2125, 2125, - /* 2930 */ 2125, 2125, 2125, 2125, 2125, 2125, 2125, 2125, 2125, 2125, - /* 2940 */ 2125, 2125, 2125, 2125, 2125, 2125, 2125, 2125, 2125, 2125, - /* 2950 */ 2125, 2125, 2125, 2125, 2125, 2125, 2125, 2125, 2125, 2125, - /* 2960 */ 2125, 2125, 2125, 2125, 2125, 2635, 2125, 2125, 2674, 2125, - /* 2970 */ 2125, 2125, 386, 2637, 807, 2639, 2640, 802, 2125, 825, + /* 0 */ 2427, 251, 37, 337, 533, 639, 122, 2219, 461, 532, + /* 10 */ 182, 2520, 47, 45, 2081, 486, 2369, 33, 2302, 2425, + /* 20 */ 468, 2169, 1902, 40, 39, 1927, 463, 46, 44, 43, + /* 30 */ 42, 41, 2517, 841, 850, 1990, 636, 1900, 2254, 637, + /* 40 */ 2211, 2686, 136, 2351, 416, 135, 134, 133, 132, 131, + /* 50 */ 130, 129, 128, 127, 799, 40, 39, 209, 750, 46, + /* 60 */ 44, 43, 42, 41, 35, 1985, 2876, 452, 2567, 733, + /* 70 */ 40, 39, 19, 2414, 46, 44, 43, 42, 41, 1908, + /* 80 */ 29, 2520, 2704, 644, 2882, 216, 637, 2211, 2644, 2877, + /* 90 */ 785, 484, 549, 2489, 796, 155, 470, 633, 2651, 850, + /* 100 */ 836, 910, 2517, 841, 2327, 1928, 631, 2604, 952, 627, + /* 110 */ 623, 15, 927, 926, 925, 924, 496, 2880, 923, 922, + /* 120 */ 160, 917, 916, 915, 914, 913, 912, 911, 159, 905, + /* 130 */ 904, 903, 495, 494, 900, 899, 898, 196, 195, 897, + /* 140 */ 491, 896, 895, 2191, 641, 231, 2685, 1992, 1993, 2724, + /* 150 */ 638, 1589, 473, 119, 2687, 840, 2689, 2690, 835, 2126, + /* 160 */ 855, 750, 517, 855, 66, 199, 1588, 2778, 2793, 2876, + /* 170 */ 136, 464, 2774, 135, 134, 133, 132, 131, 130, 129, + /* 180 */ 128, 127, 190, 197, 314, 1963, 1973, 2882, 216, 540, + /* 190 */ 50, 217, 2877, 785, 2790, 1991, 1994, 40, 39, 2825, + /* 200 */ 2651, 46, 44, 43, 42, 41, 702, 701, 700, 436, + /* 210 */ 1903, 2493, 1901, 692, 152, 696, 125, 2786, 2787, 695, + /* 220 */ 153, 2791, 2520, 652, 694, 699, 445, 444, 156, 2686, + /* 230 */ 693, 2749, 1776, 1777, 443, 689, 688, 606, 601, 599, + /* 240 */ 659, 408, 837, 2518, 841, 229, 1906, 1907, 1960, 773, + /* 250 */ 1962, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 832, + /* 260 */ 853, 852, 1984, 1986, 1987, 1988, 1989, 2, 47, 45, + /* 270 */ 2704, 62, 2358, 413, 1927, 1925, 468, 2704, 1902, 1927, + /* 280 */ 1775, 1778, 583, 851, 2367, 604, 2651, 2222, 836, 769, + /* 290 */ 603, 1990, 288, 1900, 40, 39, 287, 521, 46, 44, + /* 300 */ 43, 42, 41, 146, 235, 1488, 563, 1487, 605, 827, + /* 310 */ 682, 40, 39, 414, 565, 46, 44, 43, 42, 41, + /* 320 */ 826, 1985, 151, 1931, 655, 543, 523, 519, 19, 46, + /* 330 */ 44, 43, 42, 41, 2685, 1908, 473, 2724, 2056, 945, + /* 340 */ 1489, 119, 2687, 840, 2689, 2690, 835, 855, 855, 92, + /* 350 */ 772, 157, 91, 166, 2749, 2778, 796, 155, 428, 464, + /* 360 */ 2774, 2421, 2422, 2106, 952, 437, 1638, 15, 2056, 101, + /* 370 */ 62, 9, 321, 375, 423, 2462, 551, 450, 2107, 722, + /* 380 */ 1629, 884, 883, 882, 1633, 881, 1635, 1636, 880, 877, + /* 390 */ 850, 1644, 874, 1646, 1647, 871, 868, 865, 775, 770, + /* 400 */ 763, 759, 1462, 1992, 1993, 2019, 2500, 2479, 894, 591, + /* 410 */ 590, 589, 588, 587, 582, 581, 580, 579, 420, 90, + /* 420 */ 2105, 1469, 569, 568, 567, 566, 560, 559, 558, 787, + /* 430 */ 553, 552, 435, 861, 451, 2567, 544, 1737, 1738, 1749, + /* 440 */ 1750, 1963, 1973, 1756, 1464, 1467, 1468, 731, 2661, 181, + /* 450 */ 479, 1991, 1994, 321, 388, 482, 2798, 2053, 2054, 2055, + /* 460 */ 2798, 2798, 2798, 2798, 2798, 471, 1903, 12, 1901, 98, + /* 470 */ 2020, 386, 76, 179, 1930, 75, 2665, 798, 185, 2786, + /* 480 */ 2787, 50, 153, 2791, 2372, 415, 438, 2053, 2054, 2055, + /* 490 */ 212, 488, 885, 2056, 2420, 2422, 2362, 249, 618, 616, + /* 500 */ 613, 611, 1906, 1907, 1960, 907, 1962, 1965, 1966, 1967, + /* 510 */ 1968, 1969, 1970, 1971, 1972, 832, 853, 852, 1984, 1986, + /* 520 */ 1987, 1988, 1989, 2, 12, 47, 45, 2667, 2669, 465, + /* 530 */ 180, 2686, 183, 468, 2180, 1902, 851, 2367, 855, 486, + /* 540 */ 2369, 576, 62, 253, 837, 575, 734, 639, 1990, 2219, + /* 550 */ 1900, 1932, 321, 574, 796, 155, 220, 36, 466, 2014, + /* 560 */ 2015, 2016, 2017, 2018, 2022, 2023, 2024, 2025, 1908, 40, + /* 570 */ 39, 909, 2704, 46, 44, 43, 42, 41, 1985, 1638, + /* 580 */ 63, 860, 859, 858, 1927, 19, 1491, 1492, 2651, 371, + /* 590 */ 836, 2645, 1908, 1629, 884, 883, 882, 1633, 881, 1635, + /* 600 */ 1636, 831, 830, 2661, 1644, 829, 1646, 1647, 828, 868, + /* 610 */ 865, 2798, 2053, 2054, 2055, 2798, 2798, 2798, 2798, 2798, + /* 620 */ 1471, 952, 851, 2367, 15, 1871, 1926, 2686, 646, 2559, + /* 630 */ 1870, 2665, 2356, 86, 85, 536, 2685, 2427, 228, 2724, + /* 640 */ 799, 319, 146, 184, 2687, 840, 2689, 2690, 835, 687, + /* 650 */ 855, 528, 526, 2085, 62, 473, 803, 478, 477, 1927, + /* 660 */ 1992, 1993, 481, 480, 412, 1928, 855, 515, 2704, 98, + /* 670 */ 512, 508, 504, 501, 529, 117, 192, 2786, 795, 62, + /* 680 */ 147, 794, 2667, 2670, 2651, 774, 836, 2881, 2876, 2168, + /* 690 */ 751, 2836, 158, 855, 555, 2489, 2363, 595, 1963, 1973, + /* 700 */ 2354, 2359, 784, 1488, 1930, 1487, 783, 216, 1991, 1994, + /* 710 */ 2876, 2877, 785, 145, 144, 143, 142, 141, 140, 139, + /* 720 */ 138, 137, 2343, 1903, 321, 1901, 442, 441, 783, 216, + /* 730 */ 851, 2367, 2685, 2877, 785, 2724, 851, 2367, 1489, 119, + /* 740 */ 2687, 840, 2689, 2690, 835, 2349, 855, 233, 123, 1964, + /* 750 */ 55, 199, 531, 2778, 530, 2114, 537, 464, 2774, 1906, + /* 760 */ 1907, 1960, 240, 1962, 1965, 1966, 1967, 1968, 1969, 1970, + /* 770 */ 1971, 1972, 832, 853, 852, 1984, 1986, 1987, 1988, 1989, + /* 780 */ 2, 47, 45, 1995, 2686, 2826, 529, 594, 239, 468, + /* 790 */ 296, 1902, 1677, 1678, 2021, 381, 2149, 837, 820, 2221, + /* 800 */ 2750, 592, 440, 439, 1990, 684, 1900, 2058, 2059, 2060, + /* 810 */ 2061, 2062, 1961, 2686, 766, 765, 2112, 2113, 2115, 2116, + /* 820 */ 2117, 2427, 851, 2367, 1964, 2704, 837, 686, 2833, 472, + /* 830 */ 2371, 685, 720, 822, 1985, 2750, 321, 585, 2489, 102, + /* 840 */ 2425, 2651, 538, 836, 493, 492, 656, 718, 1908, 716, + /* 850 */ 285, 284, 40, 39, 2704, 653, 46, 44, 43, 42, + /* 860 */ 41, 321, 892, 172, 171, 889, 888, 887, 169, 1909, + /* 870 */ 2651, 319, 836, 1804, 851, 2367, 2427, 952, 328, 329, + /* 880 */ 48, 34, 2000, 327, 487, 111, 2605, 1961, 1927, 2685, + /* 890 */ 238, 2026, 2724, 210, 557, 2425, 119, 2687, 840, 2689, + /* 900 */ 2690, 835, 2257, 855, 2881, 2507, 749, 657, 2896, 2342, + /* 910 */ 2778, 2360, 2876, 1960, 464, 2774, 1992, 1993, 2685, 654, + /* 920 */ 2513, 2724, 851, 2367, 289, 119, 2687, 840, 2689, 2690, + /* 930 */ 835, 2880, 855, 851, 2367, 2877, 2879, 2896, 489, 2778, + /* 940 */ 750, 51, 570, 464, 2774, 2371, 179, 12, 2876, 10, + /* 950 */ 418, 417, 2341, 571, 1963, 1973, 2125, 2372, 3, 2166, + /* 960 */ 474, 2190, 851, 2367, 1991, 1994, 2882, 216, 851, 2367, + /* 970 */ 53, 2877, 785, 1990, 2181, 483, 702, 701, 700, 1903, + /* 980 */ 894, 1901, 572, 692, 152, 696, 727, 1931, 658, 695, + /* 990 */ 851, 2367, 851, 2367, 694, 699, 445, 444, 2686, 1902, + /* 1000 */ 693, 734, 2189, 1985, 443, 689, 688, 730, 1830, 1831, + /* 1010 */ 2364, 837, 291, 2846, 1900, 1906, 1907, 1960, 2651, 1962, + /* 1020 */ 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 832, 853, + /* 1030 */ 852, 1984, 1986, 1987, 1988, 1989, 2, 47, 45, 2704, + /* 1040 */ 750, 851, 2367, 60, 1912, 468, 499, 1902, 2876, 791, + /* 1050 */ 2686, 498, 2793, 1964, 747, 2651, 1908, 836, 197, 2651, + /* 1060 */ 1990, 299, 1900, 837, 1469, 761, 2882, 216, 2188, 40, + /* 1070 */ 39, 2877, 785, 46, 44, 43, 42, 41, 2789, 851, + /* 1080 */ 2367, 14, 13, 736, 2559, 952, 2494, 778, 1467, 1468, + /* 1090 */ 1985, 2704, 892, 172, 171, 889, 888, 887, 169, 802, + /* 1100 */ 750, 851, 2367, 2685, 1908, 2592, 2724, 2651, 2876, 836, + /* 1110 */ 119, 2687, 840, 2689, 2690, 835, 1961, 855, 2303, 851, + /* 1120 */ 2367, 332, 2896, 321, 2778, 2651, 2882, 216, 464, 2774, + /* 1130 */ 1931, 2877, 785, 952, 2686, 2446, 48, 40, 39, 816, + /* 1140 */ 2078, 46, 44, 43, 42, 41, 690, 837, 1893, 2869, + /* 1150 */ 1869, 851, 2367, 2067, 207, 2685, 2187, 375, 2724, 851, + /* 1160 */ 2367, 2186, 119, 2687, 840, 2689, 2690, 835, 825, 855, + /* 1170 */ 1571, 339, 1992, 1993, 2896, 2704, 2778, 851, 2367, 848, + /* 1180 */ 464, 2774, 476, 475, 1894, 851, 2367, 1903, 2185, 1901, + /* 1190 */ 1577, 2651, 2033, 836, 851, 2367, 2793, 849, 853, 852, + /* 1200 */ 1984, 1986, 1987, 1988, 1989, 367, 43, 42, 41, 2427, + /* 1210 */ 1963, 1973, 1593, 2651, 490, 1932, 180, 434, 2651, 2568, + /* 1220 */ 1991, 1994, 2788, 1906, 1907, 2881, 2370, 1592, 2425, 315, + /* 1230 */ 796, 155, 1579, 2876, 2573, 1903, 1931, 1901, 170, 2685, + /* 1240 */ 2427, 2097, 2724, 678, 677, 2651, 119, 2687, 840, 2689, + /* 1250 */ 2690, 835, 2880, 855, 2686, 2184, 2877, 2878, 2896, 811, + /* 1260 */ 2778, 698, 697, 2156, 464, 2774, 2183, 837, 1927, 2810, + /* 1270 */ 686, 1906, 1907, 1960, 685, 1962, 1965, 1966, 1967, 1968, + /* 1280 */ 1969, 1970, 1971, 1972, 832, 853, 852, 1984, 1986, 1987, + /* 1290 */ 1988, 1989, 2, 47, 45, 2704, 290, 211, 608, 578, + /* 1300 */ 577, 468, 886, 1902, 2182, 2418, 784, 788, 2179, 680, + /* 1310 */ 679, 2651, 2651, 836, 2876, 179, 1990, 54, 1900, 2178, + /* 1320 */ 735, 921, 919, 2651, 493, 492, 2373, 2196, 947, 2177, + /* 1330 */ 2176, 2686, 783, 216, 1916, 792, 2175, 2877, 785, 2174, + /* 1340 */ 2173, 2172, 2011, 222, 837, 2171, 1985, 1990, 890, 1909, + /* 1350 */ 2344, 2418, 186, 2786, 2787, 78, 153, 2791, 1932, 2685, + /* 1360 */ 1908, 2651, 2724, 2595, 709, 2651, 119, 2687, 840, 2689, + /* 1370 */ 2690, 835, 2704, 855, 750, 2427, 2651, 1985, 2896, 721, + /* 1380 */ 2778, 2155, 2876, 161, 464, 2774, 2651, 2651, 2651, 952, + /* 1390 */ 836, 1908, 15, 2651, 2426, 286, 2651, 2651, 2651, 2686, + /* 1400 */ 2882, 216, 2651, 148, 891, 2877, 785, 2418, 89, 800, + /* 1410 */ 382, 712, 834, 2404, 506, 88, 2241, 1573, 706, 704, + /* 1420 */ 824, 276, 162, 162, 274, 283, 2472, 278, 1992, 1993, + /* 1430 */ 277, 2077, 280, 2839, 282, 279, 2685, 281, 703, 2724, + /* 1440 */ 2704, 691, 757, 119, 2687, 840, 2689, 2690, 835, 724, + /* 1450 */ 855, 723, 300, 2158, 2159, 2753, 2651, 2778, 836, 1574, + /* 1460 */ 116, 464, 2774, 750, 1932, 1569, 1963, 1973, 547, 113, + /* 1470 */ 72, 2876, 190, 71, 49, 49, 1991, 1994, 892, 172, + /* 1480 */ 171, 889, 888, 887, 169, 200, 170, 326, 2672, 2882, + /* 1490 */ 216, 1903, 77, 1901, 2877, 785, 1961, 14, 13, 1911, + /* 1500 */ 103, 1820, 1828, 307, 2685, 64, 1910, 2724, 2239, 49, + /* 1510 */ 2686, 404, 2687, 840, 2689, 2690, 835, 833, 855, 819, + /* 1520 */ 2743, 2101, 1917, 837, 1912, 49, 77, 1906, 1907, 1960, + /* 1530 */ 705, 1962, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, + /* 1540 */ 832, 853, 852, 1984, 1986, 1987, 1988, 1989, 2, 2686, + /* 1550 */ 2674, 2704, 167, 2111, 2110, 767, 170, 797, 1920, 1922, + /* 1560 */ 2230, 2228, 837, 901, 305, 801, 330, 2651, 150, 836, + /* 1570 */ 74, 808, 853, 852, 1984, 1986, 1987, 1988, 1989, 863, + /* 1580 */ 2686, 2705, 707, 710, 2027, 346, 345, 1544, 1974, 2296, + /* 1590 */ 2704, 789, 168, 837, 2295, 348, 347, 350, 349, 352, + /* 1600 */ 351, 354, 353, 170, 1773, 1763, 2651, 149, 836, 356, + /* 1610 */ 355, 358, 357, 360, 359, 2685, 2498, 2212, 2724, 2686, + /* 1620 */ 2829, 2704, 119, 2687, 840, 2689, 2690, 835, 1552, 855, + /* 1630 */ 1525, 342, 837, 167, 2751, 1620, 2778, 2651, 764, 836, + /* 1640 */ 464, 2774, 362, 361, 364, 363, 2686, 366, 365, 380, + /* 1650 */ 457, 771, 453, 902, 2685, 805, 497, 2724, 1651, 837, + /* 1660 */ 2704, 119, 2687, 840, 2689, 2690, 835, 2218, 855, 2499, + /* 1670 */ 1553, 1659, 1526, 821, 1914, 2778, 2651, 1542, 836, 464, + /* 1680 */ 2774, 1913, 1666, 2415, 743, 2685, 1664, 2704, 2724, 779, + /* 1690 */ 2830, 2840, 120, 2687, 840, 2689, 2690, 835, 780, 855, + /* 1700 */ 317, 2328, 312, 2651, 320, 836, 2778, 732, 5, 505, + /* 1710 */ 2777, 2774, 173, 500, 432, 513, 1935, 514, 525, 223, + /* 1720 */ 224, 524, 527, 226, 2685, 955, 1797, 2724, 374, 1925, + /* 1730 */ 541, 120, 2687, 840, 2689, 2690, 835, 1926, 855, 237, + /* 1740 */ 548, 373, 550, 554, 556, 2778, 597, 561, 584, 823, + /* 1750 */ 2774, 838, 573, 2491, 2724, 593, 586, 206, 120, 2687, + /* 1760 */ 840, 2689, 2690, 835, 596, 855, 943, 939, 935, 931, + /* 1770 */ 598, 370, 2778, 609, 610, 607, 427, 2774, 242, 243, + /* 1780 */ 612, 614, 615, 246, 617, 619, 1933, 634, 4, 635, + /* 1790 */ 643, 642, 1928, 645, 1934, 254, 94, 647, 257, 1936, + /* 1800 */ 260, 648, 649, 651, 262, 1937, 2514, 1938, 271, 660, + /* 1810 */ 681, 95, 96, 2686, 2508, 97, 118, 269, 2582, 343, + /* 1820 */ 728, 409, 124, 713, 191, 683, 837, 714, 376, 726, + /* 1830 */ 100, 163, 2686, 676, 672, 668, 664, 1929, 270, 2357, + /* 1840 */ 273, 2353, 275, 2560, 175, 837, 292, 121, 2355, 2350, + /* 1850 */ 176, 812, 177, 738, 2704, 739, 295, 737, 297, 745, + /* 1860 */ 768, 744, 2845, 2844, 8, 189, 806, 2817, 777, 2579, + /* 1870 */ 2651, 2578, 836, 2704, 308, 306, 309, 753, 742, 754, + /* 1880 */ 755, 752, 310, 99, 782, 313, 268, 781, 2797, 2651, + /* 1890 */ 458, 836, 154, 2686, 793, 341, 2899, 818, 790, 302, + /* 1900 */ 324, 304, 2875, 1930, 316, 323, 837, 2075, 2073, 1, + /* 1910 */ 311, 203, 377, 804, 2528, 322, 218, 164, 2685, 2527, + /* 1920 */ 2686, 2724, 2526, 462, 293, 187, 2687, 840, 2689, 2690, + /* 1930 */ 835, 378, 855, 837, 2704, 809, 810, 2685, 165, 814, + /* 1940 */ 2724, 61, 2794, 335, 120, 2687, 840, 2689, 2690, 835, + /* 1950 */ 2651, 855, 836, 256, 817, 2759, 842, 844, 2778, 846, + /* 1960 */ 847, 2704, 267, 2775, 379, 2643, 258, 265, 2642, 2638, + /* 1970 */ 2686, 2637, 263, 650, 340, 110, 112, 2651, 2629, 836, + /* 1980 */ 2628, 1446, 2620, 837, 786, 2897, 2619, 2635, 2634, 857, + /* 1990 */ 2626, 255, 2368, 383, 949, 946, 730, 369, 2685, 174, + /* 2000 */ 2686, 2724, 455, 951, 2625, 184, 2687, 840, 2689, 2690, + /* 2010 */ 835, 2704, 855, 837, 2614, 407, 2603, 2686, 387, 2613, + /* 2020 */ 424, 2632, 52, 2631, 385, 2685, 2602, 2651, 2724, 836, + /* 2030 */ 837, 395, 405, 2687, 840, 2689, 2690, 835, 2686, 855, + /* 2040 */ 2623, 2704, 2622, 2611, 2610, 2608, 2607, 406, 2419, 396, + /* 2050 */ 425, 834, 456, 2837, 2601, 83, 2596, 2651, 2704, 836, + /* 2060 */ 502, 503, 419, 507, 1853, 1854, 221, 2594, 509, 510, + /* 2070 */ 511, 1852, 2593, 433, 2651, 2685, 836, 2591, 2724, 2704, + /* 2080 */ 2686, 516, 405, 2687, 840, 2689, 2690, 835, 2590, 855, + /* 2090 */ 518, 2589, 520, 837, 2588, 2651, 522, 836, 1841, 2564, + /* 2100 */ 225, 2563, 1800, 227, 1799, 2685, 84, 2541, 2724, 2540, + /* 2110 */ 2539, 534, 398, 2687, 840, 2689, 2690, 835, 535, 855, + /* 2120 */ 2538, 2704, 2685, 2537, 2481, 2724, 2478, 2686, 539, 187, + /* 2130 */ 2687, 840, 2689, 2690, 835, 1736, 855, 2651, 2477, 836, + /* 2140 */ 837, 542, 2471, 2685, 546, 545, 2724, 2468, 2467, 230, + /* 2150 */ 404, 2687, 840, 2689, 2690, 835, 87, 855, 2466, 2744, + /* 2160 */ 2465, 2470, 467, 776, 232, 2469, 2464, 2463, 2704, 2461, + /* 2170 */ 2460, 2459, 234, 562, 2458, 564, 2456, 2455, 2454, 2453, + /* 2180 */ 2476, 2452, 2451, 2450, 2651, 2685, 836, 2474, 2724, 2898, + /* 2190 */ 2686, 2457, 405, 2687, 840, 2689, 2690, 835, 2449, 855, + /* 2200 */ 2448, 2447, 2445, 837, 2444, 2443, 2442, 2441, 2440, 469, + /* 2210 */ 2686, 236, 2439, 93, 2438, 2437, 2436, 2435, 2506, 2475, + /* 2220 */ 2473, 2434, 2433, 837, 600, 1742, 2432, 2431, 241, 2430, + /* 2230 */ 602, 2704, 2685, 2429, 2428, 2724, 421, 2261, 422, 405, + /* 2240 */ 2687, 840, 2689, 2690, 835, 1590, 855, 2651, 2260, 836, + /* 2250 */ 1594, 2704, 2259, 2258, 244, 245, 2256, 247, 2253, 248, + /* 2260 */ 2686, 621, 1586, 2252, 625, 2245, 2232, 2651, 620, 836, + /* 2270 */ 2207, 1470, 622, 837, 626, 624, 628, 632, 630, 198, + /* 2280 */ 2206, 2562, 2558, 80, 2548, 2536, 629, 250, 261, 2535, + /* 2290 */ 2512, 2505, 252, 2671, 208, 725, 640, 2686, 2724, 264, + /* 2300 */ 266, 2704, 400, 2687, 840, 2689, 2690, 835, 2345, 855, + /* 2310 */ 837, 81, 2255, 259, 2251, 2685, 661, 2651, 2724, 836, + /* 2320 */ 663, 2686, 390, 2687, 840, 2689, 2690, 835, 1518, 855, + /* 2330 */ 2249, 665, 2247, 669, 837, 667, 2244, 662, 2704, 666, + /* 2340 */ 2686, 671, 673, 670, 675, 2227, 674, 2225, 2226, 2224, + /* 2350 */ 2203, 2347, 1671, 837, 2651, 1670, 836, 2346, 1576, 1575, + /* 2360 */ 1572, 1570, 2704, 1568, 1567, 2685, 1566, 918, 2724, 2242, + /* 2370 */ 920, 272, 389, 2687, 840, 2689, 2690, 835, 2651, 855, + /* 2380 */ 836, 2704, 2686, 73, 1559, 446, 2240, 447, 2231, 1565, + /* 2390 */ 1564, 708, 1561, 1560, 448, 837, 1558, 2651, 2229, 836, + /* 2400 */ 449, 711, 2685, 2202, 2201, 2724, 2686, 2200, 715, 391, + /* 2410 */ 2687, 840, 2689, 2690, 835, 719, 855, 2199, 2198, 837, + /* 2420 */ 717, 126, 1835, 2704, 1837, 1839, 2685, 1834, 28, 2724, + /* 2430 */ 2561, 67, 1825, 397, 2687, 840, 2689, 2690, 835, 2651, + /* 2440 */ 855, 836, 1806, 294, 2557, 2685, 56, 2704, 2724, 57, + /* 2450 */ 1808, 2686, 401, 2687, 840, 2689, 2690, 835, 2547, 855, + /* 2460 */ 740, 298, 741, 2651, 837, 836, 2534, 2533, 20, 746, + /* 2470 */ 1785, 2881, 2686, 748, 1784, 6, 756, 30, 1810, 2128, + /* 2480 */ 178, 301, 729, 17, 454, 837, 2102, 2685, 758, 2686, + /* 2490 */ 2724, 760, 2704, 7, 392, 2687, 840, 2689, 2690, 835, + /* 2500 */ 188, 855, 837, 762, 303, 21, 22, 2109, 2651, 2096, + /* 2510 */ 836, 2685, 202, 2704, 2724, 32, 2068, 201, 402, 2687, + /* 2520 */ 840, 2689, 2690, 835, 31, 855, 213, 2672, 2066, 2651, + /* 2530 */ 2704, 836, 82, 214, 215, 2070, 2148, 65, 2149, 24, + /* 2540 */ 318, 2143, 2142, 2050, 459, 2147, 2651, 2146, 836, 460, + /* 2550 */ 59, 193, 2049, 2532, 2511, 105, 2685, 104, 807, 2724, + /* 2560 */ 325, 2104, 204, 393, 2687, 840, 2689, 2690, 835, 2686, + /* 2570 */ 855, 23, 331, 69, 2510, 18, 2504, 2685, 106, 58, + /* 2580 */ 2724, 813, 837, 107, 403, 2687, 840, 2689, 2690, 835, + /* 2590 */ 815, 855, 334, 333, 2685, 25, 2002, 2724, 336, 2001, + /* 2600 */ 2686, 394, 2687, 840, 2689, 2690, 835, 13, 855, 11, + /* 2610 */ 2704, 1918, 870, 837, 194, 205, 1953, 2503, 344, 2686, + /* 2620 */ 873, 2012, 839, 1977, 845, 876, 2651, 1976, 836, 879, + /* 2630 */ 38, 16, 837, 1975, 26, 108, 1945, 27, 70, 862, + /* 2640 */ 843, 2704, 338, 109, 2729, 113, 2728, 2164, 2163, 1979, + /* 2650 */ 2686, 854, 2162, 68, 1643, 2161, 1652, 2651, 485, 836, + /* 2660 */ 2704, 864, 867, 837, 856, 866, 869, 1649, 1648, 1645, + /* 2670 */ 872, 1639, 875, 1637, 2685, 878, 2651, 2724, 836, 1642, + /* 2680 */ 2686, 410, 2687, 840, 2689, 2690, 835, 368, 855, 114, + /* 2690 */ 1641, 2704, 1640, 837, 115, 1665, 79, 1661, 1555, 1554, + /* 2700 */ 1516, 1551, 1548, 893, 1547, 2685, 1546, 2651, 2724, 836, + /* 2710 */ 1545, 1543, 411, 2687, 840, 2689, 2690, 835, 1541, 855, + /* 2720 */ 1540, 2704, 1539, 1584, 2685, 906, 1583, 2724, 908, 219, + /* 2730 */ 2686, 2698, 2687, 840, 2689, 2690, 835, 2651, 855, 836, + /* 2740 */ 1537, 1536, 1535, 837, 1534, 1533, 1532, 1531, 1578, 1580, + /* 2750 */ 1528, 1527, 1524, 1523, 1522, 2685, 1521, 2686, 2724, 2250, + /* 2760 */ 928, 2248, 2697, 2687, 840, 2689, 2690, 835, 929, 855, + /* 2770 */ 837, 2704, 930, 932, 2246, 933, 934, 936, 937, 938, + /* 2780 */ 2243, 940, 941, 942, 2223, 2685, 944, 2651, 2724, 836, + /* 2790 */ 1459, 2686, 2696, 2687, 840, 2689, 2690, 835, 2704, 855, + /* 2800 */ 2197, 1447, 948, 372, 837, 1904, 950, 954, 384, 953, + /* 2810 */ 2167, 2167, 2167, 2167, 2651, 2167, 836, 2167, 2686, 2167, + /* 2820 */ 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, + /* 2830 */ 2167, 837, 2704, 2167, 2167, 2685, 2167, 2167, 2724, 2167, + /* 2840 */ 2167, 2686, 429, 2687, 840, 2689, 2690, 835, 2651, 855, + /* 2850 */ 836, 2167, 2167, 2167, 837, 2167, 2167, 2167, 2167, 2704, + /* 2860 */ 2167, 2167, 2685, 2167, 2167, 2724, 2167, 2167, 2167, 430, + /* 2870 */ 2687, 840, 2689, 2690, 835, 2651, 855, 836, 2167, 2686, + /* 2880 */ 2167, 2167, 2704, 2167, 2167, 2167, 2167, 2167, 2167, 2167, + /* 2890 */ 2167, 2167, 837, 2167, 2167, 2167, 2685, 2167, 2651, 2724, + /* 2900 */ 836, 2167, 2167, 426, 2687, 840, 2689, 2690, 835, 2167, + /* 2910 */ 855, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, + /* 2920 */ 2704, 2167, 2167, 2685, 2167, 2167, 2724, 2167, 2167, 2167, + /* 2930 */ 431, 2687, 840, 2689, 2690, 835, 2651, 855, 836, 2167, + /* 2940 */ 2167, 2167, 2167, 2167, 2167, 2167, 838, 2167, 2167, 2724, + /* 2950 */ 2167, 2167, 2167, 400, 2687, 840, 2689, 2690, 835, 2167, + /* 2960 */ 855, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, + /* 2970 */ 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, 2167, + /* 2980 */ 2167, 2167, 2167, 2167, 2685, 2167, 2167, 2724, 2167, 2167, + /* 2990 */ 2167, 399, 2687, 840, 2689, 2690, 835, 2167, 855, }; static const YYCODETYPE yy_lookahead[] = { - /* 0 */ 508, 394, 401, 385, 386, 404, 432, 508, 516, 508, - /* 10 */ 385, 415, 12, 13, 14, 516, 373, 516, 411, 414, - /* 20 */ 20, 447, 22, 405, 450, 451, 534, 535, 421, 386, - /* 30 */ 412, 539, 540, 417, 535, 35, 535, 37, 539, 540, - /* 40 */ 539, 540, 386, 34, 385, 386, 8, 9, 395, 432, - /* 50 */ 12, 13, 14, 15, 16, 14, 403, 414, 0, 434, - /* 60 */ 435, 20, 437, 373, 405, 65, 441, 450, 451, 454, - /* 70 */ 414, 412, 72, 430, 459, 432, 386, 472, 473, 79, - /* 80 */ 21, 414, 24, 25, 26, 27, 28, 29, 30, 31, - /* 90 */ 32, 20, 12, 13, 478, 36, 20, 38, 39, 40, - /* 100 */ 20, 373, 22, 20, 414, 489, 70, 440, 108, 442, - /* 110 */ 72, 111, 385, 386, 386, 35, 414, 37, 475, 65, - /* 120 */ 430, 478, 432, 508, 422, 482, 483, 484, 485, 486, - /* 130 */ 487, 516, 489, 33, 20, 433, 22, 494, 20, 496, - /* 140 */ 484, 385, 414, 500, 501, 65, 414, 147, 148, 534, - /* 150 */ 535, 37, 72, 20, 539, 540, 424, 119, 430, 79, - /* 160 */ 432, 141, 142, 520, 110, 475, 146, 113, 478, 55, - /* 170 */ 121, 528, 482, 483, 484, 485, 486, 487, 488, 489, - /* 180 */ 490, 491, 111, 373, 14, 185, 186, 164, 108, 406, - /* 190 */ 20, 111, 192, 193, 8, 9, 386, 414, 12, 13, - /* 200 */ 14, 15, 16, 475, 497, 498, 478, 207, 425, 209, - /* 210 */ 482, 483, 484, 485, 486, 487, 510, 489, 512, 33, - /* 220 */ 464, 465, 184, 174, 414, 37, 185, 147, 148, 111, - /* 230 */ 503, 504, 505, 506, 180, 508, 509, 372, 202, 374, - /* 240 */ 430, 20, 432, 243, 244, 245, 42, 247, 248, 249, + /* 0 */ 417, 384, 503, 504, 460, 388, 417, 390, 425, 465, + /* 10 */ 398, 435, 12, 13, 14, 426, 427, 2, 406, 436, + /* 20 */ 20, 0, 22, 8, 9, 20, 450, 12, 13, 14, + /* 30 */ 15, 16, 456, 457, 20, 35, 383, 37, 0, 386, + /* 40 */ 387, 376, 21, 418, 419, 24, 25, 26, 27, 28, + /* 50 */ 29, 30, 31, 32, 389, 8, 9, 416, 514, 12, + /* 60 */ 13, 14, 15, 16, 2, 65, 522, 478, 479, 20, + /* 70 */ 8, 9, 72, 432, 12, 13, 14, 15, 16, 79, + /* 80 */ 33, 435, 417, 383, 540, 541, 386, 387, 420, 545, + /* 90 */ 546, 423, 388, 389, 388, 389, 450, 51, 433, 20, + /* 100 */ 435, 404, 456, 457, 407, 20, 60, 460, 108, 63, + /* 110 */ 64, 111, 74, 75, 76, 77, 78, 3, 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, 376, 14, 441, 481, 147, 148, 484, + /* 150 */ 20, 22, 484, 488, 489, 490, 491, 492, 493, 112, + /* 160 */ 495, 514, 70, 495, 4, 500, 37, 502, 487, 522, + /* 170 */ 21, 506, 507, 24, 25, 26, 27, 28, 29, 30, + /* 180 */ 31, 32, 516, 417, 518, 185, 186, 540, 541, 388, + /* 190 */ 111, 526, 545, 546, 513, 195, 196, 8, 9, 534, + /* 200 */ 433, 12, 13, 14, 15, 16, 74, 75, 76, 443, + /* 210 */ 210, 445, 212, 81, 82, 83, 510, 511, 512, 87, + /* 220 */ 514, 515, 435, 20, 92, 93, 94, 95, 498, 376, + /* 230 */ 98, 501, 147, 148, 102, 103, 104, 108, 437, 438, + /* 240 */ 71, 440, 389, 456, 457, 444, 246, 247, 248, 389, /* 250 */ 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, - /* 260 */ 260, 261, 262, 263, 264, 185, 186, 231, 232, 541, - /* 270 */ 542, 21, 192, 193, 24, 25, 26, 27, 28, 29, - /* 280 */ 30, 31, 32, 20, 37, 475, 245, 207, 478, 209, - /* 290 */ 394, 414, 482, 483, 484, 485, 486, 487, 112, 489, - /* 300 */ 423, 424, 164, 280, 281, 282, 268, 269, 270, 271, - /* 310 */ 272, 273, 274, 275, 276, 277, 278, 421, 185, 186, - /* 320 */ 385, 386, 20, 243, 244, 245, 79, 247, 248, 249, - /* 330 */ 250, 251, 252, 253, 254, 255, 256, 257, 258, 259, - /* 340 */ 260, 261, 262, 263, 264, 265, 12, 13, 373, 472, - /* 350 */ 473, 51, 542, 415, 20, 428, 22, 414, 431, 432, - /* 360 */ 60, 386, 71, 63, 64, 108, 423, 424, 164, 35, - /* 370 */ 71, 37, 140, 141, 142, 143, 144, 145, 146, 122, - /* 380 */ 123, 124, 125, 126, 127, 128, 129, 130, 131, 414, - /* 390 */ 133, 134, 135, 136, 137, 138, 139, 209, 415, 65, - /* 400 */ 12, 13, 14, 15, 16, 430, 72, 432, 290, 426, - /* 410 */ 147, 148, 474, 79, 314, 385, 386, 279, 280, 281, - /* 420 */ 282, 283, 284, 285, 286, 287, 12, 13, 14, 241, - /* 430 */ 242, 20, 39, 40, 20, 111, 22, 20, 385, 504, - /* 440 */ 505, 506, 108, 508, 509, 111, 414, 12, 13, 35, - /* 450 */ 475, 37, 417, 478, 422, 192, 193, 482, 483, 484, - /* 460 */ 485, 486, 487, 3, 489, 433, 20, 492, 219, 494, - /* 470 */ 495, 496, 37, 431, 432, 500, 501, 88, 413, 65, - /* 480 */ 20, 147, 148, 279, 280, 281, 282, 283, 284, 285, - /* 490 */ 286, 287, 380, 79, 429, 383, 384, 8, 9, 373, - /* 500 */ 22, 12, 13, 14, 15, 16, 12, 13, 115, 116, - /* 510 */ 13, 118, 386, 478, 20, 37, 22, 464, 465, 185, - /* 520 */ 186, 414, 108, 0, 489, 111, 192, 193, 111, 35, - /* 530 */ 111, 37, 191, 140, 504, 505, 506, 144, 508, 509, - /* 540 */ 414, 207, 153, 209, 21, 481, 516, 24, 25, 26, - /* 550 */ 27, 28, 29, 30, 31, 32, 430, 79, 432, 65, - /* 560 */ 492, 147, 148, 495, 534, 535, 4, 178, 179, 539, - /* 570 */ 540, 507, 112, 79, 385, 386, 79, 243, 244, 245, - /* 580 */ 473, 247, 248, 249, 250, 251, 252, 253, 254, 255, - /* 590 */ 256, 257, 258, 259, 260, 261, 262, 263, 264, 185, - /* 600 */ 186, 475, 108, 37, 478, 111, 192, 193, 482, 483, - /* 610 */ 484, 485, 486, 487, 290, 489, 367, 368, 369, 20, - /* 620 */ 494, 207, 496, 209, 8, 9, 500, 501, 12, 13, - /* 630 */ 14, 15, 16, 187, 481, 373, 20, 296, 297, 298, - /* 640 */ 299, 147, 148, 33, 209, 370, 20, 187, 0, 283, - /* 650 */ 284, 285, 286, 287, 528, 45, 245, 243, 244, 245, - /* 660 */ 507, 247, 248, 249, 250, 251, 252, 253, 254, 255, - /* 670 */ 256, 257, 258, 259, 260, 261, 262, 263, 264, 185, - /* 680 */ 186, 380, 121, 4, 383, 384, 192, 193, 199, 265, - /* 690 */ 111, 245, 430, 504, 505, 506, 108, 508, 509, 51, - /* 700 */ 20, 207, 381, 209, 13, 50, 385, 290, 387, 290, - /* 710 */ 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, - /* 720 */ 373, 133, 134, 135, 136, 137, 138, 139, 37, 454, - /* 730 */ 14, 15, 16, 386, 459, 388, 481, 243, 244, 245, - /* 740 */ 0, 247, 248, 249, 250, 251, 252, 253, 254, 255, - /* 750 */ 256, 257, 258, 259, 260, 261, 262, 263, 264, 12, - /* 760 */ 13, 414, 507, 20, 18, 14, 20, 20, 381, 22, - /* 770 */ 0, 20, 385, 27, 387, 209, 30, 430, 373, 432, - /* 780 */ 410, 35, 35, 508, 37, 206, 187, 208, 8, 9, - /* 790 */ 111, 516, 12, 13, 14, 15, 16, 51, 417, 53, - /* 800 */ 265, 420, 267, 187, 58, 59, 317, 241, 242, 534, - /* 810 */ 535, 185, 65, 23, 539, 540, 70, 427, 14, 240, - /* 820 */ 430, 243, 475, 392, 20, 478, 79, 147, 148, 482, - /* 830 */ 483, 484, 485, 486, 487, 430, 489, 47, 48, 469, - /* 840 */ 409, 494, 187, 496, 74, 75, 76, 500, 501, 418, - /* 850 */ 195, 81, 82, 83, 292, 108, 110, 87, 111, 478, - /* 860 */ 402, 245, 92, 93, 94, 95, 20, 121, 98, 290, - /* 870 */ 489, 245, 102, 103, 104, 140, 385, 386, 22, 144, - /* 880 */ 302, 303, 304, 305, 306, 307, 308, 0, 430, 0, - /* 890 */ 385, 386, 112, 37, 147, 148, 405, 151, 152, 79, - /* 900 */ 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, - /* 910 */ 405, 385, 386, 167, 168, 169, 170, 171, 172, 173, - /* 920 */ 373, 175, 176, 177, 414, 385, 386, 181, 182, 183, - /* 930 */ 187, 405, 185, 186, 188, 79, 478, 479, 480, 192, - /* 940 */ 193, 0, 74, 75, 76, 405, 493, 489, 495, 81, - /* 950 */ 82, 83, 442, 385, 207, 87, 209, 414, 71, 414, - /* 960 */ 92, 93, 94, 95, 108, 422, 98, 422, 0, 290, - /* 970 */ 102, 103, 104, 415, 416, 235, 433, 430, 433, 8, - /* 980 */ 9, 0, 121, 12, 13, 14, 15, 16, 245, 185, - /* 990 */ 243, 244, 245, 72, 247, 248, 249, 250, 251, 252, - /* 1000 */ 253, 254, 255, 256, 257, 258, 259, 260, 261, 262, - /* 1010 */ 263, 264, 415, 445, 446, 74, 75, 76, 77, 78, - /* 1020 */ 415, 80, 81, 82, 83, 84, 85, 86, 87, 88, - /* 1030 */ 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, - /* 1040 */ 99, 100, 101, 102, 103, 104, 18, 373, 373, 245, - /* 1050 */ 373, 23, 493, 508, 495, 166, 4, 56, 57, 170, - /* 1060 */ 386, 516, 388, 207, 0, 209, 142, 178, 40, 41, - /* 1070 */ 146, 19, 44, 385, 386, 390, 391, 373, 414, 534, - /* 1080 */ 535, 373, 54, 112, 539, 540, 22, 35, 414, 425, - /* 1090 */ 386, 245, 388, 405, 66, 67, 68, 69, 70, 243, - /* 1100 */ 244, 20, 2, 51, 430, 430, 432, 430, 8, 9, - /* 1110 */ 58, 59, 12, 13, 14, 15, 16, 65, 414, 12, - /* 1120 */ 13, 140, 141, 142, 143, 144, 145, 146, 373, 22, - /* 1130 */ 385, 386, 164, 165, 430, 13, 432, 373, 430, 111, - /* 1140 */ 216, 20, 35, 22, 37, 221, 385, 386, 224, 475, - /* 1150 */ 226, 3, 478, 385, 386, 373, 482, 483, 484, 485, - /* 1160 */ 486, 487, 110, 489, 243, 113, 373, 402, 494, 373, - /* 1170 */ 496, 415, 65, 405, 500, 501, 55, 149, 141, 475, - /* 1180 */ 385, 386, 478, 438, 392, 430, 482, 483, 484, 485, - /* 1190 */ 486, 487, 0, 489, 430, 430, 373, 4, 494, 438, - /* 1200 */ 496, 79, 385, 386, 500, 501, 373, 2, 454, 386, - /* 1210 */ 418, 388, 430, 8, 9, 415, 23, 12, 13, 14, - /* 1220 */ 15, 16, 405, 430, 12, 13, 430, 199, 200, 201, - /* 1230 */ 385, 386, 204, 438, 22, 1, 2, 414, 65, 46, - /* 1240 */ 47, 48, 373, 478, 479, 217, 218, 35, 0, 37, - /* 1250 */ 405, 385, 386, 430, 489, 432, 399, 400, 230, 222, - /* 1260 */ 223, 233, 508, 430, 236, 237, 238, 239, 240, 22, - /* 1270 */ 516, 405, 373, 390, 391, 8, 9, 65, 184, 12, - /* 1280 */ 13, 14, 15, 16, 37, 386, 113, 388, 534, 535, - /* 1290 */ 42, 79, 406, 539, 540, 385, 386, 37, 475, 430, - /* 1300 */ 414, 478, 385, 386, 33, 482, 483, 484, 485, 486, - /* 1310 */ 487, 425, 489, 414, 207, 405, 209, 494, 290, 496, - /* 1320 */ 108, 373, 405, 500, 501, 22, 245, 385, 386, 430, - /* 1330 */ 373, 432, 140, 141, 142, 143, 144, 145, 146, 79, - /* 1340 */ 37, 385, 386, 386, 414, 388, 112, 405, 241, 242, - /* 1350 */ 243, 407, 8, 9, 410, 108, 12, 13, 14, 15, - /* 1360 */ 16, 405, 268, 433, 257, 258, 259, 260, 261, 262, - /* 1370 */ 263, 414, 278, 373, 475, 414, 373, 478, 430, 373, - /* 1380 */ 373, 482, 483, 484, 485, 486, 487, 430, 489, 432, - /* 1390 */ 385, 386, 386, 494, 433, 496, 385, 386, 414, 500, - /* 1400 */ 501, 33, 373, 385, 386, 385, 386, 385, 386, 373, - /* 1410 */ 405, 108, 427, 399, 400, 430, 405, 433, 180, 207, - /* 1420 */ 414, 209, 386, 405, 225, 405, 227, 405, 0, 373, - /* 1430 */ 430, 427, 475, 430, 430, 478, 430, 430, 432, 482, - /* 1440 */ 483, 484, 485, 486, 487, 0, 489, 376, 377, 211, - /* 1450 */ 414, 494, 33, 496, 187, 243, 244, 500, 501, 430, - /* 1460 */ 312, 33, 454, 13, 45, 33, 430, 22, 432, 257, - /* 1470 */ 258, 259, 260, 261, 262, 263, 114, 454, 37, 117, - /* 1480 */ 112, 475, 0, 49, 478, 33, 430, 37, 482, 483, - /* 1490 */ 484, 485, 486, 487, 33, 489, 114, 454, 114, 117, - /* 1500 */ 494, 117, 496, 415, 22, 114, 500, 501, 117, 33, - /* 1510 */ 33, 475, 0, 373, 478, 37, 508, 454, 482, 483, - /* 1520 */ 484, 485, 486, 487, 516, 489, 386, 33, 147, 148, - /* 1530 */ 494, 508, 496, 373, 22, 33, 500, 501, 33, 516, - /* 1540 */ 33, 33, 534, 535, 112, 111, 386, 539, 540, 1, - /* 1550 */ 2, 508, 33, 373, 414, 12, 13, 534, 535, 516, - /* 1560 */ 33, 0, 539, 540, 112, 403, 386, 12, 13, 33, - /* 1570 */ 430, 508, 432, 112, 414, 33, 460, 534, 535, 516, - /* 1580 */ 12, 13, 539, 540, 12, 13, 443, 316, 112, 112, - /* 1590 */ 430, 33, 432, 374, 414, 12, 13, 534, 535, 510, - /* 1600 */ 12, 13, 539, 540, 33, 543, 112, 33, 12, 13, - /* 1610 */ 430, 33, 432, 52, 112, 475, 532, 112, 478, 112, - /* 1620 */ 112, 525, 482, 483, 484, 485, 486, 487, 111, 489, - /* 1630 */ 33, 112, 12, 13, 494, 475, 496, 120, 478, 112, - /* 1640 */ 500, 501, 482, 483, 484, 485, 486, 487, 112, 489, - /* 1650 */ 209, 12, 13, 511, 112, 475, 496, 389, 478, 373, - /* 1660 */ 500, 501, 482, 483, 484, 485, 486, 487, 37, 489, - /* 1670 */ 112, 37, 386, 12, 13, 33, 496, 12, 13, 373, - /* 1680 */ 500, 501, 13, 112, 13, 402, 112, 209, 414, 402, - /* 1690 */ 112, 384, 386, 443, 373, 443, 531, 531, 531, 453, - /* 1700 */ 414, 35, 531, 389, 443, 386, 37, 386, 37, 112, - /* 1710 */ 79, 429, 461, 79, 536, 443, 430, 51, 432, 443, - /* 1720 */ 414, 515, 515, 502, 404, 455, 60, 61, 62, 63, - /* 1730 */ 293, 65, 518, 51, 477, 414, 430, 42, 432, 476, - /* 1740 */ 20, 466, 224, 394, 471, 466, 394, 457, 20, 205, - /* 1750 */ 385, 430, 20, 432, 112, 386, 45, 439, 386, 184, - /* 1760 */ 436, 475, 439, 385, 478, 386, 439, 436, 482, 483, - /* 1770 */ 484, 485, 486, 487, 385, 489, 110, 436, 436, 113, - /* 1780 */ 107, 475, 496, 109, 478, 398, 500, 501, 482, 483, - /* 1790 */ 484, 485, 486, 487, 397, 489, 475, 385, 385, 478, - /* 1800 */ 106, 396, 385, 482, 483, 484, 485, 486, 487, 385, - /* 1810 */ 489, 385, 373, 20, 378, 382, 50, 496, 378, 466, - /* 1820 */ 382, 394, 501, 394, 20, 386, 432, 373, 20, 394, - /* 1830 */ 387, 20, 456, 387, 20, 529, 530, 414, 394, 446, - /* 1840 */ 386, 394, 394, 394, 385, 394, 180, 378, 373, 376, - /* 1850 */ 376, 430, 385, 414, 228, 189, 190, 378, 470, 111, - /* 1860 */ 430, 386, 196, 197, 468, 466, 20, 414, 414, 430, - /* 1870 */ 414, 432, 414, 392, 373, 465, 414, 414, 414, 414, - /* 1880 */ 414, 215, 414, 213, 430, 414, 432, 386, 463, 414, - /* 1890 */ 430, 212, 392, 462, 385, 301, 309, 455, 524, 300, - /* 1900 */ 527, 524, 432, 448, 198, 430, 452, 432, 523, 526, - /* 1910 */ 430, 311, 310, 294, 475, 414, 524, 478, 289, 521, - /* 1920 */ 448, 482, 483, 484, 485, 486, 487, 452, 489, 475, - /* 1930 */ 522, 430, 478, 432, 514, 288, 482, 483, 484, 485, - /* 1940 */ 486, 487, 455, 489, 544, 318, 313, 315, 386, 538, - /* 1950 */ 475, 537, 20, 478, 121, 291, 387, 482, 483, 484, - /* 1960 */ 485, 486, 487, 111, 489, 481, 190, 430, 373, 530, - /* 1970 */ 513, 392, 392, 448, 448, 430, 475, 430, 444, 478, - /* 1980 */ 430, 386, 430, 482, 483, 484, 485, 486, 487, 373, - /* 1990 */ 489, 499, 410, 392, 386, 392, 430, 430, 111, 22, - /* 2000 */ 517, 38, 386, 430, 519, 375, 430, 430, 373, 414, - /* 2010 */ 419, 430, 458, 385, 430, 430, 430, 392, 378, 430, - /* 2020 */ 430, 386, 430, 430, 379, 430, 467, 432, 430, 408, - /* 2030 */ 414, 474, 408, 416, 533, 430, 430, 430, 371, 430, - /* 2040 */ 430, 430, 430, 430, 430, 408, 430, 393, 432, 414, - /* 2050 */ 0, 0, 0, 449, 0, 45, 37, 234, 37, 37, - /* 2060 */ 37, 234, 0, 37, 449, 430, 37, 432, 452, 234, - /* 2070 */ 475, 37, 0, 478, 234, 1, 0, 482, 483, 484, - /* 2080 */ 485, 486, 487, 37, 489, 0, 491, 452, 22, 0, - /* 2090 */ 37, 475, 0, 19, 478, 37, 229, 0, 482, 483, - /* 2100 */ 484, 485, 486, 487, 215, 489, 0, 215, 209, 35, - /* 2110 */ 475, 216, 207, 478, 0, 0, 0, 482, 483, 484, - /* 2120 */ 485, 486, 487, 203, 489, 51, 202, 0, 0, 49, - /* 2130 */ 152, 49, 0, 37, 60, 61, 62, 63, 373, 65, - /* 2140 */ 0, 0, 37, 0, 51, 0, 45, 49, 0, 0, - /* 2150 */ 0, 386, 0, 49, 0, 373, 0, 0, 0, 0, - /* 2160 */ 170, 37, 0, 170, 0, 0, 0, 0, 386, 0, - /* 2170 */ 373, 0, 0, 0, 0, 0, 0, 0, 0, 414, - /* 2180 */ 0, 0, 0, 386, 110, 0, 0, 113, 0, 0, - /* 2190 */ 0, 49, 45, 0, 0, 430, 414, 432, 0, 0, - /* 2200 */ 0, 0, 0, 0, 0, 22, 0, 152, 151, 150, - /* 2210 */ 0, 414, 430, 0, 432, 0, 65, 22, 50, 145, - /* 2220 */ 50, 0, 0, 0, 37, 65, 65, 430, 65, 432, - /* 2230 */ 22, 0, 0, 37, 42, 51, 0, 0, 0, 42, - /* 2240 */ 475, 198, 37, 478, 0, 33, 37, 482, 483, 484, - /* 2250 */ 485, 486, 487, 37, 489, 0, 42, 475, 51, 42, - /* 2260 */ 478, 373, 51, 189, 482, 483, 484, 485, 486, 487, - /* 2270 */ 196, 489, 475, 45, 386, 478, 49, 14, 49, 482, - /* 2280 */ 483, 484, 485, 486, 487, 0, 489, 42, 373, 215, - /* 2290 */ 43, 0, 49, 0, 0, 42, 0, 49, 0, 0, - /* 2300 */ 0, 386, 414, 373, 0, 37, 73, 51, 42, 0, - /* 2310 */ 37, 51, 42, 0, 37, 51, 386, 42, 430, 0, - /* 2320 */ 432, 37, 51, 42, 373, 0, 0, 0, 0, 414, - /* 2330 */ 0, 0, 37, 22, 0, 117, 0, 386, 119, 37, - /* 2340 */ 37, 33, 37, 37, 414, 430, 22, 432, 0, 37, - /* 2350 */ 0, 37, 37, 37, 37, 33, 0, 37, 37, 22, - /* 2360 */ 430, 22, 432, 475, 22, 414, 478, 0, 22, 37, - /* 2370 */ 482, 483, 484, 485, 486, 487, 53, 489, 37, 0, - /* 2380 */ 0, 430, 373, 432, 37, 0, 37, 0, 22, 20, - /* 2390 */ 475, 37, 37, 478, 37, 386, 0, 482, 483, 484, - /* 2400 */ 485, 486, 487, 111, 489, 475, 0, 49, 478, 112, - /* 2410 */ 219, 187, 482, 483, 484, 485, 486, 487, 111, 489, - /* 2420 */ 37, 187, 22, 414, 22, 190, 475, 0, 0, 478, - /* 2430 */ 0, 33, 3, 482, 483, 484, 485, 486, 487, 430, - /* 2440 */ 489, 432, 373, 194, 214, 220, 187, 112, 187, 210, - /* 2450 */ 295, 194, 187, 37, 111, 386, 112, 37, 50, 50, - /* 2460 */ 107, 373, 111, 111, 33, 33, 33, 49, 109, 33, - /* 2470 */ 49, 79, 112, 112, 386, 112, 373, 112, 33, 111, - /* 2480 */ 37, 111, 111, 414, 475, 111, 111, 478, 112, 386, - /* 2490 */ 112, 482, 483, 484, 485, 486, 487, 3, 489, 430, - /* 2500 */ 33, 432, 414, 37, 49, 37, 37, 37, 373, 37, - /* 2510 */ 37, 112, 33, 112, 49, 0, 0, 414, 430, 279, - /* 2520 */ 432, 386, 111, 42, 33, 2, 109, 22, 266, 243, - /* 2530 */ 111, 109, 49, 430, 111, 432, 111, 295, 112, 22, - /* 2540 */ 0, 295, 49, 42, 475, 49, 112, 478, 111, 414, - /* 2550 */ 111, 482, 483, 484, 485, 486, 487, 111, 489, 112, - /* 2560 */ 111, 189, 112, 475, 246, 430, 478, 432, 111, 111, - /* 2570 */ 482, 483, 484, 485, 486, 487, 112, 489, 475, 191, - /* 2580 */ 120, 478, 121, 112, 22, 482, 483, 484, 485, 486, - /* 2590 */ 487, 111, 489, 373, 112, 111, 111, 111, 111, 111, - /* 2600 */ 111, 22, 22, 37, 112, 37, 386, 112, 111, 220, - /* 2610 */ 475, 37, 112, 478, 373, 111, 33, 482, 483, 484, - /* 2620 */ 485, 486, 487, 37, 489, 112, 37, 386, 37, 37, - /* 2630 */ 112, 373, 112, 111, 414, 132, 111, 37, 132, 132, - /* 2640 */ 132, 111, 22, 73, 386, 72, 37, 37, 37, 37, - /* 2650 */ 430, 37, 432, 373, 37, 414, 37, 79, 37, 37, - /* 2660 */ 37, 37, 105, 79, 105, 33, 386, 37, 37, 22, - /* 2670 */ 37, 430, 414, 432, 37, 37, 37, 79, 37, 37, - /* 2680 */ 37, 37, 37, 22, 0, 37, 37, 51, 430, 0, - /* 2690 */ 432, 37, 42, 42, 414, 475, 0, 51, 478, 37, - /* 2700 */ 42, 0, 482, 483, 484, 485, 486, 487, 51, 489, - /* 2710 */ 430, 37, 432, 42, 51, 0, 475, 37, 373, 478, - /* 2720 */ 37, 0, 22, 482, 483, 484, 485, 486, 487, 22, - /* 2730 */ 489, 386, 33, 475, 21, 21, 478, 373, 22, 22, - /* 2740 */ 482, 483, 484, 485, 486, 487, 20, 489, 545, 545, - /* 2750 */ 386, 545, 545, 545, 545, 475, 545, 373, 478, 414, - /* 2760 */ 545, 545, 482, 483, 484, 485, 486, 487, 545, 489, - /* 2770 */ 386, 545, 545, 545, 545, 430, 373, 432, 414, 545, - /* 2780 */ 545, 545, 545, 545, 545, 545, 545, 545, 545, 386, - /* 2790 */ 545, 545, 545, 545, 430, 545, 432, 373, 414, 545, - /* 2800 */ 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, - /* 2810 */ 386, 545, 545, 545, 430, 545, 432, 414, 545, 545, - /* 2820 */ 475, 545, 545, 478, 545, 545, 545, 482, 483, 484, - /* 2830 */ 485, 486, 487, 430, 489, 432, 545, 545, 414, 475, - /* 2840 */ 545, 545, 478, 545, 545, 545, 482, 483, 484, 485, - /* 2850 */ 486, 487, 545, 489, 430, 545, 432, 545, 545, 475, - /* 2860 */ 545, 545, 478, 373, 545, 545, 482, 483, 484, 485, - /* 2870 */ 486, 487, 545, 489, 545, 545, 386, 545, 475, 545, - /* 2880 */ 545, 478, 545, 545, 545, 482, 483, 484, 485, 486, - /* 2890 */ 487, 545, 489, 545, 545, 545, 545, 545, 545, 475, - /* 2900 */ 545, 545, 478, 545, 414, 545, 482, 483, 484, 485, - /* 2910 */ 486, 487, 545, 489, 545, 545, 545, 545, 545, 545, - /* 2920 */ 430, 545, 432, 545, 545, 545, 545, 545, 545, 545, - /* 2930 */ 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, - /* 2940 */ 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, - /* 2950 */ 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, - /* 2960 */ 545, 545, 545, 545, 545, 475, 545, 545, 478, 545, - /* 2970 */ 545, 545, 482, 483, 484, 485, 486, 487, 545, 489, - /* 2980 */ 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, - /* 2990 */ 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, - /* 3000 */ 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, - /* 3010 */ 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, - /* 3020 */ 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, - /* 3030 */ 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, - /* 3040 */ 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, - /* 3050 */ 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, - /* 3060 */ 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, - /* 3070 */ 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, - /* 3080 */ 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, - /* 3090 */ 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, - /* 3100 */ 545, 545, 545, 545, 545, 545, 545, 545, 545, 545, - /* 3110 */ 545, 545, 545, 545, 545, 545, 545, 370, 370, 370, - /* 3120 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, - /* 3130 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, - /* 3140 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, - /* 3150 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, - /* 3160 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, - /* 3170 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, - /* 3180 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, - /* 3190 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, - /* 3200 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, - /* 3210 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, - /* 3220 */ 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, - /* 3230 */ 370, 370, 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, + /* 260 */ 260, 261, 262, 263, 264, 265, 266, 267, 12, 13, + /* 270 */ 417, 111, 420, 18, 20, 20, 20, 417, 22, 20, + /* 280 */ 195, 196, 27, 388, 389, 30, 433, 0, 435, 190, + /* 290 */ 35, 35, 142, 37, 8, 9, 146, 205, 12, 13, + /* 300 */ 14, 15, 16, 408, 65, 20, 51, 22, 53, 418, + /* 310 */ 415, 8, 9, 58, 59, 12, 13, 14, 15, 16, + /* 320 */ 429, 65, 37, 20, 20, 70, 234, 235, 72, 12, + /* 330 */ 13, 14, 15, 16, 481, 79, 484, 484, 164, 52, + /* 340 */ 55, 488, 489, 490, 491, 492, 493, 495, 495, 110, + /* 350 */ 490, 498, 113, 500, 501, 502, 388, 389, 72, 506, + /* 360 */ 507, 434, 435, 22, 108, 110, 108, 111, 164, 219, + /* 370 */ 111, 42, 293, 417, 224, 0, 121, 227, 37, 229, + /* 380 */ 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, + /* 390 */ 20, 133, 134, 135, 136, 137, 138, 139, 299, 300, + /* 400 */ 301, 302, 4, 147, 148, 119, 151, 152, 71, 154, + /* 410 */ 155, 156, 157, 158, 159, 160, 161, 162, 163, 180, + /* 420 */ 79, 23, 167, 168, 169, 170, 171, 172, 173, 315, + /* 430 */ 175, 176, 177, 222, 478, 479, 181, 182, 183, 185, + /* 440 */ 186, 185, 186, 188, 46, 47, 48, 121, 405, 18, + /* 450 */ 37, 195, 196, 293, 23, 37, 282, 283, 284, 285, + /* 460 */ 286, 287, 288, 289, 290, 409, 210, 268, 212, 397, + /* 470 */ 184, 40, 41, 417, 20, 44, 433, 509, 510, 511, + /* 480 */ 512, 111, 514, 515, 428, 54, 414, 283, 284, 285, + /* 490 */ 187, 431, 121, 164, 434, 435, 424, 66, 67, 68, + /* 500 */ 69, 70, 246, 247, 248, 13, 250, 251, 252, 253, + /* 510 */ 254, 255, 256, 257, 258, 259, 260, 261, 262, 263, + /* 520 */ 264, 265, 266, 267, 268, 12, 13, 484, 485, 486, + /* 530 */ 417, 376, 375, 20, 377, 22, 388, 389, 495, 426, + /* 540 */ 427, 166, 111, 384, 389, 170, 388, 388, 35, 390, + /* 550 */ 37, 248, 293, 178, 388, 389, 408, 271, 272, 273, + /* 560 */ 274, 275, 276, 277, 278, 279, 280, 281, 79, 8, + /* 570 */ 9, 79, 417, 12, 13, 14, 15, 16, 65, 108, + /* 580 */ 149, 370, 371, 372, 20, 72, 56, 57, 433, 34, + /* 590 */ 435, 420, 79, 122, 123, 124, 125, 126, 127, 128, + /* 600 */ 129, 130, 131, 405, 133, 134, 135, 136, 137, 138, + /* 610 */ 139, 282, 283, 284, 285, 286, 287, 288, 289, 290, + /* 620 */ 14, 108, 388, 389, 111, 212, 20, 376, 470, 471, + /* 630 */ 212, 433, 418, 202, 203, 204, 481, 417, 207, 484, + /* 640 */ 389, 187, 408, 488, 489, 490, 491, 492, 493, 415, + /* 650 */ 495, 220, 221, 14, 111, 484, 436, 244, 245, 20, + /* 660 */ 147, 148, 244, 245, 233, 20, 495, 236, 417, 397, + /* 670 */ 239, 240, 241, 242, 243, 395, 510, 511, 512, 111, + /* 680 */ 514, 515, 484, 485, 433, 20, 435, 3, 522, 0, + /* 690 */ 535, 536, 412, 495, 388, 389, 424, 88, 185, 186, + /* 700 */ 418, 421, 514, 20, 20, 22, 540, 541, 195, 196, + /* 710 */ 522, 545, 546, 24, 25, 26, 27, 28, 29, 30, + /* 720 */ 31, 32, 0, 210, 293, 212, 39, 40, 540, 541, + /* 730 */ 388, 389, 481, 545, 546, 484, 388, 389, 55, 488, + /* 740 */ 489, 490, 491, 492, 493, 418, 495, 441, 187, 185, + /* 750 */ 408, 500, 209, 502, 211, 246, 408, 506, 507, 246, + /* 760 */ 247, 248, 153, 250, 251, 252, 253, 254, 255, 256, + /* 770 */ 257, 258, 259, 260, 261, 262, 263, 264, 265, 266, + /* 780 */ 267, 12, 13, 14, 376, 534, 243, 178, 179, 20, + /* 790 */ 418, 22, 147, 148, 184, 418, 112, 389, 499, 391, + /* 800 */ 501, 192, 115, 116, 35, 118, 37, 286, 287, 288, + /* 810 */ 289, 290, 248, 376, 305, 306, 307, 308, 309, 310, + /* 820 */ 311, 417, 388, 389, 185, 417, 389, 140, 391, 425, + /* 830 */ 418, 144, 21, 499, 65, 501, 293, 388, 389, 180, + /* 840 */ 436, 433, 408, 435, 12, 13, 388, 36, 79, 38, + /* 850 */ 39, 40, 8, 9, 417, 388, 12, 13, 14, 15, + /* 860 */ 16, 293, 140, 141, 142, 143, 144, 145, 146, 37, + /* 870 */ 433, 187, 435, 214, 388, 389, 417, 108, 141, 142, + /* 880 */ 111, 271, 14, 146, 425, 395, 460, 248, 20, 481, + /* 890 */ 441, 281, 484, 466, 408, 436, 488, 489, 490, 491, + /* 900 */ 492, 493, 0, 495, 514, 447, 50, 449, 500, 0, + /* 910 */ 502, 421, 522, 248, 506, 507, 147, 148, 481, 452, + /* 920 */ 453, 484, 388, 389, 141, 488, 489, 490, 491, 492, + /* 930 */ 493, 541, 495, 388, 389, 545, 546, 500, 409, 502, + /* 940 */ 514, 111, 408, 506, 507, 418, 417, 268, 522, 270, + /* 950 */ 12, 13, 0, 408, 185, 186, 112, 428, 33, 373, + /* 960 */ 22, 376, 388, 389, 195, 196, 540, 541, 388, 389, + /* 970 */ 45, 545, 546, 35, 377, 37, 74, 75, 76, 210, + /* 980 */ 71, 212, 408, 81, 82, 83, 460, 20, 408, 87, + /* 990 */ 388, 389, 388, 389, 92, 93, 94, 95, 376, 22, + /* 1000 */ 98, 388, 376, 65, 102, 103, 104, 480, 225, 226, + /* 1010 */ 408, 389, 408, 391, 37, 246, 247, 248, 433, 250, + /* 1020 */ 251, 252, 253, 254, 255, 256, 257, 258, 259, 260, + /* 1030 */ 261, 262, 263, 264, 265, 266, 267, 12, 13, 417, + /* 1040 */ 514, 388, 389, 187, 212, 20, 460, 22, 522, 33, + /* 1050 */ 376, 465, 487, 185, 198, 433, 79, 435, 417, 433, + /* 1060 */ 35, 408, 37, 389, 23, 391, 540, 541, 376, 8, + /* 1070 */ 9, 545, 546, 12, 13, 14, 15, 16, 513, 388, + /* 1080 */ 389, 1, 2, 470, 471, 108, 445, 13, 47, 48, + /* 1090 */ 65, 417, 140, 141, 142, 143, 144, 145, 146, 408, + /* 1100 */ 514, 388, 389, 481, 79, 0, 484, 433, 522, 435, + /* 1110 */ 488, 489, 490, 491, 492, 493, 248, 495, 406, 388, + /* 1120 */ 389, 408, 500, 293, 502, 433, 540, 541, 506, 507, + /* 1130 */ 20, 545, 546, 108, 376, 0, 111, 8, 9, 408, + /* 1140 */ 4, 12, 13, 14, 15, 16, 13, 389, 210, 391, + /* 1150 */ 212, 388, 389, 79, 187, 481, 376, 417, 484, 388, + /* 1160 */ 389, 376, 488, 489, 490, 491, 492, 493, 72, 495, + /* 1170 */ 37, 408, 147, 148, 500, 417, 502, 388, 389, 408, + /* 1180 */ 506, 507, 244, 245, 246, 388, 389, 210, 376, 212, + /* 1190 */ 37, 433, 112, 435, 388, 389, 487, 408, 260, 261, + /* 1200 */ 262, 263, 264, 265, 266, 408, 14, 15, 16, 417, + /* 1210 */ 185, 186, 22, 433, 408, 248, 417, 425, 433, 479, + /* 1220 */ 195, 196, 513, 246, 247, 514, 427, 37, 436, 549, + /* 1230 */ 388, 389, 79, 522, 413, 210, 20, 212, 33, 481, + /* 1240 */ 417, 112, 484, 393, 394, 433, 488, 489, 490, 491, + /* 1250 */ 492, 493, 541, 495, 376, 376, 545, 546, 500, 436, + /* 1260 */ 502, 402, 403, 202, 506, 507, 376, 389, 20, 391, + /* 1270 */ 140, 246, 247, 248, 144, 250, 251, 252, 253, 254, + /* 1280 */ 255, 256, 257, 258, 259, 260, 261, 262, 263, 264, + /* 1290 */ 265, 266, 267, 12, 13, 417, 475, 187, 108, 164, + /* 1300 */ 165, 20, 430, 22, 376, 433, 514, 33, 376, 393, + /* 1310 */ 394, 433, 433, 435, 522, 417, 35, 112, 37, 376, + /* 1320 */ 460, 402, 403, 433, 12, 13, 428, 379, 380, 376, + /* 1330 */ 376, 376, 540, 541, 22, 319, 376, 545, 546, 376, + /* 1340 */ 376, 376, 246, 238, 389, 376, 65, 35, 430, 37, + /* 1350 */ 0, 433, 510, 511, 512, 121, 514, 515, 248, 481, + /* 1360 */ 79, 433, 484, 0, 4, 433, 488, 489, 490, 491, + /* 1370 */ 492, 493, 417, 495, 514, 417, 433, 65, 500, 19, + /* 1380 */ 502, 320, 522, 33, 506, 507, 433, 433, 433, 108, + /* 1390 */ 435, 79, 111, 433, 436, 35, 433, 433, 433, 376, + /* 1400 */ 540, 541, 433, 33, 430, 545, 546, 433, 174, 460, + /* 1410 */ 410, 51, 389, 413, 51, 45, 0, 37, 58, 59, + /* 1420 */ 108, 114, 33, 33, 117, 65, 0, 114, 147, 148, + /* 1430 */ 117, 295, 114, 446, 114, 117, 481, 117, 22, 484, + /* 1440 */ 417, 13, 33, 488, 489, 490, 491, 492, 493, 228, + /* 1450 */ 495, 230, 65, 147, 148, 500, 433, 502, 435, 79, + /* 1460 */ 111, 506, 507, 514, 248, 37, 185, 186, 42, 120, + /* 1470 */ 110, 522, 516, 113, 33, 33, 195, 196, 140, 141, + /* 1480 */ 142, 143, 144, 145, 146, 33, 33, 33, 49, 540, + /* 1490 */ 541, 210, 33, 212, 545, 546, 248, 1, 2, 37, + /* 1500 */ 113, 112, 112, 531, 481, 33, 37, 484, 0, 33, + /* 1510 */ 376, 488, 489, 490, 491, 492, 493, 494, 495, 496, + /* 1520 */ 497, 112, 210, 389, 212, 33, 33, 246, 247, 248, + /* 1530 */ 22, 250, 251, 252, 253, 254, 255, 256, 257, 258, + /* 1540 */ 259, 260, 261, 262, 263, 264, 265, 266, 267, 376, + /* 1550 */ 111, 417, 33, 112, 112, 538, 33, 517, 246, 247, + /* 1560 */ 0, 0, 389, 13, 112, 112, 112, 433, 392, 435, + /* 1570 */ 33, 112, 260, 261, 262, 263, 264, 265, 266, 33, + /* 1580 */ 376, 417, 22, 22, 112, 12, 13, 37, 112, 405, + /* 1590 */ 417, 317, 33, 389, 405, 12, 13, 12, 13, 12, + /* 1600 */ 13, 12, 13, 33, 112, 112, 433, 33, 435, 12, + /* 1610 */ 13, 12, 13, 12, 13, 481, 446, 387, 484, 376, + /* 1620 */ 446, 417, 488, 489, 490, 491, 492, 493, 37, 495, + /* 1630 */ 37, 112, 389, 33, 500, 112, 502, 433, 537, 435, + /* 1640 */ 506, 507, 12, 13, 12, 13, 376, 12, 13, 112, + /* 1650 */ 537, 537, 459, 13, 481, 537, 392, 484, 112, 389, + /* 1660 */ 417, 488, 489, 490, 491, 492, 493, 389, 495, 446, + /* 1670 */ 79, 112, 79, 500, 212, 502, 433, 37, 435, 506, + /* 1680 */ 507, 212, 112, 432, 467, 481, 112, 417, 484, 521, + /* 1690 */ 446, 446, 488, 489, 490, 491, 492, 493, 521, 495, + /* 1700 */ 542, 407, 508, 433, 524, 435, 502, 1, 296, 51, + /* 1710 */ 506, 507, 112, 461, 483, 42, 20, 482, 472, 477, + /* 1720 */ 397, 227, 472, 397, 481, 19, 208, 484, 463, 20, + /* 1730 */ 388, 488, 489, 490, 491, 492, 493, 20, 495, 45, + /* 1740 */ 389, 35, 442, 389, 442, 502, 184, 439, 389, 506, + /* 1750 */ 507, 481, 388, 388, 484, 439, 442, 51, 488, 489, + /* 1760 */ 490, 491, 492, 493, 439, 495, 60, 61, 62, 63, + /* 1770 */ 439, 65, 502, 109, 401, 107, 506, 507, 400, 388, + /* 1780 */ 388, 106, 399, 388, 388, 388, 20, 381, 50, 385, + /* 1790 */ 385, 381, 20, 472, 20, 397, 397, 435, 397, 20, + /* 1800 */ 397, 390, 462, 390, 397, 20, 453, 20, 35, 388, + /* 1810 */ 381, 397, 397, 376, 447, 397, 110, 397, 433, 113, + /* 1820 */ 476, 381, 388, 379, 51, 417, 389, 379, 472, 231, + /* 1830 */ 111, 474, 376, 60, 61, 62, 63, 20, 65, 417, + /* 1840 */ 417, 417, 417, 471, 417, 389, 395, 417, 417, 417, + /* 1850 */ 417, 145, 417, 216, 417, 469, 468, 215, 395, 388, + /* 1860 */ 304, 461, 530, 530, 312, 530, 303, 533, 201, 433, + /* 1870 */ 433, 433, 435, 417, 529, 532, 528, 313, 435, 433, + /* 1880 */ 314, 297, 527, 110, 292, 519, 113, 291, 520, 433, + /* 1890 */ 321, 435, 389, 376, 318, 189, 550, 191, 316, 454, + /* 1900 */ 194, 454, 544, 20, 543, 199, 389, 121, 294, 525, + /* 1910 */ 461, 390, 454, 433, 433, 395, 523, 395, 481, 433, + /* 1920 */ 376, 484, 433, 433, 218, 488, 489, 490, 491, 492, + /* 1930 */ 493, 454, 495, 389, 417, 193, 451, 481, 395, 433, + /* 1940 */ 484, 111, 487, 395, 488, 489, 490, 491, 492, 493, + /* 1950 */ 433, 495, 435, 180, 447, 505, 193, 433, 502, 448, + /* 1960 */ 447, 417, 189, 507, 413, 433, 193, 194, 433, 433, + /* 1970 */ 376, 433, 199, 200, 395, 395, 111, 433, 433, 435, + /* 1980 */ 433, 22, 433, 389, 547, 548, 433, 433, 433, 422, + /* 1990 */ 433, 218, 389, 388, 378, 38, 480, 395, 481, 382, + /* 2000 */ 376, 484, 458, 381, 433, 488, 489, 490, 491, 492, + /* 2010 */ 493, 417, 495, 389, 433, 473, 0, 376, 374, 433, + /* 2020 */ 455, 433, 464, 433, 396, 481, 0, 433, 484, 435, + /* 2030 */ 389, 411, 488, 489, 490, 491, 492, 493, 376, 495, + /* 2040 */ 433, 417, 433, 433, 433, 433, 433, 411, 433, 411, + /* 2050 */ 455, 389, 458, 536, 0, 45, 0, 433, 417, 435, + /* 2060 */ 37, 237, 419, 237, 37, 37, 37, 0, 37, 37, + /* 2070 */ 237, 37, 0, 237, 433, 481, 435, 0, 484, 417, + /* 2080 */ 376, 37, 488, 489, 490, 491, 492, 493, 0, 495, + /* 2090 */ 37, 0, 22, 389, 0, 433, 37, 435, 232, 0, + /* 2100 */ 218, 0, 212, 218, 210, 481, 219, 0, 484, 0, + /* 2110 */ 0, 206, 488, 489, 490, 491, 492, 493, 205, 495, + /* 2120 */ 0, 417, 481, 0, 152, 484, 0, 376, 49, 488, + /* 2130 */ 489, 490, 491, 492, 493, 49, 495, 433, 0, 435, + /* 2140 */ 389, 37, 0, 481, 51, 37, 484, 0, 0, 49, + /* 2150 */ 488, 489, 490, 491, 492, 493, 45, 495, 0, 497, + /* 2160 */ 0, 0, 458, 539, 49, 0, 0, 0, 417, 0, + /* 2170 */ 0, 0, 170, 37, 0, 170, 0, 0, 0, 0, + /* 2180 */ 0, 0, 0, 0, 433, 481, 435, 0, 484, 548, + /* 2190 */ 376, 0, 488, 489, 490, 491, 492, 493, 0, 495, + /* 2200 */ 0, 0, 0, 389, 0, 0, 0, 0, 0, 458, + /* 2210 */ 376, 49, 0, 45, 0, 0, 0, 0, 0, 0, + /* 2220 */ 0, 0, 0, 389, 151, 22, 0, 0, 152, 0, + /* 2230 */ 150, 417, 481, 0, 0, 484, 50, 0, 50, 488, + /* 2240 */ 489, 490, 491, 492, 493, 22, 495, 433, 0, 435, + /* 2250 */ 22, 417, 0, 0, 65, 65, 0, 65, 0, 65, + /* 2260 */ 376, 51, 37, 0, 51, 0, 0, 433, 37, 435, + /* 2270 */ 0, 14, 42, 389, 42, 37, 37, 37, 42, 33, + /* 2280 */ 0, 0, 0, 42, 0, 0, 51, 45, 201, 0, + /* 2290 */ 0, 0, 43, 49, 49, 481, 49, 376, 484, 49, + /* 2300 */ 49, 417, 488, 489, 490, 491, 492, 493, 0, 495, + /* 2310 */ 389, 42, 0, 42, 0, 481, 37, 433, 484, 435, + /* 2320 */ 42, 376, 488, 489, 490, 491, 492, 493, 73, 495, + /* 2330 */ 0, 37, 0, 37, 389, 42, 0, 51, 417, 51, + /* 2340 */ 376, 42, 37, 51, 42, 0, 51, 0, 0, 0, + /* 2350 */ 0, 0, 37, 389, 433, 22, 435, 0, 37, 37, + /* 2360 */ 37, 37, 417, 37, 37, 481, 37, 33, 484, 0, + /* 2370 */ 33, 117, 488, 489, 490, 491, 492, 493, 433, 495, + /* 2380 */ 435, 417, 376, 119, 22, 22, 0, 22, 0, 37, + /* 2390 */ 37, 53, 37, 37, 22, 389, 37, 433, 0, 435, + /* 2400 */ 22, 37, 481, 0, 0, 484, 376, 0, 37, 488, + /* 2410 */ 489, 490, 491, 492, 493, 22, 495, 0, 0, 389, + /* 2420 */ 37, 20, 37, 417, 37, 112, 481, 37, 111, 484, + /* 2430 */ 0, 111, 223, 488, 489, 490, 491, 492, 493, 433, + /* 2440 */ 495, 435, 37, 49, 0, 481, 187, 417, 484, 187, + /* 2450 */ 22, 376, 488, 489, 490, 491, 492, 493, 0, 495, + /* 2460 */ 22, 193, 187, 433, 389, 435, 0, 0, 33, 197, + /* 2470 */ 187, 3, 376, 197, 187, 50, 37, 111, 217, 112, + /* 2480 */ 213, 111, 222, 298, 37, 389, 112, 481, 111, 376, + /* 2490 */ 484, 109, 417, 50, 488, 489, 490, 491, 492, 493, + /* 2500 */ 111, 495, 389, 107, 112, 33, 33, 112, 433, 112, + /* 2510 */ 435, 481, 33, 417, 484, 33, 79, 111, 488, 489, + /* 2520 */ 490, 491, 492, 493, 111, 495, 49, 49, 112, 433, + /* 2530 */ 417, 435, 111, 33, 111, 37, 112, 3, 112, 33, + /* 2540 */ 49, 37, 37, 112, 37, 37, 433, 37, 435, 37, + /* 2550 */ 33, 49, 112, 0, 0, 42, 481, 111, 190, 484, + /* 2560 */ 112, 112, 111, 488, 489, 490, 491, 492, 493, 376, + /* 2570 */ 495, 298, 111, 111, 0, 298, 0, 481, 42, 282, + /* 2580 */ 484, 112, 389, 42, 488, 489, 490, 491, 492, 493, + /* 2590 */ 190, 495, 111, 194, 481, 33, 109, 484, 189, 109, + /* 2600 */ 376, 488, 489, 490, 491, 492, 493, 2, 495, 269, + /* 2610 */ 417, 22, 111, 389, 49, 49, 22, 0, 49, 376, + /* 2620 */ 111, 246, 249, 112, 190, 111, 433, 112, 435, 111, + /* 2630 */ 111, 111, 389, 112, 111, 42, 112, 111, 111, 37, + /* 2640 */ 112, 417, 111, 111, 111, 120, 111, 22, 22, 112, + /* 2650 */ 376, 111, 22, 111, 132, 223, 112, 433, 37, 435, + /* 2660 */ 417, 111, 111, 389, 121, 37, 37, 112, 112, 112, + /* 2670 */ 37, 112, 37, 112, 481, 37, 433, 484, 435, 132, + /* 2680 */ 376, 488, 489, 490, 491, 492, 493, 33, 495, 111, + /* 2690 */ 132, 417, 132, 389, 111, 37, 111, 22, 37, 37, + /* 2700 */ 73, 37, 37, 72, 37, 481, 37, 433, 484, 435, + /* 2710 */ 37, 37, 488, 489, 490, 491, 492, 493, 37, 495, + /* 2720 */ 37, 417, 37, 79, 481, 105, 79, 484, 105, 33, + /* 2730 */ 376, 488, 489, 490, 491, 492, 493, 433, 495, 435, + /* 2740 */ 37, 37, 37, 389, 22, 37, 37, 37, 37, 79, + /* 2750 */ 37, 37, 37, 37, 22, 481, 37, 376, 484, 0, + /* 2760 */ 37, 0, 488, 489, 490, 491, 492, 493, 51, 495, + /* 2770 */ 389, 417, 42, 37, 0, 51, 42, 37, 51, 42, + /* 2780 */ 0, 37, 51, 42, 0, 481, 37, 433, 484, 435, + /* 2790 */ 37, 376, 488, 489, 490, 491, 492, 493, 417, 495, + /* 2800 */ 0, 22, 33, 22, 389, 22, 21, 20, 22, 21, + /* 2810 */ 551, 551, 551, 551, 433, 551, 435, 551, 376, 551, + /* 2820 */ 551, 551, 551, 551, 551, 551, 551, 551, 551, 551, + /* 2830 */ 551, 389, 417, 551, 551, 481, 551, 551, 484, 551, + /* 2840 */ 551, 376, 488, 489, 490, 491, 492, 493, 433, 495, + /* 2850 */ 435, 551, 551, 551, 389, 551, 551, 551, 551, 417, + /* 2860 */ 551, 551, 481, 551, 551, 484, 551, 551, 551, 488, + /* 2870 */ 489, 490, 491, 492, 493, 433, 495, 435, 551, 376, + /* 2880 */ 551, 551, 417, 551, 551, 551, 551, 551, 551, 551, + /* 2890 */ 551, 551, 389, 551, 551, 551, 481, 551, 433, 484, + /* 2900 */ 435, 551, 551, 488, 489, 490, 491, 492, 493, 551, + /* 2910 */ 495, 551, 551, 551, 551, 551, 551, 551, 551, 551, + /* 2920 */ 417, 551, 551, 481, 551, 551, 484, 551, 551, 551, + /* 2930 */ 488, 489, 490, 491, 492, 493, 433, 495, 435, 551, + /* 2940 */ 551, 551, 551, 551, 551, 551, 481, 551, 551, 484, + /* 2950 */ 551, 551, 551, 488, 489, 490, 491, 492, 493, 551, + /* 2960 */ 495, 551, 551, 551, 551, 551, 551, 551, 551, 551, + /* 2970 */ 551, 551, 551, 551, 551, 551, 551, 551, 551, 551, + /* 2980 */ 551, 551, 551, 551, 481, 551, 551, 484, 551, 551, + /* 2990 */ 551, 488, 489, 490, 491, 492, 493, 551, 495, 551, + /* 3000 */ 551, 551, 551, 551, 551, 551, 551, 551, 551, 551, + /* 3010 */ 551, 551, 551, 551, 551, 551, 551, 551, 551, 551, + /* 3020 */ 551, 551, 551, 551, 551, 551, 551, 551, 551, 551, + /* 3030 */ 551, 551, 551, 551, 551, 551, 551, 551, 551, 551, + /* 3040 */ 551, 551, 551, 551, 551, 551, 551, 551, 551, 551, + /* 3050 */ 551, 551, 551, 551, 551, 551, 551, 551, 551, 551, + /* 3060 */ 551, 551, 551, 551, 551, 551, 551, 551, 551, 551, + /* 3070 */ 551, 551, 551, 551, 551, 551, 551, 551, 551, 551, + /* 3080 */ 551, 551, 551, 551, 551, 551, 551, 551, 551, 551, + /* 3090 */ 551, 551, 551, 551, 551, 551, 551, 551, 551, 551, + /* 3100 */ 551, 551, 551, 551, 551, 551, 551, 551, 551, 551, + /* 3110 */ 551, 551, 551, 551, 551, 551, 551, 551, 551, 551, + /* 3120 */ 551, 551, 551, 551, 551, 551, 551, 551, 551, 551, + /* 3130 */ 551, 551, 551, 551, 551, 551, 551, 551, 551, 551, + /* 3140 */ 551, 551, 551, 551, 551, 551, 551, 551, 551, 551, + /* 3150 */ 551, 551, 551, 551, 551, 551, 551, 551, 551, 551, + /* 3160 */ 551, 551, 551, 551, 551, 551, 551, 551, 551, 551, + /* 3170 */ 551, 551, 551, 551, 551, 551, 551, 551, 551, 551, + /* 3180 */ 551, 551, 551, 373, 373, 373, 373, 373, 373, 373, + /* 3190 */ 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, + /* 3200 */ 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, + /* 3210 */ 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, + /* 3220 */ 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, + /* 3230 */ 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, + /* 3240 */ 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, + /* 3250 */ 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, + /* 3260 */ 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, + /* 3270 */ 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, + /* 3280 */ 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, + /* 3290 */ 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, + /* 3300 */ 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, + /* 3310 */ 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, + /* 3320 */ 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, + /* 3330 */ 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, + /* 3340 */ 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, + /* 3350 */ 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, + /* 3360 */ 373, 373, 373, 373, 373, 373, 373, 373, 373, 373, + /* 3370 */ 373, 373, }; -#define YY_SHIFT_COUNT (925) +#define YY_SHIFT_COUNT (955) #define YY_SHIFT_MIN (0) -#define YY_SHIFT_MAX (2726) +#define YY_SHIFT_MAX (2800) static const unsigned short int yy_shift_ofst[] = { - /* 0 */ 1028, 0, 80, 0, 334, 334, 334, 334, 334, 334, - /* 10 */ 334, 334, 334, 334, 334, 334, 414, 494, 494, 747, - /* 20 */ 494, 494, 494, 494, 494, 494, 494, 494, 494, 494, - /* 30 */ 494, 494, 494, 494, 494, 494, 494, 494, 494, 494, - /* 40 */ 494, 494, 494, 494, 494, 494, 494, 494, 494, 494, - /* 50 */ 118, 417, 579, 71, 324, 419, 324, 324, 71, 71, - /* 60 */ 324, 1212, 324, 746, 1212, 679, 324, 76, 1107, 263, - /* 70 */ 83, 83, 1107, 1107, 1193, 1193, 263, 133, 680, 170, - /* 80 */ 170, 411, 83, 83, 83, 83, 83, 83, 83, 83, - /* 90 */ 83, 83, 83, 221, 302, 83, 83, 291, 76, 83, - /* 100 */ 221, 83, 76, 83, 83, 76, 83, 83, 76, 83, - /* 110 */ 76, 76, 76, 83, 299, 38, 38, 257, 257, 588, - /* 120 */ 868, 204, 250, 856, 856, 856, 856, 856, 856, 856, - /* 130 */ 856, 856, 856, 856, 856, 856, 856, 856, 856, 856, - /* 140 */ 856, 856, 393, 460, 133, 680, 1001, 1001, 247, 599, - /* 150 */ 599, 599, 535, 535, 887, 497, 247, 291, 76, 561, - /* 160 */ 76, 424, 76, 76, 76, 820, 76, 820, 820, 861, - /* 170 */ 9, 257, 257, 257, 257, 257, 257, 770, 2074, 523, - /* 180 */ 616, 138, 138, 489, 578, 341, 366, 114, 23, 41, - /* 190 */ 804, 435, 435, 446, 790, 743, 478, 478, 478, 655, - /* 200 */ 626, 478, 1121, 846, 751, 735, 1238, 846, 846, 1081, - /* 210 */ 1122, 1122, 1148, 610, 562, 497, 1437, 1682, 1695, 1720, - /* 220 */ 1518, 291, 1720, 291, 1544, 1728, 1732, 1711, 1732, 1711, - /* 230 */ 1575, 1728, 1732, 1728, 1711, 1575, 1575, 1575, 1674, 1673, - /* 240 */ 1728, 1728, 1694, 1728, 1728, 1728, 1793, 1766, 1793, 1766, - /* 250 */ 1720, 291, 291, 1804, 291, 1808, 1811, 291, 1808, 291, - /* 260 */ 1814, 291, 291, 1728, 291, 1793, 76, 76, 76, 76, - /* 270 */ 76, 76, 76, 76, 76, 76, 76, 1728, 9, 9, - /* 280 */ 1793, 820, 820, 820, 1626, 1748, 1720, 299, 1846, 1670, - /* 290 */ 1679, 1804, 299, 1437, 1728, 820, 1594, 1599, 1594, 1599, - /* 300 */ 1587, 1706, 1594, 1600, 1602, 1619, 1437, 1629, 1647, 1627, - /* 310 */ 1632, 1633, 1732, 1932, 1833, 1664, 1808, 299, 299, 1852, - /* 320 */ 1599, 820, 820, 820, 820, 1599, 820, 1776, 299, 861, - /* 330 */ 299, 1732, 820, 820, 820, 820, 820, 820, 820, 820, - /* 340 */ 820, 820, 820, 820, 820, 820, 820, 820, 820, 820, - /* 350 */ 820, 820, 820, 820, 1887, 820, 1728, 299, 1977, 1963, - /* 360 */ 1793, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, 2980, - /* 370 */ 2980, 2980, 941, 1666, 58, 1052, 186, 780, 971, 1100, - /* 380 */ 1205, 1267, 981, 1192, 1344, 1344, 1344, 1344, 1344, 1344, - /* 390 */ 1344, 1344, 1344, 232, 924, 59, 388, 388, 36, 54, - /* 400 */ 889, 389, 300, 249, 188, 566, 249, 968, 1247, 1303, - /* 410 */ 1037, 716, 1234, 1094, 716, 716, 716, 20, 20, 648, - /* 420 */ 740, 1368, 1248, 1419, 49, 1428, 1362, 1382, 1384, 1391, - /* 430 */ 1260, 691, 1450, 1064, 1445, 1482, 1512, 1199, 1432, 1452, - /* 440 */ 1173, 1461, 1476, 1477, 1494, 1381, 100, 1271, 1502, 1548, - /* 450 */ 1505, 921, 1507, 1434, 1508, 1519, 1527, 1536, 1542, 1543, - /* 460 */ 1555, 1568, 1572, 1583, 1588, 1596, 1620, 1639, 1661, 1665, - /* 470 */ 1558, 1571, 1574, 1578, 1597, 1642, 1517, 1631, 1441, 1478, - /* 480 */ 1669, 1671, 1634, 1561, 2050, 2051, 2052, 2010, 2054, 2019, - /* 490 */ 1823, 2021, 2022, 2023, 1827, 2062, 2026, 2029, 1835, 2034, - /* 500 */ 2072, 1840, 2076, 2046, 2085, 2053, 2092, 2066, 2089, 2058, - /* 510 */ 1867, 2097, 1889, 2106, 1892, 1895, 1899, 1905, 2114, 2115, - /* 520 */ 2116, 1920, 1924, 2127, 2128, 1978, 2080, 2082, 2132, 2096, - /* 530 */ 2140, 2141, 2105, 2093, 2143, 2098, 2145, 2101, 2148, 2149, - /* 540 */ 2150, 2104, 2152, 2154, 2156, 2157, 2158, 2159, 1990, 2124, - /* 550 */ 2162, 1993, 2164, 2165, 2166, 2167, 2169, 2171, 2172, 2173, - /* 560 */ 2174, 2175, 2176, 2177, 2178, 2180, 2181, 2182, 2185, 2186, - /* 570 */ 2188, 2142, 2189, 2147, 2190, 2193, 2194, 2198, 2199, 2200, - /* 580 */ 2201, 2202, 2183, 2203, 2055, 2204, 2057, 2206, 2059, 2210, - /* 590 */ 2213, 2195, 2168, 2208, 2170, 2215, 2151, 2221, 2160, 2187, - /* 600 */ 2222, 2161, 2223, 2163, 2231, 2232, 2196, 2184, 2192, 2236, - /* 610 */ 2205, 2207, 2197, 2237, 2209, 2211, 2214, 2238, 2216, 2244, - /* 620 */ 2228, 2217, 2212, 2227, 2229, 2263, 2243, 2255, 2247, 2245, - /* 630 */ 2285, 2291, 2293, 2294, 2253, 2043, 2296, 2227, 2248, 2298, - /* 640 */ 2299, 2233, 2300, 2304, 2268, 2256, 2266, 2309, 2273, 2260, - /* 650 */ 2270, 2313, 2277, 2264, 2275, 2319, 2284, 2271, 2281, 2325, - /* 660 */ 2326, 2327, 2328, 2330, 2331, 2219, 2218, 2295, 2311, 2334, - /* 670 */ 2302, 2303, 2305, 2306, 2312, 2314, 2315, 2316, 2317, 2308, - /* 680 */ 2322, 2320, 2321, 2324, 2332, 2336, 2337, 2348, 2339, 2350, - /* 690 */ 2342, 2323, 2356, 2346, 2341, 2367, 2379, 2380, 2347, 2385, - /* 700 */ 2349, 2387, 2366, 2369, 2354, 2355, 2357, 2297, 2292, 2396, - /* 710 */ 2224, 2225, 2191, 2307, 2230, 2227, 2358, 2406, 2234, 2383, - /* 720 */ 2400, 2427, 2239, 2402, 2259, 2235, 2428, 2430, 2261, 2249, - /* 730 */ 2265, 2257, 2429, 2398, 2155, 2343, 2335, 2351, 2344, 2416, - /* 740 */ 2420, 2352, 2408, 2359, 2409, 2353, 2360, 2431, 2432, 2361, - /* 750 */ 2368, 2370, 2371, 2363, 2433, 2418, 2421, 2374, 2436, 2242, - /* 760 */ 2392, 2365, 2445, 2375, 2443, 2376, 2378, 2494, 2467, 2246, - /* 770 */ 2466, 2468, 2469, 2470, 2472, 2473, 2399, 2401, 2455, 2240, - /* 780 */ 2479, 2465, 2515, 2516, 2411, 2481, 2491, 2417, 2262, 2422, - /* 790 */ 2523, 2505, 2286, 2426, 2434, 2419, 2423, 2425, 2437, 2439, - /* 800 */ 2447, 2483, 2446, 2449, 2493, 2450, 2517, 2318, 2457, 2464, - /* 810 */ 2471, 2458, 2480, 2388, 2484, 2540, 2501, 2372, 2485, 2460, - /* 820 */ 2227, 2496, 2486, 2487, 2482, 2488, 2489, 2461, 2562, 2579, - /* 830 */ 2580, 2389, 2492, 2566, 2568, 2497, 2495, 2574, 2504, 2500, - /* 840 */ 2586, 2419, 2513, 2589, 2423, 2518, 2591, 2425, 2520, 2592, - /* 850 */ 2437, 2503, 2506, 2507, 2508, 2522, 2583, 2525, 2600, 2530, - /* 860 */ 2583, 2583, 2620, 2570, 2573, 2609, 2610, 2611, 2612, 2614, - /* 870 */ 2617, 2619, 2621, 2622, 2623, 2624, 2578, 2557, 2584, 2559, - /* 880 */ 2632, 2630, 2631, 2633, 2647, 2637, 2638, 2639, 2598, 2308, - /* 890 */ 2641, 2322, 2642, 2643, 2644, 2645, 2661, 2648, 2684, 2649, - /* 900 */ 2636, 2650, 2689, 2654, 2646, 2651, 2696, 2662, 2657, 2658, - /* 910 */ 2701, 2674, 2663, 2671, 2715, 2680, 2683, 2721, 2700, 2699, - /* 920 */ 2707, 2713, 2716, 2717, 2714, 2726, + /* 0 */ 431, 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 */ 79, 259, 543, 370, 568, 830, 568, 568, 370, 370, + /* 60 */ 568, 1312, 568, 255, 1312, 160, 568, 5, 938, 85, + /* 70 */ 85, 14, 14, 938, 938, 398, 398, 85, 254, 645, + /* 80 */ 130, 130, 665, 14, 14, 14, 14, 14, 14, 14, + /* 90 */ 14, 14, 14, 14, 49, 203, 304, 14, 14, 169, + /* 100 */ 5, 14, 49, 14, 5, 14, 14, 14, 14, 5, + /* 110 */ 14, 14, 5, 14, 5, 5, 5, 14, 337, 286, + /* 120 */ 286, 258, 258, 471, 132, 329, 149, 977, 977, 977, + /* 130 */ 977, 977, 977, 977, 977, 977, 977, 977, 977, 977, + /* 140 */ 977, 977, 977, 977, 977, 977, 687, 684, 254, 645, + /* 150 */ 530, 530, 1153, 454, 454, 454, 679, 679, 909, 492, + /* 160 */ 1153, 169, 5, 326, 5, 5, 199, 5, 5, 489, + /* 170 */ 5, 489, 489, 371, 555, 258, 258, 258, 258, 258, + /* 180 */ 258, 1706, 902, 21, 303, 174, 174, 1061, 509, 99, + /* 190 */ 521, 285, 204, 639, 868, 832, 832, 967, 1041, 1110, + /* 200 */ 341, 341, 341, 856, 341, 564, 683, 1216, 606, 1130, + /* 210 */ 659, 1216, 1216, 1248, 1074, 1074, 114, 925, 1136, 492, + /* 220 */ 1412, 1658, 1673, 1696, 1494, 169, 1696, 169, 1518, 1709, + /* 230 */ 1717, 1694, 1717, 1694, 1562, 1709, 1717, 1709, 1694, 1562, + /* 240 */ 1562, 1562, 1664, 1668, 1709, 1709, 1675, 1709, 1709, 1709, + /* 250 */ 1766, 1738, 1766, 1738, 1696, 169, 169, 1772, 169, 1774, + /* 260 */ 1779, 169, 1774, 169, 1785, 169, 1787, 169, 169, 1709, + /* 270 */ 169, 1766, 5, 5, 5, 5, 5, 5, 5, 5, + /* 280 */ 5, 5, 5, 1709, 555, 555, 1766, 489, 489, 489, + /* 290 */ 1598, 1719, 1696, 337, 1817, 1637, 1642, 1772, 337, 1412, + /* 300 */ 1709, 489, 1556, 1563, 1556, 1563, 1552, 1667, 1556, 1566, + /* 310 */ 1564, 1584, 1412, 1592, 1596, 1569, 1576, 1582, 1717, 1883, + /* 320 */ 1786, 1614, 1774, 337, 337, 1563, 489, 489, 489, 489, + /* 330 */ 1563, 489, 1742, 337, 489, 1787, 337, 1830, 489, 1763, + /* 340 */ 1787, 337, 371, 337, 1717, 489, 489, 489, 489, 489, + /* 350 */ 489, 489, 489, 489, 489, 489, 489, 489, 489, 489, + /* 360 */ 489, 489, 489, 489, 489, 489, 489, 1865, 489, 1709, + /* 370 */ 337, 1959, 1957, 1766, 2999, 2999, 2999, 2999, 2999, 2999, + /* 380 */ 2999, 2999, 2999, 2999, 2999, 38, 1773, 689, 1360, 47, + /* 390 */ 844, 1129, 15, 62, 561, 722, 952, 189, 189, 189, + /* 400 */ 189, 189, 189, 189, 189, 189, 1338, 150, 609, 811, + /* 410 */ 317, 317, 92, 239, 375, 46, 211, 413, 418, 211, + /* 420 */ 1135, 129, 1190, 783, 737, 737, 1192, 1080, 610, 1192, + /* 430 */ 1192, 1192, 1363, 1105, 1205, 1426, 1370, 1234, 1350, 1307, + /* 440 */ 1313, 1318, 1320, 1380, 1133, 1428, 1416, 1508, 1560, 1561, + /* 450 */ 1221, 1389, 1390, 1387, 1409, 1441, 1442, 1452, 1306, 1274, + /* 460 */ 1016, 1453, 1454, 1459, 1496, 1472, 1096, 1476, 1439, 1492, + /* 470 */ 1493, 1519, 1523, 1573, 1583, 1585, 1587, 1589, 1597, 1599, + /* 480 */ 1601, 1630, 1632, 1635, 1537, 1546, 1559, 1570, 1574, 1600, + /* 490 */ 1349, 1591, 1462, 1469, 1550, 1640, 1593, 287, 2016, 2026, + /* 500 */ 2054, 2010, 2056, 2023, 1824, 2027, 2028, 2029, 1826, 2067, + /* 510 */ 2031, 2032, 1833, 2034, 2072, 1836, 2077, 2044, 2088, 2053, + /* 520 */ 2091, 2070, 2094, 2059, 1866, 2099, 1882, 2101, 1885, 1887, + /* 530 */ 1890, 1894, 2107, 2109, 2110, 1905, 1913, 2120, 2123, 1972, + /* 540 */ 2079, 2086, 2126, 2104, 2138, 2142, 2108, 2093, 2147, 2100, + /* 550 */ 2148, 2111, 2158, 2160, 2161, 2115, 2165, 2166, 2167, 2169, + /* 560 */ 2170, 2171, 2002, 2136, 2174, 2005, 2176, 2177, 2178, 2179, + /* 570 */ 2180, 2181, 2182, 2183, 2187, 2191, 2198, 2200, 2201, 2202, + /* 580 */ 2204, 2205, 2206, 2207, 2208, 2162, 2212, 2168, 2214, 2215, + /* 590 */ 2216, 2217, 2218, 2219, 2220, 2221, 2222, 2203, 2226, 2076, + /* 600 */ 2227, 2073, 2229, 2080, 2233, 2234, 2223, 2186, 2228, 2188, + /* 610 */ 2237, 2189, 2248, 2190, 2225, 2252, 2192, 2253, 2194, 2256, + /* 620 */ 2258, 2231, 2210, 2230, 2263, 2238, 2213, 2232, 2265, 2239, + /* 630 */ 2235, 2236, 2266, 2240, 2270, 2242, 2241, 2246, 2244, 2245, + /* 640 */ 2257, 2247, 2280, 2249, 2269, 2281, 2282, 2284, 2285, 2271, + /* 650 */ 2087, 2289, 2244, 2250, 2290, 2244, 2251, 2291, 2308, 2255, + /* 660 */ 2312, 2314, 2279, 2286, 2278, 2330, 2294, 2288, 2293, 2332, + /* 670 */ 2296, 2292, 2299, 2336, 2305, 2295, 2302, 2345, 2347, 2348, + /* 680 */ 2349, 2350, 2351, 2264, 2254, 2315, 2333, 2357, 2321, 2322, + /* 690 */ 2323, 2324, 2326, 2327, 2329, 2352, 2353, 2334, 2337, 2355, + /* 700 */ 2356, 2362, 2359, 2369, 2363, 2386, 2365, 2388, 2372, 2338, + /* 710 */ 2398, 2378, 2364, 2403, 2404, 2407, 2371, 2417, 2383, 2418, + /* 720 */ 2393, 2401, 2385, 2387, 2390, 2313, 2317, 2430, 2259, 2209, + /* 730 */ 2260, 2320, 2261, 2244, 2394, 2444, 2262, 2405, 2428, 2458, + /* 740 */ 2267, 2438, 2275, 2268, 2466, 2467, 2283, 2272, 2287, 2276, + /* 750 */ 2468, 2435, 2185, 2366, 2367, 2370, 2374, 2439, 2447, 2377, + /* 760 */ 2425, 2382, 2443, 2396, 2392, 2472, 2473, 2395, 2389, 2406, + /* 770 */ 2413, 2397, 2479, 2477, 2478, 2421, 2482, 2273, 2437, 2416, + /* 780 */ 2500, 2423, 2498, 2424, 2426, 2534, 2506, 2277, 2504, 2505, + /* 790 */ 2507, 2508, 2510, 2512, 2431, 2440, 2491, 2297, 2517, 2502, + /* 800 */ 2553, 2554, 2446, 2513, 2448, 2449, 2451, 2461, 2368, 2462, + /* 810 */ 2574, 2536, 2399, 2576, 2469, 2481, 2400, 2541, 2409, 2562, + /* 820 */ 2487, 2340, 2490, 2605, 2589, 2375, 2511, 2515, 2501, 2509, + /* 830 */ 2514, 2518, 2519, 2521, 2565, 2520, 2523, 2566, 2524, 2594, + /* 840 */ 2373, 2526, 2527, 2617, 2528, 2531, 2434, 2593, 2532, 2525, + /* 850 */ 2244, 2569, 2533, 2535, 2537, 2540, 2542, 2543, 2625, 2626, + /* 860 */ 2630, 2432, 2544, 2602, 2621, 2550, 2555, 2628, 2551, 2556, + /* 870 */ 2629, 2501, 2557, 2633, 2509, 2559, 2635, 2514, 2561, 2638, + /* 880 */ 2518, 2522, 2547, 2558, 2560, 2578, 2654, 2583, 2658, 2585, + /* 890 */ 2654, 2654, 2675, 2627, 2631, 2661, 2662, 2664, 2665, 2667, + /* 900 */ 2669, 2673, 2674, 2681, 2683, 2685, 2644, 2620, 2647, 2623, + /* 910 */ 2696, 2703, 2704, 2705, 2722, 2708, 2709, 2710, 2670, 2334, + /* 920 */ 2711, 2337, 2713, 2714, 2715, 2716, 2732, 2719, 2759, 2723, + /* 930 */ 2717, 2730, 2761, 2736, 2724, 2734, 2774, 2740, 2727, 2737, + /* 940 */ 2780, 2744, 2731, 2741, 2784, 2749, 2753, 2800, 2779, 2769, + /* 950 */ 2781, 2785, 2783, 2786, 2788, 2787, }; -#define YY_REDUCE_COUNT (371) -#define YY_REDUCE_MIN (-508) -#define YY_REDUCE_MAX (2490) +#define YY_REDUCE_COUNT (384) +#define YY_REDUCE_MIN (-501) +#define YY_REDUCE_MAX (2503) static const short yy_reduce_ofst[] = { - /* 0 */ 275, -357, -25, 126, 347, 674, 704, 823, 899, 957, - /* 10 */ 1006, 1036, 1140, 1160, 1180, 1286, -310, 1306, -272, 1321, - /* 20 */ 1439, 1454, 1475, 1501, -190, 1595, 1616, 1635, 1765, 1782, - /* 30 */ 1797, 1888, 1915, 1930, 1951, 2009, 2069, 2088, 2103, 2135, - /* 40 */ 2220, 2241, 2258, 2280, 2345, 2364, 2384, 2403, 2424, 2490, - /* 50 */ 30, 545, -385, -273, 754, 1008, 1023, 1043, -65, 189, - /* 60 */ 1063, 458, -508, -375, 765, -501, -499, -123, 381, -426, - /* 70 */ -382, -341, -384, 35, 112, 301, -383, -333, -73, 321, - /* 80 */ 387, -344, 491, 505, 526, 540, 745, 761, 688, 768, - /* 90 */ 817, 845, 795, -244, 568, 866, 910, -393, -395, 917, - /* 100 */ 53, 942, -298, 956, 1005, -217, 1011, 1018, 32, 1020, - /* 110 */ -57, 543, 886, 1022, 431, -293, -293, 558, -62, -17, - /* 120 */ -347, -294, -135, 262, 405, 547, 675, 677, 708, 755, - /* 130 */ 764, 782, 793, 796, 833, 869, 948, 1000, 1003, 1007, - /* 140 */ 1029, 1056, 65, 64, 510, 42, 685, 883, 857, 64, - /* 150 */ 153, 255, 453, 559, 792, -399, 1014, -104, 107, 370, - /* 160 */ 930, 68, 961, 664, -268, 390, 984, 985, 1004, 944, - /* 170 */ 1071, -404, 597, 605, 756, 800, 1088, 1162, 1116, 1219, - /* 180 */ 1143, 1089, 1089, 1062, 1084, 1096, 1142, 1268, 1089, 1274, - /* 190 */ 1274, 1283, 1287, 1250, 1307, 1252, 1165, 1166, 1167, 1246, - /* 200 */ 1274, 1171, 1314, 1261, 1319, 1282, 1251, 1272, 1276, 1274, - /* 210 */ 1206, 1207, 1178, 1221, 1214, 1320, 1270, 1257, 1263, 1275, - /* 220 */ 1273, 1349, 1279, 1352, 1290, 1365, 1369, 1318, 1372, 1323, - /* 230 */ 1324, 1378, 1379, 1389, 1327, 1331, 1341, 1342, 1387, 1397, - /* 240 */ 1412, 1413, 1405, 1417, 1424, 1426, 1436, 1433, 1440, 1438, - /* 250 */ 1353, 1427, 1429, 1394, 1435, 1443, 1376, 1444, 1446, 1447, - /* 260 */ 1393, 1448, 1449, 1459, 1451, 1469, 1423, 1453, 1456, 1458, - /* 270 */ 1462, 1463, 1464, 1465, 1466, 1468, 1471, 1467, 1473, 1474, - /* 280 */ 1479, 1421, 1430, 1460, 1388, 1396, 1399, 1481, 1410, 1425, - /* 290 */ 1431, 1470, 1500, 1442, 1509, 1480, 1374, 1455, 1377, 1472, - /* 300 */ 1373, 1383, 1392, 1385, 1408, 1398, 1487, 1420, 1457, 1400, - /* 310 */ 1411, 1414, 1562, 1484, 1485, 1483, 1569, 1579, 1580, 1492, - /* 320 */ 1525, 1537, 1545, 1547, 1550, 1526, 1552, 1534, 1601, 1582, - /* 330 */ 1603, 1608, 1566, 1567, 1573, 1576, 1577, 1581, 1584, 1585, - /* 340 */ 1586, 1589, 1590, 1592, 1593, 1598, 1605, 1606, 1607, 1609, - /* 350 */ 1610, 1611, 1612, 1613, 1591, 1614, 1628, 1625, 1630, 1645, - /* 360 */ 1640, 1554, 1557, 1559, 1604, 1615, 1621, 1624, 1617, 1637, - /* 370 */ 1654, 1667, + /* 0 */ 586, -335, -147, 251, 408, 437, 622, 674, 758, 878, + /* 10 */ 955, 1134, 1173, 1204, 1243, 1270, 1023, 155, 1437, 1456, + /* 20 */ 1517, 1544, 1594, 1624, 1641, 1662, 1704, 1751, 1814, 1834, + /* 30 */ 1884, 1921, 1945, 1964, 2006, 2030, 2075, 2096, 2113, 2193, + /* 40 */ 2224, 2243, 2274, 2304, 2354, 2381, 2415, 2442, 2465, 2503, + /* 50 */ 166, 792, -456, -32, -353, 426, 526, 860, -294, 842, + /* 60 */ 949, 43, 188, -199, 198, 390, 711, -411, -332, -424, + /* 70 */ -354, -105, 234, -148, 171, -347, -300, -213, -234, 60, + /* 80 */ -383, 159, -140, 148, 342, 348, 434, -296, 306, 486, + /* 90 */ 534, 545, 574, 449, 158, 467, 458, 580, 602, 72, + /* 100 */ -44, 604, 613, 653, -417, 691, 713, 731, 763, 56, + /* 110 */ 771, 789, 404, 797, 113, 459, 529, 806, 280, -501, + /* 120 */ -501, -375, 527, -109, -388, -334, 157, -233, 585, 626, + /* 130 */ 692, 780, 785, 812, 879, 890, 928, 932, 943, 953, + /* 140 */ 954, 960, 963, 964, 965, 969, -359, -319, 641, -73, + /* 150 */ 850, 916, 859, -319, 565, 709, 299, 334, 490, -303, + /* 160 */ 919, 272, 740, 821, 220, 823, -270, 898, 799, 872, + /* 170 */ 958, 918, 974, 1000, 948, 214, 282, 327, 372, 377, + /* 180 */ 412, 427, 712, 597, 987, 956, 956, 680, 1017, 972, + /* 190 */ 1040, 1176, 956, 1164, 1164, 1184, 1189, 1170, 1230, 1174, + /* 200 */ 1101, 1113, 1114, 1193, 1118, 1164, 1264, 1223, 1278, 1251, + /* 210 */ 1217, 1244, 1245, 1164, 1168, 1177, 1158, 1194, 1180, 1294, + /* 220 */ 1252, 1231, 1235, 1246, 1242, 1323, 1250, 1326, 1265, 1342, + /* 230 */ 1351, 1300, 1354, 1302, 1308, 1364, 1359, 1365, 1314, 1316, + /* 240 */ 1325, 1331, 1373, 1378, 1391, 1392, 1383, 1395, 1396, 1397, + /* 250 */ 1406, 1404, 1410, 1405, 1321, 1398, 1399, 1362, 1401, 1411, + /* 260 */ 1340, 1403, 1413, 1407, 1353, 1414, 1367, 1415, 1418, 1421, + /* 270 */ 1420, 1429, 1408, 1422, 1423, 1424, 1425, 1427, 1430, 1431, + /* 280 */ 1432, 1433, 1435, 1434, 1444, 1448, 1440, 1385, 1436, 1438, + /* 290 */ 1344, 1357, 1356, 1451, 1372, 1386, 1388, 1443, 1463, 1400, + /* 300 */ 1471, 1446, 1332, 1445, 1333, 1447, 1334, 1343, 1335, 1345, + /* 310 */ 1348, 1355, 1449, 1368, 1366, 1346, 1358, 1361, 1503, 1455, + /* 320 */ 1384, 1393, 1521, 1520, 1522, 1458, 1480, 1481, 1486, 1489, + /* 330 */ 1477, 1490, 1485, 1543, 1506, 1507, 1548, 1450, 1524, 1511, + /* 340 */ 1513, 1579, 1551, 1580, 1603, 1532, 1535, 1536, 1538, 1545, + /* 350 */ 1547, 1549, 1553, 1554, 1555, 1557, 1571, 1581, 1586, 1588, + /* 360 */ 1590, 1607, 1609, 1610, 1611, 1612, 1613, 1567, 1615, 1605, + /* 370 */ 1602, 1616, 1617, 1622, 1558, 1516, 1542, 1565, 1595, 1620, + /* 380 */ 1636, 1643, 1638, 1628, 1644, }; static const YYACTIONTYPE yy_default[] = { - /* 0 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 10 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 20 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 30 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 40 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 50 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 60 */ 2480, 2123, 2123, 2443, 2123, 2123, 2123, 2123, 2123, 2123, - /* 70 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2450, 2123, 2123, - /* 80 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 90 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2223, 2123, 2123, - /* 100 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 110 */ 2123, 2123, 2123, 2123, 2221, 2730, 2123, 2856, 2521, 2123, - /* 120 */ 2123, 2759, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 130 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 140 */ 2123, 2123, 2123, 2742, 2123, 2123, 2194, 2194, 2123, 2742, - /* 150 */ 2742, 2742, 2702, 2702, 2221, 2123, 2123, 2223, 2123, 2523, - /* 160 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2361, - /* 170 */ 2153, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2506, 2123, - /* 180 */ 2788, 2734, 2735, 2850, 2123, 2791, 2753, 2123, 2748, 2123, - /* 190 */ 2123, 2123, 2123, 2455, 2123, 2778, 2123, 2123, 2123, 2123, - /* 200 */ 2123, 2123, 2123, 2123, 2123, 2306, 2500, 2123, 2123, 2123, - /* 210 */ 2123, 2123, 2834, 2732, 2772, 2123, 2782, 2123, 2548, 2123, - /* 220 */ 2537, 2223, 2123, 2223, 2493, 2438, 2123, 2448, 2123, 2448, - /* 230 */ 2445, 2123, 2123, 2123, 2448, 2445, 2445, 2445, 2295, 2291, - /* 240 */ 2123, 2123, 2289, 2123, 2123, 2123, 2123, 2178, 2123, 2178, - /* 250 */ 2123, 2223, 2223, 2123, 2223, 2123, 2123, 2223, 2123, 2223, - /* 260 */ 2123, 2223, 2223, 2123, 2223, 2123, 2123, 2123, 2123, 2123, - /* 270 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 280 */ 2123, 2123, 2123, 2123, 2535, 2516, 2123, 2221, 2123, 2504, - /* 290 */ 2502, 2123, 2221, 2782, 2123, 2123, 2804, 2799, 2804, 2799, - /* 300 */ 2818, 2814, 2804, 2823, 2820, 2784, 2782, 2765, 2761, 2853, - /* 310 */ 2840, 2836, 2123, 2123, 2770, 2768, 2123, 2221, 2221, 2123, - /* 320 */ 2799, 2123, 2123, 2123, 2123, 2799, 2123, 2123, 2221, 2123, - /* 330 */ 2221, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 340 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 350 */ 2123, 2123, 2123, 2123, 2323, 2123, 2123, 2221, 2123, 2162, - /* 360 */ 2123, 2495, 2521, 2526, 2476, 2476, 2364, 2364, 2856, 2364, - /* 370 */ 2224, 2128, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 380 */ 2123, 2123, 2123, 2123, 2817, 2816, 2653, 2123, 2706, 2705, - /* 390 */ 2704, 2695, 2652, 2319, 2123, 2123, 2651, 2650, 2123, 2123, - /* 400 */ 2123, 2123, 2123, 2310, 2123, 2123, 2332, 2123, 2123, 2123, - /* 410 */ 2123, 2644, 2123, 2123, 2645, 2643, 2642, 2467, 2466, 2123, - /* 420 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 430 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 440 */ 2123, 2123, 2123, 2123, 2123, 2123, 2837, 2841, 2123, 2731, - /* 450 */ 2123, 2123, 2123, 2624, 2123, 2123, 2123, 2123, 2123, 2592, - /* 460 */ 2587, 2578, 2569, 2584, 2575, 2563, 2581, 2572, 2560, 2557, - /* 470 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 480 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 490 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 500 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 510 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 520 */ 2123, 2123, 2123, 2123, 2123, 2444, 2123, 2123, 2123, 2123, - /* 530 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 540 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 550 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 560 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 570 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 580 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2459, 2123, - /* 590 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 600 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 610 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 620 */ 2123, 2123, 2167, 2631, 2123, 2123, 2123, 2123, 2123, 2123, - /* 630 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2634, 2123, 2123, - /* 640 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 650 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 660 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 670 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2267, - /* 680 */ 2266, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 690 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 700 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2635, 2123, 2123, - /* 710 */ 2123, 2123, 2520, 2123, 2123, 2626, 2123, 2123, 2123, 2123, - /* 720 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 730 */ 2123, 2123, 2833, 2785, 2123, 2123, 2123, 2123, 2123, 2123, - /* 740 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 750 */ 2123, 2123, 2123, 2123, 2123, 2123, 2624, 2123, 2815, 2123, - /* 760 */ 2123, 2123, 2123, 2123, 2123, 2123, 2831, 2123, 2835, 2123, - /* 770 */ 2123, 2123, 2123, 2123, 2123, 2123, 2741, 2737, 2123, 2123, - /* 780 */ 2733, 2123, 2123, 2123, 2123, 2123, 2692, 2123, 2123, 2123, - /* 790 */ 2726, 2123, 2123, 2123, 2123, 2360, 2359, 2358, 2357, 2123, - /* 800 */ 2123, 2123, 2123, 2123, 2123, 2635, 2123, 2638, 2123, 2123, - /* 810 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 820 */ 2623, 2123, 2677, 2676, 2123, 2123, 2123, 2123, 2123, 2123, - /* 830 */ 2123, 2123, 2123, 2123, 2123, 2354, 2123, 2123, 2123, 2123, - /* 840 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 850 */ 2123, 2338, 2336, 2335, 2334, 2123, 2371, 2123, 2123, 2123, - /* 860 */ 2367, 2366, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 870 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 880 */ 2242, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2234, - /* 890 */ 2123, 2233, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 900 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, - /* 910 */ 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2123, 2152, - /* 920 */ 2123, 2123, 2123, 2123, 2123, 2123, + /* 0 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 10 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 20 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 30 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 40 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 50 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 60 */ 2529, 2165, 2165, 2485, 2165, 2165, 2165, 2165, 2165, 2165, + /* 70 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2492, 2165, + /* 80 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 90 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2265, + /* 100 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 110 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2263, 2780, + /* 120 */ 2165, 2906, 2570, 2165, 2165, 2809, 2165, 2165, 2165, 2165, + /* 130 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 140 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2792, 2165, 2165, + /* 150 */ 2236, 2236, 2165, 2792, 2792, 2792, 2752, 2752, 2263, 2165, + /* 160 */ 2165, 2265, 2165, 2572, 2165, 2165, 2165, 2165, 2165, 2165, + /* 170 */ 2165, 2165, 2165, 2403, 2195, 2165, 2165, 2165, 2165, 2165, + /* 180 */ 2165, 2555, 2165, 2165, 2838, 2784, 2785, 2900, 2165, 2841, + /* 190 */ 2803, 2165, 2798, 2165, 2165, 2165, 2165, 2497, 2165, 2828, + /* 200 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2348, + /* 210 */ 2549, 2165, 2165, 2165, 2165, 2165, 2884, 2782, 2822, 2165, + /* 220 */ 2832, 2165, 2597, 2165, 2586, 2265, 2165, 2265, 2542, 2480, + /* 230 */ 2165, 2490, 2165, 2490, 2487, 2165, 2165, 2165, 2490, 2487, + /* 240 */ 2487, 2487, 2337, 2333, 2165, 2165, 2331, 2165, 2165, 2165, + /* 250 */ 2165, 2220, 2165, 2220, 2165, 2265, 2265, 2165, 2265, 2165, + /* 260 */ 2165, 2265, 2165, 2265, 2165, 2265, 2165, 2265, 2265, 2165, + /* 270 */ 2265, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 280 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 290 */ 2584, 2565, 2165, 2263, 2165, 2553, 2551, 2165, 2263, 2832, + /* 300 */ 2165, 2165, 2854, 2849, 2854, 2849, 2868, 2864, 2854, 2873, + /* 310 */ 2870, 2834, 2832, 2815, 2811, 2903, 2890, 2886, 2165, 2165, + /* 320 */ 2820, 2818, 2165, 2263, 2263, 2849, 2165, 2165, 2165, 2165, + /* 330 */ 2849, 2165, 2165, 2263, 2165, 2165, 2263, 2165, 2165, 2165, + /* 340 */ 2165, 2263, 2165, 2263, 2165, 2165, 2165, 2165, 2165, 2165, + /* 350 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 360 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2365, 2165, 2165, + /* 370 */ 2263, 2165, 2204, 2165, 2544, 2570, 2575, 2525, 2525, 2406, + /* 380 */ 2406, 2906, 2406, 2266, 2170, 2165, 2165, 2165, 2165, 2165, + /* 390 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2867, 2866, 2703, + /* 400 */ 2165, 2756, 2755, 2754, 2745, 2702, 2361, 2165, 2165, 2165, + /* 410 */ 2701, 2700, 2165, 2165, 2165, 2165, 2352, 2165, 2165, 2374, + /* 420 */ 2165, 2165, 2165, 2165, 2516, 2515, 2694, 2165, 2165, 2695, + /* 430 */ 2693, 2692, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 440 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 450 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2887, + /* 460 */ 2891, 2165, 2165, 2165, 2781, 2165, 2165, 2165, 2673, 2165, + /* 470 */ 2165, 2165, 2165, 2641, 2636, 2627, 2618, 2633, 2624, 2612, + /* 480 */ 2630, 2621, 2609, 2606, 2165, 2165, 2165, 2165, 2165, 2165, + /* 490 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 500 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 510 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 520 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 530 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2486, + /* 540 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 550 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 560 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 570 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 580 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 590 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 600 */ 2165, 2165, 2165, 2501, 2165, 2165, 2165, 2165, 2165, 2165, + /* 610 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 620 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 630 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2209, 2680, 2165, + /* 640 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 650 */ 2165, 2165, 2683, 2165, 2165, 2684, 2165, 2165, 2165, 2165, + /* 660 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 670 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 680 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 690 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2309, 2308, 2165, + /* 700 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 710 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 720 */ 2165, 2165, 2165, 2165, 2165, 2685, 2165, 2165, 2165, 2165, + /* 730 */ 2569, 2165, 2165, 2675, 2165, 2165, 2165, 2165, 2165, 2165, + /* 740 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 750 */ 2883, 2835, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 760 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 770 */ 2165, 2165, 2165, 2165, 2673, 2165, 2865, 2165, 2165, 2165, + /* 780 */ 2165, 2165, 2165, 2165, 2881, 2165, 2885, 2165, 2165, 2165, + /* 790 */ 2165, 2165, 2165, 2165, 2791, 2787, 2165, 2165, 2783, 2165, + /* 800 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 810 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2742, + /* 820 */ 2165, 2165, 2165, 2776, 2165, 2165, 2165, 2165, 2402, 2401, + /* 830 */ 2400, 2399, 2165, 2165, 2165, 2165, 2165, 2165, 2685, 2165, + /* 840 */ 2688, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 850 */ 2672, 2165, 2727, 2726, 2165, 2165, 2165, 2165, 2165, 2165, + /* 860 */ 2165, 2165, 2165, 2165, 2165, 2396, 2165, 2165, 2165, 2165, + /* 870 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 880 */ 2165, 2380, 2378, 2377, 2376, 2165, 2413, 2165, 2165, 2165, + /* 890 */ 2409, 2408, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 900 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 910 */ 2284, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2276, + /* 920 */ 2165, 2275, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 930 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, + /* 940 */ 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2165, 2194, + /* 950 */ 2165, 2165, 2165, 2165, 2165, 2165, }; /********** End of lemon-generated parsing tables *****************************/ @@ -1593,7 +1608,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 */ @@ -1664,7 +1679,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 */ @@ -1673,9 +1688,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 */ @@ -1704,7 +1722,7 @@ static const YYCODETYPE yyFallback[] = { 0, /* PAUSE => nothing */ 0, /* RESUME => nothing */ 0, /* PRIMARY => nothing */ - 319, /* KEY => ABORT */ + 322, /* KEY => ABORT */ 0, /* TRIGGER => nothing */ 0, /* AT_ONCE => nothing */ 0, /* WINDOW_CLOSE => nothing */ @@ -1768,7 +1786,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 */ @@ -1804,53 +1822,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 */ 0, /* ENCODE => nothing */ 0, /* COMPRESS => nothing */ 0, /* LEVEL => nothing */ @@ -2131,362 +2149,368 @@ static const char *const yyTokenName[] = { /* 186 */ "QTAGS", /* 187 */ "AS", /* 188 */ "SYSTEM", - /* 189 */ "INDEX", - /* 190 */ "FUNCTION", - /* 191 */ "INTERVAL", - /* 192 */ "COUNT", - /* 193 */ "LAST_ROW", - /* 194 */ "META", - /* 195 */ "ONLY", - /* 196 */ "TOPIC", - /* 197 */ "CONSUMER", - /* 198 */ "GROUP", - /* 199 */ "DESC", - /* 200 */ "DESCRIBE", - /* 201 */ "RESET", - /* 202 */ "QUERY", - /* 203 */ "CACHE", - /* 204 */ "EXPLAIN", - /* 205 */ "ANALYZE", - /* 206 */ "VERBOSE", - /* 207 */ "NK_BOOL", - /* 208 */ "RATIO", - /* 209 */ "NK_FLOAT", - /* 210 */ "OUTPUTTYPE", - /* 211 */ "AGGREGATE", - /* 212 */ "BUFSIZE", - /* 213 */ "LANGUAGE", - /* 214 */ "REPLACE", - /* 215 */ "STREAM", - /* 216 */ "INTO", - /* 217 */ "PAUSE", - /* 218 */ "RESUME", - /* 219 */ "PRIMARY", - /* 220 */ "KEY", - /* 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 */ "ENCODE", - /* 368 */ "COMPRESS", - /* 369 */ "LEVEL", - /* 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 */ "column_options", - /* 417 */ "tags_literal", - /* 418 */ "create_subtable_clause", - /* 419 */ "specific_cols_opt", - /* 420 */ "tags_literal_list", - /* 421 */ "drop_table_clause", - /* 422 */ "col_name_list", - /* 423 */ "tag_def_list", - /* 424 */ "tag_def", - /* 425 */ "column_def", - /* 426 */ "type_name_default_len", - /* 427 */ "duration_list", - /* 428 */ "rollup_func_list", - /* 429 */ "alter_table_option", - /* 430 */ "duration_literal", - /* 431 */ "rollup_func_name", - /* 432 */ "function_name", - /* 433 */ "col_name", - /* 434 */ "db_kind_opt", - /* 435 */ "table_kind_db_name_cond_opt", - /* 436 */ "like_pattern_opt", - /* 437 */ "db_name_cond_opt", - /* 438 */ "table_name_cond", - /* 439 */ "from_db_opt", - /* 440 */ "tag_list_opt", - /* 441 */ "table_kind", - /* 442 */ "tag_item", - /* 443 */ "column_alias", - /* 444 */ "index_options", - /* 445 */ "full_index_name", - /* 446 */ "index_name", - /* 447 */ "func_list", - /* 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 */ "stream_col_options", - /* 475 */ "expression", - /* 476 */ "on_vgroup_id", - /* 477 */ "dnode_list", - /* 478 */ "literal_func", - /* 479 */ "signed_literal", - /* 480 */ "literal_list", - /* 481 */ "table_alias", - /* 482 */ "expr_or_subquery", - /* 483 */ "pseudo_column", - /* 484 */ "column_reference", - /* 485 */ "function_expression", - /* 486 */ "case_when_expression", - /* 487 */ "star_func", - /* 488 */ "star_func_para_list", - /* 489 */ "noarg_func", - /* 490 */ "other_para_list", - /* 491 */ "star_func_para", - /* 492 */ "when_then_list", - /* 493 */ "case_when_else_opt", - /* 494 */ "common_expression", - /* 495 */ "when_then_expr", - /* 496 */ "predicate", - /* 497 */ "compare_op", - /* 498 */ "in_op", - /* 499 */ "in_predicate_value", - /* 500 */ "boolean_value_expression", - /* 501 */ "boolean_primary", - /* 502 */ "from_clause_opt", - /* 503 */ "table_reference_list", - /* 504 */ "table_reference", - /* 505 */ "table_primary", - /* 506 */ "joined_table", - /* 507 */ "alias_opt", - /* 508 */ "subquery", - /* 509 */ "parenthesized_joined_table", - /* 510 */ "join_type", - /* 511 */ "join_subtype", - /* 512 */ "join_on_clause_opt", - /* 513 */ "window_offset_clause_opt", - /* 514 */ "jlimit_clause_opt", - /* 515 */ "window_offset_literal", - /* 516 */ "query_specification", - /* 517 */ "hint_list", - /* 518 */ "set_quantifier_opt", - /* 519 */ "tag_mode_opt", - /* 520 */ "select_list", - /* 521 */ "partition_by_clause_opt", - /* 522 */ "range_opt", - /* 523 */ "every_opt", - /* 524 */ "fill_opt", - /* 525 */ "twindow_clause_opt", - /* 526 */ "group_by_clause_opt", - /* 527 */ "having_clause_opt", - /* 528 */ "select_item", - /* 529 */ "partition_list", - /* 530 */ "partition_item", - /* 531 */ "interval_sliding_duration_literal", - /* 532 */ "fill_mode", - /* 533 */ "group_by_list", - /* 534 */ "query_expression", - /* 535 */ "query_simple", - /* 536 */ "order_by_clause_opt", - /* 537 */ "slimit_clause_opt", - /* 538 */ "limit_clause_opt", - /* 539 */ "union_query_expression", - /* 540 */ "query_simple_or_subquery", - /* 541 */ "sort_specification_list", - /* 542 */ "sort_specification", - /* 543 */ "ordering_specification_opt", - /* 544 */ "null_ordering_opt", + /* 189 */ "TSMA", + /* 190 */ "INTERVAL", + /* 191 */ "RECURSIVE", + /* 192 */ "TSMAS", + /* 193 */ "FUNCTION", + /* 194 */ "INDEX", + /* 195 */ "COUNT", + /* 196 */ "LAST_ROW", + /* 197 */ "META", + /* 198 */ "ONLY", + /* 199 */ "TOPIC", + /* 200 */ "CONSUMER", + /* 201 */ "GROUP", + /* 202 */ "DESC", + /* 203 */ "DESCRIBE", + /* 204 */ "RESET", + /* 205 */ "QUERY", + /* 206 */ "CACHE", + /* 207 */ "EXPLAIN", + /* 208 */ "ANALYZE", + /* 209 */ "VERBOSE", + /* 210 */ "NK_BOOL", + /* 211 */ "RATIO", + /* 212 */ "NK_FLOAT", + /* 213 */ "OUTPUTTYPE", + /* 214 */ "AGGREGATE", + /* 215 */ "BUFSIZE", + /* 216 */ "LANGUAGE", + /* 217 */ "REPLACE", + /* 218 */ "STREAM", + /* 219 */ "INTO", + /* 220 */ "PAUSE", + /* 221 */ "RESUME", + /* 222 */ "PRIMARY", + /* 223 */ "KEY", + /* 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 */ "ENCODE", + /* 371 */ "COMPRESS", + /* 372 */ "LEVEL", + /* 373 */ "cmd", + /* 374 */ "account_options", + /* 375 */ "alter_account_options", + /* 376 */ "literal", + /* 377 */ "alter_account_option", + /* 378 */ "ip_range_list", + /* 379 */ "white_list", + /* 380 */ "white_list_opt", + /* 381 */ "user_name", + /* 382 */ "sysinfo_opt", + /* 383 */ "privileges", + /* 384 */ "priv_level", + /* 385 */ "with_opt", + /* 386 */ "priv_type_list", + /* 387 */ "priv_type", + /* 388 */ "db_name", + /* 389 */ "table_name", + /* 390 */ "topic_name", + /* 391 */ "search_condition", + /* 392 */ "dnode_endpoint", + /* 393 */ "force_opt", + /* 394 */ "unsafe_opt", + /* 395 */ "not_exists_opt", + /* 396 */ "db_options", + /* 397 */ "exists_opt", + /* 398 */ "alter_db_options", + /* 399 */ "speed_opt", + /* 400 */ "start_opt", + /* 401 */ "end_opt", + /* 402 */ "integer_list", + /* 403 */ "variable_list", + /* 404 */ "retention_list", + /* 405 */ "signed", + /* 406 */ "alter_db_option", + /* 407 */ "retention", + /* 408 */ "full_table_name", + /* 409 */ "column_def_list", + /* 410 */ "tags_def_opt", + /* 411 */ "table_options", + /* 412 */ "multi_create_clause", + /* 413 */ "tags_def", + /* 414 */ "multi_drop_clause", + /* 415 */ "alter_table_clause", + /* 416 */ "alter_table_options", + /* 417 */ "column_name", + /* 418 */ "type_name", + /* 419 */ "column_options", + /* 420 */ "tags_literal", + /* 421 */ "create_subtable_clause", + /* 422 */ "specific_cols_opt", + /* 423 */ "tags_literal_list", + /* 424 */ "drop_table_clause", + /* 425 */ "col_name_list", + /* 426 */ "tag_def_list", + /* 427 */ "tag_def", + /* 428 */ "column_def", + /* 429 */ "type_name_default_len", + /* 430 */ "duration_list", + /* 431 */ "rollup_func_list", + /* 432 */ "alter_table_option", + /* 433 */ "duration_literal", + /* 434 */ "rollup_func_name", + /* 435 */ "function_name", + /* 436 */ "col_name", + /* 437 */ "db_kind_opt", + /* 438 */ "table_kind_db_name_cond_opt", + /* 439 */ "like_pattern_opt", + /* 440 */ "db_name_cond_opt", + /* 441 */ "table_name_cond", + /* 442 */ "from_db_opt", + /* 443 */ "tag_list_opt", + /* 444 */ "table_kind", + /* 445 */ "tag_item", + /* 446 */ "column_alias", + /* 447 */ "tsma_name", + /* 448 */ "tsma_func_list", + /* 449 */ "full_tsma_name", + /* 450 */ "func_list", + /* 451 */ "index_options", + /* 452 */ "full_index_name", + /* 453 */ "index_name", + /* 454 */ "sliding_opt", + /* 455 */ "sma_stream_opt", + /* 456 */ "func", + /* 457 */ "sma_func_name", + /* 458 */ "expression_list", + /* 459 */ "with_meta", + /* 460 */ "query_or_subquery", + /* 461 */ "where_clause_opt", + /* 462 */ "cgroup_name", + /* 463 */ "analyze_opt", + /* 464 */ "explain_options", + /* 465 */ "insert_query", + /* 466 */ "or_replace_opt", + /* 467 */ "agg_func_opt", + /* 468 */ "bufsize_opt", + /* 469 */ "language_opt", + /* 470 */ "full_view_name", + /* 471 */ "view_name", + /* 472 */ "stream_name", + /* 473 */ "stream_options", + /* 474 */ "col_list_opt", + /* 475 */ "tag_def_or_ref_opt", + /* 476 */ "subtable_opt", + /* 477 */ "ignore_opt", + /* 478 */ "column_stream_def_list", + /* 479 */ "column_stream_def", + /* 480 */ "stream_col_options", + /* 481 */ "expression", + /* 482 */ "on_vgroup_id", + /* 483 */ "dnode_list", + /* 484 */ "literal_func", + /* 485 */ "signed_literal", + /* 486 */ "literal_list", + /* 487 */ "table_alias", + /* 488 */ "expr_or_subquery", + /* 489 */ "pseudo_column", + /* 490 */ "column_reference", + /* 491 */ "function_expression", + /* 492 */ "case_when_expression", + /* 493 */ "star_func", + /* 494 */ "star_func_para_list", + /* 495 */ "noarg_func", + /* 496 */ "other_para_list", + /* 497 */ "star_func_para", + /* 498 */ "when_then_list", + /* 499 */ "case_when_else_opt", + /* 500 */ "common_expression", + /* 501 */ "when_then_expr", + /* 502 */ "predicate", + /* 503 */ "compare_op", + /* 504 */ "in_op", + /* 505 */ "in_predicate_value", + /* 506 */ "boolean_value_expression", + /* 507 */ "boolean_primary", + /* 508 */ "from_clause_opt", + /* 509 */ "table_reference_list", + /* 510 */ "table_reference", + /* 511 */ "table_primary", + /* 512 */ "joined_table", + /* 513 */ "alias_opt", + /* 514 */ "subquery", + /* 515 */ "parenthesized_joined_table", + /* 516 */ "join_type", + /* 517 */ "join_subtype", + /* 518 */ "join_on_clause_opt", + /* 519 */ "window_offset_clause_opt", + /* 520 */ "jlimit_clause_opt", + /* 521 */ "window_offset_literal", + /* 522 */ "query_specification", + /* 523 */ "hint_list", + /* 524 */ "set_quantifier_opt", + /* 525 */ "tag_mode_opt", + /* 526 */ "select_list", + /* 527 */ "partition_by_clause_opt", + /* 528 */ "range_opt", + /* 529 */ "every_opt", + /* 530 */ "fill_opt", + /* 531 */ "twindow_clause_opt", + /* 532 */ "group_by_clause_opt", + /* 533 */ "having_clause_opt", + /* 534 */ "select_item", + /* 535 */ "partition_list", + /* 536 */ "partition_item", + /* 537 */ "interval_sliding_duration_literal", + /* 538 */ "fill_mode", + /* 539 */ "group_by_list", + /* 540 */ "query_expression", + /* 541 */ "query_simple", + /* 542 */ "order_by_clause_opt", + /* 543 */ "slimit_clause_opt", + /* 544 */ "limit_clause_opt", + /* 545 */ "union_query_expression", + /* 546 */ "query_simple_or_subquery", + /* 547 */ "sort_specification_list", + /* 548 */ "sort_specification", + /* 549 */ "ordering_specification_opt", + /* 550 */ "null_ordering_opt", }; #endif /* defined(YYCOVERAGE) || !defined(NDEBUG) */ @@ -2829,406 +2853,414 @@ static const char *const yyRuleName[] = { /* 332 */ "db_kind_opt ::=", /* 333 */ "db_kind_opt ::= USER", /* 334 */ "db_kind_opt ::= SYSTEM", - /* 335 */ "cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options", - /* 336 */ "cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP", - /* 337 */ "cmd ::= DROP INDEX exists_opt full_index_name", - /* 338 */ "full_index_name ::= index_name", - /* 339 */ "full_index_name ::= db_name NK_DOT index_name", - /* 340 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", - /* 341 */ "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", - /* 342 */ "func_list ::= func", - /* 343 */ "func_list ::= func_list NK_COMMA func", - /* 344 */ "func ::= sma_func_name NK_LP expression_list NK_RP", - /* 345 */ "sma_func_name ::= function_name", - /* 346 */ "sma_func_name ::= COUNT", - /* 347 */ "sma_func_name ::= FIRST", - /* 348 */ "sma_func_name ::= LAST", - /* 349 */ "sma_func_name ::= LAST_ROW", - /* 350 */ "sma_stream_opt ::=", - /* 351 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", - /* 352 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", - /* 353 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", - /* 354 */ "with_meta ::= AS", - /* 355 */ "with_meta ::= WITH META AS", - /* 356 */ "with_meta ::= ONLY META AS", - /* 357 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", - /* 358 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name", - /* 359 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt", - /* 360 */ "cmd ::= DROP TOPIC exists_opt topic_name", - /* 361 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", - /* 362 */ "cmd ::= DESC full_table_name", - /* 363 */ "cmd ::= DESCRIBE full_table_name", - /* 364 */ "cmd ::= RESET QUERY CACHE", - /* 365 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", - /* 366 */ "cmd ::= EXPLAIN analyze_opt explain_options insert_query", - /* 367 */ "analyze_opt ::=", - /* 368 */ "analyze_opt ::= ANALYZE", - /* 369 */ "explain_options ::=", - /* 370 */ "explain_options ::= explain_options VERBOSE NK_BOOL", - /* 371 */ "explain_options ::= explain_options RATIO NK_FLOAT", - /* 372 */ "cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt", - /* 373 */ "cmd ::= DROP FUNCTION exists_opt function_name", - /* 374 */ "agg_func_opt ::=", - /* 375 */ "agg_func_opt ::= AGGREGATE", - /* 376 */ "bufsize_opt ::=", - /* 377 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", - /* 378 */ "language_opt ::=", - /* 379 */ "language_opt ::= LANGUAGE NK_STRING", - /* 380 */ "or_replace_opt ::=", - /* 381 */ "or_replace_opt ::= OR REPLACE", - /* 382 */ "cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery", - /* 383 */ "cmd ::= DROP VIEW exists_opt full_view_name", - /* 384 */ "full_view_name ::= view_name", - /* 385 */ "full_view_name ::= db_name NK_DOT view_name", - /* 386 */ "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", - /* 387 */ "cmd ::= DROP STREAM exists_opt stream_name", - /* 388 */ "cmd ::= PAUSE STREAM exists_opt stream_name", - /* 389 */ "cmd ::= RESUME STREAM exists_opt ignore_opt stream_name", - /* 390 */ "col_list_opt ::=", - /* 391 */ "col_list_opt ::= NK_LP column_stream_def_list NK_RP", - /* 392 */ "column_stream_def_list ::= column_stream_def", - /* 393 */ "column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def", - /* 394 */ "column_stream_def ::= column_name stream_col_options", - /* 395 */ "stream_col_options ::=", - /* 396 */ "stream_col_options ::= stream_col_options PRIMARY KEY", - /* 397 */ "tag_def_or_ref_opt ::=", - /* 398 */ "tag_def_or_ref_opt ::= tags_def", - /* 399 */ "tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP", - /* 400 */ "stream_options ::=", - /* 401 */ "stream_options ::= stream_options TRIGGER AT_ONCE", - /* 402 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", - /* 403 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", - /* 404 */ "stream_options ::= stream_options WATERMARK duration_literal", - /* 405 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", - /* 406 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", - /* 407 */ "stream_options ::= stream_options DELETE_MARK duration_literal", - /* 408 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER", - /* 409 */ "subtable_opt ::=", - /* 410 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", - /* 411 */ "ignore_opt ::=", - /* 412 */ "ignore_opt ::= IGNORE UNTREATED", - /* 413 */ "cmd ::= KILL CONNECTION NK_INTEGER", - /* 414 */ "cmd ::= KILL QUERY NK_STRING", - /* 415 */ "cmd ::= KILL TRANSACTION NK_INTEGER", - /* 416 */ "cmd ::= KILL COMPACT NK_INTEGER", - /* 417 */ "cmd ::= BALANCE VGROUP", - /* 418 */ "cmd ::= BALANCE VGROUP LEADER on_vgroup_id", - /* 419 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", - /* 420 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", - /* 421 */ "cmd ::= SPLIT VGROUP NK_INTEGER", - /* 422 */ "on_vgroup_id ::=", - /* 423 */ "on_vgroup_id ::= ON NK_INTEGER", - /* 424 */ "dnode_list ::= DNODE NK_INTEGER", - /* 425 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", - /* 426 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", - /* 427 */ "cmd ::= query_or_subquery", - /* 428 */ "cmd ::= insert_query", - /* 429 */ "insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", - /* 430 */ "insert_query ::= INSERT INTO full_table_name query_or_subquery", - /* 431 */ "tags_literal ::= NK_INTEGER", - /* 432 */ "tags_literal ::= NK_INTEGER NK_PLUS duration_literal", - /* 433 */ "tags_literal ::= NK_INTEGER NK_MINUS duration_literal", - /* 434 */ "tags_literal ::= NK_PLUS NK_INTEGER", - /* 435 */ "tags_literal ::= NK_PLUS NK_INTEGER NK_PLUS duration_literal", - /* 436 */ "tags_literal ::= NK_PLUS NK_INTEGER NK_MINUS duration_literal", - /* 437 */ "tags_literal ::= NK_MINUS NK_INTEGER", - /* 438 */ "tags_literal ::= NK_MINUS NK_INTEGER NK_PLUS duration_literal", - /* 439 */ "tags_literal ::= NK_MINUS NK_INTEGER NK_MINUS duration_literal", - /* 440 */ "tags_literal ::= NK_FLOAT", - /* 441 */ "tags_literal ::= NK_PLUS NK_FLOAT", - /* 442 */ "tags_literal ::= NK_MINUS NK_FLOAT", - /* 443 */ "tags_literal ::= NK_BIN", - /* 444 */ "tags_literal ::= NK_BIN NK_PLUS duration_literal", - /* 445 */ "tags_literal ::= NK_BIN NK_MINUS duration_literal", - /* 446 */ "tags_literal ::= NK_PLUS NK_BIN", - /* 447 */ "tags_literal ::= NK_PLUS NK_BIN NK_PLUS duration_literal", - /* 448 */ "tags_literal ::= NK_PLUS NK_BIN NK_MINUS duration_literal", - /* 449 */ "tags_literal ::= NK_MINUS NK_BIN", - /* 450 */ "tags_literal ::= NK_MINUS NK_BIN NK_PLUS duration_literal", - /* 451 */ "tags_literal ::= NK_MINUS NK_BIN NK_MINUS duration_literal", - /* 452 */ "tags_literal ::= NK_HEX", - /* 453 */ "tags_literal ::= NK_HEX NK_PLUS duration_literal", - /* 454 */ "tags_literal ::= NK_HEX NK_MINUS duration_literal", - /* 455 */ "tags_literal ::= NK_PLUS NK_HEX", - /* 456 */ "tags_literal ::= NK_PLUS NK_HEX NK_PLUS duration_literal", - /* 457 */ "tags_literal ::= NK_PLUS NK_HEX NK_MINUS duration_literal", - /* 458 */ "tags_literal ::= NK_MINUS NK_HEX", - /* 459 */ "tags_literal ::= NK_MINUS NK_HEX NK_PLUS duration_literal", - /* 460 */ "tags_literal ::= NK_MINUS NK_HEX NK_MINUS duration_literal", - /* 461 */ "tags_literal ::= NK_STRING", - /* 462 */ "tags_literal ::= NK_STRING NK_PLUS duration_literal", - /* 463 */ "tags_literal ::= NK_STRING NK_MINUS duration_literal", - /* 464 */ "tags_literal ::= NK_BOOL", - /* 465 */ "tags_literal ::= NULL", - /* 466 */ "tags_literal ::= literal_func", - /* 467 */ "tags_literal ::= literal_func NK_PLUS duration_literal", - /* 468 */ "tags_literal ::= literal_func NK_MINUS duration_literal", - /* 469 */ "tags_literal_list ::= tags_literal", - /* 470 */ "tags_literal_list ::= tags_literal_list NK_COMMA tags_literal", - /* 471 */ "literal ::= NK_INTEGER", - /* 472 */ "literal ::= NK_FLOAT", - /* 473 */ "literal ::= NK_STRING", - /* 474 */ "literal ::= NK_BOOL", - /* 475 */ "literal ::= TIMESTAMP NK_STRING", - /* 476 */ "literal ::= duration_literal", - /* 477 */ "literal ::= NULL", - /* 478 */ "literal ::= NK_QUESTION", - /* 479 */ "duration_literal ::= NK_VARIABLE", - /* 480 */ "signed ::= NK_INTEGER", - /* 481 */ "signed ::= NK_PLUS NK_INTEGER", - /* 482 */ "signed ::= NK_MINUS NK_INTEGER", - /* 483 */ "signed ::= NK_FLOAT", - /* 484 */ "signed ::= NK_PLUS NK_FLOAT", - /* 485 */ "signed ::= NK_MINUS NK_FLOAT", - /* 486 */ "signed_literal ::= signed", - /* 487 */ "signed_literal ::= NK_STRING", - /* 488 */ "signed_literal ::= NK_BOOL", - /* 489 */ "signed_literal ::= TIMESTAMP NK_STRING", - /* 490 */ "signed_literal ::= duration_literal", - /* 491 */ "signed_literal ::= NULL", - /* 492 */ "signed_literal ::= literal_func", - /* 493 */ "signed_literal ::= NK_QUESTION", - /* 494 */ "literal_list ::= signed_literal", - /* 495 */ "literal_list ::= literal_list NK_COMMA signed_literal", - /* 496 */ "db_name ::= NK_ID", - /* 497 */ "table_name ::= NK_ID", - /* 498 */ "column_name ::= NK_ID", - /* 499 */ "function_name ::= NK_ID", - /* 500 */ "view_name ::= NK_ID", - /* 501 */ "table_alias ::= NK_ID", - /* 502 */ "column_alias ::= NK_ID", - /* 503 */ "column_alias ::= NK_ALIAS", - /* 504 */ "user_name ::= NK_ID", - /* 505 */ "topic_name ::= NK_ID", - /* 506 */ "stream_name ::= NK_ID", - /* 507 */ "cgroup_name ::= NK_ID", - /* 508 */ "index_name ::= NK_ID", - /* 509 */ "expr_or_subquery ::= expression", - /* 510 */ "expression ::= literal", - /* 511 */ "expression ::= pseudo_column", - /* 512 */ "expression ::= column_reference", - /* 513 */ "expression ::= function_expression", - /* 514 */ "expression ::= case_when_expression", - /* 515 */ "expression ::= NK_LP expression NK_RP", - /* 516 */ "expression ::= NK_PLUS expr_or_subquery", - /* 517 */ "expression ::= NK_MINUS expr_or_subquery", - /* 518 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", - /* 519 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", - /* 520 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", - /* 521 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", - /* 522 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", - /* 523 */ "expression ::= column_reference NK_ARROW NK_STRING", - /* 524 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", - /* 525 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", - /* 526 */ "expression_list ::= expr_or_subquery", - /* 527 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", - /* 528 */ "column_reference ::= column_name", - /* 529 */ "column_reference ::= table_name NK_DOT column_name", - /* 530 */ "column_reference ::= NK_ALIAS", - /* 531 */ "column_reference ::= table_name NK_DOT NK_ALIAS", - /* 532 */ "pseudo_column ::= ROWTS", - /* 533 */ "pseudo_column ::= TBNAME", - /* 534 */ "pseudo_column ::= table_name NK_DOT TBNAME", - /* 535 */ "pseudo_column ::= QSTART", - /* 536 */ "pseudo_column ::= QEND", - /* 537 */ "pseudo_column ::= QDURATION", - /* 538 */ "pseudo_column ::= WSTART", - /* 539 */ "pseudo_column ::= WEND", - /* 540 */ "pseudo_column ::= WDURATION", - /* 541 */ "pseudo_column ::= IROWTS", - /* 542 */ "pseudo_column ::= ISFILLED", - /* 543 */ "pseudo_column ::= QTAGS", - /* 544 */ "function_expression ::= function_name NK_LP expression_list NK_RP", - /* 545 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", - /* 546 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", - /* 547 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name_default_len NK_RP", - /* 548 */ "function_expression ::= literal_func", - /* 549 */ "literal_func ::= noarg_func NK_LP NK_RP", - /* 550 */ "literal_func ::= NOW", - /* 551 */ "literal_func ::= TODAY", - /* 552 */ "noarg_func ::= NOW", - /* 553 */ "noarg_func ::= TODAY", - /* 554 */ "noarg_func ::= TIMEZONE", - /* 555 */ "noarg_func ::= DATABASE", - /* 556 */ "noarg_func ::= CLIENT_VERSION", - /* 557 */ "noarg_func ::= SERVER_VERSION", - /* 558 */ "noarg_func ::= SERVER_STATUS", - /* 559 */ "noarg_func ::= CURRENT_USER", - /* 560 */ "noarg_func ::= USER", - /* 561 */ "star_func ::= COUNT", - /* 562 */ "star_func ::= FIRST", - /* 563 */ "star_func ::= LAST", - /* 564 */ "star_func ::= LAST_ROW", - /* 565 */ "star_func_para_list ::= NK_STAR", - /* 566 */ "star_func_para_list ::= other_para_list", - /* 567 */ "other_para_list ::= star_func_para", - /* 568 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", - /* 569 */ "star_func_para ::= expr_or_subquery", - /* 570 */ "star_func_para ::= table_name NK_DOT NK_STAR", - /* 571 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", - /* 572 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", - /* 573 */ "when_then_list ::= when_then_expr", - /* 574 */ "when_then_list ::= when_then_list when_then_expr", - /* 575 */ "when_then_expr ::= WHEN common_expression THEN common_expression", - /* 576 */ "case_when_else_opt ::=", - /* 577 */ "case_when_else_opt ::= ELSE common_expression", - /* 578 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", - /* 579 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", - /* 580 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", - /* 581 */ "predicate ::= expr_or_subquery IS NULL", - /* 582 */ "predicate ::= expr_or_subquery IS NOT NULL", - /* 583 */ "predicate ::= expr_or_subquery in_op in_predicate_value", - /* 584 */ "compare_op ::= NK_LT", - /* 585 */ "compare_op ::= NK_GT", - /* 586 */ "compare_op ::= NK_LE", - /* 587 */ "compare_op ::= NK_GE", - /* 588 */ "compare_op ::= NK_NE", - /* 589 */ "compare_op ::= NK_EQ", - /* 590 */ "compare_op ::= LIKE", - /* 591 */ "compare_op ::= NOT LIKE", - /* 592 */ "compare_op ::= MATCH", - /* 593 */ "compare_op ::= NMATCH", - /* 594 */ "compare_op ::= CONTAINS", - /* 595 */ "in_op ::= IN", - /* 596 */ "in_op ::= NOT IN", - /* 597 */ "in_predicate_value ::= NK_LP literal_list NK_RP", - /* 598 */ "boolean_value_expression ::= boolean_primary", - /* 599 */ "boolean_value_expression ::= NOT boolean_primary", - /* 600 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", - /* 601 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", - /* 602 */ "boolean_primary ::= predicate", - /* 603 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", - /* 604 */ "common_expression ::= expr_or_subquery", - /* 605 */ "common_expression ::= boolean_value_expression", - /* 606 */ "from_clause_opt ::=", - /* 607 */ "from_clause_opt ::= FROM table_reference_list", - /* 608 */ "table_reference_list ::= table_reference", - /* 609 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", - /* 610 */ "table_reference ::= table_primary", - /* 611 */ "table_reference ::= joined_table", - /* 612 */ "table_primary ::= table_name alias_opt", - /* 613 */ "table_primary ::= db_name NK_DOT table_name alias_opt", - /* 614 */ "table_primary ::= subquery alias_opt", - /* 615 */ "table_primary ::= parenthesized_joined_table", - /* 616 */ "alias_opt ::=", - /* 617 */ "alias_opt ::= table_alias", - /* 618 */ "alias_opt ::= AS table_alias", - /* 619 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", - /* 620 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", - /* 621 */ "joined_table ::= table_reference join_type join_subtype JOIN table_reference join_on_clause_opt window_offset_clause_opt jlimit_clause_opt", - /* 622 */ "join_type ::=", - /* 623 */ "join_type ::= INNER", - /* 624 */ "join_type ::= LEFT", - /* 625 */ "join_type ::= RIGHT", - /* 626 */ "join_type ::= FULL", - /* 627 */ "join_subtype ::=", - /* 628 */ "join_subtype ::= OUTER", - /* 629 */ "join_subtype ::= SEMI", - /* 630 */ "join_subtype ::= ANTI", - /* 631 */ "join_subtype ::= ASOF", - /* 632 */ "join_subtype ::= WINDOW", - /* 633 */ "join_on_clause_opt ::=", - /* 634 */ "join_on_clause_opt ::= ON search_condition", - /* 635 */ "window_offset_clause_opt ::=", - /* 636 */ "window_offset_clause_opt ::= WINDOW_OFFSET NK_LP window_offset_literal NK_COMMA window_offset_literal NK_RP", - /* 637 */ "window_offset_literal ::= NK_VARIABLE", - /* 638 */ "window_offset_literal ::= NK_MINUS NK_VARIABLE", - /* 639 */ "jlimit_clause_opt ::=", - /* 640 */ "jlimit_clause_opt ::= JLIMIT NK_INTEGER", - /* 641 */ "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", - /* 642 */ "hint_list ::=", - /* 643 */ "hint_list ::= NK_HINT", - /* 644 */ "tag_mode_opt ::=", - /* 645 */ "tag_mode_opt ::= TAGS", - /* 646 */ "set_quantifier_opt ::=", - /* 647 */ "set_quantifier_opt ::= DISTINCT", - /* 648 */ "set_quantifier_opt ::= ALL", - /* 649 */ "select_list ::= select_item", - /* 650 */ "select_list ::= select_list NK_COMMA select_item", - /* 651 */ "select_item ::= NK_STAR", - /* 652 */ "select_item ::= common_expression", - /* 653 */ "select_item ::= common_expression column_alias", - /* 654 */ "select_item ::= common_expression AS column_alias", - /* 655 */ "select_item ::= table_name NK_DOT NK_STAR", - /* 656 */ "where_clause_opt ::=", - /* 657 */ "where_clause_opt ::= WHERE search_condition", - /* 658 */ "partition_by_clause_opt ::=", - /* 659 */ "partition_by_clause_opt ::= PARTITION BY partition_list", - /* 660 */ "partition_list ::= partition_item", - /* 661 */ "partition_list ::= partition_list NK_COMMA partition_item", - /* 662 */ "partition_item ::= expr_or_subquery", - /* 663 */ "partition_item ::= expr_or_subquery column_alias", - /* 664 */ "partition_item ::= expr_or_subquery AS column_alias", - /* 665 */ "twindow_clause_opt ::=", - /* 666 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP", - /* 667 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", - /* 668 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt", - /* 669 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt", - /* 670 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", - /* 671 */ "twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP", - /* 672 */ "twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", - /* 673 */ "sliding_opt ::=", - /* 674 */ "sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP", - /* 675 */ "interval_sliding_duration_literal ::= NK_VARIABLE", - /* 676 */ "interval_sliding_duration_literal ::= NK_STRING", - /* 677 */ "interval_sliding_duration_literal ::= NK_INTEGER", - /* 678 */ "fill_opt ::=", - /* 679 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", - /* 680 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP", - /* 681 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP", - /* 682 */ "fill_mode ::= NONE", - /* 683 */ "fill_mode ::= PREV", - /* 684 */ "fill_mode ::= NULL", - /* 685 */ "fill_mode ::= NULL_F", - /* 686 */ "fill_mode ::= LINEAR", - /* 687 */ "fill_mode ::= NEXT", - /* 688 */ "group_by_clause_opt ::=", - /* 689 */ "group_by_clause_opt ::= GROUP BY group_by_list", - /* 690 */ "group_by_list ::= expr_or_subquery", - /* 691 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", - /* 692 */ "having_clause_opt ::=", - /* 693 */ "having_clause_opt ::= HAVING search_condition", - /* 694 */ "range_opt ::=", - /* 695 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", - /* 696 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_RP", - /* 697 */ "every_opt ::=", - /* 698 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", - /* 699 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", - /* 700 */ "query_simple ::= query_specification", - /* 701 */ "query_simple ::= union_query_expression", - /* 702 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", - /* 703 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", - /* 704 */ "query_simple_or_subquery ::= query_simple", - /* 705 */ "query_simple_or_subquery ::= subquery", - /* 706 */ "query_or_subquery ::= query_expression", - /* 707 */ "query_or_subquery ::= subquery", - /* 708 */ "order_by_clause_opt ::=", - /* 709 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", - /* 710 */ "slimit_clause_opt ::=", - /* 711 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", - /* 712 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", - /* 713 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 714 */ "limit_clause_opt ::=", - /* 715 */ "limit_clause_opt ::= LIMIT NK_INTEGER", - /* 716 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", - /* 717 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", - /* 718 */ "subquery ::= NK_LP query_expression NK_RP", - /* 719 */ "subquery ::= NK_LP subquery NK_RP", - /* 720 */ "search_condition ::= common_expression", - /* 721 */ "sort_specification_list ::= sort_specification", - /* 722 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", - /* 723 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", - /* 724 */ "ordering_specification_opt ::=", - /* 725 */ "ordering_specification_opt ::= ASC", - /* 726 */ "ordering_specification_opt ::= DESC", - /* 727 */ "null_ordering_opt ::=", - /* 728 */ "null_ordering_opt ::= NULLS FIRST", - /* 729 */ "null_ordering_opt ::= NULLS LAST", - /* 730 */ "column_options ::=", - /* 731 */ "column_options ::= column_options PRIMARY KEY", - /* 732 */ "column_options ::= column_options ENCODE NK_STRING", - /* 733 */ "column_options ::= column_options COMPRESS NK_STRING", - /* 734 */ "column_options ::= column_options LEVEL NK_STRING", + /* 335 */ "cmd ::= CREATE TSMA not_exists_opt tsma_name ON full_table_name tsma_func_list INTERVAL NK_LP duration_literal NK_RP", + /* 336 */ "cmd ::= CREATE RECURSIVE TSMA not_exists_opt tsma_name ON full_table_name INTERVAL NK_LP duration_literal NK_RP", + /* 337 */ "cmd ::= DROP TSMA exists_opt full_tsma_name", + /* 338 */ "cmd ::= SHOW db_name_cond_opt TSMAS", + /* 339 */ "full_tsma_name ::= tsma_name", + /* 340 */ "full_tsma_name ::= db_name NK_DOT tsma_name", + /* 341 */ "tsma_func_list ::= FUNCTION NK_LP func_list NK_RP", + /* 342 */ "cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options", + /* 343 */ "cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP", + /* 344 */ "cmd ::= DROP INDEX exists_opt full_index_name", + /* 345 */ "full_index_name ::= index_name", + /* 346 */ "full_index_name ::= db_name NK_DOT index_name", + /* 347 */ "index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt", + /* 348 */ "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", + /* 349 */ "func_list ::= func", + /* 350 */ "func_list ::= func_list NK_COMMA func", + /* 351 */ "func ::= sma_func_name NK_LP expression_list NK_RP", + /* 352 */ "sma_func_name ::= function_name", + /* 353 */ "sma_func_name ::= COUNT", + /* 354 */ "sma_func_name ::= FIRST", + /* 355 */ "sma_func_name ::= LAST", + /* 356 */ "sma_func_name ::= LAST_ROW", + /* 357 */ "sma_stream_opt ::=", + /* 358 */ "sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal", + /* 359 */ "sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal", + /* 360 */ "sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal", + /* 361 */ "with_meta ::= AS", + /* 362 */ "with_meta ::= WITH META AS", + /* 363 */ "with_meta ::= ONLY META AS", + /* 364 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery", + /* 365 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name", + /* 366 */ "cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt", + /* 367 */ "cmd ::= DROP TOPIC exists_opt topic_name", + /* 368 */ "cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name", + /* 369 */ "cmd ::= DESC full_table_name", + /* 370 */ "cmd ::= DESCRIBE full_table_name", + /* 371 */ "cmd ::= RESET QUERY CACHE", + /* 372 */ "cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery", + /* 373 */ "cmd ::= EXPLAIN analyze_opt explain_options insert_query", + /* 374 */ "analyze_opt ::=", + /* 375 */ "analyze_opt ::= ANALYZE", + /* 376 */ "explain_options ::=", + /* 377 */ "explain_options ::= explain_options VERBOSE NK_BOOL", + /* 378 */ "explain_options ::= explain_options RATIO NK_FLOAT", + /* 379 */ "cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt", + /* 380 */ "cmd ::= DROP FUNCTION exists_opt function_name", + /* 381 */ "agg_func_opt ::=", + /* 382 */ "agg_func_opt ::= AGGREGATE", + /* 383 */ "bufsize_opt ::=", + /* 384 */ "bufsize_opt ::= BUFSIZE NK_INTEGER", + /* 385 */ "language_opt ::=", + /* 386 */ "language_opt ::= LANGUAGE NK_STRING", + /* 387 */ "or_replace_opt ::=", + /* 388 */ "or_replace_opt ::= OR REPLACE", + /* 389 */ "cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery", + /* 390 */ "cmd ::= DROP VIEW exists_opt full_view_name", + /* 391 */ "full_view_name ::= view_name", + /* 392 */ "full_view_name ::= db_name NK_DOT view_name", + /* 393 */ "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", + /* 394 */ "cmd ::= DROP STREAM exists_opt stream_name", + /* 395 */ "cmd ::= PAUSE STREAM exists_opt stream_name", + /* 396 */ "cmd ::= RESUME STREAM exists_opt ignore_opt stream_name", + /* 397 */ "col_list_opt ::=", + /* 398 */ "col_list_opt ::= NK_LP column_stream_def_list NK_RP", + /* 399 */ "column_stream_def_list ::= column_stream_def", + /* 400 */ "column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def", + /* 401 */ "column_stream_def ::= column_name stream_col_options", + /* 402 */ "stream_col_options ::=", + /* 403 */ "stream_col_options ::= stream_col_options PRIMARY KEY", + /* 404 */ "tag_def_or_ref_opt ::=", + /* 405 */ "tag_def_or_ref_opt ::= tags_def", + /* 406 */ "tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP", + /* 407 */ "stream_options ::=", + /* 408 */ "stream_options ::= stream_options TRIGGER AT_ONCE", + /* 409 */ "stream_options ::= stream_options TRIGGER WINDOW_CLOSE", + /* 410 */ "stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal", + /* 411 */ "stream_options ::= stream_options WATERMARK duration_literal", + /* 412 */ "stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER", + /* 413 */ "stream_options ::= stream_options FILL_HISTORY NK_INTEGER", + /* 414 */ "stream_options ::= stream_options DELETE_MARK duration_literal", + /* 415 */ "stream_options ::= stream_options IGNORE UPDATE NK_INTEGER", + /* 416 */ "subtable_opt ::=", + /* 417 */ "subtable_opt ::= SUBTABLE NK_LP expression NK_RP", + /* 418 */ "ignore_opt ::=", + /* 419 */ "ignore_opt ::= IGNORE UNTREATED", + /* 420 */ "cmd ::= KILL CONNECTION NK_INTEGER", + /* 421 */ "cmd ::= KILL QUERY NK_STRING", + /* 422 */ "cmd ::= KILL TRANSACTION NK_INTEGER", + /* 423 */ "cmd ::= KILL COMPACT NK_INTEGER", + /* 424 */ "cmd ::= BALANCE VGROUP", + /* 425 */ "cmd ::= BALANCE VGROUP LEADER on_vgroup_id", + /* 426 */ "cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER", + /* 427 */ "cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list", + /* 428 */ "cmd ::= SPLIT VGROUP NK_INTEGER", + /* 429 */ "on_vgroup_id ::=", + /* 430 */ "on_vgroup_id ::= ON NK_INTEGER", + /* 431 */ "dnode_list ::= DNODE NK_INTEGER", + /* 432 */ "dnode_list ::= dnode_list DNODE NK_INTEGER", + /* 433 */ "cmd ::= DELETE FROM full_table_name where_clause_opt", + /* 434 */ "cmd ::= query_or_subquery", + /* 435 */ "cmd ::= insert_query", + /* 436 */ "insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery", + /* 437 */ "insert_query ::= INSERT INTO full_table_name query_or_subquery", + /* 438 */ "tags_literal ::= NK_INTEGER", + /* 439 */ "tags_literal ::= NK_INTEGER NK_PLUS duration_literal", + /* 440 */ "tags_literal ::= NK_INTEGER NK_MINUS duration_literal", + /* 441 */ "tags_literal ::= NK_PLUS NK_INTEGER", + /* 442 */ "tags_literal ::= NK_PLUS NK_INTEGER NK_PLUS duration_literal", + /* 443 */ "tags_literal ::= NK_PLUS NK_INTEGER NK_MINUS duration_literal", + /* 444 */ "tags_literal ::= NK_MINUS NK_INTEGER", + /* 445 */ "tags_literal ::= NK_MINUS NK_INTEGER NK_PLUS duration_literal", + /* 446 */ "tags_literal ::= NK_MINUS NK_INTEGER NK_MINUS duration_literal", + /* 447 */ "tags_literal ::= NK_FLOAT", + /* 448 */ "tags_literal ::= NK_PLUS NK_FLOAT", + /* 449 */ "tags_literal ::= NK_MINUS NK_FLOAT", + /* 450 */ "tags_literal ::= NK_BIN", + /* 451 */ "tags_literal ::= NK_BIN NK_PLUS duration_literal", + /* 452 */ "tags_literal ::= NK_BIN NK_MINUS duration_literal", + /* 453 */ "tags_literal ::= NK_PLUS NK_BIN", + /* 454 */ "tags_literal ::= NK_PLUS NK_BIN NK_PLUS duration_literal", + /* 455 */ "tags_literal ::= NK_PLUS NK_BIN NK_MINUS duration_literal", + /* 456 */ "tags_literal ::= NK_MINUS NK_BIN", + /* 457 */ "tags_literal ::= NK_MINUS NK_BIN NK_PLUS duration_literal", + /* 458 */ "tags_literal ::= NK_MINUS NK_BIN NK_MINUS duration_literal", + /* 459 */ "tags_literal ::= NK_HEX", + /* 460 */ "tags_literal ::= NK_HEX NK_PLUS duration_literal", + /* 461 */ "tags_literal ::= NK_HEX NK_MINUS duration_literal", + /* 462 */ "tags_literal ::= NK_PLUS NK_HEX", + /* 463 */ "tags_literal ::= NK_PLUS NK_HEX NK_PLUS duration_literal", + /* 464 */ "tags_literal ::= NK_PLUS NK_HEX NK_MINUS duration_literal", + /* 465 */ "tags_literal ::= NK_MINUS NK_HEX", + /* 466 */ "tags_literal ::= NK_MINUS NK_HEX NK_PLUS duration_literal", + /* 467 */ "tags_literal ::= NK_MINUS NK_HEX NK_MINUS duration_literal", + /* 468 */ "tags_literal ::= NK_STRING", + /* 469 */ "tags_literal ::= NK_STRING NK_PLUS duration_literal", + /* 470 */ "tags_literal ::= NK_STRING NK_MINUS duration_literal", + /* 471 */ "tags_literal ::= NK_BOOL", + /* 472 */ "tags_literal ::= NULL", + /* 473 */ "tags_literal ::= literal_func", + /* 474 */ "tags_literal ::= literal_func NK_PLUS duration_literal", + /* 475 */ "tags_literal ::= literal_func NK_MINUS duration_literal", + /* 476 */ "tags_literal_list ::= tags_literal", + /* 477 */ "tags_literal_list ::= tags_literal_list NK_COMMA tags_literal", + /* 478 */ "literal ::= NK_INTEGER", + /* 479 */ "literal ::= NK_FLOAT", + /* 480 */ "literal ::= NK_STRING", + /* 481 */ "literal ::= NK_BOOL", + /* 482 */ "literal ::= TIMESTAMP NK_STRING", + /* 483 */ "literal ::= duration_literal", + /* 484 */ "literal ::= NULL", + /* 485 */ "literal ::= NK_QUESTION", + /* 486 */ "duration_literal ::= NK_VARIABLE", + /* 487 */ "signed ::= NK_INTEGER", + /* 488 */ "signed ::= NK_PLUS NK_INTEGER", + /* 489 */ "signed ::= NK_MINUS NK_INTEGER", + /* 490 */ "signed ::= NK_FLOAT", + /* 491 */ "signed ::= NK_PLUS NK_FLOAT", + /* 492 */ "signed ::= NK_MINUS NK_FLOAT", + /* 493 */ "signed_literal ::= signed", + /* 494 */ "signed_literal ::= NK_STRING", + /* 495 */ "signed_literal ::= NK_BOOL", + /* 496 */ "signed_literal ::= TIMESTAMP NK_STRING", + /* 497 */ "signed_literal ::= duration_literal", + /* 498 */ "signed_literal ::= NULL", + /* 499 */ "signed_literal ::= literal_func", + /* 500 */ "signed_literal ::= NK_QUESTION", + /* 501 */ "literal_list ::= signed_literal", + /* 502 */ "literal_list ::= literal_list NK_COMMA signed_literal", + /* 503 */ "db_name ::= NK_ID", + /* 504 */ "table_name ::= NK_ID", + /* 505 */ "column_name ::= NK_ID", + /* 506 */ "function_name ::= NK_ID", + /* 507 */ "view_name ::= NK_ID", + /* 508 */ "table_alias ::= NK_ID", + /* 509 */ "column_alias ::= NK_ID", + /* 510 */ "column_alias ::= NK_ALIAS", + /* 511 */ "user_name ::= NK_ID", + /* 512 */ "topic_name ::= NK_ID", + /* 513 */ "stream_name ::= NK_ID", + /* 514 */ "cgroup_name ::= NK_ID", + /* 515 */ "index_name ::= NK_ID", + /* 516 */ "tsma_name ::= NK_ID", + /* 517 */ "expr_or_subquery ::= expression", + /* 518 */ "expression ::= literal", + /* 519 */ "expression ::= pseudo_column", + /* 520 */ "expression ::= column_reference", + /* 521 */ "expression ::= function_expression", + /* 522 */ "expression ::= case_when_expression", + /* 523 */ "expression ::= NK_LP expression NK_RP", + /* 524 */ "expression ::= NK_PLUS expr_or_subquery", + /* 525 */ "expression ::= NK_MINUS expr_or_subquery", + /* 526 */ "expression ::= expr_or_subquery NK_PLUS expr_or_subquery", + /* 527 */ "expression ::= expr_or_subquery NK_MINUS expr_or_subquery", + /* 528 */ "expression ::= expr_or_subquery NK_STAR expr_or_subquery", + /* 529 */ "expression ::= expr_or_subquery NK_SLASH expr_or_subquery", + /* 530 */ "expression ::= expr_or_subquery NK_REM expr_or_subquery", + /* 531 */ "expression ::= column_reference NK_ARROW NK_STRING", + /* 532 */ "expression ::= expr_or_subquery NK_BITAND expr_or_subquery", + /* 533 */ "expression ::= expr_or_subquery NK_BITOR expr_or_subquery", + /* 534 */ "expression_list ::= expr_or_subquery", + /* 535 */ "expression_list ::= expression_list NK_COMMA expr_or_subquery", + /* 536 */ "column_reference ::= column_name", + /* 537 */ "column_reference ::= table_name NK_DOT column_name", + /* 538 */ "column_reference ::= NK_ALIAS", + /* 539 */ "column_reference ::= table_name NK_DOT NK_ALIAS", + /* 540 */ "pseudo_column ::= ROWTS", + /* 541 */ "pseudo_column ::= TBNAME", + /* 542 */ "pseudo_column ::= table_name NK_DOT TBNAME", + /* 543 */ "pseudo_column ::= QSTART", + /* 544 */ "pseudo_column ::= QEND", + /* 545 */ "pseudo_column ::= QDURATION", + /* 546 */ "pseudo_column ::= WSTART", + /* 547 */ "pseudo_column ::= WEND", + /* 548 */ "pseudo_column ::= WDURATION", + /* 549 */ "pseudo_column ::= IROWTS", + /* 550 */ "pseudo_column ::= ISFILLED", + /* 551 */ "pseudo_column ::= QTAGS", + /* 552 */ "function_expression ::= function_name NK_LP expression_list NK_RP", + /* 553 */ "function_expression ::= star_func NK_LP star_func_para_list NK_RP", + /* 554 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP", + /* 555 */ "function_expression ::= CAST NK_LP expr_or_subquery AS type_name_default_len NK_RP", + /* 556 */ "function_expression ::= literal_func", + /* 557 */ "literal_func ::= noarg_func NK_LP NK_RP", + /* 558 */ "literal_func ::= NOW", + /* 559 */ "literal_func ::= TODAY", + /* 560 */ "noarg_func ::= NOW", + /* 561 */ "noarg_func ::= TODAY", + /* 562 */ "noarg_func ::= TIMEZONE", + /* 563 */ "noarg_func ::= DATABASE", + /* 564 */ "noarg_func ::= CLIENT_VERSION", + /* 565 */ "noarg_func ::= SERVER_VERSION", + /* 566 */ "noarg_func ::= SERVER_STATUS", + /* 567 */ "noarg_func ::= CURRENT_USER", + /* 568 */ "noarg_func ::= USER", + /* 569 */ "star_func ::= COUNT", + /* 570 */ "star_func ::= FIRST", + /* 571 */ "star_func ::= LAST", + /* 572 */ "star_func ::= LAST_ROW", + /* 573 */ "star_func_para_list ::= NK_STAR", + /* 574 */ "star_func_para_list ::= other_para_list", + /* 575 */ "other_para_list ::= star_func_para", + /* 576 */ "other_para_list ::= other_para_list NK_COMMA star_func_para", + /* 577 */ "star_func_para ::= expr_or_subquery", + /* 578 */ "star_func_para ::= table_name NK_DOT NK_STAR", + /* 579 */ "case_when_expression ::= CASE when_then_list case_when_else_opt END", + /* 580 */ "case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END", + /* 581 */ "when_then_list ::= when_then_expr", + /* 582 */ "when_then_list ::= when_then_list when_then_expr", + /* 583 */ "when_then_expr ::= WHEN common_expression THEN common_expression", + /* 584 */ "case_when_else_opt ::=", + /* 585 */ "case_when_else_opt ::= ELSE common_expression", + /* 586 */ "predicate ::= expr_or_subquery compare_op expr_or_subquery", + /* 587 */ "predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery", + /* 588 */ "predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery", + /* 589 */ "predicate ::= expr_or_subquery IS NULL", + /* 590 */ "predicate ::= expr_or_subquery IS NOT NULL", + /* 591 */ "predicate ::= expr_or_subquery in_op in_predicate_value", + /* 592 */ "compare_op ::= NK_LT", + /* 593 */ "compare_op ::= NK_GT", + /* 594 */ "compare_op ::= NK_LE", + /* 595 */ "compare_op ::= NK_GE", + /* 596 */ "compare_op ::= NK_NE", + /* 597 */ "compare_op ::= NK_EQ", + /* 598 */ "compare_op ::= LIKE", + /* 599 */ "compare_op ::= NOT LIKE", + /* 600 */ "compare_op ::= MATCH", + /* 601 */ "compare_op ::= NMATCH", + /* 602 */ "compare_op ::= CONTAINS", + /* 603 */ "in_op ::= IN", + /* 604 */ "in_op ::= NOT IN", + /* 605 */ "in_predicate_value ::= NK_LP literal_list NK_RP", + /* 606 */ "boolean_value_expression ::= boolean_primary", + /* 607 */ "boolean_value_expression ::= NOT boolean_primary", + /* 608 */ "boolean_value_expression ::= boolean_value_expression OR boolean_value_expression", + /* 609 */ "boolean_value_expression ::= boolean_value_expression AND boolean_value_expression", + /* 610 */ "boolean_primary ::= predicate", + /* 611 */ "boolean_primary ::= NK_LP boolean_value_expression NK_RP", + /* 612 */ "common_expression ::= expr_or_subquery", + /* 613 */ "common_expression ::= boolean_value_expression", + /* 614 */ "from_clause_opt ::=", + /* 615 */ "from_clause_opt ::= FROM table_reference_list", + /* 616 */ "table_reference_list ::= table_reference", + /* 617 */ "table_reference_list ::= table_reference_list NK_COMMA table_reference", + /* 618 */ "table_reference ::= table_primary", + /* 619 */ "table_reference ::= joined_table", + /* 620 */ "table_primary ::= table_name alias_opt", + /* 621 */ "table_primary ::= db_name NK_DOT table_name alias_opt", + /* 622 */ "table_primary ::= subquery alias_opt", + /* 623 */ "table_primary ::= parenthesized_joined_table", + /* 624 */ "alias_opt ::=", + /* 625 */ "alias_opt ::= table_alias", + /* 626 */ "alias_opt ::= AS table_alias", + /* 627 */ "parenthesized_joined_table ::= NK_LP joined_table NK_RP", + /* 628 */ "parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP", + /* 629 */ "joined_table ::= table_reference join_type join_subtype JOIN table_reference join_on_clause_opt window_offset_clause_opt jlimit_clause_opt", + /* 630 */ "join_type ::=", + /* 631 */ "join_type ::= INNER", + /* 632 */ "join_type ::= LEFT", + /* 633 */ "join_type ::= RIGHT", + /* 634 */ "join_type ::= FULL", + /* 635 */ "join_subtype ::=", + /* 636 */ "join_subtype ::= OUTER", + /* 637 */ "join_subtype ::= SEMI", + /* 638 */ "join_subtype ::= ANTI", + /* 639 */ "join_subtype ::= ASOF", + /* 640 */ "join_subtype ::= WINDOW", + /* 641 */ "join_on_clause_opt ::=", + /* 642 */ "join_on_clause_opt ::= ON search_condition", + /* 643 */ "window_offset_clause_opt ::=", + /* 644 */ "window_offset_clause_opt ::= WINDOW_OFFSET NK_LP window_offset_literal NK_COMMA window_offset_literal NK_RP", + /* 645 */ "window_offset_literal ::= NK_VARIABLE", + /* 646 */ "window_offset_literal ::= NK_MINUS NK_VARIABLE", + /* 647 */ "jlimit_clause_opt ::=", + /* 648 */ "jlimit_clause_opt ::= JLIMIT NK_INTEGER", + /* 649 */ "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", + /* 650 */ "hint_list ::=", + /* 651 */ "hint_list ::= NK_HINT", + /* 652 */ "tag_mode_opt ::=", + /* 653 */ "tag_mode_opt ::= TAGS", + /* 654 */ "set_quantifier_opt ::=", + /* 655 */ "set_quantifier_opt ::= DISTINCT", + /* 656 */ "set_quantifier_opt ::= ALL", + /* 657 */ "select_list ::= select_item", + /* 658 */ "select_list ::= select_list NK_COMMA select_item", + /* 659 */ "select_item ::= NK_STAR", + /* 660 */ "select_item ::= common_expression", + /* 661 */ "select_item ::= common_expression column_alias", + /* 662 */ "select_item ::= common_expression AS column_alias", + /* 663 */ "select_item ::= table_name NK_DOT NK_STAR", + /* 664 */ "where_clause_opt ::=", + /* 665 */ "where_clause_opt ::= WHERE search_condition", + /* 666 */ "partition_by_clause_opt ::=", + /* 667 */ "partition_by_clause_opt ::= PARTITION BY partition_list", + /* 668 */ "partition_list ::= partition_item", + /* 669 */ "partition_list ::= partition_list NK_COMMA partition_item", + /* 670 */ "partition_item ::= expr_or_subquery", + /* 671 */ "partition_item ::= expr_or_subquery column_alias", + /* 672 */ "partition_item ::= expr_or_subquery AS column_alias", + /* 673 */ "twindow_clause_opt ::=", + /* 674 */ "twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP", + /* 675 */ "twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP", + /* 676 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt", + /* 677 */ "twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt", + /* 678 */ "twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition", + /* 679 */ "twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP", + /* 680 */ "twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP", + /* 681 */ "sliding_opt ::=", + /* 682 */ "sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP", + /* 683 */ "interval_sliding_duration_literal ::= NK_VARIABLE", + /* 684 */ "interval_sliding_duration_literal ::= NK_STRING", + /* 685 */ "interval_sliding_duration_literal ::= NK_INTEGER", + /* 686 */ "fill_opt ::=", + /* 687 */ "fill_opt ::= FILL NK_LP fill_mode NK_RP", + /* 688 */ "fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP", + /* 689 */ "fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP", + /* 690 */ "fill_mode ::= NONE", + /* 691 */ "fill_mode ::= PREV", + /* 692 */ "fill_mode ::= NULL", + /* 693 */ "fill_mode ::= NULL_F", + /* 694 */ "fill_mode ::= LINEAR", + /* 695 */ "fill_mode ::= NEXT", + /* 696 */ "group_by_clause_opt ::=", + /* 697 */ "group_by_clause_opt ::= GROUP BY group_by_list", + /* 698 */ "group_by_list ::= expr_or_subquery", + /* 699 */ "group_by_list ::= group_by_list NK_COMMA expr_or_subquery", + /* 700 */ "having_clause_opt ::=", + /* 701 */ "having_clause_opt ::= HAVING search_condition", + /* 702 */ "range_opt ::=", + /* 703 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP", + /* 704 */ "range_opt ::= RANGE NK_LP expr_or_subquery NK_RP", + /* 705 */ "every_opt ::=", + /* 706 */ "every_opt ::= EVERY NK_LP duration_literal NK_RP", + /* 707 */ "query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt", + /* 708 */ "query_simple ::= query_specification", + /* 709 */ "query_simple ::= union_query_expression", + /* 710 */ "union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery", + /* 711 */ "union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery", + /* 712 */ "query_simple_or_subquery ::= query_simple", + /* 713 */ "query_simple_or_subquery ::= subquery", + /* 714 */ "query_or_subquery ::= query_expression", + /* 715 */ "query_or_subquery ::= subquery", + /* 716 */ "order_by_clause_opt ::=", + /* 717 */ "order_by_clause_opt ::= ORDER BY sort_specification_list", + /* 718 */ "slimit_clause_opt ::=", + /* 719 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER", + /* 720 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER", + /* 721 */ "slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 722 */ "limit_clause_opt ::=", + /* 723 */ "limit_clause_opt ::= LIMIT NK_INTEGER", + /* 724 */ "limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER", + /* 725 */ "limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER", + /* 726 */ "subquery ::= NK_LP query_expression NK_RP", + /* 727 */ "subquery ::= NK_LP subquery NK_RP", + /* 728 */ "search_condition ::= common_expression", + /* 729 */ "sort_specification_list ::= sort_specification", + /* 730 */ "sort_specification_list ::= sort_specification_list NK_COMMA sort_specification", + /* 731 */ "sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt", + /* 732 */ "ordering_specification_opt ::=", + /* 733 */ "ordering_specification_opt ::= ASC", + /* 734 */ "ordering_specification_opt ::= DESC", + /* 735 */ "null_ordering_opt ::=", + /* 736 */ "null_ordering_opt ::= NULLS FIRST", + /* 737 */ "null_ordering_opt ::= NULLS LAST", + /* 738 */ "column_options ::=", + /* 739 */ "column_options ::= column_options PRIMARY KEY", + /* 740 */ "column_options ::= column_options ENCODE NK_STRING", + /* 741 */ "column_options ::= column_options COMPRESS NK_STRING", + /* 742 */ "column_options ::= column_options LEVEL NK_STRING", }; #endif /* NDEBUG */ @@ -3355,287 +3387,296 @@ static void yy_destructor( */ /********* Begin destructor definitions ***************************************/ /* Default NON-TERMINAL Destructor */ - 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: /* column_options */ - case 417: /* tags_literal */ - case 418: /* create_subtable_clause */ - case 421: /* drop_table_clause */ - case 424: /* tag_def */ - case 425: /* column_def */ - case 430: /* duration_literal */ - case 431: /* rollup_func_name */ - case 433: /* col_name */ - case 436: /* like_pattern_opt */ - case 437: /* db_name_cond_opt */ - case 438: /* table_name_cond */ - case 439: /* from_db_opt */ - case 442: /* tag_item */ - case 444: /* index_options */ - case 445: /* 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: /* stream_col_options */ - case 475: /* expression */ - case 478: /* literal_func */ - case 479: /* signed_literal */ - case 482: /* expr_or_subquery */ - case 483: /* pseudo_column */ - case 484: /* column_reference */ - case 485: /* function_expression */ - case 486: /* case_when_expression */ - case 491: /* star_func_para */ - case 493: /* case_when_else_opt */ - case 494: /* common_expression */ - case 495: /* when_then_expr */ - case 496: /* predicate */ - case 499: /* in_predicate_value */ - case 500: /* boolean_value_expression */ - case 501: /* boolean_primary */ - case 502: /* from_clause_opt */ - case 503: /* table_reference_list */ - case 504: /* table_reference */ - case 505: /* table_primary */ - case 506: /* joined_table */ - case 508: /* subquery */ - case 509: /* parenthesized_joined_table */ - case 512: /* join_on_clause_opt */ - case 513: /* window_offset_clause_opt */ - case 514: /* jlimit_clause_opt */ - case 515: /* window_offset_literal */ - case 516: /* query_specification */ - case 522: /* range_opt */ - case 523: /* every_opt */ - case 524: /* fill_opt */ - case 525: /* twindow_clause_opt */ - case 527: /* having_clause_opt */ - case 528: /* select_item */ - case 530: /* partition_item */ - case 531: /* interval_sliding_duration_literal */ - case 534: /* query_expression */ - case 535: /* query_simple */ - case 537: /* slimit_clause_opt */ - case 538: /* limit_clause_opt */ - case 539: /* union_query_expression */ - case 540: /* query_simple_or_subquery */ - case 542: /* sort_specification */ + case 373: /* cmd */ + case 376: /* literal */ + case 385: /* with_opt */ + case 391: /* search_condition */ + case 396: /* db_options */ + case 398: /* alter_db_options */ + case 400: /* start_opt */ + case 401: /* end_opt */ + case 405: /* signed */ + case 407: /* retention */ + case 408: /* full_table_name */ + case 411: /* table_options */ + case 415: /* alter_table_clause */ + case 416: /* alter_table_options */ + case 419: /* column_options */ + case 420: /* tags_literal */ + case 421: /* create_subtable_clause */ + case 424: /* drop_table_clause */ + case 427: /* tag_def */ + case 428: /* column_def */ + case 433: /* duration_literal */ + case 434: /* rollup_func_name */ + case 436: /* col_name */ + case 439: /* like_pattern_opt */ + case 440: /* db_name_cond_opt */ + case 441: /* table_name_cond */ + case 442: /* from_db_opt */ + case 445: /* tag_item */ + case 449: /* full_tsma_name */ + case 451: /* index_options */ + case 452: /* full_index_name */ + case 454: /* sliding_opt */ + case 455: /* sma_stream_opt */ + case 456: /* func */ + case 460: /* query_or_subquery */ + case 461: /* where_clause_opt */ + case 464: /* explain_options */ + case 465: /* insert_query */ + case 470: /* full_view_name */ + case 473: /* stream_options */ + case 476: /* subtable_opt */ + case 479: /* column_stream_def */ + case 480: /* stream_col_options */ + case 481: /* expression */ + case 484: /* literal_func */ + case 485: /* signed_literal */ + case 488: /* expr_or_subquery */ + case 489: /* pseudo_column */ + case 490: /* column_reference */ + case 491: /* function_expression */ + case 492: /* case_when_expression */ + case 497: /* star_func_para */ + case 499: /* case_when_else_opt */ + case 500: /* common_expression */ + case 501: /* when_then_expr */ + case 502: /* predicate */ + case 505: /* in_predicate_value */ + case 506: /* boolean_value_expression */ + case 507: /* boolean_primary */ + case 508: /* from_clause_opt */ + case 509: /* table_reference_list */ + case 510: /* table_reference */ + case 511: /* table_primary */ + case 512: /* joined_table */ + case 514: /* subquery */ + case 515: /* parenthesized_joined_table */ + case 518: /* join_on_clause_opt */ + case 519: /* window_offset_clause_opt */ + case 520: /* jlimit_clause_opt */ + case 521: /* window_offset_literal */ + case 522: /* query_specification */ + case 528: /* range_opt */ + case 529: /* every_opt */ + case 530: /* fill_opt */ + case 531: /* twindow_clause_opt */ + case 533: /* having_clause_opt */ + case 534: /* select_item */ + case 536: /* partition_item */ + case 537: /* interval_sliding_duration_literal */ + case 540: /* query_expression */ + case 541: /* query_simple */ + case 543: /* slimit_clause_opt */ + case 544: /* limit_clause_opt */ + case 545: /* union_query_expression */ + case 546: /* query_simple_or_subquery */ + case 548: /* sort_specification */ { #line 7 "sql.y" - nodesDestroyNode((yypminor->yy722)); -#line 3446 "sql.c" + nodesDestroyNode((yypminor->yy826)); +#line 3479 "sql.c" } break; - 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 */ + case 374: /* account_options */ + case 375: /* alter_account_options */ + case 377: /* alter_account_option */ + case 399: /* speed_opt */ + case 459: /* with_meta */ + case 468: /* bufsize_opt */ { #line 54 "sql.y" -#line 3458 "sql.c" +#line 3491 "sql.c" } break; - 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 419: /* specific_cols_opt */ - case 420: /* tags_literal_list */ - case 422: /* col_name_list */ - case 423: /* tag_def_list */ - case 427: /* duration_list */ - case 428: /* rollup_func_list */ - case 440: /* tag_list_opt */ - case 447: /* 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 477: /* dnode_list */ - case 480: /* literal_list */ - case 488: /* star_func_para_list */ - case 490: /* other_para_list */ - case 492: /* when_then_list */ - case 517: /* hint_list */ - case 520: /* select_list */ - case 521: /* partition_by_clause_opt */ - case 526: /* group_by_clause_opt */ - case 529: /* partition_list */ - case 533: /* group_by_list */ - case 536: /* order_by_clause_opt */ - case 541: /* sort_specification_list */ + case 378: /* ip_range_list */ + case 379: /* white_list */ + case 380: /* white_list_opt */ + case 402: /* integer_list */ + case 403: /* variable_list */ + case 404: /* retention_list */ + case 409: /* column_def_list */ + case 410: /* tags_def_opt */ + case 412: /* multi_create_clause */ + case 413: /* tags_def */ + case 414: /* multi_drop_clause */ + case 422: /* specific_cols_opt */ + case 423: /* tags_literal_list */ + case 425: /* col_name_list */ + case 426: /* tag_def_list */ + case 430: /* duration_list */ + case 431: /* rollup_func_list */ + case 443: /* tag_list_opt */ + case 450: /* func_list */ + case 458: /* expression_list */ + case 474: /* col_list_opt */ + case 475: /* tag_def_or_ref_opt */ + case 478: /* column_stream_def_list */ + case 483: /* dnode_list */ + case 486: /* literal_list */ + case 494: /* star_func_para_list */ + case 496: /* other_para_list */ + case 498: /* when_then_list */ + case 523: /* hint_list */ + case 526: /* select_list */ + case 527: /* partition_by_clause_opt */ + case 532: /* group_by_clause_opt */ + case 535: /* partition_list */ + case 539: /* group_by_list */ + case 542: /* order_by_clause_opt */ + case 547: /* sort_specification_list */ { #line 85 "sql.y" - nodesDestroyList((yypminor->yy694)); -#line 3500 "sql.c" + nodesDestroyList((yypminor->yy616)); +#line 3533 "sql.c" } break; - 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 432: /* function_name */ - case 443: /* column_alias */ - case 446: /* index_name */ - case 451: /* sma_func_name */ - case 456: /* cgroup_name */ - case 463: /* language_opt */ - case 465: /* view_name */ - case 466: /* stream_name */ - case 476: /* on_vgroup_id */ - case 481: /* table_alias */ - case 487: /* star_func */ - case 489: /* noarg_func */ - case 507: /* alias_opt */ + case 381: /* user_name */ + case 388: /* db_name */ + case 389: /* table_name */ + case 390: /* topic_name */ + case 392: /* dnode_endpoint */ + case 417: /* column_name */ + case 435: /* function_name */ + case 446: /* column_alias */ + case 447: /* tsma_name */ + case 453: /* index_name */ + case 457: /* sma_func_name */ + case 462: /* cgroup_name */ + case 469: /* language_opt */ + case 471: /* view_name */ + case 472: /* stream_name */ + case 482: /* on_vgroup_id */ + case 487: /* table_alias */ + case 493: /* star_func */ + case 495: /* noarg_func */ + case 513: /* alias_opt */ { -#line 1044 "sql.y" +#line 1061 "sql.y" -#line 3525 "sql.c" +#line 3559 "sql.c" } break; - case 379: /* sysinfo_opt */ + case 382: /* sysinfo_opt */ { #line 112 "sql.y" -#line 3532 "sql.c" +#line 3566 "sql.c" } break; - case 380: /* privileges */ - case 383: /* priv_type_list */ - case 384: /* priv_type */ + case 383: /* privileges */ + case 386: /* priv_type_list */ + case 387: /* priv_type */ { #line 121 "sql.y" -#line 3541 "sql.c" +#line 3575 "sql.c" } break; - case 381: /* priv_level */ + case 384: /* priv_level */ { #line 138 "sql.y" -#line 3548 "sql.c" +#line 3582 "sql.c" } break; - 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 518: /* set_quantifier_opt */ - case 519: /* tag_mode_opt */ + case 393: /* force_opt */ + case 394: /* unsafe_opt */ + case 395: /* not_exists_opt */ + case 397: /* exists_opt */ + case 463: /* analyze_opt */ + case 466: /* or_replace_opt */ + case 467: /* agg_func_opt */ + case 477: /* ignore_opt */ + case 524: /* set_quantifier_opt */ + case 525: /* tag_mode_opt */ { #line 167 "sql.y" -#line 3564 "sql.c" +#line 3598 "sql.c" } break; - case 403: /* alter_db_option */ - case 429: /* alter_table_option */ + case 406: /* alter_db_option */ + case 432: /* alter_table_option */ { #line 274 "sql.y" -#line 3572 "sql.c" +#line 3606 "sql.c" } break; - case 415: /* type_name */ - case 426: /* type_name_default_len */ + case 418: /* type_name */ + case 429: /* type_name_default_len */ { #line 408 "sql.y" -#line 3580 "sql.c" +#line 3614 "sql.c" } break; - case 434: /* db_kind_opt */ - case 441: /* table_kind */ + case 437: /* db_kind_opt */ + case 444: /* table_kind */ { #line 584 "sql.y" -#line 3588 "sql.c" +#line 3622 "sql.c" } break; - case 435: /* table_kind_db_name_cond_opt */ + case 438: /* table_kind_db_name_cond_opt */ { #line 549 "sql.y" -#line 3595 "sql.c" +#line 3629 "sql.c" } break; - case 497: /* compare_op */ - case 498: /* in_op */ + case 448: /* tsma_func_list */ { -#line 1238 "sql.y" - -#line 3603 "sql.c" +#line 603 "sql.y" + nodesDestroyNode((yypminor->yy826)); +#line 3636 "sql.c" } break; - case 510: /* join_type */ + case 503: /* compare_op */ + case 504: /* in_op */ { -#line 1319 "sql.y" +#line 1259 "sql.y" -#line 3610 "sql.c" +#line 3644 "sql.c" } break; - case 511: /* join_subtype */ + case 516: /* join_type */ { -#line 1327 "sql.y" +#line 1340 "sql.y" -#line 3617 "sql.c" +#line 3651 "sql.c" } break; - case 532: /* fill_mode */ + case 517: /* join_subtype */ { -#line 1443 "sql.y" +#line 1348 "sql.y" -#line 3624 "sql.c" +#line 3658 "sql.c" } break; - case 543: /* ordering_specification_opt */ + case 538: /* fill_mode */ { -#line 1528 "sql.y" +#line 1464 "sql.y" -#line 3631 "sql.c" +#line 3665 "sql.c" } break; - case 544: /* null_ordering_opt */ + case 549: /* ordering_specification_opt */ { -#line 1534 "sql.y" +#line 1549 "sql.y" -#line 3638 "sql.c" +#line 3672 "sql.c" +} + break; + case 550: /* null_ordering_opt */ +{ +#line 1555 "sql.y" + +#line 3679 "sql.c" } break; /********* End destructor definitions *****************************************/ @@ -3924,741 +3965,749 @@ static void yy_shift( /* For rule J, yyRuleInfoLhs[J] contains the symbol on the left-hand side ** of that rule */ static const YYCODETYPE yyRuleInfoLhs[] = { - 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 MODIFY COLUMN column_name column_options */ - 412, /* (185) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ - 412, /* (186) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ - 412, /* (187) alter_table_clause ::= full_table_name DROP TAG column_name */ - 412, /* (188) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ - 412, /* (189) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ - 412, /* (190) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ tags_literal */ - 409, /* (191) multi_create_clause ::= create_subtable_clause */ - 409, /* (192) multi_create_clause ::= multi_create_clause create_subtable_clause */ - 418, /* (193) 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, /* (194) multi_drop_clause ::= drop_table_clause */ - 411, /* (195) multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ - 421, /* (196) drop_table_clause ::= exists_opt full_table_name */ - 419, /* (197) specific_cols_opt ::= */ - 419, /* (198) specific_cols_opt ::= NK_LP col_name_list NK_RP */ - 405, /* (199) full_table_name ::= table_name */ - 405, /* (200) full_table_name ::= db_name NK_DOT table_name */ - 423, /* (201) tag_def_list ::= tag_def */ - 423, /* (202) tag_def_list ::= tag_def_list NK_COMMA tag_def */ - 424, /* (203) tag_def ::= column_name type_name */ - 406, /* (204) column_def_list ::= column_def */ - 406, /* (205) column_def_list ::= column_def_list NK_COMMA column_def */ - 425, /* (206) column_def ::= column_name type_name column_options */ - 415, /* (207) type_name ::= BOOL */ - 415, /* (208) type_name ::= TINYINT */ - 415, /* (209) type_name ::= SMALLINT */ - 415, /* (210) type_name ::= INT */ - 415, /* (211) type_name ::= INTEGER */ - 415, /* (212) type_name ::= BIGINT */ - 415, /* (213) type_name ::= FLOAT */ - 415, /* (214) type_name ::= DOUBLE */ - 415, /* (215) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ - 415, /* (216) type_name ::= TIMESTAMP */ - 415, /* (217) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ - 415, /* (218) type_name ::= TINYINT UNSIGNED */ - 415, /* (219) type_name ::= SMALLINT UNSIGNED */ - 415, /* (220) type_name ::= INT UNSIGNED */ - 415, /* (221) type_name ::= BIGINT UNSIGNED */ - 415, /* (222) type_name ::= JSON */ - 415, /* (223) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ - 415, /* (224) type_name ::= MEDIUMBLOB */ - 415, /* (225) type_name ::= BLOB */ - 415, /* (226) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ - 415, /* (227) type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ - 415, /* (228) type_name ::= DECIMAL */ - 415, /* (229) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ - 415, /* (230) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - 426, /* (231) type_name_default_len ::= BINARY */ - 426, /* (232) type_name_default_len ::= NCHAR */ - 426, /* (233) type_name_default_len ::= VARCHAR */ - 426, /* (234) type_name_default_len ::= VARBINARY */ - 407, /* (235) tags_def_opt ::= */ - 407, /* (236) tags_def_opt ::= tags_def */ - 410, /* (237) tags_def ::= TAGS NK_LP tag_def_list NK_RP */ - 408, /* (238) table_options ::= */ - 408, /* (239) table_options ::= table_options COMMENT NK_STRING */ - 408, /* (240) table_options ::= table_options MAX_DELAY duration_list */ - 408, /* (241) table_options ::= table_options WATERMARK duration_list */ - 408, /* (242) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ - 408, /* (243) table_options ::= table_options TTL NK_INTEGER */ - 408, /* (244) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ - 408, /* (245) table_options ::= table_options DELETE_MARK duration_list */ - 413, /* (246) alter_table_options ::= alter_table_option */ - 413, /* (247) alter_table_options ::= alter_table_options alter_table_option */ - 429, /* (248) alter_table_option ::= COMMENT NK_STRING */ - 429, /* (249) alter_table_option ::= TTL NK_INTEGER */ - 427, /* (250) duration_list ::= duration_literal */ - 427, /* (251) duration_list ::= duration_list NK_COMMA duration_literal */ - 428, /* (252) rollup_func_list ::= rollup_func_name */ - 428, /* (253) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ - 431, /* (254) rollup_func_name ::= function_name */ - 431, /* (255) rollup_func_name ::= FIRST */ - 431, /* (256) rollup_func_name ::= LAST */ - 422, /* (257) col_name_list ::= col_name */ - 422, /* (258) col_name_list ::= col_name_list NK_COMMA col_name */ - 433, /* (259) col_name ::= column_name */ - 370, /* (260) cmd ::= SHOW DNODES */ - 370, /* (261) cmd ::= SHOW USERS */ - 370, /* (262) cmd ::= SHOW USER PRIVILEGES */ - 370, /* (263) cmd ::= SHOW db_kind_opt DATABASES */ - 370, /* (264) cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ - 370, /* (265) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ - 370, /* (266) cmd ::= SHOW db_name_cond_opt VGROUPS */ - 370, /* (267) cmd ::= SHOW MNODES */ - 370, /* (268) cmd ::= SHOW QNODES */ - 370, /* (269) cmd ::= SHOW ARBGROUPS */ - 370, /* (270) cmd ::= SHOW FUNCTIONS */ - 370, /* (271) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ - 370, /* (272) cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ - 370, /* (273) cmd ::= SHOW STREAMS */ - 370, /* (274) cmd ::= SHOW ACCOUNTS */ - 370, /* (275) cmd ::= SHOW APPS */ - 370, /* (276) cmd ::= SHOW CONNECTIONS */ - 370, /* (277) cmd ::= SHOW LICENCES */ - 370, /* (278) cmd ::= SHOW GRANTS */ - 370, /* (279) cmd ::= SHOW GRANTS FULL */ - 370, /* (280) cmd ::= SHOW GRANTS LOGS */ - 370, /* (281) cmd ::= SHOW CLUSTER MACHINES */ - 370, /* (282) cmd ::= SHOW CREATE DATABASE db_name */ - 370, /* (283) cmd ::= SHOW CREATE TABLE full_table_name */ - 370, /* (284) cmd ::= SHOW CREATE STABLE full_table_name */ - 370, /* (285) cmd ::= SHOW QUERIES */ - 370, /* (286) cmd ::= SHOW SCORES */ - 370, /* (287) cmd ::= SHOW TOPICS */ - 370, /* (288) cmd ::= SHOW VARIABLES */ - 370, /* (289) cmd ::= SHOW CLUSTER VARIABLES */ - 370, /* (290) cmd ::= SHOW LOCAL VARIABLES */ - 370, /* (291) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ - 370, /* (292) cmd ::= SHOW BNODES */ - 370, /* (293) cmd ::= SHOW SNODES */ - 370, /* (294) cmd ::= SHOW CLUSTER */ - 370, /* (295) cmd ::= SHOW TRANSACTIONS */ - 370, /* (296) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ - 370, /* (297) cmd ::= SHOW CONSUMERS */ - 370, /* (298) cmd ::= SHOW SUBSCRIPTIONS */ - 370, /* (299) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ - 370, /* (300) cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ - 370, /* (301) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ - 370, /* (302) cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ - 370, /* (303) cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ - 370, /* (304) cmd ::= SHOW VNODES */ - 370, /* (305) cmd ::= SHOW db_name_cond_opt ALIVE */ - 370, /* (306) cmd ::= SHOW CLUSTER ALIVE */ - 370, /* (307) cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ - 370, /* (308) cmd ::= SHOW CREATE VIEW full_table_name */ - 370, /* (309) cmd ::= SHOW COMPACTS */ - 370, /* (310) cmd ::= SHOW COMPACT NK_INTEGER */ - 435, /* (311) table_kind_db_name_cond_opt ::= */ - 435, /* (312) table_kind_db_name_cond_opt ::= table_kind */ - 435, /* (313) table_kind_db_name_cond_opt ::= db_name NK_DOT */ - 435, /* (314) table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ - 441, /* (315) table_kind ::= NORMAL */ - 441, /* (316) table_kind ::= CHILD */ - 437, /* (317) db_name_cond_opt ::= */ - 437, /* (318) db_name_cond_opt ::= db_name NK_DOT */ - 436, /* (319) like_pattern_opt ::= */ - 436, /* (320) like_pattern_opt ::= LIKE NK_STRING */ - 438, /* (321) table_name_cond ::= table_name */ - 439, /* (322) from_db_opt ::= */ - 439, /* (323) from_db_opt ::= FROM db_name */ - 440, /* (324) tag_list_opt ::= */ - 440, /* (325) tag_list_opt ::= tag_item */ - 440, /* (326) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ - 442, /* (327) tag_item ::= TBNAME */ - 442, /* (328) tag_item ::= QTAGS */ - 442, /* (329) tag_item ::= column_name */ - 442, /* (330) tag_item ::= column_name column_alias */ - 442, /* (331) tag_item ::= column_name AS column_alias */ - 434, /* (332) db_kind_opt ::= */ - 434, /* (333) db_kind_opt ::= USER */ - 434, /* (334) db_kind_opt ::= SYSTEM */ - 370, /* (335) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ - 370, /* (336) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ - 370, /* (337) cmd ::= DROP INDEX exists_opt full_index_name */ - 445, /* (338) full_index_name ::= index_name */ - 445, /* (339) full_index_name ::= db_name NK_DOT index_name */ - 444, /* (340) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - 444, /* (341) 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 */ - 447, /* (342) func_list ::= func */ - 447, /* (343) func_list ::= func_list NK_COMMA func */ - 450, /* (344) func ::= sma_func_name NK_LP expression_list NK_RP */ - 451, /* (345) sma_func_name ::= function_name */ - 451, /* (346) sma_func_name ::= COUNT */ - 451, /* (347) sma_func_name ::= FIRST */ - 451, /* (348) sma_func_name ::= LAST */ - 451, /* (349) sma_func_name ::= LAST_ROW */ - 449, /* (350) sma_stream_opt ::= */ - 449, /* (351) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ - 449, /* (352) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ - 449, /* (353) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ - 453, /* (354) with_meta ::= AS */ - 453, /* (355) with_meta ::= WITH META AS */ - 453, /* (356) with_meta ::= ONLY META AS */ - 370, /* (357) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ - 370, /* (358) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ - 370, /* (359) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ - 370, /* (360) cmd ::= DROP TOPIC exists_opt topic_name */ - 370, /* (361) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - 370, /* (362) cmd ::= DESC full_table_name */ - 370, /* (363) cmd ::= DESCRIBE full_table_name */ - 370, /* (364) cmd ::= RESET QUERY CACHE */ - 370, /* (365) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - 370, /* (366) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ - 457, /* (367) analyze_opt ::= */ - 457, /* (368) analyze_opt ::= ANALYZE */ - 458, /* (369) explain_options ::= */ - 458, /* (370) explain_options ::= explain_options VERBOSE NK_BOOL */ - 458, /* (371) explain_options ::= explain_options RATIO NK_FLOAT */ - 370, /* (372) 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, /* (373) cmd ::= DROP FUNCTION exists_opt function_name */ - 461, /* (374) agg_func_opt ::= */ - 461, /* (375) agg_func_opt ::= AGGREGATE */ - 462, /* (376) bufsize_opt ::= */ - 462, /* (377) bufsize_opt ::= BUFSIZE NK_INTEGER */ - 463, /* (378) language_opt ::= */ - 463, /* (379) language_opt ::= LANGUAGE NK_STRING */ - 460, /* (380) or_replace_opt ::= */ - 460, /* (381) or_replace_opt ::= OR REPLACE */ - 370, /* (382) cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ - 370, /* (383) cmd ::= DROP VIEW exists_opt full_view_name */ - 464, /* (384) full_view_name ::= view_name */ - 464, /* (385) full_view_name ::= db_name NK_DOT view_name */ - 370, /* (386) 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, /* (387) cmd ::= DROP STREAM exists_opt stream_name */ - 370, /* (388) cmd ::= PAUSE STREAM exists_opt stream_name */ - 370, /* (389) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ - 468, /* (390) col_list_opt ::= */ - 468, /* (391) col_list_opt ::= NK_LP column_stream_def_list NK_RP */ - 472, /* (392) column_stream_def_list ::= column_stream_def */ - 472, /* (393) column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def */ - 473, /* (394) column_stream_def ::= column_name stream_col_options */ - 474, /* (395) stream_col_options ::= */ - 474, /* (396) stream_col_options ::= stream_col_options PRIMARY KEY */ - 469, /* (397) tag_def_or_ref_opt ::= */ - 469, /* (398) tag_def_or_ref_opt ::= tags_def */ - 469, /* (399) tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP */ - 467, /* (400) stream_options ::= */ - 467, /* (401) stream_options ::= stream_options TRIGGER AT_ONCE */ - 467, /* (402) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - 467, /* (403) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - 467, /* (404) stream_options ::= stream_options WATERMARK duration_literal */ - 467, /* (405) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ - 467, /* (406) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ - 467, /* (407) stream_options ::= stream_options DELETE_MARK duration_literal */ - 467, /* (408) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ - 470, /* (409) subtable_opt ::= */ - 470, /* (410) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - 471, /* (411) ignore_opt ::= */ - 471, /* (412) ignore_opt ::= IGNORE UNTREATED */ - 370, /* (413) cmd ::= KILL CONNECTION NK_INTEGER */ - 370, /* (414) cmd ::= KILL QUERY NK_STRING */ - 370, /* (415) cmd ::= KILL TRANSACTION NK_INTEGER */ - 370, /* (416) cmd ::= KILL COMPACT NK_INTEGER */ - 370, /* (417) cmd ::= BALANCE VGROUP */ - 370, /* (418) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ - 370, /* (419) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - 370, /* (420) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - 370, /* (421) cmd ::= SPLIT VGROUP NK_INTEGER */ - 476, /* (422) on_vgroup_id ::= */ - 476, /* (423) on_vgroup_id ::= ON NK_INTEGER */ - 477, /* (424) dnode_list ::= DNODE NK_INTEGER */ - 477, /* (425) dnode_list ::= dnode_list DNODE NK_INTEGER */ - 370, /* (426) cmd ::= DELETE FROM full_table_name where_clause_opt */ - 370, /* (427) cmd ::= query_or_subquery */ - 370, /* (428) cmd ::= insert_query */ - 459, /* (429) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ - 459, /* (430) insert_query ::= INSERT INTO full_table_name query_or_subquery */ - 417, /* (431) tags_literal ::= NK_INTEGER */ - 417, /* (432) tags_literal ::= NK_INTEGER NK_PLUS duration_literal */ - 417, /* (433) tags_literal ::= NK_INTEGER NK_MINUS duration_literal */ - 417, /* (434) tags_literal ::= NK_PLUS NK_INTEGER */ - 417, /* (435) tags_literal ::= NK_PLUS NK_INTEGER NK_PLUS duration_literal */ - 417, /* (436) tags_literal ::= NK_PLUS NK_INTEGER NK_MINUS duration_literal */ - 417, /* (437) tags_literal ::= NK_MINUS NK_INTEGER */ - 417, /* (438) tags_literal ::= NK_MINUS NK_INTEGER NK_PLUS duration_literal */ - 417, /* (439) tags_literal ::= NK_MINUS NK_INTEGER NK_MINUS duration_literal */ - 417, /* (440) tags_literal ::= NK_FLOAT */ - 417, /* (441) tags_literal ::= NK_PLUS NK_FLOAT */ - 417, /* (442) tags_literal ::= NK_MINUS NK_FLOAT */ - 417, /* (443) tags_literal ::= NK_BIN */ - 417, /* (444) tags_literal ::= NK_BIN NK_PLUS duration_literal */ - 417, /* (445) tags_literal ::= NK_BIN NK_MINUS duration_literal */ - 417, /* (446) tags_literal ::= NK_PLUS NK_BIN */ - 417, /* (447) tags_literal ::= NK_PLUS NK_BIN NK_PLUS duration_literal */ - 417, /* (448) tags_literal ::= NK_PLUS NK_BIN NK_MINUS duration_literal */ - 417, /* (449) tags_literal ::= NK_MINUS NK_BIN */ - 417, /* (450) tags_literal ::= NK_MINUS NK_BIN NK_PLUS duration_literal */ - 417, /* (451) tags_literal ::= NK_MINUS NK_BIN NK_MINUS duration_literal */ - 417, /* (452) tags_literal ::= NK_HEX */ - 417, /* (453) tags_literal ::= NK_HEX NK_PLUS duration_literal */ - 417, /* (454) tags_literal ::= NK_HEX NK_MINUS duration_literal */ - 417, /* (455) tags_literal ::= NK_PLUS NK_HEX */ - 417, /* (456) tags_literal ::= NK_PLUS NK_HEX NK_PLUS duration_literal */ - 417, /* (457) tags_literal ::= NK_PLUS NK_HEX NK_MINUS duration_literal */ - 417, /* (458) tags_literal ::= NK_MINUS NK_HEX */ - 417, /* (459) tags_literal ::= NK_MINUS NK_HEX NK_PLUS duration_literal */ - 417, /* (460) tags_literal ::= NK_MINUS NK_HEX NK_MINUS duration_literal */ - 417, /* (461) tags_literal ::= NK_STRING */ - 417, /* (462) tags_literal ::= NK_STRING NK_PLUS duration_literal */ - 417, /* (463) tags_literal ::= NK_STRING NK_MINUS duration_literal */ - 417, /* (464) tags_literal ::= NK_BOOL */ - 417, /* (465) tags_literal ::= NULL */ - 417, /* (466) tags_literal ::= literal_func */ - 417, /* (467) tags_literal ::= literal_func NK_PLUS duration_literal */ - 417, /* (468) tags_literal ::= literal_func NK_MINUS duration_literal */ - 420, /* (469) tags_literal_list ::= tags_literal */ - 420, /* (470) tags_literal_list ::= tags_literal_list NK_COMMA tags_literal */ - 373, /* (471) literal ::= NK_INTEGER */ - 373, /* (472) literal ::= NK_FLOAT */ - 373, /* (473) literal ::= NK_STRING */ - 373, /* (474) literal ::= NK_BOOL */ - 373, /* (475) literal ::= TIMESTAMP NK_STRING */ - 373, /* (476) literal ::= duration_literal */ - 373, /* (477) literal ::= NULL */ - 373, /* (478) literal ::= NK_QUESTION */ - 430, /* (479) duration_literal ::= NK_VARIABLE */ - 402, /* (480) signed ::= NK_INTEGER */ - 402, /* (481) signed ::= NK_PLUS NK_INTEGER */ - 402, /* (482) signed ::= NK_MINUS NK_INTEGER */ - 402, /* (483) signed ::= NK_FLOAT */ - 402, /* (484) signed ::= NK_PLUS NK_FLOAT */ - 402, /* (485) signed ::= NK_MINUS NK_FLOAT */ - 479, /* (486) signed_literal ::= signed */ - 479, /* (487) signed_literal ::= NK_STRING */ - 479, /* (488) signed_literal ::= NK_BOOL */ - 479, /* (489) signed_literal ::= TIMESTAMP NK_STRING */ - 479, /* (490) signed_literal ::= duration_literal */ - 479, /* (491) signed_literal ::= NULL */ - 479, /* (492) signed_literal ::= literal_func */ - 479, /* (493) signed_literal ::= NK_QUESTION */ - 480, /* (494) literal_list ::= signed_literal */ - 480, /* (495) literal_list ::= literal_list NK_COMMA signed_literal */ - 385, /* (496) db_name ::= NK_ID */ - 386, /* (497) table_name ::= NK_ID */ - 414, /* (498) column_name ::= NK_ID */ - 432, /* (499) function_name ::= NK_ID */ - 465, /* (500) view_name ::= NK_ID */ - 481, /* (501) table_alias ::= NK_ID */ - 443, /* (502) column_alias ::= NK_ID */ - 443, /* (503) column_alias ::= NK_ALIAS */ - 378, /* (504) user_name ::= NK_ID */ - 387, /* (505) topic_name ::= NK_ID */ - 466, /* (506) stream_name ::= NK_ID */ - 456, /* (507) cgroup_name ::= NK_ID */ - 446, /* (508) index_name ::= NK_ID */ - 482, /* (509) expr_or_subquery ::= expression */ - 475, /* (510) expression ::= literal */ - 475, /* (511) expression ::= pseudo_column */ - 475, /* (512) expression ::= column_reference */ - 475, /* (513) expression ::= function_expression */ - 475, /* (514) expression ::= case_when_expression */ - 475, /* (515) expression ::= NK_LP expression NK_RP */ - 475, /* (516) expression ::= NK_PLUS expr_or_subquery */ - 475, /* (517) expression ::= NK_MINUS expr_or_subquery */ - 475, /* (518) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ - 475, /* (519) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ - 475, /* (520) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ - 475, /* (521) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ - 475, /* (522) expression ::= expr_or_subquery NK_REM expr_or_subquery */ - 475, /* (523) expression ::= column_reference NK_ARROW NK_STRING */ - 475, /* (524) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ - 475, /* (525) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ - 452, /* (526) expression_list ::= expr_or_subquery */ - 452, /* (527) expression_list ::= expression_list NK_COMMA expr_or_subquery */ - 484, /* (528) column_reference ::= column_name */ - 484, /* (529) column_reference ::= table_name NK_DOT column_name */ - 484, /* (530) column_reference ::= NK_ALIAS */ - 484, /* (531) column_reference ::= table_name NK_DOT NK_ALIAS */ - 483, /* (532) pseudo_column ::= ROWTS */ - 483, /* (533) pseudo_column ::= TBNAME */ - 483, /* (534) pseudo_column ::= table_name NK_DOT TBNAME */ - 483, /* (535) pseudo_column ::= QSTART */ - 483, /* (536) pseudo_column ::= QEND */ - 483, /* (537) pseudo_column ::= QDURATION */ - 483, /* (538) pseudo_column ::= WSTART */ - 483, /* (539) pseudo_column ::= WEND */ - 483, /* (540) pseudo_column ::= WDURATION */ - 483, /* (541) pseudo_column ::= IROWTS */ - 483, /* (542) pseudo_column ::= ISFILLED */ - 483, /* (543) pseudo_column ::= QTAGS */ - 485, /* (544) function_expression ::= function_name NK_LP expression_list NK_RP */ - 485, /* (545) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - 485, /* (546) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - 485, /* (547) function_expression ::= CAST NK_LP expr_or_subquery AS type_name_default_len NK_RP */ - 485, /* (548) function_expression ::= literal_func */ - 478, /* (549) literal_func ::= noarg_func NK_LP NK_RP */ - 478, /* (550) literal_func ::= NOW */ - 478, /* (551) literal_func ::= TODAY */ - 489, /* (552) noarg_func ::= NOW */ - 489, /* (553) noarg_func ::= TODAY */ - 489, /* (554) noarg_func ::= TIMEZONE */ - 489, /* (555) noarg_func ::= DATABASE */ - 489, /* (556) noarg_func ::= CLIENT_VERSION */ - 489, /* (557) noarg_func ::= SERVER_VERSION */ - 489, /* (558) noarg_func ::= SERVER_STATUS */ - 489, /* (559) noarg_func ::= CURRENT_USER */ - 489, /* (560) noarg_func ::= USER */ - 487, /* (561) star_func ::= COUNT */ - 487, /* (562) star_func ::= FIRST */ - 487, /* (563) star_func ::= LAST */ - 487, /* (564) star_func ::= LAST_ROW */ - 488, /* (565) star_func_para_list ::= NK_STAR */ - 488, /* (566) star_func_para_list ::= other_para_list */ - 490, /* (567) other_para_list ::= star_func_para */ - 490, /* (568) other_para_list ::= other_para_list NK_COMMA star_func_para */ - 491, /* (569) star_func_para ::= expr_or_subquery */ - 491, /* (570) star_func_para ::= table_name NK_DOT NK_STAR */ - 486, /* (571) case_when_expression ::= CASE when_then_list case_when_else_opt END */ - 486, /* (572) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ - 492, /* (573) when_then_list ::= when_then_expr */ - 492, /* (574) when_then_list ::= when_then_list when_then_expr */ - 495, /* (575) when_then_expr ::= WHEN common_expression THEN common_expression */ - 493, /* (576) case_when_else_opt ::= */ - 493, /* (577) case_when_else_opt ::= ELSE common_expression */ - 496, /* (578) predicate ::= expr_or_subquery compare_op expr_or_subquery */ - 496, /* (579) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ - 496, /* (580) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ - 496, /* (581) predicate ::= expr_or_subquery IS NULL */ - 496, /* (582) predicate ::= expr_or_subquery IS NOT NULL */ - 496, /* (583) predicate ::= expr_or_subquery in_op in_predicate_value */ - 497, /* (584) compare_op ::= NK_LT */ - 497, /* (585) compare_op ::= NK_GT */ - 497, /* (586) compare_op ::= NK_LE */ - 497, /* (587) compare_op ::= NK_GE */ - 497, /* (588) compare_op ::= NK_NE */ - 497, /* (589) compare_op ::= NK_EQ */ - 497, /* (590) compare_op ::= LIKE */ - 497, /* (591) compare_op ::= NOT LIKE */ - 497, /* (592) compare_op ::= MATCH */ - 497, /* (593) compare_op ::= NMATCH */ - 497, /* (594) compare_op ::= CONTAINS */ - 498, /* (595) in_op ::= IN */ - 498, /* (596) in_op ::= NOT IN */ - 499, /* (597) in_predicate_value ::= NK_LP literal_list NK_RP */ - 500, /* (598) boolean_value_expression ::= boolean_primary */ - 500, /* (599) boolean_value_expression ::= NOT boolean_primary */ - 500, /* (600) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - 500, /* (601) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - 501, /* (602) boolean_primary ::= predicate */ - 501, /* (603) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - 494, /* (604) common_expression ::= expr_or_subquery */ - 494, /* (605) common_expression ::= boolean_value_expression */ - 502, /* (606) from_clause_opt ::= */ - 502, /* (607) from_clause_opt ::= FROM table_reference_list */ - 503, /* (608) table_reference_list ::= table_reference */ - 503, /* (609) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - 504, /* (610) table_reference ::= table_primary */ - 504, /* (611) table_reference ::= joined_table */ - 505, /* (612) table_primary ::= table_name alias_opt */ - 505, /* (613) table_primary ::= db_name NK_DOT table_name alias_opt */ - 505, /* (614) table_primary ::= subquery alias_opt */ - 505, /* (615) table_primary ::= parenthesized_joined_table */ - 507, /* (616) alias_opt ::= */ - 507, /* (617) alias_opt ::= table_alias */ - 507, /* (618) alias_opt ::= AS table_alias */ - 509, /* (619) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - 509, /* (620) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - 506, /* (621) joined_table ::= table_reference join_type join_subtype JOIN table_reference join_on_clause_opt window_offset_clause_opt jlimit_clause_opt */ - 510, /* (622) join_type ::= */ - 510, /* (623) join_type ::= INNER */ - 510, /* (624) join_type ::= LEFT */ - 510, /* (625) join_type ::= RIGHT */ - 510, /* (626) join_type ::= FULL */ - 511, /* (627) join_subtype ::= */ - 511, /* (628) join_subtype ::= OUTER */ - 511, /* (629) join_subtype ::= SEMI */ - 511, /* (630) join_subtype ::= ANTI */ - 511, /* (631) join_subtype ::= ASOF */ - 511, /* (632) join_subtype ::= WINDOW */ - 512, /* (633) join_on_clause_opt ::= */ - 512, /* (634) join_on_clause_opt ::= ON search_condition */ - 513, /* (635) window_offset_clause_opt ::= */ - 513, /* (636) window_offset_clause_opt ::= WINDOW_OFFSET NK_LP window_offset_literal NK_COMMA window_offset_literal NK_RP */ - 515, /* (637) window_offset_literal ::= NK_VARIABLE */ - 515, /* (638) window_offset_literal ::= NK_MINUS NK_VARIABLE */ - 514, /* (639) jlimit_clause_opt ::= */ - 514, /* (640) jlimit_clause_opt ::= JLIMIT NK_INTEGER */ - 516, /* (641) 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 */ - 517, /* (642) hint_list ::= */ - 517, /* (643) hint_list ::= NK_HINT */ - 519, /* (644) tag_mode_opt ::= */ - 519, /* (645) tag_mode_opt ::= TAGS */ - 518, /* (646) set_quantifier_opt ::= */ - 518, /* (647) set_quantifier_opt ::= DISTINCT */ - 518, /* (648) set_quantifier_opt ::= ALL */ - 520, /* (649) select_list ::= select_item */ - 520, /* (650) select_list ::= select_list NK_COMMA select_item */ - 528, /* (651) select_item ::= NK_STAR */ - 528, /* (652) select_item ::= common_expression */ - 528, /* (653) select_item ::= common_expression column_alias */ - 528, /* (654) select_item ::= common_expression AS column_alias */ - 528, /* (655) select_item ::= table_name NK_DOT NK_STAR */ - 455, /* (656) where_clause_opt ::= */ - 455, /* (657) where_clause_opt ::= WHERE search_condition */ - 521, /* (658) partition_by_clause_opt ::= */ - 521, /* (659) partition_by_clause_opt ::= PARTITION BY partition_list */ - 529, /* (660) partition_list ::= partition_item */ - 529, /* (661) partition_list ::= partition_list NK_COMMA partition_item */ - 530, /* (662) partition_item ::= expr_or_subquery */ - 530, /* (663) partition_item ::= expr_or_subquery column_alias */ - 530, /* (664) partition_item ::= expr_or_subquery AS column_alias */ - 525, /* (665) twindow_clause_opt ::= */ - 525, /* (666) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ - 525, /* (667) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ - 525, /* (668) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - 525, /* (669) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - 525, /* (670) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ - 525, /* (671) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ - 525, /* (672) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - 448, /* (673) sliding_opt ::= */ - 448, /* (674) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ - 531, /* (675) interval_sliding_duration_literal ::= NK_VARIABLE */ - 531, /* (676) interval_sliding_duration_literal ::= NK_STRING */ - 531, /* (677) interval_sliding_duration_literal ::= NK_INTEGER */ - 524, /* (678) fill_opt ::= */ - 524, /* (679) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - 524, /* (680) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ - 524, /* (681) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ - 532, /* (682) fill_mode ::= NONE */ - 532, /* (683) fill_mode ::= PREV */ - 532, /* (684) fill_mode ::= NULL */ - 532, /* (685) fill_mode ::= NULL_F */ - 532, /* (686) fill_mode ::= LINEAR */ - 532, /* (687) fill_mode ::= NEXT */ - 526, /* (688) group_by_clause_opt ::= */ - 526, /* (689) group_by_clause_opt ::= GROUP BY group_by_list */ - 533, /* (690) group_by_list ::= expr_or_subquery */ - 533, /* (691) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ - 527, /* (692) having_clause_opt ::= */ - 527, /* (693) having_clause_opt ::= HAVING search_condition */ - 522, /* (694) range_opt ::= */ - 522, /* (695) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ - 522, /* (696) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ - 523, /* (697) every_opt ::= */ - 523, /* (698) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - 534, /* (699) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ - 535, /* (700) query_simple ::= query_specification */ - 535, /* (701) query_simple ::= union_query_expression */ - 539, /* (702) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ - 539, /* (703) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ - 540, /* (704) query_simple_or_subquery ::= query_simple */ - 540, /* (705) query_simple_or_subquery ::= subquery */ - 454, /* (706) query_or_subquery ::= query_expression */ - 454, /* (707) query_or_subquery ::= subquery */ - 536, /* (708) order_by_clause_opt ::= */ - 536, /* (709) order_by_clause_opt ::= ORDER BY sort_specification_list */ - 537, /* (710) slimit_clause_opt ::= */ - 537, /* (711) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - 537, /* (712) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - 537, /* (713) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 538, /* (714) limit_clause_opt ::= */ - 538, /* (715) limit_clause_opt ::= LIMIT NK_INTEGER */ - 538, /* (716) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - 538, /* (717) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 508, /* (718) subquery ::= NK_LP query_expression NK_RP */ - 508, /* (719) subquery ::= NK_LP subquery NK_RP */ - 388, /* (720) search_condition ::= common_expression */ - 541, /* (721) sort_specification_list ::= sort_specification */ - 541, /* (722) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - 542, /* (723) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ - 543, /* (724) ordering_specification_opt ::= */ - 543, /* (725) ordering_specification_opt ::= ASC */ - 543, /* (726) ordering_specification_opt ::= DESC */ - 544, /* (727) null_ordering_opt ::= */ - 544, /* (728) null_ordering_opt ::= NULLS FIRST */ - 544, /* (729) null_ordering_opt ::= NULLS LAST */ - 416, /* (730) column_options ::= */ - 416, /* (731) column_options ::= column_options PRIMARY KEY */ - 416, /* (732) column_options ::= column_options ENCODE NK_STRING */ - 416, /* (733) column_options ::= column_options COMPRESS NK_STRING */ - 416, /* (734) column_options ::= column_options LEVEL NK_STRING */ + 373, /* (0) cmd ::= CREATE ACCOUNT NK_ID PASS NK_STRING account_options */ + 373, /* (1) cmd ::= ALTER ACCOUNT NK_ID alter_account_options */ + 374, /* (2) account_options ::= */ + 374, /* (3) account_options ::= account_options PPS literal */ + 374, /* (4) account_options ::= account_options TSERIES literal */ + 374, /* (5) account_options ::= account_options STORAGE literal */ + 374, /* (6) account_options ::= account_options STREAMS literal */ + 374, /* (7) account_options ::= account_options QTIME literal */ + 374, /* (8) account_options ::= account_options DBS literal */ + 374, /* (9) account_options ::= account_options USERS literal */ + 374, /* (10) account_options ::= account_options CONNS literal */ + 374, /* (11) account_options ::= account_options STATE literal */ + 375, /* (12) alter_account_options ::= alter_account_option */ + 375, /* (13) alter_account_options ::= alter_account_options alter_account_option */ + 377, /* (14) alter_account_option ::= PASS literal */ + 377, /* (15) alter_account_option ::= PPS literal */ + 377, /* (16) alter_account_option ::= TSERIES literal */ + 377, /* (17) alter_account_option ::= STORAGE literal */ + 377, /* (18) alter_account_option ::= STREAMS literal */ + 377, /* (19) alter_account_option ::= QTIME literal */ + 377, /* (20) alter_account_option ::= DBS literal */ + 377, /* (21) alter_account_option ::= USERS literal */ + 377, /* (22) alter_account_option ::= CONNS literal */ + 377, /* (23) alter_account_option ::= STATE literal */ + 378, /* (24) ip_range_list ::= NK_STRING */ + 378, /* (25) ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ + 379, /* (26) white_list ::= HOST ip_range_list */ + 380, /* (27) white_list_opt ::= */ + 380, /* (28) white_list_opt ::= white_list */ + 373, /* (29) cmd ::= CREATE USER user_name PASS NK_STRING sysinfo_opt white_list_opt */ + 373, /* (30) cmd ::= ALTER USER user_name PASS NK_STRING */ + 373, /* (31) cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ + 373, /* (32) cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ + 373, /* (33) cmd ::= ALTER USER user_name ADD white_list */ + 373, /* (34) cmd ::= ALTER USER user_name DROP white_list */ + 373, /* (35) cmd ::= DROP USER user_name */ + 382, /* (36) sysinfo_opt ::= */ + 382, /* (37) sysinfo_opt ::= SYSINFO NK_INTEGER */ + 373, /* (38) cmd ::= GRANT privileges ON priv_level with_opt TO user_name */ + 373, /* (39) cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ + 383, /* (40) privileges ::= ALL */ + 383, /* (41) privileges ::= priv_type_list */ + 383, /* (42) privileges ::= SUBSCRIBE */ + 386, /* (43) priv_type_list ::= priv_type */ + 386, /* (44) priv_type_list ::= priv_type_list NK_COMMA priv_type */ + 387, /* (45) priv_type ::= READ */ + 387, /* (46) priv_type ::= WRITE */ + 387, /* (47) priv_type ::= ALTER */ + 384, /* (48) priv_level ::= NK_STAR NK_DOT NK_STAR */ + 384, /* (49) priv_level ::= db_name NK_DOT NK_STAR */ + 384, /* (50) priv_level ::= db_name NK_DOT table_name */ + 384, /* (51) priv_level ::= topic_name */ + 385, /* (52) with_opt ::= */ + 385, /* (53) with_opt ::= WITH search_condition */ + 373, /* (54) cmd ::= CREATE DNODE dnode_endpoint */ + 373, /* (55) cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ + 373, /* (56) cmd ::= DROP DNODE NK_INTEGER force_opt */ + 373, /* (57) cmd ::= DROP DNODE dnode_endpoint force_opt */ + 373, /* (58) cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ + 373, /* (59) cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ + 373, /* (60) cmd ::= ALTER DNODE NK_INTEGER NK_STRING */ + 373, /* (61) cmd ::= ALTER DNODE NK_INTEGER NK_STRING NK_STRING */ + 373, /* (62) cmd ::= ALTER ALL DNODES NK_STRING */ + 373, /* (63) cmd ::= ALTER ALL DNODES NK_STRING NK_STRING */ + 373, /* (64) cmd ::= RESTORE DNODE NK_INTEGER */ + 392, /* (65) dnode_endpoint ::= NK_STRING */ + 392, /* (66) dnode_endpoint ::= NK_ID */ + 392, /* (67) dnode_endpoint ::= NK_IPTOKEN */ + 393, /* (68) force_opt ::= */ + 393, /* (69) force_opt ::= FORCE */ + 394, /* (70) unsafe_opt ::= UNSAFE */ + 373, /* (71) cmd ::= ALTER CLUSTER NK_STRING */ + 373, /* (72) cmd ::= ALTER CLUSTER NK_STRING NK_STRING */ + 373, /* (73) cmd ::= ALTER LOCAL NK_STRING */ + 373, /* (74) cmd ::= ALTER LOCAL NK_STRING NK_STRING */ + 373, /* (75) cmd ::= CREATE QNODE ON DNODE NK_INTEGER */ + 373, /* (76) cmd ::= DROP QNODE ON DNODE NK_INTEGER */ + 373, /* (77) cmd ::= RESTORE QNODE ON DNODE NK_INTEGER */ + 373, /* (78) cmd ::= CREATE BNODE ON DNODE NK_INTEGER */ + 373, /* (79) cmd ::= DROP BNODE ON DNODE NK_INTEGER */ + 373, /* (80) cmd ::= CREATE SNODE ON DNODE NK_INTEGER */ + 373, /* (81) cmd ::= DROP SNODE ON DNODE NK_INTEGER */ + 373, /* (82) cmd ::= CREATE MNODE ON DNODE NK_INTEGER */ + 373, /* (83) cmd ::= DROP MNODE ON DNODE NK_INTEGER */ + 373, /* (84) cmd ::= RESTORE MNODE ON DNODE NK_INTEGER */ + 373, /* (85) cmd ::= RESTORE VNODE ON DNODE NK_INTEGER */ + 373, /* (86) cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ + 373, /* (87) cmd ::= DROP DATABASE exists_opt db_name */ + 373, /* (88) cmd ::= USE db_name */ + 373, /* (89) cmd ::= ALTER DATABASE db_name alter_db_options */ + 373, /* (90) cmd ::= FLUSH DATABASE db_name */ + 373, /* (91) cmd ::= TRIM DATABASE db_name speed_opt */ + 373, /* (92) cmd ::= S3MIGRATE DATABASE db_name */ + 373, /* (93) cmd ::= COMPACT DATABASE db_name start_opt end_opt */ + 395, /* (94) not_exists_opt ::= IF NOT EXISTS */ + 395, /* (95) not_exists_opt ::= */ + 397, /* (96) exists_opt ::= IF EXISTS */ + 397, /* (97) exists_opt ::= */ + 396, /* (98) db_options ::= */ + 396, /* (99) db_options ::= db_options BUFFER NK_INTEGER */ + 396, /* (100) db_options ::= db_options CACHEMODEL NK_STRING */ + 396, /* (101) db_options ::= db_options CACHESIZE NK_INTEGER */ + 396, /* (102) db_options ::= db_options COMP NK_INTEGER */ + 396, /* (103) db_options ::= db_options DURATION NK_INTEGER */ + 396, /* (104) db_options ::= db_options DURATION NK_VARIABLE */ + 396, /* (105) db_options ::= db_options MAXROWS NK_INTEGER */ + 396, /* (106) db_options ::= db_options MINROWS NK_INTEGER */ + 396, /* (107) db_options ::= db_options KEEP integer_list */ + 396, /* (108) db_options ::= db_options KEEP variable_list */ + 396, /* (109) db_options ::= db_options PAGES NK_INTEGER */ + 396, /* (110) db_options ::= db_options PAGESIZE NK_INTEGER */ + 396, /* (111) db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ + 396, /* (112) db_options ::= db_options PRECISION NK_STRING */ + 396, /* (113) db_options ::= db_options REPLICA NK_INTEGER */ + 396, /* (114) db_options ::= db_options VGROUPS NK_INTEGER */ + 396, /* (115) db_options ::= db_options SINGLE_STABLE NK_INTEGER */ + 396, /* (116) db_options ::= db_options RETENTIONS retention_list */ + 396, /* (117) db_options ::= db_options SCHEMALESS NK_INTEGER */ + 396, /* (118) db_options ::= db_options WAL_LEVEL NK_INTEGER */ + 396, /* (119) db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ + 396, /* (120) db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ + 396, /* (121) db_options ::= db_options WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + 396, /* (122) db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ + 396, /* (123) db_options ::= db_options WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + 396, /* (124) db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ + 396, /* (125) db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ + 396, /* (126) db_options ::= db_options STT_TRIGGER NK_INTEGER */ + 396, /* (127) db_options ::= db_options TABLE_PREFIX signed */ + 396, /* (128) db_options ::= db_options TABLE_SUFFIX signed */ + 396, /* (129) db_options ::= db_options S3_CHUNKSIZE NK_INTEGER */ + 396, /* (130) db_options ::= db_options S3_KEEPLOCAL NK_INTEGER */ + 396, /* (131) db_options ::= db_options S3_KEEPLOCAL NK_VARIABLE */ + 396, /* (132) db_options ::= db_options S3_COMPACT NK_INTEGER */ + 396, /* (133) db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ + 398, /* (134) alter_db_options ::= alter_db_option */ + 398, /* (135) alter_db_options ::= alter_db_options alter_db_option */ + 406, /* (136) alter_db_option ::= BUFFER NK_INTEGER */ + 406, /* (137) alter_db_option ::= CACHEMODEL NK_STRING */ + 406, /* (138) alter_db_option ::= CACHESIZE NK_INTEGER */ + 406, /* (139) alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ + 406, /* (140) alter_db_option ::= KEEP integer_list */ + 406, /* (141) alter_db_option ::= KEEP variable_list */ + 406, /* (142) alter_db_option ::= PAGES NK_INTEGER */ + 406, /* (143) alter_db_option ::= REPLICA NK_INTEGER */ + 406, /* (144) alter_db_option ::= WAL_LEVEL NK_INTEGER */ + 406, /* (145) alter_db_option ::= STT_TRIGGER NK_INTEGER */ + 406, /* (146) alter_db_option ::= MINROWS NK_INTEGER */ + 406, /* (147) alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ + 406, /* (148) alter_db_option ::= WAL_RETENTION_PERIOD NK_MINUS NK_INTEGER */ + 406, /* (149) alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ + 406, /* (150) alter_db_option ::= WAL_RETENTION_SIZE NK_MINUS NK_INTEGER */ + 406, /* (151) alter_db_option ::= S3_KEEPLOCAL NK_INTEGER */ + 406, /* (152) alter_db_option ::= S3_KEEPLOCAL NK_VARIABLE */ + 406, /* (153) alter_db_option ::= S3_COMPACT NK_INTEGER */ + 406, /* (154) alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ + 402, /* (155) integer_list ::= NK_INTEGER */ + 402, /* (156) integer_list ::= integer_list NK_COMMA NK_INTEGER */ + 403, /* (157) variable_list ::= NK_VARIABLE */ + 403, /* (158) variable_list ::= variable_list NK_COMMA NK_VARIABLE */ + 404, /* (159) retention_list ::= retention */ + 404, /* (160) retention_list ::= retention_list NK_COMMA retention */ + 407, /* (161) retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ + 407, /* (162) retention ::= NK_MINUS NK_COLON NK_VARIABLE */ + 399, /* (163) speed_opt ::= */ + 399, /* (164) speed_opt ::= BWLIMIT NK_INTEGER */ + 400, /* (165) start_opt ::= */ + 400, /* (166) start_opt ::= START WITH NK_INTEGER */ + 400, /* (167) start_opt ::= START WITH NK_STRING */ + 400, /* (168) start_opt ::= START WITH TIMESTAMP NK_STRING */ + 401, /* (169) end_opt ::= */ + 401, /* (170) end_opt ::= END WITH NK_INTEGER */ + 401, /* (171) end_opt ::= END WITH NK_STRING */ + 401, /* (172) end_opt ::= END WITH TIMESTAMP NK_STRING */ + 373, /* (173) cmd ::= CREATE TABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def_opt table_options */ + 373, /* (174) cmd ::= CREATE TABLE multi_create_clause */ + 373, /* (175) cmd ::= CREATE STABLE not_exists_opt full_table_name NK_LP column_def_list NK_RP tags_def table_options */ + 373, /* (176) cmd ::= DROP TABLE multi_drop_clause */ + 373, /* (177) cmd ::= DROP STABLE exists_opt full_table_name */ + 373, /* (178) cmd ::= ALTER TABLE alter_table_clause */ + 373, /* (179) cmd ::= ALTER STABLE alter_table_clause */ + 415, /* (180) alter_table_clause ::= full_table_name alter_table_options */ + 415, /* (181) alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ + 415, /* (182) alter_table_clause ::= full_table_name DROP COLUMN column_name */ + 415, /* (183) alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ + 415, /* (184) alter_table_clause ::= full_table_name MODIFY COLUMN column_name column_options */ + 415, /* (185) alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ + 415, /* (186) alter_table_clause ::= full_table_name ADD TAG column_name type_name */ + 415, /* (187) alter_table_clause ::= full_table_name DROP TAG column_name */ + 415, /* (188) alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ + 415, /* (189) alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ + 415, /* (190) alter_table_clause ::= full_table_name SET TAG column_name NK_EQ tags_literal */ + 412, /* (191) multi_create_clause ::= create_subtable_clause */ + 412, /* (192) multi_create_clause ::= multi_create_clause create_subtable_clause */ + 421, /* (193) 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 */ + 414, /* (194) multi_drop_clause ::= drop_table_clause */ + 414, /* (195) multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ + 424, /* (196) drop_table_clause ::= exists_opt full_table_name */ + 422, /* (197) specific_cols_opt ::= */ + 422, /* (198) specific_cols_opt ::= NK_LP col_name_list NK_RP */ + 408, /* (199) full_table_name ::= table_name */ + 408, /* (200) full_table_name ::= db_name NK_DOT table_name */ + 426, /* (201) tag_def_list ::= tag_def */ + 426, /* (202) tag_def_list ::= tag_def_list NK_COMMA tag_def */ + 427, /* (203) tag_def ::= column_name type_name */ + 409, /* (204) column_def_list ::= column_def */ + 409, /* (205) column_def_list ::= column_def_list NK_COMMA column_def */ + 428, /* (206) column_def ::= column_name type_name column_options */ + 418, /* (207) type_name ::= BOOL */ + 418, /* (208) type_name ::= TINYINT */ + 418, /* (209) type_name ::= SMALLINT */ + 418, /* (210) type_name ::= INT */ + 418, /* (211) type_name ::= INTEGER */ + 418, /* (212) type_name ::= BIGINT */ + 418, /* (213) type_name ::= FLOAT */ + 418, /* (214) type_name ::= DOUBLE */ + 418, /* (215) type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ + 418, /* (216) type_name ::= TIMESTAMP */ + 418, /* (217) type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ + 418, /* (218) type_name ::= TINYINT UNSIGNED */ + 418, /* (219) type_name ::= SMALLINT UNSIGNED */ + 418, /* (220) type_name ::= INT UNSIGNED */ + 418, /* (221) type_name ::= BIGINT UNSIGNED */ + 418, /* (222) type_name ::= JSON */ + 418, /* (223) type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ + 418, /* (224) type_name ::= MEDIUMBLOB */ + 418, /* (225) type_name ::= BLOB */ + 418, /* (226) type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ + 418, /* (227) type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ + 418, /* (228) type_name ::= DECIMAL */ + 418, /* (229) type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ + 418, /* (230) type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + 429, /* (231) type_name_default_len ::= BINARY */ + 429, /* (232) type_name_default_len ::= NCHAR */ + 429, /* (233) type_name_default_len ::= VARCHAR */ + 429, /* (234) type_name_default_len ::= VARBINARY */ + 410, /* (235) tags_def_opt ::= */ + 410, /* (236) tags_def_opt ::= tags_def */ + 413, /* (237) tags_def ::= TAGS NK_LP tag_def_list NK_RP */ + 411, /* (238) table_options ::= */ + 411, /* (239) table_options ::= table_options COMMENT NK_STRING */ + 411, /* (240) table_options ::= table_options MAX_DELAY duration_list */ + 411, /* (241) table_options ::= table_options WATERMARK duration_list */ + 411, /* (242) table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ + 411, /* (243) table_options ::= table_options TTL NK_INTEGER */ + 411, /* (244) table_options ::= table_options SMA NK_LP col_name_list NK_RP */ + 411, /* (245) table_options ::= table_options DELETE_MARK duration_list */ + 416, /* (246) alter_table_options ::= alter_table_option */ + 416, /* (247) alter_table_options ::= alter_table_options alter_table_option */ + 432, /* (248) alter_table_option ::= COMMENT NK_STRING */ + 432, /* (249) alter_table_option ::= TTL NK_INTEGER */ + 430, /* (250) duration_list ::= duration_literal */ + 430, /* (251) duration_list ::= duration_list NK_COMMA duration_literal */ + 431, /* (252) rollup_func_list ::= rollup_func_name */ + 431, /* (253) rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ + 434, /* (254) rollup_func_name ::= function_name */ + 434, /* (255) rollup_func_name ::= FIRST */ + 434, /* (256) rollup_func_name ::= LAST */ + 425, /* (257) col_name_list ::= col_name */ + 425, /* (258) col_name_list ::= col_name_list NK_COMMA col_name */ + 436, /* (259) col_name ::= column_name */ + 373, /* (260) cmd ::= SHOW DNODES */ + 373, /* (261) cmd ::= SHOW USERS */ + 373, /* (262) cmd ::= SHOW USER PRIVILEGES */ + 373, /* (263) cmd ::= SHOW db_kind_opt DATABASES */ + 373, /* (264) cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ + 373, /* (265) cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ + 373, /* (266) cmd ::= SHOW db_name_cond_opt VGROUPS */ + 373, /* (267) cmd ::= SHOW MNODES */ + 373, /* (268) cmd ::= SHOW QNODES */ + 373, /* (269) cmd ::= SHOW ARBGROUPS */ + 373, /* (270) cmd ::= SHOW FUNCTIONS */ + 373, /* (271) cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ + 373, /* (272) cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ + 373, /* (273) cmd ::= SHOW STREAMS */ + 373, /* (274) cmd ::= SHOW ACCOUNTS */ + 373, /* (275) cmd ::= SHOW APPS */ + 373, /* (276) cmd ::= SHOW CONNECTIONS */ + 373, /* (277) cmd ::= SHOW LICENCES */ + 373, /* (278) cmd ::= SHOW GRANTS */ + 373, /* (279) cmd ::= SHOW GRANTS FULL */ + 373, /* (280) cmd ::= SHOW GRANTS LOGS */ + 373, /* (281) cmd ::= SHOW CLUSTER MACHINES */ + 373, /* (282) cmd ::= SHOW CREATE DATABASE db_name */ + 373, /* (283) cmd ::= SHOW CREATE TABLE full_table_name */ + 373, /* (284) cmd ::= SHOW CREATE STABLE full_table_name */ + 373, /* (285) cmd ::= SHOW QUERIES */ + 373, /* (286) cmd ::= SHOW SCORES */ + 373, /* (287) cmd ::= SHOW TOPICS */ + 373, /* (288) cmd ::= SHOW VARIABLES */ + 373, /* (289) cmd ::= SHOW CLUSTER VARIABLES */ + 373, /* (290) cmd ::= SHOW LOCAL VARIABLES */ + 373, /* (291) cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ + 373, /* (292) cmd ::= SHOW BNODES */ + 373, /* (293) cmd ::= SHOW SNODES */ + 373, /* (294) cmd ::= SHOW CLUSTER */ + 373, /* (295) cmd ::= SHOW TRANSACTIONS */ + 373, /* (296) cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ + 373, /* (297) cmd ::= SHOW CONSUMERS */ + 373, /* (298) cmd ::= SHOW SUBSCRIPTIONS */ + 373, /* (299) cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ + 373, /* (300) cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ + 373, /* (301) cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ + 373, /* (302) cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ + 373, /* (303) cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ + 373, /* (304) cmd ::= SHOW VNODES */ + 373, /* (305) cmd ::= SHOW db_name_cond_opt ALIVE */ + 373, /* (306) cmd ::= SHOW CLUSTER ALIVE */ + 373, /* (307) cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ + 373, /* (308) cmd ::= SHOW CREATE VIEW full_table_name */ + 373, /* (309) cmd ::= SHOW COMPACTS */ + 373, /* (310) cmd ::= SHOW COMPACT NK_INTEGER */ + 438, /* (311) table_kind_db_name_cond_opt ::= */ + 438, /* (312) table_kind_db_name_cond_opt ::= table_kind */ + 438, /* (313) table_kind_db_name_cond_opt ::= db_name NK_DOT */ + 438, /* (314) table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ + 444, /* (315) table_kind ::= NORMAL */ + 444, /* (316) table_kind ::= CHILD */ + 440, /* (317) db_name_cond_opt ::= */ + 440, /* (318) db_name_cond_opt ::= db_name NK_DOT */ + 439, /* (319) like_pattern_opt ::= */ + 439, /* (320) like_pattern_opt ::= LIKE NK_STRING */ + 441, /* (321) table_name_cond ::= table_name */ + 442, /* (322) from_db_opt ::= */ + 442, /* (323) from_db_opt ::= FROM db_name */ + 443, /* (324) tag_list_opt ::= */ + 443, /* (325) tag_list_opt ::= tag_item */ + 443, /* (326) tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ + 445, /* (327) tag_item ::= TBNAME */ + 445, /* (328) tag_item ::= QTAGS */ + 445, /* (329) tag_item ::= column_name */ + 445, /* (330) tag_item ::= column_name column_alias */ + 445, /* (331) tag_item ::= column_name AS column_alias */ + 437, /* (332) db_kind_opt ::= */ + 437, /* (333) db_kind_opt ::= USER */ + 437, /* (334) db_kind_opt ::= SYSTEM */ + 373, /* (335) cmd ::= CREATE TSMA not_exists_opt tsma_name ON full_table_name tsma_func_list INTERVAL NK_LP duration_literal NK_RP */ + 373, /* (336) cmd ::= CREATE RECURSIVE TSMA not_exists_opt tsma_name ON full_table_name INTERVAL NK_LP duration_literal NK_RP */ + 373, /* (337) cmd ::= DROP TSMA exists_opt full_tsma_name */ + 373, /* (338) cmd ::= SHOW db_name_cond_opt TSMAS */ + 449, /* (339) full_tsma_name ::= tsma_name */ + 449, /* (340) full_tsma_name ::= db_name NK_DOT tsma_name */ + 448, /* (341) tsma_func_list ::= FUNCTION NK_LP func_list NK_RP */ + 373, /* (342) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ + 373, /* (343) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ + 373, /* (344) cmd ::= DROP INDEX exists_opt full_index_name */ + 452, /* (345) full_index_name ::= index_name */ + 452, /* (346) full_index_name ::= db_name NK_DOT index_name */ + 451, /* (347) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + 451, /* (348) 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 */ + 450, /* (349) func_list ::= func */ + 450, /* (350) func_list ::= func_list NK_COMMA func */ + 456, /* (351) func ::= sma_func_name NK_LP expression_list NK_RP */ + 457, /* (352) sma_func_name ::= function_name */ + 457, /* (353) sma_func_name ::= COUNT */ + 457, /* (354) sma_func_name ::= FIRST */ + 457, /* (355) sma_func_name ::= LAST */ + 457, /* (356) sma_func_name ::= LAST_ROW */ + 455, /* (357) sma_stream_opt ::= */ + 455, /* (358) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ + 455, /* (359) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ + 455, /* (360) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ + 459, /* (361) with_meta ::= AS */ + 459, /* (362) with_meta ::= WITH META AS */ + 459, /* (363) with_meta ::= ONLY META AS */ + 373, /* (364) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + 373, /* (365) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ + 373, /* (366) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ + 373, /* (367) cmd ::= DROP TOPIC exists_opt topic_name */ + 373, /* (368) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + 373, /* (369) cmd ::= DESC full_table_name */ + 373, /* (370) cmd ::= DESCRIBE full_table_name */ + 373, /* (371) cmd ::= RESET QUERY CACHE */ + 373, /* (372) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + 373, /* (373) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ + 463, /* (374) analyze_opt ::= */ + 463, /* (375) analyze_opt ::= ANALYZE */ + 464, /* (376) explain_options ::= */ + 464, /* (377) explain_options ::= explain_options VERBOSE NK_BOOL */ + 464, /* (378) explain_options ::= explain_options RATIO NK_FLOAT */ + 373, /* (379) cmd ::= CREATE or_replace_opt agg_func_opt FUNCTION not_exists_opt function_name AS NK_STRING OUTPUTTYPE type_name bufsize_opt language_opt */ + 373, /* (380) cmd ::= DROP FUNCTION exists_opt function_name */ + 467, /* (381) agg_func_opt ::= */ + 467, /* (382) agg_func_opt ::= AGGREGATE */ + 468, /* (383) bufsize_opt ::= */ + 468, /* (384) bufsize_opt ::= BUFSIZE NK_INTEGER */ + 469, /* (385) language_opt ::= */ + 469, /* (386) language_opt ::= LANGUAGE NK_STRING */ + 466, /* (387) or_replace_opt ::= */ + 466, /* (388) or_replace_opt ::= OR REPLACE */ + 373, /* (389) cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ + 373, /* (390) cmd ::= DROP VIEW exists_opt full_view_name */ + 470, /* (391) full_view_name ::= view_name */ + 470, /* (392) full_view_name ::= db_name NK_DOT view_name */ + 373, /* (393) 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 */ + 373, /* (394) cmd ::= DROP STREAM exists_opt stream_name */ + 373, /* (395) cmd ::= PAUSE STREAM exists_opt stream_name */ + 373, /* (396) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ + 474, /* (397) col_list_opt ::= */ + 474, /* (398) col_list_opt ::= NK_LP column_stream_def_list NK_RP */ + 478, /* (399) column_stream_def_list ::= column_stream_def */ + 478, /* (400) column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def */ + 479, /* (401) column_stream_def ::= column_name stream_col_options */ + 480, /* (402) stream_col_options ::= */ + 480, /* (403) stream_col_options ::= stream_col_options PRIMARY KEY */ + 475, /* (404) tag_def_or_ref_opt ::= */ + 475, /* (405) tag_def_or_ref_opt ::= tags_def */ + 475, /* (406) tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP */ + 473, /* (407) stream_options ::= */ + 473, /* (408) stream_options ::= stream_options TRIGGER AT_ONCE */ + 473, /* (409) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + 473, /* (410) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + 473, /* (411) stream_options ::= stream_options WATERMARK duration_literal */ + 473, /* (412) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + 473, /* (413) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ + 473, /* (414) stream_options ::= stream_options DELETE_MARK duration_literal */ + 473, /* (415) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ + 476, /* (416) subtable_opt ::= */ + 476, /* (417) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + 477, /* (418) ignore_opt ::= */ + 477, /* (419) ignore_opt ::= IGNORE UNTREATED */ + 373, /* (420) cmd ::= KILL CONNECTION NK_INTEGER */ + 373, /* (421) cmd ::= KILL QUERY NK_STRING */ + 373, /* (422) cmd ::= KILL TRANSACTION NK_INTEGER */ + 373, /* (423) cmd ::= KILL COMPACT NK_INTEGER */ + 373, /* (424) cmd ::= BALANCE VGROUP */ + 373, /* (425) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ + 373, /* (426) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + 373, /* (427) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + 373, /* (428) cmd ::= SPLIT VGROUP NK_INTEGER */ + 482, /* (429) on_vgroup_id ::= */ + 482, /* (430) on_vgroup_id ::= ON NK_INTEGER */ + 483, /* (431) dnode_list ::= DNODE NK_INTEGER */ + 483, /* (432) dnode_list ::= dnode_list DNODE NK_INTEGER */ + 373, /* (433) cmd ::= DELETE FROM full_table_name where_clause_opt */ + 373, /* (434) cmd ::= query_or_subquery */ + 373, /* (435) cmd ::= insert_query */ + 465, /* (436) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + 465, /* (437) insert_query ::= INSERT INTO full_table_name query_or_subquery */ + 420, /* (438) tags_literal ::= NK_INTEGER */ + 420, /* (439) tags_literal ::= NK_INTEGER NK_PLUS duration_literal */ + 420, /* (440) tags_literal ::= NK_INTEGER NK_MINUS duration_literal */ + 420, /* (441) tags_literal ::= NK_PLUS NK_INTEGER */ + 420, /* (442) tags_literal ::= NK_PLUS NK_INTEGER NK_PLUS duration_literal */ + 420, /* (443) tags_literal ::= NK_PLUS NK_INTEGER NK_MINUS duration_literal */ + 420, /* (444) tags_literal ::= NK_MINUS NK_INTEGER */ + 420, /* (445) tags_literal ::= NK_MINUS NK_INTEGER NK_PLUS duration_literal */ + 420, /* (446) tags_literal ::= NK_MINUS NK_INTEGER NK_MINUS duration_literal */ + 420, /* (447) tags_literal ::= NK_FLOAT */ + 420, /* (448) tags_literal ::= NK_PLUS NK_FLOAT */ + 420, /* (449) tags_literal ::= NK_MINUS NK_FLOAT */ + 420, /* (450) tags_literal ::= NK_BIN */ + 420, /* (451) tags_literal ::= NK_BIN NK_PLUS duration_literal */ + 420, /* (452) tags_literal ::= NK_BIN NK_MINUS duration_literal */ + 420, /* (453) tags_literal ::= NK_PLUS NK_BIN */ + 420, /* (454) tags_literal ::= NK_PLUS NK_BIN NK_PLUS duration_literal */ + 420, /* (455) tags_literal ::= NK_PLUS NK_BIN NK_MINUS duration_literal */ + 420, /* (456) tags_literal ::= NK_MINUS NK_BIN */ + 420, /* (457) tags_literal ::= NK_MINUS NK_BIN NK_PLUS duration_literal */ + 420, /* (458) tags_literal ::= NK_MINUS NK_BIN NK_MINUS duration_literal */ + 420, /* (459) tags_literal ::= NK_HEX */ + 420, /* (460) tags_literal ::= NK_HEX NK_PLUS duration_literal */ + 420, /* (461) tags_literal ::= NK_HEX NK_MINUS duration_literal */ + 420, /* (462) tags_literal ::= NK_PLUS NK_HEX */ + 420, /* (463) tags_literal ::= NK_PLUS NK_HEX NK_PLUS duration_literal */ + 420, /* (464) tags_literal ::= NK_PLUS NK_HEX NK_MINUS duration_literal */ + 420, /* (465) tags_literal ::= NK_MINUS NK_HEX */ + 420, /* (466) tags_literal ::= NK_MINUS NK_HEX NK_PLUS duration_literal */ + 420, /* (467) tags_literal ::= NK_MINUS NK_HEX NK_MINUS duration_literal */ + 420, /* (468) tags_literal ::= NK_STRING */ + 420, /* (469) tags_literal ::= NK_STRING NK_PLUS duration_literal */ + 420, /* (470) tags_literal ::= NK_STRING NK_MINUS duration_literal */ + 420, /* (471) tags_literal ::= NK_BOOL */ + 420, /* (472) tags_literal ::= NULL */ + 420, /* (473) tags_literal ::= literal_func */ + 420, /* (474) tags_literal ::= literal_func NK_PLUS duration_literal */ + 420, /* (475) tags_literal ::= literal_func NK_MINUS duration_literal */ + 423, /* (476) tags_literal_list ::= tags_literal */ + 423, /* (477) tags_literal_list ::= tags_literal_list NK_COMMA tags_literal */ + 376, /* (478) literal ::= NK_INTEGER */ + 376, /* (479) literal ::= NK_FLOAT */ + 376, /* (480) literal ::= NK_STRING */ + 376, /* (481) literal ::= NK_BOOL */ + 376, /* (482) literal ::= TIMESTAMP NK_STRING */ + 376, /* (483) literal ::= duration_literal */ + 376, /* (484) literal ::= NULL */ + 376, /* (485) literal ::= NK_QUESTION */ + 433, /* (486) duration_literal ::= NK_VARIABLE */ + 405, /* (487) signed ::= NK_INTEGER */ + 405, /* (488) signed ::= NK_PLUS NK_INTEGER */ + 405, /* (489) signed ::= NK_MINUS NK_INTEGER */ + 405, /* (490) signed ::= NK_FLOAT */ + 405, /* (491) signed ::= NK_PLUS NK_FLOAT */ + 405, /* (492) signed ::= NK_MINUS NK_FLOAT */ + 485, /* (493) signed_literal ::= signed */ + 485, /* (494) signed_literal ::= NK_STRING */ + 485, /* (495) signed_literal ::= NK_BOOL */ + 485, /* (496) signed_literal ::= TIMESTAMP NK_STRING */ + 485, /* (497) signed_literal ::= duration_literal */ + 485, /* (498) signed_literal ::= NULL */ + 485, /* (499) signed_literal ::= literal_func */ + 485, /* (500) signed_literal ::= NK_QUESTION */ + 486, /* (501) literal_list ::= signed_literal */ + 486, /* (502) literal_list ::= literal_list NK_COMMA signed_literal */ + 388, /* (503) db_name ::= NK_ID */ + 389, /* (504) table_name ::= NK_ID */ + 417, /* (505) column_name ::= NK_ID */ + 435, /* (506) function_name ::= NK_ID */ + 471, /* (507) view_name ::= NK_ID */ + 487, /* (508) table_alias ::= NK_ID */ + 446, /* (509) column_alias ::= NK_ID */ + 446, /* (510) column_alias ::= NK_ALIAS */ + 381, /* (511) user_name ::= NK_ID */ + 390, /* (512) topic_name ::= NK_ID */ + 472, /* (513) stream_name ::= NK_ID */ + 462, /* (514) cgroup_name ::= NK_ID */ + 453, /* (515) index_name ::= NK_ID */ + 447, /* (516) tsma_name ::= NK_ID */ + 488, /* (517) expr_or_subquery ::= expression */ + 481, /* (518) expression ::= literal */ + 481, /* (519) expression ::= pseudo_column */ + 481, /* (520) expression ::= column_reference */ + 481, /* (521) expression ::= function_expression */ + 481, /* (522) expression ::= case_when_expression */ + 481, /* (523) expression ::= NK_LP expression NK_RP */ + 481, /* (524) expression ::= NK_PLUS expr_or_subquery */ + 481, /* (525) expression ::= NK_MINUS expr_or_subquery */ + 481, /* (526) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + 481, /* (527) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + 481, /* (528) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + 481, /* (529) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + 481, /* (530) expression ::= expr_or_subquery NK_REM expr_or_subquery */ + 481, /* (531) expression ::= column_reference NK_ARROW NK_STRING */ + 481, /* (532) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + 481, /* (533) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + 458, /* (534) expression_list ::= expr_or_subquery */ + 458, /* (535) expression_list ::= expression_list NK_COMMA expr_or_subquery */ + 490, /* (536) column_reference ::= column_name */ + 490, /* (537) column_reference ::= table_name NK_DOT column_name */ + 490, /* (538) column_reference ::= NK_ALIAS */ + 490, /* (539) column_reference ::= table_name NK_DOT NK_ALIAS */ + 489, /* (540) pseudo_column ::= ROWTS */ + 489, /* (541) pseudo_column ::= TBNAME */ + 489, /* (542) pseudo_column ::= table_name NK_DOT TBNAME */ + 489, /* (543) pseudo_column ::= QSTART */ + 489, /* (544) pseudo_column ::= QEND */ + 489, /* (545) pseudo_column ::= QDURATION */ + 489, /* (546) pseudo_column ::= WSTART */ + 489, /* (547) pseudo_column ::= WEND */ + 489, /* (548) pseudo_column ::= WDURATION */ + 489, /* (549) pseudo_column ::= IROWTS */ + 489, /* (550) pseudo_column ::= ISFILLED */ + 489, /* (551) pseudo_column ::= QTAGS */ + 491, /* (552) function_expression ::= function_name NK_LP expression_list NK_RP */ + 491, /* (553) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + 491, /* (554) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + 491, /* (555) function_expression ::= CAST NK_LP expr_or_subquery AS type_name_default_len NK_RP */ + 491, /* (556) function_expression ::= literal_func */ + 484, /* (557) literal_func ::= noarg_func NK_LP NK_RP */ + 484, /* (558) literal_func ::= NOW */ + 484, /* (559) literal_func ::= TODAY */ + 495, /* (560) noarg_func ::= NOW */ + 495, /* (561) noarg_func ::= TODAY */ + 495, /* (562) noarg_func ::= TIMEZONE */ + 495, /* (563) noarg_func ::= DATABASE */ + 495, /* (564) noarg_func ::= CLIENT_VERSION */ + 495, /* (565) noarg_func ::= SERVER_VERSION */ + 495, /* (566) noarg_func ::= SERVER_STATUS */ + 495, /* (567) noarg_func ::= CURRENT_USER */ + 495, /* (568) noarg_func ::= USER */ + 493, /* (569) star_func ::= COUNT */ + 493, /* (570) star_func ::= FIRST */ + 493, /* (571) star_func ::= LAST */ + 493, /* (572) star_func ::= LAST_ROW */ + 494, /* (573) star_func_para_list ::= NK_STAR */ + 494, /* (574) star_func_para_list ::= other_para_list */ + 496, /* (575) other_para_list ::= star_func_para */ + 496, /* (576) other_para_list ::= other_para_list NK_COMMA star_func_para */ + 497, /* (577) star_func_para ::= expr_or_subquery */ + 497, /* (578) star_func_para ::= table_name NK_DOT NK_STAR */ + 492, /* (579) case_when_expression ::= CASE when_then_list case_when_else_opt END */ + 492, /* (580) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + 498, /* (581) when_then_list ::= when_then_expr */ + 498, /* (582) when_then_list ::= when_then_list when_then_expr */ + 501, /* (583) when_then_expr ::= WHEN common_expression THEN common_expression */ + 499, /* (584) case_when_else_opt ::= */ + 499, /* (585) case_when_else_opt ::= ELSE common_expression */ + 502, /* (586) predicate ::= expr_or_subquery compare_op expr_or_subquery */ + 502, /* (587) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + 502, /* (588) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + 502, /* (589) predicate ::= expr_or_subquery IS NULL */ + 502, /* (590) predicate ::= expr_or_subquery IS NOT NULL */ + 502, /* (591) predicate ::= expr_or_subquery in_op in_predicate_value */ + 503, /* (592) compare_op ::= NK_LT */ + 503, /* (593) compare_op ::= NK_GT */ + 503, /* (594) compare_op ::= NK_LE */ + 503, /* (595) compare_op ::= NK_GE */ + 503, /* (596) compare_op ::= NK_NE */ + 503, /* (597) compare_op ::= NK_EQ */ + 503, /* (598) compare_op ::= LIKE */ + 503, /* (599) compare_op ::= NOT LIKE */ + 503, /* (600) compare_op ::= MATCH */ + 503, /* (601) compare_op ::= NMATCH */ + 503, /* (602) compare_op ::= CONTAINS */ + 504, /* (603) in_op ::= IN */ + 504, /* (604) in_op ::= NOT IN */ + 505, /* (605) in_predicate_value ::= NK_LP literal_list NK_RP */ + 506, /* (606) boolean_value_expression ::= boolean_primary */ + 506, /* (607) boolean_value_expression ::= NOT boolean_primary */ + 506, /* (608) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + 506, /* (609) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + 507, /* (610) boolean_primary ::= predicate */ + 507, /* (611) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + 500, /* (612) common_expression ::= expr_or_subquery */ + 500, /* (613) common_expression ::= boolean_value_expression */ + 508, /* (614) from_clause_opt ::= */ + 508, /* (615) from_clause_opt ::= FROM table_reference_list */ + 509, /* (616) table_reference_list ::= table_reference */ + 509, /* (617) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + 510, /* (618) table_reference ::= table_primary */ + 510, /* (619) table_reference ::= joined_table */ + 511, /* (620) table_primary ::= table_name alias_opt */ + 511, /* (621) table_primary ::= db_name NK_DOT table_name alias_opt */ + 511, /* (622) table_primary ::= subquery alias_opt */ + 511, /* (623) table_primary ::= parenthesized_joined_table */ + 513, /* (624) alias_opt ::= */ + 513, /* (625) alias_opt ::= table_alias */ + 513, /* (626) alias_opt ::= AS table_alias */ + 515, /* (627) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + 515, /* (628) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + 512, /* (629) joined_table ::= table_reference join_type join_subtype JOIN table_reference join_on_clause_opt window_offset_clause_opt jlimit_clause_opt */ + 516, /* (630) join_type ::= */ + 516, /* (631) join_type ::= INNER */ + 516, /* (632) join_type ::= LEFT */ + 516, /* (633) join_type ::= RIGHT */ + 516, /* (634) join_type ::= FULL */ + 517, /* (635) join_subtype ::= */ + 517, /* (636) join_subtype ::= OUTER */ + 517, /* (637) join_subtype ::= SEMI */ + 517, /* (638) join_subtype ::= ANTI */ + 517, /* (639) join_subtype ::= ASOF */ + 517, /* (640) join_subtype ::= WINDOW */ + 518, /* (641) join_on_clause_opt ::= */ + 518, /* (642) join_on_clause_opt ::= ON search_condition */ + 519, /* (643) window_offset_clause_opt ::= */ + 519, /* (644) window_offset_clause_opt ::= WINDOW_OFFSET NK_LP window_offset_literal NK_COMMA window_offset_literal NK_RP */ + 521, /* (645) window_offset_literal ::= NK_VARIABLE */ + 521, /* (646) window_offset_literal ::= NK_MINUS NK_VARIABLE */ + 520, /* (647) jlimit_clause_opt ::= */ + 520, /* (648) jlimit_clause_opt ::= JLIMIT NK_INTEGER */ + 522, /* (649) 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 */ + 523, /* (650) hint_list ::= */ + 523, /* (651) hint_list ::= NK_HINT */ + 525, /* (652) tag_mode_opt ::= */ + 525, /* (653) tag_mode_opt ::= TAGS */ + 524, /* (654) set_quantifier_opt ::= */ + 524, /* (655) set_quantifier_opt ::= DISTINCT */ + 524, /* (656) set_quantifier_opt ::= ALL */ + 526, /* (657) select_list ::= select_item */ + 526, /* (658) select_list ::= select_list NK_COMMA select_item */ + 534, /* (659) select_item ::= NK_STAR */ + 534, /* (660) select_item ::= common_expression */ + 534, /* (661) select_item ::= common_expression column_alias */ + 534, /* (662) select_item ::= common_expression AS column_alias */ + 534, /* (663) select_item ::= table_name NK_DOT NK_STAR */ + 461, /* (664) where_clause_opt ::= */ + 461, /* (665) where_clause_opt ::= WHERE search_condition */ + 527, /* (666) partition_by_clause_opt ::= */ + 527, /* (667) partition_by_clause_opt ::= PARTITION BY partition_list */ + 535, /* (668) partition_list ::= partition_item */ + 535, /* (669) partition_list ::= partition_list NK_COMMA partition_item */ + 536, /* (670) partition_item ::= expr_or_subquery */ + 536, /* (671) partition_item ::= expr_or_subquery column_alias */ + 536, /* (672) partition_item ::= expr_or_subquery AS column_alias */ + 531, /* (673) twindow_clause_opt ::= */ + 531, /* (674) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ + 531, /* (675) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + 531, /* (676) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + 531, /* (677) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + 531, /* (678) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ + 531, /* (679) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ + 531, /* (680) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + 454, /* (681) sliding_opt ::= */ + 454, /* (682) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ + 537, /* (683) interval_sliding_duration_literal ::= NK_VARIABLE */ + 537, /* (684) interval_sliding_duration_literal ::= NK_STRING */ + 537, /* (685) interval_sliding_duration_literal ::= NK_INTEGER */ + 530, /* (686) fill_opt ::= */ + 530, /* (687) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + 530, /* (688) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ + 530, /* (689) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ + 538, /* (690) fill_mode ::= NONE */ + 538, /* (691) fill_mode ::= PREV */ + 538, /* (692) fill_mode ::= NULL */ + 538, /* (693) fill_mode ::= NULL_F */ + 538, /* (694) fill_mode ::= LINEAR */ + 538, /* (695) fill_mode ::= NEXT */ + 532, /* (696) group_by_clause_opt ::= */ + 532, /* (697) group_by_clause_opt ::= GROUP BY group_by_list */ + 539, /* (698) group_by_list ::= expr_or_subquery */ + 539, /* (699) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + 533, /* (700) having_clause_opt ::= */ + 533, /* (701) having_clause_opt ::= HAVING search_condition */ + 528, /* (702) range_opt ::= */ + 528, /* (703) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + 528, /* (704) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ + 529, /* (705) every_opt ::= */ + 529, /* (706) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + 540, /* (707) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + 541, /* (708) query_simple ::= query_specification */ + 541, /* (709) query_simple ::= union_query_expression */ + 545, /* (710) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + 545, /* (711) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + 546, /* (712) query_simple_or_subquery ::= query_simple */ + 546, /* (713) query_simple_or_subquery ::= subquery */ + 460, /* (714) query_or_subquery ::= query_expression */ + 460, /* (715) query_or_subquery ::= subquery */ + 542, /* (716) order_by_clause_opt ::= */ + 542, /* (717) order_by_clause_opt ::= ORDER BY sort_specification_list */ + 543, /* (718) slimit_clause_opt ::= */ + 543, /* (719) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + 543, /* (720) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + 543, /* (721) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 544, /* (722) limit_clause_opt ::= */ + 544, /* (723) limit_clause_opt ::= LIMIT NK_INTEGER */ + 544, /* (724) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + 544, /* (725) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 514, /* (726) subquery ::= NK_LP query_expression NK_RP */ + 514, /* (727) subquery ::= NK_LP subquery NK_RP */ + 391, /* (728) search_condition ::= common_expression */ + 547, /* (729) sort_specification_list ::= sort_specification */ + 547, /* (730) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + 548, /* (731) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + 549, /* (732) ordering_specification_opt ::= */ + 549, /* (733) ordering_specification_opt ::= ASC */ + 549, /* (734) ordering_specification_opt ::= DESC */ + 550, /* (735) null_ordering_opt ::= */ + 550, /* (736) null_ordering_opt ::= NULLS FIRST */ + 550, /* (737) null_ordering_opt ::= NULLS LAST */ + 419, /* (738) column_options ::= */ + 419, /* (739) column_options ::= column_options PRIMARY KEY */ + 419, /* (740) column_options ::= column_options ENCODE NK_STRING */ + 419, /* (741) column_options ::= column_options COMPRESS NK_STRING */ + 419, /* (742) column_options ::= column_options LEVEL NK_STRING */ }; /* For rule J, yyRuleInfoNRhs[J] contains the negative of the number @@ -4999,406 +5048,414 @@ static const signed char yyRuleInfoNRhs[] = { 0, /* (332) db_kind_opt ::= */ -1, /* (333) db_kind_opt ::= USER */ -1, /* (334) db_kind_opt ::= SYSTEM */ - -8, /* (335) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ - -9, /* (336) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ - -4, /* (337) cmd ::= DROP INDEX exists_opt full_index_name */ - -1, /* (338) full_index_name ::= index_name */ - -3, /* (339) full_index_name ::= db_name NK_DOT index_name */ - -10, /* (340) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ - -12, /* (341) 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, /* (342) func_list ::= func */ - -3, /* (343) func_list ::= func_list NK_COMMA func */ - -4, /* (344) func ::= sma_func_name NK_LP expression_list NK_RP */ - -1, /* (345) sma_func_name ::= function_name */ - -1, /* (346) sma_func_name ::= COUNT */ - -1, /* (347) sma_func_name ::= FIRST */ - -1, /* (348) sma_func_name ::= LAST */ - -1, /* (349) sma_func_name ::= LAST_ROW */ - 0, /* (350) sma_stream_opt ::= */ - -3, /* (351) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ - -3, /* (352) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ - -3, /* (353) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ - -1, /* (354) with_meta ::= AS */ - -3, /* (355) with_meta ::= WITH META AS */ - -3, /* (356) with_meta ::= ONLY META AS */ - -6, /* (357) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ - -7, /* (358) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ - -8, /* (359) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ - -4, /* (360) cmd ::= DROP TOPIC exists_opt topic_name */ - -7, /* (361) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ - -2, /* (362) cmd ::= DESC full_table_name */ - -2, /* (363) cmd ::= DESCRIBE full_table_name */ - -3, /* (364) cmd ::= RESET QUERY CACHE */ - -4, /* (365) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - -4, /* (366) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ - 0, /* (367) analyze_opt ::= */ - -1, /* (368) analyze_opt ::= ANALYZE */ - 0, /* (369) explain_options ::= */ - -3, /* (370) explain_options ::= explain_options VERBOSE NK_BOOL */ - -3, /* (371) explain_options ::= explain_options RATIO NK_FLOAT */ - -12, /* (372) 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, /* (373) cmd ::= DROP FUNCTION exists_opt function_name */ - 0, /* (374) agg_func_opt ::= */ - -1, /* (375) agg_func_opt ::= AGGREGATE */ - 0, /* (376) bufsize_opt ::= */ - -2, /* (377) bufsize_opt ::= BUFSIZE NK_INTEGER */ - 0, /* (378) language_opt ::= */ - -2, /* (379) language_opt ::= LANGUAGE NK_STRING */ - 0, /* (380) or_replace_opt ::= */ - -2, /* (381) or_replace_opt ::= OR REPLACE */ - -6, /* (382) cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ - -4, /* (383) cmd ::= DROP VIEW exists_opt full_view_name */ - -1, /* (384) full_view_name ::= view_name */ - -3, /* (385) full_view_name ::= db_name NK_DOT view_name */ - -12, /* (386) 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, /* (387) cmd ::= DROP STREAM exists_opt stream_name */ - -4, /* (388) cmd ::= PAUSE STREAM exists_opt stream_name */ - -5, /* (389) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ - 0, /* (390) col_list_opt ::= */ - -3, /* (391) col_list_opt ::= NK_LP column_stream_def_list NK_RP */ - -1, /* (392) column_stream_def_list ::= column_stream_def */ - -3, /* (393) column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def */ - -2, /* (394) column_stream_def ::= column_name stream_col_options */ - 0, /* (395) stream_col_options ::= */ - -3, /* (396) stream_col_options ::= stream_col_options PRIMARY KEY */ - 0, /* (397) tag_def_or_ref_opt ::= */ - -1, /* (398) tag_def_or_ref_opt ::= tags_def */ - -4, /* (399) tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP */ - 0, /* (400) stream_options ::= */ - -3, /* (401) stream_options ::= stream_options TRIGGER AT_ONCE */ - -3, /* (402) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ - -4, /* (403) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ - -3, /* (404) stream_options ::= stream_options WATERMARK duration_literal */ - -4, /* (405) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ - -3, /* (406) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ - -3, /* (407) stream_options ::= stream_options DELETE_MARK duration_literal */ - -4, /* (408) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ - 0, /* (409) subtable_opt ::= */ - -4, /* (410) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - 0, /* (411) ignore_opt ::= */ - -2, /* (412) ignore_opt ::= IGNORE UNTREATED */ - -3, /* (413) cmd ::= KILL CONNECTION NK_INTEGER */ - -3, /* (414) cmd ::= KILL QUERY NK_STRING */ - -3, /* (415) cmd ::= KILL TRANSACTION NK_INTEGER */ - -3, /* (416) cmd ::= KILL COMPACT NK_INTEGER */ - -2, /* (417) cmd ::= BALANCE VGROUP */ - -4, /* (418) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ - -4, /* (419) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ - -4, /* (420) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ - -3, /* (421) cmd ::= SPLIT VGROUP NK_INTEGER */ - 0, /* (422) on_vgroup_id ::= */ - -2, /* (423) on_vgroup_id ::= ON NK_INTEGER */ - -2, /* (424) dnode_list ::= DNODE NK_INTEGER */ - -3, /* (425) dnode_list ::= dnode_list DNODE NK_INTEGER */ - -4, /* (426) cmd ::= DELETE FROM full_table_name where_clause_opt */ - -1, /* (427) cmd ::= query_or_subquery */ - -1, /* (428) cmd ::= insert_query */ - -7, /* (429) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ - -4, /* (430) insert_query ::= INSERT INTO full_table_name query_or_subquery */ - -1, /* (431) tags_literal ::= NK_INTEGER */ - -3, /* (432) tags_literal ::= NK_INTEGER NK_PLUS duration_literal */ - -3, /* (433) tags_literal ::= NK_INTEGER NK_MINUS duration_literal */ - -2, /* (434) tags_literal ::= NK_PLUS NK_INTEGER */ - -4, /* (435) tags_literal ::= NK_PLUS NK_INTEGER NK_PLUS duration_literal */ - -4, /* (436) tags_literal ::= NK_PLUS NK_INTEGER NK_MINUS duration_literal */ - -2, /* (437) tags_literal ::= NK_MINUS NK_INTEGER */ - -4, /* (438) tags_literal ::= NK_MINUS NK_INTEGER NK_PLUS duration_literal */ - -4, /* (439) tags_literal ::= NK_MINUS NK_INTEGER NK_MINUS duration_literal */ - -1, /* (440) tags_literal ::= NK_FLOAT */ - -2, /* (441) tags_literal ::= NK_PLUS NK_FLOAT */ - -2, /* (442) tags_literal ::= NK_MINUS NK_FLOAT */ - -1, /* (443) tags_literal ::= NK_BIN */ - -3, /* (444) tags_literal ::= NK_BIN NK_PLUS duration_literal */ - -3, /* (445) tags_literal ::= NK_BIN NK_MINUS duration_literal */ - -2, /* (446) tags_literal ::= NK_PLUS NK_BIN */ - -4, /* (447) tags_literal ::= NK_PLUS NK_BIN NK_PLUS duration_literal */ - -4, /* (448) tags_literal ::= NK_PLUS NK_BIN NK_MINUS duration_literal */ - -2, /* (449) tags_literal ::= NK_MINUS NK_BIN */ - -4, /* (450) tags_literal ::= NK_MINUS NK_BIN NK_PLUS duration_literal */ - -4, /* (451) tags_literal ::= NK_MINUS NK_BIN NK_MINUS duration_literal */ - -1, /* (452) tags_literal ::= NK_HEX */ - -3, /* (453) tags_literal ::= NK_HEX NK_PLUS duration_literal */ - -3, /* (454) tags_literal ::= NK_HEX NK_MINUS duration_literal */ - -2, /* (455) tags_literal ::= NK_PLUS NK_HEX */ - -4, /* (456) tags_literal ::= NK_PLUS NK_HEX NK_PLUS duration_literal */ - -4, /* (457) tags_literal ::= NK_PLUS NK_HEX NK_MINUS duration_literal */ - -2, /* (458) tags_literal ::= NK_MINUS NK_HEX */ - -4, /* (459) tags_literal ::= NK_MINUS NK_HEX NK_PLUS duration_literal */ - -4, /* (460) tags_literal ::= NK_MINUS NK_HEX NK_MINUS duration_literal */ - -1, /* (461) tags_literal ::= NK_STRING */ - -3, /* (462) tags_literal ::= NK_STRING NK_PLUS duration_literal */ - -3, /* (463) tags_literal ::= NK_STRING NK_MINUS duration_literal */ - -1, /* (464) tags_literal ::= NK_BOOL */ - -1, /* (465) tags_literal ::= NULL */ - -1, /* (466) tags_literal ::= literal_func */ - -3, /* (467) tags_literal ::= literal_func NK_PLUS duration_literal */ - -3, /* (468) tags_literal ::= literal_func NK_MINUS duration_literal */ - -1, /* (469) tags_literal_list ::= tags_literal */ - -3, /* (470) tags_literal_list ::= tags_literal_list NK_COMMA tags_literal */ - -1, /* (471) literal ::= NK_INTEGER */ - -1, /* (472) literal ::= NK_FLOAT */ - -1, /* (473) literal ::= NK_STRING */ - -1, /* (474) literal ::= NK_BOOL */ - -2, /* (475) literal ::= TIMESTAMP NK_STRING */ - -1, /* (476) literal ::= duration_literal */ - -1, /* (477) literal ::= NULL */ - -1, /* (478) literal ::= NK_QUESTION */ - -1, /* (479) duration_literal ::= NK_VARIABLE */ - -1, /* (480) signed ::= NK_INTEGER */ - -2, /* (481) signed ::= NK_PLUS NK_INTEGER */ - -2, /* (482) signed ::= NK_MINUS NK_INTEGER */ - -1, /* (483) signed ::= NK_FLOAT */ - -2, /* (484) signed ::= NK_PLUS NK_FLOAT */ - -2, /* (485) signed ::= NK_MINUS NK_FLOAT */ - -1, /* (486) signed_literal ::= signed */ - -1, /* (487) signed_literal ::= NK_STRING */ - -1, /* (488) signed_literal ::= NK_BOOL */ - -2, /* (489) signed_literal ::= TIMESTAMP NK_STRING */ - -1, /* (490) signed_literal ::= duration_literal */ - -1, /* (491) signed_literal ::= NULL */ - -1, /* (492) signed_literal ::= literal_func */ - -1, /* (493) signed_literal ::= NK_QUESTION */ - -1, /* (494) literal_list ::= signed_literal */ - -3, /* (495) literal_list ::= literal_list NK_COMMA signed_literal */ - -1, /* (496) db_name ::= NK_ID */ - -1, /* (497) table_name ::= NK_ID */ - -1, /* (498) column_name ::= NK_ID */ - -1, /* (499) function_name ::= NK_ID */ - -1, /* (500) view_name ::= NK_ID */ - -1, /* (501) table_alias ::= NK_ID */ - -1, /* (502) column_alias ::= NK_ID */ - -1, /* (503) column_alias ::= NK_ALIAS */ - -1, /* (504) user_name ::= NK_ID */ - -1, /* (505) topic_name ::= NK_ID */ - -1, /* (506) stream_name ::= NK_ID */ - -1, /* (507) cgroup_name ::= NK_ID */ - -1, /* (508) index_name ::= NK_ID */ - -1, /* (509) expr_or_subquery ::= expression */ - -1, /* (510) expression ::= literal */ - -1, /* (511) expression ::= pseudo_column */ - -1, /* (512) expression ::= column_reference */ - -1, /* (513) expression ::= function_expression */ - -1, /* (514) expression ::= case_when_expression */ - -3, /* (515) expression ::= NK_LP expression NK_RP */ - -2, /* (516) expression ::= NK_PLUS expr_or_subquery */ - -2, /* (517) expression ::= NK_MINUS expr_or_subquery */ - -3, /* (518) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ - -3, /* (519) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ - -3, /* (520) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ - -3, /* (521) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ - -3, /* (522) expression ::= expr_or_subquery NK_REM expr_or_subquery */ - -3, /* (523) expression ::= column_reference NK_ARROW NK_STRING */ - -3, /* (524) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ - -3, /* (525) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ - -1, /* (526) expression_list ::= expr_or_subquery */ - -3, /* (527) expression_list ::= expression_list NK_COMMA expr_or_subquery */ - -1, /* (528) column_reference ::= column_name */ - -3, /* (529) column_reference ::= table_name NK_DOT column_name */ - -1, /* (530) column_reference ::= NK_ALIAS */ - -3, /* (531) column_reference ::= table_name NK_DOT NK_ALIAS */ - -1, /* (532) pseudo_column ::= ROWTS */ - -1, /* (533) pseudo_column ::= TBNAME */ - -3, /* (534) pseudo_column ::= table_name NK_DOT TBNAME */ - -1, /* (535) pseudo_column ::= QSTART */ - -1, /* (536) pseudo_column ::= QEND */ - -1, /* (537) pseudo_column ::= QDURATION */ - -1, /* (538) pseudo_column ::= WSTART */ - -1, /* (539) pseudo_column ::= WEND */ - -1, /* (540) pseudo_column ::= WDURATION */ - -1, /* (541) pseudo_column ::= IROWTS */ - -1, /* (542) pseudo_column ::= ISFILLED */ - -1, /* (543) pseudo_column ::= QTAGS */ - -4, /* (544) function_expression ::= function_name NK_LP expression_list NK_RP */ - -4, /* (545) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ - -6, /* (546) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - -6, /* (547) function_expression ::= CAST NK_LP expr_or_subquery AS type_name_default_len NK_RP */ - -1, /* (548) function_expression ::= literal_func */ - -3, /* (549) literal_func ::= noarg_func NK_LP NK_RP */ - -1, /* (550) literal_func ::= NOW */ - -1, /* (551) literal_func ::= TODAY */ - -1, /* (552) noarg_func ::= NOW */ - -1, /* (553) noarg_func ::= TODAY */ - -1, /* (554) noarg_func ::= TIMEZONE */ - -1, /* (555) noarg_func ::= DATABASE */ - -1, /* (556) noarg_func ::= CLIENT_VERSION */ - -1, /* (557) noarg_func ::= SERVER_VERSION */ - -1, /* (558) noarg_func ::= SERVER_STATUS */ - -1, /* (559) noarg_func ::= CURRENT_USER */ - -1, /* (560) noarg_func ::= USER */ - -1, /* (561) star_func ::= COUNT */ - -1, /* (562) star_func ::= FIRST */ - -1, /* (563) star_func ::= LAST */ - -1, /* (564) star_func ::= LAST_ROW */ - -1, /* (565) star_func_para_list ::= NK_STAR */ - -1, /* (566) star_func_para_list ::= other_para_list */ - -1, /* (567) other_para_list ::= star_func_para */ - -3, /* (568) other_para_list ::= other_para_list NK_COMMA star_func_para */ - -1, /* (569) star_func_para ::= expr_or_subquery */ - -3, /* (570) star_func_para ::= table_name NK_DOT NK_STAR */ - -4, /* (571) case_when_expression ::= CASE when_then_list case_when_else_opt END */ - -5, /* (572) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ - -1, /* (573) when_then_list ::= when_then_expr */ - -2, /* (574) when_then_list ::= when_then_list when_then_expr */ - -4, /* (575) when_then_expr ::= WHEN common_expression THEN common_expression */ - 0, /* (576) case_when_else_opt ::= */ - -2, /* (577) case_when_else_opt ::= ELSE common_expression */ - -3, /* (578) predicate ::= expr_or_subquery compare_op expr_or_subquery */ - -5, /* (579) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ - -6, /* (580) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ - -3, /* (581) predicate ::= expr_or_subquery IS NULL */ - -4, /* (582) predicate ::= expr_or_subquery IS NOT NULL */ - -3, /* (583) predicate ::= expr_or_subquery in_op in_predicate_value */ - -1, /* (584) compare_op ::= NK_LT */ - -1, /* (585) compare_op ::= NK_GT */ - -1, /* (586) compare_op ::= NK_LE */ - -1, /* (587) compare_op ::= NK_GE */ - -1, /* (588) compare_op ::= NK_NE */ - -1, /* (589) compare_op ::= NK_EQ */ - -1, /* (590) compare_op ::= LIKE */ - -2, /* (591) compare_op ::= NOT LIKE */ - -1, /* (592) compare_op ::= MATCH */ - -1, /* (593) compare_op ::= NMATCH */ - -1, /* (594) compare_op ::= CONTAINS */ - -1, /* (595) in_op ::= IN */ - -2, /* (596) in_op ::= NOT IN */ - -3, /* (597) in_predicate_value ::= NK_LP literal_list NK_RP */ - -1, /* (598) boolean_value_expression ::= boolean_primary */ - -2, /* (599) boolean_value_expression ::= NOT boolean_primary */ - -3, /* (600) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ - -3, /* (601) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ - -1, /* (602) boolean_primary ::= predicate */ - -3, /* (603) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ - -1, /* (604) common_expression ::= expr_or_subquery */ - -1, /* (605) common_expression ::= boolean_value_expression */ - 0, /* (606) from_clause_opt ::= */ - -2, /* (607) from_clause_opt ::= FROM table_reference_list */ - -1, /* (608) table_reference_list ::= table_reference */ - -3, /* (609) table_reference_list ::= table_reference_list NK_COMMA table_reference */ - -1, /* (610) table_reference ::= table_primary */ - -1, /* (611) table_reference ::= joined_table */ - -2, /* (612) table_primary ::= table_name alias_opt */ - -4, /* (613) table_primary ::= db_name NK_DOT table_name alias_opt */ - -2, /* (614) table_primary ::= subquery alias_opt */ - -1, /* (615) table_primary ::= parenthesized_joined_table */ - 0, /* (616) alias_opt ::= */ - -1, /* (617) alias_opt ::= table_alias */ - -2, /* (618) alias_opt ::= AS table_alias */ - -3, /* (619) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - -3, /* (620) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ - -8, /* (621) joined_table ::= table_reference join_type join_subtype JOIN table_reference join_on_clause_opt window_offset_clause_opt jlimit_clause_opt */ - 0, /* (622) join_type ::= */ - -1, /* (623) join_type ::= INNER */ - -1, /* (624) join_type ::= LEFT */ - -1, /* (625) join_type ::= RIGHT */ - -1, /* (626) join_type ::= FULL */ - 0, /* (627) join_subtype ::= */ - -1, /* (628) join_subtype ::= OUTER */ - -1, /* (629) join_subtype ::= SEMI */ - -1, /* (630) join_subtype ::= ANTI */ - -1, /* (631) join_subtype ::= ASOF */ - -1, /* (632) join_subtype ::= WINDOW */ - 0, /* (633) join_on_clause_opt ::= */ - -2, /* (634) join_on_clause_opt ::= ON search_condition */ - 0, /* (635) window_offset_clause_opt ::= */ - -6, /* (636) window_offset_clause_opt ::= WINDOW_OFFSET NK_LP window_offset_literal NK_COMMA window_offset_literal NK_RP */ - -1, /* (637) window_offset_literal ::= NK_VARIABLE */ - -2, /* (638) window_offset_literal ::= NK_MINUS NK_VARIABLE */ - 0, /* (639) jlimit_clause_opt ::= */ - -2, /* (640) jlimit_clause_opt ::= JLIMIT NK_INTEGER */ - -14, /* (641) 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, /* (642) hint_list ::= */ - -1, /* (643) hint_list ::= NK_HINT */ - 0, /* (644) tag_mode_opt ::= */ - -1, /* (645) tag_mode_opt ::= TAGS */ - 0, /* (646) set_quantifier_opt ::= */ - -1, /* (647) set_quantifier_opt ::= DISTINCT */ - -1, /* (648) set_quantifier_opt ::= ALL */ - -1, /* (649) select_list ::= select_item */ - -3, /* (650) select_list ::= select_list NK_COMMA select_item */ - -1, /* (651) select_item ::= NK_STAR */ - -1, /* (652) select_item ::= common_expression */ - -2, /* (653) select_item ::= common_expression column_alias */ - -3, /* (654) select_item ::= common_expression AS column_alias */ - -3, /* (655) select_item ::= table_name NK_DOT NK_STAR */ - 0, /* (656) where_clause_opt ::= */ - -2, /* (657) where_clause_opt ::= WHERE search_condition */ - 0, /* (658) partition_by_clause_opt ::= */ - -3, /* (659) partition_by_clause_opt ::= PARTITION BY partition_list */ - -1, /* (660) partition_list ::= partition_item */ - -3, /* (661) partition_list ::= partition_list NK_COMMA partition_item */ - -1, /* (662) partition_item ::= expr_or_subquery */ - -2, /* (663) partition_item ::= expr_or_subquery column_alias */ - -3, /* (664) partition_item ::= expr_or_subquery AS column_alias */ - 0, /* (665) twindow_clause_opt ::= */ - -6, /* (666) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ - -4, /* (667) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ - -6, /* (668) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - -8, /* (669) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ - -7, /* (670) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ - -4, /* (671) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ - -6, /* (672) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ - 0, /* (673) sliding_opt ::= */ - -4, /* (674) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ - -1, /* (675) interval_sliding_duration_literal ::= NK_VARIABLE */ - -1, /* (676) interval_sliding_duration_literal ::= NK_STRING */ - -1, /* (677) interval_sliding_duration_literal ::= NK_INTEGER */ - 0, /* (678) fill_opt ::= */ - -4, /* (679) fill_opt ::= FILL NK_LP fill_mode NK_RP */ - -6, /* (680) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ - -6, /* (681) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ - -1, /* (682) fill_mode ::= NONE */ - -1, /* (683) fill_mode ::= PREV */ - -1, /* (684) fill_mode ::= NULL */ - -1, /* (685) fill_mode ::= NULL_F */ - -1, /* (686) fill_mode ::= LINEAR */ - -1, /* (687) fill_mode ::= NEXT */ - 0, /* (688) group_by_clause_opt ::= */ - -3, /* (689) group_by_clause_opt ::= GROUP BY group_by_list */ - -1, /* (690) group_by_list ::= expr_or_subquery */ - -3, /* (691) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ - 0, /* (692) having_clause_opt ::= */ - -2, /* (693) having_clause_opt ::= HAVING search_condition */ - 0, /* (694) range_opt ::= */ - -6, /* (695) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ - -4, /* (696) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ - 0, /* (697) every_opt ::= */ - -4, /* (698) every_opt ::= EVERY NK_LP duration_literal NK_RP */ - -4, /* (699) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ - -1, /* (700) query_simple ::= query_specification */ - -1, /* (701) query_simple ::= union_query_expression */ - -4, /* (702) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ - -3, /* (703) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ - -1, /* (704) query_simple_or_subquery ::= query_simple */ - -1, /* (705) query_simple_or_subquery ::= subquery */ - -1, /* (706) query_or_subquery ::= query_expression */ - -1, /* (707) query_or_subquery ::= subquery */ - 0, /* (708) order_by_clause_opt ::= */ - -3, /* (709) order_by_clause_opt ::= ORDER BY sort_specification_list */ - 0, /* (710) slimit_clause_opt ::= */ - -2, /* (711) slimit_clause_opt ::= SLIMIT NK_INTEGER */ - -4, /* (712) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - -4, /* (713) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - 0, /* (714) limit_clause_opt ::= */ - -2, /* (715) limit_clause_opt ::= LIMIT NK_INTEGER */ - -4, /* (716) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ - -4, /* (717) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - -3, /* (718) subquery ::= NK_LP query_expression NK_RP */ - -3, /* (719) subquery ::= NK_LP subquery NK_RP */ - -1, /* (720) search_condition ::= common_expression */ - -1, /* (721) sort_specification_list ::= sort_specification */ - -3, /* (722) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ - -3, /* (723) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ - 0, /* (724) ordering_specification_opt ::= */ - -1, /* (725) ordering_specification_opt ::= ASC */ - -1, /* (726) ordering_specification_opt ::= DESC */ - 0, /* (727) null_ordering_opt ::= */ - -2, /* (728) null_ordering_opt ::= NULLS FIRST */ - -2, /* (729) null_ordering_opt ::= NULLS LAST */ - 0, /* (730) column_options ::= */ - -3, /* (731) column_options ::= column_options PRIMARY KEY */ - -3, /* (732) column_options ::= column_options ENCODE NK_STRING */ - -3, /* (733) column_options ::= column_options COMPRESS NK_STRING */ - -3, /* (734) column_options ::= column_options LEVEL NK_STRING */ + -11, /* (335) cmd ::= CREATE TSMA not_exists_opt tsma_name ON full_table_name tsma_func_list INTERVAL NK_LP duration_literal NK_RP */ + -11, /* (336) cmd ::= CREATE RECURSIVE TSMA not_exists_opt tsma_name ON full_table_name INTERVAL NK_LP duration_literal NK_RP */ + -4, /* (337) cmd ::= DROP TSMA exists_opt full_tsma_name */ + -3, /* (338) cmd ::= SHOW db_name_cond_opt TSMAS */ + -1, /* (339) full_tsma_name ::= tsma_name */ + -3, /* (340) full_tsma_name ::= db_name NK_DOT tsma_name */ + -4, /* (341) tsma_func_list ::= FUNCTION NK_LP func_list NK_RP */ + -8, /* (342) cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ + -9, /* (343) cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ + -4, /* (344) cmd ::= DROP INDEX exists_opt full_index_name */ + -1, /* (345) full_index_name ::= index_name */ + -3, /* (346) full_index_name ::= db_name NK_DOT index_name */ + -10, /* (347) index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ + -12, /* (348) 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, /* (349) func_list ::= func */ + -3, /* (350) func_list ::= func_list NK_COMMA func */ + -4, /* (351) func ::= sma_func_name NK_LP expression_list NK_RP */ + -1, /* (352) sma_func_name ::= function_name */ + -1, /* (353) sma_func_name ::= COUNT */ + -1, /* (354) sma_func_name ::= FIRST */ + -1, /* (355) sma_func_name ::= LAST */ + -1, /* (356) sma_func_name ::= LAST_ROW */ + 0, /* (357) sma_stream_opt ::= */ + -3, /* (358) sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ + -3, /* (359) sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ + -3, /* (360) sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ + -1, /* (361) with_meta ::= AS */ + -3, /* (362) with_meta ::= WITH META AS */ + -3, /* (363) with_meta ::= ONLY META AS */ + -6, /* (364) cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ + -7, /* (365) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ + -8, /* (366) cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ + -4, /* (367) cmd ::= DROP TOPIC exists_opt topic_name */ + -7, /* (368) cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ + -2, /* (369) cmd ::= DESC full_table_name */ + -2, /* (370) cmd ::= DESCRIBE full_table_name */ + -3, /* (371) cmd ::= RESET QUERY CACHE */ + -4, /* (372) cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + -4, /* (373) cmd ::= EXPLAIN analyze_opt explain_options insert_query */ + 0, /* (374) analyze_opt ::= */ + -1, /* (375) analyze_opt ::= ANALYZE */ + 0, /* (376) explain_options ::= */ + -3, /* (377) explain_options ::= explain_options VERBOSE NK_BOOL */ + -3, /* (378) explain_options ::= explain_options RATIO NK_FLOAT */ + -12, /* (379) 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, /* (380) cmd ::= DROP FUNCTION exists_opt function_name */ + 0, /* (381) agg_func_opt ::= */ + -1, /* (382) agg_func_opt ::= AGGREGATE */ + 0, /* (383) bufsize_opt ::= */ + -2, /* (384) bufsize_opt ::= BUFSIZE NK_INTEGER */ + 0, /* (385) language_opt ::= */ + -2, /* (386) language_opt ::= LANGUAGE NK_STRING */ + 0, /* (387) or_replace_opt ::= */ + -2, /* (388) or_replace_opt ::= OR REPLACE */ + -6, /* (389) cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ + -4, /* (390) cmd ::= DROP VIEW exists_opt full_view_name */ + -1, /* (391) full_view_name ::= view_name */ + -3, /* (392) full_view_name ::= db_name NK_DOT view_name */ + -12, /* (393) 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, /* (394) cmd ::= DROP STREAM exists_opt stream_name */ + -4, /* (395) cmd ::= PAUSE STREAM exists_opt stream_name */ + -5, /* (396) cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ + 0, /* (397) col_list_opt ::= */ + -3, /* (398) col_list_opt ::= NK_LP column_stream_def_list NK_RP */ + -1, /* (399) column_stream_def_list ::= column_stream_def */ + -3, /* (400) column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def */ + -2, /* (401) column_stream_def ::= column_name stream_col_options */ + 0, /* (402) stream_col_options ::= */ + -3, /* (403) stream_col_options ::= stream_col_options PRIMARY KEY */ + 0, /* (404) tag_def_or_ref_opt ::= */ + -1, /* (405) tag_def_or_ref_opt ::= tags_def */ + -4, /* (406) tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP */ + 0, /* (407) stream_options ::= */ + -3, /* (408) stream_options ::= stream_options TRIGGER AT_ONCE */ + -3, /* (409) stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ + -4, /* (410) stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ + -3, /* (411) stream_options ::= stream_options WATERMARK duration_literal */ + -4, /* (412) stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ + -3, /* (413) stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ + -3, /* (414) stream_options ::= stream_options DELETE_MARK duration_literal */ + -4, /* (415) stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ + 0, /* (416) subtable_opt ::= */ + -4, /* (417) subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + 0, /* (418) ignore_opt ::= */ + -2, /* (419) ignore_opt ::= IGNORE UNTREATED */ + -3, /* (420) cmd ::= KILL CONNECTION NK_INTEGER */ + -3, /* (421) cmd ::= KILL QUERY NK_STRING */ + -3, /* (422) cmd ::= KILL TRANSACTION NK_INTEGER */ + -3, /* (423) cmd ::= KILL COMPACT NK_INTEGER */ + -2, /* (424) cmd ::= BALANCE VGROUP */ + -4, /* (425) cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ + -4, /* (426) cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ + -4, /* (427) cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ + -3, /* (428) cmd ::= SPLIT VGROUP NK_INTEGER */ + 0, /* (429) on_vgroup_id ::= */ + -2, /* (430) on_vgroup_id ::= ON NK_INTEGER */ + -2, /* (431) dnode_list ::= DNODE NK_INTEGER */ + -3, /* (432) dnode_list ::= dnode_list DNODE NK_INTEGER */ + -4, /* (433) cmd ::= DELETE FROM full_table_name where_clause_opt */ + -1, /* (434) cmd ::= query_or_subquery */ + -1, /* (435) cmd ::= insert_query */ + -7, /* (436) insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ + -4, /* (437) insert_query ::= INSERT INTO full_table_name query_or_subquery */ + -1, /* (438) tags_literal ::= NK_INTEGER */ + -3, /* (439) tags_literal ::= NK_INTEGER NK_PLUS duration_literal */ + -3, /* (440) tags_literal ::= NK_INTEGER NK_MINUS duration_literal */ + -2, /* (441) tags_literal ::= NK_PLUS NK_INTEGER */ + -4, /* (442) tags_literal ::= NK_PLUS NK_INTEGER NK_PLUS duration_literal */ + -4, /* (443) tags_literal ::= NK_PLUS NK_INTEGER NK_MINUS duration_literal */ + -2, /* (444) tags_literal ::= NK_MINUS NK_INTEGER */ + -4, /* (445) tags_literal ::= NK_MINUS NK_INTEGER NK_PLUS duration_literal */ + -4, /* (446) tags_literal ::= NK_MINUS NK_INTEGER NK_MINUS duration_literal */ + -1, /* (447) tags_literal ::= NK_FLOAT */ + -2, /* (448) tags_literal ::= NK_PLUS NK_FLOAT */ + -2, /* (449) tags_literal ::= NK_MINUS NK_FLOAT */ + -1, /* (450) tags_literal ::= NK_BIN */ + -3, /* (451) tags_literal ::= NK_BIN NK_PLUS duration_literal */ + -3, /* (452) tags_literal ::= NK_BIN NK_MINUS duration_literal */ + -2, /* (453) tags_literal ::= NK_PLUS NK_BIN */ + -4, /* (454) tags_literal ::= NK_PLUS NK_BIN NK_PLUS duration_literal */ + -4, /* (455) tags_literal ::= NK_PLUS NK_BIN NK_MINUS duration_literal */ + -2, /* (456) tags_literal ::= NK_MINUS NK_BIN */ + -4, /* (457) tags_literal ::= NK_MINUS NK_BIN NK_PLUS duration_literal */ + -4, /* (458) tags_literal ::= NK_MINUS NK_BIN NK_MINUS duration_literal */ + -1, /* (459) tags_literal ::= NK_HEX */ + -3, /* (460) tags_literal ::= NK_HEX NK_PLUS duration_literal */ + -3, /* (461) tags_literal ::= NK_HEX NK_MINUS duration_literal */ + -2, /* (462) tags_literal ::= NK_PLUS NK_HEX */ + -4, /* (463) tags_literal ::= NK_PLUS NK_HEX NK_PLUS duration_literal */ + -4, /* (464) tags_literal ::= NK_PLUS NK_HEX NK_MINUS duration_literal */ + -2, /* (465) tags_literal ::= NK_MINUS NK_HEX */ + -4, /* (466) tags_literal ::= NK_MINUS NK_HEX NK_PLUS duration_literal */ + -4, /* (467) tags_literal ::= NK_MINUS NK_HEX NK_MINUS duration_literal */ + -1, /* (468) tags_literal ::= NK_STRING */ + -3, /* (469) tags_literal ::= NK_STRING NK_PLUS duration_literal */ + -3, /* (470) tags_literal ::= NK_STRING NK_MINUS duration_literal */ + -1, /* (471) tags_literal ::= NK_BOOL */ + -1, /* (472) tags_literal ::= NULL */ + -1, /* (473) tags_literal ::= literal_func */ + -3, /* (474) tags_literal ::= literal_func NK_PLUS duration_literal */ + -3, /* (475) tags_literal ::= literal_func NK_MINUS duration_literal */ + -1, /* (476) tags_literal_list ::= tags_literal */ + -3, /* (477) tags_literal_list ::= tags_literal_list NK_COMMA tags_literal */ + -1, /* (478) literal ::= NK_INTEGER */ + -1, /* (479) literal ::= NK_FLOAT */ + -1, /* (480) literal ::= NK_STRING */ + -1, /* (481) literal ::= NK_BOOL */ + -2, /* (482) literal ::= TIMESTAMP NK_STRING */ + -1, /* (483) literal ::= duration_literal */ + -1, /* (484) literal ::= NULL */ + -1, /* (485) literal ::= NK_QUESTION */ + -1, /* (486) duration_literal ::= NK_VARIABLE */ + -1, /* (487) signed ::= NK_INTEGER */ + -2, /* (488) signed ::= NK_PLUS NK_INTEGER */ + -2, /* (489) signed ::= NK_MINUS NK_INTEGER */ + -1, /* (490) signed ::= NK_FLOAT */ + -2, /* (491) signed ::= NK_PLUS NK_FLOAT */ + -2, /* (492) signed ::= NK_MINUS NK_FLOAT */ + -1, /* (493) signed_literal ::= signed */ + -1, /* (494) signed_literal ::= NK_STRING */ + -1, /* (495) signed_literal ::= NK_BOOL */ + -2, /* (496) signed_literal ::= TIMESTAMP NK_STRING */ + -1, /* (497) signed_literal ::= duration_literal */ + -1, /* (498) signed_literal ::= NULL */ + -1, /* (499) signed_literal ::= literal_func */ + -1, /* (500) signed_literal ::= NK_QUESTION */ + -1, /* (501) literal_list ::= signed_literal */ + -3, /* (502) literal_list ::= literal_list NK_COMMA signed_literal */ + -1, /* (503) db_name ::= NK_ID */ + -1, /* (504) table_name ::= NK_ID */ + -1, /* (505) column_name ::= NK_ID */ + -1, /* (506) function_name ::= NK_ID */ + -1, /* (507) view_name ::= NK_ID */ + -1, /* (508) table_alias ::= NK_ID */ + -1, /* (509) column_alias ::= NK_ID */ + -1, /* (510) column_alias ::= NK_ALIAS */ + -1, /* (511) user_name ::= NK_ID */ + -1, /* (512) topic_name ::= NK_ID */ + -1, /* (513) stream_name ::= NK_ID */ + -1, /* (514) cgroup_name ::= NK_ID */ + -1, /* (515) index_name ::= NK_ID */ + -1, /* (516) tsma_name ::= NK_ID */ + -1, /* (517) expr_or_subquery ::= expression */ + -1, /* (518) expression ::= literal */ + -1, /* (519) expression ::= pseudo_column */ + -1, /* (520) expression ::= column_reference */ + -1, /* (521) expression ::= function_expression */ + -1, /* (522) expression ::= case_when_expression */ + -3, /* (523) expression ::= NK_LP expression NK_RP */ + -2, /* (524) expression ::= NK_PLUS expr_or_subquery */ + -2, /* (525) expression ::= NK_MINUS expr_or_subquery */ + -3, /* (526) expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ + -3, /* (527) expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ + -3, /* (528) expression ::= expr_or_subquery NK_STAR expr_or_subquery */ + -3, /* (529) expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ + -3, /* (530) expression ::= expr_or_subquery NK_REM expr_or_subquery */ + -3, /* (531) expression ::= column_reference NK_ARROW NK_STRING */ + -3, /* (532) expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ + -3, /* (533) expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ + -1, /* (534) expression_list ::= expr_or_subquery */ + -3, /* (535) expression_list ::= expression_list NK_COMMA expr_or_subquery */ + -1, /* (536) column_reference ::= column_name */ + -3, /* (537) column_reference ::= table_name NK_DOT column_name */ + -1, /* (538) column_reference ::= NK_ALIAS */ + -3, /* (539) column_reference ::= table_name NK_DOT NK_ALIAS */ + -1, /* (540) pseudo_column ::= ROWTS */ + -1, /* (541) pseudo_column ::= TBNAME */ + -3, /* (542) pseudo_column ::= table_name NK_DOT TBNAME */ + -1, /* (543) pseudo_column ::= QSTART */ + -1, /* (544) pseudo_column ::= QEND */ + -1, /* (545) pseudo_column ::= QDURATION */ + -1, /* (546) pseudo_column ::= WSTART */ + -1, /* (547) pseudo_column ::= WEND */ + -1, /* (548) pseudo_column ::= WDURATION */ + -1, /* (549) pseudo_column ::= IROWTS */ + -1, /* (550) pseudo_column ::= ISFILLED */ + -1, /* (551) pseudo_column ::= QTAGS */ + -4, /* (552) function_expression ::= function_name NK_LP expression_list NK_RP */ + -4, /* (553) function_expression ::= star_func NK_LP star_func_para_list NK_RP */ + -6, /* (554) function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + -6, /* (555) function_expression ::= CAST NK_LP expr_or_subquery AS type_name_default_len NK_RP */ + -1, /* (556) function_expression ::= literal_func */ + -3, /* (557) literal_func ::= noarg_func NK_LP NK_RP */ + -1, /* (558) literal_func ::= NOW */ + -1, /* (559) literal_func ::= TODAY */ + -1, /* (560) noarg_func ::= NOW */ + -1, /* (561) noarg_func ::= TODAY */ + -1, /* (562) noarg_func ::= TIMEZONE */ + -1, /* (563) noarg_func ::= DATABASE */ + -1, /* (564) noarg_func ::= CLIENT_VERSION */ + -1, /* (565) noarg_func ::= SERVER_VERSION */ + -1, /* (566) noarg_func ::= SERVER_STATUS */ + -1, /* (567) noarg_func ::= CURRENT_USER */ + -1, /* (568) noarg_func ::= USER */ + -1, /* (569) star_func ::= COUNT */ + -1, /* (570) star_func ::= FIRST */ + -1, /* (571) star_func ::= LAST */ + -1, /* (572) star_func ::= LAST_ROW */ + -1, /* (573) star_func_para_list ::= NK_STAR */ + -1, /* (574) star_func_para_list ::= other_para_list */ + -1, /* (575) other_para_list ::= star_func_para */ + -3, /* (576) other_para_list ::= other_para_list NK_COMMA star_func_para */ + -1, /* (577) star_func_para ::= expr_or_subquery */ + -3, /* (578) star_func_para ::= table_name NK_DOT NK_STAR */ + -4, /* (579) case_when_expression ::= CASE when_then_list case_when_else_opt END */ + -5, /* (580) case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ + -1, /* (581) when_then_list ::= when_then_expr */ + -2, /* (582) when_then_list ::= when_then_list when_then_expr */ + -4, /* (583) when_then_expr ::= WHEN common_expression THEN common_expression */ + 0, /* (584) case_when_else_opt ::= */ + -2, /* (585) case_when_else_opt ::= ELSE common_expression */ + -3, /* (586) predicate ::= expr_or_subquery compare_op expr_or_subquery */ + -5, /* (587) predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ + -6, /* (588) predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ + -3, /* (589) predicate ::= expr_or_subquery IS NULL */ + -4, /* (590) predicate ::= expr_or_subquery IS NOT NULL */ + -3, /* (591) predicate ::= expr_or_subquery in_op in_predicate_value */ + -1, /* (592) compare_op ::= NK_LT */ + -1, /* (593) compare_op ::= NK_GT */ + -1, /* (594) compare_op ::= NK_LE */ + -1, /* (595) compare_op ::= NK_GE */ + -1, /* (596) compare_op ::= NK_NE */ + -1, /* (597) compare_op ::= NK_EQ */ + -1, /* (598) compare_op ::= LIKE */ + -2, /* (599) compare_op ::= NOT LIKE */ + -1, /* (600) compare_op ::= MATCH */ + -1, /* (601) compare_op ::= NMATCH */ + -1, /* (602) compare_op ::= CONTAINS */ + -1, /* (603) in_op ::= IN */ + -2, /* (604) in_op ::= NOT IN */ + -3, /* (605) in_predicate_value ::= NK_LP literal_list NK_RP */ + -1, /* (606) boolean_value_expression ::= boolean_primary */ + -2, /* (607) boolean_value_expression ::= NOT boolean_primary */ + -3, /* (608) boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ + -3, /* (609) boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ + -1, /* (610) boolean_primary ::= predicate */ + -3, /* (611) boolean_primary ::= NK_LP boolean_value_expression NK_RP */ + -1, /* (612) common_expression ::= expr_or_subquery */ + -1, /* (613) common_expression ::= boolean_value_expression */ + 0, /* (614) from_clause_opt ::= */ + -2, /* (615) from_clause_opt ::= FROM table_reference_list */ + -1, /* (616) table_reference_list ::= table_reference */ + -3, /* (617) table_reference_list ::= table_reference_list NK_COMMA table_reference */ + -1, /* (618) table_reference ::= table_primary */ + -1, /* (619) table_reference ::= joined_table */ + -2, /* (620) table_primary ::= table_name alias_opt */ + -4, /* (621) table_primary ::= db_name NK_DOT table_name alias_opt */ + -2, /* (622) table_primary ::= subquery alias_opt */ + -1, /* (623) table_primary ::= parenthesized_joined_table */ + 0, /* (624) alias_opt ::= */ + -1, /* (625) alias_opt ::= table_alias */ + -2, /* (626) alias_opt ::= AS table_alias */ + -3, /* (627) parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + -3, /* (628) parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ + -8, /* (629) joined_table ::= table_reference join_type join_subtype JOIN table_reference join_on_clause_opt window_offset_clause_opt jlimit_clause_opt */ + 0, /* (630) join_type ::= */ + -1, /* (631) join_type ::= INNER */ + -1, /* (632) join_type ::= LEFT */ + -1, /* (633) join_type ::= RIGHT */ + -1, /* (634) join_type ::= FULL */ + 0, /* (635) join_subtype ::= */ + -1, /* (636) join_subtype ::= OUTER */ + -1, /* (637) join_subtype ::= SEMI */ + -1, /* (638) join_subtype ::= ANTI */ + -1, /* (639) join_subtype ::= ASOF */ + -1, /* (640) join_subtype ::= WINDOW */ + 0, /* (641) join_on_clause_opt ::= */ + -2, /* (642) join_on_clause_opt ::= ON search_condition */ + 0, /* (643) window_offset_clause_opt ::= */ + -6, /* (644) window_offset_clause_opt ::= WINDOW_OFFSET NK_LP window_offset_literal NK_COMMA window_offset_literal NK_RP */ + -1, /* (645) window_offset_literal ::= NK_VARIABLE */ + -2, /* (646) window_offset_literal ::= NK_MINUS NK_VARIABLE */ + 0, /* (647) jlimit_clause_opt ::= */ + -2, /* (648) jlimit_clause_opt ::= JLIMIT NK_INTEGER */ + -14, /* (649) 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, /* (650) hint_list ::= */ + -1, /* (651) hint_list ::= NK_HINT */ + 0, /* (652) tag_mode_opt ::= */ + -1, /* (653) tag_mode_opt ::= TAGS */ + 0, /* (654) set_quantifier_opt ::= */ + -1, /* (655) set_quantifier_opt ::= DISTINCT */ + -1, /* (656) set_quantifier_opt ::= ALL */ + -1, /* (657) select_list ::= select_item */ + -3, /* (658) select_list ::= select_list NK_COMMA select_item */ + -1, /* (659) select_item ::= NK_STAR */ + -1, /* (660) select_item ::= common_expression */ + -2, /* (661) select_item ::= common_expression column_alias */ + -3, /* (662) select_item ::= common_expression AS column_alias */ + -3, /* (663) select_item ::= table_name NK_DOT NK_STAR */ + 0, /* (664) where_clause_opt ::= */ + -2, /* (665) where_clause_opt ::= WHERE search_condition */ + 0, /* (666) partition_by_clause_opt ::= */ + -3, /* (667) partition_by_clause_opt ::= PARTITION BY partition_list */ + -1, /* (668) partition_list ::= partition_item */ + -3, /* (669) partition_list ::= partition_list NK_COMMA partition_item */ + -1, /* (670) partition_item ::= expr_or_subquery */ + -2, /* (671) partition_item ::= expr_or_subquery column_alias */ + -3, /* (672) partition_item ::= expr_or_subquery AS column_alias */ + 0, /* (673) twindow_clause_opt ::= */ + -6, /* (674) twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ + -4, /* (675) twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ + -6, /* (676) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + -8, /* (677) twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ + -7, /* (678) twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ + -4, /* (679) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ + -6, /* (680) twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ + 0, /* (681) sliding_opt ::= */ + -4, /* (682) sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ + -1, /* (683) interval_sliding_duration_literal ::= NK_VARIABLE */ + -1, /* (684) interval_sliding_duration_literal ::= NK_STRING */ + -1, /* (685) interval_sliding_duration_literal ::= NK_INTEGER */ + 0, /* (686) fill_opt ::= */ + -4, /* (687) fill_opt ::= FILL NK_LP fill_mode NK_RP */ + -6, /* (688) fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ + -6, /* (689) fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ + -1, /* (690) fill_mode ::= NONE */ + -1, /* (691) fill_mode ::= PREV */ + -1, /* (692) fill_mode ::= NULL */ + -1, /* (693) fill_mode ::= NULL_F */ + -1, /* (694) fill_mode ::= LINEAR */ + -1, /* (695) fill_mode ::= NEXT */ + 0, /* (696) group_by_clause_opt ::= */ + -3, /* (697) group_by_clause_opt ::= GROUP BY group_by_list */ + -1, /* (698) group_by_list ::= expr_or_subquery */ + -3, /* (699) group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ + 0, /* (700) having_clause_opt ::= */ + -2, /* (701) having_clause_opt ::= HAVING search_condition */ + 0, /* (702) range_opt ::= */ + -6, /* (703) range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ + -4, /* (704) range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ + 0, /* (705) every_opt ::= */ + -4, /* (706) every_opt ::= EVERY NK_LP duration_literal NK_RP */ + -4, /* (707) query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ + -1, /* (708) query_simple ::= query_specification */ + -1, /* (709) query_simple ::= union_query_expression */ + -4, /* (710) union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ + -3, /* (711) union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ + -1, /* (712) query_simple_or_subquery ::= query_simple */ + -1, /* (713) query_simple_or_subquery ::= subquery */ + -1, /* (714) query_or_subquery ::= query_expression */ + -1, /* (715) query_or_subquery ::= subquery */ + 0, /* (716) order_by_clause_opt ::= */ + -3, /* (717) order_by_clause_opt ::= ORDER BY sort_specification_list */ + 0, /* (718) slimit_clause_opt ::= */ + -2, /* (719) slimit_clause_opt ::= SLIMIT NK_INTEGER */ + -4, /* (720) slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + -4, /* (721) slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + 0, /* (722) limit_clause_opt ::= */ + -2, /* (723) limit_clause_opt ::= LIMIT NK_INTEGER */ + -4, /* (724) limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ + -4, /* (725) limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + -3, /* (726) subquery ::= NK_LP query_expression NK_RP */ + -3, /* (727) subquery ::= NK_LP subquery NK_RP */ + -1, /* (728) search_condition ::= common_expression */ + -1, /* (729) sort_specification_list ::= sort_specification */ + -3, /* (730) sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ + -3, /* (731) sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ + 0, /* (732) ordering_specification_opt ::= */ + -1, /* (733) ordering_specification_opt ::= ASC */ + -1, /* (734) ordering_specification_opt ::= DESC */ + 0, /* (735) null_ordering_opt ::= */ + -2, /* (736) null_ordering_opt ::= NULLS FIRST */ + -2, /* (737) null_ordering_opt ::= NULLS LAST */ + 0, /* (738) column_options ::= */ + -3, /* (739) column_options ::= column_options PRIMARY KEY */ + -3, /* (740) column_options ::= column_options ENCODE NK_STRING */ + -3, /* (741) column_options ::= column_options COMPRESS NK_STRING */ + -3, /* (742) column_options ::= column_options LEVEL NK_STRING */ }; static void yy_accept(yyParser*); /* Forward Declaration */ @@ -5443,19 +5500,19 @@ static YYACTIONTYPE yy_reduce( 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); } -#line 5446 "sql.c" - yy_destructor(yypParser,371,&yymsp[0].minor); +#line 5503 "sql.c" + yy_destructor(yypParser,374,&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); } -#line 5452 "sql.c" - yy_destructor(yypParser,372,&yymsp[0].minor); +#line 5509 "sql.c" + yy_destructor(yypParser,375,&yymsp[0].minor); break; case 2: /* account_options ::= */ #line 55 "sql.y" { } -#line 5458 "sql.c" +#line 5515 "sql.c" break; case 3: /* account_options ::= account_options PPS literal */ case 4: /* account_options ::= account_options TSERIES literal */ yytestcase(yyruleno==4); @@ -5466,26 +5523,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,371,&yymsp[-2].minor); +{ yy_destructor(yypParser,374,&yymsp[-2].minor); #line 56 "sql.y" { } -#line 5472 "sql.c" - yy_destructor(yypParser,373,&yymsp[0].minor); +#line 5529 "sql.c" + yy_destructor(yypParser,376,&yymsp[0].minor); } break; case 12: /* alter_account_options ::= alter_account_option */ -{ yy_destructor(yypParser,374,&yymsp[0].minor); +{ yy_destructor(yypParser,377,&yymsp[0].minor); #line 68 "sql.y" { } -#line 5480 "sql.c" +#line 5537 "sql.c" } break; case 13: /* alter_account_options ::= alter_account_options alter_account_option */ -{ yy_destructor(yypParser,372,&yymsp[-1].minor); +{ yy_destructor(yypParser,375,&yymsp[-1].minor); #line 69 "sql.y" { } -#line 5487 "sql.c" - yy_destructor(yypParser,374,&yymsp[0].minor); +#line 5544 "sql.c" + yy_destructor(yypParser,377,&yymsp[0].minor); } break; case 14: /* alter_account_option ::= PASS literal */ @@ -5500,782 +5557,783 @@ static YYACTIONTYPE yy_reduce( case 23: /* alter_account_option ::= STATE literal */ yytestcase(yyruleno==23); #line 73 "sql.y" { } -#line 5503 "sql.c" - yy_destructor(yypParser,373,&yymsp[0].minor); +#line 5560 "sql.c" + yy_destructor(yypParser,376,&yymsp[0].minor); break; case 24: /* ip_range_list ::= NK_STRING */ #line 86 "sql.y" -{ yylhsminor.yy694 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } -#line 5509 "sql.c" - yymsp[0].minor.yy694 = yylhsminor.yy694; +{ yylhsminor.yy616 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } +#line 5566 "sql.c" + yymsp[0].minor.yy616 = yylhsminor.yy616; break; case 25: /* ip_range_list ::= ip_range_list NK_COMMA NK_STRING */ #line 87 "sql.y" -{ yylhsminor.yy694 = addNodeToList(pCxt, yymsp[-2].minor.yy694, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } -#line 5515 "sql.c" - yymsp[-2].minor.yy694 = yylhsminor.yy694; +{ yylhsminor.yy616 = addNodeToList(pCxt, yymsp[-2].minor.yy616, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } +#line 5572 "sql.c" + yymsp[-2].minor.yy616 = yylhsminor.yy616; break; case 26: /* white_list ::= HOST ip_range_list */ #line 91 "sql.y" -{ yymsp[-1].minor.yy694 = yymsp[0].minor.yy694; } -#line 5521 "sql.c" +{ yymsp[-1].minor.yy616 = yymsp[0].minor.yy616; } +#line 5578 "sql.c" break; case 27: /* white_list_opt ::= */ case 197: /* specific_cols_opt ::= */ yytestcase(yyruleno==197); case 235: /* tags_def_opt ::= */ yytestcase(yyruleno==235); case 324: /* tag_list_opt ::= */ yytestcase(yyruleno==324); - case 390: /* col_list_opt ::= */ yytestcase(yyruleno==390); - case 397: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==397); - case 658: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==658); - case 688: /* group_by_clause_opt ::= */ yytestcase(yyruleno==688); - case 708: /* order_by_clause_opt ::= */ yytestcase(yyruleno==708); + case 397: /* col_list_opt ::= */ yytestcase(yyruleno==397); + case 404: /* tag_def_or_ref_opt ::= */ yytestcase(yyruleno==404); + case 666: /* partition_by_clause_opt ::= */ yytestcase(yyruleno==666); + case 696: /* group_by_clause_opt ::= */ yytestcase(yyruleno==696); + case 716: /* order_by_clause_opt ::= */ yytestcase(yyruleno==716); #line 95 "sql.y" -{ yymsp[1].minor.yy694 = NULL; } -#line 5534 "sql.c" +{ yymsp[1].minor.yy616 = NULL; } +#line 5591 "sql.c" break; case 28: /* white_list_opt ::= white_list */ case 236: /* tags_def_opt ::= tags_def */ yytestcase(yyruleno==236); - case 398: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==398); - case 566: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==566); + case 405: /* tag_def_or_ref_opt ::= tags_def */ yytestcase(yyruleno==405); + case 574: /* star_func_para_list ::= other_para_list */ yytestcase(yyruleno==574); #line 96 "sql.y" -{ yylhsminor.yy694 = yymsp[0].minor.yy694; } -#line 5542 "sql.c" - yymsp[0].minor.yy694 = yylhsminor.yy694; +{ yylhsminor.yy616 = yymsp[0].minor.yy616; } +#line 5599 "sql.c" + yymsp[0].minor.yy616 = yylhsminor.yy616; 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.yy659, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy173); - pCxt->pRootNode = addCreateUserStmtWhiteList(pCxt, pCxt->pRootNode, yymsp[0].minor.yy694); + pCxt->pRootNode = createCreateUserStmt(pCxt, &yymsp[-4].minor.yy585, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy999); + pCxt->pRootNode = addCreateUserStmtWhiteList(pCxt, pCxt->pRootNode, yymsp[0].minor.yy616); } -#line 5551 "sql.c" +#line 5608 "sql.c" break; case 30: /* cmd ::= ALTER USER user_name PASS NK_STRING */ #line 104 "sql.y" -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy659, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } -#line 5556 "sql.c" +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy585, TSDB_ALTER_USER_PASSWD, &yymsp[0].minor.yy0); } +#line 5613 "sql.c" break; case 31: /* cmd ::= ALTER USER user_name ENABLE NK_INTEGER */ #line 105 "sql.y" -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy659, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } -#line 5561 "sql.c" +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy585, TSDB_ALTER_USER_ENABLE, &yymsp[0].minor.yy0); } +#line 5618 "sql.c" break; case 32: /* cmd ::= ALTER USER user_name SYSINFO NK_INTEGER */ #line 106 "sql.y" -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy659, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } -#line 5566 "sql.c" +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy585, TSDB_ALTER_USER_SYSINFO, &yymsp[0].minor.yy0); } +#line 5623 "sql.c" break; case 33: /* cmd ::= ALTER USER user_name ADD white_list */ #line 107 "sql.y" -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy659, TSDB_ALTER_USER_ADD_WHITE_LIST, yymsp[0].minor.yy694); } -#line 5571 "sql.c" +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy585, TSDB_ALTER_USER_ADD_WHITE_LIST, yymsp[0].minor.yy616); } +#line 5628 "sql.c" break; case 34: /* cmd ::= ALTER USER user_name DROP white_list */ #line 108 "sql.y" -{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy659, TSDB_ALTER_USER_DROP_WHITE_LIST, yymsp[0].minor.yy694); } -#line 5576 "sql.c" +{ pCxt->pRootNode = createAlterUserStmt(pCxt, &yymsp[-2].minor.yy585, TSDB_ALTER_USER_DROP_WHITE_LIST, yymsp[0].minor.yy616); } +#line 5633 "sql.c" break; case 35: /* cmd ::= DROP USER user_name */ #line 109 "sql.y" -{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy659); } -#line 5581 "sql.c" +{ pCxt->pRootNode = createDropUserStmt(pCxt, &yymsp[0].minor.yy585); } +#line 5638 "sql.c" break; case 36: /* sysinfo_opt ::= */ #line 113 "sql.y" -{ yymsp[1].minor.yy173 = 1; } -#line 5586 "sql.c" +{ yymsp[1].minor.yy999 = 1; } +#line 5643 "sql.c" break; case 37: /* sysinfo_opt ::= SYSINFO NK_INTEGER */ #line 114 "sql.y" -{ yymsp[-1].minor.yy173 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } -#line 5591 "sql.c" +{ yymsp[-1].minor.yy999 = taosStr2Int8(yymsp[0].minor.yy0.z, NULL, 10); } +#line 5648 "sql.c" break; case 38: /* cmd ::= GRANT privileges ON priv_level with_opt TO user_name */ #line 117 "sql.y" -{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-5].minor.yy729, &yymsp[-3].minor.yy967, &yymsp[0].minor.yy659, yymsp[-2].minor.yy722); } -#line 5596 "sql.c" +{ pCxt->pRootNode = createGrantStmt(pCxt, yymsp[-5].minor.yy891, &yymsp[-3].minor.yy73, &yymsp[0].minor.yy585, yymsp[-2].minor.yy826); } +#line 5653 "sql.c" break; case 39: /* cmd ::= REVOKE privileges ON priv_level with_opt FROM user_name */ #line 118 "sql.y" -{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-5].minor.yy729, &yymsp[-3].minor.yy967, &yymsp[0].minor.yy659, yymsp[-2].minor.yy722); } -#line 5601 "sql.c" +{ pCxt->pRootNode = createRevokeStmt(pCxt, yymsp[-5].minor.yy891, &yymsp[-3].minor.yy73, &yymsp[0].minor.yy585, yymsp[-2].minor.yy826); } +#line 5658 "sql.c" break; case 40: /* privileges ::= ALL */ #line 122 "sql.y" -{ yymsp[0].minor.yy729 = PRIVILEGE_TYPE_ALL; } -#line 5606 "sql.c" +{ yymsp[0].minor.yy891 = PRIVILEGE_TYPE_ALL; } +#line 5663 "sql.c" break; case 41: /* privileges ::= priv_type_list */ case 43: /* priv_type_list ::= priv_type */ yytestcase(yyruleno==43); #line 123 "sql.y" -{ yylhsminor.yy729 = yymsp[0].minor.yy729; } -#line 5612 "sql.c" - yymsp[0].minor.yy729 = yylhsminor.yy729; +{ yylhsminor.yy891 = yymsp[0].minor.yy891; } +#line 5669 "sql.c" + yymsp[0].minor.yy891 = yylhsminor.yy891; break; case 42: /* privileges ::= SUBSCRIBE */ #line 124 "sql.y" -{ yymsp[0].minor.yy729 = PRIVILEGE_TYPE_SUBSCRIBE; } -#line 5618 "sql.c" +{ yymsp[0].minor.yy891 = PRIVILEGE_TYPE_SUBSCRIBE; } +#line 5675 "sql.c" break; case 44: /* priv_type_list ::= priv_type_list NK_COMMA priv_type */ #line 129 "sql.y" -{ yylhsminor.yy729 = yymsp[-2].minor.yy729 | yymsp[0].minor.yy729; } -#line 5623 "sql.c" - yymsp[-2].minor.yy729 = yylhsminor.yy729; +{ yylhsminor.yy891 = yymsp[-2].minor.yy891 | yymsp[0].minor.yy891; } +#line 5680 "sql.c" + yymsp[-2].minor.yy891 = yylhsminor.yy891; break; case 45: /* priv_type ::= READ */ #line 133 "sql.y" -{ yymsp[0].minor.yy729 = PRIVILEGE_TYPE_READ; } -#line 5629 "sql.c" +{ yymsp[0].minor.yy891 = PRIVILEGE_TYPE_READ; } +#line 5686 "sql.c" break; case 46: /* priv_type ::= WRITE */ #line 134 "sql.y" -{ yymsp[0].minor.yy729 = PRIVILEGE_TYPE_WRITE; } -#line 5634 "sql.c" +{ yymsp[0].minor.yy891 = PRIVILEGE_TYPE_WRITE; } +#line 5691 "sql.c" break; case 47: /* priv_type ::= ALTER */ #line 135 "sql.y" -{ yymsp[0].minor.yy729 = PRIVILEGE_TYPE_ALTER; } -#line 5639 "sql.c" +{ yymsp[0].minor.yy891 = PRIVILEGE_TYPE_ALTER; } +#line 5696 "sql.c" break; case 48: /* priv_level ::= NK_STAR NK_DOT NK_STAR */ #line 139 "sql.y" -{ yylhsminor.yy967.first = yymsp[-2].minor.yy0; yylhsminor.yy967.second = yymsp[0].minor.yy0; } -#line 5644 "sql.c" - yymsp[-2].minor.yy967 = yylhsminor.yy967; +{ yylhsminor.yy73.first = yymsp[-2].minor.yy0; yylhsminor.yy73.second = yymsp[0].minor.yy0; } +#line 5701 "sql.c" + yymsp[-2].minor.yy73 = yylhsminor.yy73; break; case 49: /* priv_level ::= db_name NK_DOT NK_STAR */ #line 140 "sql.y" -{ yylhsminor.yy967.first = yymsp[-2].minor.yy659; yylhsminor.yy967.second = yymsp[0].minor.yy0; } -#line 5650 "sql.c" - yymsp[-2].minor.yy967 = yylhsminor.yy967; +{ yylhsminor.yy73.first = yymsp[-2].minor.yy585; yylhsminor.yy73.second = yymsp[0].minor.yy0; } +#line 5707 "sql.c" + yymsp[-2].minor.yy73 = yylhsminor.yy73; break; case 50: /* priv_level ::= db_name NK_DOT table_name */ #line 141 "sql.y" -{ yylhsminor.yy967.first = yymsp[-2].minor.yy659; yylhsminor.yy967.second = yymsp[0].minor.yy659; } -#line 5656 "sql.c" - yymsp[-2].minor.yy967 = yylhsminor.yy967; +{ yylhsminor.yy73.first = yymsp[-2].minor.yy585; yylhsminor.yy73.second = yymsp[0].minor.yy585; } +#line 5713 "sql.c" + yymsp[-2].minor.yy73 = yylhsminor.yy73; break; case 51: /* priv_level ::= topic_name */ #line 142 "sql.y" -{ yylhsminor.yy967.first = yymsp[0].minor.yy659; yylhsminor.yy967.second = nil_token; } -#line 5662 "sql.c" - yymsp[0].minor.yy967 = yylhsminor.yy967; +{ yylhsminor.yy73.first = yymsp[0].minor.yy585; yylhsminor.yy73.second = nil_token; } +#line 5719 "sql.c" + yymsp[0].minor.yy73 = yylhsminor.yy73; break; case 52: /* with_opt ::= */ case 165: /* start_opt ::= */ yytestcase(yyruleno==165); case 169: /* end_opt ::= */ yytestcase(yyruleno==169); case 319: /* like_pattern_opt ::= */ yytestcase(yyruleno==319); - case 409: /* subtable_opt ::= */ yytestcase(yyruleno==409); - case 576: /* case_when_else_opt ::= */ yytestcase(yyruleno==576); - case 606: /* from_clause_opt ::= */ yytestcase(yyruleno==606); - case 633: /* join_on_clause_opt ::= */ yytestcase(yyruleno==633); - case 635: /* window_offset_clause_opt ::= */ yytestcase(yyruleno==635); - case 639: /* jlimit_clause_opt ::= */ yytestcase(yyruleno==639); - case 656: /* where_clause_opt ::= */ yytestcase(yyruleno==656); - case 665: /* twindow_clause_opt ::= */ yytestcase(yyruleno==665); - case 673: /* sliding_opt ::= */ yytestcase(yyruleno==673); - case 678: /* fill_opt ::= */ yytestcase(yyruleno==678); - case 692: /* having_clause_opt ::= */ yytestcase(yyruleno==692); - case 694: /* range_opt ::= */ yytestcase(yyruleno==694); - case 697: /* every_opt ::= */ yytestcase(yyruleno==697); - case 710: /* slimit_clause_opt ::= */ yytestcase(yyruleno==710); - case 714: /* limit_clause_opt ::= */ yytestcase(yyruleno==714); + case 416: /* subtable_opt ::= */ yytestcase(yyruleno==416); + case 584: /* case_when_else_opt ::= */ yytestcase(yyruleno==584); + case 614: /* from_clause_opt ::= */ yytestcase(yyruleno==614); + case 641: /* join_on_clause_opt ::= */ yytestcase(yyruleno==641); + case 643: /* window_offset_clause_opt ::= */ yytestcase(yyruleno==643); + case 647: /* jlimit_clause_opt ::= */ yytestcase(yyruleno==647); + case 664: /* where_clause_opt ::= */ yytestcase(yyruleno==664); + case 673: /* twindow_clause_opt ::= */ yytestcase(yyruleno==673); + case 681: /* sliding_opt ::= */ yytestcase(yyruleno==681); + case 686: /* fill_opt ::= */ yytestcase(yyruleno==686); + case 700: /* having_clause_opt ::= */ yytestcase(yyruleno==700); + case 702: /* range_opt ::= */ yytestcase(yyruleno==702); + case 705: /* every_opt ::= */ yytestcase(yyruleno==705); + case 718: /* slimit_clause_opt ::= */ yytestcase(yyruleno==718); + case 722: /* limit_clause_opt ::= */ yytestcase(yyruleno==722); #line 144 "sql.y" -{ yymsp[1].minor.yy722 = NULL; } -#line 5686 "sql.c" +{ yymsp[1].minor.yy826 = NULL; } +#line 5743 "sql.c" break; case 53: /* with_opt ::= WITH search_condition */ - case 607: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==607); - case 634: /* join_on_clause_opt ::= ON search_condition */ yytestcase(yyruleno==634); - case 657: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==657); - case 693: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==693); + case 615: /* from_clause_opt ::= FROM table_reference_list */ yytestcase(yyruleno==615); + case 642: /* join_on_clause_opt ::= ON search_condition */ yytestcase(yyruleno==642); + case 665: /* where_clause_opt ::= WHERE search_condition */ yytestcase(yyruleno==665); + case 701: /* having_clause_opt ::= HAVING search_condition */ yytestcase(yyruleno==701); #line 145 "sql.y" -{ yymsp[-1].minor.yy722 = yymsp[0].minor.yy722; } -#line 5695 "sql.c" +{ yymsp[-1].minor.yy826 = yymsp[0].minor.yy826; } +#line 5752 "sql.c" break; case 54: /* cmd ::= CREATE DNODE dnode_endpoint */ #line 148 "sql.y" -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy659, NULL); } -#line 5700 "sql.c" +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[0].minor.yy585, NULL); } +#line 5757 "sql.c" break; case 55: /* cmd ::= CREATE DNODE dnode_endpoint PORT NK_INTEGER */ #line 149 "sql.y" -{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy0); } -#line 5705 "sql.c" +{ pCxt->pRootNode = createCreateDnodeStmt(pCxt, &yymsp[-2].minor.yy585, &yymsp[0].minor.yy0); } +#line 5762 "sql.c" break; case 56: /* cmd ::= DROP DNODE NK_INTEGER force_opt */ #line 150 "sql.y" -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy897, false); } -#line 5710 "sql.c" +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy983, false); } +#line 5767 "sql.c" break; case 57: /* cmd ::= DROP DNODE dnode_endpoint force_opt */ #line 151 "sql.y" -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy659, yymsp[0].minor.yy897, false); } -#line 5715 "sql.c" +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy585, yymsp[0].minor.yy983, false); } +#line 5772 "sql.c" break; case 58: /* cmd ::= DROP DNODE NK_INTEGER unsafe_opt */ #line 152 "sql.y" -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, false, yymsp[0].minor.yy897); } -#line 5720 "sql.c" +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy0, false, yymsp[0].minor.yy983); } +#line 5777 "sql.c" break; case 59: /* cmd ::= DROP DNODE dnode_endpoint unsafe_opt */ #line 153 "sql.y" -{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy659, false, yymsp[0].minor.yy897); } -#line 5725 "sql.c" +{ pCxt->pRootNode = createDropDnodeStmt(pCxt, &yymsp[-1].minor.yy585, false, yymsp[0].minor.yy983); } +#line 5782 "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 5730 "sql.c" +#line 5787 "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 5735 "sql.c" +#line 5792 "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 5740 "sql.c" +#line 5797 "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 5745 "sql.c" +#line 5802 "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 5750 "sql.c" +#line 5807 "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 346: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==346); - case 347: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==347); - case 348: /* sma_func_name ::= LAST */ yytestcase(yyruleno==348); - case 349: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==349); - case 496: /* db_name ::= NK_ID */ yytestcase(yyruleno==496); - case 497: /* table_name ::= NK_ID */ yytestcase(yyruleno==497); - case 498: /* column_name ::= NK_ID */ yytestcase(yyruleno==498); - case 499: /* function_name ::= NK_ID */ yytestcase(yyruleno==499); - case 500: /* view_name ::= NK_ID */ yytestcase(yyruleno==500); - case 501: /* table_alias ::= NK_ID */ yytestcase(yyruleno==501); - case 502: /* column_alias ::= NK_ID */ yytestcase(yyruleno==502); - case 503: /* column_alias ::= NK_ALIAS */ yytestcase(yyruleno==503); - case 504: /* user_name ::= NK_ID */ yytestcase(yyruleno==504); - case 505: /* topic_name ::= NK_ID */ yytestcase(yyruleno==505); - case 506: /* stream_name ::= NK_ID */ yytestcase(yyruleno==506); - case 507: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==507); - case 508: /* index_name ::= NK_ID */ yytestcase(yyruleno==508); - case 552: /* noarg_func ::= NOW */ yytestcase(yyruleno==552); - case 553: /* noarg_func ::= TODAY */ yytestcase(yyruleno==553); - case 554: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==554); - case 555: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==555); - case 556: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==556); - case 557: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==557); - case 558: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==558); - case 559: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==559); - case 560: /* noarg_func ::= USER */ yytestcase(yyruleno==560); - case 561: /* star_func ::= COUNT */ yytestcase(yyruleno==561); - case 562: /* star_func ::= FIRST */ yytestcase(yyruleno==562); - case 563: /* star_func ::= LAST */ yytestcase(yyruleno==563); - case 564: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==564); + case 353: /* sma_func_name ::= COUNT */ yytestcase(yyruleno==353); + case 354: /* sma_func_name ::= FIRST */ yytestcase(yyruleno==354); + case 355: /* sma_func_name ::= LAST */ yytestcase(yyruleno==355); + case 356: /* sma_func_name ::= LAST_ROW */ yytestcase(yyruleno==356); + case 503: /* db_name ::= NK_ID */ yytestcase(yyruleno==503); + case 504: /* table_name ::= NK_ID */ yytestcase(yyruleno==504); + case 505: /* column_name ::= NK_ID */ yytestcase(yyruleno==505); + case 506: /* function_name ::= NK_ID */ yytestcase(yyruleno==506); + case 507: /* view_name ::= NK_ID */ yytestcase(yyruleno==507); + case 508: /* table_alias ::= NK_ID */ yytestcase(yyruleno==508); + case 509: /* column_alias ::= NK_ID */ yytestcase(yyruleno==509); + case 510: /* column_alias ::= NK_ALIAS */ yytestcase(yyruleno==510); + case 511: /* user_name ::= NK_ID */ yytestcase(yyruleno==511); + case 512: /* topic_name ::= NK_ID */ yytestcase(yyruleno==512); + case 513: /* stream_name ::= NK_ID */ yytestcase(yyruleno==513); + case 514: /* cgroup_name ::= NK_ID */ yytestcase(yyruleno==514); + case 515: /* index_name ::= NK_ID */ yytestcase(yyruleno==515); + case 516: /* tsma_name ::= NK_ID */ yytestcase(yyruleno==516); + case 560: /* noarg_func ::= NOW */ yytestcase(yyruleno==560); + case 561: /* noarg_func ::= TODAY */ yytestcase(yyruleno==561); + case 562: /* noarg_func ::= TIMEZONE */ yytestcase(yyruleno==562); + case 563: /* noarg_func ::= DATABASE */ yytestcase(yyruleno==563); + case 564: /* noarg_func ::= CLIENT_VERSION */ yytestcase(yyruleno==564); + case 565: /* noarg_func ::= SERVER_VERSION */ yytestcase(yyruleno==565); + case 566: /* noarg_func ::= SERVER_STATUS */ yytestcase(yyruleno==566); + case 567: /* noarg_func ::= CURRENT_USER */ yytestcase(yyruleno==567); + case 568: /* noarg_func ::= USER */ yytestcase(yyruleno==568); + case 569: /* star_func ::= COUNT */ yytestcase(yyruleno==569); + case 570: /* star_func ::= FIRST */ yytestcase(yyruleno==570); + case 571: /* star_func ::= LAST */ yytestcase(yyruleno==571); + case 572: /* star_func ::= LAST_ROW */ yytestcase(yyruleno==572); #line 162 "sql.y" -{ yylhsminor.yy659 = yymsp[0].minor.yy0; } -#line 5787 "sql.c" - yymsp[0].minor.yy659 = yylhsminor.yy659; +{ yylhsminor.yy585 = yymsp[0].minor.yy0; } +#line 5845 "sql.c" + yymsp[0].minor.yy585 = yylhsminor.yy585; break; case 68: /* force_opt ::= */ case 95: /* not_exists_opt ::= */ yytestcase(yyruleno==95); case 97: /* exists_opt ::= */ yytestcase(yyruleno==97); - case 367: /* analyze_opt ::= */ yytestcase(yyruleno==367); - case 374: /* agg_func_opt ::= */ yytestcase(yyruleno==374); - case 380: /* or_replace_opt ::= */ yytestcase(yyruleno==380); - case 411: /* ignore_opt ::= */ yytestcase(yyruleno==411); - case 644: /* tag_mode_opt ::= */ yytestcase(yyruleno==644); - case 646: /* set_quantifier_opt ::= */ yytestcase(yyruleno==646); + case 374: /* analyze_opt ::= */ yytestcase(yyruleno==374); + case 381: /* agg_func_opt ::= */ yytestcase(yyruleno==381); + case 387: /* or_replace_opt ::= */ yytestcase(yyruleno==387); + case 418: /* ignore_opt ::= */ yytestcase(yyruleno==418); + case 652: /* tag_mode_opt ::= */ yytestcase(yyruleno==652); + case 654: /* set_quantifier_opt ::= */ yytestcase(yyruleno==654); #line 168 "sql.y" -{ yymsp[1].minor.yy897 = false; } -#line 5801 "sql.c" +{ yymsp[1].minor.yy983 = false; } +#line 5859 "sql.c" break; case 69: /* force_opt ::= FORCE */ case 70: /* unsafe_opt ::= UNSAFE */ yytestcase(yyruleno==70); - case 368: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==368); - case 375: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==375); - case 645: /* tag_mode_opt ::= TAGS */ yytestcase(yyruleno==645); - case 647: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==647); + case 375: /* analyze_opt ::= ANALYZE */ yytestcase(yyruleno==375); + case 382: /* agg_func_opt ::= AGGREGATE */ yytestcase(yyruleno==382); + case 653: /* tag_mode_opt ::= TAGS */ yytestcase(yyruleno==653); + case 655: /* set_quantifier_opt ::= DISTINCT */ yytestcase(yyruleno==655); #line 169 "sql.y" -{ yymsp[0].minor.yy897 = true; } -#line 5811 "sql.c" +{ yymsp[0].minor.yy983 = true; } +#line 5869 "sql.c" break; case 71: /* cmd ::= ALTER CLUSTER NK_STRING */ #line 176 "sql.y" { pCxt->pRootNode = createAlterClusterStmt(pCxt, &yymsp[0].minor.yy0, NULL); } -#line 5816 "sql.c" +#line 5874 "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 5821 "sql.c" +#line 5879 "sql.c" break; case 73: /* cmd ::= ALTER LOCAL NK_STRING */ #line 180 "sql.y" { pCxt->pRootNode = createAlterLocalStmt(pCxt, &yymsp[0].minor.yy0, NULL); } -#line 5826 "sql.c" +#line 5884 "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 5831 "sql.c" +#line 5889 "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 5836 "sql.c" +#line 5894 "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 5841 "sql.c" +#line 5899 "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 5846 "sql.c" +#line 5904 "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 5851 "sql.c" +#line 5909 "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 5856 "sql.c" +#line 5914 "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 5861 "sql.c" +#line 5919 "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 5866 "sql.c" +#line 5924 "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 5871 "sql.c" +#line 5929 "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 5876 "sql.c" +#line 5934 "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 5881 "sql.c" +#line 5939 "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 5886 "sql.c" +#line 5944 "sql.c" break; case 86: /* cmd ::= CREATE DATABASE not_exists_opt db_name db_options */ #line 205 "sql.y" -{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy897, &yymsp[-1].minor.yy659, yymsp[0].minor.yy722); } -#line 5891 "sql.c" +{ pCxt->pRootNode = createCreateDatabaseStmt(pCxt, yymsp[-2].minor.yy983, &yymsp[-1].minor.yy585, yymsp[0].minor.yy826); } +#line 5949 "sql.c" break; case 87: /* cmd ::= DROP DATABASE exists_opt db_name */ #line 206 "sql.y" -{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy897, &yymsp[0].minor.yy659); } -#line 5896 "sql.c" +{ pCxt->pRootNode = createDropDatabaseStmt(pCxt, yymsp[-1].minor.yy983, &yymsp[0].minor.yy585); } +#line 5954 "sql.c" break; case 88: /* cmd ::= USE db_name */ #line 207 "sql.y" -{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy659); } -#line 5901 "sql.c" +{ pCxt->pRootNode = createUseDatabaseStmt(pCxt, &yymsp[0].minor.yy585); } +#line 5959 "sql.c" break; case 89: /* cmd ::= ALTER DATABASE db_name alter_db_options */ #line 208 "sql.y" -{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy659, yymsp[0].minor.yy722); } -#line 5906 "sql.c" +{ pCxt->pRootNode = createAlterDatabaseStmt(pCxt, &yymsp[-1].minor.yy585, yymsp[0].minor.yy826); } +#line 5964 "sql.c" break; case 90: /* cmd ::= FLUSH DATABASE db_name */ #line 209 "sql.y" -{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy659); } -#line 5911 "sql.c" +{ pCxt->pRootNode = createFlushDatabaseStmt(pCxt, &yymsp[0].minor.yy585); } +#line 5969 "sql.c" break; case 91: /* cmd ::= TRIM DATABASE db_name speed_opt */ #line 210 "sql.y" -{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy659, yymsp[0].minor.yy830); } -#line 5916 "sql.c" +{ pCxt->pRootNode = createTrimDatabaseStmt(pCxt, &yymsp[-1].minor.yy585, yymsp[0].minor.yy462); } +#line 5974 "sql.c" break; case 92: /* cmd ::= S3MIGRATE DATABASE db_name */ #line 211 "sql.y" -{ pCxt->pRootNode = createS3MigrateDatabaseStmt(pCxt, &yymsp[0].minor.yy659); } -#line 5921 "sql.c" +{ pCxt->pRootNode = createS3MigrateDatabaseStmt(pCxt, &yymsp[0].minor.yy585); } +#line 5979 "sql.c" break; case 93: /* cmd ::= COMPACT DATABASE db_name start_opt end_opt */ #line 212 "sql.y" -{ pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy659, yymsp[-1].minor.yy722, yymsp[0].minor.yy722); } -#line 5926 "sql.c" +{ pCxt->pRootNode = createCompactStmt(pCxt, &yymsp[-2].minor.yy585, yymsp[-1].minor.yy826, yymsp[0].minor.yy826); } +#line 5984 "sql.c" break; case 94: /* not_exists_opt ::= IF NOT EXISTS */ #line 216 "sql.y" -{ yymsp[-2].minor.yy897 = true; } -#line 5931 "sql.c" +{ yymsp[-2].minor.yy983 = true; } +#line 5989 "sql.c" break; case 96: /* exists_opt ::= IF EXISTS */ - case 381: /* or_replace_opt ::= OR REPLACE */ yytestcase(yyruleno==381); - case 412: /* ignore_opt ::= IGNORE UNTREATED */ yytestcase(yyruleno==412); + case 388: /* or_replace_opt ::= OR REPLACE */ yytestcase(yyruleno==388); + case 419: /* ignore_opt ::= IGNORE UNTREATED */ yytestcase(yyruleno==419); #line 221 "sql.y" -{ yymsp[-1].minor.yy897 = true; } -#line 5938 "sql.c" +{ yymsp[-1].minor.yy983 = true; } +#line 5996 "sql.c" break; case 98: /* db_options ::= */ #line 224 "sql.y" -{ yymsp[1].minor.yy722 = createDefaultDatabaseOptions(pCxt); } -#line 5943 "sql.c" +{ yymsp[1].minor.yy826 = createDefaultDatabaseOptions(pCxt); } +#line 6001 "sql.c" break; case 99: /* db_options ::= db_options BUFFER NK_INTEGER */ #line 225 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } -#line 5948 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_BUFFER, &yymsp[0].minor.yy0); } +#line 6006 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 100: /* db_options ::= db_options CACHEMODEL NK_STRING */ #line 226 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } -#line 5954 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_CACHEMODEL, &yymsp[0].minor.yy0); } +#line 6012 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 101: /* db_options ::= db_options CACHESIZE NK_INTEGER */ #line 227 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } -#line 5960 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_CACHESIZE, &yymsp[0].minor.yy0); } +#line 6018 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 102: /* db_options ::= db_options COMP NK_INTEGER */ #line 228 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_COMP, &yymsp[0].minor.yy0); } -#line 5966 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_COMP, &yymsp[0].minor.yy0); } +#line 6024 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 103: /* db_options ::= db_options DURATION NK_INTEGER */ case 104: /* db_options ::= db_options DURATION NK_VARIABLE */ yytestcase(yyruleno==104); #line 229 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } -#line 5973 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_DAYS, &yymsp[0].minor.yy0); } +#line 6031 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 105: /* db_options ::= db_options MAXROWS NK_INTEGER */ #line 231 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } -#line 5979 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_MAXROWS, &yymsp[0].minor.yy0); } +#line 6037 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 106: /* db_options ::= db_options MINROWS NK_INTEGER */ #line 232 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } -#line 5985 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_MINROWS, &yymsp[0].minor.yy0); } +#line 6043 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 107: /* db_options ::= db_options KEEP integer_list */ case 108: /* db_options ::= db_options KEEP variable_list */ yytestcase(yyruleno==108); #line 233 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_KEEP, yymsp[0].minor.yy694); } -#line 5992 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_KEEP, yymsp[0].minor.yy616); } +#line 6050 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 109: /* db_options ::= db_options PAGES NK_INTEGER */ #line 235 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } -#line 5998 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_PAGES, &yymsp[0].minor.yy0); } +#line 6056 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 110: /* db_options ::= db_options PAGESIZE NK_INTEGER */ #line 236 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } -#line 6004 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_PAGESIZE, &yymsp[0].minor.yy0); } +#line 6062 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 111: /* db_options ::= db_options TSDB_PAGESIZE NK_INTEGER */ #line 237 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } -#line 6010 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_TSDB_PAGESIZE, &yymsp[0].minor.yy0); } +#line 6068 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 112: /* db_options ::= db_options PRECISION NK_STRING */ #line 238 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } -#line 6016 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_PRECISION, &yymsp[0].minor.yy0); } +#line 6074 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 113: /* db_options ::= db_options REPLICA NK_INTEGER */ #line 239 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } -#line 6022 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_REPLICA, &yymsp[0].minor.yy0); } +#line 6080 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 114: /* db_options ::= db_options VGROUPS NK_INTEGER */ #line 241 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } -#line 6028 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_VGROUPS, &yymsp[0].minor.yy0); } +#line 6086 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 115: /* db_options ::= db_options SINGLE_STABLE NK_INTEGER */ #line 242 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } -#line 6034 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_SINGLE_STABLE, &yymsp[0].minor.yy0); } +#line 6092 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 116: /* db_options ::= db_options RETENTIONS retention_list */ #line 243 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_RETENTIONS, yymsp[0].minor.yy694); } -#line 6040 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_RETENTIONS, yymsp[0].minor.yy616); } +#line 6098 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 117: /* db_options ::= db_options SCHEMALESS NK_INTEGER */ #line 244 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } -#line 6046 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_SCHEMALESS, &yymsp[0].minor.yy0); } +#line 6104 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 118: /* db_options ::= db_options WAL_LEVEL NK_INTEGER */ #line 245 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_WAL, &yymsp[0].minor.yy0); } -#line 6052 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_WAL, &yymsp[0].minor.yy0); } +#line 6110 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 119: /* db_options ::= db_options WAL_FSYNC_PERIOD NK_INTEGER */ #line 246 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } -#line 6058 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_FSYNC, &yymsp[0].minor.yy0); } +#line 6116 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 120: /* db_options ::= db_options WAL_RETENTION_PERIOD NK_INTEGER */ #line 247 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } -#line 6064 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_WAL_RETENTION_PERIOD, &yymsp[0].minor.yy0); } +#line 6122 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; 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.yy722 = setDatabaseOption(pCxt, yymsp[-3].minor.yy722, DB_OPTION_WAL_RETENTION_PERIOD, &t); + yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-3].minor.yy826, DB_OPTION_WAL_RETENTION_PERIOD, &t); } -#line 6074 "sql.c" - yymsp[-3].minor.yy722 = yylhsminor.yy722; +#line 6132 "sql.c" + yymsp[-3].minor.yy826 = yylhsminor.yy826; break; case 122: /* db_options ::= db_options WAL_RETENTION_SIZE NK_INTEGER */ #line 253 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } -#line 6080 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_WAL_RETENTION_SIZE, &yymsp[0].minor.yy0); } +#line 6138 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; 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.yy722 = setDatabaseOption(pCxt, yymsp[-3].minor.yy722, DB_OPTION_WAL_RETENTION_SIZE, &t); + yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-3].minor.yy826, DB_OPTION_WAL_RETENTION_SIZE, &t); } -#line 6090 "sql.c" - yymsp[-3].minor.yy722 = yylhsminor.yy722; +#line 6148 "sql.c" + yymsp[-3].minor.yy826 = yylhsminor.yy826; break; case 124: /* db_options ::= db_options WAL_ROLL_PERIOD NK_INTEGER */ #line 259 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } -#line 6096 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_WAL_ROLL_PERIOD, &yymsp[0].minor.yy0); } +#line 6154 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 125: /* db_options ::= db_options WAL_SEGMENT_SIZE NK_INTEGER */ #line 260 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } -#line 6102 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_WAL_SEGMENT_SIZE, &yymsp[0].minor.yy0); } +#line 6160 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 126: /* db_options ::= db_options STT_TRIGGER NK_INTEGER */ #line 261 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } -#line 6108 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_STT_TRIGGER, &yymsp[0].minor.yy0); } +#line 6166 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 127: /* db_options ::= db_options TABLE_PREFIX signed */ #line 262 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_TABLE_PREFIX, yymsp[0].minor.yy722); } -#line 6114 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_TABLE_PREFIX, yymsp[0].minor.yy826); } +#line 6172 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 128: /* db_options ::= db_options TABLE_SUFFIX signed */ #line 263 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_TABLE_SUFFIX, yymsp[0].minor.yy722); } -#line 6120 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_TABLE_SUFFIX, yymsp[0].minor.yy826); } +#line 6178 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 129: /* db_options ::= db_options S3_CHUNKSIZE NK_INTEGER */ #line 264 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_S3_CHUNKSIZE, &yymsp[0].minor.yy0); } -#line 6126 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_S3_CHUNKSIZE, &yymsp[0].minor.yy0); } +#line 6184 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 130: /* db_options ::= db_options S3_KEEPLOCAL NK_INTEGER */ case 131: /* db_options ::= db_options S3_KEEPLOCAL NK_VARIABLE */ yytestcase(yyruleno==131); #line 265 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_S3_KEEPLOCAL, &yymsp[0].minor.yy0); } -#line 6133 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_S3_KEEPLOCAL, &yymsp[0].minor.yy0); } +#line 6191 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 132: /* db_options ::= db_options S3_COMPACT NK_INTEGER */ #line 267 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_S3_COMPACT, &yymsp[0].minor.yy0); } -#line 6139 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_S3_COMPACT, &yymsp[0].minor.yy0); } +#line 6197 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 133: /* db_options ::= db_options KEEP_TIME_OFFSET NK_INTEGER */ #line 268 "sql.y" -{ yylhsminor.yy722 = setDatabaseOption(pCxt, yymsp[-2].minor.yy722, DB_OPTION_KEEP_TIME_OFFSET, &yymsp[0].minor.yy0); } -#line 6145 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setDatabaseOption(pCxt, yymsp[-2].minor.yy826, DB_OPTION_KEEP_TIME_OFFSET, &yymsp[0].minor.yy0); } +#line 6203 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 134: /* alter_db_options ::= alter_db_option */ #line 270 "sql.y" -{ yylhsminor.yy722 = createAlterDatabaseOptions(pCxt); yylhsminor.yy722 = setAlterDatabaseOption(pCxt, yylhsminor.yy722, &yymsp[0].minor.yy845); } -#line 6151 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createAlterDatabaseOptions(pCxt); yylhsminor.yy826 = setAlterDatabaseOption(pCxt, yylhsminor.yy826, &yymsp[0].minor.yy177); } +#line 6209 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; break; case 135: /* alter_db_options ::= alter_db_options alter_db_option */ #line 271 "sql.y" -{ yylhsminor.yy722 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy722, &yymsp[0].minor.yy845); } -#line 6157 "sql.c" - yymsp[-1].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setAlterDatabaseOption(pCxt, yymsp[-1].minor.yy826, &yymsp[0].minor.yy177); } +#line 6215 "sql.c" + yymsp[-1].minor.yy826 = yylhsminor.yy826; break; case 136: /* alter_db_option ::= BUFFER NK_INTEGER */ #line 275 "sql.y" -{ yymsp[-1].minor.yy845.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } -#line 6163 "sql.c" +{ yymsp[-1].minor.yy177.type = DB_OPTION_BUFFER; yymsp[-1].minor.yy177.val = yymsp[0].minor.yy0; } +#line 6221 "sql.c" break; case 137: /* alter_db_option ::= CACHEMODEL NK_STRING */ #line 276 "sql.y" -{ yymsp[-1].minor.yy845.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } -#line 6168 "sql.c" +{ yymsp[-1].minor.yy177.type = DB_OPTION_CACHEMODEL; yymsp[-1].minor.yy177.val = yymsp[0].minor.yy0; } +#line 6226 "sql.c" break; case 138: /* alter_db_option ::= CACHESIZE NK_INTEGER */ #line 277 "sql.y" -{ yymsp[-1].minor.yy845.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } -#line 6173 "sql.c" +{ yymsp[-1].minor.yy177.type = DB_OPTION_CACHESIZE; yymsp[-1].minor.yy177.val = yymsp[0].minor.yy0; } +#line 6231 "sql.c" break; case 139: /* alter_db_option ::= WAL_FSYNC_PERIOD NK_INTEGER */ #line 278 "sql.y" -{ yymsp[-1].minor.yy845.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } -#line 6178 "sql.c" +{ yymsp[-1].minor.yy177.type = DB_OPTION_FSYNC; yymsp[-1].minor.yy177.val = yymsp[0].minor.yy0; } +#line 6236 "sql.c" break; case 140: /* alter_db_option ::= KEEP integer_list */ case 141: /* alter_db_option ::= KEEP variable_list */ yytestcase(yyruleno==141); #line 279 "sql.y" -{ yymsp[-1].minor.yy845.type = DB_OPTION_KEEP; yymsp[-1].minor.yy845.pList = yymsp[0].minor.yy694; } -#line 6184 "sql.c" +{ yymsp[-1].minor.yy177.type = DB_OPTION_KEEP; yymsp[-1].minor.yy177.pList = yymsp[0].minor.yy616; } +#line 6242 "sql.c" break; case 142: /* alter_db_option ::= PAGES NK_INTEGER */ #line 281 "sql.y" -{ yymsp[-1].minor.yy845.type = DB_OPTION_PAGES; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } -#line 6189 "sql.c" +{ yymsp[-1].minor.yy177.type = DB_OPTION_PAGES; yymsp[-1].minor.yy177.val = yymsp[0].minor.yy0; } +#line 6247 "sql.c" break; case 143: /* alter_db_option ::= REPLICA NK_INTEGER */ #line 282 "sql.y" -{ yymsp[-1].minor.yy845.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } -#line 6194 "sql.c" +{ yymsp[-1].minor.yy177.type = DB_OPTION_REPLICA; yymsp[-1].minor.yy177.val = yymsp[0].minor.yy0; } +#line 6252 "sql.c" break; case 144: /* alter_db_option ::= WAL_LEVEL NK_INTEGER */ #line 284 "sql.y" -{ yymsp[-1].minor.yy845.type = DB_OPTION_WAL; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } -#line 6199 "sql.c" +{ yymsp[-1].minor.yy177.type = DB_OPTION_WAL; yymsp[-1].minor.yy177.val = yymsp[0].minor.yy0; } +#line 6257 "sql.c" break; case 145: /* alter_db_option ::= STT_TRIGGER NK_INTEGER */ #line 285 "sql.y" -{ yymsp[-1].minor.yy845.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } -#line 6204 "sql.c" +{ yymsp[-1].minor.yy177.type = DB_OPTION_STT_TRIGGER; yymsp[-1].minor.yy177.val = yymsp[0].minor.yy0; } +#line 6262 "sql.c" break; case 146: /* alter_db_option ::= MINROWS NK_INTEGER */ #line 286 "sql.y" -{ yymsp[-1].minor.yy845.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } -#line 6209 "sql.c" +{ yymsp[-1].minor.yy177.type = DB_OPTION_MINROWS; yymsp[-1].minor.yy177.val = yymsp[0].minor.yy0; } +#line 6267 "sql.c" break; case 147: /* alter_db_option ::= WAL_RETENTION_PERIOD NK_INTEGER */ #line 287 "sql.y" -{ yymsp[-1].minor.yy845.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } -#line 6214 "sql.c" +{ yymsp[-1].minor.yy177.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-1].minor.yy177.val = yymsp[0].minor.yy0; } +#line 6272 "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.yy845.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-2].minor.yy845.val = t; + yymsp[-2].minor.yy177.type = DB_OPTION_WAL_RETENTION_PERIOD; yymsp[-2].minor.yy177.val = t; } -#line 6223 "sql.c" +#line 6281 "sql.c" break; case 149: /* alter_db_option ::= WAL_RETENTION_SIZE NK_INTEGER */ #line 293 "sql.y" -{ yymsp[-1].minor.yy845.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } -#line 6228 "sql.c" +{ yymsp[-1].minor.yy177.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-1].minor.yy177.val = yymsp[0].minor.yy0; } +#line 6286 "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.yy845.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-2].minor.yy845.val = t; + yymsp[-2].minor.yy177.type = DB_OPTION_WAL_RETENTION_SIZE; yymsp[-2].minor.yy177.val = t; } -#line 6237 "sql.c" +#line 6295 "sql.c" break; case 151: /* alter_db_option ::= S3_KEEPLOCAL NK_INTEGER */ case 152: /* alter_db_option ::= S3_KEEPLOCAL NK_VARIABLE */ yytestcase(yyruleno==152); #line 299 "sql.y" -{ yymsp[-1].minor.yy845.type = DB_OPTION_S3_KEEPLOCAL; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } -#line 6243 "sql.c" +{ yymsp[-1].minor.yy177.type = DB_OPTION_S3_KEEPLOCAL; yymsp[-1].minor.yy177.val = yymsp[0].minor.yy0; } +#line 6301 "sql.c" break; case 153: /* alter_db_option ::= S3_COMPACT NK_INTEGER */ #line 301 "sql.y" -{ yymsp[-1].minor.yy845.type = DB_OPTION_S3_COMPACT, yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } -#line 6248 "sql.c" +{ yymsp[-1].minor.yy177.type = DB_OPTION_S3_COMPACT, yymsp[-1].minor.yy177.val = yymsp[0].minor.yy0; } +#line 6306 "sql.c" break; case 154: /* alter_db_option ::= KEEP_TIME_OFFSET NK_INTEGER */ #line 302 "sql.y" -{ yymsp[-1].minor.yy845.type = DB_OPTION_KEEP_TIME_OFFSET; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } -#line 6253 "sql.c" +{ yymsp[-1].minor.yy177.type = DB_OPTION_KEEP_TIME_OFFSET; yymsp[-1].minor.yy177.val = yymsp[0].minor.yy0; } +#line 6311 "sql.c" break; case 155: /* integer_list ::= NK_INTEGER */ #line 306 "sql.y" -{ yylhsminor.yy694 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } -#line 6258 "sql.c" - yymsp[0].minor.yy694 = yylhsminor.yy694; +{ yylhsminor.yy616 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +#line 6316 "sql.c" + yymsp[0].minor.yy616 = yylhsminor.yy616; break; case 156: /* integer_list ::= integer_list NK_COMMA NK_INTEGER */ - case 425: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==425); + case 432: /* dnode_list ::= dnode_list DNODE NK_INTEGER */ yytestcase(yyruleno==432); #line 307 "sql.y" -{ yylhsminor.yy694 = addNodeToList(pCxt, yymsp[-2].minor.yy694, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } -#line 6265 "sql.c" - yymsp[-2].minor.yy694 = yylhsminor.yy694; +{ yylhsminor.yy616 = addNodeToList(pCxt, yymsp[-2].minor.yy616, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +#line 6323 "sql.c" + yymsp[-2].minor.yy616 = yylhsminor.yy616; break; case 157: /* variable_list ::= NK_VARIABLE */ #line 311 "sql.y" -{ yylhsminor.yy694 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 6271 "sql.c" - yymsp[0].minor.yy694 = yylhsminor.yy694; +{ yylhsminor.yy616 = createNodeList(pCxt, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 6329 "sql.c" + yymsp[0].minor.yy616 = yylhsminor.yy616; break; case 158: /* variable_list ::= variable_list NK_COMMA NK_VARIABLE */ #line 312 "sql.y" -{ yylhsminor.yy694 = addNodeToList(pCxt, yymsp[-2].minor.yy694, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 6277 "sql.c" - yymsp[-2].minor.yy694 = yylhsminor.yy694; +{ yylhsminor.yy616 = addNodeToList(pCxt, yymsp[-2].minor.yy616, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 6335 "sql.c" + yymsp[-2].minor.yy616 = yylhsminor.yy616; break; case 159: /* retention_list ::= retention */ case 191: /* multi_create_clause ::= create_subtable_clause */ yytestcase(yyruleno==191); @@ -6285,19 +6343,19 @@ static YYACTIONTYPE yy_reduce( case 252: /* rollup_func_list ::= rollup_func_name */ yytestcase(yyruleno==252); case 257: /* col_name_list ::= col_name */ yytestcase(yyruleno==257); case 325: /* tag_list_opt ::= tag_item */ yytestcase(yyruleno==325); - case 342: /* func_list ::= func */ yytestcase(yyruleno==342); - case 392: /* column_stream_def_list ::= column_stream_def */ yytestcase(yyruleno==392); - case 469: /* tags_literal_list ::= tags_literal */ yytestcase(yyruleno==469); - case 494: /* literal_list ::= signed_literal */ yytestcase(yyruleno==494); - case 567: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==567); - case 573: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==573); - case 649: /* select_list ::= select_item */ yytestcase(yyruleno==649); - case 660: /* partition_list ::= partition_item */ yytestcase(yyruleno==660); - case 721: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==721); + case 349: /* func_list ::= func */ yytestcase(yyruleno==349); + case 399: /* column_stream_def_list ::= column_stream_def */ yytestcase(yyruleno==399); + case 476: /* tags_literal_list ::= tags_literal */ yytestcase(yyruleno==476); + case 501: /* literal_list ::= signed_literal */ yytestcase(yyruleno==501); + case 575: /* other_para_list ::= star_func_para */ yytestcase(yyruleno==575); + case 581: /* when_then_list ::= when_then_expr */ yytestcase(yyruleno==581); + case 657: /* select_list ::= select_item */ yytestcase(yyruleno==657); + case 668: /* partition_list ::= partition_item */ yytestcase(yyruleno==668); + case 729: /* sort_specification_list ::= sort_specification */ yytestcase(yyruleno==729); #line 316 "sql.y" -{ yylhsminor.yy694 = createNodeList(pCxt, yymsp[0].minor.yy722); } -#line 6299 "sql.c" - yymsp[0].minor.yy694 = yylhsminor.yy694; +{ yylhsminor.yy616 = createNodeList(pCxt, yymsp[0].minor.yy826); } +#line 6357 "sql.c" + yymsp[0].minor.yy616 = yylhsminor.yy616; break; case 160: /* retention_list ::= retention_list NK_COMMA retention */ case 195: /* multi_drop_clause ::= multi_drop_clause NK_COMMA drop_table_clause */ yytestcase(yyruleno==195); @@ -6306,2168 +6364,2195 @@ static YYACTIONTYPE yy_reduce( case 253: /* rollup_func_list ::= rollup_func_list NK_COMMA rollup_func_name */ yytestcase(yyruleno==253); case 258: /* col_name_list ::= col_name_list NK_COMMA col_name */ yytestcase(yyruleno==258); case 326: /* tag_list_opt ::= tag_list_opt NK_COMMA tag_item */ yytestcase(yyruleno==326); - case 343: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==343); - case 393: /* column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def */ yytestcase(yyruleno==393); - case 470: /* tags_literal_list ::= tags_literal_list NK_COMMA tags_literal */ yytestcase(yyruleno==470); - case 495: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==495); - case 568: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==568); - case 650: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==650); - case 661: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==661); - case 722: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==722); + case 350: /* func_list ::= func_list NK_COMMA func */ yytestcase(yyruleno==350); + case 400: /* column_stream_def_list ::= column_stream_def_list NK_COMMA column_stream_def */ yytestcase(yyruleno==400); + case 477: /* tags_literal_list ::= tags_literal_list NK_COMMA tags_literal */ yytestcase(yyruleno==477); + case 502: /* literal_list ::= literal_list NK_COMMA signed_literal */ yytestcase(yyruleno==502); + case 576: /* other_para_list ::= other_para_list NK_COMMA star_func_para */ yytestcase(yyruleno==576); + case 658: /* select_list ::= select_list NK_COMMA select_item */ yytestcase(yyruleno==658); + case 669: /* partition_list ::= partition_list NK_COMMA partition_item */ yytestcase(yyruleno==669); + case 730: /* sort_specification_list ::= sort_specification_list NK_COMMA sort_specification */ yytestcase(yyruleno==730); #line 317 "sql.y" -{ yylhsminor.yy694 = addNodeToList(pCxt, yymsp[-2].minor.yy694, yymsp[0].minor.yy722); } -#line 6319 "sql.c" - yymsp[-2].minor.yy694 = yylhsminor.yy694; +{ yylhsminor.yy616 = addNodeToList(pCxt, yymsp[-2].minor.yy616, yymsp[0].minor.yy826); } +#line 6377 "sql.c" + yymsp[-2].minor.yy616 = yylhsminor.yy616; break; case 161: /* retention ::= NK_VARIABLE NK_COLON NK_VARIABLE */ case 162: /* retention ::= NK_MINUS NK_COLON NK_VARIABLE */ yytestcase(yyruleno==162); #line 319 "sql.y" -{ yylhsminor.yy722 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 6326 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createNodeListNodeEx(pCxt, createDurationValueNode(pCxt, &yymsp[-2].minor.yy0), createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 6384 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 163: /* speed_opt ::= */ - case 376: /* bufsize_opt ::= */ yytestcase(yyruleno==376); + case 383: /* bufsize_opt ::= */ yytestcase(yyruleno==383); #line 324 "sql.y" -{ yymsp[1].minor.yy830 = 0; } -#line 6333 "sql.c" +{ yymsp[1].minor.yy462 = 0; } +#line 6391 "sql.c" break; case 164: /* speed_opt ::= BWLIMIT NK_INTEGER */ - case 377: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==377); + case 384: /* bufsize_opt ::= BUFSIZE NK_INTEGER */ yytestcase(yyruleno==384); #line 325 "sql.y" -{ yymsp[-1].minor.yy830 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } -#line 6339 "sql.c" +{ yymsp[-1].minor.yy462 = taosStr2Int32(yymsp[0].minor.yy0.z, NULL, 10); } +#line 6397 "sql.c" break; case 166: /* start_opt ::= START WITH NK_INTEGER */ case 170: /* end_opt ::= END WITH NK_INTEGER */ yytestcase(yyruleno==170); #line 328 "sql.y" -{ yymsp[-2].minor.yy722 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } -#line 6345 "sql.c" +{ yymsp[-2].minor.yy826 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0); } +#line 6403 "sql.c" break; case 167: /* start_opt ::= START WITH NK_STRING */ case 171: /* end_opt ::= END WITH NK_STRING */ yytestcase(yyruleno==171); #line 329 "sql.y" -{ yymsp[-2].minor.yy722 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } -#line 6351 "sql.c" +{ yymsp[-2].minor.yy826 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +#line 6409 "sql.c" break; case 168: /* start_opt ::= START WITH TIMESTAMP NK_STRING */ case 172: /* end_opt ::= END WITH TIMESTAMP NK_STRING */ yytestcase(yyruleno==172); #line 330 "sql.y" -{ yymsp[-3].minor.yy722 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } -#line 6357 "sql.c" +{ yymsp[-3].minor.yy826 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +#line 6415 "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); #line 339 "sql.y" -{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy897, yymsp[-5].minor.yy722, yymsp[-3].minor.yy694, yymsp[-1].minor.yy694, yymsp[0].minor.yy722); } -#line 6363 "sql.c" +{ pCxt->pRootNode = createCreateTableStmt(pCxt, yymsp[-6].minor.yy983, yymsp[-5].minor.yy826, yymsp[-3].minor.yy616, yymsp[-1].minor.yy616, yymsp[0].minor.yy826); } +#line 6421 "sql.c" break; case 174: /* cmd ::= CREATE TABLE multi_create_clause */ #line 340 "sql.y" -{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy694); } -#line 6368 "sql.c" +{ pCxt->pRootNode = createCreateMultiTableStmt(pCxt, yymsp[0].minor.yy616); } +#line 6426 "sql.c" break; case 176: /* cmd ::= DROP TABLE multi_drop_clause */ #line 343 "sql.y" -{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy694); } -#line 6373 "sql.c" +{ pCxt->pRootNode = createDropTableStmt(pCxt, yymsp[0].minor.yy616); } +#line 6431 "sql.c" break; case 177: /* cmd ::= DROP STABLE exists_opt full_table_name */ #line 344 "sql.y" -{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy897, yymsp[0].minor.yy722); } -#line 6378 "sql.c" +{ pCxt->pRootNode = createDropSuperTableStmt(pCxt, yymsp[-1].minor.yy983, yymsp[0].minor.yy826); } +#line 6436 "sql.c" break; case 178: /* cmd ::= ALTER TABLE alter_table_clause */ - case 427: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==427); - case 428: /* cmd ::= insert_query */ yytestcase(yyruleno==428); + case 434: /* cmd ::= query_or_subquery */ yytestcase(yyruleno==434); + case 435: /* cmd ::= insert_query */ yytestcase(yyruleno==435); #line 346 "sql.y" -{ pCxt->pRootNode = yymsp[0].minor.yy722; } -#line 6385 "sql.c" +{ pCxt->pRootNode = yymsp[0].minor.yy826; } +#line 6443 "sql.c" break; case 179: /* cmd ::= ALTER STABLE alter_table_clause */ #line 347 "sql.y" -{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy722); } -#line 6390 "sql.c" +{ pCxt->pRootNode = setAlterSuperTableType(yymsp[0].minor.yy826); } +#line 6448 "sql.c" break; case 180: /* alter_table_clause ::= full_table_name alter_table_options */ #line 349 "sql.y" -{ yylhsminor.yy722 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy722, yymsp[0].minor.yy722); } -#line 6395 "sql.c" - yymsp[-1].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createAlterTableModifyOptions(pCxt, yymsp[-1].minor.yy826, yymsp[0].minor.yy826); } +#line 6453 "sql.c" + yymsp[-1].minor.yy826 = yylhsminor.yy826; break; case 181: /* alter_table_clause ::= full_table_name ADD COLUMN column_name type_name */ #line 351 "sql.y" -{ yylhsminor.yy722 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy722, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy659, yymsp[0].minor.yy154); } -#line 6401 "sql.c" - yymsp[-4].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy826, TSDB_ALTER_TABLE_ADD_COLUMN, &yymsp[-1].minor.yy585, yymsp[0].minor.yy146); } +#line 6459 "sql.c" + yymsp[-4].minor.yy826 = yylhsminor.yy826; break; case 182: /* alter_table_clause ::= full_table_name DROP COLUMN column_name */ #line 352 "sql.y" -{ yylhsminor.yy722 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy722, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy659); } -#line 6407 "sql.c" - yymsp[-3].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy826, TSDB_ALTER_TABLE_DROP_COLUMN, &yymsp[0].minor.yy585); } +#line 6465 "sql.c" + yymsp[-3].minor.yy826 = yylhsminor.yy826; break; case 183: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name type_name */ #line 354 "sql.y" -{ yylhsminor.yy722 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy722, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy659, yymsp[0].minor.yy154); } -#line 6413 "sql.c" - yymsp[-4].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy826, TSDB_ALTER_TABLE_UPDATE_COLUMN_BYTES, &yymsp[-1].minor.yy585, yymsp[0].minor.yy146); } +#line 6471 "sql.c" + yymsp[-4].minor.yy826 = yylhsminor.yy826; break; case 184: /* alter_table_clause ::= full_table_name MODIFY COLUMN column_name column_options */ #line 356 "sql.y" -{ yylhsminor.yy722 = createAlterTableAddModifyColOptions(pCxt, yymsp[-4].minor.yy722, TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS, &yymsp[-1].minor.yy659, yymsp[0].minor.yy722); } -#line 6419 "sql.c" - yymsp[-4].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createAlterTableAddModifyColOptions(pCxt, yymsp[-4].minor.yy826, TSDB_ALTER_TABLE_UPDATE_COLUMN_COMPRESS, &yymsp[-1].minor.yy585, yymsp[0].minor.yy826); } +#line 6477 "sql.c" + yymsp[-4].minor.yy826 = yylhsminor.yy826; break; case 185: /* alter_table_clause ::= full_table_name RENAME COLUMN column_name column_name */ #line 358 "sql.y" -{ yylhsminor.yy722 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy722, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy659, &yymsp[0].minor.yy659); } -#line 6425 "sql.c" - yymsp[-4].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy826, TSDB_ALTER_TABLE_UPDATE_COLUMN_NAME, &yymsp[-1].minor.yy585, &yymsp[0].minor.yy585); } +#line 6483 "sql.c" + yymsp[-4].minor.yy826 = yylhsminor.yy826; break; case 186: /* alter_table_clause ::= full_table_name ADD TAG column_name type_name */ #line 360 "sql.y" -{ yylhsminor.yy722 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy722, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy659, yymsp[0].minor.yy154); } -#line 6431 "sql.c" - yymsp[-4].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy826, TSDB_ALTER_TABLE_ADD_TAG, &yymsp[-1].minor.yy585, yymsp[0].minor.yy146); } +#line 6489 "sql.c" + yymsp[-4].minor.yy826 = yylhsminor.yy826; break; case 187: /* alter_table_clause ::= full_table_name DROP TAG column_name */ #line 361 "sql.y" -{ yylhsminor.yy722 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy722, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy659); } -#line 6437 "sql.c" - yymsp[-3].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createAlterTableDropCol(pCxt, yymsp[-3].minor.yy826, TSDB_ALTER_TABLE_DROP_TAG, &yymsp[0].minor.yy585); } +#line 6495 "sql.c" + yymsp[-3].minor.yy826 = yylhsminor.yy826; break; case 188: /* alter_table_clause ::= full_table_name MODIFY TAG column_name type_name */ #line 363 "sql.y" -{ yylhsminor.yy722 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy722, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy659, yymsp[0].minor.yy154); } -#line 6443 "sql.c" - yymsp[-4].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createAlterTableAddModifyCol(pCxt, yymsp[-4].minor.yy826, TSDB_ALTER_TABLE_UPDATE_TAG_BYTES, &yymsp[-1].minor.yy585, yymsp[0].minor.yy146); } +#line 6501 "sql.c" + yymsp[-4].minor.yy826 = yylhsminor.yy826; break; case 189: /* alter_table_clause ::= full_table_name RENAME TAG column_name column_name */ #line 365 "sql.y" -{ yylhsminor.yy722 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy722, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy659, &yymsp[0].minor.yy659); } -#line 6449 "sql.c" - yymsp[-4].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createAlterTableRenameCol(pCxt, yymsp[-4].minor.yy826, TSDB_ALTER_TABLE_UPDATE_TAG_NAME, &yymsp[-1].minor.yy585, &yymsp[0].minor.yy585); } +#line 6507 "sql.c" + yymsp[-4].minor.yy826 = yylhsminor.yy826; break; case 190: /* alter_table_clause ::= full_table_name SET TAG column_name NK_EQ tags_literal */ #line 367 "sql.y" -{ yylhsminor.yy722 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy722, &yymsp[-2].minor.yy659, yymsp[0].minor.yy722); } -#line 6455 "sql.c" - yymsp[-5].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createAlterTableSetTag(pCxt, yymsp[-5].minor.yy826, &yymsp[-2].minor.yy585, yymsp[0].minor.yy826); } +#line 6513 "sql.c" + yymsp[-5].minor.yy826 = yylhsminor.yy826; break; case 192: /* multi_create_clause ::= multi_create_clause create_subtable_clause */ - case 574: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==574); + case 582: /* when_then_list ::= when_then_list when_then_expr */ yytestcase(yyruleno==582); #line 372 "sql.y" -{ yylhsminor.yy694 = addNodeToList(pCxt, yymsp[-1].minor.yy694, yymsp[0].minor.yy722); } -#line 6462 "sql.c" - yymsp[-1].minor.yy694 = yylhsminor.yy694; +{ yylhsminor.yy616 = addNodeToList(pCxt, yymsp[-1].minor.yy616, yymsp[0].minor.yy826); } +#line 6520 "sql.c" + yymsp[-1].minor.yy616 = yylhsminor.yy616; break; case 193: /* 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 */ #line 376 "sql.y" -{ yylhsminor.yy722 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy897, yymsp[-8].minor.yy722, yymsp[-6].minor.yy722, yymsp[-5].minor.yy694, yymsp[-2].minor.yy694, yymsp[0].minor.yy722); } -#line 6468 "sql.c" - yymsp[-9].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createCreateSubTableClause(pCxt, yymsp[-9].minor.yy983, yymsp[-8].minor.yy826, yymsp[-6].minor.yy826, yymsp[-5].minor.yy616, yymsp[-2].minor.yy616, yymsp[0].minor.yy826); } +#line 6526 "sql.c" + yymsp[-9].minor.yy826 = yylhsminor.yy826; break; case 196: /* drop_table_clause ::= exists_opt full_table_name */ #line 383 "sql.y" -{ yylhsminor.yy722 = createDropTableClause(pCxt, yymsp[-1].minor.yy897, yymsp[0].minor.yy722); } -#line 6474 "sql.c" - yymsp[-1].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createDropTableClause(pCxt, yymsp[-1].minor.yy983, yymsp[0].minor.yy826); } +#line 6532 "sql.c" + yymsp[-1].minor.yy826 = yylhsminor.yy826; break; case 198: /* specific_cols_opt ::= NK_LP col_name_list NK_RP */ - case 391: /* col_list_opt ::= NK_LP column_stream_def_list NK_RP */ yytestcase(yyruleno==391); + case 398: /* col_list_opt ::= NK_LP column_stream_def_list NK_RP */ yytestcase(yyruleno==398); #line 388 "sql.y" -{ yymsp[-2].minor.yy694 = yymsp[-1].minor.yy694; } -#line 6481 "sql.c" +{ yymsp[-2].minor.yy616 = yymsp[-1].minor.yy616; } +#line 6539 "sql.c" break; case 199: /* full_table_name ::= table_name */ + case 339: /* full_tsma_name ::= tsma_name */ yytestcase(yyruleno==339); #line 390 "sql.y" -{ yylhsminor.yy722 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy659, NULL); } -#line 6486 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createRealTableNode(pCxt, NULL, &yymsp[0].minor.yy585, NULL); } +#line 6545 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; break; case 200: /* full_table_name ::= db_name NK_DOT table_name */ + case 340: /* full_tsma_name ::= db_name NK_DOT tsma_name */ yytestcase(yyruleno==340); #line 391 "sql.y" -{ yylhsminor.yy722 = createRealTableNode(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy659, NULL); } -#line 6492 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createRealTableNode(pCxt, &yymsp[-2].minor.yy585, &yymsp[0].minor.yy585, NULL); } +#line 6552 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 203: /* tag_def ::= column_name type_name */ #line 397 "sql.y" -{ yylhsminor.yy722 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy659, yymsp[0].minor.yy154, NULL); } -#line 6498 "sql.c" - yymsp[-1].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy585, yymsp[0].minor.yy146, NULL); } +#line 6558 "sql.c" + yymsp[-1].minor.yy826 = yylhsminor.yy826; break; case 206: /* column_def ::= column_name type_name column_options */ #line 405 "sql.y" -{ yylhsminor.yy722 = createColumnDefNode(pCxt, &yymsp[-2].minor.yy659, yymsp[-1].minor.yy154, yymsp[0].minor.yy722); } -#line 6504 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createColumnDefNode(pCxt, &yymsp[-2].minor.yy585, yymsp[-1].minor.yy146, yymsp[0].minor.yy826); } +#line 6564 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 207: /* type_name ::= BOOL */ #line 409 "sql.y" -{ yymsp[0].minor.yy154 = createDataType(TSDB_DATA_TYPE_BOOL); } -#line 6510 "sql.c" +{ yymsp[0].minor.yy146 = createDataType(TSDB_DATA_TYPE_BOOL); } +#line 6570 "sql.c" break; case 208: /* type_name ::= TINYINT */ #line 410 "sql.y" -{ yymsp[0].minor.yy154 = createDataType(TSDB_DATA_TYPE_TINYINT); } -#line 6515 "sql.c" +{ yymsp[0].minor.yy146 = createDataType(TSDB_DATA_TYPE_TINYINT); } +#line 6575 "sql.c" break; case 209: /* type_name ::= SMALLINT */ #line 411 "sql.y" -{ yymsp[0].minor.yy154 = createDataType(TSDB_DATA_TYPE_SMALLINT); } -#line 6520 "sql.c" +{ yymsp[0].minor.yy146 = createDataType(TSDB_DATA_TYPE_SMALLINT); } +#line 6580 "sql.c" break; case 210: /* type_name ::= INT */ case 211: /* type_name ::= INTEGER */ yytestcase(yyruleno==211); #line 412 "sql.y" -{ yymsp[0].minor.yy154 = createDataType(TSDB_DATA_TYPE_INT); } -#line 6526 "sql.c" +{ yymsp[0].minor.yy146 = createDataType(TSDB_DATA_TYPE_INT); } +#line 6586 "sql.c" break; case 212: /* type_name ::= BIGINT */ #line 414 "sql.y" -{ yymsp[0].minor.yy154 = createDataType(TSDB_DATA_TYPE_BIGINT); } -#line 6531 "sql.c" +{ yymsp[0].minor.yy146 = createDataType(TSDB_DATA_TYPE_BIGINT); } +#line 6591 "sql.c" break; case 213: /* type_name ::= FLOAT */ #line 415 "sql.y" -{ yymsp[0].minor.yy154 = createDataType(TSDB_DATA_TYPE_FLOAT); } -#line 6536 "sql.c" +{ yymsp[0].minor.yy146 = createDataType(TSDB_DATA_TYPE_FLOAT); } +#line 6596 "sql.c" break; case 214: /* type_name ::= DOUBLE */ #line 416 "sql.y" -{ yymsp[0].minor.yy154 = createDataType(TSDB_DATA_TYPE_DOUBLE); } -#line 6541 "sql.c" +{ yymsp[0].minor.yy146 = createDataType(TSDB_DATA_TYPE_DOUBLE); } +#line 6601 "sql.c" break; case 215: /* type_name ::= BINARY NK_LP NK_INTEGER NK_RP */ #line 417 "sql.y" -{ yymsp[-3].minor.yy154 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } -#line 6546 "sql.c" +{ yymsp[-3].minor.yy146 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, &yymsp[-1].minor.yy0); } +#line 6606 "sql.c" break; case 216: /* type_name ::= TIMESTAMP */ #line 418 "sql.y" -{ yymsp[0].minor.yy154 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } -#line 6551 "sql.c" +{ yymsp[0].minor.yy146 = createDataType(TSDB_DATA_TYPE_TIMESTAMP); } +#line 6611 "sql.c" break; case 217: /* type_name ::= NCHAR NK_LP NK_INTEGER NK_RP */ #line 419 "sql.y" -{ yymsp[-3].minor.yy154 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } -#line 6556 "sql.c" +{ yymsp[-3].minor.yy146 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, &yymsp[-1].minor.yy0); } +#line 6616 "sql.c" break; case 218: /* type_name ::= TINYINT UNSIGNED */ #line 420 "sql.y" -{ yymsp[-1].minor.yy154 = createDataType(TSDB_DATA_TYPE_UTINYINT); } -#line 6561 "sql.c" +{ yymsp[-1].minor.yy146 = createDataType(TSDB_DATA_TYPE_UTINYINT); } +#line 6621 "sql.c" break; case 219: /* type_name ::= SMALLINT UNSIGNED */ #line 421 "sql.y" -{ yymsp[-1].minor.yy154 = createDataType(TSDB_DATA_TYPE_USMALLINT); } -#line 6566 "sql.c" +{ yymsp[-1].minor.yy146 = createDataType(TSDB_DATA_TYPE_USMALLINT); } +#line 6626 "sql.c" break; case 220: /* type_name ::= INT UNSIGNED */ #line 422 "sql.y" -{ yymsp[-1].minor.yy154 = createDataType(TSDB_DATA_TYPE_UINT); } -#line 6571 "sql.c" +{ yymsp[-1].minor.yy146 = createDataType(TSDB_DATA_TYPE_UINT); } +#line 6631 "sql.c" break; case 221: /* type_name ::= BIGINT UNSIGNED */ #line 423 "sql.y" -{ yymsp[-1].minor.yy154 = createDataType(TSDB_DATA_TYPE_UBIGINT); } -#line 6576 "sql.c" +{ yymsp[-1].minor.yy146 = createDataType(TSDB_DATA_TYPE_UBIGINT); } +#line 6636 "sql.c" break; case 222: /* type_name ::= JSON */ #line 424 "sql.y" -{ yymsp[0].minor.yy154 = createDataType(TSDB_DATA_TYPE_JSON); } -#line 6581 "sql.c" +{ yymsp[0].minor.yy146 = createDataType(TSDB_DATA_TYPE_JSON); } +#line 6641 "sql.c" break; case 223: /* type_name ::= VARCHAR NK_LP NK_INTEGER NK_RP */ #line 425 "sql.y" -{ yymsp[-3].minor.yy154 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } -#line 6586 "sql.c" +{ yymsp[-3].minor.yy146 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, &yymsp[-1].minor.yy0); } +#line 6646 "sql.c" break; case 224: /* type_name ::= MEDIUMBLOB */ #line 426 "sql.y" -{ yymsp[0].minor.yy154 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } -#line 6591 "sql.c" +{ yymsp[0].minor.yy146 = createDataType(TSDB_DATA_TYPE_MEDIUMBLOB); } +#line 6651 "sql.c" break; case 225: /* type_name ::= BLOB */ #line 427 "sql.y" -{ yymsp[0].minor.yy154 = createDataType(TSDB_DATA_TYPE_BLOB); } -#line 6596 "sql.c" +{ yymsp[0].minor.yy146 = createDataType(TSDB_DATA_TYPE_BLOB); } +#line 6656 "sql.c" break; case 226: /* type_name ::= VARBINARY NK_LP NK_INTEGER NK_RP */ #line 428 "sql.y" -{ yymsp[-3].minor.yy154 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } -#line 6601 "sql.c" +{ yymsp[-3].minor.yy146 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, &yymsp[-1].minor.yy0); } +#line 6661 "sql.c" break; case 227: /* type_name ::= GEOMETRY NK_LP NK_INTEGER NK_RP */ #line 429 "sql.y" -{ yymsp[-3].minor.yy154 = createVarLenDataType(TSDB_DATA_TYPE_GEOMETRY, &yymsp[-1].minor.yy0); } -#line 6606 "sql.c" +{ yymsp[-3].minor.yy146 = createVarLenDataType(TSDB_DATA_TYPE_GEOMETRY, &yymsp[-1].minor.yy0); } +#line 6666 "sql.c" break; case 228: /* type_name ::= DECIMAL */ #line 430 "sql.y" -{ yymsp[0].minor.yy154 = createDataType(TSDB_DATA_TYPE_DECIMAL); } -#line 6611 "sql.c" +{ yymsp[0].minor.yy146 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 6671 "sql.c" break; case 229: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_RP */ #line 431 "sql.y" -{ yymsp[-3].minor.yy154 = createDataType(TSDB_DATA_TYPE_DECIMAL); } -#line 6616 "sql.c" +{ yymsp[-3].minor.yy146 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 6676 "sql.c" break; case 230: /* type_name ::= DECIMAL NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ #line 432 "sql.y" -{ yymsp[-5].minor.yy154 = createDataType(TSDB_DATA_TYPE_DECIMAL); } -#line 6621 "sql.c" +{ yymsp[-5].minor.yy146 = createDataType(TSDB_DATA_TYPE_DECIMAL); } +#line 6681 "sql.c" break; case 231: /* type_name_default_len ::= BINARY */ #line 436 "sql.y" -{ yymsp[0].minor.yy154 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, NULL); } -#line 6626 "sql.c" +{ yymsp[0].minor.yy146 = createVarLenDataType(TSDB_DATA_TYPE_BINARY, NULL); } +#line 6686 "sql.c" break; case 232: /* type_name_default_len ::= NCHAR */ #line 437 "sql.y" -{ yymsp[0].minor.yy154 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, NULL); } -#line 6631 "sql.c" +{ yymsp[0].minor.yy146 = createVarLenDataType(TSDB_DATA_TYPE_NCHAR, NULL); } +#line 6691 "sql.c" break; case 233: /* type_name_default_len ::= VARCHAR */ #line 438 "sql.y" -{ yymsp[0].minor.yy154 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, NULL); } -#line 6636 "sql.c" +{ yymsp[0].minor.yy146 = createVarLenDataType(TSDB_DATA_TYPE_VARCHAR, NULL); } +#line 6696 "sql.c" break; case 234: /* type_name_default_len ::= VARBINARY */ #line 439 "sql.y" -{ yymsp[0].minor.yy154 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, NULL); } -#line 6641 "sql.c" +{ yymsp[0].minor.yy146 = createVarLenDataType(TSDB_DATA_TYPE_VARBINARY, NULL); } +#line 6701 "sql.c" break; case 237: /* tags_def ::= TAGS NK_LP tag_def_list NK_RP */ - case 399: /* tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP */ yytestcase(yyruleno==399); + case 406: /* tag_def_or_ref_opt ::= TAGS NK_LP column_stream_def_list NK_RP */ yytestcase(yyruleno==406); #line 448 "sql.y" -{ yymsp[-3].minor.yy694 = yymsp[-1].minor.yy694; } -#line 6647 "sql.c" +{ yymsp[-3].minor.yy616 = yymsp[-1].minor.yy616; } +#line 6707 "sql.c" break; case 238: /* table_options ::= */ #line 450 "sql.y" -{ yymsp[1].minor.yy722 = createDefaultTableOptions(pCxt); } -#line 6652 "sql.c" +{ yymsp[1].minor.yy826 = createDefaultTableOptions(pCxt); } +#line 6712 "sql.c" break; case 239: /* table_options ::= table_options COMMENT NK_STRING */ #line 451 "sql.y" -{ yylhsminor.yy722 = setTableOption(pCxt, yymsp[-2].minor.yy722, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } -#line 6657 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setTableOption(pCxt, yymsp[-2].minor.yy826, TABLE_OPTION_COMMENT, &yymsp[0].minor.yy0); } +#line 6717 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 240: /* table_options ::= table_options MAX_DELAY duration_list */ #line 452 "sql.y" -{ yylhsminor.yy722 = setTableOption(pCxt, yymsp[-2].minor.yy722, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy694); } -#line 6663 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setTableOption(pCxt, yymsp[-2].minor.yy826, TABLE_OPTION_MAXDELAY, yymsp[0].minor.yy616); } +#line 6723 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 241: /* table_options ::= table_options WATERMARK duration_list */ #line 453 "sql.y" -{ yylhsminor.yy722 = setTableOption(pCxt, yymsp[-2].minor.yy722, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy694); } -#line 6669 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setTableOption(pCxt, yymsp[-2].minor.yy826, TABLE_OPTION_WATERMARK, yymsp[0].minor.yy616); } +#line 6729 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 242: /* table_options ::= table_options ROLLUP NK_LP rollup_func_list NK_RP */ #line 454 "sql.y" -{ yylhsminor.yy722 = setTableOption(pCxt, yymsp[-4].minor.yy722, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy694); } -#line 6675 "sql.c" - yymsp[-4].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setTableOption(pCxt, yymsp[-4].minor.yy826, TABLE_OPTION_ROLLUP, yymsp[-1].minor.yy616); } +#line 6735 "sql.c" + yymsp[-4].minor.yy826 = yylhsminor.yy826; break; case 243: /* table_options ::= table_options TTL NK_INTEGER */ #line 455 "sql.y" -{ yylhsminor.yy722 = setTableOption(pCxt, yymsp[-2].minor.yy722, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } -#line 6681 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setTableOption(pCxt, yymsp[-2].minor.yy826, TABLE_OPTION_TTL, &yymsp[0].minor.yy0); } +#line 6741 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 244: /* table_options ::= table_options SMA NK_LP col_name_list NK_RP */ #line 456 "sql.y" -{ yylhsminor.yy722 = setTableOption(pCxt, yymsp[-4].minor.yy722, TABLE_OPTION_SMA, yymsp[-1].minor.yy694); } -#line 6687 "sql.c" - yymsp[-4].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setTableOption(pCxt, yymsp[-4].minor.yy826, TABLE_OPTION_SMA, yymsp[-1].minor.yy616); } +#line 6747 "sql.c" + yymsp[-4].minor.yy826 = yylhsminor.yy826; break; case 245: /* table_options ::= table_options DELETE_MARK duration_list */ #line 457 "sql.y" -{ yylhsminor.yy722 = setTableOption(pCxt, yymsp[-2].minor.yy722, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy694); } -#line 6693 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setTableOption(pCxt, yymsp[-2].minor.yy826, TABLE_OPTION_DELETE_MARK, yymsp[0].minor.yy616); } +#line 6753 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 246: /* alter_table_options ::= alter_table_option */ #line 459 "sql.y" -{ yylhsminor.yy722 = createAlterTableOptions(pCxt); yylhsminor.yy722 = setTableOption(pCxt, yylhsminor.yy722, yymsp[0].minor.yy845.type, &yymsp[0].minor.yy845.val); } -#line 6699 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createAlterTableOptions(pCxt); yylhsminor.yy826 = setTableOption(pCxt, yylhsminor.yy826, yymsp[0].minor.yy177.type, &yymsp[0].minor.yy177.val); } +#line 6759 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; break; case 247: /* alter_table_options ::= alter_table_options alter_table_option */ #line 460 "sql.y" -{ yylhsminor.yy722 = setTableOption(pCxt, yymsp[-1].minor.yy722, yymsp[0].minor.yy845.type, &yymsp[0].minor.yy845.val); } -#line 6705 "sql.c" - yymsp[-1].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setTableOption(pCxt, yymsp[-1].minor.yy826, yymsp[0].minor.yy177.type, &yymsp[0].minor.yy177.val); } +#line 6765 "sql.c" + yymsp[-1].minor.yy826 = yylhsminor.yy826; break; case 248: /* alter_table_option ::= COMMENT NK_STRING */ #line 464 "sql.y" -{ yymsp[-1].minor.yy845.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } -#line 6711 "sql.c" +{ yymsp[-1].minor.yy177.type = TABLE_OPTION_COMMENT; yymsp[-1].minor.yy177.val = yymsp[0].minor.yy0; } +#line 6771 "sql.c" break; case 249: /* alter_table_option ::= TTL NK_INTEGER */ #line 465 "sql.y" -{ yymsp[-1].minor.yy845.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy845.val = yymsp[0].minor.yy0; } -#line 6716 "sql.c" +{ yymsp[-1].minor.yy177.type = TABLE_OPTION_TTL; yymsp[-1].minor.yy177.val = yymsp[0].minor.yy0; } +#line 6776 "sql.c" break; case 250: /* duration_list ::= duration_literal */ - case 526: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==526); + case 534: /* expression_list ::= expr_or_subquery */ yytestcase(yyruleno==534); #line 469 "sql.y" -{ yylhsminor.yy694 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy722)); } -#line 6722 "sql.c" - yymsp[0].minor.yy694 = yylhsminor.yy694; +{ yylhsminor.yy616 = createNodeList(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy826)); } +#line 6782 "sql.c" + yymsp[0].minor.yy616 = yylhsminor.yy616; break; case 251: /* duration_list ::= duration_list NK_COMMA duration_literal */ - case 527: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==527); + case 535: /* expression_list ::= expression_list NK_COMMA expr_or_subquery */ yytestcase(yyruleno==535); #line 470 "sql.y" -{ yylhsminor.yy694 = addNodeToList(pCxt, yymsp[-2].minor.yy694, releaseRawExprNode(pCxt, yymsp[0].minor.yy722)); } -#line 6729 "sql.c" - yymsp[-2].minor.yy694 = yylhsminor.yy694; +{ yylhsminor.yy616 = addNodeToList(pCxt, yymsp[-2].minor.yy616, releaseRawExprNode(pCxt, yymsp[0].minor.yy826)); } +#line 6789 "sql.c" + yymsp[-2].minor.yy616 = yylhsminor.yy616; break; case 254: /* rollup_func_name ::= function_name */ #line 477 "sql.y" -{ yylhsminor.yy722 = createFunctionNode(pCxt, &yymsp[0].minor.yy659, NULL); } -#line 6735 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createFunctionNode(pCxt, &yymsp[0].minor.yy585, NULL); } +#line 6795 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; break; case 255: /* rollup_func_name ::= FIRST */ case 256: /* rollup_func_name ::= LAST */ yytestcase(yyruleno==256); case 328: /* tag_item ::= QTAGS */ yytestcase(yyruleno==328); #line 478 "sql.y" -{ yylhsminor.yy722 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } -#line 6743 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL); } +#line 6803 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; break; case 259: /* col_name ::= column_name */ case 329: /* tag_item ::= column_name */ yytestcase(yyruleno==329); #line 486 "sql.y" -{ yylhsminor.yy722 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy659); } -#line 6750 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy585); } +#line 6810 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; break; case 260: /* cmd ::= SHOW DNODES */ #line 489 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DNODES_STMT); } -#line 6756 "sql.c" +#line 6816 "sql.c" break; case 261: /* cmd ::= SHOW USERS */ #line 490 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USERS_STMT); } -#line 6761 "sql.c" +#line 6821 "sql.c" break; case 262: /* cmd ::= SHOW USER PRIVILEGES */ #line 491 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_USER_PRIVILEGES_STMT); } -#line 6766 "sql.c" +#line 6826 "sql.c" break; case 263: /* cmd ::= SHOW db_kind_opt DATABASES */ #line 492 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_DATABASES_STMT); - setShowKind(pCxt, pCxt->pRootNode, yymsp[-1].minor.yy89); + setShowKind(pCxt, pCxt->pRootNode, yymsp[-1].minor.yy857); } -#line 6774 "sql.c" +#line 6834 "sql.c" break; case 264: /* cmd ::= SHOW table_kind_db_name_cond_opt TABLES like_pattern_opt */ #line 496 "sql.y" { - pCxt->pRootNode = createShowTablesStmt(pCxt, yymsp[-2].minor.yy817, yymsp[0].minor.yy722, OP_TYPE_LIKE); + pCxt->pRootNode = createShowTablesStmt(pCxt, yymsp[-2].minor.yy347, yymsp[0].minor.yy826, OP_TYPE_LIKE); } -#line 6781 "sql.c" +#line 6841 "sql.c" break; case 265: /* cmd ::= SHOW db_name_cond_opt STABLES like_pattern_opt */ #line 499 "sql.y" -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy722, yymsp[0].minor.yy722, OP_TYPE_LIKE); } -#line 6786 "sql.c" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_STABLES_STMT, yymsp[-2].minor.yy826, yymsp[0].minor.yy826, OP_TYPE_LIKE); } +#line 6846 "sql.c" break; case 266: /* cmd ::= SHOW db_name_cond_opt VGROUPS */ #line 500 "sql.y" -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy722, NULL, OP_TYPE_LIKE); } -#line 6791 "sql.c" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VGROUPS_STMT, yymsp[-1].minor.yy826, NULL, OP_TYPE_LIKE); } +#line 6851 "sql.c" break; case 267: /* cmd ::= SHOW MNODES */ #line 501 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_MNODES_STMT); } -#line 6796 "sql.c" +#line 6856 "sql.c" break; case 268: /* cmd ::= SHOW QNODES */ #line 503 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QNODES_STMT); } -#line 6801 "sql.c" +#line 6861 "sql.c" break; case 269: /* cmd ::= SHOW ARBGROUPS */ #line 504 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_ARBGROUPS_STMT); } -#line 6806 "sql.c" +#line 6866 "sql.c" break; case 270: /* cmd ::= SHOW FUNCTIONS */ #line 505 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_FUNCTIONS_STMT); } -#line 6811 "sql.c" +#line 6871 "sql.c" break; case 271: /* cmd ::= SHOW INDEXES FROM table_name_cond from_db_opt */ #line 506 "sql.y" -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy722, yymsp[-1].minor.yy722, OP_TYPE_EQUAL); } -#line 6816 "sql.c" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, yymsp[0].minor.yy826, yymsp[-1].minor.yy826, OP_TYPE_EQUAL); } +#line 6876 "sql.c" break; case 272: /* cmd ::= SHOW INDEXES FROM db_name NK_DOT table_name */ #line 507 "sql.y" -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy659), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy659), OP_TYPE_EQUAL); } -#line 6821 "sql.c" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_INDEXES_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy585), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy585), OP_TYPE_EQUAL); } +#line 6881 "sql.c" break; case 273: /* cmd ::= SHOW STREAMS */ #line 508 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_STREAMS_STMT); } -#line 6826 "sql.c" +#line 6886 "sql.c" break; case 274: /* cmd ::= SHOW ACCOUNTS */ #line 509 "sql.y" { pCxt->errCode = generateSyntaxErrMsg(&pCxt->msgBuf, TSDB_CODE_PAR_EXPRIE_STATEMENT); } -#line 6831 "sql.c" +#line 6891 "sql.c" break; case 275: /* cmd ::= SHOW APPS */ #line 510 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_APPS_STMT); } -#line 6836 "sql.c" +#line 6896 "sql.c" break; case 276: /* cmd ::= SHOW CONNECTIONS */ #line 511 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONNECTIONS_STMT); } -#line 6841 "sql.c" +#line 6901 "sql.c" break; case 277: /* cmd ::= SHOW LICENCES */ case 278: /* cmd ::= SHOW GRANTS */ yytestcase(yyruleno==278); #line 512 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LICENCES_STMT); } -#line 6847 "sql.c" +#line 6907 "sql.c" break; case 279: /* cmd ::= SHOW GRANTS FULL */ #line 514 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_GRANTS_FULL_STMT); } -#line 6852 "sql.c" +#line 6912 "sql.c" break; case 280: /* cmd ::= SHOW GRANTS LOGS */ #line 515 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_GRANTS_LOGS_STMT); } -#line 6857 "sql.c" +#line 6917 "sql.c" break; case 281: /* cmd ::= SHOW CLUSTER MACHINES */ #line 516 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_MACHINES_STMT); } -#line 6862 "sql.c" +#line 6922 "sql.c" break; case 282: /* cmd ::= SHOW CREATE DATABASE db_name */ #line 517 "sql.y" -{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy659); } -#line 6867 "sql.c" +{ pCxt->pRootNode = createShowCreateDatabaseStmt(pCxt, &yymsp[0].minor.yy585); } +#line 6927 "sql.c" break; case 283: /* cmd ::= SHOW CREATE TABLE full_table_name */ #line 518 "sql.y" -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy722); } -#line 6872 "sql.c" +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_TABLE_STMT, yymsp[0].minor.yy826); } +#line 6932 "sql.c" break; case 284: /* cmd ::= SHOW CREATE STABLE full_table_name */ #line 519 "sql.y" -{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy722); } -#line 6877 "sql.c" +{ pCxt->pRootNode = createShowCreateTableStmt(pCxt, QUERY_NODE_SHOW_CREATE_STABLE_STMT, yymsp[0].minor.yy826); } +#line 6937 "sql.c" break; case 285: /* cmd ::= SHOW QUERIES */ #line 520 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_QUERIES_STMT); } -#line 6882 "sql.c" +#line 6942 "sql.c" break; case 286: /* cmd ::= SHOW SCORES */ #line 521 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SCORES_STMT); } -#line 6887 "sql.c" +#line 6947 "sql.c" break; case 287: /* cmd ::= SHOW TOPICS */ #line 522 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TOPICS_STMT); } -#line 6892 "sql.c" +#line 6952 "sql.c" break; case 288: /* cmd ::= SHOW VARIABLES */ case 289: /* cmd ::= SHOW CLUSTER VARIABLES */ yytestcase(yyruleno==289); #line 523 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_VARIABLES_STMT); } -#line 6898 "sql.c" +#line 6958 "sql.c" break; case 290: /* cmd ::= SHOW LOCAL VARIABLES */ #line 525 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_LOCAL_VARIABLES_STMT); } -#line 6903 "sql.c" +#line 6963 "sql.c" break; case 291: /* cmd ::= SHOW DNODE NK_INTEGER VARIABLES like_pattern_opt */ #line 526 "sql.y" -{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy722); } -#line 6908 "sql.c" +{ pCxt->pRootNode = createShowDnodeVariablesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[-2].minor.yy0), yymsp[0].minor.yy826); } +#line 6968 "sql.c" break; case 292: /* cmd ::= SHOW BNODES */ #line 527 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_BNODES_STMT); } -#line 6913 "sql.c" +#line 6973 "sql.c" break; case 293: /* cmd ::= SHOW SNODES */ #line 528 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SNODES_STMT); } -#line 6918 "sql.c" +#line 6978 "sql.c" break; case 294: /* cmd ::= SHOW CLUSTER */ #line 529 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CLUSTER_STMT); } -#line 6923 "sql.c" +#line 6983 "sql.c" break; case 295: /* cmd ::= SHOW TRANSACTIONS */ #line 530 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_TRANSACTIONS_STMT); } -#line 6928 "sql.c" +#line 6988 "sql.c" break; case 296: /* cmd ::= SHOW TABLE DISTRIBUTED full_table_name */ #line 531 "sql.y" -{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy722); } -#line 6933 "sql.c" +{ pCxt->pRootNode = createShowTableDistributedStmt(pCxt, yymsp[0].minor.yy826); } +#line 6993 "sql.c" break; case 297: /* cmd ::= SHOW CONSUMERS */ #line 532 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_CONSUMERS_STMT); } -#line 6938 "sql.c" +#line 6998 "sql.c" break; case 298: /* cmd ::= SHOW SUBSCRIPTIONS */ #line 533 "sql.y" { pCxt->pRootNode = createShowStmt(pCxt, QUERY_NODE_SHOW_SUBSCRIPTIONS_STMT); } -#line 6943 "sql.c" +#line 7003 "sql.c" break; case 299: /* cmd ::= SHOW TAGS FROM table_name_cond from_db_opt */ #line 534 "sql.y" -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy722, yymsp[-1].minor.yy722, OP_TYPE_EQUAL); } -#line 6948 "sql.c" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, yymsp[0].minor.yy826, yymsp[-1].minor.yy826, OP_TYPE_EQUAL); } +#line 7008 "sql.c" break; case 300: /* cmd ::= SHOW TAGS FROM db_name NK_DOT table_name */ #line 535 "sql.y" -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy659), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy659), OP_TYPE_EQUAL); } -#line 6953 "sql.c" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_TAGS_STMT, createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy585), createIdentifierValueNode(pCxt, &yymsp[0].minor.yy585), OP_TYPE_EQUAL); } +#line 7013 "sql.c" break; case 301: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM table_name_cond from_db_opt */ #line 536 "sql.y" -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy722, yymsp[0].minor.yy722, yymsp[-3].minor.yy694); } -#line 6958 "sql.c" +{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, yymsp[-1].minor.yy826, yymsp[0].minor.yy826, yymsp[-3].minor.yy616); } +#line 7018 "sql.c" break; case 302: /* cmd ::= SHOW TABLE TAGS tag_list_opt FROM db_name NK_DOT table_name */ #line 537 "sql.y" -{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, createIdentifierValueNode(pCxt, &yymsp[0].minor.yy659), createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy659), yymsp[-4].minor.yy694); } -#line 6963 "sql.c" +{ pCxt->pRootNode = createShowTableTagsStmt(pCxt, createIdentifierValueNode(pCxt, &yymsp[0].minor.yy585), createIdentifierValueNode(pCxt, &yymsp[-2].minor.yy585), yymsp[-4].minor.yy616); } +#line 7023 "sql.c" break; case 303: /* cmd ::= SHOW VNODES ON DNODE NK_INTEGER */ #line 538 "sql.y" { pCxt->pRootNode = createShowVnodesStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0), NULL); } -#line 6968 "sql.c" +#line 7028 "sql.c" break; case 304: /* cmd ::= SHOW VNODES */ #line 539 "sql.y" { pCxt->pRootNode = createShowVnodesStmt(pCxt, NULL, NULL); } -#line 6973 "sql.c" +#line 7033 "sql.c" break; case 305: /* cmd ::= SHOW db_name_cond_opt ALIVE */ #line 541 "sql.y" -{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy722, QUERY_NODE_SHOW_DB_ALIVE_STMT); } -#line 6978 "sql.c" +{ pCxt->pRootNode = createShowAliveStmt(pCxt, yymsp[-1].minor.yy826, QUERY_NODE_SHOW_DB_ALIVE_STMT); } +#line 7038 "sql.c" break; case 306: /* cmd ::= SHOW CLUSTER ALIVE */ #line 542 "sql.y" { pCxt->pRootNode = createShowAliveStmt(pCxt, NULL, QUERY_NODE_SHOW_CLUSTER_ALIVE_STMT); } -#line 6983 "sql.c" +#line 7043 "sql.c" break; case 307: /* cmd ::= SHOW db_name_cond_opt VIEWS like_pattern_opt */ #line 543 "sql.y" -{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VIEWS_STMT, yymsp[-2].minor.yy722, yymsp[0].minor.yy722, OP_TYPE_LIKE); } -#line 6988 "sql.c" +{ pCxt->pRootNode = createShowStmtWithCond(pCxt, QUERY_NODE_SHOW_VIEWS_STMT, yymsp[-2].minor.yy826, yymsp[0].minor.yy826, OP_TYPE_LIKE); } +#line 7048 "sql.c" break; case 308: /* cmd ::= SHOW CREATE VIEW full_table_name */ #line 544 "sql.y" -{ pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, yymsp[0].minor.yy722); } -#line 6993 "sql.c" +{ pCxt->pRootNode = createShowCreateViewStmt(pCxt, QUERY_NODE_SHOW_CREATE_VIEW_STMT, yymsp[0].minor.yy826); } +#line 7053 "sql.c" break; case 309: /* cmd ::= SHOW COMPACTS */ #line 545 "sql.y" { pCxt->pRootNode = createShowCompactsStmt(pCxt, QUERY_NODE_SHOW_COMPACTS_STMT); } -#line 6998 "sql.c" +#line 7058 "sql.c" break; case 310: /* cmd ::= SHOW COMPACT NK_INTEGER */ #line 546 "sql.y" { pCxt->pRootNode = createShowCompactDetailsStmt(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } -#line 7003 "sql.c" +#line 7063 "sql.c" break; case 311: /* table_kind_db_name_cond_opt ::= */ #line 550 "sql.y" -{ yymsp[1].minor.yy817.kind = SHOW_KIND_ALL; yymsp[1].minor.yy817.dbName = nil_token; } -#line 7008 "sql.c" +{ yymsp[1].minor.yy347.kind = SHOW_KIND_ALL; yymsp[1].minor.yy347.dbName = nil_token; } +#line 7068 "sql.c" break; case 312: /* table_kind_db_name_cond_opt ::= table_kind */ #line 551 "sql.y" -{ yylhsminor.yy817.kind = yymsp[0].minor.yy89; yylhsminor.yy817.dbName = nil_token; } -#line 7013 "sql.c" - yymsp[0].minor.yy817 = yylhsminor.yy817; +{ yylhsminor.yy347.kind = yymsp[0].minor.yy857; yylhsminor.yy347.dbName = nil_token; } +#line 7073 "sql.c" + yymsp[0].minor.yy347 = yylhsminor.yy347; break; case 313: /* table_kind_db_name_cond_opt ::= db_name NK_DOT */ #line 552 "sql.y" -{ yylhsminor.yy817.kind = SHOW_KIND_ALL; yylhsminor.yy817.dbName = yymsp[-1].minor.yy659; } -#line 7019 "sql.c" - yymsp[-1].minor.yy817 = yylhsminor.yy817; +{ yylhsminor.yy347.kind = SHOW_KIND_ALL; yylhsminor.yy347.dbName = yymsp[-1].minor.yy585; } +#line 7079 "sql.c" + yymsp[-1].minor.yy347 = yylhsminor.yy347; break; case 314: /* table_kind_db_name_cond_opt ::= table_kind db_name NK_DOT */ #line 553 "sql.y" -{ yylhsminor.yy817.kind = yymsp[-2].minor.yy89; yylhsminor.yy817.dbName = yymsp[-1].minor.yy659; } -#line 7025 "sql.c" - yymsp[-2].minor.yy817 = yylhsminor.yy817; +{ yylhsminor.yy347.kind = yymsp[-2].minor.yy857; yylhsminor.yy347.dbName = yymsp[-1].minor.yy585; } +#line 7085 "sql.c" + yymsp[-2].minor.yy347 = yylhsminor.yy347; break; case 315: /* table_kind ::= NORMAL */ #line 557 "sql.y" -{ yymsp[0].minor.yy89 = SHOW_KIND_TABLES_NORMAL; } -#line 7031 "sql.c" +{ yymsp[0].minor.yy857 = SHOW_KIND_TABLES_NORMAL; } +#line 7091 "sql.c" break; case 316: /* table_kind ::= CHILD */ #line 558 "sql.y" -{ yymsp[0].minor.yy89 = SHOW_KIND_TABLES_CHILD; } -#line 7036 "sql.c" +{ yymsp[0].minor.yy857 = SHOW_KIND_TABLES_CHILD; } +#line 7096 "sql.c" break; case 317: /* db_name_cond_opt ::= */ case 322: /* from_db_opt ::= */ yytestcase(yyruleno==322); #line 560 "sql.y" -{ yymsp[1].minor.yy722 = createDefaultDatabaseCondValue(pCxt); } -#line 7042 "sql.c" +{ yymsp[1].minor.yy826 = createDefaultDatabaseCondValue(pCxt); } +#line 7102 "sql.c" break; case 318: /* db_name_cond_opt ::= db_name NK_DOT */ #line 561 "sql.y" -{ yylhsminor.yy722 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy659); } -#line 7047 "sql.c" - yymsp[-1].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createIdentifierValueNode(pCxt, &yymsp[-1].minor.yy585); } +#line 7107 "sql.c" + yymsp[-1].minor.yy826 = yylhsminor.yy826; break; case 320: /* like_pattern_opt ::= LIKE NK_STRING */ #line 564 "sql.y" -{ yymsp[-1].minor.yy722 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } -#line 7053 "sql.c" +{ yymsp[-1].minor.yy826 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +#line 7113 "sql.c" break; case 321: /* table_name_cond ::= table_name */ #line 566 "sql.y" -{ yylhsminor.yy722 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy659); } -#line 7058 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy585); } +#line 7118 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; break; case 323: /* from_db_opt ::= FROM db_name */ #line 569 "sql.y" -{ yymsp[-1].minor.yy722 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy659); } -#line 7064 "sql.c" +{ yymsp[-1].minor.yy826 = createIdentifierValueNode(pCxt, &yymsp[0].minor.yy585); } +#line 7124 "sql.c" break; case 327: /* tag_item ::= TBNAME */ #line 577 "sql.y" -{ yylhsminor.yy722 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } -#line 7069 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setProjectionAlias(pCxt, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL), &yymsp[0].minor.yy0); } +#line 7129 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; break; case 330: /* tag_item ::= column_name column_alias */ #line 580 "sql.y" -{ yylhsminor.yy722 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy659), &yymsp[0].minor.yy659); } -#line 7075 "sql.c" - yymsp[-1].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-1].minor.yy585), &yymsp[0].minor.yy585); } +#line 7135 "sql.c" + yymsp[-1].minor.yy826 = yylhsminor.yy826; break; case 331: /* tag_item ::= column_name AS column_alias */ #line 581 "sql.y" -{ yylhsminor.yy722 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy659), &yymsp[0].minor.yy659); } -#line 7081 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setProjectionAlias(pCxt, createColumnNode(pCxt, NULL, &yymsp[-2].minor.yy585), &yymsp[0].minor.yy585); } +#line 7141 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; case 332: /* db_kind_opt ::= */ #line 585 "sql.y" -{ yymsp[1].minor.yy89 = SHOW_KIND_ALL; } -#line 7087 "sql.c" +{ yymsp[1].minor.yy857 = SHOW_KIND_ALL; } +#line 7147 "sql.c" break; case 333: /* db_kind_opt ::= USER */ #line 586 "sql.y" -{ yymsp[0].minor.yy89 = SHOW_KIND_DATABASES_USER; } -#line 7092 "sql.c" +{ yymsp[0].minor.yy857 = SHOW_KIND_DATABASES_USER; } +#line 7152 "sql.c" break; case 334: /* db_kind_opt ::= SYSTEM */ #line 587 "sql.y" -{ yymsp[0].minor.yy89 = SHOW_KIND_DATABASES_SYSTEM; } -#line 7097 "sql.c" +{ yymsp[0].minor.yy857 = SHOW_KIND_DATABASES_SYSTEM; } +#line 7157 "sql.c" break; - case 335: /* cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ -#line 591 "sql.y" -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy897, yymsp[-3].minor.yy722, yymsp[-1].minor.yy722, NULL, yymsp[0].minor.yy722); } -#line 7102 "sql.c" - break; - case 336: /* cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ + case 335: /* cmd ::= CREATE TSMA not_exists_opt tsma_name ON full_table_name tsma_func_list INTERVAL NK_LP duration_literal NK_RP */ #line 593 "sql.y" -{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy897, yymsp[-5].minor.yy722, yymsp[-3].minor.yy722, yymsp[-1].minor.yy694, NULL); } -#line 7107 "sql.c" +{ pCxt->pRootNode = createCreateTSMAStmt(pCxt, yymsp[-8].minor.yy983, &yymsp[-7].minor.yy585, yymsp[-4].minor.yy826, yymsp[-5].minor.yy826, releaseRawExprNode(pCxt, yymsp[-1].minor.yy826)); } +#line 7162 "sql.c" break; - case 337: /* cmd ::= DROP INDEX exists_opt full_index_name */ -#line 594 "sql.y" -{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy897, yymsp[0].minor.yy722); } -#line 7112 "sql.c" + case 336: /* cmd ::= CREATE RECURSIVE TSMA not_exists_opt tsma_name ON full_table_name INTERVAL NK_LP duration_literal NK_RP */ +#line 595 "sql.y" +{ pCxt->pRootNode = createCreateTSMAStmt(pCxt, yymsp[-7].minor.yy983, &yymsp[-6].minor.yy585, NULL, yymsp[-4].minor.yy826, releaseRawExprNode(pCxt, yymsp[-1].minor.yy826)); } +#line 7167 "sql.c" break; - case 338: /* full_index_name ::= index_name */ + case 337: /* cmd ::= DROP TSMA exists_opt full_tsma_name */ #line 596 "sql.y" -{ yylhsminor.yy722 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy659); } -#line 7117 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; +{ pCxt->pRootNode = createDropTSMAStmt(pCxt, yymsp[-1].minor.yy983, yymsp[0].minor.yy826); } +#line 7172 "sql.c" break; - case 339: /* full_index_name ::= db_name NK_DOT index_name */ + case 338: /* cmd ::= SHOW db_name_cond_opt TSMAS */ #line 597 "sql.y" -{ yylhsminor.yy722 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy659); } -#line 7123 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ pCxt->pRootNode = createShowTSMASStmt(pCxt, yymsp[-1].minor.yy826); } +#line 7177 "sql.c" break; - case 340: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ -#line 600 "sql.y" -{ yymsp[-9].minor.yy722 = createIndexOption(pCxt, yymsp[-7].minor.yy694, releaseRawExprNode(pCxt, yymsp[-3].minor.yy722), NULL, yymsp[-1].minor.yy722, yymsp[0].minor.yy722); } -#line 7129 "sql.c" + case 341: /* tsma_func_list ::= FUNCTION NK_LP func_list NK_RP */ +#line 604 "sql.y" +{ yymsp[-3].minor.yy826 = createTSMAOptions(pCxt, yymsp[-1].minor.yy616); } +#line 7182 "sql.c" break; - case 341: /* 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 603 "sql.y" -{ yymsp[-11].minor.yy722 = createIndexOption(pCxt, yymsp[-9].minor.yy694, releaseRawExprNode(pCxt, yymsp[-5].minor.yy722), releaseRawExprNode(pCxt, yymsp[-3].minor.yy722), yymsp[-1].minor.yy722, yymsp[0].minor.yy722); } -#line 7134 "sql.c" + case 342: /* cmd ::= CREATE SMA INDEX not_exists_opt col_name ON full_table_name index_options */ +#line 608 "sql.y" +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_SMA, yymsp[-4].minor.yy983, yymsp[-3].minor.yy826, yymsp[-1].minor.yy826, NULL, yymsp[0].minor.yy826); } +#line 7187 "sql.c" break; - case 344: /* func ::= sma_func_name NK_LP expression_list NK_RP */ + case 343: /* cmd ::= CREATE INDEX not_exists_opt col_name ON full_table_name NK_LP col_name_list NK_RP */ #line 610 "sql.y" -{ yylhsminor.yy722 = createFunctionNode(pCxt, &yymsp[-3].minor.yy659, yymsp[-1].minor.yy694); } -#line 7139 "sql.c" - yymsp[-3].minor.yy722 = yylhsminor.yy722; +{ pCxt->pRootNode = createCreateIndexStmt(pCxt, INDEX_TYPE_NORMAL, yymsp[-6].minor.yy983, yymsp[-5].minor.yy826, yymsp[-3].minor.yy826, yymsp[-1].minor.yy616, NULL); } +#line 7192 "sql.c" break; - case 345: /* sma_func_name ::= function_name */ - case 617: /* alias_opt ::= table_alias */ yytestcase(yyruleno==617); + case 344: /* cmd ::= DROP INDEX exists_opt full_index_name */ +#line 611 "sql.y" +{ pCxt->pRootNode = createDropIndexStmt(pCxt, yymsp[-1].minor.yy983, yymsp[0].minor.yy826); } +#line 7197 "sql.c" + break; + case 345: /* full_index_name ::= index_name */ +#line 613 "sql.y" +{ yylhsminor.yy826 = createRealTableNodeForIndexName(pCxt, NULL, &yymsp[0].minor.yy585); } +#line 7202 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; + break; + case 346: /* full_index_name ::= db_name NK_DOT index_name */ #line 614 "sql.y" -{ yylhsminor.yy659 = yymsp[0].minor.yy659; } -#line 7146 "sql.c" - yymsp[0].minor.yy659 = yylhsminor.yy659; +{ yylhsminor.yy826 = createRealTableNodeForIndexName(pCxt, &yymsp[-2].minor.yy585, &yymsp[0].minor.yy585); } +#line 7208 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 350: /* sma_stream_opt ::= */ - case 400: /* stream_options ::= */ yytestcase(yyruleno==400); + case 347: /* index_options ::= FUNCTION NK_LP func_list NK_RP INTERVAL NK_LP duration_literal NK_RP sliding_opt sma_stream_opt */ +#line 617 "sql.y" +{ yymsp[-9].minor.yy826 = createIndexOption(pCxt, yymsp[-7].minor.yy616, releaseRawExprNode(pCxt, yymsp[-3].minor.yy826), NULL, yymsp[-1].minor.yy826, yymsp[0].minor.yy826); } +#line 7214 "sql.c" + break; + case 348: /* 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 620 "sql.y" -{ yymsp[1].minor.yy722 = createStreamOptions(pCxt); } -#line 7153 "sql.c" +{ yymsp[-11].minor.yy826 = createIndexOption(pCxt, yymsp[-9].minor.yy616, releaseRawExprNode(pCxt, yymsp[-5].minor.yy826), releaseRawExprNode(pCxt, yymsp[-3].minor.yy826), yymsp[-1].minor.yy826, yymsp[0].minor.yy826); } +#line 7219 "sql.c" break; - case 351: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ -#line 621 "sql.y" -{ ((SStreamOptions*)yymsp[-2].minor.yy722)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy722); yylhsminor.yy722 = yymsp[-2].minor.yy722; } -#line 7158 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + case 351: /* func ::= sma_func_name NK_LP expression_list NK_RP */ +#line 627 "sql.y" +{ yylhsminor.yy826 = createFunctionNode(pCxt, &yymsp[-3].minor.yy585, yymsp[-1].minor.yy616); } +#line 7224 "sql.c" + yymsp[-3].minor.yy826 = yylhsminor.yy826; break; - case 352: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ -#line 622 "sql.y" -{ ((SStreamOptions*)yymsp[-2].minor.yy722)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy722); yylhsminor.yy722 = yymsp[-2].minor.yy722; } -#line 7164 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + case 352: /* sma_func_name ::= function_name */ + case 625: /* alias_opt ::= table_alias */ yytestcase(yyruleno==625); +#line 631 "sql.y" +{ yylhsminor.yy585 = yymsp[0].minor.yy585; } +#line 7231 "sql.c" + yymsp[0].minor.yy585 = yylhsminor.yy585; break; - case 353: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ -#line 623 "sql.y" -{ ((SStreamOptions*)yymsp[-2].minor.yy722)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy722); yylhsminor.yy722 = yymsp[-2].minor.yy722; } -#line 7170 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; - break; - case 354: /* with_meta ::= AS */ -#line 628 "sql.y" -{ yymsp[0].minor.yy830 = 0; } -#line 7176 "sql.c" - break; - case 355: /* with_meta ::= WITH META AS */ -#line 629 "sql.y" -{ yymsp[-2].minor.yy830 = 1; } -#line 7181 "sql.c" - break; - case 356: /* with_meta ::= ONLY META AS */ -#line 630 "sql.y" -{ yymsp[-2].minor.yy830 = 2; } -#line 7186 "sql.c" - break; - case 357: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ -#line 632 "sql.y" -{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy897, &yymsp[-2].minor.yy659, yymsp[0].minor.yy722); } -#line 7191 "sql.c" - break; - case 358: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ -#line 634 "sql.y" -{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy897, &yymsp[-3].minor.yy659, &yymsp[0].minor.yy659, yymsp[-2].minor.yy830); } -#line 7196 "sql.c" - break; - case 359: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ -#line 636 "sql.y" -{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-5].minor.yy897, &yymsp[-4].minor.yy659, yymsp[-1].minor.yy722, yymsp[-3].minor.yy830, yymsp[0].minor.yy722); } -#line 7201 "sql.c" - break; - case 360: /* cmd ::= DROP TOPIC exists_opt topic_name */ -#line 638 "sql.y" -{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy897, &yymsp[0].minor.yy659); } -#line 7206 "sql.c" - break; - case 361: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ -#line 639 "sql.y" -{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy897, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy659); } -#line 7211 "sql.c" - break; - case 362: /* cmd ::= DESC full_table_name */ - case 363: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==363); -#line 642 "sql.y" -{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy722); } -#line 7217 "sql.c" - break; - case 364: /* cmd ::= RESET QUERY CACHE */ -#line 646 "sql.y" -{ pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } -#line 7222 "sql.c" - break; - case 365: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ - case 366: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==366); -#line 649 "sql.y" -{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy897, yymsp[-1].minor.yy722, yymsp[0].minor.yy722); } -#line 7228 "sql.c" - break; - case 369: /* explain_options ::= */ -#line 657 "sql.y" -{ yymsp[1].minor.yy722 = createDefaultExplainOptions(pCxt); } -#line 7233 "sql.c" - break; - case 370: /* explain_options ::= explain_options VERBOSE NK_BOOL */ -#line 658 "sql.y" -{ yylhsminor.yy722 = setExplainVerbose(pCxt, yymsp[-2].minor.yy722, &yymsp[0].minor.yy0); } + case 357: /* sma_stream_opt ::= */ + case 407: /* stream_options ::= */ yytestcase(yyruleno==407); +#line 637 "sql.y" +{ yymsp[1].minor.yy826 = createStreamOptions(pCxt); } #line 7238 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; break; - case 371: /* explain_options ::= explain_options RATIO NK_FLOAT */ -#line 659 "sql.y" -{ yylhsminor.yy722 = setExplainRatio(pCxt, yymsp[-2].minor.yy722, &yymsp[0].minor.yy0); } -#line 7244 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + case 358: /* sma_stream_opt ::= sma_stream_opt WATERMARK duration_literal */ +#line 638 "sql.y" +{ ((SStreamOptions*)yymsp[-2].minor.yy826)->pWatermark = releaseRawExprNode(pCxt, yymsp[0].minor.yy826); yylhsminor.yy826 = yymsp[-2].minor.yy826; } +#line 7243 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 372: /* 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 664 "sql.y" -{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy897, yymsp[-9].minor.yy897, &yymsp[-6].minor.yy659, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy154, yymsp[-1].minor.yy830, &yymsp[0].minor.yy659, yymsp[-10].minor.yy897); } -#line 7250 "sql.c" + case 359: /* sma_stream_opt ::= sma_stream_opt MAX_DELAY duration_literal */ +#line 639 "sql.y" +{ ((SStreamOptions*)yymsp[-2].minor.yy826)->pDelay = releaseRawExprNode(pCxt, yymsp[0].minor.yy826); yylhsminor.yy826 = yymsp[-2].minor.yy826; } +#line 7249 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 373: /* cmd ::= DROP FUNCTION exists_opt function_name */ -#line 665 "sql.y" -{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy897, &yymsp[0].minor.yy659); } + case 360: /* sma_stream_opt ::= sma_stream_opt DELETE_MARK duration_literal */ +#line 640 "sql.y" +{ ((SStreamOptions*)yymsp[-2].minor.yy826)->pDeleteMark = releaseRawExprNode(pCxt, yymsp[0].minor.yy826); yylhsminor.yy826 = yymsp[-2].minor.yy826; } #line 7255 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 378: /* language_opt ::= */ - case 422: /* on_vgroup_id ::= */ yytestcase(yyruleno==422); -#line 679 "sql.y" -{ yymsp[1].minor.yy659 = nil_token; } + case 361: /* with_meta ::= AS */ +#line 645 "sql.y" +{ yymsp[0].minor.yy462 = 0; } #line 7261 "sql.c" break; - case 379: /* language_opt ::= LANGUAGE NK_STRING */ - case 423: /* on_vgroup_id ::= ON NK_INTEGER */ yytestcase(yyruleno==423); -#line 680 "sql.y" -{ yymsp[-1].minor.yy659 = yymsp[0].minor.yy0; } -#line 7267 "sql.c" + case 362: /* with_meta ::= WITH META AS */ +#line 646 "sql.y" +{ yymsp[-2].minor.yy462 = 1; } +#line 7266 "sql.c" break; - case 382: /* cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ -#line 689 "sql.y" -{ pCxt->pRootNode = createCreateViewStmt(pCxt, yymsp[-4].minor.yy897, yymsp[-2].minor.yy722, &yymsp[-1].minor.yy0, yymsp[0].minor.yy722); } -#line 7272 "sql.c" + case 363: /* with_meta ::= ONLY META AS */ +#line 647 "sql.y" +{ yymsp[-2].minor.yy462 = 2; } +#line 7271 "sql.c" break; - case 383: /* cmd ::= DROP VIEW exists_opt full_view_name */ -#line 690 "sql.y" -{ pCxt->pRootNode = createDropViewStmt(pCxt, yymsp[-1].minor.yy897, yymsp[0].minor.yy722); } -#line 7277 "sql.c" + case 364: /* cmd ::= CREATE TOPIC not_exists_opt topic_name AS query_or_subquery */ +#line 649 "sql.y" +{ pCxt->pRootNode = createCreateTopicStmtUseQuery(pCxt, yymsp[-3].minor.yy983, &yymsp[-2].minor.yy585, yymsp[0].minor.yy826); } +#line 7276 "sql.c" break; - case 384: /* full_view_name ::= view_name */ -#line 692 "sql.y" -{ yylhsminor.yy722 = createViewNode(pCxt, NULL, &yymsp[0].minor.yy659); } -#line 7282 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; + case 365: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta DATABASE db_name */ +#line 651 "sql.y" +{ pCxt->pRootNode = createCreateTopicStmtUseDb(pCxt, yymsp[-4].minor.yy983, &yymsp[-3].minor.yy585, &yymsp[0].minor.yy585, yymsp[-2].minor.yy462); } +#line 7281 "sql.c" break; - case 385: /* full_view_name ::= db_name NK_DOT view_name */ -#line 693 "sql.y" -{ yylhsminor.yy722 = createViewNode(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy659); } -#line 7288 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + case 366: /* cmd ::= CREATE TOPIC not_exists_opt topic_name with_meta STABLE full_table_name where_clause_opt */ +#line 653 "sql.y" +{ pCxt->pRootNode = createCreateTopicStmtUseTable(pCxt, yymsp[-5].minor.yy983, &yymsp[-4].minor.yy585, yymsp[-1].minor.yy826, yymsp[-3].minor.yy462, yymsp[0].minor.yy826); } +#line 7286 "sql.c" break; - case 386: /* 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 698 "sql.y" -{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-9].minor.yy897, &yymsp[-8].minor.yy659, yymsp[-5].minor.yy722, yymsp[-7].minor.yy722, yymsp[-3].minor.yy694, yymsp[-2].minor.yy722, yymsp[0].minor.yy722, yymsp[-4].minor.yy694); } -#line 7294 "sql.c" + case 367: /* cmd ::= DROP TOPIC exists_opt topic_name */ +#line 655 "sql.y" +{ pCxt->pRootNode = createDropTopicStmt(pCxt, yymsp[-1].minor.yy983, &yymsp[0].minor.yy585); } +#line 7291 "sql.c" break; - case 387: /* cmd ::= DROP STREAM exists_opt stream_name */ -#line 699 "sql.y" -{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy897, &yymsp[0].minor.yy659); } -#line 7299 "sql.c" + case 368: /* cmd ::= DROP CONSUMER GROUP exists_opt cgroup_name ON topic_name */ +#line 656 "sql.y" +{ pCxt->pRootNode = createDropCGroupStmt(pCxt, yymsp[-3].minor.yy983, &yymsp[-2].minor.yy585, &yymsp[0].minor.yy585); } +#line 7296 "sql.c" break; - case 388: /* cmd ::= PAUSE STREAM exists_opt stream_name */ -#line 700 "sql.y" -{ pCxt->pRootNode = createPauseStreamStmt(pCxt, yymsp[-1].minor.yy897, &yymsp[0].minor.yy659); } -#line 7304 "sql.c" + case 369: /* cmd ::= DESC full_table_name */ + case 370: /* cmd ::= DESCRIBE full_table_name */ yytestcase(yyruleno==370); +#line 659 "sql.y" +{ pCxt->pRootNode = createDescribeStmt(pCxt, yymsp[0].minor.yy826); } +#line 7302 "sql.c" break; - case 389: /* cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ -#line 701 "sql.y" -{ pCxt->pRootNode = createResumeStreamStmt(pCxt, yymsp[-2].minor.yy897, yymsp[-1].minor.yy897, &yymsp[0].minor.yy659); } -#line 7309 "sql.c" + case 371: /* cmd ::= RESET QUERY CACHE */ +#line 663 "sql.y" +{ pCxt->pRootNode = createResetQueryCacheStmt(pCxt); } +#line 7307 "sql.c" break; - case 394: /* column_stream_def ::= column_name stream_col_options */ -#line 714 "sql.y" -{ yylhsminor.yy722 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy659, createDataType(TSDB_DATA_TYPE_NULL), yymsp[0].minor.yy722); } -#line 7314 "sql.c" - yymsp[-1].minor.yy722 = yylhsminor.yy722; + case 372: /* cmd ::= EXPLAIN analyze_opt explain_options query_or_subquery */ + case 373: /* cmd ::= EXPLAIN analyze_opt explain_options insert_query */ yytestcase(yyruleno==373); +#line 666 "sql.y" +{ pCxt->pRootNode = createExplainStmt(pCxt, yymsp[-2].minor.yy983, yymsp[-1].minor.yy826, yymsp[0].minor.yy826); } +#line 7313 "sql.c" break; - case 395: /* stream_col_options ::= */ - case 730: /* column_options ::= */ yytestcase(yyruleno==730); -#line 715 "sql.y" -{ yymsp[1].minor.yy722 = createDefaultColumnOptions(pCxt); } -#line 7321 "sql.c" + case 376: /* explain_options ::= */ +#line 674 "sql.y" +{ yymsp[1].minor.yy826 = createDefaultExplainOptions(pCxt); } +#line 7318 "sql.c" break; - case 396: /* stream_col_options ::= stream_col_options PRIMARY KEY */ - case 731: /* column_options ::= column_options PRIMARY KEY */ yytestcase(yyruleno==731); -#line 716 "sql.y" -{ yylhsminor.yy722 = setColumnOptions(pCxt, yymsp[-2].minor.yy722, COLUMN_OPTION_PRIMARYKEY, NULL); } -#line 7327 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + case 377: /* explain_options ::= explain_options VERBOSE NK_BOOL */ +#line 675 "sql.y" +{ yylhsminor.yy826 = setExplainVerbose(pCxt, yymsp[-2].minor.yy826, &yymsp[0].minor.yy0); } +#line 7323 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 401: /* stream_options ::= stream_options TRIGGER AT_ONCE */ - case 402: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==402); -#line 726 "sql.y" -{ yylhsminor.yy722 = setStreamOptions(pCxt, yymsp[-2].minor.yy722, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } -#line 7334 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + case 378: /* explain_options ::= explain_options RATIO NK_FLOAT */ +#line 676 "sql.y" +{ yylhsminor.yy826 = setExplainRatio(pCxt, yymsp[-2].minor.yy826, &yymsp[0].minor.yy0); } +#line 7329 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 403: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ -#line 728 "sql.y" -{ yylhsminor.yy722 = setStreamOptions(pCxt, yymsp[-3].minor.yy722, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy722)); } + case 379: /* 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 681 "sql.y" +{ pCxt->pRootNode = createCreateFunctionStmt(pCxt, yymsp[-7].minor.yy983, yymsp[-9].minor.yy983, &yymsp[-6].minor.yy585, &yymsp[-4].minor.yy0, yymsp[-2].minor.yy146, yymsp[-1].minor.yy462, &yymsp[0].minor.yy585, yymsp[-10].minor.yy983); } +#line 7335 "sql.c" + break; + case 380: /* cmd ::= DROP FUNCTION exists_opt function_name */ +#line 682 "sql.y" +{ pCxt->pRootNode = createDropFunctionStmt(pCxt, yymsp[-1].minor.yy983, &yymsp[0].minor.yy585); } #line 7340 "sql.c" - yymsp[-3].minor.yy722 = yylhsminor.yy722; break; - case 404: /* stream_options ::= stream_options WATERMARK duration_literal */ -#line 729 "sql.y" -{ yylhsminor.yy722 = setStreamOptions(pCxt, yymsp[-2].minor.yy722, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy722)); } + case 385: /* language_opt ::= */ + case 429: /* on_vgroup_id ::= */ yytestcase(yyruleno==429); +#line 696 "sql.y" +{ yymsp[1].minor.yy585 = nil_token; } #line 7346 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; break; - case 405: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ -#line 730 "sql.y" -{ yylhsminor.yy722 = setStreamOptions(pCxt, yymsp[-3].minor.yy722, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } + case 386: /* language_opt ::= LANGUAGE NK_STRING */ + case 430: /* on_vgroup_id ::= ON NK_INTEGER */ yytestcase(yyruleno==430); +#line 697 "sql.y" +{ yymsp[-1].minor.yy585 = yymsp[0].minor.yy0; } #line 7352 "sql.c" - yymsp[-3].minor.yy722 = yylhsminor.yy722; break; - case 406: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ + case 389: /* cmd ::= CREATE or_replace_opt VIEW full_view_name AS query_or_subquery */ +#line 706 "sql.y" +{ pCxt->pRootNode = createCreateViewStmt(pCxt, yymsp[-4].minor.yy983, yymsp[-2].minor.yy826, &yymsp[-1].minor.yy0, yymsp[0].minor.yy826); } +#line 7357 "sql.c" + break; + case 390: /* cmd ::= DROP VIEW exists_opt full_view_name */ +#line 707 "sql.y" +{ pCxt->pRootNode = createDropViewStmt(pCxt, yymsp[-1].minor.yy983, yymsp[0].minor.yy826); } +#line 7362 "sql.c" + break; + case 391: /* full_view_name ::= view_name */ +#line 709 "sql.y" +{ yylhsminor.yy826 = createViewNode(pCxt, NULL, &yymsp[0].minor.yy585); } +#line 7367 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; + break; + case 392: /* full_view_name ::= db_name NK_DOT view_name */ +#line 710 "sql.y" +{ yylhsminor.yy826 = createViewNode(pCxt, &yymsp[-2].minor.yy585, &yymsp[0].minor.yy585); } +#line 7373 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; + break; + case 393: /* 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 715 "sql.y" +{ pCxt->pRootNode = createCreateStreamStmt(pCxt, yymsp[-9].minor.yy983, &yymsp[-8].minor.yy585, yymsp[-5].minor.yy826, yymsp[-7].minor.yy826, yymsp[-3].minor.yy616, yymsp[-2].minor.yy826, yymsp[0].minor.yy826, yymsp[-4].minor.yy616); } +#line 7379 "sql.c" + break; + case 394: /* cmd ::= DROP STREAM exists_opt stream_name */ +#line 716 "sql.y" +{ pCxt->pRootNode = createDropStreamStmt(pCxt, yymsp[-1].minor.yy983, &yymsp[0].minor.yy585); } +#line 7384 "sql.c" + break; + case 395: /* cmd ::= PAUSE STREAM exists_opt stream_name */ +#line 717 "sql.y" +{ pCxt->pRootNode = createPauseStreamStmt(pCxt, yymsp[-1].minor.yy983, &yymsp[0].minor.yy585); } +#line 7389 "sql.c" + break; + case 396: /* cmd ::= RESUME STREAM exists_opt ignore_opt stream_name */ +#line 718 "sql.y" +{ pCxt->pRootNode = createResumeStreamStmt(pCxt, yymsp[-2].minor.yy983, yymsp[-1].minor.yy983, &yymsp[0].minor.yy585); } +#line 7394 "sql.c" + break; + case 401: /* column_stream_def ::= column_name stream_col_options */ #line 731 "sql.y" -{ yylhsminor.yy722 = setStreamOptions(pCxt, yymsp[-2].minor.yy722, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } -#line 7358 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createColumnDefNode(pCxt, &yymsp[-1].minor.yy585, createDataType(TSDB_DATA_TYPE_NULL), yymsp[0].minor.yy826); } +#line 7399 "sql.c" + yymsp[-1].minor.yy826 = yylhsminor.yy826; break; - case 407: /* stream_options ::= stream_options DELETE_MARK duration_literal */ + case 402: /* stream_col_options ::= */ + case 738: /* column_options ::= */ yytestcase(yyruleno==738); #line 732 "sql.y" -{ yylhsminor.yy722 = setStreamOptions(pCxt, yymsp[-2].minor.yy722, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy722)); } -#line 7364 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yymsp[1].minor.yy826 = createDefaultColumnOptions(pCxt); } +#line 7406 "sql.c" break; - case 408: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ + case 403: /* stream_col_options ::= stream_col_options PRIMARY KEY */ + case 739: /* column_options ::= column_options PRIMARY KEY */ yytestcase(yyruleno==739); #line 733 "sql.y" -{ yylhsminor.yy722 = setStreamOptions(pCxt, yymsp[-3].minor.yy722, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } -#line 7370 "sql.c" - yymsp[-3].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = setColumnOptions(pCxt, yymsp[-2].minor.yy826, COLUMN_OPTION_PRIMARYKEY, NULL); } +#line 7412 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 410: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ - case 674: /* sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ yytestcase(yyruleno==674); - case 698: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==698); -#line 736 "sql.y" -{ yymsp[-3].minor.yy722 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy722); } -#line 7378 "sql.c" + case 408: /* stream_options ::= stream_options TRIGGER AT_ONCE */ + case 409: /* stream_options ::= stream_options TRIGGER WINDOW_CLOSE */ yytestcase(yyruleno==409); +#line 743 "sql.y" +{ yylhsminor.yy826 = setStreamOptions(pCxt, yymsp[-2].minor.yy826, SOPT_TRIGGER_TYPE_SET, &yymsp[0].minor.yy0, NULL); } +#line 7419 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 413: /* cmd ::= KILL CONNECTION NK_INTEGER */ -#line 744 "sql.y" -{ pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } -#line 7383 "sql.c" - break; - case 414: /* cmd ::= KILL QUERY NK_STRING */ + case 410: /* stream_options ::= stream_options TRIGGER MAX_DELAY duration_literal */ #line 745 "sql.y" -{ pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } -#line 7388 "sql.c" +{ yylhsminor.yy826 = setStreamOptions(pCxt, yymsp[-3].minor.yy826, SOPT_TRIGGER_TYPE_SET, &yymsp[-1].minor.yy0, releaseRawExprNode(pCxt, yymsp[0].minor.yy826)); } +#line 7425 "sql.c" + yymsp[-3].minor.yy826 = yylhsminor.yy826; break; - case 415: /* cmd ::= KILL TRANSACTION NK_INTEGER */ + case 411: /* stream_options ::= stream_options WATERMARK duration_literal */ #line 746 "sql.y" -{ pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } -#line 7393 "sql.c" +{ yylhsminor.yy826 = setStreamOptions(pCxt, yymsp[-2].minor.yy826, SOPT_WATERMARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy826)); } +#line 7431 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 416: /* cmd ::= KILL COMPACT NK_INTEGER */ + case 412: /* stream_options ::= stream_options IGNORE EXPIRED NK_INTEGER */ #line 747 "sql.y" -{ pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_COMPACT_STMT, &yymsp[0].minor.yy0); } -#line 7398 "sql.c" +{ yylhsminor.yy826 = setStreamOptions(pCxt, yymsp[-3].minor.yy826, SOPT_IGNORE_EXPIRED_SET, &yymsp[0].minor.yy0, NULL); } +#line 7437 "sql.c" + yymsp[-3].minor.yy826 = yylhsminor.yy826; break; - case 417: /* cmd ::= BALANCE VGROUP */ -#line 750 "sql.y" -{ pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } -#line 7403 "sql.c" - break; - case 418: /* cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ -#line 751 "sql.y" -{ pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &yymsp[0].minor.yy659); } -#line 7408 "sql.c" - break; - case 419: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ -#line 752 "sql.y" -{ pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } -#line 7413 "sql.c" - break; - case 420: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ -#line 753 "sql.y" -{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy694); } -#line 7418 "sql.c" - break; - case 421: /* cmd ::= SPLIT VGROUP NK_INTEGER */ -#line 754 "sql.y" -{ pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } -#line 7423 "sql.c" - break; - case 424: /* dnode_list ::= DNODE NK_INTEGER */ -#line 763 "sql.y" -{ yymsp[-1].minor.yy694 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } -#line 7428 "sql.c" - break; - case 426: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ -#line 770 "sql.y" -{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy722, yymsp[0].minor.yy722); } -#line 7433 "sql.c" - break; - case 429: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ -#line 779 "sql.y" -{ yymsp[-6].minor.yy722 = createInsertStmt(pCxt, yymsp[-4].minor.yy722, yymsp[-2].minor.yy694, yymsp[0].minor.yy722); } -#line 7438 "sql.c" - break; - case 430: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ -#line 780 "sql.y" -{ yymsp[-3].minor.yy722 = createInsertStmt(pCxt, yymsp[-1].minor.yy722, NULL, yymsp[0].minor.yy722); } + case 413: /* stream_options ::= stream_options FILL_HISTORY NK_INTEGER */ +#line 748 "sql.y" +{ yylhsminor.yy826 = setStreamOptions(pCxt, yymsp[-2].minor.yy826, SOPT_FILL_HISTORY_SET, &yymsp[0].minor.yy0, NULL); } #line 7443 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 431: /* tags_literal ::= NK_INTEGER */ - case 443: /* tags_literal ::= NK_BIN */ yytestcase(yyruleno==443); - case 452: /* tags_literal ::= NK_HEX */ yytestcase(yyruleno==452); -#line 783 "sql.y" -{ yylhsminor.yy722 = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0, NULL); } -#line 7450 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; + case 414: /* stream_options ::= stream_options DELETE_MARK duration_literal */ +#line 749 "sql.y" +{ yylhsminor.yy826 = setStreamOptions(pCxt, yymsp[-2].minor.yy826, SOPT_DELETE_MARK_SET, NULL, releaseRawExprNode(pCxt, yymsp[0].minor.yy826)); } +#line 7449 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 432: /* tags_literal ::= NK_INTEGER NK_PLUS duration_literal */ - case 433: /* tags_literal ::= NK_INTEGER NK_MINUS duration_literal */ yytestcase(yyruleno==433); - case 444: /* tags_literal ::= NK_BIN NK_PLUS duration_literal */ yytestcase(yyruleno==444); - case 445: /* tags_literal ::= NK_BIN NK_MINUS duration_literal */ yytestcase(yyruleno==445); - case 453: /* tags_literal ::= NK_HEX NK_PLUS duration_literal */ yytestcase(yyruleno==453); - case 454: /* tags_literal ::= NK_HEX NK_MINUS duration_literal */ yytestcase(yyruleno==454); - case 462: /* tags_literal ::= NK_STRING NK_PLUS duration_literal */ yytestcase(yyruleno==462); - case 463: /* tags_literal ::= NK_STRING NK_MINUS duration_literal */ yytestcase(yyruleno==463); -#line 784 "sql.y" -{ - SToken l = yymsp[-2].minor.yy0; - SToken r = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy722); - l.n = (r.z + r.n) - l.z; - yylhsminor.yy722 = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, yymsp[0].minor.yy722); - } + case 415: /* stream_options ::= stream_options IGNORE UPDATE NK_INTEGER */ +#line 750 "sql.y" +{ yylhsminor.yy826 = setStreamOptions(pCxt, yymsp[-3].minor.yy826, SOPT_IGNORE_UPDATE_SET, &yymsp[0].minor.yy0, NULL); } +#line 7455 "sql.c" + yymsp[-3].minor.yy826 = yylhsminor.yy826; + break; + case 417: /* subtable_opt ::= SUBTABLE NK_LP expression NK_RP */ + case 682: /* sliding_opt ::= SLIDING NK_LP interval_sliding_duration_literal NK_RP */ yytestcase(yyruleno==682); + case 706: /* every_opt ::= EVERY NK_LP duration_literal NK_RP */ yytestcase(yyruleno==706); +#line 753 "sql.y" +{ yymsp[-3].minor.yy826 = releaseRawExprNode(pCxt, yymsp[-1].minor.yy826); } +#line 7463 "sql.c" + break; + case 420: /* cmd ::= KILL CONNECTION NK_INTEGER */ +#line 761 "sql.y" +{ pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_CONNECTION_STMT, &yymsp[0].minor.yy0); } #line 7468 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; break; - case 434: /* tags_literal ::= NK_PLUS NK_INTEGER */ - case 437: /* tags_literal ::= NK_MINUS NK_INTEGER */ yytestcase(yyruleno==437); - case 446: /* tags_literal ::= NK_PLUS NK_BIN */ yytestcase(yyruleno==446); - case 449: /* tags_literal ::= NK_MINUS NK_BIN */ yytestcase(yyruleno==449); - case 455: /* tags_literal ::= NK_PLUS NK_HEX */ yytestcase(yyruleno==455); - case 458: /* tags_literal ::= NK_MINUS NK_HEX */ yytestcase(yyruleno==458); -#line 796 "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.yy722 = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL); - } + case 421: /* cmd ::= KILL QUERY NK_STRING */ +#line 762 "sql.y" +{ pCxt->pRootNode = createKillQueryStmt(pCxt, &yymsp[0].minor.yy0); } +#line 7473 "sql.c" + break; + case 422: /* cmd ::= KILL TRANSACTION NK_INTEGER */ +#line 763 "sql.y" +{ pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_TRANSACTION_STMT, &yymsp[0].minor.yy0); } +#line 7478 "sql.c" + break; + case 423: /* cmd ::= KILL COMPACT NK_INTEGER */ +#line 764 "sql.y" +{ pCxt->pRootNode = createKillStmt(pCxt, QUERY_NODE_KILL_COMPACT_STMT, &yymsp[0].minor.yy0); } #line 7483 "sql.c" - yymsp[-1].minor.yy722 = yylhsminor.yy722; break; - case 435: /* tags_literal ::= NK_PLUS NK_INTEGER NK_PLUS duration_literal */ - case 436: /* tags_literal ::= NK_PLUS NK_INTEGER NK_MINUS duration_literal */ yytestcase(yyruleno==436); - case 438: /* tags_literal ::= NK_MINUS NK_INTEGER NK_PLUS duration_literal */ yytestcase(yyruleno==438); - case 439: /* tags_literal ::= NK_MINUS NK_INTEGER NK_MINUS duration_literal */ yytestcase(yyruleno==439); - case 447: /* tags_literal ::= NK_PLUS NK_BIN NK_PLUS duration_literal */ yytestcase(yyruleno==447); - case 448: /* tags_literal ::= NK_PLUS NK_BIN NK_MINUS duration_literal */ yytestcase(yyruleno==448); - case 450: /* tags_literal ::= NK_MINUS NK_BIN NK_PLUS duration_literal */ yytestcase(yyruleno==450); - case 451: /* tags_literal ::= NK_MINUS NK_BIN NK_MINUS duration_literal */ yytestcase(yyruleno==451); - case 456: /* tags_literal ::= NK_PLUS NK_HEX NK_PLUS duration_literal */ yytestcase(yyruleno==456); - case 457: /* tags_literal ::= NK_PLUS NK_HEX NK_MINUS duration_literal */ yytestcase(yyruleno==457); - case 459: /* tags_literal ::= NK_MINUS NK_HEX NK_PLUS duration_literal */ yytestcase(yyruleno==459); - case 460: /* tags_literal ::= NK_MINUS NK_HEX NK_MINUS duration_literal */ yytestcase(yyruleno==460); + case 424: /* cmd ::= BALANCE VGROUP */ +#line 767 "sql.y" +{ pCxt->pRootNode = createBalanceVgroupStmt(pCxt); } +#line 7488 "sql.c" + break; + case 425: /* cmd ::= BALANCE VGROUP LEADER on_vgroup_id */ +#line 768 "sql.y" +{ pCxt->pRootNode = createBalanceVgroupLeaderStmt(pCxt, &yymsp[0].minor.yy585); } +#line 7493 "sql.c" + break; + case 426: /* cmd ::= MERGE VGROUP NK_INTEGER NK_INTEGER */ +#line 769 "sql.y" +{ pCxt->pRootNode = createMergeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0); } +#line 7498 "sql.c" + break; + case 427: /* cmd ::= REDISTRIBUTE VGROUP NK_INTEGER dnode_list */ +#line 770 "sql.y" +{ pCxt->pRootNode = createRedistributeVgroupStmt(pCxt, &yymsp[-1].minor.yy0, yymsp[0].minor.yy616); } +#line 7503 "sql.c" + break; + case 428: /* cmd ::= SPLIT VGROUP NK_INTEGER */ +#line 771 "sql.y" +{ pCxt->pRootNode = createSplitVgroupStmt(pCxt, &yymsp[0].minor.yy0); } +#line 7508 "sql.c" + break; + case 431: /* dnode_list ::= DNODE NK_INTEGER */ +#line 780 "sql.y" +{ yymsp[-1].minor.yy616 = createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &yymsp[0].minor.yy0)); } +#line 7513 "sql.c" + break; + case 433: /* cmd ::= DELETE FROM full_table_name where_clause_opt */ +#line 787 "sql.y" +{ pCxt->pRootNode = createDeleteStmt(pCxt, yymsp[-1].minor.yy826, yymsp[0].minor.yy826); } +#line 7518 "sql.c" + break; + case 436: /* insert_query ::= INSERT INTO full_table_name NK_LP col_name_list NK_RP query_or_subquery */ +#line 796 "sql.y" +{ yymsp[-6].minor.yy826 = createInsertStmt(pCxt, yymsp[-4].minor.yy826, yymsp[-2].minor.yy616, yymsp[0].minor.yy826); } +#line 7523 "sql.c" + break; + case 437: /* insert_query ::= INSERT INTO full_table_name query_or_subquery */ +#line 797 "sql.y" +{ yymsp[-3].minor.yy826 = createInsertStmt(pCxt, yymsp[-1].minor.yy826, NULL, yymsp[0].minor.yy826); } +#line 7528 "sql.c" + break; + case 438: /* tags_literal ::= NK_INTEGER */ + case 450: /* tags_literal ::= NK_BIN */ yytestcase(yyruleno==450); + case 459: /* tags_literal ::= NK_HEX */ yytestcase(yyruleno==459); +#line 800 "sql.y" +{ yylhsminor.yy826 = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0, NULL); } +#line 7535 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; + break; + case 439: /* tags_literal ::= NK_INTEGER NK_PLUS duration_literal */ + case 440: /* tags_literal ::= NK_INTEGER NK_MINUS duration_literal */ yytestcase(yyruleno==440); + case 451: /* tags_literal ::= NK_BIN NK_PLUS duration_literal */ yytestcase(yyruleno==451); + case 452: /* tags_literal ::= NK_BIN NK_MINUS duration_literal */ yytestcase(yyruleno==452); + case 460: /* tags_literal ::= NK_HEX NK_PLUS duration_literal */ yytestcase(yyruleno==460); + case 461: /* tags_literal ::= NK_HEX NK_MINUS duration_literal */ yytestcase(yyruleno==461); + case 469: /* tags_literal ::= NK_STRING NK_PLUS duration_literal */ yytestcase(yyruleno==469); + case 470: /* tags_literal ::= NK_STRING NK_MINUS duration_literal */ yytestcase(yyruleno==470); #line 801 "sql.y" { - SToken l = yymsp[-3].minor.yy0; - SToken r = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy722); + SToken l = yymsp[-2].minor.yy0; + SToken r = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy826); l.n = (r.z + r.n) - l.z; - yylhsminor.yy722 = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, yymsp[0].minor.yy722); + yylhsminor.yy826 = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, yymsp[0].minor.yy826); } -#line 7505 "sql.c" - yymsp[-3].minor.yy722 = yylhsminor.yy722; +#line 7553 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 440: /* tags_literal ::= NK_FLOAT */ -#line 830 "sql.y" -{ yylhsminor.yy722 = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0, NULL); } -#line 7511 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; - break; - case 441: /* tags_literal ::= NK_PLUS NK_FLOAT */ - case 442: /* tags_literal ::= NK_MINUS NK_FLOAT */ yytestcase(yyruleno==442); -#line 831 "sql.y" + case 441: /* tags_literal ::= NK_PLUS NK_INTEGER */ + case 444: /* tags_literal ::= NK_MINUS NK_INTEGER */ yytestcase(yyruleno==444); + case 453: /* tags_literal ::= NK_PLUS NK_BIN */ yytestcase(yyruleno==453); + case 456: /* tags_literal ::= NK_MINUS NK_BIN */ yytestcase(yyruleno==456); + case 462: /* tags_literal ::= NK_PLUS NK_HEX */ yytestcase(yyruleno==462); + case 465: /* tags_literal ::= NK_MINUS NK_HEX */ yytestcase(yyruleno==465); +#line 813 "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.yy722 = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t, NULL); + yylhsminor.yy826 = createRawValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &t, NULL); } -#line 7522 "sql.c" - yymsp[-1].minor.yy722 = yylhsminor.yy722; +#line 7568 "sql.c" + yymsp[-1].minor.yy826 = yylhsminor.yy826; break; - case 461: /* tags_literal ::= NK_STRING */ -#line 937 "sql.y" -{ yylhsminor.yy722 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0, NULL); } -#line 7528 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; + case 442: /* tags_literal ::= NK_PLUS NK_INTEGER NK_PLUS duration_literal */ + case 443: /* tags_literal ::= NK_PLUS NK_INTEGER NK_MINUS duration_literal */ yytestcase(yyruleno==443); + case 445: /* tags_literal ::= NK_MINUS NK_INTEGER NK_PLUS duration_literal */ yytestcase(yyruleno==445); + case 446: /* tags_literal ::= NK_MINUS NK_INTEGER NK_MINUS duration_literal */ yytestcase(yyruleno==446); + case 454: /* tags_literal ::= NK_PLUS NK_BIN NK_PLUS duration_literal */ yytestcase(yyruleno==454); + case 455: /* tags_literal ::= NK_PLUS NK_BIN NK_MINUS duration_literal */ yytestcase(yyruleno==455); + case 457: /* tags_literal ::= NK_MINUS NK_BIN NK_PLUS duration_literal */ yytestcase(yyruleno==457); + case 458: /* tags_literal ::= NK_MINUS NK_BIN NK_MINUS duration_literal */ yytestcase(yyruleno==458); + case 463: /* tags_literal ::= NK_PLUS NK_HEX NK_PLUS duration_literal */ yytestcase(yyruleno==463); + case 464: /* tags_literal ::= NK_PLUS NK_HEX NK_MINUS duration_literal */ yytestcase(yyruleno==464); + case 466: /* tags_literal ::= NK_MINUS NK_HEX NK_PLUS duration_literal */ yytestcase(yyruleno==466); + case 467: /* tags_literal ::= NK_MINUS NK_HEX NK_MINUS duration_literal */ yytestcase(yyruleno==467); +#line 818 "sql.y" +{ + SToken l = yymsp[-3].minor.yy0; + SToken r = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy826); + l.n = (r.z + r.n) - l.z; + yylhsminor.yy826 = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, NULL, yymsp[0].minor.yy826); + } +#line 7590 "sql.c" + yymsp[-3].minor.yy826 = yylhsminor.yy826; break; - case 464: /* tags_literal ::= NK_BOOL */ -#line 950 "sql.y" -{ yylhsminor.yy722 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0, NULL); } -#line 7534 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; + case 447: /* tags_literal ::= NK_FLOAT */ +#line 847 "sql.y" +{ yylhsminor.yy826 = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0, NULL); } +#line 7596 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; break; - case 465: /* tags_literal ::= NULL */ -#line 951 "sql.y" -{ yylhsminor.yy722 = createRawValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0, NULL); } -#line 7540 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; + case 448: /* tags_literal ::= NK_PLUS NK_FLOAT */ + case 449: /* tags_literal ::= NK_MINUS NK_FLOAT */ yytestcase(yyruleno==449); +#line 848 "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.yy826 = createRawValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t, NULL); + } +#line 7607 "sql.c" + yymsp[-1].minor.yy826 = yylhsminor.yy826; break; - case 466: /* tags_literal ::= literal_func */ -#line 953 "sql.y" -{ yylhsminor.yy722 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, NULL, yymsp[0].minor.yy722); } -#line 7546 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; - break; - case 467: /* tags_literal ::= literal_func NK_PLUS duration_literal */ - case 468: /* tags_literal ::= literal_func NK_MINUS duration_literal */ yytestcase(yyruleno==468); + case 468: /* tags_literal ::= NK_STRING */ #line 954 "sql.y" -{ - SToken l = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy722); - SToken r = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy722); - l.n = (r.z + r.n) - l.z; - yylhsminor.yy722 = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, yymsp[-2].minor.yy722, yymsp[0].minor.yy722); - } -#line 7558 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; - break; - case 471: /* literal ::= NK_INTEGER */ -#line 973 "sql.y" -{ yylhsminor.yy722 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } -#line 7564 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; - break; - case 472: /* literal ::= NK_FLOAT */ -#line 974 "sql.y" -{ yylhsminor.yy722 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } -#line 7570 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; - break; - case 473: /* literal ::= NK_STRING */ -#line 975 "sql.y" -{ yylhsminor.yy722 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } -#line 7576 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; - break; - case 474: /* literal ::= NK_BOOL */ -#line 976 "sql.y" -{ yylhsminor.yy722 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } -#line 7582 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; - break; - case 475: /* literal ::= TIMESTAMP NK_STRING */ -#line 977 "sql.y" -{ yylhsminor.yy722 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } -#line 7588 "sql.c" - yymsp[-1].minor.yy722 = yylhsminor.yy722; - break; - case 476: /* literal ::= duration_literal */ - case 486: /* signed_literal ::= signed */ yytestcase(yyruleno==486); - case 509: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==509); - case 510: /* expression ::= literal */ yytestcase(yyruleno==510); - case 512: /* expression ::= column_reference */ yytestcase(yyruleno==512); - case 513: /* expression ::= function_expression */ yytestcase(yyruleno==513); - case 514: /* expression ::= case_when_expression */ yytestcase(yyruleno==514); - case 548: /* function_expression ::= literal_func */ yytestcase(yyruleno==548); - case 598: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==598); - case 602: /* boolean_primary ::= predicate */ yytestcase(yyruleno==602); - case 604: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==604); - case 605: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==605); - case 608: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==608); - case 610: /* table_reference ::= table_primary */ yytestcase(yyruleno==610); - case 611: /* table_reference ::= joined_table */ yytestcase(yyruleno==611); - case 615: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==615); - case 700: /* query_simple ::= query_specification */ yytestcase(yyruleno==700); - case 701: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==701); - case 704: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==704); - case 706: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==706); -#line 978 "sql.y" -{ yylhsminor.yy722 = yymsp[0].minor.yy722; } +{ yylhsminor.yy826 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0, NULL); } #line 7613 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; + yymsp[0].minor.yy826 = yylhsminor.yy826; break; - case 477: /* literal ::= NULL */ -#line 979 "sql.y" -{ yylhsminor.yy722 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } + case 471: /* tags_literal ::= NK_BOOL */ +#line 967 "sql.y" +{ yylhsminor.yy826 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0, NULL); } #line 7619 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; + yymsp[0].minor.yy826 = yylhsminor.yy826; break; - case 478: /* literal ::= NK_QUESTION */ -#line 980 "sql.y" -{ yylhsminor.yy722 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } + case 472: /* tags_literal ::= NULL */ +#line 968 "sql.y" +{ yylhsminor.yy826 = createRawValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0, NULL); } #line 7625 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; + yymsp[0].minor.yy826 = yylhsminor.yy826; break; - case 479: /* duration_literal ::= NK_VARIABLE */ - case 675: /* interval_sliding_duration_literal ::= NK_VARIABLE */ yytestcase(yyruleno==675); - case 676: /* interval_sliding_duration_literal ::= NK_STRING */ yytestcase(yyruleno==676); - case 677: /* interval_sliding_duration_literal ::= NK_INTEGER */ yytestcase(yyruleno==677); -#line 982 "sql.y" -{ yylhsminor.yy722 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 7634 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; + case 473: /* tags_literal ::= literal_func */ +#line 970 "sql.y" +{ yylhsminor.yy826 = createRawValueNode(pCxt, TSDB_DATA_TYPE_BINARY, NULL, yymsp[0].minor.yy826); } +#line 7631 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; break; - case 480: /* signed ::= NK_INTEGER */ -#line 984 "sql.y" -{ yylhsminor.yy722 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } -#line 7640 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; - break; - case 481: /* signed ::= NK_PLUS NK_INTEGER */ -#line 985 "sql.y" -{ yymsp[-1].minor.yy722 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } -#line 7646 "sql.c" - break; - case 482: /* signed ::= NK_MINUS NK_INTEGER */ -#line 986 "sql.y" + case 474: /* tags_literal ::= literal_func NK_PLUS duration_literal */ + case 475: /* tags_literal ::= literal_func NK_MINUS duration_literal */ yytestcase(yyruleno==475); +#line 971 "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.yy722 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); + SToken l = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy826); + SToken r = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy826); + l.n = (r.z + r.n) - l.z; + yylhsminor.yy826 = createRawValueNodeExt(pCxt, TSDB_DATA_TYPE_BINARY, &l, yymsp[-2].minor.yy826, yymsp[0].minor.yy826); } -#line 7655 "sql.c" - yymsp[-1].minor.yy722 = yylhsminor.yy722; +#line 7643 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 483: /* signed ::= NK_FLOAT */ + case 478: /* literal ::= NK_INTEGER */ +#line 990 "sql.y" +{ yylhsminor.yy826 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0)); } +#line 7649 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; + break; + case 479: /* literal ::= NK_FLOAT */ #line 991 "sql.y" -{ yylhsminor.yy722 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } -#line 7661 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0)); } +#line 7655 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; break; - case 484: /* signed ::= NK_PLUS NK_FLOAT */ + case 480: /* literal ::= NK_STRING */ #line 992 "sql.y" -{ yymsp[-1].minor.yy722 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } -#line 7667 "sql.c" +{ yylhsminor.yy826 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0)); } +#line 7661 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; break; - case 485: /* signed ::= NK_MINUS NK_FLOAT */ + case 481: /* literal ::= NK_BOOL */ #line 993 "sql.y" +{ yylhsminor.yy826 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0)); } +#line 7667 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; + break; + case 482: /* literal ::= TIMESTAMP NK_STRING */ +#line 994 "sql.y" +{ yylhsminor.yy826 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0)); } +#line 7673 "sql.c" + yymsp[-1].minor.yy826 = yylhsminor.yy826; + break; + case 483: /* literal ::= duration_literal */ + case 493: /* signed_literal ::= signed */ yytestcase(yyruleno==493); + case 517: /* expr_or_subquery ::= expression */ yytestcase(yyruleno==517); + case 518: /* expression ::= literal */ yytestcase(yyruleno==518); + case 520: /* expression ::= column_reference */ yytestcase(yyruleno==520); + case 521: /* expression ::= function_expression */ yytestcase(yyruleno==521); + case 522: /* expression ::= case_when_expression */ yytestcase(yyruleno==522); + case 556: /* function_expression ::= literal_func */ yytestcase(yyruleno==556); + case 606: /* boolean_value_expression ::= boolean_primary */ yytestcase(yyruleno==606); + case 610: /* boolean_primary ::= predicate */ yytestcase(yyruleno==610); + case 612: /* common_expression ::= expr_or_subquery */ yytestcase(yyruleno==612); + case 613: /* common_expression ::= boolean_value_expression */ yytestcase(yyruleno==613); + case 616: /* table_reference_list ::= table_reference */ yytestcase(yyruleno==616); + case 618: /* table_reference ::= table_primary */ yytestcase(yyruleno==618); + case 619: /* table_reference ::= joined_table */ yytestcase(yyruleno==619); + case 623: /* table_primary ::= parenthesized_joined_table */ yytestcase(yyruleno==623); + case 708: /* query_simple ::= query_specification */ yytestcase(yyruleno==708); + case 709: /* query_simple ::= union_query_expression */ yytestcase(yyruleno==709); + case 712: /* query_simple_or_subquery ::= query_simple */ yytestcase(yyruleno==712); + case 714: /* query_or_subquery ::= query_expression */ yytestcase(yyruleno==714); +#line 995 "sql.y" +{ yylhsminor.yy826 = yymsp[0].minor.yy826; } +#line 7698 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; + break; + case 484: /* literal ::= NULL */ +#line 996 "sql.y" +{ yylhsminor.yy826 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0)); } +#line 7704 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; + break; + case 485: /* literal ::= NK_QUESTION */ +#line 997 "sql.y" +{ yylhsminor.yy826 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 7710 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; + break; + case 486: /* duration_literal ::= NK_VARIABLE */ + case 683: /* interval_sliding_duration_literal ::= NK_VARIABLE */ yytestcase(yyruleno==683); + case 684: /* interval_sliding_duration_literal ::= NK_STRING */ yytestcase(yyruleno==684); + case 685: /* interval_sliding_duration_literal ::= NK_INTEGER */ yytestcase(yyruleno==685); +#line 999 "sql.y" +{ yylhsminor.yy826 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createDurationValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 7719 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; + break; + case 487: /* signed ::= NK_INTEGER */ +#line 1001 "sql.y" +{ yylhsminor.yy826 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } +#line 7725 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; + break; + case 488: /* signed ::= NK_PLUS NK_INTEGER */ +#line 1002 "sql.y" +{ yymsp[-1].minor.yy826 = createValueNode(pCxt, TSDB_DATA_TYPE_UBIGINT, &yymsp[0].minor.yy0); } +#line 7731 "sql.c" + break; + case 489: /* signed ::= NK_MINUS NK_INTEGER */ +#line 1003 "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.yy722 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); + yylhsminor.yy826 = createValueNode(pCxt, TSDB_DATA_TYPE_BIGINT, &t); } -#line 7676 "sql.c" - yymsp[-1].minor.yy722 = yylhsminor.yy722; +#line 7740 "sql.c" + yymsp[-1].minor.yy826 = yylhsminor.yy826; break; - case 487: /* signed_literal ::= NK_STRING */ -#line 1000 "sql.y" -{ yylhsminor.yy722 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } -#line 7682 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; + case 490: /* signed ::= NK_FLOAT */ +#line 1008 "sql.y" +{ yylhsminor.yy826 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } +#line 7746 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; break; - case 488: /* signed_literal ::= NK_BOOL */ -#line 1001 "sql.y" -{ yylhsminor.yy722 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } -#line 7688 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; + case 491: /* signed ::= NK_PLUS NK_FLOAT */ +#line 1009 "sql.y" +{ yymsp[-1].minor.yy826 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &yymsp[0].minor.yy0); } +#line 7752 "sql.c" break; - case 489: /* signed_literal ::= TIMESTAMP NK_STRING */ -#line 1002 "sql.y" -{ yymsp[-1].minor.yy722 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } -#line 7694 "sql.c" - break; - case 490: /* signed_literal ::= duration_literal */ - case 492: /* signed_literal ::= literal_func */ yytestcase(yyruleno==492); - case 569: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==569); - case 652: /* select_item ::= common_expression */ yytestcase(yyruleno==652); - case 662: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==662); - case 705: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==705); - case 707: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==707); - case 720: /* search_condition ::= common_expression */ yytestcase(yyruleno==720); -#line 1003 "sql.y" -{ yylhsminor.yy722 = releaseRawExprNode(pCxt, yymsp[0].minor.yy722); } -#line 7706 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; - break; - case 491: /* signed_literal ::= NULL */ -#line 1004 "sql.y" -{ yylhsminor.yy722 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } -#line 7712 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; - break; - case 493: /* signed_literal ::= NK_QUESTION */ -#line 1006 "sql.y" -{ yylhsminor.yy722 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } -#line 7718 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; - break; - case 511: /* expression ::= pseudo_column */ -#line 1068 "sql.y" -{ yylhsminor.yy722 = yymsp[0].minor.yy722; setRawExprNodeIsPseudoColumn(pCxt, yylhsminor.yy722, true); } -#line 7724 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; - break; - case 515: /* expression ::= NK_LP expression NK_RP */ - case 603: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==603); - case 719: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==719); -#line 1072 "sql.y" -{ yylhsminor.yy722 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy722)); } -#line 7732 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; - break; - case 516: /* expression ::= NK_PLUS expr_or_subquery */ -#line 1073 "sql.y" + case 492: /* signed ::= NK_MINUS NK_FLOAT */ +#line 1010 "sql.y" { - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy722); - yylhsminor.yy722 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy722)); + SToken t = yymsp[-1].minor.yy0; + t.n = (yymsp[0].minor.yy0.z + yymsp[0].minor.yy0.n) - yymsp[-1].minor.yy0.z; + yylhsminor.yy826 = createValueNode(pCxt, TSDB_DATA_TYPE_DOUBLE, &t); } -#line 7741 "sql.c" - yymsp[-1].minor.yy722 = yylhsminor.yy722; +#line 7761 "sql.c" + yymsp[-1].minor.yy826 = yylhsminor.yy826; break; - case 517: /* expression ::= NK_MINUS expr_or_subquery */ -#line 1077 "sql.y" -{ - SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy722); - yylhsminor.yy722 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy722), NULL)); - } -#line 7750 "sql.c" - yymsp[-1].minor.yy722 = yylhsminor.yy722; + case 494: /* signed_literal ::= NK_STRING */ +#line 1017 "sql.y" +{ yylhsminor.yy826 = createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0); } +#line 7767 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; break; - case 518: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ -#line 1081 "sql.y" -{ - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy722); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy722); - yylhsminor.yy722 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy722), releaseRawExprNode(pCxt, yymsp[0].minor.yy722))); - } -#line 7760 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + case 495: /* signed_literal ::= NK_BOOL */ +#line 1018 "sql.y" +{ yylhsminor.yy826 = createValueNode(pCxt, TSDB_DATA_TYPE_BOOL, &yymsp[0].minor.yy0); } +#line 7773 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; break; - case 519: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ -#line 1086 "sql.y" -{ - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy722); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy722); - yylhsminor.yy722 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy722), releaseRawExprNode(pCxt, yymsp[0].minor.yy722))); - } -#line 7770 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + case 496: /* signed_literal ::= TIMESTAMP NK_STRING */ +#line 1019 "sql.y" +{ yymsp[-1].minor.yy826 = createValueNode(pCxt, TSDB_DATA_TYPE_TIMESTAMP, &yymsp[0].minor.yy0); } +#line 7779 "sql.c" break; - case 520: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ -#line 1091 "sql.y" -{ - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy722); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy722); - yylhsminor.yy722 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy722), releaseRawExprNode(pCxt, yymsp[0].minor.yy722))); - } -#line 7780 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + case 497: /* signed_literal ::= duration_literal */ + case 499: /* signed_literal ::= literal_func */ yytestcase(yyruleno==499); + case 577: /* star_func_para ::= expr_or_subquery */ yytestcase(yyruleno==577); + case 660: /* select_item ::= common_expression */ yytestcase(yyruleno==660); + case 670: /* partition_item ::= expr_or_subquery */ yytestcase(yyruleno==670); + case 713: /* query_simple_or_subquery ::= subquery */ yytestcase(yyruleno==713); + case 715: /* query_or_subquery ::= subquery */ yytestcase(yyruleno==715); + case 728: /* search_condition ::= common_expression */ yytestcase(yyruleno==728); +#line 1020 "sql.y" +{ yylhsminor.yy826 = releaseRawExprNode(pCxt, yymsp[0].minor.yy826); } +#line 7791 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; break; - case 521: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ -#line 1096 "sql.y" -{ - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy722); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy722); - yylhsminor.yy722 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy722), releaseRawExprNode(pCxt, yymsp[0].minor.yy722))); - } -#line 7790 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + case 498: /* signed_literal ::= NULL */ +#line 1021 "sql.y" +{ yylhsminor.yy826 = createValueNode(pCxt, TSDB_DATA_TYPE_NULL, &yymsp[0].minor.yy0); } +#line 7797 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; break; - case 522: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ -#line 1101 "sql.y" -{ - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy722); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy722); - yylhsminor.yy722 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy722), releaseRawExprNode(pCxt, yymsp[0].minor.yy722))); - } -#line 7800 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + case 500: /* signed_literal ::= NK_QUESTION */ +#line 1023 "sql.y" +{ yylhsminor.yy826 = createPlaceholderValueNode(pCxt, &yymsp[0].minor.yy0); } +#line 7803 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; break; - case 523: /* expression ::= column_reference NK_ARROW NK_STRING */ -#line 1106 "sql.y" -{ - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy722); - yylhsminor.yy722 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy722), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); - } + case 519: /* expression ::= pseudo_column */ +#line 1089 "sql.y" +{ yylhsminor.yy826 = yymsp[0].minor.yy826; setRawExprNodeIsPseudoColumn(pCxt, yylhsminor.yy826, true); } #line 7809 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + yymsp[0].minor.yy826 = yylhsminor.yy826; break; - case 524: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ -#line 1110 "sql.y" + case 523: /* expression ::= NK_LP expression NK_RP */ + case 611: /* boolean_primary ::= NK_LP boolean_value_expression NK_RP */ yytestcase(yyruleno==611); + case 727: /* subquery ::= NK_LP subquery NK_RP */ yytestcase(yyruleno==727); +#line 1093 "sql.y" +{ yylhsminor.yy826 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, releaseRawExprNode(pCxt, yymsp[-1].minor.yy826)); } +#line 7817 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; + break; + case 524: /* expression ::= NK_PLUS expr_or_subquery */ +#line 1094 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy722); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy722); - yylhsminor.yy722 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy722), releaseRawExprNode(pCxt, yymsp[0].minor.yy722))); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy826); + yylhsminor.yy826 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, releaseRawExprNode(pCxt, yymsp[0].minor.yy826)); } -#line 7819 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +#line 7826 "sql.c" + yymsp[-1].minor.yy826 = yylhsminor.yy826; break; - case 525: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ -#line 1115 "sql.y" + case 525: /* expression ::= NK_MINUS expr_or_subquery */ +#line 1098 "sql.y" { - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy722); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy722); - yylhsminor.yy722 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy722), releaseRawExprNode(pCxt, yymsp[0].minor.yy722))); + SToken t = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy826); + yylhsminor.yy826 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &t, createOperatorNode(pCxt, OP_TYPE_MINUS, releaseRawExprNode(pCxt, yymsp[0].minor.yy826), NULL)); } -#line 7829 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; - break; - case 528: /* column_reference ::= column_name */ -#line 1126 "sql.y" -{ yylhsminor.yy722 = createRawExprNode(pCxt, &yymsp[0].minor.yy659, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy659)); } #line 7835 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; + yymsp[-1].minor.yy826 = yylhsminor.yy826; break; - case 529: /* column_reference ::= table_name NK_DOT column_name */ + case 526: /* expression ::= expr_or_subquery NK_PLUS expr_or_subquery */ +#line 1102 "sql.y" +{ + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy826); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy826); + yylhsminor.yy826 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_ADD, releaseRawExprNode(pCxt, yymsp[-2].minor.yy826), releaseRawExprNode(pCxt, yymsp[0].minor.yy826))); + } +#line 7845 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; + break; + case 527: /* expression ::= expr_or_subquery NK_MINUS expr_or_subquery */ +#line 1107 "sql.y" +{ + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy826); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy826); + yylhsminor.yy826 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_SUB, releaseRawExprNode(pCxt, yymsp[-2].minor.yy826), releaseRawExprNode(pCxt, yymsp[0].minor.yy826))); + } +#line 7855 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; + break; + case 528: /* expression ::= expr_or_subquery NK_STAR expr_or_subquery */ +#line 1112 "sql.y" +{ + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy826); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy826); + yylhsminor.yy826 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_MULTI, releaseRawExprNode(pCxt, yymsp[-2].minor.yy826), releaseRawExprNode(pCxt, yymsp[0].minor.yy826))); + } +#line 7865 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; + break; + case 529: /* expression ::= expr_or_subquery NK_SLASH expr_or_subquery */ +#line 1117 "sql.y" +{ + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy826); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy826); + yylhsminor.yy826 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_DIV, releaseRawExprNode(pCxt, yymsp[-2].minor.yy826), releaseRawExprNode(pCxt, yymsp[0].minor.yy826))); + } +#line 7875 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; + break; + case 530: /* expression ::= expr_or_subquery NK_REM expr_or_subquery */ +#line 1122 "sql.y" +{ + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy826); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy826); + yylhsminor.yy826 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_REM, releaseRawExprNode(pCxt, yymsp[-2].minor.yy826), releaseRawExprNode(pCxt, yymsp[0].minor.yy826))); + } +#line 7885 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; + break; + case 531: /* expression ::= column_reference NK_ARROW NK_STRING */ #line 1127 "sql.y" -{ yylhsminor.yy722 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy659, createColumnNode(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy659)); } -#line 7841 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy826); + yylhsminor.yy826 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_JSON_GET_VALUE, releaseRawExprNode(pCxt, yymsp[-2].minor.yy826), createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[0].minor.yy0))); + } +#line 7894 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 530: /* column_reference ::= NK_ALIAS */ -#line 1128 "sql.y" -{ yylhsminor.yy722 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } -#line 7847 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; - break; - case 531: /* column_reference ::= table_name NK_DOT NK_ALIAS */ -#line 1129 "sql.y" -{ yylhsminor.yy722 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy0, createColumnNode(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy0)); } -#line 7853 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; - break; - case 532: /* pseudo_column ::= ROWTS */ - case 533: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==533); - case 535: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==535); - case 536: /* pseudo_column ::= QEND */ yytestcase(yyruleno==536); - case 537: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==537); - case 538: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==538); - case 539: /* pseudo_column ::= WEND */ yytestcase(yyruleno==539); - case 540: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==540); - case 541: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==541); - case 542: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==542); - case 543: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==543); - case 550: /* literal_func ::= NOW */ yytestcase(yyruleno==550); - case 551: /* literal_func ::= TODAY */ yytestcase(yyruleno==551); + case 532: /* expression ::= expr_or_subquery NK_BITAND expr_or_subquery */ #line 1131 "sql.y" -{ yylhsminor.yy722 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } -#line 7871 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; +{ + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy826); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy826); + yylhsminor.yy826 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy826), releaseRawExprNode(pCxt, yymsp[0].minor.yy826))); + } +#line 7904 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 534: /* pseudo_column ::= table_name NK_DOT TBNAME */ -#line 1133 "sql.y" -{ yylhsminor.yy722 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy659)))); } -#line 7877 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + case 533: /* expression ::= expr_or_subquery NK_BITOR expr_or_subquery */ +#line 1136 "sql.y" +{ + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy826); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy826); + yylhsminor.yy826 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, OP_TYPE_BIT_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy826), releaseRawExprNode(pCxt, yymsp[0].minor.yy826))); + } +#line 7914 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 544: /* function_expression ::= function_name NK_LP expression_list NK_RP */ - case 545: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==545); -#line 1144 "sql.y" -{ yylhsminor.yy722 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy659, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy659, yymsp[-1].minor.yy694)); } -#line 7884 "sql.c" - yymsp[-3].minor.yy722 = yylhsminor.yy722; - break; - case 546: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ - case 547: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name_default_len NK_RP */ yytestcase(yyruleno==547); + case 536: /* column_reference ::= column_name */ #line 1147 "sql.y" -{ yylhsminor.yy722 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy722), yymsp[-1].minor.yy154)); } -#line 7891 "sql.c" - yymsp[-5].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createRawExprNode(pCxt, &yymsp[0].minor.yy585, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy585)); } +#line 7920 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; break; - case 549: /* literal_func ::= noarg_func NK_LP NK_RP */ -#line 1153 "sql.y" -{ yylhsminor.yy722 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy659, NULL)); } -#line 7897 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + case 537: /* column_reference ::= table_name NK_DOT column_name */ +#line 1148 "sql.y" +{ yylhsminor.yy826 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy585, &yymsp[0].minor.yy585, createColumnNode(pCxt, &yymsp[-2].minor.yy585, &yymsp[0].minor.yy585)); } +#line 7926 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 565: /* star_func_para_list ::= NK_STAR */ -#line 1178 "sql.y" -{ yylhsminor.yy694 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } -#line 7903 "sql.c" - yymsp[0].minor.yy694 = yylhsminor.yy694; + case 538: /* column_reference ::= NK_ALIAS */ +#line 1149 "sql.y" +{ yylhsminor.yy826 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } +#line 7932 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; break; - case 570: /* star_func_para ::= table_name NK_DOT NK_STAR */ - case 655: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==655); -#line 1187 "sql.y" -{ yylhsminor.yy722 = createColumnNode(pCxt, &yymsp[-2].minor.yy659, &yymsp[0].minor.yy0); } -#line 7910 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + case 539: /* column_reference ::= table_name NK_DOT NK_ALIAS */ +#line 1150 "sql.y" +{ yylhsminor.yy826 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy585, &yymsp[0].minor.yy0, createColumnNode(pCxt, &yymsp[-2].minor.yy585, &yymsp[0].minor.yy0)); } +#line 7938 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 571: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ -#line 1190 "sql.y" -{ yylhsminor.yy722 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy694, yymsp[-1].minor.yy722)); } -#line 7916 "sql.c" - yymsp[-3].minor.yy722 = yylhsminor.yy722; + case 540: /* pseudo_column ::= ROWTS */ + case 541: /* pseudo_column ::= TBNAME */ yytestcase(yyruleno==541); + case 543: /* pseudo_column ::= QSTART */ yytestcase(yyruleno==543); + case 544: /* pseudo_column ::= QEND */ yytestcase(yyruleno==544); + case 545: /* pseudo_column ::= QDURATION */ yytestcase(yyruleno==545); + case 546: /* pseudo_column ::= WSTART */ yytestcase(yyruleno==546); + case 547: /* pseudo_column ::= WEND */ yytestcase(yyruleno==547); + case 548: /* pseudo_column ::= WDURATION */ yytestcase(yyruleno==548); + case 549: /* pseudo_column ::= IROWTS */ yytestcase(yyruleno==549); + case 550: /* pseudo_column ::= ISFILLED */ yytestcase(yyruleno==550); + case 551: /* pseudo_column ::= QTAGS */ yytestcase(yyruleno==551); + case 558: /* literal_func ::= NOW */ yytestcase(yyruleno==558); + case 559: /* literal_func ::= TODAY */ yytestcase(yyruleno==559); +#line 1152 "sql.y" +{ yylhsminor.yy826 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, NULL)); } +#line 7956 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; break; - case 572: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ -#line 1192 "sql.y" -{ yylhsminor.yy722 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy722), yymsp[-2].minor.yy694, yymsp[-1].minor.yy722)); } -#line 7922 "sql.c" - yymsp[-4].minor.yy722 = yylhsminor.yy722; + case 542: /* pseudo_column ::= table_name NK_DOT TBNAME */ +#line 1154 "sql.y" +{ yylhsminor.yy826 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy585, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[0].minor.yy0, createNodeList(pCxt, createValueNode(pCxt, TSDB_DATA_TYPE_BINARY, &yymsp[-2].minor.yy585)))); } +#line 7962 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 575: /* when_then_expr ::= WHEN common_expression THEN common_expression */ + case 552: /* function_expression ::= function_name NK_LP expression_list NK_RP */ + case 553: /* function_expression ::= star_func NK_LP star_func_para_list NK_RP */ yytestcase(yyruleno==553); +#line 1165 "sql.y" +{ yylhsminor.yy826 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy585, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-3].minor.yy585, yymsp[-1].minor.yy616)); } +#line 7969 "sql.c" + yymsp[-3].minor.yy826 = yylhsminor.yy826; + break; + case 554: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name NK_RP */ + case 555: /* function_expression ::= CAST NK_LP expr_or_subquery AS type_name_default_len NK_RP */ yytestcase(yyruleno==555); +#line 1168 "sql.y" +{ yylhsminor.yy826 = createRawExprNodeExt(pCxt, &yymsp[-5].minor.yy0, &yymsp[0].minor.yy0, createCastFunctionNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy826), yymsp[-1].minor.yy146)); } +#line 7976 "sql.c" + yymsp[-5].minor.yy826 = yylhsminor.yy826; + break; + case 557: /* literal_func ::= noarg_func NK_LP NK_RP */ +#line 1174 "sql.y" +{ yylhsminor.yy826 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy585, &yymsp[0].minor.yy0, createFunctionNode(pCxt, &yymsp[-2].minor.yy585, NULL)); } +#line 7982 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; + break; + case 573: /* star_func_para_list ::= NK_STAR */ #line 1199 "sql.y" -{ yymsp[-3].minor.yy722 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy722), releaseRawExprNode(pCxt, yymsp[0].minor.yy722)); } -#line 7928 "sql.c" +{ yylhsminor.yy616 = createNodeList(pCxt, createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0)); } +#line 7988 "sql.c" + yymsp[0].minor.yy616 = yylhsminor.yy616; break; - case 577: /* case_when_else_opt ::= ELSE common_expression */ -#line 1202 "sql.y" -{ yymsp[-1].minor.yy722 = releaseRawExprNode(pCxt, yymsp[0].minor.yy722); } -#line 7933 "sql.c" + case 578: /* star_func_para ::= table_name NK_DOT NK_STAR */ + case 663: /* select_item ::= table_name NK_DOT NK_STAR */ yytestcase(yyruleno==663); +#line 1208 "sql.y" +{ yylhsminor.yy826 = createColumnNode(pCxt, &yymsp[-2].minor.yy585, &yymsp[0].minor.yy0); } +#line 7995 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 578: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ - case 583: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==583); -#line 1205 "sql.y" -{ - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy722); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy722); - yylhsminor.yy722 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy1070, releaseRawExprNode(pCxt, yymsp[-2].minor.yy722), releaseRawExprNode(pCxt, yymsp[0].minor.yy722))); - } -#line 7943 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + case 579: /* case_when_expression ::= CASE when_then_list case_when_else_opt END */ +#line 1211 "sql.y" +{ yylhsminor.yy826 = createRawExprNodeExt(pCxt, &yymsp[-3].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, NULL, yymsp[-2].minor.yy616, yymsp[-1].minor.yy826)); } +#line 8001 "sql.c" + yymsp[-3].minor.yy826 = yylhsminor.yy826; break; - case 579: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ -#line 1212 "sql.y" -{ - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy722); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy722); - yylhsminor.yy722 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy722), releaseRawExprNode(pCxt, yymsp[-2].minor.yy722), releaseRawExprNode(pCxt, yymsp[0].minor.yy722))); - } -#line 7953 "sql.c" - yymsp[-4].minor.yy722 = yylhsminor.yy722; - break; - case 580: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ -#line 1218 "sql.y" -{ - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy722); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy722); - yylhsminor.yy722 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy722), releaseRawExprNode(pCxt, yymsp[-2].minor.yy722), releaseRawExprNode(pCxt, yymsp[0].minor.yy722))); - } -#line 7963 "sql.c" - yymsp[-5].minor.yy722 = yylhsminor.yy722; - break; - case 581: /* predicate ::= expr_or_subquery IS NULL */ -#line 1223 "sql.y" -{ - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy722); - yylhsminor.yy722 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy722), NULL)); - } -#line 7972 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; - break; - case 582: /* predicate ::= expr_or_subquery IS NOT NULL */ -#line 1227 "sql.y" -{ - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy722); - yylhsminor.yy722 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy722), NULL)); - } -#line 7981 "sql.c" - yymsp[-3].minor.yy722 = yylhsminor.yy722; - break; - case 584: /* compare_op ::= NK_LT */ -#line 1239 "sql.y" -{ yymsp[0].minor.yy1070 = OP_TYPE_LOWER_THAN; } -#line 7987 "sql.c" - break; - case 585: /* compare_op ::= NK_GT */ -#line 1240 "sql.y" -{ yymsp[0].minor.yy1070 = OP_TYPE_GREATER_THAN; } -#line 7992 "sql.c" - break; - case 586: /* compare_op ::= NK_LE */ -#line 1241 "sql.y" -{ yymsp[0].minor.yy1070 = OP_TYPE_LOWER_EQUAL; } -#line 7997 "sql.c" - break; - case 587: /* compare_op ::= NK_GE */ -#line 1242 "sql.y" -{ yymsp[0].minor.yy1070 = OP_TYPE_GREATER_EQUAL; } -#line 8002 "sql.c" - break; - case 588: /* compare_op ::= NK_NE */ -#line 1243 "sql.y" -{ yymsp[0].minor.yy1070 = OP_TYPE_NOT_EQUAL; } + case 580: /* case_when_expression ::= CASE common_expression when_then_list case_when_else_opt END */ +#line 1213 "sql.y" +{ yylhsminor.yy826 = createRawExprNodeExt(pCxt, &yymsp[-4].minor.yy0, &yymsp[0].minor.yy0, createCaseWhenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy826), yymsp[-2].minor.yy616, yymsp[-1].minor.yy826)); } #line 8007 "sql.c" + yymsp[-4].minor.yy826 = yylhsminor.yy826; break; - case 589: /* compare_op ::= NK_EQ */ + case 583: /* when_then_expr ::= WHEN common_expression THEN common_expression */ +#line 1220 "sql.y" +{ yymsp[-3].minor.yy826 = createWhenThenNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy826), releaseRawExprNode(pCxt, yymsp[0].minor.yy826)); } +#line 8013 "sql.c" + break; + case 585: /* case_when_else_opt ::= ELSE common_expression */ +#line 1223 "sql.y" +{ yymsp[-1].minor.yy826 = releaseRawExprNode(pCxt, yymsp[0].minor.yy826); } +#line 8018 "sql.c" + break; + case 586: /* predicate ::= expr_or_subquery compare_op expr_or_subquery */ + case 591: /* predicate ::= expr_or_subquery in_op in_predicate_value */ yytestcase(yyruleno==591); +#line 1226 "sql.y" +{ + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy826); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy826); + yylhsminor.yy826 = createRawExprNodeExt(pCxt, &s, &e, createOperatorNode(pCxt, yymsp[-1].minor.yy22, releaseRawExprNode(pCxt, yymsp[-2].minor.yy826), releaseRawExprNode(pCxt, yymsp[0].minor.yy826))); + } +#line 8028 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; + break; + case 587: /* predicate ::= expr_or_subquery BETWEEN expr_or_subquery AND expr_or_subquery */ +#line 1233 "sql.y" +{ + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-4].minor.yy826); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy826); + yylhsminor.yy826 = createRawExprNodeExt(pCxt, &s, &e, createBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-4].minor.yy826), releaseRawExprNode(pCxt, yymsp[-2].minor.yy826), releaseRawExprNode(pCxt, yymsp[0].minor.yy826))); + } +#line 8038 "sql.c" + yymsp[-4].minor.yy826 = yylhsminor.yy826; + break; + case 588: /* predicate ::= expr_or_subquery NOT BETWEEN expr_or_subquery AND expr_or_subquery */ +#line 1239 "sql.y" +{ + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-5].minor.yy826); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy826); + yylhsminor.yy826 = createRawExprNodeExt(pCxt, &s, &e, createNotBetweenAnd(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy826), releaseRawExprNode(pCxt, yymsp[-2].minor.yy826), releaseRawExprNode(pCxt, yymsp[0].minor.yy826))); + } +#line 8048 "sql.c" + yymsp[-5].minor.yy826 = yylhsminor.yy826; + break; + case 589: /* predicate ::= expr_or_subquery IS NULL */ #line 1244 "sql.y" -{ yymsp[0].minor.yy1070 = OP_TYPE_EQUAL; } -#line 8012 "sql.c" +{ + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy826); + yylhsminor.yy826 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NULL, releaseRawExprNode(pCxt, yymsp[-2].minor.yy826), NULL)); + } +#line 8057 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 590: /* compare_op ::= LIKE */ -#line 1245 "sql.y" -{ yymsp[0].minor.yy1070 = OP_TYPE_LIKE; } -#line 8017 "sql.c" - break; - case 591: /* compare_op ::= NOT LIKE */ -#line 1246 "sql.y" -{ yymsp[-1].minor.yy1070 = OP_TYPE_NOT_LIKE; } -#line 8022 "sql.c" - break; - case 592: /* compare_op ::= MATCH */ -#line 1247 "sql.y" -{ yymsp[0].minor.yy1070 = OP_TYPE_MATCH; } -#line 8027 "sql.c" - break; - case 593: /* compare_op ::= NMATCH */ + case 590: /* predicate ::= expr_or_subquery IS NOT NULL */ #line 1248 "sql.y" -{ yymsp[0].minor.yy1070 = OP_TYPE_NMATCH; } -#line 8032 "sql.c" +{ + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-3].minor.yy826); + yylhsminor.yy826 = createRawExprNodeExt(pCxt, &s, &yymsp[0].minor.yy0, createOperatorNode(pCxt, OP_TYPE_IS_NOT_NULL, releaseRawExprNode(pCxt, yymsp[-3].minor.yy826), NULL)); + } +#line 8066 "sql.c" + yymsp[-3].minor.yy826 = yylhsminor.yy826; break; - case 594: /* compare_op ::= CONTAINS */ -#line 1249 "sql.y" -{ yymsp[0].minor.yy1070 = OP_TYPE_JSON_CONTAINS; } -#line 8037 "sql.c" - break; - case 595: /* in_op ::= IN */ -#line 1253 "sql.y" -{ yymsp[0].minor.yy1070 = OP_TYPE_IN; } -#line 8042 "sql.c" - break; - case 596: /* in_op ::= NOT IN */ -#line 1254 "sql.y" -{ yymsp[-1].minor.yy1070 = OP_TYPE_NOT_IN; } -#line 8047 "sql.c" - break; - case 597: /* in_predicate_value ::= NK_LP literal_list NK_RP */ -#line 1256 "sql.y" -{ yylhsminor.yy722 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy694)); } -#line 8052 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; - break; - case 599: /* boolean_value_expression ::= NOT boolean_primary */ + case 592: /* compare_op ::= NK_LT */ #line 1260 "sql.y" -{ - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy722); - yylhsminor.yy722 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy722), NULL)); - } -#line 8061 "sql.c" - yymsp[-1].minor.yy722 = yylhsminor.yy722; +{ yymsp[0].minor.yy22 = OP_TYPE_LOWER_THAN; } +#line 8072 "sql.c" break; - case 600: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ -#line 1265 "sql.y" -{ - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy722); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy722); - yylhsminor.yy722 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy722), releaseRawExprNode(pCxt, yymsp[0].minor.yy722))); - } -#line 8071 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + case 593: /* compare_op ::= NK_GT */ +#line 1261 "sql.y" +{ yymsp[0].minor.yy22 = OP_TYPE_GREATER_THAN; } +#line 8077 "sql.c" break; - case 601: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ -#line 1271 "sql.y" -{ - SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy722); - SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy722); - yylhsminor.yy722 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy722), releaseRawExprNode(pCxt, yymsp[0].minor.yy722))); - } -#line 8081 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + case 594: /* compare_op ::= NK_LE */ +#line 1262 "sql.y" +{ yymsp[0].minor.yy22 = OP_TYPE_LOWER_EQUAL; } +#line 8082 "sql.c" break; - case 609: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ -#line 1289 "sql.y" -{ yylhsminor.yy722 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, JOIN_STYPE_NONE, yymsp[-2].minor.yy722, yymsp[0].minor.yy722, NULL); } + case 595: /* compare_op ::= NK_GE */ +#line 1263 "sql.y" +{ yymsp[0].minor.yy22 = OP_TYPE_GREATER_EQUAL; } #line 8087 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; break; - case 612: /* table_primary ::= table_name alias_opt */ -#line 1295 "sql.y" -{ yylhsminor.yy722 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy659, &yymsp[0].minor.yy659); } -#line 8093 "sql.c" - yymsp[-1].minor.yy722 = yylhsminor.yy722; + case 596: /* compare_op ::= NK_NE */ +#line 1264 "sql.y" +{ yymsp[0].minor.yy22 = OP_TYPE_NOT_EQUAL; } +#line 8092 "sql.c" break; - case 613: /* table_primary ::= db_name NK_DOT table_name alias_opt */ -#line 1296 "sql.y" -{ yylhsminor.yy722 = createRealTableNode(pCxt, &yymsp[-3].minor.yy659, &yymsp[-1].minor.yy659, &yymsp[0].minor.yy659); } -#line 8099 "sql.c" - yymsp[-3].minor.yy722 = yylhsminor.yy722; + case 597: /* compare_op ::= NK_EQ */ +#line 1265 "sql.y" +{ yymsp[0].minor.yy22 = OP_TYPE_EQUAL; } +#line 8097 "sql.c" break; - case 614: /* table_primary ::= subquery alias_opt */ -#line 1297 "sql.y" -{ yylhsminor.yy722 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy722), &yymsp[0].minor.yy659); } -#line 8105 "sql.c" - yymsp[-1].minor.yy722 = yylhsminor.yy722; + case 598: /* compare_op ::= LIKE */ +#line 1266 "sql.y" +{ yymsp[0].minor.yy22 = OP_TYPE_LIKE; } +#line 8102 "sql.c" break; - case 616: /* alias_opt ::= */ -#line 1302 "sql.y" -{ yymsp[1].minor.yy659 = nil_token; } -#line 8111 "sql.c" + case 599: /* compare_op ::= NOT LIKE */ +#line 1267 "sql.y" +{ yymsp[-1].minor.yy22 = OP_TYPE_NOT_LIKE; } +#line 8107 "sql.c" break; - case 618: /* alias_opt ::= AS table_alias */ -#line 1304 "sql.y" -{ yymsp[-1].minor.yy659 = yymsp[0].minor.yy659; } -#line 8116 "sql.c" + case 600: /* compare_op ::= MATCH */ +#line 1268 "sql.y" +{ yymsp[0].minor.yy22 = OP_TYPE_MATCH; } +#line 8112 "sql.c" break; - case 619: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ - case 620: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==620); -#line 1306 "sql.y" -{ yymsp[-2].minor.yy722 = yymsp[-1].minor.yy722; } + case 601: /* compare_op ::= NMATCH */ +#line 1269 "sql.y" +{ yymsp[0].minor.yy22 = OP_TYPE_NMATCH; } +#line 8117 "sql.c" + break; + case 602: /* compare_op ::= CONTAINS */ +#line 1270 "sql.y" +{ yymsp[0].minor.yy22 = OP_TYPE_JSON_CONTAINS; } #line 8122 "sql.c" break; - case 621: /* joined_table ::= table_reference join_type join_subtype JOIN table_reference join_on_clause_opt window_offset_clause_opt jlimit_clause_opt */ -#line 1312 "sql.y" -{ - yylhsminor.yy722 = createJoinTableNode(pCxt, yymsp[-6].minor.yy92, yymsp[-5].minor.yy534, yymsp[-7].minor.yy722, yymsp[-3].minor.yy722, yymsp[-2].minor.yy722); - yylhsminor.yy722 = addWindowOffsetClause(pCxt, yylhsminor.yy722, yymsp[-1].minor.yy722); - yylhsminor.yy722 = addJLimitClause(pCxt, yylhsminor.yy722, yymsp[0].minor.yy722); - } -#line 8131 "sql.c" - yymsp[-7].minor.yy722 = yylhsminor.yy722; + case 603: /* in_op ::= IN */ +#line 1274 "sql.y" +{ yymsp[0].minor.yy22 = OP_TYPE_IN; } +#line 8127 "sql.c" break; - case 622: /* join_type ::= */ -#line 1320 "sql.y" -{ yymsp[1].minor.yy92 = JOIN_TYPE_INNER; } + case 604: /* in_op ::= NOT IN */ +#line 1275 "sql.y" +{ yymsp[-1].minor.yy22 = OP_TYPE_NOT_IN; } +#line 8132 "sql.c" + break; + case 605: /* in_predicate_value ::= NK_LP literal_list NK_RP */ +#line 1277 "sql.y" +{ yylhsminor.yy826 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, createNodeListNode(pCxt, yymsp[-1].minor.yy616)); } #line 8137 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 623: /* join_type ::= INNER */ -#line 1321 "sql.y" -{ yymsp[0].minor.yy92 = JOIN_TYPE_INNER; } -#line 8142 "sql.c" + case 607: /* boolean_value_expression ::= NOT boolean_primary */ +#line 1281 "sql.y" +{ + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy826); + yylhsminor.yy826 = createRawExprNodeExt(pCxt, &yymsp[-1].minor.yy0, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_NOT, releaseRawExprNode(pCxt, yymsp[0].minor.yy826), NULL)); + } +#line 8146 "sql.c" + yymsp[-1].minor.yy826 = yylhsminor.yy826; break; - case 624: /* join_type ::= LEFT */ -#line 1322 "sql.y" -{ yymsp[0].minor.yy92 = JOIN_TYPE_LEFT; } -#line 8147 "sql.c" + case 608: /* boolean_value_expression ::= boolean_value_expression OR boolean_value_expression */ +#line 1286 "sql.y" +{ + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy826); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy826); + yylhsminor.yy826 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_OR, releaseRawExprNode(pCxt, yymsp[-2].minor.yy826), releaseRawExprNode(pCxt, yymsp[0].minor.yy826))); + } +#line 8156 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 625: /* join_type ::= RIGHT */ -#line 1323 "sql.y" -{ yymsp[0].minor.yy92 = JOIN_TYPE_RIGHT; } -#line 8152 "sql.c" + case 609: /* boolean_value_expression ::= boolean_value_expression AND boolean_value_expression */ +#line 1292 "sql.y" +{ + SToken s = getTokenFromRawExprNode(pCxt, yymsp[-2].minor.yy826); + SToken e = getTokenFromRawExprNode(pCxt, yymsp[0].minor.yy826); + yylhsminor.yy826 = createRawExprNodeExt(pCxt, &s, &e, createLogicConditionNode(pCxt, LOGIC_COND_TYPE_AND, releaseRawExprNode(pCxt, yymsp[-2].minor.yy826), releaseRawExprNode(pCxt, yymsp[0].minor.yy826))); + } +#line 8166 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 626: /* join_type ::= FULL */ -#line 1324 "sql.y" -{ yymsp[0].minor.yy92 = JOIN_TYPE_FULL; } -#line 8157 "sql.c" - break; - case 627: /* join_subtype ::= */ -#line 1328 "sql.y" -{ yymsp[1].minor.yy534 = JOIN_STYPE_NONE; } -#line 8162 "sql.c" - break; - case 628: /* join_subtype ::= OUTER */ -#line 1329 "sql.y" -{ yymsp[0].minor.yy534 = JOIN_STYPE_OUTER; } -#line 8167 "sql.c" - break; - case 629: /* join_subtype ::= SEMI */ -#line 1330 "sql.y" -{ yymsp[0].minor.yy534 = JOIN_STYPE_SEMI; } + case 617: /* table_reference_list ::= table_reference_list NK_COMMA table_reference */ +#line 1310 "sql.y" +{ yylhsminor.yy826 = createJoinTableNode(pCxt, JOIN_TYPE_INNER, JOIN_STYPE_NONE, yymsp[-2].minor.yy826, yymsp[0].minor.yy826, NULL); } #line 8172 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 630: /* join_subtype ::= ANTI */ -#line 1331 "sql.y" -{ yymsp[0].minor.yy534 = JOIN_STYPE_ANTI; } -#line 8177 "sql.c" + case 620: /* table_primary ::= table_name alias_opt */ +#line 1316 "sql.y" +{ yylhsminor.yy826 = createRealTableNode(pCxt, NULL, &yymsp[-1].minor.yy585, &yymsp[0].minor.yy585); } +#line 8178 "sql.c" + yymsp[-1].minor.yy826 = yylhsminor.yy826; break; - case 631: /* join_subtype ::= ASOF */ -#line 1332 "sql.y" -{ yymsp[0].minor.yy534 = JOIN_STYPE_ASOF; } -#line 8182 "sql.c" + case 621: /* table_primary ::= db_name NK_DOT table_name alias_opt */ +#line 1317 "sql.y" +{ yylhsminor.yy826 = createRealTableNode(pCxt, &yymsp[-3].minor.yy585, &yymsp[-1].minor.yy585, &yymsp[0].minor.yy585); } +#line 8184 "sql.c" + yymsp[-3].minor.yy826 = yylhsminor.yy826; break; - case 632: /* join_subtype ::= WINDOW */ + case 622: /* table_primary ::= subquery alias_opt */ +#line 1318 "sql.y" +{ yylhsminor.yy826 = createTempTableNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy826), &yymsp[0].minor.yy585); } +#line 8190 "sql.c" + yymsp[-1].minor.yy826 = yylhsminor.yy826; + break; + case 624: /* alias_opt ::= */ +#line 1323 "sql.y" +{ yymsp[1].minor.yy585 = nil_token; } +#line 8196 "sql.c" + break; + case 626: /* alias_opt ::= AS table_alias */ +#line 1325 "sql.y" +{ yymsp[-1].minor.yy585 = yymsp[0].minor.yy585; } +#line 8201 "sql.c" + break; + case 627: /* parenthesized_joined_table ::= NK_LP joined_table NK_RP */ + case 628: /* parenthesized_joined_table ::= NK_LP parenthesized_joined_table NK_RP */ yytestcase(yyruleno==628); +#line 1327 "sql.y" +{ yymsp[-2].minor.yy826 = yymsp[-1].minor.yy826; } +#line 8207 "sql.c" + break; + case 629: /* joined_table ::= table_reference join_type join_subtype JOIN table_reference join_on_clause_opt window_offset_clause_opt jlimit_clause_opt */ #line 1333 "sql.y" -{ yymsp[0].minor.yy534 = JOIN_STYPE_WIN; } -#line 8187 "sql.c" +{ + yylhsminor.yy826 = createJoinTableNode(pCxt, yymsp[-6].minor.yy190, yymsp[-5].minor.yy26, yymsp[-7].minor.yy826, yymsp[-3].minor.yy826, yymsp[-2].minor.yy826); + yylhsminor.yy826 = addWindowOffsetClause(pCxt, yylhsminor.yy826, yymsp[-1].minor.yy826); + yylhsminor.yy826 = addJLimitClause(pCxt, yylhsminor.yy826, yymsp[0].minor.yy826); + } +#line 8216 "sql.c" + yymsp[-7].minor.yy826 = yylhsminor.yy826; break; - case 636: /* window_offset_clause_opt ::= WINDOW_OFFSET NK_LP window_offset_literal NK_COMMA window_offset_literal NK_RP */ -#line 1340 "sql.y" -{ yymsp[-5].minor.yy722 = createWindowOffsetNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy722), releaseRawExprNode(pCxt, yymsp[-1].minor.yy722)); } -#line 8192 "sql.c" + case 630: /* join_type ::= */ +#line 1341 "sql.y" +{ yymsp[1].minor.yy190 = JOIN_TYPE_INNER; } +#line 8222 "sql.c" break; - case 637: /* window_offset_literal ::= NK_VARIABLE */ + case 631: /* join_type ::= INNER */ #line 1342 "sql.y" -{ yylhsminor.yy722 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createTimeOffsetValueNode(pCxt, &yymsp[0].minor.yy0)); } -#line 8197 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; +{ yymsp[0].minor.yy190 = JOIN_TYPE_INNER; } +#line 8227 "sql.c" break; - case 638: /* window_offset_literal ::= NK_MINUS NK_VARIABLE */ + case 632: /* join_type ::= LEFT */ #line 1343 "sql.y" +{ yymsp[0].minor.yy190 = JOIN_TYPE_LEFT; } +#line 8232 "sql.c" + break; + case 633: /* join_type ::= RIGHT */ +#line 1344 "sql.y" +{ yymsp[0].minor.yy190 = JOIN_TYPE_RIGHT; } +#line 8237 "sql.c" + break; + case 634: /* join_type ::= FULL */ +#line 1345 "sql.y" +{ yymsp[0].minor.yy190 = JOIN_TYPE_FULL; } +#line 8242 "sql.c" + break; + case 635: /* join_subtype ::= */ +#line 1349 "sql.y" +{ yymsp[1].minor.yy26 = JOIN_STYPE_NONE; } +#line 8247 "sql.c" + break; + case 636: /* join_subtype ::= OUTER */ +#line 1350 "sql.y" +{ yymsp[0].minor.yy26 = JOIN_STYPE_OUTER; } +#line 8252 "sql.c" + break; + case 637: /* join_subtype ::= SEMI */ +#line 1351 "sql.y" +{ yymsp[0].minor.yy26 = JOIN_STYPE_SEMI; } +#line 8257 "sql.c" + break; + case 638: /* join_subtype ::= ANTI */ +#line 1352 "sql.y" +{ yymsp[0].minor.yy26 = JOIN_STYPE_ANTI; } +#line 8262 "sql.c" + break; + case 639: /* join_subtype ::= ASOF */ +#line 1353 "sql.y" +{ yymsp[0].minor.yy26 = JOIN_STYPE_ASOF; } +#line 8267 "sql.c" + break; + case 640: /* join_subtype ::= WINDOW */ +#line 1354 "sql.y" +{ yymsp[0].minor.yy26 = JOIN_STYPE_WIN; } +#line 8272 "sql.c" + break; + case 644: /* window_offset_clause_opt ::= WINDOW_OFFSET NK_LP window_offset_literal NK_COMMA window_offset_literal NK_RP */ +#line 1361 "sql.y" +{ yymsp[-5].minor.yy826 = createWindowOffsetNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy826), releaseRawExprNode(pCxt, yymsp[-1].minor.yy826)); } +#line 8277 "sql.c" + break; + case 645: /* window_offset_literal ::= NK_VARIABLE */ +#line 1363 "sql.y" +{ yylhsminor.yy826 = createRawExprNode(pCxt, &yymsp[0].minor.yy0, createTimeOffsetValueNode(pCxt, &yymsp[0].minor.yy0)); } +#line 8282 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; + break; + case 646: /* window_offset_literal ::= NK_MINUS NK_VARIABLE */ +#line 1364 "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.yy722 = createRawExprNode(pCxt, &t, createTimeOffsetValueNode(pCxt, &t)); + yylhsminor.yy826 = createRawExprNode(pCxt, &t, createTimeOffsetValueNode(pCxt, &t)); } -#line 8207 "sql.c" - yymsp[-1].minor.yy722 = yylhsminor.yy722; +#line 8292 "sql.c" + yymsp[-1].minor.yy826 = yylhsminor.yy826; break; - case 640: /* jlimit_clause_opt ::= JLIMIT NK_INTEGER */ - case 711: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ yytestcase(yyruleno==711); - case 715: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==715); -#line 1350 "sql.y" -{ yymsp[-1].minor.yy722 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } -#line 8215 "sql.c" - break; - case 641: /* 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 1356 "sql.y" -{ - yymsp[-13].minor.yy722 = createSelectStmt(pCxt, yymsp[-11].minor.yy897, yymsp[-9].minor.yy694, yymsp[-8].minor.yy722, yymsp[-12].minor.yy694); - yymsp[-13].minor.yy722 = setSelectStmtTagMode(pCxt, yymsp[-13].minor.yy722, yymsp[-10].minor.yy897); - yymsp[-13].minor.yy722 = addWhereClause(pCxt, yymsp[-13].minor.yy722, yymsp[-7].minor.yy722); - yymsp[-13].minor.yy722 = addPartitionByClause(pCxt, yymsp[-13].minor.yy722, yymsp[-6].minor.yy694); - yymsp[-13].minor.yy722 = addWindowClauseClause(pCxt, yymsp[-13].minor.yy722, yymsp[-2].minor.yy722); - yymsp[-13].minor.yy722 = addGroupByClause(pCxt, yymsp[-13].minor.yy722, yymsp[-1].minor.yy694); - yymsp[-13].minor.yy722 = addHavingClause(pCxt, yymsp[-13].minor.yy722, yymsp[0].minor.yy722); - yymsp[-13].minor.yy722 = addRangeClause(pCxt, yymsp[-13].minor.yy722, yymsp[-5].minor.yy722); - yymsp[-13].minor.yy722 = addEveryClause(pCxt, yymsp[-13].minor.yy722, yymsp[-4].minor.yy722); - yymsp[-13].minor.yy722 = addFillClause(pCxt, yymsp[-13].minor.yy722, yymsp[-3].minor.yy722); - } -#line 8231 "sql.c" - break; - case 642: /* hint_list ::= */ + case 648: /* jlimit_clause_opt ::= JLIMIT NK_INTEGER */ + case 719: /* slimit_clause_opt ::= SLIMIT NK_INTEGER */ yytestcase(yyruleno==719); + case 723: /* limit_clause_opt ::= LIMIT NK_INTEGER */ yytestcase(yyruleno==723); #line 1371 "sql.y" -{ yymsp[1].minor.yy694 = createHintNodeList(pCxt, NULL); } -#line 8236 "sql.c" +{ yymsp[-1].minor.yy826 = createLimitNode(pCxt, &yymsp[0].minor.yy0, NULL); } +#line 8300 "sql.c" break; - case 643: /* hint_list ::= NK_HINT */ -#line 1372 "sql.y" -{ yylhsminor.yy694 = createHintNodeList(pCxt, &yymsp[0].minor.yy0); } -#line 8241 "sql.c" - yymsp[0].minor.yy694 = yylhsminor.yy694; - break; - case 648: /* set_quantifier_opt ::= ALL */ -#line 1383 "sql.y" -{ yymsp[0].minor.yy897 = false; } -#line 8247 "sql.c" - break; - case 651: /* select_item ::= NK_STAR */ -#line 1390 "sql.y" -{ yylhsminor.yy722 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } -#line 8252 "sql.c" - yymsp[0].minor.yy722 = yylhsminor.yy722; - break; - case 653: /* select_item ::= common_expression column_alias */ - case 663: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==663); -#line 1392 "sql.y" -{ yylhsminor.yy722 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy722), &yymsp[0].minor.yy659); } -#line 8259 "sql.c" - yymsp[-1].minor.yy722 = yylhsminor.yy722; - break; - case 654: /* select_item ::= common_expression AS column_alias */ - case 664: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==664); -#line 1393 "sql.y" -{ yylhsminor.yy722 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy722), &yymsp[0].minor.yy659); } -#line 8266 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; - break; - case 659: /* partition_by_clause_opt ::= PARTITION BY partition_list */ - case 689: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==689); - case 709: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==709); -#line 1402 "sql.y" -{ yymsp[-2].minor.yy694 = yymsp[0].minor.yy694; } -#line 8274 "sql.c" - break; - case 666: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ -#line 1415 "sql.y" -{ yymsp[-5].minor.yy722 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy722), releaseRawExprNode(pCxt, yymsp[-1].minor.yy722)); } -#line 8279 "sql.c" - break; - case 667: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ -#line 1416 "sql.y" -{ yymsp[-3].minor.yy722 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy722)); } -#line 8284 "sql.c" - break; - case 668: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ -#line 1418 "sql.y" -{ yymsp[-5].minor.yy722 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy722), NULL, yymsp[-1].minor.yy722, yymsp[0].minor.yy722); } -#line 8289 "sql.c" - break; - case 669: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ -#line 1422 "sql.y" -{ yymsp[-7].minor.yy722 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy722), releaseRawExprNode(pCxt, yymsp[-3].minor.yy722), yymsp[-1].minor.yy722, yymsp[0].minor.yy722); } -#line 8294 "sql.c" - break; - case 670: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ -#line 1424 "sql.y" -{ yymsp[-6].minor.yy722 = createEventWindowNode(pCxt, yymsp[-3].minor.yy722, yymsp[0].minor.yy722); } -#line 8299 "sql.c" - break; - case 671: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ -#line 1426 "sql.y" -{ yymsp[-3].minor.yy722 = createCountWindowNode(pCxt, &yymsp[-1].minor.yy0, &yymsp[-1].minor.yy0); } -#line 8304 "sql.c" - break; - case 672: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ -#line 1428 "sql.y" -{ yymsp[-5].minor.yy722 = createCountWindowNode(pCxt, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0); } -#line 8309 "sql.c" - break; - case 679: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ -#line 1438 "sql.y" -{ yymsp[-3].minor.yy722 = createFillNode(pCxt, yymsp[-1].minor.yy94, NULL); } -#line 8314 "sql.c" - break; - case 680: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ -#line 1439 "sql.y" -{ yymsp[-5].minor.yy722 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy694)); } -#line 8319 "sql.c" - break; - case 681: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ -#line 1440 "sql.y" -{ yymsp[-5].minor.yy722 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy694)); } -#line 8324 "sql.c" - break; - case 682: /* fill_mode ::= NONE */ -#line 1444 "sql.y" -{ yymsp[0].minor.yy94 = FILL_MODE_NONE; } -#line 8329 "sql.c" - break; - case 683: /* fill_mode ::= PREV */ -#line 1445 "sql.y" -{ yymsp[0].minor.yy94 = FILL_MODE_PREV; } -#line 8334 "sql.c" - break; - case 684: /* fill_mode ::= NULL */ -#line 1446 "sql.y" -{ yymsp[0].minor.yy94 = FILL_MODE_NULL; } -#line 8339 "sql.c" - break; - case 685: /* fill_mode ::= NULL_F */ -#line 1447 "sql.y" -{ yymsp[0].minor.yy94 = FILL_MODE_NULL_F; } -#line 8344 "sql.c" - break; - case 686: /* fill_mode ::= LINEAR */ -#line 1448 "sql.y" -{ yymsp[0].minor.yy94 = FILL_MODE_LINEAR; } -#line 8349 "sql.c" - break; - case 687: /* fill_mode ::= NEXT */ -#line 1449 "sql.y" -{ yymsp[0].minor.yy94 = FILL_MODE_NEXT; } -#line 8354 "sql.c" - break; - case 690: /* group_by_list ::= expr_or_subquery */ -#line 1458 "sql.y" -{ yylhsminor.yy694 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy722))); } -#line 8359 "sql.c" - yymsp[0].minor.yy694 = yylhsminor.yy694; - break; - case 691: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ -#line 1459 "sql.y" -{ yylhsminor.yy694 = addNodeToList(pCxt, yymsp[-2].minor.yy694, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy722))); } -#line 8365 "sql.c" - yymsp[-2].minor.yy694 = yylhsminor.yy694; - break; - case 695: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ -#line 1466 "sql.y" -{ yymsp[-5].minor.yy722 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy722), releaseRawExprNode(pCxt, yymsp[-1].minor.yy722)); } -#line 8371 "sql.c" - break; - case 696: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ -#line 1468 "sql.y" -{ yymsp[-3].minor.yy722 = createInterpTimePoint(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy722)); } -#line 8376 "sql.c" - break; - case 699: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ -#line 1475 "sql.y" + case 649: /* 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 1377 "sql.y" { - yylhsminor.yy722 = addOrderByClause(pCxt, yymsp[-3].minor.yy722, yymsp[-2].minor.yy694); - yylhsminor.yy722 = addSlimitClause(pCxt, yylhsminor.yy722, yymsp[-1].minor.yy722); - yylhsminor.yy722 = addLimitClause(pCxt, yylhsminor.yy722, yymsp[0].minor.yy722); + yymsp[-13].minor.yy826 = createSelectStmt(pCxt, yymsp[-11].minor.yy983, yymsp[-9].minor.yy616, yymsp[-8].minor.yy826, yymsp[-12].minor.yy616); + yymsp[-13].minor.yy826 = setSelectStmtTagMode(pCxt, yymsp[-13].minor.yy826, yymsp[-10].minor.yy983); + yymsp[-13].minor.yy826 = addWhereClause(pCxt, yymsp[-13].minor.yy826, yymsp[-7].minor.yy826); + yymsp[-13].minor.yy826 = addPartitionByClause(pCxt, yymsp[-13].minor.yy826, yymsp[-6].minor.yy616); + yymsp[-13].minor.yy826 = addWindowClauseClause(pCxt, yymsp[-13].minor.yy826, yymsp[-2].minor.yy826); + yymsp[-13].minor.yy826 = addGroupByClause(pCxt, yymsp[-13].minor.yy826, yymsp[-1].minor.yy616); + yymsp[-13].minor.yy826 = addHavingClause(pCxt, yymsp[-13].minor.yy826, yymsp[0].minor.yy826); + yymsp[-13].minor.yy826 = addRangeClause(pCxt, yymsp[-13].minor.yy826, yymsp[-5].minor.yy826); + yymsp[-13].minor.yy826 = addEveryClause(pCxt, yymsp[-13].minor.yy826, yymsp[-4].minor.yy826); + yymsp[-13].minor.yy826 = addFillClause(pCxt, yymsp[-13].minor.yy826, yymsp[-3].minor.yy826); } -#line 8385 "sql.c" - yymsp[-3].minor.yy722 = yylhsminor.yy722; +#line 8316 "sql.c" break; - case 702: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ -#line 1485 "sql.y" -{ yylhsminor.yy722 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy722, yymsp[0].minor.yy722); } -#line 8391 "sql.c" - yymsp[-3].minor.yy722 = yylhsminor.yy722; + case 650: /* hint_list ::= */ +#line 1392 "sql.y" +{ yymsp[1].minor.yy616 = createHintNodeList(pCxt, NULL); } +#line 8321 "sql.c" break; - case 703: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ -#line 1487 "sql.y" -{ yylhsminor.yy722 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy722, yymsp[0].minor.yy722); } -#line 8397 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + case 651: /* hint_list ::= NK_HINT */ +#line 1393 "sql.y" +{ yylhsminor.yy616 = createHintNodeList(pCxt, &yymsp[0].minor.yy0); } +#line 8326 "sql.c" + yymsp[0].minor.yy616 = yylhsminor.yy616; break; - case 712: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ - case 716: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==716); -#line 1502 "sql.y" -{ yymsp[-3].minor.yy722 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } + case 656: /* set_quantifier_opt ::= ALL */ +#line 1404 "sql.y" +{ yymsp[0].minor.yy983 = false; } +#line 8332 "sql.c" + break; + case 659: /* select_item ::= NK_STAR */ +#line 1411 "sql.y" +{ yylhsminor.yy826 = createColumnNode(pCxt, NULL, &yymsp[0].minor.yy0); } +#line 8337 "sql.c" + yymsp[0].minor.yy826 = yylhsminor.yy826; + break; + case 661: /* select_item ::= common_expression column_alias */ + case 671: /* partition_item ::= expr_or_subquery column_alias */ yytestcase(yyruleno==671); +#line 1413 "sql.y" +{ yylhsminor.yy826 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy826), &yymsp[0].minor.yy585); } +#line 8344 "sql.c" + yymsp[-1].minor.yy826 = yylhsminor.yy826; + break; + case 662: /* select_item ::= common_expression AS column_alias */ + case 672: /* partition_item ::= expr_or_subquery AS column_alias */ yytestcase(yyruleno==672); +#line 1414 "sql.y" +{ yylhsminor.yy826 = setProjectionAlias(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy826), &yymsp[0].minor.yy585); } +#line 8351 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; + break; + case 667: /* partition_by_clause_opt ::= PARTITION BY partition_list */ + case 697: /* group_by_clause_opt ::= GROUP BY group_by_list */ yytestcase(yyruleno==697); + case 717: /* order_by_clause_opt ::= ORDER BY sort_specification_list */ yytestcase(yyruleno==717); +#line 1423 "sql.y" +{ yymsp[-2].minor.yy616 = yymsp[0].minor.yy616; } +#line 8359 "sql.c" + break; + case 674: /* twindow_clause_opt ::= SESSION NK_LP column_reference NK_COMMA interval_sliding_duration_literal NK_RP */ +#line 1436 "sql.y" +{ yymsp[-5].minor.yy826 = createSessionWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy826), releaseRawExprNode(pCxt, yymsp[-1].minor.yy826)); } +#line 8364 "sql.c" + break; + case 675: /* twindow_clause_opt ::= STATE_WINDOW NK_LP expr_or_subquery NK_RP */ +#line 1437 "sql.y" +{ yymsp[-3].minor.yy826 = createStateWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy826)); } +#line 8369 "sql.c" + break; + case 676: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ +#line 1439 "sql.y" +{ yymsp[-5].minor.yy826 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy826), NULL, yymsp[-1].minor.yy826, yymsp[0].minor.yy826); } +#line 8374 "sql.c" + break; + case 677: /* twindow_clause_opt ::= INTERVAL NK_LP interval_sliding_duration_literal NK_COMMA interval_sliding_duration_literal NK_RP sliding_opt fill_opt */ +#line 1443 "sql.y" +{ yymsp[-7].minor.yy826 = createIntervalWindowNode(pCxt, releaseRawExprNode(pCxt, yymsp[-5].minor.yy826), releaseRawExprNode(pCxt, yymsp[-3].minor.yy826), yymsp[-1].minor.yy826, yymsp[0].minor.yy826); } +#line 8379 "sql.c" + break; + case 678: /* twindow_clause_opt ::= EVENT_WINDOW START WITH search_condition END WITH search_condition */ +#line 1445 "sql.y" +{ yymsp[-6].minor.yy826 = createEventWindowNode(pCxt, yymsp[-3].minor.yy826, yymsp[0].minor.yy826); } +#line 8384 "sql.c" + break; + case 679: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_RP */ +#line 1447 "sql.y" +{ yymsp[-3].minor.yy826 = createCountWindowNode(pCxt, &yymsp[-1].minor.yy0, &yymsp[-1].minor.yy0); } +#line 8389 "sql.c" + break; + case 680: /* twindow_clause_opt ::= COUNT_WINDOW NK_LP NK_INTEGER NK_COMMA NK_INTEGER NK_RP */ +#line 1449 "sql.y" +{ yymsp[-5].minor.yy826 = createCountWindowNode(pCxt, &yymsp[-3].minor.yy0, &yymsp[-1].minor.yy0); } +#line 8394 "sql.c" + break; + case 687: /* fill_opt ::= FILL NK_LP fill_mode NK_RP */ +#line 1459 "sql.y" +{ yymsp[-3].minor.yy826 = createFillNode(pCxt, yymsp[-1].minor.yy1082, NULL); } +#line 8399 "sql.c" + break; + case 688: /* fill_opt ::= FILL NK_LP VALUE NK_COMMA expression_list NK_RP */ +#line 1460 "sql.y" +{ yymsp[-5].minor.yy826 = createFillNode(pCxt, FILL_MODE_VALUE, createNodeListNode(pCxt, yymsp[-1].minor.yy616)); } #line 8404 "sql.c" break; - case 713: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ - case 717: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==717); -#line 1503 "sql.y" -{ yymsp[-3].minor.yy722 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } -#line 8410 "sql.c" + case 689: /* fill_opt ::= FILL NK_LP VALUE_F NK_COMMA expression_list NK_RP */ +#line 1461 "sql.y" +{ yymsp[-5].minor.yy826 = createFillNode(pCxt, FILL_MODE_VALUE_F, createNodeListNode(pCxt, yymsp[-1].minor.yy616)); } +#line 8409 "sql.c" break; - case 718: /* subquery ::= NK_LP query_expression NK_RP */ -#line 1511 "sql.y" -{ yylhsminor.yy722 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy722); } -#line 8415 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + case 690: /* fill_mode ::= NONE */ +#line 1465 "sql.y" +{ yymsp[0].minor.yy1082 = FILL_MODE_NONE; } +#line 8414 "sql.c" break; - case 723: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ -#line 1525 "sql.y" -{ yylhsminor.yy722 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy722), yymsp[-1].minor.yy708, yymsp[0].minor.yy707); } -#line 8421 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + case 691: /* fill_mode ::= PREV */ +#line 1466 "sql.y" +{ yymsp[0].minor.yy1082 = FILL_MODE_PREV; } +#line 8419 "sql.c" break; - case 724: /* ordering_specification_opt ::= */ -#line 1529 "sql.y" -{ yymsp[1].minor.yy708 = ORDER_ASC; } -#line 8427 "sql.c" + case 692: /* fill_mode ::= NULL */ +#line 1467 "sql.y" +{ yymsp[0].minor.yy1082 = FILL_MODE_NULL; } +#line 8424 "sql.c" break; - case 725: /* ordering_specification_opt ::= ASC */ -#line 1530 "sql.y" -{ yymsp[0].minor.yy708 = ORDER_ASC; } -#line 8432 "sql.c" + case 693: /* fill_mode ::= NULL_F */ +#line 1468 "sql.y" +{ yymsp[0].minor.yy1082 = FILL_MODE_NULL_F; } +#line 8429 "sql.c" break; - case 726: /* ordering_specification_opt ::= DESC */ -#line 1531 "sql.y" -{ yymsp[0].minor.yy708 = ORDER_DESC; } -#line 8437 "sql.c" + case 694: /* fill_mode ::= LINEAR */ +#line 1469 "sql.y" +{ yymsp[0].minor.yy1082 = FILL_MODE_LINEAR; } +#line 8434 "sql.c" break; - case 727: /* null_ordering_opt ::= */ -#line 1535 "sql.y" -{ yymsp[1].minor.yy707 = NULL_ORDER_DEFAULT; } -#line 8442 "sql.c" + case 695: /* fill_mode ::= NEXT */ +#line 1470 "sql.y" +{ yymsp[0].minor.yy1082 = FILL_MODE_NEXT; } +#line 8439 "sql.c" break; - case 728: /* null_ordering_opt ::= NULLS FIRST */ -#line 1536 "sql.y" -{ yymsp[-1].minor.yy707 = NULL_ORDER_FIRST; } -#line 8447 "sql.c" + case 698: /* group_by_list ::= expr_or_subquery */ +#line 1479 "sql.y" +{ yylhsminor.yy616 = createNodeList(pCxt, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy826))); } +#line 8444 "sql.c" + yymsp[0].minor.yy616 = yylhsminor.yy616; break; - case 729: /* null_ordering_opt ::= NULLS LAST */ -#line 1537 "sql.y" -{ yymsp[-1].minor.yy707 = NULL_ORDER_LAST; } -#line 8452 "sql.c" + case 699: /* group_by_list ::= group_by_list NK_COMMA expr_or_subquery */ +#line 1480 "sql.y" +{ yylhsminor.yy616 = addNodeToList(pCxt, yymsp[-2].minor.yy616, createGroupingSetNode(pCxt, releaseRawExprNode(pCxt, yymsp[0].minor.yy826))); } +#line 8450 "sql.c" + yymsp[-2].minor.yy616 = yylhsminor.yy616; break; - case 732: /* column_options ::= column_options ENCODE NK_STRING */ -#line 1545 "sql.y" -{ yylhsminor.yy722 = setColumnOptions(pCxt, yymsp[-2].minor.yy722, COLUMN_OPTION_ENCODE, &yymsp[0].minor.yy0); } -#line 8457 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + case 703: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_COMMA expr_or_subquery NK_RP */ +#line 1487 "sql.y" +{ yymsp[-5].minor.yy826 = createInterpTimeRange(pCxt, releaseRawExprNode(pCxt, yymsp[-3].minor.yy826), releaseRawExprNode(pCxt, yymsp[-1].minor.yy826)); } +#line 8456 "sql.c" break; - case 733: /* column_options ::= column_options COMPRESS NK_STRING */ + case 704: /* range_opt ::= RANGE NK_LP expr_or_subquery NK_RP */ +#line 1489 "sql.y" +{ yymsp[-3].minor.yy826 = createInterpTimePoint(pCxt, releaseRawExprNode(pCxt, yymsp[-1].minor.yy826)); } +#line 8461 "sql.c" + break; + case 707: /* query_expression ::= query_simple order_by_clause_opt slimit_clause_opt limit_clause_opt */ +#line 1496 "sql.y" +{ + yylhsminor.yy826 = addOrderByClause(pCxt, yymsp[-3].minor.yy826, yymsp[-2].minor.yy616); + yylhsminor.yy826 = addSlimitClause(pCxt, yylhsminor.yy826, yymsp[-1].minor.yy826); + yylhsminor.yy826 = addLimitClause(pCxt, yylhsminor.yy826, yymsp[0].minor.yy826); + } +#line 8470 "sql.c" + yymsp[-3].minor.yy826 = yylhsminor.yy826; + break; + case 710: /* union_query_expression ::= query_simple_or_subquery UNION ALL query_simple_or_subquery */ +#line 1506 "sql.y" +{ yylhsminor.yy826 = createSetOperator(pCxt, SET_OP_TYPE_UNION_ALL, yymsp[-3].minor.yy826, yymsp[0].minor.yy826); } +#line 8476 "sql.c" + yymsp[-3].minor.yy826 = yylhsminor.yy826; + break; + case 711: /* union_query_expression ::= query_simple_or_subquery UNION query_simple_or_subquery */ +#line 1508 "sql.y" +{ yylhsminor.yy826 = createSetOperator(pCxt, SET_OP_TYPE_UNION, yymsp[-2].minor.yy826, yymsp[0].minor.yy826); } +#line 8482 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; + break; + case 720: /* slimit_clause_opt ::= SLIMIT NK_INTEGER SOFFSET NK_INTEGER */ + case 724: /* limit_clause_opt ::= LIMIT NK_INTEGER OFFSET NK_INTEGER */ yytestcase(yyruleno==724); +#line 1523 "sql.y" +{ yymsp[-3].minor.yy826 = createLimitNode(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0); } +#line 8489 "sql.c" + break; + case 721: /* slimit_clause_opt ::= SLIMIT NK_INTEGER NK_COMMA NK_INTEGER */ + case 725: /* limit_clause_opt ::= LIMIT NK_INTEGER NK_COMMA NK_INTEGER */ yytestcase(yyruleno==725); +#line 1524 "sql.y" +{ yymsp[-3].minor.yy826 = createLimitNode(pCxt, &yymsp[0].minor.yy0, &yymsp[-2].minor.yy0); } +#line 8495 "sql.c" + break; + case 726: /* subquery ::= NK_LP query_expression NK_RP */ +#line 1532 "sql.y" +{ yylhsminor.yy826 = createRawExprNodeExt(pCxt, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-1].minor.yy826); } +#line 8500 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; + break; + case 731: /* sort_specification ::= expr_or_subquery ordering_specification_opt null_ordering_opt */ #line 1546 "sql.y" -{ yylhsminor.yy722 = setColumnOptions(pCxt, yymsp[-2].minor.yy722, COLUMN_OPTION_COMPRESS, &yymsp[0].minor.yy0); } -#line 8463 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; +{ yylhsminor.yy826 = createOrderByExprNode(pCxt, releaseRawExprNode(pCxt, yymsp[-2].minor.yy826), yymsp[-1].minor.yy88, yymsp[0].minor.yy71); } +#line 8506 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; - case 734: /* column_options ::= column_options LEVEL NK_STRING */ -#line 1547 "sql.y" -{ yylhsminor.yy722 = setColumnOptions(pCxt, yymsp[-2].minor.yy722, COLUMN_OPTION_LEVEL, &yymsp[0].minor.yy0); } -#line 8469 "sql.c" - yymsp[-2].minor.yy722 = yylhsminor.yy722; + case 732: /* ordering_specification_opt ::= */ +#line 1550 "sql.y" +{ yymsp[1].minor.yy88 = ORDER_ASC; } +#line 8512 "sql.c" + break; + case 733: /* ordering_specification_opt ::= ASC */ +#line 1551 "sql.y" +{ yymsp[0].minor.yy88 = ORDER_ASC; } +#line 8517 "sql.c" + break; + case 734: /* ordering_specification_opt ::= DESC */ +#line 1552 "sql.y" +{ yymsp[0].minor.yy88 = ORDER_DESC; } +#line 8522 "sql.c" + break; + case 735: /* null_ordering_opt ::= */ +#line 1556 "sql.y" +{ yymsp[1].minor.yy71 = NULL_ORDER_DEFAULT; } +#line 8527 "sql.c" + break; + case 736: /* null_ordering_opt ::= NULLS FIRST */ +#line 1557 "sql.y" +{ yymsp[-1].minor.yy71 = NULL_ORDER_FIRST; } +#line 8532 "sql.c" + break; + case 737: /* null_ordering_opt ::= NULLS LAST */ +#line 1558 "sql.y" +{ yymsp[-1].minor.yy71 = NULL_ORDER_LAST; } +#line 8537 "sql.c" + break; + case 740: /* column_options ::= column_options ENCODE NK_STRING */ +#line 1566 "sql.y" +{ yylhsminor.yy826 = setColumnOptions(pCxt, yymsp[-2].minor.yy826, COLUMN_OPTION_ENCODE, &yymsp[0].minor.yy0); } +#line 8542 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; + break; + case 741: /* column_options ::= column_options COMPRESS NK_STRING */ +#line 1567 "sql.y" +{ yylhsminor.yy826 = setColumnOptions(pCxt, yymsp[-2].minor.yy826, COLUMN_OPTION_COMPRESS, &yymsp[0].minor.yy0); } +#line 8548 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; + break; + case 742: /* column_options ::= column_options LEVEL NK_STRING */ +#line 1568 "sql.y" +{ yylhsminor.yy826 = setColumnOptions(pCxt, yymsp[-2].minor.yy826, COLUMN_OPTION_LEVEL, &yymsp[0].minor.yy0); } +#line 8554 "sql.c" + yymsp[-2].minor.yy826 = yylhsminor.yy826; break; default: break; @@ -8540,7 +8625,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 8543 "sql.c" +#line 8628 "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 85e466c7ba..4af207254a 100644 --- a/source/libs/qcom/src/querymsg.c +++ b/source/libs/qcom/src/querymsg.c @@ -305,6 +305,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}; @@ -693,6 +745,32 @@ 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; queryBuildMsg[TMSG_INDEX(TDMT_MND_TABLE_META)] = queryBuildTableMetaReqMsg; @@ -708,6 +786,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; @@ -723,6 +804,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/libs/stream/inc/streamInt.h b/source/libs/stream/inc/streamInt.h index ff56ae76b0..d1cc4fb710 100644 --- a/source/libs/stream/inc/streamInt.h +++ b/source/libs/stream/inc/streamInt.h @@ -87,6 +87,11 @@ struct SStreamQueue { int8_t status; }; +typedef enum { + EXEC_CONTINUE = 0x0, + EXEC_AFTER_IDLE = 0x1, +} EExtractDataCode; + extern void* streamTimer; extern int32_t streamBackendId; extern int32_t streamBackendCfWrapperId; @@ -125,7 +130,7 @@ void streamTaskSetRetryInfoForLaunch(SHistoryTaskInfo* pInfo); int32_t streamTaskResetTimewindowFilter(SStreamTask* pTask); void streamClearChkptReadyMsg(SStreamTask* pTask); -int32_t streamTaskGetDataFromInputQ(SStreamTask* pTask, SStreamQueueItem** pInput, int32_t* numOfBlocks, +EExtractDataCode streamTaskGetDataFromInputQ(SStreamTask* pTask, SStreamQueueItem** pInput, int32_t* numOfBlocks, int32_t* blockSize); int32_t streamQueueItemGetSize(const SStreamQueueItem* pItem); void streamQueueItemIncSize(const SStreamQueueItem* pItem, int32_t size); diff --git a/source/libs/stream/src/streamExec.c b/source/libs/stream/src/streamExec.c index 24d1bf7603..d55382be83 100644 --- a/source/libs/stream/src/streamExec.c +++ b/source/libs/stream/src/streamExec.c @@ -20,6 +20,7 @@ #define STREAM_RESULT_DUMP_THRESHOLD 300 #define STREAM_RESULT_DUMP_SIZE_THRESHOLD (1048576 * 1) // 1MiB result data #define STREAM_SCAN_HISTORY_TIMESLICE 1000 // 1000 ms +#define MIN_INVOKE_INTERVAL 50 // 50ms static int32_t streamTransferStateDoPrepare(SStreamTask* pTask); @@ -580,16 +581,21 @@ int32_t doStreamExecTask(SStreamTask* pTask) { return 0; } - if (taosGetTimestampMs() - pTask->status.lastExecTs < 50) { + if (taosGetTimestampMs() - pTask->status.lastExecTs < MIN_INVOKE_INTERVAL) { stDebug("s-task:%s invoke with high frequency, idle and retry exec in 50ms", id); - setTaskSchedInfo(pTask, 50); + setTaskSchedInfo(pTask, MIN_INVOKE_INTERVAL); return 0; } - /*int32_t code = */ streamTaskGetDataFromInputQ(pTask, &pInput, &numOfBlocks, &blockSize); - if (pInput == NULL) { - ASSERT(numOfBlocks == 0); - return 0; + EExtractDataCode ret = streamTaskGetDataFromInputQ(pTask, &pInput, &numOfBlocks, &blockSize); + if (ret == EXEC_AFTER_IDLE) { + ASSERT(pInput == NULL && numOfBlocks == 0); + setTaskSchedInfo(pTask, MIN_INVOKE_INTERVAL); + } else { + if (pInput == NULL) { + ASSERT(numOfBlocks == 0); + return 0; + } } // dispatch checkpoint msg to all downstream tasks diff --git a/source/libs/stream/src/streamQueue.c b/source/libs/stream/src/streamQueue.c index 0936d410bf..9f79501471 100644 --- a/source/libs/stream/src/streamQueue.c +++ b/source/libs/stream/src/streamQueue.c @@ -145,7 +145,7 @@ const char* streamQueueItemGetTypeStr(int32_t type) { } } -int32_t streamTaskGetDataFromInputQ(SStreamTask* pTask, SStreamQueueItem** pInput, int32_t* numOfBlocks, +EExtractDataCode streamTaskGetDataFromInputQ(SStreamTask* pTask, SStreamQueueItem** pInput, int32_t* numOfBlocks, int32_t* blockSize) { const char* id = pTask->id.idStr; int32_t taskLevel = pTask->info.taskLevel; @@ -157,13 +157,13 @@ int32_t streamTaskGetDataFromInputQ(SStreamTask* pTask, SStreamQueueItem** pInpu // no available token in bucket for sink task, let's wait for a little bit if (taskLevel == TASK_LEVEL__SINK && (!streamTaskExtractAvailableToken(pTask->outputInfo.pTokenBucket, id))) { stDebug("s-task:%s no available token in bucket for sink data, wait for 10ms", id); - return TSDB_CODE_SUCCESS; + return EXEC_AFTER_IDLE; } while (1) { if (streamTaskShouldPause(pTask) || streamTaskShouldStop(pTask)) { stDebug("s-task:%s task should pause, extract input blocks:%d", id, *numOfBlocks); - return TSDB_CODE_SUCCESS; + return EXEC_CONTINUE; } SStreamQueueItem* qItem = streamQueueNextItem(pTask->inputq.queue); @@ -179,7 +179,7 @@ int32_t streamTaskGetDataFromInputQ(SStreamTask* pTask, SStreamQueueItem** pInpu streamTaskPutbackToken(pTask->outputInfo.pTokenBucket); } - return TSDB_CODE_SUCCESS; + return EXEC_CONTINUE; } // do not merge blocks for sink node and check point data block @@ -196,7 +196,7 @@ int32_t streamTaskGetDataFromInputQ(SStreamTask* pTask, SStreamQueueItem** pInpu *blockSize = 0; *numOfBlocks = 1; *pInput = qItem; - return TSDB_CODE_SUCCESS; + return EXEC_CONTINUE; } else { // previous existed blocks needs to be handle, before handle the checkpoint msg block stDebug("s-task:%s %s msg extracted, handle previous blocks, numOfBlocks:%d", id, p, *numOfBlocks); *blockSize = streamQueueItemGetSize(*pInput); @@ -205,7 +205,7 @@ int32_t streamTaskGetDataFromInputQ(SStreamTask* pTask, SStreamQueueItem** pInpu } streamQueueProcessFail(pTask->inputq.queue); - return TSDB_CODE_SUCCESS; + return EXEC_CONTINUE; } } else { if (*pInput == NULL) { @@ -226,7 +226,7 @@ int32_t streamTaskGetDataFromInputQ(SStreamTask* pTask, SStreamQueueItem** pInpu } streamQueueProcessFail(pTask->inputq.queue); - return TSDB_CODE_SUCCESS; + return EXEC_CONTINUE; } *pInput = newRet; @@ -243,7 +243,7 @@ int32_t streamTaskGetDataFromInputQ(SStreamTask* pTask, SStreamQueueItem** pInpu streamTaskConsumeQuota(pTask->outputInfo.pTokenBucket, *blockSize); } - return TSDB_CODE_SUCCESS; + return EXEC_CONTINUE; } } } diff --git a/source/libs/stream/src/streamStart.c b/source/libs/stream/src/streamStart.c index 3abca307da..276997e5a8 100644 --- a/source/libs/stream/src/streamStart.c +++ b/source/libs/stream/src/streamStart.c @@ -109,7 +109,7 @@ static void doReExecScanhistory(void* param, void* tmrId) { } } -int32_t streamReExecScanHistoryFuture(SStreamTask* pTask, int32_t idleDuration) { +int32_t streamExecScanHistoryInFuture(SStreamTask* pTask, int32_t idleDuration) { int32_t numOfTicks = idleDuration / SCANHISTORY_IDLE_TIME_SLICE; if (numOfTicks <= 0) { numOfTicks = 1; diff --git a/source/util/src/terror.c b/source/util/src/terror.c index 58c743770f..5947652096 100644 --- a/source/util/src/terror.c +++ b/source/util/src/terror.c @@ -326,9 +326,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") @@ -692,6 +695,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/source/util/src/tsched.c b/source/util/src/tsched.c index 645910dfbc..603547e30b 100644 --- a/source/util/src/tsched.c +++ b/source/util/src/tsched.c @@ -210,6 +210,7 @@ int taosScheduleTask(void *queueScheduler, SSchedMsg *pMsg) { void taosCleanUpScheduler(void *param) { SSchedQueue *pSched = (SSchedQueue *)param; if (pSched == NULL) return; + if (pSched->stop) return; uDebug("start to cleanup %s schedQsueue", pSched->label); @@ -240,6 +241,7 @@ void taosCleanUpScheduler(void *param) { if (pSched->queue) taosMemoryFree(pSched->queue); if (pSched->qthread) taosMemoryFree(pSched->qthread); + pSched->numOfThreads = 0; // taosMemoryFree(pSched); } 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 45ef0d7632..29664759b7 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -114,6 +114,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())